Skip to content

Commit e6cc258

Browse files
Refactor class library and fix a few more bugs
1 parent 248e63f commit e6cc258

33 files changed

+891
-8474
lines changed

Launchpad.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TraySetIcon("Graphics\Launchpad.ico")
77
SplitPath(A_ScriptName,,,, appName)
88

99
app := Launchpad.new(appName, A_ScriptDir)
10-
app.UpdateDependencies()
10+
app.Dependencies.UpdateDependencies()
1111
app.GuiManager.OpenMainWindow()
1212

1313
~LButton::

Lib/ApiEndpoint/ApiEndpoint.ahk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,29 @@ class ApiEndpoint {
5555

5656
return this.cache.CopyItem(path, destination)
5757
}
58+
59+
OpenApiEndpoint() {
60+
Run(this.endpointUrl)
61+
}
62+
63+
ChangeApiEndpoint(existingEndpoint := "", owner := "MainWindow") {
64+
if (existingEndpoint == "") {
65+
existingEndpoint := this.app.AppConfig.ApiEndpoint
66+
}
67+
68+
text := "Enter the base URL of the API endpoint you would like Launchpad to connect to. Leave blank to revert to the default."
69+
apiEndpointUrl := this.GuiManager.SingleInputBox("API Endpoint URL", text, existingEndpoint, owner)
70+
71+
if (apiEndpointUrl != existingEndpoint) {
72+
this.app.AppConfig.ApiEndpoint := apiEndpointUrl
73+
apiEndpointUrl := this.app.AppConfig.ApiEndpoint
74+
75+
if (apiEndpointUrl != existingEndpoint) {
76+
this.endpointUrl := apiEndpointUrl
77+
this.cache.FlushCache()
78+
}
79+
}
80+
81+
return apiEndpointUrl
82+
}
5883
}

Lib/BuildFile/BuildFile.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class BuildFile {
2020
__New(app, config, launcherDir, key, extension, filePath := "") {
2121
this.app := app
2222
this.appDir := app.AppConfig.AppDir
23-
this.tempDir := app.tempDir . "\BuildFiles\" . key
23+
this.tempDir := app.AppConfig.TempDir . "\BuildFiles\" . key
2424
this.config := config
2525
this.launcherDir := launcherDir
2626
this.key := key

Lib/BuildFile/CopyableBuildFile.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CopyableBuildFile extends BuildFile {
6868
file := FileSelect(1,, this.key . ": " . this.RequestMessage, this.SelectFilter)
6969

7070
if (file == "") {
71-
this.app.Toast("No file selected. Skipping build file.", "Launchpad", 10, 3)
71+
this.app.Notifications.Warning("No file selected. Skipping build file.")
7272
}
7373

7474
return file

Lib/BuildFile/IconFile.ahk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ class IconFile extends CopyableBuildFile {
5050
}
5151

5252
if (iconsCount == 0) {
53-
this.app.Toast("No icons could be extracted from %exeFile%. Please try another file.", "Launchpad", 10, 2)
53+
this.app.Notifications.Warning("No icons could be extracted from %exeFile%. Please try another file.")
5454
iconFilePath := ""
5555
this.Cleanup()
5656
} else {
5757
if (iconsCount > 1) {
5858
iconFilePath := FileSelect(, iconsDir, "Select the correct icon from the extracted files", "Icons (*.ico)")
5959

6060
if (iconFilePath == "") {
61-
this.app.Toast("Canceled icon selection. Please try again.", "Launchpad", 10, 2)
61+
this.app.Notifications.Warning("Canceled icon selection. Please try again.")
6262
this.Cleanup()
6363
}
6464
}

Lib/Builder/Builder.ahk

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
11
class Builder {
22
app := ""
3-
key := ""
4-
config := Map()
53

6-
__New(app, key, config) {
4+
__New(app) {
75
this.app := app
8-
this.key := key
9-
this.config := config
106
}
117

12-
Build() {
8+
Build(key, config) {
139
launcherDir := this.app.AppConfig.LauncherDir
1410
assetsDir := this.app.AppConfig.AssetsDir
1511

1612
if (launcherDir == "" or assetsDir == "") {
17-
this.app.Toast(this.key . ": Required directories not set. Skipping build.", "Launchpad", 10, 2)
13+
this.app.Notifications.Warning(key . ": Required directories not set. Skipping build.")
1814
return false
1915
}
2016

2117
if (this.app.AppConfig.IndividualDirs) {
22-
launcherDir .= "\" . this.key
18+
launcherDir .= "\" . key
2319
}
24-
assetsDir .= "\" . this.key
20+
assetsDir .= "\" . key
2521

2622
DirCreate(launcherDir)
2723
DirCreate(assetsDir)
2824

29-
iconObj := IconFile.new(this.app, this.config, assetsDir, this.key)
25+
iconObj := IconFile.new(this.app, config, assetsDir, key)
3026
iconResult := iconObj.Build()
3127

32-
shortcutResult := !this.config["requiresShortcutFile"] ; Default to true if shortcut isn't required
33-
if (this.config["requiresShortcutFile"]) {
34-
shortcutObj := ShortcutFile.new(this.app, this.config, assetsDir, this.key)
28+
shortcutResult := !config["requiresShortcutFile"] ; Default to true if shortcut isn't required
29+
if (config["requiresShortcutFile"]) {
30+
shortcutObj := ShortcutFile.new(this.app, config, assetsDir, key)
3531
shortcutResult := shortcutObj.Build()
3632
}
3733

3834
ahkResult := false
3935
exeResult := false
4036

4137
if (iconResult and shortcutResult) {
42-
gameAhkObj := GameAhkFile.new(this.app, this.config, assetsDir, this.key)
38+
gameAhkObj := GameAhkFile.new(this.app, config, assetsDir, key)
4339
ahkResult := gameAhkObj.Build()
4440

4541
if (ahkResult) {
46-
gameExeObj := GameExeFile.new(this.app, this.config, launcherDir, this.key)
42+
gameExeObj := GameExeFile.new(this.app, config, launcherDir, key)
4743
exeResult := gameExeObj.Build()
4844
}
4945

Lib/Cache/Cache.ahk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ class Cache {
3030
}
3131

3232
ImportItemFromUrl(reference, url) {
33-
tempDir := this.app.tempDir
34-
tempFile := tempDir . "\cacheDownload"
35-
36-
DirCreate(tempDir)
33+
tempFile := this.app.AppConfig.TempDir . "\cacheDownload"
34+
DirCreate(this.app.AppConfig.TempDir)
3735
tempFile := this.DownloadItem(tempFile, url)
3836
content := FileRead(tempFile)
3937

Lib/Cache/FileCache.ahk

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
class FileCache extends Cache {
22
cachePath := ""
33

4-
__New(app, cachePath := "") {
5-
if (cachePath == "") {
6-
cachePath := A_Temp . "\Launchpad\Cache"
7-
}
8-
4+
__New(app, cachePath) {
95
this.cachePath := cachePath
10-
DirCreate(this.cachePath)
116

127
super.__New(app)
8+
9+
if (!DirExist(this.cachePath)) {
10+
DirCreate(this.cachePath)
11+
}
1312
}
1413

1514
ItemExists(path) {

Lib/Cache/ObjectCache.ahk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class ObjectCache extends Cache {
55
if (cacheObj != "") {
66
this.cacheObj := cacheObj
77
}
8+
89
super.__New(app)
910
}
1011

0 commit comments

Comments
 (0)