Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Controls/GameSettingsFile.js
/** | /** | ||||
* This class provides a way to save g_GameAttributes to a file and load them. | * This class provides a way to save g_GameAttributes to a file and load them. | ||||
*/ | */ | ||||
class GameSettingsFile | class GameSettingsFile | ||||
{ | { | ||||
constructor(GameSettingsControl) | constructor(GameSettingsControl) | ||||
{ | { | ||||
this.filename = g_IsNetworked ? | this.filename = g_IsNetworked ? | ||||
this.GameAttributesFileMultiplayer : | this.GameAttributesFileMultiplayer : | ||||
this.GameAttributesFileSingleplayer; | this.GameAttributesFileSingleplayer; | ||||
this.gameSettingsControl = GameSettingsControl; | |||||
this.engineInfo = Engine.GetEngineInfo(); | this.engineInfo = Engine.GetEngineInfo(); | ||||
this.enabled = Engine.ConfigDB_GetValue("user", this.ConfigName) == "true"; | this.enabled = Engine.ConfigDB_GetValue("user", this.ConfigName) == "true"; | ||||
} | } | ||||
loadFile() | loadFile() | ||||
{ | { | ||||
Engine.ProfileStart("loadPersistMatchSettingsFile"); | Engine.ProfileStart("loadPersistMatchSettingsFile"); | ||||
Show All 20 Lines | class GameSettingsFile | ||||
*/ | */ | ||||
saveFile() | saveFile() | ||||
{ | { | ||||
if (!g_IsController) | if (!g_IsController) | ||||
return; | return; | ||||
Engine.ProfileStart("savePersistMatchSettingsFile"); | Engine.ProfileStart("savePersistMatchSettingsFile"); | ||||
Engine.WriteJSONFile(this.filename, { | Engine.WriteJSONFile(this.filename, { | ||||
"attributes": this.enabled ? g_GameAttributes : {}, | "attributes": this.enabled ? this.gameSettingsControl.getSettings() : {}, | ||||
"engine_info": this.engineInfo | "engine_info": this.engineInfo | ||||
}); | }); | ||||
Engine.ProfileStop(); | Engine.ProfileStop(); | ||||
} | } | ||||
} | } | ||||
GameSettingsFile.prototype.ConfigName = | GameSettingsFile.prototype.ConfigName = | ||||
"persistmatchsettings"; | "persistmatchsettings"; | ||||
GameSettingsFile.prototype.GameAttributesFileSingleplayer = | GameSettingsFile.prototype.GameAttributesFileSingleplayer = | ||||
"config/matchsettings.json"; | "config/matchsettings.json"; | ||||
GameSettingsFile.prototype.GameAttributesFileMultiplayer = | GameSettingsFile.prototype.GameAttributesFileMultiplayer = | ||||
"config/matchsettings.mp.json"; | "config/matchsettings.mp.json"; |
Wildfire Games · Phabricator