-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgameFinderPre.go
134 lines (127 loc) · 4.08 KB
/
gameFinderPre.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package main
import (
"fmt"
"github.com/20kdc/CCUpdaterUI/design"
"github.com/20kdc/CCUpdaterUI/frenyard"
"github.com/20kdc/CCUpdaterUI/frenyard/framework"
"github.com/20kdc/CCUpdaterUI/frenyard/integration"
"github.com/20kdc/CCUpdaterUI/middle"
"github.com/CCDirectLink/CCUpdaterCLI"
"github.com/CCDirectLink/CCUpdaterCLI/local"
)
func (app *upApplication) ResetWithGameLocation(save bool, location string) {
app.gameInstance = nil
app.config.GamePath = location
if save {
middle.WriteUpdaterConfig(app.config)
}
// Re-kick
app.ShowGameFinderPreface()
}
func (app *upApplication) ShowGameFinderPreface() {
var gameLocations []middle.GameLocation
app.ShowWaiter("Starting...", func (progress func(string)) {
progress("Preparing remote packages...")
middle.GetRemotePackages()
progress("Scanning local installation...")
gi := ccmodupdater.NewGameInstance(app.config.GamePath)
fmt.Printf("Doing preliminary check of %s\n", app.config.GamePath)
lp, err := local.AllLocalPackagePlugins(gi)
if err == nil {
gi.LocalPlugins = lp
_, hasCC := gi.Packages()["crosscode"]
if hasCC {
app.gameInstance = gi
return
}
fmt.Printf("Game not present?\n")
} else {
fmt.Printf("Failed check: %s\n", err.Error())
}
progress("Not configured ; Autodetecting game locations...")
gameLocations = middle.AutodetectGameLocations()
}, func () {
if app.gameInstance == nil {
app.ShowGameFinderPrefaceInternal(gameLocations)
} else {
app.cachedPrimaryView = nil
app.ShowPrimaryView()
}
})
}
func (app *upApplication) ShowGameFinderPrefaceInternal(locations []middle.GameLocation) {
suggestSlots := []framework.FlexboxSlot{}
for _, location := range locations {
suggestSlots = append(suggestSlots, framework.FlexboxSlot{
Element: design.ListItem(design.ListItemDetails{
Icon: design.GameIconID,
Text: "CrossCode " + location.Version,
Subtext: location.Location,
Click: func () {
app.GSRightwards()
app.ResetWithGameLocation(true, location.Location)
},
}),
RespectMinimumSize: true,
})
}
// Space-taker to prevent wrongly scaled list items
suggestSlots = append(suggestSlots, framework.FlexboxSlot{
Grow: 1,
Shrink: 0,
})
foundInstallsScroller := design.ScrollboxV(framework.NewUIFlexboxContainerPtr(framework.FlexboxContainer{
DirVertical: true,
WrapMode: framework.FlexboxWrapModeNone,
Slots: suggestSlots,
}))
content := framework.NewUIFlexboxContainerPtr(framework.FlexboxContainer{
DirVertical: true,
Slots: []framework.FlexboxSlot{
framework.FlexboxSlot{
Element: framework.NewUILabelPtr(integration.NewTextTypeChunk("Welcome to the unofficial CrossCode mod updater UI.\nBefore we begin, you need to indicate which CrossCode installation you want to install mods to.", design.GlobalFont), design.ThemeText, 0, frenyard.Alignment2i{}),
},
framework.FlexboxSlot{
Basis: design.SizeMarginAroundEverything,
},
framework.FlexboxSlot{
Element: foundInstallsScroller,
Grow: 1,
Shrink: 1,
RespectMinimumSize: true,
},
framework.FlexboxSlot{
Basis: design.SizeMarginAroundEverything,
},
framework.FlexboxSlot{
Element: framework.NewUILabelPtr(integration.NewTextTypeChunk("If the installation you'd like to install mods to isn't shown here, you can locate it manually.", design.GlobalFont), design.ThemeText, 0, frenyard.Alignment2i{}),
},
framework.FlexboxSlot{
Basis: design.SizeMarginAroundEverything,
},
framework.FlexboxSlot{
Element: design.ButtonBar([]framework.UILayoutElement{
design.ButtonAction(design.ThemeOkActionButton, "LOCATE MANUALLY", func () {
app.GSDownwards()
app.ShowGameFinder(func () {
app.GSUpwards()
app.ShowGameFinderPrefaceInternal(locations)
}, middle.BrowserVFSPathDefault)
}),
}),
},
},
})
primary := design.LayoutDocument(design.Header{
BackIcon: design.WarningIconID,
Back: func () {
app.GSLeftwards()
app.ShowCredits(func () {
app.GSRightwards()
app.ShowGameFinderPrefaceInternal(locations)
})
},
Title: "Welcome",
}, content, true)
app.Teleport(primary)
}