Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gamesettings/GameSettings.js
- This file was moved from binaries/data/mods/public/gui/gamesettings/GameSettings.js.
/** | /** | ||||
* Data store for game settings. | * Data store for game settings. | ||||
* | * | ||||
* This is intended as a helper to create the settings object for a game. | * This is intended as a helper to create the settings object for a game. | ||||
* This object is referred to as: | * This object is referred to as: | ||||
* - g_InitAttributes in the GUI session context | * - g_InitAttributes in the GUI session context | ||||
* - InitAttributes in the JS simulation context | * - InitAttributes in the JS simulation context | ||||
* - Either InitAttributes or MapSettings in the C++ simulation. | * - Either InitAttributes or MapSettings in the C++ simulation. | ||||
* Settings can depend on each other, and the map provides many. | * Settings can depend on each other, and the map provides many. | ||||
* This class's job is thus to provide a simpler interface around that. | * This class's job is thus to provide a simpler interface around that. | ||||
*/ | */ | ||||
class GameSettings | class GameSettings | ||||
{ | { | ||||
init(mapCache) | init(mapCache, civData) | ||||
{ | { | ||||
if (!mapCache) | if (!mapCache) | ||||
mapCache = new MapCache(); | mapCache = new MapCache(); | ||||
Object.defineProperty(this, "mapCache", { | Object.defineProperty(this, "mapCache", { | ||||
"value": mapCache, | "value": mapCache, | ||||
}); | }); | ||||
if (!civData) | |||||
// Load all possible civ data - don't presume that some will be available. | // Load all possible civ data - don't presume that some will be available. | ||||
civData = loadCivData(false, false); | |||||
Object.defineProperty(this, "civData", { | Object.defineProperty(this, "civData", { | ||||
"value": loadCivData(false, false), | "value": civData | ||||
}); | }); | ||||
Object.defineProperty(this, "isNetworked", { | Object.defineProperty(this, "isNetworked", { | ||||
"value": Engine.HasNetClient(), | "value": Engine.HasNetClient(), | ||||
}); | }); | ||||
// Load attributes as regular enumerable (i.e. iterable) properties. | // Load attributes as regular enumerable (i.e. iterable) properties. | ||||
for (let comp in GameSettings.prototype.Attributes) | for (let comp in GameSettings.prototype.Attributes) | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator