Differential D3243 Diff 16556 ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/Nomad.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/Nomad.js
GameSettingControls.Nomad = class extends GameSettingControlCheckbox | GameSettingControls.Nomad = class Nomad extends GameSettingControlCheckbox | ||||
{ | { | ||||
onMapChange(mapData) | constructor(...args) | ||||
{ | { | ||||
let available = g_GameAttributes.mapType == "random"; | super(...args); | ||||
this.setHidden(!available); | g_GameSettings.nomad.watch(() => this.render(), ["enabled"]); | ||||
if (!available) | g_GameSettings.map.watch(() => this.render(), ["type"]); | ||||
return; | this.render(); | ||||
let mapValue; | |||||
if (mapData && | |||||
mapData.settings && | |||||
mapData.settings.Nomad !== undefined) | |||||
mapValue = mapData.settings.Nomad; | |||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.Nomad) | |||||
{ | |||||
g_GameAttributes.settings.Nomad = mapValue; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | } | ||||
onGameAttributesChange() | render() | ||||
{ | { | ||||
if (!g_GameAttributes.mapType) | this.setHidden(g_GameSettings.map.type != "random"); | ||||
return; | this.setChecked(g_GameSettings.nomad.enabled); | ||||
if (g_GameAttributes.mapType == "random") | |||||
{ | |||||
if (g_GameAttributes.settings.Nomad === undefined) | |||||
{ | |||||
g_GameAttributes.settings.Nomad = false; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
else if (g_GameAttributes.settings.Nomad !== undefined) | |||||
{ | |||||
delete g_GameAttributes.settings.Nomad; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesBatchChange() | |||||
{ | |||||
if (!g_GameAttributes.mapType) | |||||
return; | |||||
if (g_GameAttributes.mapType == "random") | |||||
this.setChecked(g_GameAttributes.settings.Nomad); | |||||
} | } | ||||
onPress(checked) | onPress(checked) | ||||
{ | { | ||||
g_GameAttributes.settings.Nomad = checked; | g_GameSettings.nomad.setEnabled(checked); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.Nomad.prototype.TitleCaption = | GameSettingControls.Nomad.prototype.TitleCaption = | ||||
translate("Nomad"); | translate("Nomad"); | ||||
GameSettingControls.Nomad.prototype.Tooltip = | GameSettingControls.Nomad.prototype.Tooltip = | ||||
translate("In Nomad mode, players start with only few units and have to find a suitable place to build their city. Ceasefire is recommended."); | translate("In Nomad mode, players start with only few units and have to find a suitable place to build their city. Ceasefire is recommended."); |
Wildfire Games · Phabricator