GOOD: add flags, start using vim-go
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0f8ed0da1f
commit
1acd29f3b6
|
@ -0,0 +1,14 @@
|
|||
//go:build !js || !wasm
|
||||
// +build !js !wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
)
|
||||
|
||||
func parseFlags(g *game) {
|
||||
flag.IntVar(&g.w, "width", 100, "Enable width mode")
|
||||
flag.IntVar(&g.h, "noclip", 50, "Enable noclip mode")
|
||||
flag.Parse()
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
func parseFlags(g *game) {
|
||||
g.disableEsc = true
|
||||
}
|
26
main.go
26
main.go
|
@ -1,17 +1,17 @@
|
|||
package main
|
||||
|
||||
import origlog "log"
|
||||
|
||||
import (
|
||||
"git.wit.org/jcarr/log"
|
||||
origlog "log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.wit.org/jcarr/log"
|
||||
"git.wit.org/wit/gui"
|
||||
// "github.com/davecgh/go-spew/spew"
|
||||
"github.com/gobuffalo/packr"
|
||||
)
|
||||
|
||||
// "github.com/davecgh/go-spew/spew"
|
||||
|
||||
var GITCOMMIT string // this is passed in as an ldflag
|
||||
var GOVERSION string // this is passed in as an ldflag
|
||||
var VERSION string // this is passed in as an ldflag
|
||||
|
@ -39,6 +39,12 @@ func customExit(n *gui.Node) {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
type game struct {
|
||||
w, h int
|
||||
|
||||
levelNum int
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Println("starting my Control Panel")
|
||||
log.Println("GOVERSION =", GOVERSION)
|
||||
|
@ -46,6 +52,13 @@ func main() {
|
|||
|
||||
log.Println("packr ./resources box")
|
||||
|
||||
g := &game{
|
||||
w: 5,
|
||||
h: 20,
|
||||
}
|
||||
|
||||
parseFlags(g)
|
||||
|
||||
// This puts all the files in that directory in the binary
|
||||
// This directory includes the default config file if there is not already one
|
||||
packrBox = packr.NewBox("./resources")
|
||||
|
@ -65,6 +78,11 @@ func main() {
|
|||
// only os.Exit() on close of the main Window
|
||||
// TODO: Change to only exit from systray(?)
|
||||
func initGUI() {
|
||||
g := &gui.GuiConfig{
|
||||
Exit: customExit,
|
||||
Stretchy: false,
|
||||
}
|
||||
log.Println("g =", g)
|
||||
gui.Config.Exit = customExit
|
||||
gui.Config.Stretchy = false
|
||||
mainWindow(nil)
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
package main
|
||||
|
||||
import "log"
|
||||
import "os"
|
||||
import "bufio"
|
||||
import "strings"
|
||||
import "errors"
|
||||
import "git.wit.org/wit/gui"
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.wit.org/wit/gui"
|
||||
)
|
||||
|
||||
func aptPackagesWindow(w *gui.Node) {
|
||||
var aptoutput *gui.Node
|
||||
var aptNode *gui.Node
|
||||
var filename string
|
||||
|
||||
if (w == nil) {
|
||||
if w == nil {
|
||||
gui.Config.Title = "apt configuration and package installer"
|
||||
gui.Config.Width = 1600
|
||||
gui.Config.Height = 800
|
||||
|
@ -31,7 +34,7 @@ func aptPackagesWindow(w *gui.Node) {
|
|||
aptNode.SetText("bin/install-default-packages.sh")
|
||||
filename = "bin/install-default-packages.sh"
|
||||
b, _ := packrBox.FindString(filename)
|
||||
if (aptoutput != nil) {
|
||||
if aptoutput != nil {
|
||||
aptoutput.SetText(b)
|
||||
}
|
||||
log.Println("ENDED GetText() HOSTNAME =", filename)
|
||||
|
@ -44,7 +47,7 @@ func aptPackagesWindow(w *gui.Node) {
|
|||
aptNode.SetText("bin/apt-file.sh")
|
||||
filename = "bin/apt-file.sh"
|
||||
b, _ := packrBox.FindString(filename)
|
||||
if (aptoutput != nil) {
|
||||
if aptoutput != nil {
|
||||
aptoutput.SetText(b)
|
||||
}
|
||||
log.Println("ENDED GetText() HOSTNAME =", filename)
|
||||
|
@ -66,7 +69,7 @@ func aptPackagesWindow(w *gui.Node) {
|
|||
log.Println("STARTED HOSTNAME")
|
||||
filename = aptNode.GetText()
|
||||
b, _ := packrBox.FindString(filename)
|
||||
if (aptoutput != nil) {
|
||||
if aptoutput != nil {
|
||||
aptoutput.SetText(b)
|
||||
}
|
||||
log.Println("ENDED GetText() HOSTNAME =", filename)
|
||||
|
@ -99,7 +102,7 @@ func aptPackagesWindow(w *gui.Node) {
|
|||
|
||||
gui.Config.Stretchy = true
|
||||
gNode.AddButton("set output", func(*gui.Node) {
|
||||
if (aptoutput != nil) {
|
||||
if aptoutput != nil {
|
||||
aptoutput.SetText("wow")
|
||||
aptoutput.SetMargined(false)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue