Skip to content

Commit

Permalink
Merge pull request #346 from VolantisDev/module-deps
Browse files Browse the repository at this point in the history
Module improvements
  • Loading branch information
bmcclure committed Mar 12, 2022
2 parents 224bc61 + dd682be commit 50bdffb
Show file tree
Hide file tree
Showing 62 changed files with 452 additions and 297 deletions.
21 changes: 10 additions & 11 deletions Launchpad.services.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"config.platforms_view_mode": "Tile",
"config.launcher_view_mode": "Report",
"config.launcher_double_click_action": "Edit",
"modules.Auth": true,
"modules.Bethesda": true,
"modules.Blizzard": true,
"modules.Epic": true,
Expand Down Expand Up @@ -57,21 +56,21 @@
"class": "PersistentConfig",
"arguments": ["@config_storage.backups", "@{}", "backups_config"]
},
"BackupManager": {
"manager.backup": {
"class": "BackupManager",
"arguments": ["@{App}", "@config.backups"]
},
"DataSourceManager": {
"manager.datasource": {
"class": "DataSourceManager",
"arguments": ["@{}", "@EventManager", "@Notifier", "@@config.data_source_key"]
"arguments": ["@{}", "@manager.event", "@Notifier", "@@config.data_source_key"]
},
"builder.ahk_launcher": {
"class": "AhkLauncherBuilder",
"arguments": ["@{App}", "@Notifier"]
},
"BuilderManager": {
"manager.builder": {
"class": "BuilderManager",
"arguments": ["@LauncherManager", "@{}", "@EventManager", "@Notifier"]
"arguments": ["@manager.launcher", "@{}", "@manager.event", "@Notifier"]
},
"config_storage.launchers": {
"class": "JsonConfigStorage",
Expand All @@ -81,7 +80,7 @@
"class": "LauncherConfig",
"arguments": ["@config_storage.launchers", "@{}", "launcher_config"]
},
"LauncherManager": {
"manager.launcher": {
"class": "LauncherManager",
"arguments": ["@{App}", "@config.launchers"]
},
Expand All @@ -93,21 +92,21 @@
"class": "PlatformsConfig",
"arguments": ["@config_storage.platforms", "@{}", "platforms_config"]
},
"PlatformManager": {
"manager.platform": {
"class": "PlatformManager",
"arguments": ["@{App}", "@config.platforms"]
},
"installer.launchpad_update": {
"class": "LaunchpadUpdate",
"arguments": ["@@version", "@State", "@CacheManager", "file", "@@tmp_dir"]
"arguments": ["@@version", "@State", "@manager.cache", "file", "@@tmp_dir"]
},
"installer.dependencies": {
"class": "DependencyInstaller",
"arguments": ["@@version", "@State", "@CacheManager", "file", [], "@@tmp_dir"]
"arguments": ["@@version", "@State", "@manager.cache", "file", [], "@@tmp_dir"]
},
"LaunchpadIniMigrator": {
"class": "LaunchpadIniMigrator",
"arguments": ["@{App}", "@GuiManager"]
"arguments": ["@{App}", "@manager.gui"]
}
}
}
44 changes: 16 additions & 28 deletions Lib/Launchpad/App/Launchpad.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,11 @@
detectGames := false
isSetup := false

GetDefaultModules(config) {
modules := super.GetDefaultModules(config)
modules["LaunchpadApi"] := "LaunchpadApi"
modules["Bethesda"] := "Bethesda"
modules["Blizzard"] := "Blizzard"
modules["Epic"] := "Epic"
modules["Origin"] := "Origin"
modules["Riot"] := "Riot"
modules["Steam"] := "Steam"
return modules
}

CheckForUpdates(notify := true) {
updateAvailable := false

if (this.Version != "{{VERSION}}") {
dataSource := this.Service("DataSourceManager")["api"]
dataSource := this.Service("manager.datasource")["api"]
releaseInfoStr := dataSource.ReadItem("release-info")

if (releaseInfoStr) {
Expand All @@ -28,7 +16,7 @@

if (releaseInfo && releaseInfo["data"].Has("version") && releaseInfo["data"]["version"] && this.Service("VersionChecker").VersionIsOutdated(releaseInfo["data"]["version"], this.Version)) {
updateAvailable := true
this.Service("GuiManager").Dialog(Map("type", "UpdateAvailableWindow"), releaseInfo)
this.Service("manager.gui").Dialog(Map("type", "UpdateAvailableWindow"), releaseInfo)
}
}
}
Expand Down Expand Up @@ -92,22 +80,22 @@

super.RunApp(config)

this.Service("PlatformManager").LoadComponents()
this.Service("LauncherManager").LoadComponents()
this.Service("BackupManager").LoadComponents()
this.Service("manager.platform").LoadComponents()
this.Service("manager.launcher").LoadComponents()
this.Service("manager.backup").LoadComponents()

this.OpenApp()

if (this.detectGames) {
this.Service("PlatformManager").DetectGames()
this.Service("manager.platform").DetectGames()
}
}

MigrateConfiguration() {
configFile := this.Parameter("previous_config_file")

if (configFile && FileExist(configFile)) {
response := this.Service("GuiManager").Dialog(Map(
response := this.Service("manager.gui").Dialog(Map(
"title", "Migrate settings?",
"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."
))
Expand All @@ -121,7 +109,7 @@
}

InitialSetup(config) {
result := this.Service("GuiManager").Dialog(Map("type", "SetupWindow"))
result := this.Service("manager.gui").Dialog(Map("type", "SetupWindow"))

if (result == "Exit") {
this.ExitApp()
Expand All @@ -134,18 +122,18 @@
}

UpdateStatusIndicators() {
if (this.Service("GuiManager").Has("MainWindow")) {
this.Service("GuiManager")["MainWindow"].UpdateStatusIndicator()
if (this.Service("manager.gui").Has("MainWindow")) {
this.Service("manager.gui")["MainWindow"].UpdateStatusIndicator()
}
}

ExitApp() {
if (this.isSetup && this.Config["clean_launchers_on_exit"]) {
this.Service("BuilderManager").CleanLaunchers()
this.Service("manager.builder").CleanLaunchers()
}

if (this.isSetup && this.Config["flush_cache_on_exit"]) {
this.Service("CacheManager").FlushCaches(false, false)
this.Service("manager.cache").FlushCaches(false, false)
}

super.ExitApp()
Expand All @@ -156,15 +144,15 @@
}

ProvideFeedback() {
this.Service("GuiManager").Dialog(Map("type", "FeedbackWindow"))
this.Service("manager.gui").Dialog(Map("type", "FeedbackWindow"))
}

RestartApp() {
if (this.Services.Has("GuiManager")) {
guiMgr := this.Service("GuiManager")
if (this.Services.Has("manager.gui")) {
guiMgr := this.Service("manager.gui")

if (guiMgr.Has("MainWindow")) {
guiMgr.StoreWindowState(this.Service("GuiManager")["MainWindow"])
guiMgr.StoreWindowState(this.Service("manager.gui")["MainWindow"])
}
}

Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Builder/BuildFile/GameAhkFile.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GameAhkFile extends ComposableBuildFile {
GetPlatforms() {
platforms := Map()

for key, platform in this.app.Service("PlatformManager").GetActivePlatforms() {
for key, platform in this.app.Service("manager.platform").GetActivePlatforms() {
platforms[key] := platform.Config
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LauncherBuilderOpBase extends LauncherGameOpBase {
}

if (Type(builder) == "String" && builder != "") {
builder := app.Service("BuilderManager")[builder]
builder := app.Service("manager.builder")[builder]
}

InvalidParameterException.CheckTypes("LauncherBuilderOpBase", "builder", builder, "BuilderBase")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LauncherGameOpBase extends BulkOperationBase {

__New(app, launcherEntities := "", owner := "") {
if (launcherEntities == "") {
launcherEntities := app.Service("LauncherManager").Entities
launcherEntities := app.Service("manager.launcher").Entities
}

InvalidParameterException.CheckTypes("LauncherGameOpBase", "launcherEntities", launcherEntities, "Map")
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/BulkOperation/LoadOp/LoadLaunchersOp.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class LoadLaunchersOp extends BulkOperationBase {

__New(app, launcherConfigObj := "", owner := "") {
if (launcherConfigObj == "") {
launcherConfigObj := app.Service("LauncherManager").GetConfig()
launcherConfigObj := app.Service("manager.launcher").GetConfig()
}

InvalidParameterException.CheckTypes("EntityBase", "launcherConfigObj", launcherConfigObj, "LauncherConfig")
Expand Down
4 changes: 2 additions & 2 deletions Lib/Launchpad/BulkOperation/LoadOp/LoadPlatformsOp.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LoadPlatformsOp extends BulkOperationBase {

__New(app, platformsConfigObj := "", owner := "") {
if (platformsConfigObj == "") {
platformsConfigObj := app.Service("PlatformManager").GetConfig()
platformsConfigObj := app.Service("manager.platform").GetConfig()
}

InvalidParameterException.CheckTypes("LoadPlatformsOp", "platformsConfigObj", platformsConfigObj, "PlatformsConfig")
Expand All @@ -29,7 +29,7 @@ class LoadPlatformsOp extends BulkOperationBase {
)

event := DefineComponentsEvent(LaunchpadEvents.PLATFORMS_DEFINE, platforms)
this.app.Service("EventManager").DispatchEvent(LaunchpadEvents.PLATFORMS_DEFINE, event)
this.app.Service("manager.event").DispatchEvent(LaunchpadEvents.PLATFORMS_DEFINE, event)
platforms := event.components

if (this.useProgress) {
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Config/LaunchpadConfig.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class LaunchpadConfig extends AppConfig {
LaunchersLoaded() {
return this.app.Services.Has("LauncherManager")
return this.app.Services.Has("manager.launcher")
}

OpenDestinationDir() {
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Entity/LauncherEntity.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class LauncherEntity extends AppEntityBase {

while (result == "Simple" || result == "Advanced") {
form := result == "Advanced" ? "LauncherEditor" : "LauncherEditorSimple"
result := this.app.Service("GuiManager").Dialog(Map(
result := this.app.Service("manager.gui").Dialog(Map(
"type", form,
"mode", mode,
"child", !!(parent),
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Entity/ManagedGameEntity.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ManagedGameEntity extends ManagedEntityBase {
ownerOrParent := owner
}

return this.app.Service("GuiManager").Dialog(Map(
return this.app.Service("manager.gui").Dialog(Map(
"type", "ManagedGameEditor",
"mode", mode,
"child", !!(parent),
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Entity/ManagedLauncherEntity.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ManagedLauncherEntity extends ManagedEntityBase {
ownerOrParent := owner
}

return this.app.Service("GuiManager").Dialog(Map(
return this.app.Service("manager.gui").Dialog(Map(
"type", "ManagedLauncherEditor",
"mode", mode,
"child", !!(parent),
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Entity/PlatformEntity.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class PlatformEntity extends AppEntityBase {
ownerOrParent := owner
}

return this.app.Service("GuiManager").Dialog(Map(
return this.app.Service("manager.gui").Dialog(Map(
"type", "PlatformEditor",
"mode", mode,
"child", !!(parent),
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/GamePlatform/GamePlatformBase.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class GamePlatformBase {
}

DetermineMainExe(key, possibleExes) {
dataSource := this.app.Service("DataSourceManager").GetDefaultDataSource()
dataSource := this.app.Service("manager.datasource").GetDefaultDataSource()
dsData := this.GetDataSourceDefaults(dataSource, key)

mainExe := ""
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Gui/EntityEditor/LauncherEditorBase.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LauncherEditorBase extends EntityEditorBase {
this.platforms := this.dataSource.ReadListing("platforms")
this.launcherTypes := this.dataSource.ReadListing("launcher-types")
this.gameTypes := this.dataSource.ReadListing("game-types")
this.knownThemes := this.app.Service("ThemeManager").GetAvailableThemes()
this.knownThemes := this.app.Service("manager.theme").GetAvailableThemes()
}

OnKeyChange(ctlObj, info) {
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Gui/Form/DetectedGameEditor.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

Create() {
super.Create()
this.dataSource := this.app.Service("DataSourceManager")["api"]
this.dataSource := this.app.Service("manager.datasource")["api"]
this.knownPlatforms := this.dataSource.ReadListing("platforms")
this.knownGames := this.dataSource.ReadListing("game-keys")
this.launcherTypes := this.dataSource.ReadListing("launcher-types")
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Gui/Form/ImportShortcutForm.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
GetLauncherConfig() {
platformKey := Trim(this.guiObj["Platform"].Text)
config := Map("Platform", platformKey)
platform := this.app.Service("PlatformManager").GetItem(platformKey)
platform := this.app.Service("manager.platform").GetItem(platformKey)

if (platform) {
config["LauncherType"] := platform.platform.launcherType
Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Gui/Form/LauncherCreateFormBase.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
dataSource := ""

__New(container, themeObj, config) {
this.dataSource := container.Get("DataSourceManager").GetDefaultDataSource()
this.dataSource := container.Get("manager.datasource").GetDefaultDataSource()
super.__New(container, themeObj, config)
}

Expand Down
2 changes: 1 addition & 1 deletion Lib/Launchpad/Gui/Form/LauncherWizard.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
GetLauncherConfig() {
platformKey := Trim(this.guiObj["Platform"].Text)
config := Map("Platform", platformKey, "GameInstallDir", this.installDir, "GameExe", this.exe)
platform := this.app.Service("PlatformManager").GetItem(platformKey)
platform := this.app.Service("manager.platform").GetItem(platformKey)

if (platform) {
config["LauncherType"] := platform.platform.launcherType
Expand Down
Loading

0 comments on commit 50bdffb

Please sign in to comment.