Skip to content

Commit 4a8ff51

Browse files
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() {

0 commit comments

Comments
 (0)