Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 1,841 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if (!g_IsController || Engine.ConfigDB_GetValue("user", "persistmatchsettings") != "true" || g_IsTutorial) | if (!g_IsController || Engine.ConfigDB_GetValue("user", "persistmatchsettings") != "true" || g_IsTutorial) | ||||
return; | return; | ||||
let settingsFile = g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP; | let settingsFile = g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP; | ||||
if (!Engine.FileExists(settingsFile)) | if (!Engine.FileExists(settingsFile)) | ||||
return; | return; | ||||
let attrs = Engine.ReadJSONFile(settingsFile); | let data = Engine.ReadJSONFile(settingsFile); | ||||
if (!attrs || !attrs.settings) | if (!data || !data.attributes || !data.attributes.settings) | ||||
return; | |||||
if (data.engine_info.engine_version != Engine.GetEngineInfo().engine_version || | |||||
!hasSameMods(data.engine_info.mods, Engine.GetEngineInfo().mods)) | |||||
return; | return; | ||||
g_IsInGuiUpdate = true; | g_IsInGuiUpdate = true; | ||||
let mapName = attrs.map || ""; | let mapName = data.attributes.map || ""; | ||||
let mapSettings = attrs.settings; | let mapSettings = data.attributes.settings; | ||||
g_GameAttributes = attrs; | g_GameAttributes = data.attributes; | ||||
if (!g_IsNetworked) | if (!g_IsNetworked) | ||||
mapSettings.CheatsEnabled = true; | mapSettings.CheatsEnabled = true; | ||||
// Replace unselectable civs with random civ | // Replace unselectable civs with random civ | ||||
let playerData = mapSettings.PlayerData; | let playerData = mapSettings.PlayerData; | ||||
if (playerData && g_GameAttributes.mapType != "scenario") | if (playerData && g_GameAttributes.mapType != "scenario") | ||||
for (let i in playerData) | for (let i in playerData) | ||||
Show All 25 Lines | function loadPersistMatchSettings() | ||||
g_IsInGuiUpdate = false; | g_IsInGuiUpdate = false; | ||||
} | } | ||||
function savePersistMatchSettings() | function savePersistMatchSettings() | ||||
{ | { | ||||
if (g_IsTutorial) | if (g_IsTutorial) | ||||
return; | return; | ||||
let attributes = Engine.ConfigDB_GetValue("user", "persistmatchsettings") == "true" ? g_GameAttributes : {}; | |||||
Engine.WriteJSONFile(g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP, attributes); | Engine.WriteJSONFile( | ||||
g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP, | |||||
{ | |||||
"attributes": | |||||
// Delete settings if disabled, so that players are not confronted with old settings after enabling the setting again | |||||
Engine.ConfigDB_GetValue("user", "persistmatchsettings") == "true" ? | |||||
g_GameAttributes : | |||||
{}, | |||||
"engine_info": Engine.GetEngineInfo() | |||||
}); | |||||
} | } | ||||
function sanitizePlayerData(playerData) | function sanitizePlayerData(playerData) | ||||
{ | { | ||||
// Remove gaia | // Remove gaia | ||||
if (playerData.length && !playerData[0]) | if (playerData.length && !playerData[0]) | ||||
playerData.shift(); | playerData.shift(); | ||||
▲ Show 20 Lines • Show All 830 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator