2021-11-02 23:44:28 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-11-04 08:44:01 -05:00
|
|
|
"log"
|
2021-11-02 23:44:28 -05:00
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.wit.org/wit/gui"
|
|
|
|
"github.com/gobuffalo/packr"
|
|
|
|
)
|
|
|
|
|
2021-11-04 08:44:01 -05:00
|
|
|
// origlog "log"
|
|
|
|
// "git.wit.org/jcarr/log"
|
2021-11-04 08:20:46 -05:00
|
|
|
// "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2021-11-02 23:44:28 -05:00
|
|
|
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
|
|
|
|
var BUILDTIME string // this is passed in as an ldflag
|
|
|
|
|
|
|
|
var closed bool = false
|
|
|
|
var loopsleep time.Duration = 100 // in tenths of seconds
|
|
|
|
var username string
|
|
|
|
var hostname string
|
|
|
|
var geom string = "120x30+500+500"
|
|
|
|
|
|
|
|
var debugTest bool = false
|
|
|
|
|
|
|
|
// var xterm = []string{"nohup", "xterm", "-geometry", geom}
|
|
|
|
var useFirefox bool = true
|
|
|
|
var firefox = []string{"firefox", "--new-window"}
|
|
|
|
var packrBox packr.Box
|
|
|
|
|
|
|
|
func customExit(n *gui.Node) {
|
2021-11-04 08:44:01 -05:00
|
|
|
log.Println("Should Exit Here")
|
2021-11-02 23:44:28 -05:00
|
|
|
closed = true
|
|
|
|
log.Println("")
|
|
|
|
log.Println("CLEAN EXIT")
|
|
|
|
log.Println("")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2021-11-04 08:20:46 -05:00
|
|
|
type game struct {
|
|
|
|
w, h int
|
|
|
|
|
|
|
|
levelNum int
|
|
|
|
}
|
|
|
|
|
2021-11-02 23:44:28 -05:00
|
|
|
func main() {
|
2021-11-04 08:20:46 -05:00
|
|
|
g := &game{
|
|
|
|
w: 5,
|
|
|
|
h: 20,
|
|
|
|
}
|
|
|
|
|
|
|
|
parseFlags(g)
|
|
|
|
|
2021-11-02 23:44:28 -05:00
|
|
|
// 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")
|
|
|
|
|
2021-11-03 22:20:49 -05:00
|
|
|
// runs the GO profiler in a goroutine
|
2021-11-02 23:44:28 -05:00
|
|
|
go pprofMain()
|
|
|
|
|
|
|
|
go gui.Main(initGUI)
|
2021-11-03 22:20:49 -05:00
|
|
|
|
2021-11-02 23:44:28 -05:00
|
|
|
time.Sleep(2 * time.Second)
|
|
|
|
gui.Queue(delayedTabs)
|
|
|
|
go systrayMain()
|
2021-11-03 22:20:49 -05:00
|
|
|
|
2021-11-02 23:44:28 -05:00
|
|
|
watchWindows()
|
|
|
|
}
|
|
|
|
|
|
|
|
// only os.Exit() on close of the main Window
|
|
|
|
// TODO: Change to only exit from systray(?)
|
|
|
|
func initGUI() {
|
2021-11-04 08:20:46 -05:00
|
|
|
g := &gui.GuiConfig{
|
|
|
|
Exit: customExit,
|
|
|
|
Stretchy: false,
|
|
|
|
}
|
|
|
|
log.Println("g =", g)
|
2021-11-02 23:44:28 -05:00
|
|
|
gui.Config.Exit = customExit
|
2021-11-04 02:49:12 -05:00
|
|
|
gui.Config.Stretchy = false
|
2021-11-02 23:44:28 -05:00
|
|
|
mainWindow(nil)
|
|
|
|
gui.Config.Exit = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func delayedTabs() {
|
|
|
|
log.Println("delayedTabs() could have added a tab here\n")
|
|
|
|
// jcarrWindow.AddTab("delayed tab", nil)
|
|
|
|
}
|
2021-11-03 23:55:58 -05:00
|
|
|
|
|
|
|
func normalWindowClose(n *gui.Node) {
|
2021-11-04 08:44:01 -05:00
|
|
|
log.Println("TODO: close this window correctly and empty the node")
|
2021-11-03 23:55:58 -05:00
|
|
|
n.Dump()
|
|
|
|
name := n.Name
|
|
|
|
// TODO: this is probably some sort of terrible and wrong memory leak
|
|
|
|
delete(gui.Data.NodeMap, name)
|
|
|
|
}
|