Differential D3243 Diff 16284 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/GameSpeed.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/GameSpeed.js
GameSettingControls.GameSpeed = class extends GameSettingControlDropdown | GameSettingControls.GameSpeed = class extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.previousAllowFastForward = undefined; | this.previousAllowFastForward = undefined; | ||||
} | |||||
onMapChange(mapData) | g_NewGameSettings.gameSpeed.watch(() => this.render(), ["gameSpeed"]); | ||||
{ | this.render(); | ||||
let mapValue; | |||||
if (mapData && mapData.gameSpeed !== undefined) | |||||
mapValue = mapData.gameSpeed; | |||||
if (mapValue !== undefined && mapValue != g_GameAttributes.gameSpeed) | |||||
{ | |||||
g_GameAttributes.gameSpeed = mapValue; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | } | ||||
onPlayerAssignmentsChange() | onPlayerAssignmentsChange() | ||||
{ | { | ||||
this.update(); | this.render(); | ||||
} | |||||
onGameAttributesChange() | |||||
{ | |||||
this.update(); | |||||
} | } | ||||
update() | render() | ||||
{ | { | ||||
let allowFastForward = true; | let allowFastForward = true; | ||||
for (let guid in g_PlayerAssignments) | for (let guid in g_PlayerAssignments) | ||||
if (g_PlayerAssignments[guid].player != -1) | if (g_PlayerAssignments[guid].player != -1) | ||||
{ | { | ||||
allowFastForward = false; | allowFastForward = false; | ||||
break; | break; | ||||
} | } | ||||
if (this.previousAllowFastForward !== allowFastForward) | if (this.previousAllowFastForward !== allowFastForward) | ||||
{ | { | ||||
Engine.ProfileStart("updateGameSpeedList"); | |||||
this.previousAllowFastForward = allowFastForward; | this.previousAllowFastForward = allowFastForward; | ||||
this.values = prepareForDropdown( | let values = prepareForDropdown( | ||||
g_Settings.GameSpeeds.filter(speed => !speed.FastForward || allowFastForward)); | g_Settings.GameSpeeds.filter(speed => !speed.FastForward || allowFastForward)); | ||||
this.dropdown.list = this.values.Title; | this.dropdown.list = values.Title; | ||||
this.dropdown.list_data = this.values.Speed; | this.dropdown.list_data = values.Speed; | ||||
Engine.ProfileStop(); | |||||
} | |||||
if (this.values.Speed.indexOf(g_GameAttributes.gameSpeed || undefined) == -1) | |||||
{ | |||||
g_GameAttributes.gameSpeed = this.values.Speed[this.values.Default]; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | } | ||||
onGameAttributesBatchChange() | this.setSelectedValue(g_NewGameSettings.gameSpeed.gameSpeed); | ||||
{ | |||||
this.setSelectedValue(g_GameAttributes.gameSpeed); | |||||
} | } | ||||
onSelectionChange(itemIdx) | onSelectionChange(itemIdx) | ||||
{ | { | ||||
g_GameAttributes.gameSpeed = this.values.Speed[itemIdx]; | g_NewGameSettings.gameSpeed.setSpeed(this.dropdown.list_data[itemIdx]); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.GameSpeed.prototype.TitleCaption = | GameSettingControls.GameSpeed.prototype.TitleCaption = | ||||
translate("Game Speed"); | translate("Game Speed"); | ||||
GameSettingControls.GameSpeed.prototype.Tooltip = | GameSettingControls.GameSpeed.prototype.Tooltip = | ||||
translate("Select game speed."); | translate("Select game speed."); |
Wildfire Games · Phabricator