Remove user.cfg from javascript
remove path from javascript path is defined by the configuration scope combine some calls remove not needed calls Differential revision: D4616 Accepted by: @Freagarach, @nani Comments by: @phosit This was SVN commit r27192.
This commit is contained in:
parent
2b94c6ca27
commit
281bb0b2ec
@ -155,8 +155,7 @@ function initGUIButtons(data)
|
||||
function saveMods()
|
||||
{
|
||||
sortEnabledMods();
|
||||
Engine.ConfigDB_CreateValue("user", "mod.enabledmods", ["mod"].concat(g_ModsEnabled).join(" "));
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "mod.enabledmods", ["mod"].concat(g_ModsEnabled).join(" "));
|
||||
|
||||
Engine.GetGUIObjectByName("saveConfigurationButton").enabled = false;
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ class CampaignRun
|
||||
|
||||
static clearCurrentRun()
|
||||
{
|
||||
Engine.ConfigDB_RemoveValue("user", "currentcampaign");
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_RemoveValueAndSave("user", "currentcampaign");
|
||||
}
|
||||
|
||||
constructor(name = "")
|
||||
|
@ -14,7 +14,7 @@ class PlayerAssignmentsController
|
||||
let name = singleplayerName();
|
||||
|
||||
// Replace empty player name when entering a single-player match for the first time.
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", this.ConfigNameSingleplayer, name, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", this.ConfigNameSingleplayer, name);
|
||||
|
||||
// By default, assign the player to the first slot.
|
||||
g_PlayerAssignments = {
|
||||
|
@ -24,11 +24,11 @@ class TipsPanel
|
||||
|
||||
onPress()
|
||||
{
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile(
|
||||
Engine.ConfigDB_CreateAndSaveValue(
|
||||
"user",
|
||||
this.Config,
|
||||
String(this.displaySPTips.checked),
|
||||
"config/user.cfg");
|
||||
String(this.displaySPTips.checked)
|
||||
);
|
||||
}
|
||||
|
||||
onGameSettingsPanelResize(settingsPanel)
|
||||
|
@ -347,9 +347,9 @@ function startHost(playername, servername, port, password)
|
||||
{
|
||||
startConnectionStatus("server");
|
||||
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "playername.multiplayer", playername, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "playername.multiplayer", playername);
|
||||
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerhosting.port", port, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "multiplayerhosting.port", port);
|
||||
|
||||
let hostFeedback = Engine.GetGUIObjectByName("hostFeedback");
|
||||
|
||||
@ -415,9 +415,9 @@ function startJoin(playername, ip, port)
|
||||
Engine.LobbySetPlayerPresence("playing");
|
||||
|
||||
// Only save the player name and host address if they're valid.
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "playername.multiplayer", playername, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerserver", ip, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerjoining.port", port, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "playername.multiplayer", playername);
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "multiplayerserver", ip);
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "multiplayerjoining.port", port);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@
|
||||
|
||||
<object name="hostSTUNWrapper" size="120 136 100% 180">
|
||||
<object name="useSTUN" size="0 10 32 100%" type="checkbox" style="ModernTickBox">
|
||||
<action on="Press">Engine.ConfigDB_CreateAndWriteValueToFile("user", "lobby.stun.enabled", String(this.checked), "config/user.cfg");</action>
|
||||
<action on="Press">Engine.ConfigDB_CreateAndSaveValue("user", "lobby.stun.enabled", String(this.checked));</action>
|
||||
</object>
|
||||
<object type="text" size="26 0 100% 100%" style="ModernLeftLabelText">
|
||||
<translatableAttribute id="caption">Use STUN to work around firewalls</translatableAttribute>
|
||||
|
@ -30,8 +30,7 @@ class HotkeyPicker
|
||||
|
||||
Engine.GetGUIObjectByName("hotkeyPickerReset").onPress = () => {
|
||||
// This is a bit "using a bazooka to kill a fly"
|
||||
Engine.ConfigDB_RemoveValue("user", "hotkey." + this.name);
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_RemoveValueAndSave("user", "hotkey." + this.name);
|
||||
Engine.ReloadHotkeys();
|
||||
let data = Engine.GetHotkeyMap();
|
||||
this.combinations = data[this.name];
|
||||
|
@ -163,7 +163,7 @@ class HotkeysPage
|
||||
this.categories[cat].hotkeys.forEach(([name, _]) => {
|
||||
Engine.ConfigDB_RemoveValue("user", "hotkey." + name);
|
||||
});
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_SaveChanges("user");
|
||||
Engine.ReloadHotkeys();
|
||||
this.saveButton.enabled = false;
|
||||
this.setupHotkeyData();
|
||||
@ -184,7 +184,7 @@ class HotkeysPage
|
||||
if (keymap.join("") !== formatHotkeyCombinations(defaultData[hotkey], false).join(""))
|
||||
Engine.ConfigDB_CreateValues("user", "hotkey." + hotkey, keymap);
|
||||
}
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_SaveChanges("user");
|
||||
Engine.ReloadHotkeys();
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +53,11 @@ class BuddyButton
|
||||
else
|
||||
g_Buddies.push(this.playerName);
|
||||
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile(
|
||||
Engine.ConfigDB_CreateAndSaveValue(
|
||||
"user",
|
||||
"lobby.buddies",
|
||||
g_Buddies.filter(nick => nick).join(g_BuddyListDelimiter) || g_BuddyListDelimiter,
|
||||
"config/user.cfg");
|
||||
g_Buddies.filter(nick => nick).join(g_BuddyListDelimiter) || g_BuddyListDelimiter
|
||||
);
|
||||
|
||||
this.rebuild();
|
||||
|
||||
|
@ -292,7 +292,6 @@ function displayOptions()
|
||||
|
||||
const hasChanges = Engine.ConfigDB_HasChanges("user");
|
||||
Engine.ConfigDB_CreateValue("user", option.config, String(value));
|
||||
Engine.ConfigDB_SetChanges("user", true);
|
||||
|
||||
g_ChangedKeys.add(option.config);
|
||||
fireConfigChangeHandlers(new Set([option.config]));
|
||||
@ -374,16 +373,17 @@ function reallySetDefaults()
|
||||
g_ChangedKeys.add(option.config);
|
||||
}
|
||||
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_SaveChanges("user");
|
||||
revertChanges();
|
||||
}
|
||||
|
||||
function revertChange(option, oldValue, hadChanges)
|
||||
{
|
||||
Engine.ConfigDB_CreateValue("user", option.config, String(oldValue));
|
||||
|
||||
if (!hadChanges)
|
||||
Engine.ConfigDB_SetChanges("user", false);
|
||||
|
||||
Engine.ConfigDB_CreateValue("user", option.config, String(oldValue));
|
||||
if (option.function)
|
||||
Engine[option.function](oldValue);
|
||||
|
||||
@ -393,7 +393,6 @@ function revertChange(option, oldValue, hadChanges)
|
||||
function revertChanges()
|
||||
{
|
||||
Engine.ConfigDB_Reload("user");
|
||||
Engine.ConfigDB_SetChanges("user", false);
|
||||
|
||||
for (let category in g_Options)
|
||||
for (let option of g_Options[category].options)
|
||||
@ -436,8 +435,7 @@ function saveChanges()
|
||||
|
||||
function reallySaveChanges()
|
||||
{
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_SetChanges("user", false);
|
||||
Engine.ConfigDB_SaveChanges("user");
|
||||
enableButtons();
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,10 @@ function toggleRememberPassword()
|
||||
[translate("No"), translate("Yes")],
|
||||
[
|
||||
() => { checkbox.checked = true; },
|
||||
() => { Engine.ConfigDB_CreateAndWriteValueToFile("user", "lobby.rememberpassword", String(!enabled), "config/user.cfg"); }
|
||||
() => { Engine.ConfigDB_CreateAndSaveValue("user", "lobby.rememberpassword", String(!enabled)); }
|
||||
]);
|
||||
else
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "lobby.rememberpassword", String(!enabled), "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "lobby.rememberpassword", String(!enabled));
|
||||
}
|
||||
|
||||
function getEncryptedPassword()
|
||||
@ -78,14 +78,13 @@ function getEncryptedPassword()
|
||||
function saveCredentials()
|
||||
{
|
||||
let username = Engine.GetGUIObjectByName("username").caption;
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "playername.multiplayer", username, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "lobby.login", username, "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "playername.multiplayer", username);
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "lobby.login", username);
|
||||
|
||||
if (Engine.ConfigDB_GetValue("user", "lobby.rememberpassword") == "true")
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "lobby.password", getEncryptedPassword(), "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "lobby.password", getEncryptedPassword());
|
||||
else
|
||||
{
|
||||
Engine.ConfigDB_RemoveValue("user", "lobby.password");
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_RemoveValueAndSave("user", "lobby.password");
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,7 @@ class AutoFormation
|
||||
this.defaultFormation = formation;
|
||||
if (formation !== NULL_FORMATION)
|
||||
this.lastDefault = this.defaultFormation;
|
||||
Engine.ConfigDB_CreateValue("user", "gui.session.defaultformation", this.defaultFormation);
|
||||
// TODO: It's extremely terrible that we have to explicitly flush the config...
|
||||
Engine.ConfigDB_SetChanges("user", true);
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
Engine.ConfigDB_ConfigDB_CreateAndSaveValue("user", "gui.session.defaultformation", this.defaultFormation);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,10 @@ class RangeOverlayManager
|
||||
{
|
||||
let enabled = !this.isEnabled(type);
|
||||
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile(
|
||||
Engine.ConfigDB_CreateAndSaveValue(
|
||||
"user",
|
||||
type.config,
|
||||
String(enabled),
|
||||
"config/user.cfg");
|
||||
String(enabled));
|
||||
|
||||
this.setEnabled(type, enabled);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class ChatWindow
|
||||
this.closeChat.onPress = this.closePage.bind(this);
|
||||
|
||||
this.extendedChat.onPress = () => {
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "chat.session.extended", String(this.isExtended()), "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "chat.session.extended", String(this.isExtended()));
|
||||
this.resizeChatWindow();
|
||||
this.chatInput.focus();
|
||||
};
|
||||
|
@ -832,7 +832,7 @@ function updateDisplayedNames()
|
||||
function toggleConfigBool(configName)
|
||||
{
|
||||
let enabled = Engine.ConfigDB_GetValue("user", configName) != "true";
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", configName, String(enabled), "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", configName, String(enabled));
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
@ -55,11 +55,10 @@ class CounterManager
|
||||
|
||||
onPress()
|
||||
{
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile(
|
||||
Engine.ConfigDB_CreateAndSaveValue(
|
||||
"user",
|
||||
"gui.session.respoptooltipsort",
|
||||
String((+Engine.ConfigDB_GetValue("user", "gui.session.respoptooltipsort") + 2) % 3 - 1),
|
||||
"config/user.cfg");
|
||||
String((+Engine.ConfigDB_GetValue("user", "gui.session.respoptooltipsort") + 2) % 3 - 1));
|
||||
this.rebuild();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ function init(data)
|
||||
|
||||
function closePage()
|
||||
{
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "gui.splashscreen.enable", String(Engine.GetGUIObjectByName("displaySplashScreen").checked), "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "gui.splashscreen.version", Engine.GetFileMTime(g_SplashScreenFile), "config/user.cfg");
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "gui.splashscreen.enable", String(Engine.GetGUIObjectByName("displaySplashScreen").checked));
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", "gui.splashscreen.version", Engine.GetFileMTime(g_SplashScreenFile));
|
||||
Engine.PopGuiPage();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -264,17 +264,18 @@ void CConfigDB::SetValueList(EConfigNamespace ns, const CStr& name, std::vector<
|
||||
it->second = values;
|
||||
}
|
||||
|
||||
void CConfigDB::RemoveValue(EConfigNamespace ns, const CStr& name)
|
||||
bool CConfigDB::RemoveValue(EConfigNamespace ns, const CStr& name)
|
||||
{
|
||||
CHECK_NS(;);
|
||||
CHECK_NS(false);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> s(m_Mutex);
|
||||
TConfigMap::iterator it = m_Map[ns].find(name);
|
||||
if (it == m_Map[ns].end())
|
||||
return;
|
||||
return false;
|
||||
m_Map[ns].erase(it);
|
||||
|
||||
TriggerAllHooks(m_Hooks, name);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CConfigDB::SetConfigFile(EConfigNamespace ns, const VfsPath& path)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -134,7 +134,7 @@ public:
|
||||
/**
|
||||
* Remove a config value in the specified namespace.
|
||||
*/
|
||||
void RemoveValue(EConfigNamespace ns, const CStr& name);
|
||||
bool RemoveValue(EConfigNamespace ns, const CStr& name);
|
||||
|
||||
/**
|
||||
* Set the path to the config file used to populate the specified namespace
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -113,6 +113,7 @@ bool CreateValue(const std::wstring& cfgNsString, const std::string& name, const
|
||||
return false;
|
||||
|
||||
g_ConfigDB.SetValueString(cfgNs, name, value);
|
||||
g_ConfigDB.SetChanges(cfgNs, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -126,6 +127,7 @@ bool CreateValues(const std::wstring& cfgNsString, const std::string& name, cons
|
||||
return false;
|
||||
|
||||
g_ConfigDB.SetValueList(cfgNs, name, values);
|
||||
g_ConfigDB.SetChanges(cfgNs, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -139,20 +141,36 @@ bool RemoveValue(const std::wstring& cfgNsString, const std::string& name)
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
|
||||
g_ConfigDB.RemoveValue(cfgNs, name);
|
||||
return true;
|
||||
bool result = g_ConfigDB.RemoveValue(cfgNs, name);
|
||||
if (result)
|
||||
g_ConfigDB.SetChanges(cfgNs, true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool WriteFile(const std::wstring& cfgNsString, const Path& path)
|
||||
bool SaveChanges(const std::wstring& cfgNsString)
|
||||
{
|
||||
EConfigNamespace cfgNs;
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
|
||||
return g_ConfigDB.WriteFile(cfgNs, path);
|
||||
bool result = g_ConfigDB.WriteFile(cfgNs);
|
||||
if (result)
|
||||
g_ConfigDB.SetChanges(cfgNs, false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool WriteValueToFile(const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path)
|
||||
bool RemoveValueAndSave(const std::wstring& cfgNsString, const std::string& name)
|
||||
{
|
||||
if (RemoveValue(cfgNsString, name))
|
||||
return SaveChanges(cfgNsString);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool SaveValue(const std::wstring& cfgNsString, const std::string& name, const std::string& value)
|
||||
{
|
||||
if (IsProtectedConfigName(name))
|
||||
return false;
|
||||
@ -161,13 +179,13 @@ bool WriteValueToFile(const std::wstring& cfgNsString, const std::string& name,
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
|
||||
return g_ConfigDB.WriteValueToFile(cfgNs, name, value, path);
|
||||
return g_ConfigDB.WriteValueToFile(cfgNs, name, value);
|
||||
}
|
||||
|
||||
void CreateAndWriteValueToFile(const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path)
|
||||
void CreateAndSaveValue(const std::wstring& cfgNsString, const std::string& name, const std::string& value)
|
||||
{
|
||||
CreateValue(cfgNsString, name, value);
|
||||
WriteValueToFile(cfgNsString, name, value, path);
|
||||
if (CreateValue(cfgNsString, name, value))
|
||||
SaveValue(cfgNsString, name, value);
|
||||
}
|
||||
|
||||
bool Reload(const std::wstring& cfgNsString)
|
||||
@ -179,16 +197,6 @@ bool Reload(const std::wstring& cfgNsString)
|
||||
return g_ConfigDB.Reload(cfgNs);
|
||||
}
|
||||
|
||||
bool SetFile(const std::wstring& cfgNsString, const Path& path)
|
||||
{
|
||||
EConfigNamespace cfgNs;
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
|
||||
g_ConfigDB.SetConfigFile(cfgNs, path);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PauseOnFocusLoss(bool pause)
|
||||
{
|
||||
g_PauseOnFocusLoss = pause;
|
||||
@ -207,10 +215,10 @@ void RegisterScriptFunctions(const ScriptRequest& rq)
|
||||
ScriptFunction::Register<&CreateValue>(rq, "ConfigDB_CreateValue");
|
||||
ScriptFunction::Register<&CreateValues>(rq, "ConfigDB_CreateValues");
|
||||
ScriptFunction::Register<&RemoveValue>(rq, "ConfigDB_RemoveValue");
|
||||
ScriptFunction::Register<&WriteFile>(rq, "ConfigDB_WriteFile");
|
||||
ScriptFunction::Register<&WriteValueToFile>(rq, "ConfigDB_WriteValueToFile");
|
||||
ScriptFunction::Register<&CreateAndWriteValueToFile>(rq, "ConfigDB_CreateAndWriteValueToFile");
|
||||
ScriptFunction::Register<&SetFile>(rq, "ConfigDB_SetFile");
|
||||
ScriptFunction::Register<&RemoveValueAndSave>(rq, "ConfigDB_RemoveValueAndSave");
|
||||
ScriptFunction::Register<&SaveChanges>(rq, "ConfigDB_SaveChanges");
|
||||
ScriptFunction::Register<&SaveValue>(rq, "ConfigDB_SaveValue");
|
||||
ScriptFunction::Register<&CreateAndSaveValue>(rq, "ConfigDB_CreateAndSaveValue");
|
||||
ScriptFunction::Register<&Reload>(rq, "ConfigDB_Reload");
|
||||
ScriptFunction::Register<&PauseOnFocusLoss>(rq, "PauseOnFocusLoss");
|
||||
ScriptFunction::Register<&SetGUIScale>(rq, "SetGUIScale");
|
||||
|
Loading…
Reference in New Issue
Block a user