Differential D3243 Diff 16556 ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIDescription.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/AIConfigPage/AIDescription.js
class AIDescription | class AIDescription | ||||
{ | { | ||||
constructor(aiConfigPage, setupWindow) | constructor(aiConfigPage, setupWindow) | ||||
{ | { | ||||
this.playerIndex = undefined; | this.playerIndex = undefined; | ||||
this.aiDescription = Engine.GetGUIObjectByName("aiDescription"); | this.aiDescription = Engine.GetGUIObjectByName("aiDescription"); | ||||
this.gameSettingsControl = setupWindow.controls.gameSettingsControl; | |||||
this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); | |||||
aiConfigPage.registerOpenPageHandler(this.onOpenPage.bind(this)); | aiConfigPage.registerOpenPageHandler(this.onOpenPage.bind(this)); | ||||
g_GameSettings.playerAI.watch(() => this.render(), ["values"]); | |||||
} | } | ||||
onOpenPage(playerIndex) | onOpenPage(playerIndex) | ||||
{ | { | ||||
this.playerIndex = playerIndex; | this.playerIndex = playerIndex; | ||||
this.updateSelectedValue(); | this.render(); | ||||
} | |||||
onGameAttributesBatchChange() | |||||
{ | |||||
this.updateSelectedValue(); | |||||
} | } | ||||
updateSelectedValue() | render() | ||||
{ | { | ||||
let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex); | let AI = g_GameSettings.playerAI.get(this.playerIndex); | ||||
if (!pData) | if (!!AI) | ||||
return; | AI = g_Settings.AIDescriptions.find(desc => desc.id == AI.bot); | ||||
let AI = g_Settings.AIDescriptions.find(AI => AI.id == pData.AI); | |||||
this.aiDescription.caption = AI ? AI.data.description : this.NoAIDescription; | this.aiDescription.caption = AI ? AI.data.description : this.NoAIDescription; | ||||
} | } | ||||
} | } | ||||
AIDescription.prototype.NoAIDescription = | AIDescription.prototype.NoAIDescription = | ||||
translate("AI will be disabled for this player."); | translate("AI will be disabled for this player."); |
Wildfire Games · Phabricator