Differential D3243 Diff 16276 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/Cheats.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Checkboxes/Cheats.js
/** | /** | ||||
* Cheats are always enabled in singleplayer mode, since they are the choice of that one player. | * Cheats are always enabled in singleplayer mode, since they are the choice of that one player. | ||||
*/ | */ | ||||
GameSettingControls.Cheats = class extends GameSettingControlCheckbox | GameSettingControls.Cheats = class extends GameSettingControlCheckbox | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.setHidden(!g_IsNetworked); | |||||
g_NewGameSettings.cheats.watch(() => this.render(), ["enabled"]); | |||||
g_NewGameSettings.rating.watch(() => this.render(), ["enabled"]); | |||||
} | } | ||||
onGameAttributesChange() | onLoad() | ||||
{ | |||||
if (g_GameAttributes.settings.CheatsEnabled === undefined || | |||||
g_GameAttributes.settings.CheatsEnabled && g_GameAttributes.settings.RatingEnabled || | |||||
!g_GameAttributes.settings.CheatsEnabled && !g_IsNetworked) | |||||
{ | { | ||||
g_GameAttributes.settings.CheatsEnabled = !g_IsNetworked; | g_NewGameSettings.cheats.setEnabled(!g_IsNetworked); | ||||
this.gameSettingsControl.updateGameAttributes(); | this.render(); | ||||
} | |||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
this.setChecked(g_GameAttributes.settings.CheatsEnabled); | this.setChecked(g_NewGameSettings.cheats.enabled); | ||||
this.setEnabled(!g_GameAttributes.settings.RatingEnabled); | this.setEnabled(g_IsNetworked && !g_NewGameSettings.rating.enabled); | ||||
} | } | ||||
onPress(checked) | onPress(checked) | ||||
{ | { | ||||
g_GameAttributes.settings.CheatsEnabled = | g_NewGameSettings.cheats.setEnabled(g_IsNetworked || checked); | ||||
!g_IsNetworked || | |||||
checked && !g_GameAttributes.settings.RatingEnabled; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.Cheats.prototype.TitleCaption = | GameSettingControls.Cheats.prototype.TitleCaption = | ||||
translate("Cheats"); | translate("Cheats"); | ||||
GameSettingControls.Cheats.prototype.Tooltip = | GameSettingControls.Cheats.prototype.Tooltip = | ||||
translate("Toggle the usability of cheats."); | translate("Toggle the usability of cheats."); |
Wildfire Games · Phabricator