Skip to content

Commit

Permalink
Create a custom tray menu for Launchpad
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcclure committed Apr 4, 2021
1 parent 2e8175c commit 7414e58
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Lib/Launchpad/Includes.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
#Include Window\Form\SettingsWindow.ahk
#Include Window\Form\SetupWindow.ahk
#Include Window\ManageWindow\DetectedGamesWindow.ahk
#Include Window\ManageWindow\ManageBackupsWindow.ahk
#Include Window\ManageWindow\MainWindow.ahk
#Include Window\ManageWindow\ManageBackupsWindow.ahk
#Include Window\ManageWindow\ManageWindowBase.ahk
#Include Window\ManageWindow\PlatformsWindow.ahk
; End of auto-generated includes.
36 changes: 26 additions & 10 deletions Lib/Launchpad/Launchpad.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Launchpad extends AppBase {
class Launchpad extends AppBase {
customTrayMenu := true

Launchers {
get => this.Services.Get("LauncherManager")
set => this.Services.Set("LauncherManager", value)
Expand Down Expand Up @@ -71,27 +73,41 @@ class Launchpad extends AppBase {
}
}

OnUpdateIncludes(itemName, itemPos, menu) {
UpdateIncludes() {
RunWait(this.appDir . "\Scripts\UpdateIncludes.bat", this.appDir . "\Scripts")
Reload()
}

OnBuildLaunchpad(itemName, itemPos, menu) {
BuildApp() {
Run(this.appDir . "\Scripts\Build.bat", this.appDir . "\Scripts")
}

InitializeApp(config) {
super.InitializeApp(config)
SetTrayMenuItems(menuItems) {
menuItems := super.SetTrayMenuItems(menuItems)

if (!A_IsCompiled) {
this.updateIncludesCallback := ObjBindMethod(this, "OnUpdateIncludes")
this.buildLaunchpadCallback := ObjBindMethod(this, "OnBuildLaunchpad")
menuItems.Push("")
menuItems.Push(Map("label", "Build Launchpad", "name", "BuildApp"))
menuItems.Push(Map("label", "Update Includes", "name", "UpdateIncludes"))
}

return menuItems
}

trayMenu := A_TrayMenu
trayMenu.Add("Update Includes", this.updateIncludesCallback)
trayMenu.Add("Build " . this.appName, this.buildLaunchpadCallback)
HandleTrayMenuClick(result) {
result := super.HandleTrayMenuClick(result)

if (result == "BuildApp") {
this.BuildApp()
} else if (result == "UpdateIncludes") {
this.UpdateIncludes()
}

return result
}

InitializeApp(config) {
super.InitializeApp(config)
this.Builders.SetItem("ahk", AhkLauncherBuilder.new(this), true)
this.Installers.SetItem("LaunchpadUpdate", LaunchpadUpdate.new(this.Version, this.State, this.Cache.GetItem("file"), this.tmpDir))
this.Installers.SetItem("Dependencies", DependencyInstaller.new(this.Version, this.State, this.Cache.GetItem("file"), [], this.tmpDir))
Expand Down

0 comments on commit 7414e58

Please sign in to comment.