Skip to content

Commit 4a8ff51

Browse files
committed
Rebuilt all Gui windows to be just-in-time factory-created services, and avoid Gui-related circular references when closing dialogs
1 parent 0b95676 commit 4a8ff51

File tree

64 files changed

+894
-620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+894
-620
lines changed

Lib/Launchpad/App/Launchpad.ahk

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220

221221
if (releaseInfo && releaseInfo["data"].Has("version") && releaseInfo["data"]["version"] && this.Service("VersionChecker").VersionIsOutdated(releaseInfo["data"]["version"], this.Version)) {
222222
updateAvailable := true
223-
this.Service("GuiManager").Dialog("UpdateAvailableWindow", releaseInfo)
223+
this.Service("GuiManager").Dialog(Map("type", "UpdateAvailableWindow"), releaseInfo)
224224
}
225225
}
226226
}
@@ -299,7 +299,10 @@
299299
configFile := this.Parameter("previous_config_file")
300300

301301
if (configFile && FileExist(configFile)) {
302-
response := this.Service("GuiManager").Dialog("DialogBox", "Migrate settings?", this.appName . " uses a new configuration file format, and has detected that you have a previous configuration file.`n`nWould you like to automatically migrate your settings?`n`nChoose Yes to migrate your previous configuration. Choose no to simply delete it and start from scratch.")
302+
response := this.Service("GuiManager").Dialog(Map(
303+
"title", "Migrate settings?",
304+
"text", this.appName . " uses a new configuration file format, and has detected that you have a previous configuration file.`n`nWould you like to automatically migrate your settings?`n`nChoose Yes to migrate your previous configuration. Choose no to simply delete it and start from scratch."
305+
))
303306

304307
if (response == "Yes") {
305308
this.Service("LaunchpadIniMigrator").Migrate(configFile, this.Config)
@@ -310,7 +313,7 @@
310313
}
311314

312315
InitialSetup(config) {
313-
result := this.Service("GuiManager").Dialog("SetupWindow")
316+
result := this.Service("GuiManager").Dialog(Map("type", "SetupWindow"))
314317

315318
if (result == "Exit") {
316319
this.ExitApp()
@@ -345,12 +348,16 @@
345348
}
346349

347350
ProvideFeedback() {
348-
this.Service("GuiManager").Dialog("FeedbackWindow")
351+
this.Service("GuiManager").Dialog(Map("type", "FeedbackWindow"))
349352
}
350353

351354
RestartApp() {
352-
if (this.Services.Has("GuiManager") && this.Service("GuiManager").Has("MainWindow")) {
353-
this.Service("GuiManager").StoreWindowState(this.Service("GuiManager")["MainWindow"])
355+
if (this.Services.Has("GuiManager")) {
356+
guiMgr := this.Service("GuiManager")
357+
358+
if (guiMgr.Has("MainWindow")) {
359+
guiMgr.StoreWindowState(this.Service("GuiManager")["MainWindow"])
360+
}
354361
}
355362

356363
super.RestartApp()

Lib/Launchpad/ConfigMigrator/LaunchpadIniMigrator.ahk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ class LaunchpadIniMigrator {
5454
}
5555

5656
FileDelete(previousFile)
57-
this.guiMgr.Dialog("DialogBox", "Migration Complete", message, "", "", "*&OK")
57+
this.guiMgr.Dialog(Map(
58+
"title", "Migration Complete",
59+
"text", message,
60+
"buttons", "*&OK"
61+
))
5862
this.app.RestartApp()
5963
}
6064
}

Lib/Launchpad/Entity/LauncherEntity.ahk

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,22 @@ class LauncherEntity extends AppEntityBase {
245245
LaunchEditWindow(mode, owner := "", parent := "") {
246246
result := this.app.Config["use_advanced_launcher_editor"] ? "Advanced" : "Simple"
247247

248+
ownerOrParent := ""
249+
250+
if (parent) {
251+
ownerOrParent := parent
252+
} else if (owner) {
253+
ownerOrParent := owner
254+
}
255+
248256
while (result == "Simple" || result == "Advanced") {
249257
form := result == "Advanced" ? "LauncherEditor" : "LauncherEditorSimple"
250-
result := this.app.Service("GuiManager").Dialog(form, this, mode, owner, parent)
258+
result := this.app.Service("GuiManager").Dialog(Map(
259+
"type", form,
260+
"mode", mode,
261+
"child", !!(parent),
262+
"ownerOrParent", ownerOrParent
263+
), this)
251264
}
252265

253266
return result

Lib/Launchpad/Entity/ManagedGameEntity.ahk

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ class ManagedGameEntity extends ManagedEntityBase {
117117
}
118118

119119
LaunchEditWindow(mode, owner := "", parent := "") {
120-
return this.app.Service("GuiManager").Dialog("ManagedGameEditor", this, mode, owner, parent)
120+
ownerOrParent := ""
121+
122+
if (parent) {
123+
ownerOrParent := parent
124+
} else if (owner) {
125+
ownerOrParent := owner
126+
}
127+
128+
return this.app.Service("GuiManager").Dialog(Map(
129+
"type", "ManagedGameEditor",
130+
"mode", mode,
131+
"child", !!(parent),
132+
"ownerOrParent", ownerOrParent
133+
), this)
121134
}
122135
}

Lib/Launchpad/Entity/ManagedLauncherEntity.ahk

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ class ManagedLauncherEntity extends ManagedEntityBase {
9494
}
9595

9696
LaunchEditWindow(mode, owner := "", parent := "") {
97-
return this.app.Service("GuiManager").Dialog("ManagedLauncherEditor", this, mode, owner, parent)
97+
ownerOrParent := ""
98+
99+
if (parent) {
100+
ownerOrParent := parent
101+
} else if (owner) {
102+
ownerOrParent := owner
103+
}
104+
105+
return this.app.Service("GuiManager").Dialog(Map(
106+
"type", "ManagedLauncherEditor",
107+
"mode", mode,
108+
"child", !!(parent),
109+
"ownerOrParent", ownerOrParent
110+
), this)
98111
}
99112
}

Lib/Launchpad/Entity/PlatformEntity.ahk

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,19 @@ class PlatformEntity extends AppEntityBase {
153153
}
154154

155155
LaunchEditWindow(mode, owner := "", parent := "") {
156-
return this.app.Service("GuiManager").Dialog("PlatformEditor", this, mode, owner, parent)
156+
ownerOrParent := ""
157+
158+
if (parent) {
159+
ownerOrParent := parent
160+
} else if (owner) {
161+
ownerOrParent := owner
162+
}
163+
164+
return this.app.Service("GuiManager").Dialog(Map(
165+
"type", "PlatformEditor",
166+
"mode", mode,
167+
"child", !!(parent),
168+
"ownerOrParent", ownerOrParent
169+
), this)
157170
}
158171
}

Lib/Launchpad/Gui/Dialog/AboutWindow.ahk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
class AboutWindow extends DialogBox {
2-
__New(app, themeObj, guiId, owner := "", parent := "", btns := "*&OK") {
3-
super.__New(app, themeObj, guiId, "About " . app.appName, "", owner, parent, btns)
2+
GetDefaultConfig(container, config) {
3+
defaults := super.GetDefaultConfig(container, config)
4+
defaults["title"] := "About " . container.GetApp().appName
5+
defaults["buttons"] := "*&OK"
6+
return defaults
47
}
58

69
Controls() {

Lib/Launchpad/Gui/Dialog/AccountInfoWindow.ahk

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
class AccountInfoWindow extends FormGuiBase {
2-
__New(app, themeObj, guiId, owner := "", parent := "") {
3-
super.__New(app, themeObj, guiId, "Account Info", this.GetTextDefinition(), owner, parent, this.GetButtonsDefinition())
4-
}
5-
6-
GetTextDefinition() {
7-
return ""
8-
}
9-
10-
GetButtonsDefinition() {
11-
return "*&Save|&Cancel|&Logout"
2+
GetDefaultConfig(container, config) {
3+
defaults := super.GetDefaultConfig(container, config)
4+
defaults["title"] := "Account Info"
5+
defaults["buttons"] := "*&Save|&Cancel|&Logout"
6+
return defaults
127
}
138

149
Controls() {

Lib/Launchpad/Gui/Dialog/LoginWindow.ahk

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
entityManager := ""
44
missingFields := Map()
55
dataSource := ""
6-
7-
__New(app, themeObj, guiId, owner := "", parent := "") {
8-
super.__New(app, themeObj, guiId, "Login", this.GetTextDefinition(), owner, parent, this.GetButtonsDefinition())
9-
}
10-
11-
GetTextDefinition() {
12-
return "Logging in allows enhanced features such as online backup, restore, personalization, and sharing with the community.`n`nIf you'd like to log in, click the `"Get token`" button to go to the launchpad.games site to retrieve a valid login token and then paste it below."
13-
}
146

15-
GetButtonsDefinition() {
16-
return "*&Login|&Cancel"
7+
GetDefaultConfig(container, config) {
8+
defaults := super.GetDefaultConfig(container, config)
9+
defaults["title"] := "Login"
10+
defaults["text"] := "Logging in allows enhanced features such as online backup, restore, personalization, and sharing with the community.`n`nIf you'd like to log in, click the `"Get token`" button to go to the launchpad.games site to retrieve a valid login token and then paste it below."
11+
defaults["buttons"] := "*&Login|&Cancel"
12+
return defaults
1713
}
1814

1915
Controls() {

Lib/Launchpad/Gui/EntityEditor/LauncherEditor.ahk

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@
77
*/
88

99
class LauncherEditor extends LauncherEditorBase {
10-
__New(app, themeObj, guiId, entityObj, mode := "config", owner := "", parent := "") {
11-
super.__New(app, themeObj, guiId, entityObj, "Launcher Editor", mode, owner, parent)
12-
}
13-
14-
GetButtonsDefinition() {
15-
buttonsDef := super.GetButtonsDefinition()
16-
buttonsDef .= "|S&imple"
17-
return buttonsDef
10+
GetDefaultConfig(container, config) {
11+
defaults := super.GetDefaultConfig(container, config)
12+
defaults["buttons"] .= "|S&imple"
13+
return defaults
1814
}
1915

2016
Controls() {

Lib/Launchpad/Gui/EntityEditor/LauncherEditorBase.ahk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class LauncherEditorBase extends EntityEditorBase {
1414
platforms := ""
1515
logLevels := ["None", "Error", "Warning", "Info", "Debug"]
1616

17+
GetDefaultConfig(container, config) {
18+
defaults := super.GetDefaultConfig(container, config)
19+
defaults["title"] := "Launcher Editor"
20+
return defaults
21+
}
22+
1723
Controls() {
1824
super.Controls()
1925
}
@@ -42,7 +48,7 @@ class LauncherEditorBase extends EntityEditorBase {
4248
}
4349

4450
EditManagedEntityType(entity, field) {
45-
diff := entity.Edit("child", this.guiObj)
51+
diff := entity.Edit("child", this.guiId)
4652

4753
if (diff != "" && diff.HasChanges()) {
4854
if (diff.ValueIsModified(field)) {

Lib/Launchpad/Gui/EntityEditor/LauncherEditorSimple.ahk

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99
class LauncherEditorSimple extends LauncherEditorBase {
1010
possibleExes := ""
1111

12-
__New(app, themeObj, guiId, entityObj, mode := "config", owner := "", parent := "") {
13-
super.__New(app, themeObj, guiId, entityObj, "Launcher Editor", mode, owner, parent)
14-
}
15-
16-
GetButtonsDefinition() {
17-
buttonsDef := super.GetButtonsDefinition()
18-
buttonsDef .= "|&Advanced"
19-
return buttonsDef
12+
GetDefaultConfig(container, config) {
13+
defaults := super.GetDefaultConfig(container, config)
14+
defaults["buttons"] .= "|&Advanced"
15+
return defaults
2016
}
2117

2218
Create() {

Lib/Launchpad/Gui/EntityEditor/ManagedEntityEditorBase.ahk

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ class ManagedEntityEditorBase extends EntityEditorBase {
1515
entityTypeName := ""
1616
possibleExes := ""
1717

18-
__New(app, themeObj, guiId, entityObj, title, mode := "config", owner := "", parent := "") {
19-
if (owner == "") {
20-
owner := "LauncherEditor"
21-
}
18+
GetDefaultConfig(container, config) {
19+
defaults := super.GetDefaultConfig(container, config)
20+
defaults["ownerOrParent"] := "LauncherEditor"
21+
defaults["child"] := false
22+
return defaults
23+
}
2224

25+
__New(container, themeObj, config, entityObj) {
2326
if (this.entityTypeName == "") {
2427
this.entityTypeName := entityObj.configPrefix
2528
}
@@ -28,7 +31,7 @@ class ManagedEntityEditorBase extends EntityEditorBase {
2831
this.regViews.Push("64")
2932
}
3033

31-
super.__New(app, themeObj, guiId, entityObj, title, mode, owner, parent)
34+
super.__New(container, themeObj, config, entityObj)
3235
}
3336

3437
Create() {

Lib/Launchpad/Gui/EntityEditor/ManagedGameEditor.ahk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
class ManagedGameEditor extends ManagedEntityEditorBase {
2-
__New(app, themeObj, guiId, entityObj, mode := "config", owner := "", parent := "") {
3-
super.__New(app, themeObj, guiId, entityObj, "Managed Game Editor", mode, owner, parent)
2+
GetDefaultConfig(container, config) {
3+
defaults := super.GetDefaultConfig(container, config)
4+
defaults["title"] := "Managed Game Editor"
5+
return defaults
46
}
57

68
ExtraTabControls(tabs) {

Lib/Launchpad/Gui/EntityEditor/ManagedLauncherEditor.ahk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
class ManagedLauncherEditor extends ManagedEntityEditorBase {
22
closeMethods := ["Prompt", "Wait", "Auto", "AutoPolite", "AutoKill"]
33

4-
__New(app, themeObj, guiId, entityObj, mode := "config", owner := "", parent := "") {
5-
super.__New(app, themeObj, guiId, entityObj, "Managed Launcher Editor", mode, owner, parent)
4+
GetDefaultConfig(container, config) {
5+
defaults := super.GetDefaultConfig(container, config)
6+
defaults["title"] := "Managed Launcher Editor"
7+
return defaults
68
}
79

810
CustomTabControls() {

Lib/Launchpad/Gui/EntityEditor/PlatformEditor.ahk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class PlatformEditor extends EntityEditorBase {
2-
__New(app, themeObj, guiId, entityObj, mode := "config", owner := "", parent := "") {
3-
if (owner == "") {
4-
owner := "PlatformsWindow"
5-
}
6-
7-
super.__New(app, themeObj, guiId, entityObj, "Platform Editor", mode, owner, parent)
2+
GetDefaultConfig(container, config) {
3+
defaults := super.GetDefaultConfig(container, config)
4+
defaults["ownerOrParent"] := "PlatformsWindow"
5+
defaults["child"] := false
6+
defaults["title"] := "Platform Editor"
7+
return defaults
88
}
99

1010
Controls() {

Lib/Launchpad/Gui/Form/DetectedGameEditor.ahk

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@
77
launcherTypes := ""
88
gameTypes := ""
99

10-
__New(app, themeObj, guiId, detectedGameObj, owner := "", parent := "") {
11-
InvalidParameterException.CheckTypes("DetectedGameEditor", "detectedGameObj", detectedGameObj, "DetectedGame")
10+
__New(container, themeObj, config, detectedGameObj) {
1211
this.detectedGameObj := detectedGameObj
13-
super.__New(app, themeObj, guiId, "Detected Game Editor", this.GetTextDefinition(), owner, parent, this.GetButtonsDefinition())
12+
super.__New(container, themeObj, config)
13+
}
14+
15+
GetDefaultConfig(container, config) {
16+
defaults := super.GetDefaultConfig(container, config)
17+
defaults["title"] := "Detected Game Editor"
18+
defaults["text"] := "These values were detected automatically. You may customize them below. Blanking out a value will cause the entity to use the default (or retain its existing value)."
19+
defaults["buttons"] := "*&Save|&Cancel"
20+
return defaults
1421
}
1522

1623
Create() {
@@ -22,14 +29,6 @@
2229
this.gameTypes := this.dataSource.ReadListing("game-types")
2330
}
2431

25-
GetTextDefinition() {
26-
return "These values were detected automatically. You may customize them below. Blanking out a value will cause the entity to use the default (or retain its existing value)."
27-
}
28-
29-
GetButtonsDefinition() {
30-
return "*&Save|&Cancel"
31-
}
32-
3332
GetTitle(title) {
3433
return super.GetTitle(title . ": " . this.detectedGameObj.key)
3534
}

Lib/Launchpad/Gui/Form/ImportShortcutForm.ahk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
shortcutExt := ""
55
defaultPlatform := ""
66

7-
__New(app, themeObj, guiId, owner := "", parent := "") {
7+
__New(container, themeObj, config) {
88
this.AskShortcutSrc()
9-
super.__New(app, themeObj, guiId, "Import Shortcut", owner, parent)
9+
super.__New(container, themeObj, config)
1010
}
1111

12-
GetTextDefinition() {
13-
return "Select an existing shortcut and platform, and Launchpad will create a launcher for your game. You can modify or add the launcher details after it's added."
12+
GetDefaultConfig(container, config) {
13+
defaults := super.GetDefaultConfig(container, config)
14+
defaults["title"] := "Import Shortcut"
15+
defaults["text"] := "Select an existing shortcut and platform, and Launchpad will create a launcher for your game. You can modify or add the launcher details after it's added."
16+
return defaults
1417
}
1518

1619
Controls() {

0 commit comments

Comments
 (0)