Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesettings/attributes/MapSize.js
- This file was added.
GameSettings.prototype.Attributes.MapSize = class MapSize extends GameSetting | |||||
{ | |||||
Init() | |||||
{ | |||||
this.setSize(g_MapSizes.Tiles[g_MapSizes.Default]); | |||||
this.settings.map.watch(() => this.onTypeChange(), ["type"]); | |||||
} | |||||
LegacySerialize(attribs) | |||||
{ | |||||
if (this.settings.map.type === "random") | |||||
attribs.settings.Size = this.size; | |||||
} | |||||
LegacyDeserialize(attribs) | |||||
{ | |||||
if (!!this.getLegacySetting(attribs, "Size")) | |||||
this.setSize(this.getLegacySetting(attribs, "Size")); | |||||
} | |||||
setSize(size) | |||||
{ | |||||
this.available = this.settings.map.type === "random"; | |||||
this.size = size; | |||||
} | |||||
onTypeChange(old) | |||||
{ | |||||
if (this.settings.map.type === "random" && old !== "random") | |||||
this.setSize(g_MapSizes.Tiles[g_MapSizes.Default]); | |||||
else if (this.settings.map.type !== "random") | |||||
this.available = false; | |||||
} | |||||
}; |
Wildfire Games · Phabricator