Differential D2577 Diff 11116 ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControl.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControl.js
Show All 19 Lines | |||||
* | * | ||||
* 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 gamesetting change. | ||||
constructor(gameSettingControlManager, category, playerIndex, setupWindow, gameSettingsControl, mapCache, mapFilters, netMessages, playerAssignmentsControl) | constructor(gameSettingControlManager, category, playerIndex, setupWindow) | ||||
{ | { | ||||
// Store arguments | // Store arguments | ||||
{ | { | ||||
this.category = category; | this.category = category; | ||||
if (playerIndex !== undefined) | |||||
this.playerIndex = playerIndex; | this.playerIndex = playerIndex; | ||||
this.setupWindow = setupWindow; | this.setupWindow = setupWindow; | ||||
this.gameSettingsControl = gameSettingsControl; | this.gameSettingsControl = setupWindow.controls.gameSettingsControl; | ||||
this.mapCache = mapCache; | this.mapCache = setupWindow.controls.mapCache; | ||||
this.mapFilters = mapFilters; | this.mapFilters = setupWindow.controls.mapFilters; | ||||
this.netMessages = netMessages; | this.netMessages = setupWindow.controls.netMessages; | ||||
this.playerAssignmentsControl = playerAssignmentsControl; | this.playerAssignmentsControl = setupWindow.controls.playerAssignmentsControl; | ||||
} | } | ||||
// enabled and hidden should only be modified through their setters or | // enabled and hidden should only be modified through their setters or | ||||
// by calling updateVisibility after modification. | // by calling updateVisibility after modification. | ||||
this.enabled = true; | this.enabled = true; | ||||
this.hidden = false; | this.hidden = false; | ||||
if (this.setControl) | if (this.setControl) | ||||
this.setControl(gameSettingControlManager); | this.setControl(gameSettingControlManager); | ||||
// This variable also used for autocompleting chat. | // This variable also used for autocompleting chat. | ||||
this.autocompleteTitle = undefined; | this.autocompleteTitle = undefined; | ||||
if (this.title && this.TitleCaption) | if (this.title && this.TitleCaption) | ||||
this.setTitle(this.TitleCaption); | this.setTitle(this.TitleCaption); | ||||
if (this.Tooltip) | if (this.Tooltip) | ||||
this.setTooltip(this.Tooltip); | this.setTooltip(this.Tooltip); | ||||
this.setHidden(false); | this.setHidden(false); | ||||
if (this.onMapChange) | if (this.onMapChange) | ||||
gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this)); | this.gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this)); | ||||
if (this.onLoad) | if (this.onLoad) | ||||
setupWindow.registerLoadHandler(this.onLoad.bind(this)); | this.setupWindow.registerLoadHandler(this.onLoad.bind(this)); | ||||
if (this.onGameAttributesChange) | if (this.onGameAttributesChange) | ||||
gameSettingsControl.registerGameAttributesChangeHandler(this.onGameAttributesChange.bind(this)); | this.gameSettingsControl.registerGameAttributesChangeHandler(this.onGameAttributesChange.bind(this)); | ||||
if (this.onGameAttributesBatchChange) | if (this.onGameAttributesBatchChange) | ||||
gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); | this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); | ||||
if (this.onAssignPlayer && this.playerIndex === 0) | if (this.onAssignPlayer && this.playerIndex === 0) | ||||
this.gameSettingsControl.registerAssignPlayerHandler(this.onAssignPlayer.bind(this)); | this.gameSettingsControl.registerAssignPlayerHandler(this.onAssignPlayer.bind(this)); | ||||
if (this.onPickRandomItems) | if (this.onPickRandomItems) | ||||
gameSettingsControl.registerPickRandomItemsHandler(this.onPickRandomItems.bind(this)); | this.gameSettingsControl.registerPickRandomItemsHandler(this.onPickRandomItems.bind(this)); | ||||
if (this.onGameAttributesFinalize) | if (this.onGameAttributesFinalize) | ||||
gameSettingsControl.registerGameAttributesFinalizeHandler(this.onGameAttributesFinalize.bind(this)); | this.gameSettingsControl.registerGameAttributesFinalizeHandler(this.onGameAttributesFinalize.bind(this)); | ||||
if (this.onPlayerAssignmentsChange) | if (this.onPlayerAssignmentsChange) | ||||
playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.onPlayerAssignmentsChange.bind(this)); | this.playerAssignmentsControl.registerPlayerAssignmentsChangeHandler(this.onPlayerAssignmentsChange.bind(this)); | ||||
} | } | ||||
setTitle(titleCaption) | setTitle(titleCaption) | ||||
{ | { | ||||
this.autocompleteTitle = titleCaption; | this.autocompleteTitle = titleCaption; | ||||
this.title.caption = sprintf(this.TitleCaptionFormat, { | this.title.caption = sprintf(this.TitleCaptionFormat, { | ||||
"setting": titleCaption | "setting": titleCaption | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator