Differential D4191 Diff 18493 ps/trunk/binaries/data/mods/public/gui/gamesettings/attributes/MapExploration.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesettings/attributes/MapExploration.js
GameSettings.prototype.Attributes.MapExploration = class MapExploration extends GameSetting | GameSettings.prototype.Attributes.MapExploration = class MapExploration extends GameSetting | ||||
{ | { | ||||
init() | init() | ||||
{ | { | ||||
this.explored = false; | this.explored = false; | ||||
this.revealed = false; | this.revealed = false; | ||||
this.allied = false; | |||||
this.settings.map.watch(() => this.onMapChange(), ["map"]); | this.settings.map.watch(() => this.onMapChange(), ["map"]); | ||||
} | } | ||||
toInitAttributes(attribs) | toInitAttributes(attribs) | ||||
{ | { | ||||
attribs.settings.RevealMap = this.revealed; | attribs.settings.RevealMap = this.revealed; | ||||
attribs.settings.ExploreMap = this.explored; | attribs.settings.ExploreMap = this.explored; | ||||
attribs.settings.AllyView = this.allied; | |||||
} | } | ||||
fromInitAttributes(attribs) | fromInitAttributes(attribs) | ||||
{ | { | ||||
this.explored = !!this.getLegacySetting(attribs, "ExploreMap"); | this.explored = !!this.getLegacySetting(attribs, "ExploreMap"); | ||||
this.revealed = !!this.getLegacySetting(attribs, "RevealMap"); | this.revealed = !!this.getLegacySetting(attribs, "RevealMap"); | ||||
this.allied = !!this.getLegacySetting(attribs, "AllyView"); | |||||
} | } | ||||
onMapChange(mapData) | onMapChange(mapData) | ||||
{ | { | ||||
if (this.settings.map.type != "scenario") | if (this.settings.map.type != "scenario") | ||||
return; | return; | ||||
this.setExplored(this.getMapSetting("ExploreMap")); | this.setExplored(this.getMapSetting("ExploreMap")); | ||||
this.setRevealed(this.getMapSetting("RevealMap")); | this.setRevealed(this.getMapSetting("RevealMap")); | ||||
this.setAllied(this.getMapSetting("AllyView")); | |||||
} | } | ||||
setExplored(enabled) | setExplored(enabled) | ||||
{ | { | ||||
this.explored = enabled; | this.explored = enabled; | ||||
this.revealed = this.revealed && this.explored; | this.revealed = this.revealed && this.explored; | ||||
} | } | ||||
setRevealed(enabled) | setRevealed(enabled) | ||||
{ | { | ||||
this.explored = this.explored || enabled; | this.explored = this.explored || enabled; | ||||
this.revealed = enabled; | this.revealed = enabled; | ||||
this.allied = this.allied || enabled; | |||||
} | |||||
setAllied(enabled) | |||||
{ | |||||
this.allied = enabled; | |||||
this.revealed = this.revealed && this.allied; | |||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator