Differential D3243 Diff 16503 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/LockedTeams.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/LockedTeams.js
GameSettingControls.LockedTeams = class extends GameSettingControlCheckbox | GameSettingControls.LockedTeams = class LockedTeams extends GameSettingControlCheckbox | ||||
{ | { | ||||
onMapChange(mapData) | constructor(...args) | ||||
{ | { | ||||
let mapValue; | super(...args); | ||||
if (mapData && | g_NewGameSettings.map.watch(() => this.render(), ["type"]); | ||||
mapData.settings && | g_NewGameSettings.rating.watch(() => this.render(), ["available", "enabled"]); | ||||
mapData.settings.LockTeams !== undefined) | this.render(); | ||||
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; | |||||
if (g_GameAttributes.settings.LockTeams === undefined || | onLoad() | ||||
g_GameAttributes.settings.RatingEnabled && !g_GameAttributes.settings.LockTeams) | |||||
{ | { | ||||
g_GameAttributes.settings.LockTeams = g_IsNetworked; | g_NewGameSettings.lockedTeams.setEnabled(this.DefaultValue); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
if (!g_GameAttributes.mapType) | this.setEnabled(g_NewGameSettings.map.type != "scenario" && g_NewGameSettings.lockedTeams.available); | ||||
return; | this.setChecked(g_NewGameSettings.lockedTeams.enabled); | ||||
this.setChecked(g_GameAttributes.settings.LockTeams); | |||||
this.setEnabled( | |||||
g_GameAttributes.mapType != "scenario" && | |||||
!g_GameAttributes.settings.RatingEnabled); | |||||
} | } | ||||
onPress(checked) | onPress(checked) | ||||
{ | { | ||||
g_GameAttributes.settings.LockTeams = checked; | g_NewGameSettings.lockedTeams.setEnabled(checked); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.LockedTeams.prototype.TitleCaption = | GameSettingControls.LockedTeams.prototype.TitleCaption = | ||||
translate("Teams Locked"); | translate("Teams Locked"); | ||||
GameSettingControls.LockedTeams.prototype.Tooltip = | GameSettingControls.LockedTeams.prototype.Tooltip = | ||||
translate("Toggle locked teams."); | translate("Toggle locked teams."); | ||||
/** | /** | ||||
* In multiplayer mode, players negotiate teams before starting the match and | * In multiplayer mode, players negotiate teams before starting the match and | ||||
* expect to play the match with these teams unless explicitly stated otherwise during the match settings. | * expect to play the match with these teams unless explicitly stated otherwise during the match settings. | ||||
* For singleplayermode, preserve the historic default of open diplomacies. | * For singleplayermode, preserve the historic default of open diplomacies. | ||||
*/ | */ | ||||
GameSettingControls.LockedTeams.prototype.DefaultValue = Engine.HasNetClient(); | GameSettingControls.LockedTeams.prototype.DefaultValue = Engine.HasNetClient(); |
Wildfire Games · Phabricator