-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (47 loc) · 1.6 KB
/
main.go
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
package main
import (
"flag"
"fmt"
"github.com/dresswithpockets/go-vgui"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"os"
)
func getPrintUsage(flagSet *flag.FlagSet) func() {
return func() {
fmt.Printf("Usage: %s [options...] <hudpath>\n", os.Args[0])
flagSet.PrintDefaults()
}
}
func main() {
launchSettings := LaunchSettings{}
// parse arguments for our app state
flagSet := flag.NewFlagSet("", flag.ExitOnError)
flagSet.Usage = getPrintUsage(flagSet)
flagSet.BoolVar(&launchSettings.readonly, "readonly", false, "Launch editor in readonly mode. Huds cannot be altered or saved in this mode, only viewed.")
flagSet.BoolVar(&launchSettings.verbose, "verbose", false, "Detailed logging.")
_ = flagSet.Parse(os.Args[1:])
if flagSet.NArg() == 0 {
fmt.Fprintln(os.Stderr, "Missing positional argument 'hudpath'")
flagSet.Usage()
os.Exit(1)
}
launchSettings.path = flagSet.Arg(0)
if !launchSettings.readonly {
// TODO: give link to issue with more information
fmt.Println("Edit mode is not supported yet. Launch with -readonly flag.")
return
}
hudSourceProvider := &vgui.HudFileSourceProvider{Root: launchSettings.path}
// the state of the application
app := &App{
&launchSettings,
&SourceVguiProvider{map[string]*vgui.Object{}, hudSourceProvider},
&SourcePictureProvider{map[string]pixel.Picture{}, hudSourceProvider},
&ControlProvider{},
&RootControl{},
nil,
nil,
}
pixelgl.Run(app.run)
}