summaryrefslogtreecommitdiff
path: root/gui.go
blob: eed96d263cf69550b41407802240484bf26668a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package prep

// initializes logging and command line options

/*
var argGui ArgsGui


// 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 {
	GuiPlugin  string `arg:"--gui"              help:"select the plugin (andlabs,gocui,etc)"`
	GuiVerbose bool   `arg:"--gui-verbose"      help:"enable all logging"`
}

// after go-args MustParse & user configuration
// the gui package can pull out the final settings and init() the GO Plugin GUI Toolkit
func postMustParse(s string) string {
	switch s {
	case "PluginHack":
	case "VERBOSE":
		if argGui.GuiVerbose == true {
			return "true"
		}
		return "false"
	case "DEFAULT":
		if argGui.GuiPlugin != "" {
			return argGui.GuiPlugin
		}
		return "gocui"
	case "FILE":
		return "someplugin"
	default:
		return ""
	}
	return "unknown"
}

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)
	}
	arg.Register(&argGui)

	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
}
*/