Differential D3007 Diff 13482 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControl.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControl.js
/** | /** | ||||
* The GameSettingControl is an abstract class that is inherited by gamesetting control classes specific to a GUI object type, | * The GameSettingControl is an abstract class that is inherited by game setting control classes specific to a GUI object type, | ||||
* such as the GameSettingControlCheckbox or GameSettingControlDropdown. | * such as the GameSettingControlCheckbox or GameSettingControlDropdown. | ||||
* | * | ||||
* These classes are abstract classes too and are implemented by each handler class specific to one logical setting of g_GameAttributes. | * These classes are abstract classes too and are implemented by each handler class specific to one logical setting of g_GameAttributes. | ||||
* The purpose of these classes is to control precisely one logical setting of g_GameAttributes. | * The purpose of these classes is to control precisely one logical setting of g_GameAttributes. | ||||
* Having one class per logical setting allows to handle each setting without making a restriction as to how the property should be written to g_GameAttributes or g_PlayerAssignments. | * Having one class per logical setting allows to handle each setting without making a restriction as to how the property should be written to g_GameAttributes or g_PlayerAssignments. | ||||
* The base classes allow implementing that while avoiding duplication. | * The base classes allow implementing that while avoiding duplication. | ||||
* | * | ||||
* A GameSettingControl may depend on and read from other g_GameAttribute values, | * A GameSettingControl may depend on and read from other g_GameAttribute values, | ||||
* but the class instance is to be the sole instance writing to its setting value in g_GameAttributes and | * but the class instance is to be the sole instance writing to its setting value in g_GameAttributes and | ||||
* shall not write to setting values of other logical settings. | * shall not write to setting values of other logical settings. | ||||
* | * | ||||
* The derived classes shall not make assumptions on the validity of g_GameAttributes, | * The derived classes shall not make assumptions on the validity of g_GameAttributes, | ||||
* sanitize or delete their value if it is incompatible. | * sanitize or delete their value if it is incompatible. | ||||
* | * | ||||
* A class should only write values to g_GameAttributes that it itself has confirmed to be accurate. | * A class should only write values to g_GameAttributes that it itself has confirmed to be accurate. | ||||
* This means that handlers may not copy an entire object or array of values, for example on mapchange. | * This means that handlers may not copy an entire object or array of values, for example on mapchange. | ||||
* This avoids writing a setting value to g_GameAttributes that is not tracked and deleted when it becomes invalid. | * This avoids writing a setting value to g_GameAttributes that is not tracked and deleted when it becomes invalid. | ||||
* | * | ||||
* Since GameSettingControls shall be able to subscribe to g_GameAttributes changes, | * Since GameSettingControls shall be able to subscribe to g_GameAttributes changes, | ||||
* it is an obligation of the derived GameSettingControl class to broadcast the GameAttributesChange event each time it changes g_GameAttributes. | * it is an obligation of the derived GameSettingControl class to broadcast the GameAttributesChange event each time it changes g_GameAttributes. | ||||
*/ | */ | ||||
class GameSettingControl | class GameSettingControl | ||||
{ | { | ||||
// The constructor and inherited constructors shall not modify game attributes, | // The constructor and inherited constructors shall not modify game attributes, | ||||
// since all GameSettingControl shall be able to subscribe to any gamesetting change. | // since all GameSettingControl shall be able to subscribe to any game setting change. | ||||
constructor(gameSettingControlManager, category, playerIndex, setupWindow) | constructor(gameSettingControlManager, category, playerIndex, setupWindow) | ||||
{ | { | ||||
// Store arguments | // Store arguments | ||||
{ | { | ||||
this.category = category; | this.category = category; | ||||
this.playerIndex = playerIndex; | this.playerIndex = playerIndex; | ||||
this.setupWindow = setupWindow; | this.setupWindow = setupWindow; | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator