cleaner common gui code
This commit is contained in:
parent
3e4383e131
commit
656a1e15d4
39
gui.go
39
gui.go
|
@ -7,6 +7,8 @@ import (
|
|||
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/fhelp"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
var argGui ArgsGui
|
||||
|
@ -16,8 +18,7 @@ This struct can be used with the go-arg package. These
|
|||
are the generic default command line arguments for the 'GUI' package
|
||||
*/
|
||||
type ArgsGui struct {
|
||||
GuiPluginHack string `arg:"--gui-check-plugin" help:"hack to verify GO plugins load"`
|
||||
GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
|
||||
GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -54,6 +55,8 @@ func postMustParse(s string) string {
|
|||
return "true"
|
||||
}
|
||||
return "false"
|
||||
case "DEFAULT":
|
||||
return "gocui"
|
||||
case "FILE":
|
||||
return "someplugin"
|
||||
default:
|
||||
|
@ -62,7 +65,15 @@ func postMustParse(s string) string {
|
|||
return "unknown"
|
||||
}
|
||||
|
||||
func Gui() *gui.Node {
|
||||
var prepGui *GuiPrep
|
||||
|
||||
type GuiPrep struct {
|
||||
rootn *gui.Node
|
||||
hidden bool // don't update the toolkits when it's hidden
|
||||
Auto func([]string)
|
||||
}
|
||||
|
||||
func Gui() *GuiPrep {
|
||||
if len(os.Args) > 1 && os.Args[1] == "--gui-check-plugin" {
|
||||
gui.TestPluginAndExitNew(os.Args[2])
|
||||
os.Exit(0)
|
||||
|
@ -70,5 +81,25 @@ func Gui() *gui.Node {
|
|||
arg.Register(&argGui)
|
||||
gui.InitArg()
|
||||
|
||||
return gui.PreInit(postMustParse)
|
||||
prepGui = new(GuiPrep)
|
||||
prepGui.rootn = gui.PreInit(postMustParse)
|
||||
|
||||
return prepGui
|
||||
}
|
||||
|
||||
func (g *GuiPrep) Start() error {
|
||||
// me.myGui.InitEmbed(resources)
|
||||
if pname, err := g.rootn.Default(); err != nil {
|
||||
if !fhelp.BuildPlugin("gocui") {
|
||||
log.Info("You can't run the forge GUI since the plugins did not build", pname)
|
||||
return nil
|
||||
}
|
||||
if err := g.rootn.LoadToolkitNew("gocui"); err != nil {
|
||||
log.Info("The plugins built, but still failed to load", pname)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
log.Info("The plugins built and loaded!", pname)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue