Skip to content

Commit

Permalink
Finish replacing all select fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcclure committed Apr 4, 2021
1 parent fa24872 commit 13438e3
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 83 deletions.
4 changes: 2 additions & 2 deletions Lib/Launchpad/Window/EntityEditor/LauncherEditor.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class LauncherEditor extends LauncherEditorBase {
this.AddTextBlock("DisplayName", "Display Name", true, "You can change the display name of the game if it differs from the key. The launcher filename will still be created using the key.")

this.AddEntityCtl("Platform", "Platform", false, "SelectControl", this.platforms, "OnPlatformChange")
this.AddEntityTypeSelect("Launcher", "LauncherType", this.entityObj.ManagedLauncher.EntityType, this.launcherTypes, "LauncherConfiguration", "This tells " . this.app.appName . " how to interact with any launcher your game might require. If your game's launcher isn't listed, or your game doesn't have a launcher, start with `"Default`".")
this.AddEntityTypeSelect("Game", "GameType", this.entityObj.ManagedLauncher.ManagedGame.EntityType, this.gameTypes, "GameConfiguration", "This tells " . this.app.appName . " how to launch your game. Most games can use 'default', but launchers can support different game types.")
this.AddEntityCtl("Launcher", "LauncherType", false, "SelectControl", this.launcherTypes, "OnLauncherTypeChange", "This tells " . this.app.appName . " how to interact with any launcher your game might require. If your game's launcher isn't listed, or your game doesn't have a launcher, start with `"Default`".", "Manage", "OnManageLauncherType")
this.AddEntityCtl("Game", "GameType", false, "SelectControl", this.gameTypes, "OnGameTypeChange", "This tells " . this.app.appName . " how to launch your game. Most games can use 'default', but launchers can support different game types.", "Manage", "OnManageGameType")

tabs.UseTab("Sources", true)
this.AddEntityCtl("Icon Source", "IconSrc", true, "LocationBlock", "IconSrc", "Clear", true)
Expand Down
4 changes: 2 additions & 2 deletions Lib/Launchpad/Window/EntityEditor/LauncherEditorBase.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class LauncherEditorBase extends EntityEditorBase {
this.entityObj.ManagedLauncher.ManagedGame.UpdateDataSourceDefaults()
}

OnLauncherConfiguration(ctlObj, info) {
OnManageLauncherType(ctlObj, info) {
entity := this.entityObj.ManagedLauncher
diff := entity.Edit(this.mode, this.guiObj)

Expand All @@ -121,7 +121,7 @@ class LauncherEditorBase extends EntityEditorBase {
}
}

OnGameConfiguration(ctlObj, info) {
OnManageGameType(ctlObj, info) {
entity := this.entityObj.ManagedLauncher.ManagedGame
diff := entity.Edit(this.mode, this.guiObj)

Expand Down
7 changes: 2 additions & 5 deletions Lib/Launchpad/Window/EntityEditor/LauncherEditorSimple.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ class LauncherEditorSimple extends LauncherEditorBase {
this.AddEntityCtl("Platform", "Platform", false, "SelectControl", this.platforms, "OnPlatformChange", "Select the platform that this game is run through.")

tabs.UseTab("Launcher", true)

this.AddEntityTypeSelect("Launcher", "LauncherType", this.entityObj.ManagedLauncher.EntityType, this.launcherTypes, "", "This tells " . this.app.appName . " how to interact with any launcher your game might require. If your game's launcher isn't listed, or your game doesn't have a launcher, start with `"Default`".", false)
this.Add("EntityControl", "", "Launcher", this.entityObj.ManagedLauncher, "LauncherType", false, "SelectControl", this.launcherTypes, "OnLauncherTypeChange", "This tells " . this.app.appName . " how to interact with any launcher your game might require. If your game's launcher isn't listed, or your game doesn't have a launcher, start with `"Default`"")
this.AddCheckBoxBlock("CloseBeforeRun", "Close launcher before run", true, "If selected, the launcher will be closed before attempting to run the game. This can be useful to ensure the process starts under " . this.app.appName . "'s process instead of the existing launcher's process.", true, this.entityObj.ManagedLauncher)
this.AddCheckBoxBlock("CloseAfterRun", "Close launcher after run", true, "If selected, the launcher will be closed after the game closes. This can be useful to ensure Steam or other applications know you are done playing the game.", true, this.entityObj.ManagedLauncher)

tabs.UseTab("Game", true)

this.AddEntityTypeSelect("Game", "GameType", this.entityObj.ManagedLauncher.ManagedGame.EntityType, this.gameTypes, "", "This tells " . this.app.appName . " how to launch your game. Most games can use 'default', but launchers can support different game types.", false)

this.Add("EntityControl", "", "Game", this.entityObj.ManagedLauncher.ManagedGame, "GameType", false, "SelectControl", this.gameTypes, "OnGameTypeChange", "This tells " . this.app.appName . " how to launch your game. Most games can use 'default', but launchers can support different game types.")
this.Add("EntityControl", "", "Game Install Directory", this.entityObj.ManagedLauncher.ManagedGame, "GameInstallDir", true, "LocationBlock", "GameInstallDir", "Clear", true, "Select the installation folder, or use default for auto-detection.")
this.Add("EntityControl", "", "Game Executable", this.entityObj.ManagedLauncher.ManagedGame, "GameExe", true, "LocationBlock", "GameExe", "Clear", true, "The main .exe file, not including any path information.")
this.AddCheckBoxBlock("ReplaceProcess", "Replace process after launching", true, "After the process is detected, immediately kill and re-launch it so that " . this.app.appName . " is its parent process.", true, this.entityObj.ManagedLauncher.ManagedGame)
Expand Down
9 changes: 2 additions & 7 deletions Lib/Launchpad/Window/EntityEditor/ManagedEntityEditorBase.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class ManagedEntityEditorBase extends EntityEditorBase {
tabs := this.guiObj.Add("Tab3", " x" . this.margin . " w" . this.windowSettings["contentWidth"] . " +0x100", this.GetTabNames())

tabs.UseTab(this.entityTypeName, true)
this.AddEntityTypeSelect(prefix . " Type", "Type", this.entityObj.EntityType, this.entityObj.ListEntityTypes(), "", "You can select from the available entity types if the default doesn't work for your use case.")

this.AddEntityCtl(prefix . " Type", prefix . "Type", false, "SelectControl", this.entityObj.ListEntityTypes(), "On" . prefix . "TypeChange", "You can select from the available entity types if the default doesn't work for your use case.")
this.AddEntityCtl(prefix . " Executable", prefix . "Exe", true, "LocationBlock", prefix . "Exe", "Clear", true, "The main .exe file, not including any path information.")
this.AddTextBlock("WindowTitle", prefix . " Window Title", true, "The part of the main window's title which identifies it uniquely.", true)
this.CustomTabControls()
Expand Down Expand Up @@ -117,12 +118,6 @@ class ManagedEntityEditorBase extends EntityEditorBase {
return this.SetDefaultValue("LauncherSpecificId", !!(ctlObj.Value), true)
}

OnTypeChange(ctlObj, info) {
this.guiObj.Submit(false)
this.entityObj.EntityType := ctlObj.Text
this.entityObj.UpdateDataSourceDefaults()
}

OnWindowTitleChange(ctlObj, info) {
this.guiObj.Submit(false)
this.entityObj.WindowTitle := ctlObj.Value
Expand Down
8 changes: 7 additions & 1 deletion Lib/Launchpad/Window/EntityEditor/ManagedGameEditor.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ class ManagedGameEditor extends ManagedEntityEditorBase {
this.guiObj.Submit(false)
this.entityObj.ProcessType := ctlObj.Text
this.entityObj.UpdateDataSourceDefaults()
this.guiObj["GameProcessId"].Value := this.entityObj.ProcessId
this.guiObj["GameProcessId"].Value := this.entityObj.Config["GameProcessId"]
}

OnGameProcessIdChange(ctlObj, info) {
this.guiObj.Submit(false)
this.entityObj.ProcessId := ctlObj.Value
}

OnGameTypeChange(ctlObj, info) {
this.guiObj.Submit(false)
this.entityObj.EntityType := ctlObj.Text
this.entityObj.UpdateDataSourceDefaults()
}
}
8 changes: 7 additions & 1 deletion Lib/Launchpad/Window/EntityEditor/ManagedLauncherEditor.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,17 @@ class ManagedLauncherEditor extends ManagedEntityEditorBase {
this.guiObj.Submit(false)
this.entityObj.ProcessType := ctlObj.Text
this.entityObj.UpdateDataSourceDefaults()
this.guiObj["LauncherProcessId"].Value := this.entityObj.ProcessId
this.guiObj["LauncherProcessId"].Value := this.entityObj.Config["LauncherProcessId"]
}

OnLauncherProcessIdChange(ctlObj, info) {
this.guiObj.Submit(false)
this.entityObj.ProcessId := ctlObj.Value
}

OnLauncherTypeChange(ctlObj, info) {
this.guiObj.Submit(false)
this.entityObj.EntityType := ctlObj.Text
this.entityObj.UpdateDataSourceDefaults()
}
}
4 changes: 2 additions & 2 deletions Lib/Launchpad/Window/Form/DetectedGameEditor.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
Controls() {
super.Controls()
this.AddComboBox("Key", "Key", this.detectedGameObj.key, this.knownGames, "You can change the detected game key here, which will become the name of your launcher. Your existing launchers, and all launchers known about via the API, can be selected to match this game up with one of those items.")
this.AddEntityTypeSelect("Launcher Type", "LauncherType", this.detectedGameObj.launcherType, this.launcherTypes, "", "This tells " . this.app.appName . " how to interact with any launcher your game might require. If your game's launcher isn't listed, or your game doesn't have a launcher, start with `"Default`".`n`nYou can customize the details of the launcher type after it is added.")
this.AddEntityTypeSelect("Game Type", "GameType", this.detectedGameObj.gameType, this.gameTypes, "", "This tells " . this.app.appName . " how to launch your game. Most games can use 'default', but launchers can support different game types.`n`nYou can customize the details of the game type after it is added.")
this.Add("SelectControl", "vLauncherType", "Launcher Type", this.detectedGameObj.launcherType, this.launcherTypes, "OnLauncherTypeChange", "This tells " . this.app.appName . " how to interact with any launcher your game might require. If your game's launcher isn't listed, or your game doesn't have a launcher, start with `"Default`".`n`nYou can customize the details of the launcher type after it is added.")
this.Add("SelectControl", "vGameType", "Game Type", this.detectedGameObj.gameType, this.gameTypes, "OnGameTypeChange", "This tells " . this.app.appName . " how to launch your game. Most games can use 'default', but launchers can support different game types.`n`nYou can customize the details of the game type after it is added.")
this.Add("LocationBlock", "", "Install Dir", this.detectedGameObj.installDir, "InstallDir", "", true, "This is the directory that the game is installed in, if it could be detected.")
this.AddComboBox("Exe", "Exe", this.detectedGameObj.exeName, this.detectedGameObj.possibleExeNames, "The main Exe, if detected, should be pre-selected. You may change it to be the name (or path) of another exe, or select another one of the detected .exe files from the list (if more than one was found).")
this.AddTextBlock("Launcher-Specific ID", "LauncherSpecificId", this.detectedGameObj.launcherSpecificId, "This is typically the ID which the game platform or launcher uses when referring to the game internally. Changing this value could cause issues with game launching.")
Expand Down
7 changes: 2 additions & 5 deletions Lib/Launchpad/Window/Form/ImportShortcutForm.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
shortcutSrc := ""
gameKey := ""
shortcutExt := ""
defaultPlatform := ""

__New(app, themeObj, windowKey, owner := "", parent := "") {
this.AskShortcutSrc()
Expand All @@ -15,11 +16,7 @@
Controls() {
super.Controls()
this.Add("LocationBlock", "", "Shortcut", this.shortcutSrc, "ShortcutSrc", "", true, "Select the shortcut file that launches the game")
this.AddSelect("Platform", "Platform", "", this.knownPlatforms, false, "", "", "Select the platform that this game is run through.", false)
}

OnPlatformChange(ctlObj, info) {

this.Add("SelectControl", "", "Platform", "", this.knownPlatforms, this.defaultPlatform, "Select the platform that this game is run through.")
}

GetLauncherKey() {
Expand Down
7 changes: 2 additions & 5 deletions Lib/Launchpad/Window/Form/LauncherWizard.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class LauncherWizard extends LauncherCreateFormBase {
installDir := ""
exe := ""
defaultPlatform := ""

__New(app, themeObj, windowKey, owner := "", parent := "") {
super.__New(app, themeObj, windowKey, "Launcher Wizard", owner, parent)
Expand All @@ -13,7 +14,7 @@
Controls() {
super.Controls()
this.AddComboBox("Key", "Key", "", this.knownGames, "Select an existing game from the API, or enter a custom game key to create your own. If choosing an existing game, most advanced values can be loaded from the API.")
this.AddSelect("Platform", "Platform", "", this.knownPlatforms, false, "", "", "Select the platform that this game is run through.", false)
this.Add("SelectControl", "", "Platform", defaultPlatform, this.knownPlatforms, "", "Select the platform that this game is run through.")
this.Add("LocationBlock", "", "Install Dir", this.installDir, "InstallDir", "", true, "Select the directory the game is installed in")
this.Add("LocationBlock", "", "Game Exe", this.exe, "Exe", "", true, "Select the game's main .exe file")
}
Expand All @@ -22,10 +23,6 @@

}

OnPlatformChange(ctlObj, info) {

}

GetLauncherKey() {
return this.guiObj["Key"].Text
}
Expand Down
47 changes: 0 additions & 47 deletions Lib/Shared/AppLib/Gui/Form/FormGuiBase.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -65,53 +65,6 @@ class FormGuiBase extends GuiBase {
}
}

AddEntityTypeSelect(heading, field, currentValue, allItems, buttonName := "", helpText := "", showManage := true) {
return this.AddSelect(heading, field, currentValue, allItems, false, buttonName, showManage ? "Manage" : "", helpText, false)
}

AddSelect(heading, field, currentValue, allItems, showDefaultCheckbox := false, buttonName := "", buttonText := "", helpText := "", addPrefix := false) {
this.AddHeading(heading)

checkW := 0
buttonW := buttonName ? 150 : 0
disabledText := ""

prefixedName := field
if (addPrefix) {
prefixedName := this.entityObj.configPrefix . field
}

if (showDefaultCheckbox) {
disabledText := this.entityObj.UnmergedConfig.Has(prefixedName) ? "" : " Disabled"
ctl := this.DefaultCheckbox(field, "", addPrefix)
ctl.GetPos(,,checkW)
}

fieldW := this.windowSettings["contentWidth"]

if (checkW) {
fieldW := fieldW - checkW - this.margin
}

if (buttonW) {
fieldW := fieldW - buttonW - this.margin
}

chosen := this.GetItemIndex(allItems, currentValue)
pos := showDefaultCheckbox ? "x+m yp" : "xs y+m"
pos := pos . disabledText
ctl := this.guiObj.AddDDL("v" . field . " " . pos . " Choose" . chosen . " w" . fieldW . " c" . this.themeObj.GetColor("editText"), allItems)
ctl.OnEvent("Change", "On" . field . "Change")

if (buttonName) {
this.Add("ButtonControl", "v" . buttonName . " x+m yp w" . buttonW . " h25", buttonText, "On" . buttonName)
}

if (helpText) {
ctl.ToolTip := helpText
}
}

DefaultCheckbox(fieldKey, entity, addPrefix := false, includePrefixInCtlName := false) {
prefixedName := fieldKey
if (addPrefix) {
Expand Down
2 changes: 1 addition & 1 deletion Lib/Shared/AppLib/GuiControl/EntityControl.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EntityControl extends GuiControlBase {

defaultX := checkW ? "x+" . this.guiObj.margin : "x" . this.guiObj.margin
defaultY := checkW ? "yp" : "y+" . this.guiObj.margin
defaults := ["w" . controlW, defaultX, defaultY]
defaults := ["w" . controlW, defaultX, defaultY, "v" . fieldName]
opts := this.SetDefaultOptions(this.options, defaults)
text := (this.entityObj.Config.Has(this.fieldName) && this.entityObj.Config[this.fieldName] != "") ? this.entityObj.Config[this.fieldName] : this.emptyValue
this.innerControl := this.guiObj.Add(controlClass, this.GetOptionsString(opts), "", text, params*)
Expand Down
19 changes: 14 additions & 5 deletions Lib/Shared/AppLib/GuiControl/SelectControl.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@ class SelectControl extends GuiControlBase {
super.CreateControl()
this.selectOptions := selectOptions

buttonW := buttonText ? this.CalculateTextWidth(buttonText) : 0
buttonW := buttonText ? (this.guiObj.themeObj.CalculateTextWidth(buttonText) + this.guiObj.margin*2) : 0

fieldW := this.guiObj.windowSettings["contentWidth"]
opts := this.options.Clone()
w := this.GetOption(opts, "w")

if (w) {
w := SubStr(w, 2)
} else {
w := this.guiObj.windowSettings["contentWidth"]
}

if (buttonW) {
fieldW -= (buttonW + this.margin)
w -= (buttonW + this.guiObj.margin)
}
this.SetOption(opts, "w", w)

fieldW := w
index := this.GetItemIndex(value)
opts := this.SetDefaultOptions(this.options.Clone(), ["Choose" . index, "c" . this.guiObj.themeObj.GetColor("editText")])
opts := this.SetDefaultOptions(opts, ["w" . fieldW, "Choose" . index, "c" . this.guiObj.themeObj.GetColor("editText")])
ctl := this.guiObj.guiObj.AddDDL(this.GetOptionsString(opts), this.selectOptions)
this.ctl := ctl

Expand All @@ -29,7 +38,7 @@ class SelectControl extends GuiControlBase {

if (buttonText) {
opts := this.SetDefaultOptions(buttonOpts, "x+m yp w" . buttonW . " h25")
this.btnCtl := this.Add("ButtonControl", this.GetOptionsString(opts), buttonText, buttonHandler)
this.btnCtl := this.guiObj.Add("ButtonControl", this.GetOptionsString(opts), buttonText, buttonHandler)
}

return this.ctl
Expand Down

0 comments on commit 13438e3

Please sign in to comment.