Differential D2577 Diff 11116 ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlManager.js
/** | /** | ||||
* Each property of this class is a class that inherits GameSettingControl and is | * Each property of this class is a class that inherits GameSettingControl and is | ||||
* instantiated by the GameSettingControlManager. | * instantiated by the GameSettingControlManager. | ||||
*/ | */ | ||||
class GameSettingControls | class GameSettingControls | ||||
{ | { | ||||
} | } | ||||
/** | /** | ||||
* The GameSettingControlManager owns all classes that handle a logical property of g_GameAttributes. | * The GameSettingControlManager owns all classes that handle a logical property of g_GameAttributes. | ||||
*/ | */ | ||||
class GameSettingControlManager | class GameSettingControlManager | ||||
{ | { | ||||
constructor(setupWindow, gameSettingsControl, mapCache, mapFilters, netMessages, playerAssignmentsControl) | constructor(setupWindow) | ||||
{ | { | ||||
this.setupWindow = setupWindow; | |||||
this.rows = {}; | this.rows = {}; | ||||
this.gameSettingControls = {}; | this.gameSettingControls = {}; | ||||
let args = Array.from(arguments); | |||||
let getCategory = name => | let getCategory = name => | ||||
g_GameSettingsLayout.findIndex(category => category.settings.indexOf(name) != -1); | g_GameSettingsLayout.findIndex(category => category.settings.indexOf(name) != -1); | ||||
for (let name in GameSettingControls) | for (let name in GameSettingControls) | ||||
this.gameSettingControls[name] = | this.gameSettingControls[name] = | ||||
new GameSettingControls[name]( | new GameSettingControls[name]( | ||||
this, getCategory(name), undefined, ...args); | this, getCategory(name), undefined, setupWindow); | ||||
for (let victoryCondition of g_VictoryConditions) | for (let victoryCondition of g_VictoryConditions) | ||||
this.gameSettingControls[victoryCondition.Name] = | this.gameSettingControls[victoryCondition.Name] = | ||||
new VictoryConditionCheckbox( | new VictoryConditionCheckbox( | ||||
victoryCondition, this, getCategory(victoryCondition.Name), undefined, ...args); | victoryCondition, this, getCategory(victoryCondition.Name), undefined, setupWindow); | ||||
this.playerSettingControlManagers = Array.from( | this.playerSettingControlManagers = Array.from( | ||||
new Array(g_MaxPlayers), | new Array(g_MaxPlayers), | ||||
(value, playerIndex) => | (value, playerIndex) => | ||||
new PlayerSettingControlManager(playerIndex, ...args)); | new PlayerSettingControlManager(playerIndex, setupWindow)); | ||||
} | } | ||||
getNextRow(name) | getNextRow(name) | ||||
{ | { | ||||
if (this.rows[name] === undefined) | if (this.rows[name] === undefined) | ||||
this.rows[name] = 0; | this.rows[name] = 0; | ||||
else | else | ||||
++this.rows[name]; | ++this.rows[name]; | ||||
Show All 19 Lines |
Wildfire Games · Phabricator