-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoptionsMenu.go
97 lines (94 loc) · 2.69 KB
/
optionsMenu.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"github.com/20kdc/CCUpdaterUI/design"
"github.com/20kdc/CCUpdaterUI/frenyard"
"github.com/20kdc/CCUpdaterUI/frenyard/framework"
"github.com/20kdc/CCUpdaterUI/middle"
"time"
)
// ShowOptionsMenu shows the options menu (run game, credits)
func (app *upApplication) ShowOptionsMenu(back framework.ButtonBehavior) {
backHere := func () {
app.GSLeftwards()
app.ShowOptionsMenu(back)
}
listSlots := []framework.FlexboxSlot{
{
Element: design.ListItem(design.ListItemDetails{
Text: "Run Game",
Subtext: "Attempts to run the game",
Click: func () {
backupFrameTime := frenyard.TargetFrameTime
app.GSRightwards()
app.ShowWaiter("Running...", func (progress func (string)) {
progress("Trying to run game...")
time.Sleep(time.Second * 1)
proc, err := middle.Launch(app.gameInstance.Base())
if err != nil {
progress("Unable to launch CrossCode.\nIf on a Unix-like, try adding a 'run' script to the directory containing 'assets'.\nIf on Windows, ensure said directory contains nw.exe or CrossCode.exe for usage by the game.")
time.Sleep(time.Second * 5)
} else {
progress("Game running...")
app.upQueued <- func () {
frenyard.TargetFrameTime = 1
}
proc.Wait()
app.upQueued <- func () {
frenyard.TargetFrameTime = backupFrameTime
}
// give the system time to 'calm down'
time.Sleep(time.Second * 2)
}
}, func () {
// make sure in case of threading shenanigans
frenyard.TargetFrameTime = backupFrameTime
app.GSLeftwards()
app.ShowPrimaryView()
})
},
}),
},
{
Element: design.ListItem(design.ListItemDetails{
Text: "Install .ccmod",
Subtext: "Installs a .ccmod file",
Click: func () {
app.GSRightwards()
app.ShowPackedModFinder(backHere, func (path string) {
app.ShowInitPackedModManager(backHere, path)
}, middle.BrowserVFSPathDefault)
},
}),
},
{
Element: design.ListItem(design.ListItemDetails{
Text: "Credits",
Subtext: "See the various components that make up CCUpdaterUI",
Click: func () {
app.GSRightwards()
app.ShowCredits(backHere)
},
}),
},
{
Element: design.ListItem(design.ListItemDetails{
Text: "Show Modloader",
Subtext: "Show the installed modloader",
Click: func () {
app.GSRightwards()
app.ShowPackageView(backHere, "ccloader", middle.GetRemotePackages())
},
}),
},
{
Grow: 1,
},
}
app.Teleport(design.LayoutDocument(design.Header{
Title: "Options",
Back: back,
}, framework.NewUIFlexboxContainerPtr(framework.FlexboxContainer{
DirVertical: true,
Slots: listSlots,
}), true))
}