Differential D4240 Diff 19682 ps/trunk/binaries/data/mods/public/gui/gamesettings/attributes/MapName.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesettings/attributes/MapName.js
/** | /** | ||||
* Map name. | * Map name. | ||||
* This is usually just the regular map name, but can be overwritten. | * This is usually just the regular map name, but can be overwritten. | ||||
*/ | */ | ||||
GameSettings.prototype.Attributes.MapName = class MapName extends GameSetting | GameSettings.prototype.Attributes.MapName = class MapName extends GameSetting | ||||
{ | { | ||||
init() | init() | ||||
{ | { | ||||
this.value = undefined; | |||||
this.settings.map.watch(() => this.updateName(), ["map"]); | |||||
} | } | ||||
toInitAttributes(attribs) | toInitAttributes(attribs) | ||||
{ | { | ||||
if (this.value) | attribs.settings.mapName = this.value; | ||||
attribs.settings.Name = this.value; | |||||
else | |||||
{ | |||||
// Copy from the map data by default - this helps make InitAttributes self-sufficient, | |||||
// which is nice for replays / saved games. | |||||
// Fallback to the map name to avoid 'undefined' errors. | |||||
attribs.settings.Name = this.settings.map?.data?.settings?.Name || this.settings.map.map; | |||||
} | |||||
} | } | ||||
fromInitAttributes(attribs) | fromInitAttributes(attribs) | ||||
{ | { | ||||
// Ser/Deser from a different attribute name as a poor man's not-persisted-setting. | if (attribs?.settings?.mapName) | ||||
// TODO: split this off more properly. | this.value = attribs.settings.mapName; | ||||
if (attribs.mapName) | |||||
this.value = attribs.mapName; | |||||
} | } | ||||
set(name) | updateName() | ||||
{ | { | ||||
this.value = name; | this.value = this.settings.map?.data?.settings?.Name || this.settings.map.map; | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator