Differential D3243 Diff 16276 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/AIConfigButton.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/AIConfigButton.js
PlayerSettingControls.AIConfigButton = class extends GameSettingControl | PlayerSettingControls.AIConfigButton = class extends GameSettingControl | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.aiConfigButton = Engine.GetGUIObjectByName("aiConfigButton[" + this.playerIndex + "]"); | this.aiConfigButton = Engine.GetGUIObjectByName("aiConfigButton[" + this.playerIndex + "]"); | ||||
g_NewGameSettings.playerAI.watch(() => this.render(), ["values"]); | |||||
// Save little performance by not reallocating every call | // Save little performance by not reallocating every call | ||||
this.sprintfArgs = {}; | this.sprintfArgs = {}; | ||||
this.render(); | |||||
} | } | ||||
onLoad() | onLoad() | ||||
{ | { | ||||
let aiConfigPage = this.setupWindow.pages.AIConfigPage; | let aiConfigPage = this.setupWindow.pages.AIConfigPage; | ||||
this.aiConfigButton.onPress = aiConfigPage.openPage.bind(aiConfigPage, this.playerIndex); | this.aiConfigButton.onPress = aiConfigPage.openPage.bind(aiConfigPage, this.playerIndex); | ||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex); | this.aiConfigButton.hidden = !g_NewGameSettings.playerAI.get(this.playerIndex); | ||||
if (!pData) | if (this.aiConfigButton.hidden) | ||||
return; | return; | ||||
this.sprintfArgs.description = g_NewGameSettings.playerAI.describe(this.playerIndex); | |||||
this.sprintfArgs.description = translateAISettings(pData); | |||||
this.aiConfigButton.tooltip = sprintf(this.Tooltip, this.sprintfArgs); | this.aiConfigButton.tooltip = sprintf(this.Tooltip, this.sprintfArgs); | ||||
this.aiConfigButton.hidden = !pData.AI; | |||||
} | } | ||||
}; | }; | ||||
PlayerSettingControls.AIConfigButton.prototype.Tooltip = | PlayerSettingControls.AIConfigButton.prototype.Tooltip = | ||||
translate("Configure AI: %(description)s."); | translate("Configure AI: %(description)s."); |
Wildfire Games · Phabricator