Differential D3243 Diff 16276 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/LastManStanding.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/LastManStanding.js
GameSettingControls.LastManStanding = class extends GameSettingControlCheckbox | GameSettingControls.LastManStanding = class extends GameSettingControlCheckbox | ||||
{ | { | ||||
onMapChange(mapData) | constructor(...args) | ||||
{ | { | ||||
let mapValue; | super(...args); | ||||
if (mapData && | g_NewGameSettings.lastManStanding.watch(() => this.render(), ["enabled", "available"]); | ||||
mapData.settings && | g_NewGameSettings.map.watch(() => this.render(), ["type"]); | ||||
mapData.settings.LastManStanding !== undefined) | |||||
mapValue = !mapData.settings.LockTeams && | |||||
mapData.settings.LastManStanding; | |||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.LastManStanding) | |||||
{ | |||||
g_GameAttributes.settings.LastManStanding = mapValue; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesChange() | |||||
{ | |||||
if (!g_GameAttributes.mapType) | |||||
return; | |||||
this.available = !g_GameAttributes.settings.LockTeams; | |||||
if (this.available) | |||||
{ | |||||
if (g_GameAttributes.settings.LastManStanding === undefined) | |||||
{ | |||||
g_GameAttributes.settings.LastManStanding = false; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
else if (g_GameAttributes.settings.LastManStanding !== undefined) | |||||
{ | |||||
delete g_GameAttributes.settings.LastManStanding; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
if (!g_GameAttributes.mapType) | |||||
return; | |||||
// Always display this, so that players are aware that there is this gamemode | // Always display this, so that players are aware that there is this gamemode | ||||
this.setChecked(!!g_GameAttributes.settings.LastManStanding); | this.setChecked(g_NewGameSettings.lastManStanding.enabled); | ||||
this.setEnabled(g_GameAttributes.mapType != "scenario" && !g_GameAttributes.settings.LockTeams); | this.setEnabled(g_NewGameSettings.map.type != "scenario" && | ||||
g_NewGameSettings.lastManStanding.available); | |||||
} | } | ||||
onPress(checked) | onPress(checked) | ||||
{ | { | ||||
g_GameAttributes.settings.LastManStanding = checked; | g_NewGameSettings.lastManStanding.setEnabled(checked); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.LastManStanding.prototype.TitleCaption = | GameSettingControls.LastManStanding.prototype.TitleCaption = | ||||
translate("Last Man Standing"); | translate("Last Man Standing"); | ||||
GameSettingControls.LastManStanding.prototype.Tooltip = | GameSettingControls.LastManStanding.prototype.Tooltip = | ||||
translate("Toggle whether the last remaining player or the last remaining set of allies wins."); | translate("Toggle whether the last remaining player or the last remaining set of allies wins."); |
Wildfire Games · Phabricator