Ticket #3737: optionsReset-v3.patch
File optionsReset-v3.patch, 24.8 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup_mp.js
192 192 function startHost(playername, servername) 193 193 { 194 194 // Save player name 195 Engine.ConfigDB_CreateValue("user", "playername", playername); 196 Engine.ConfigDB_WriteFile("user", "config/user.cfg"); 195 Engine.ConfigDB_CreateValueAndWriteOnFile("user", "playername", playername, "config/user.cfg"); 197 196 // Disallow identically named games in the multiplayer lobby 198 197 if (Engine.HasXmppClient()) 199 198 { … … 253 252 if (Engine.HasXmppClient()) 254 253 // Set player lobby presence 255 254 Engine.LobbySetPlayerPresence("playing"); 256 else { 255 else 256 { 257 257 // Only save the player name and host address if they're valid and we're not in the lobby 258 Engine.ConfigDB_CreateValue("user", "playername", playername); 259 Engine.ConfigDB_CreateValue("user", "multiplayerserver", ip); 260 Engine.ConfigDB_WriteFile("user", "config/user.cfg"); 258 Engine.ConfigDB_CreateValueAndWriteOnFile("user", "playername", playername, "config/user.cfg"); 259 Engine.ConfigDB_CreateValueAndWriteOnFile("user", "multiplayerserver", ip, "config/user.cfg"); 261 260 } 262 261 return true; 263 262 } -
binaries/data/mods/public/gui/lobby/prelobby.js
179 179 { 180 180 Engine.PopGuiPage(); 181 181 Engine.SwitchGuiPage("page_lobby.xml"); 182 Engine.ConfigDB_CreateValue ("user", "playername", sanitizePlayerName(username, true, true));183 Engine.ConfigDB_CreateValue ("user", "lobby.login", username);182 Engine.ConfigDB_CreateValueAndWriteOnFile("user", "playername", sanitizePlayerName(username, true, true), "config/user.cfg"); 183 Engine.ConfigDB_CreateValueAndWriteOnFile("user", "lobby.login", username, "config/user.cfg"); 184 184 // We only store the encrypted password, so make sure to re-encrypt it if changed before saving. 185 185 if (password != g_EncrytedPassword.substring(0, 10)) 186 186 g_EncrytedPassword = Engine.EncryptPassword(password, username); 187 Engine.ConfigDB_CreateValue("user", "lobby.password", g_EncrytedPassword); 188 Engine.ConfigDB_WriteFile("user", "config/user.cfg"); 187 Engine.ConfigDB_CreateValueAndWriteOnFile("user", "lobby.password", g_EncrytedPassword, "config/user.cfg"); 189 188 break; 190 189 } 191 190 } -
binaries/data/mods/public/gui/options/options.js
5 5 { 6 6 if (data && data.callback) 7 7 g_HasCallback = true; 8 let revert = data && data.revert;9 8 g_Controls = {}; 10 9 11 10 var options = Engine.ReadJSONFile("gui/options/options.json"); … … 21 20 let label = Engine.GetGUIObjectByName(category + "Label[" + i + "]"); 22 21 let config = option.parameters.config; 23 22 g_Controls[config] = { 24 "control": setupControl(option, i, category , revert),23 "control": setupControl(option, i, category), 25 24 "type": option.type, 26 "dependencies": option.dependencies || undefined 25 "dependencies": option.dependencies || undefined, 26 "parameters": option.parameters 27 27 }; 28 28 label.caption = translate(option.label); 29 29 label.tooltip = option.tooltip ? translate(option.tooltip) : ""; … … 47 47 continue; 48 48 if (!opt.dependencies || opt.dependencies.indexOf(config) === -1) 49 49 continue; 50 label.caption = " 50 label.caption = " " + label.caption; 51 51 break; 52 52 } 53 53 // Show element. … … 55 55 } 56 56 } 57 57 58 updateDependencies(); 59 if (!revert) 60 updateStatus(); 58 updateDisplay(); 61 59 } 62 60 63 61 /** … … 66 64 * @param option Structure containing the data to setup an option. 67 65 * @param prefix Prefix to use when accessing control, for example "generalSetting" when the tickbox name is generalSettingTickbox[i]. 68 66 */ 69 function setupControl(option, i, category , revert)67 function setupControl(option, i, category) 70 68 { 71 69 var control; 72 70 var onUpdate; … … 92 90 { 93 91 case "config": 94 92 keyConfig = option.parameters.config; 95 if (checked === undefined || revert)93 if (checked === undefined) 96 94 checked = Engine.ConfigDB_GetValue("user", keyConfig) === "true"; 97 else if ((Engine.ConfigDB_GetValue("user", keyConfig) === "true") !== checked)98 {99 Engine.ConfigDB_CreateValue("user", keyConfig, String(checked));100 updateStatus(true);101 }102 95 break; 103 96 case "renderer": 104 97 keyRenderer = option.parameters.renderer; … … 131 124 Engine["Renderer_Set" + keyRenderer + "Enabled"](val); 132 125 if (keyConfig) 133 126 Engine.ConfigDB_CreateValue("user", keyConfig, String(val)); 134 updateDependencies(); 135 updateStatus(true); 127 updateDisplay(); 136 128 }; 137 129 }(keyRenderer, keyConfig, inverted); 138 130 … … 190 182 Engine.ConfigDB_CreateValue("user", key, this.caption); 191 183 if (functionBody) 192 184 Engine[functionBody](+this.caption); 193 updateDependencies(); 194 updateStatus(true); 185 updateDisplay(); 195 186 }; 196 187 }(key, functionBody, minval, maxval); 197 188 … … 201 192 break; 202 193 case "dropdown": 203 194 control = Engine.GetGUIObjectByName(category + "Dropdown[" + i + "]"); 195 control.onSelectionChange = function(){}; // just the time to setup the value 204 196 var caption; 205 197 var key; 206 198 var functionBody; … … 237 229 if (key === "materialmgr.quality") 238 230 val = val == 0 ? 2 : val == 1 ? 5 : 8; 239 231 Engine.ConfigDB_CreateValue("user", key, val); 240 updateDependencies(); 241 updateStatus(true); 232 updateDisplay(); 242 233 }; 243 234 }(key); 244 235 … … 254 245 return control; 255 246 } 256 247 257 function update Status(val)248 function updateDisplay() 258 249 { 259 if (typeof val == "boolean") 260 Engine.ConfigDB_CreateValue("user", "nosave.haschanges", String(val)); 261 else 262 val = Engine.ConfigDB_GetValue("user", "nosave.haschanges") === "true"; 250 // Update dependencies 251 for (let item in g_Controls) 252 { 253 let control = g_Controls[item]; 254 if (control.type !== "boolean" && control.type !== "invertedboolean" || !control.dependencies) 255 continue; 263 256 264 Engine.GetGUIObjectByName("loadOptions").enabled = val; 265 Engine.GetGUIObjectByName("saveOptions").enabled = val; 257 for (let dependency of control.dependencies) 258 g_Controls[dependency].control.enabled = control.control.checked; 259 } 260 261 // And main buttons 262 let dirty = Engine.ConfigDB_IsDirty("user"); 263 let changes = Engine.ConfigDB_HasChanges("user") && !dirty; 264 Engine.GetGUIObjectByName("resetChanges").enabled = !dirty; 265 Engine.GetGUIObjectByName("revertChanges").enabled = changes; 266 Engine.GetGUIObjectByName("saveChanges").enabled = changes; 267 if (dirty) 268 { 269 let warning = "You need to restart the game after a reset to be able to modify again the options"; 270 Engine.GetGUIObjectByName("resetChanges").tooltip = warning; 271 Engine.GetGUIObjectByName("revertChanges").tooltip = warning; 272 Engine.GetGUIObjectByName("saveChanges").tooltip = warning; 273 } 266 274 } 267 275 268 276 /** … … 275 283 g_Controls[item].control.onPress(); 276 284 } 277 285 278 function updateDependencies()286 function resetChanges() 279 287 { 288 let btCaptions = [translate("No"), translate("Yes")]; 289 let btCode = [null, function(){ reallyResetChanges(); }]; 290 messageBox(500, 200, translate("Resetting the options will be effective only after restarting the game. Are you sure you want to continue ?"), 291 translate("Warning"), 0, btCaptions, btCode); 292 } 293 294 function reallyResetChanges() 295 { 280 296 for (let item in g_Controls) 281 { 282 let control = g_Controls[item]; 283 if (control.type !== "boolean" && control.type !== "invertedboolean" || !control.dependencies) 284 continue; 297 Engine.ConfigDB_RemoveValue("user", item); 285 298 286 for (let dependency of control.dependencies)287 g_Controls[dependency].control.enabled = control.control.checked;288 }299 Engine.ConfigDB_WriteFile("user", "config/user.cfg"); 300 Engine.ConfigDB_SetDirty("user"); 301 updateDisplay(); 289 302 } 290 303 291 304 function revertChanges() 292 305 { 293 306 Engine.ConfigDB_Reload("user"); 294 updateStatus(false); 295 init({ "revert": true }); 307 // needs to update renderer values (which are all of boolean type) 308 for (let item in g_Controls) 309 { 310 let control = g_Controls[item]; 311 if (!control.parameters.renderer) 312 continue; 313 if (control.type !== "boolean" && control.type !== "invertedboolean") 314 { 315 warn("Invalid type option defined in renderer '" + control.type + "': will not be reverted"); 316 continue; 317 } 318 let value = Engine.ConfigDB_GetValue("user", item) === "true"; 319 let keyRenderer = control.parameters.renderer; 320 let checked = Engine["Renderer_Get" + keyRenderer + "Enabled"](); 321 if (checked !== value) 322 Engine["Renderer_Set" + keyRenderer + "Enabled"](value); 323 } 324 init(); 296 325 } 297 326 298 327 function saveChanges() … … 299 328 { 300 329 registerChanges(); 301 330 Engine.ConfigDB_WriteFile("user", "config/user.cfg"); 302 update Status(false);331 updateDisplay(); 303 332 } 304 333 305 334 /** … … 308 337 function closePage() 309 338 { 310 339 registerChanges(); 311 if (Engine.ConfigDB_ GetValue("user", "nosave.haschanges") === "true")340 if (Engine.ConfigDB_HasChanges("user")) 312 341 { 313 342 let btCaptions = [translate("No"), translate("Yes")]; 314 343 let btCode = [null, function(){ closePageWithoutConfirmation(); }]; -
binaries/data/mods/public/gui/options/options.xml
69 69 </object> 70 70 </repeat> 71 71 </object> 72 <object name="loadOptions" type="button" style="ModernButtonRed" size="50%-170 100%-44 50%-70 100%-16" hotkey="cancel"> 72 <object name="resetChanges" type="button" style="ModernButtonRed" size="50%-236 100%-44 50%-136 100%-16"> 73 <translatableAttribute id="caption">Reset</translatableAttribute> 74 <translatableAttribute id="tooltip">Resets user settings to their game default (needs a game restart to be effective)</translatableAttribute> 75 <action on="Press">resetChanges();</action> 76 </object> 77 <object name="revertChanges" type="button" style="ModernButtonRed" size="50%-104 100%-44 50%-4 100%-16"> 73 78 <translatableAttribute id="caption">Revert</translatableAttribute> 74 <translatableAttribute id="tooltip">Revert to previous saved settings</translatableAttribute>79 <translatableAttribute id="tooltip">Reverts to previous saved settings</translatableAttribute> 75 80 <action on="Press">revertChanges();</action> 76 81 </object> 77 <object name="save Options" type="button" style="ModernButtonRed" size="50%-62 100%-44 50%+38100%-16">82 <object name="saveChanges" type="button" style="ModernButtonRed" size="50%+4 100%-44 50%+104 100%-16"> 78 83 <translatableAttribute id="caption">Save</translatableAttribute> 79 <translatableAttribute id="tooltip">Save changes</translatableAttribute>84 <translatableAttribute id="tooltip">Saves changes</translatableAttribute> 80 85 <action on="Press">saveChanges();</action> 81 86 </object> 82 <object type="button" style="ModernButtonRed" size="50%+ 70 100%-44 50%+170100%-16">87 <object type="button" style="ModernButtonRed" size="50%+136 100%-44 50%+236 100%-16"> 83 88 <translatableAttribute id="caption">Close</translatableAttribute> 84 89 <translatableAttribute id="tooltip">Unsaved changes affect this session only</translatableAttribute> 85 90 <action on="Press">closePage();</action> -
binaries/data/mods/public/gui/splashscreen/splashscreen.xml
27 27 <object name="btnOK" type="button" style="ModernButtonRed" size="18 100%-45 50%-5 100%-17" hotkey="cancel"> 28 28 <translatableAttribute id="caption">OK</translatableAttribute> 29 29 <action on="Press"><![CDATA[ 30 if (Engine.GetGUIObjectByName("displaySplashScreen").checked) 31 Engine.ConfigDB_CreateValue("user", "splashscreenversion", 0); 32 else 33 Engine.ConfigDB_CreateValue("user", "splashscreenversion", Engine.GetFileMTime("gui/splashscreen/splashscreen.txt")); 34 Engine.ConfigDB_WriteFile("user", "config/user.cfg"); 30 let value = Engine.GetGUIObjectByName("displaySplashScreen").checked ? 0 : Engine.GetFileMTime("gui/splashscreen/splashscreen.txt"); 31 Engine.ConfigDB_CreateValueAndWriteOnFile("user", "splashscreenversion", value, "config/user.cfg"); 35 32 Engine.PopGuiPageCB(); 36 33 ]]></action> 37 34 </object> -
source/i18n/L10n.cpp
92 92 if (!ValidateLocale(locale)) 93 93 return false; 94 94 95 g_ConfigDB.SetValueString(CFG_USER, "locale", locale.getName()); 96 g_ConfigDB.WriteFile(CFG_USER); 95 g_ConfigDB.SetValueAndWriteOnFile(CFG_USER, "locale", locale.getName()); 97 96 return true; 98 97 } 99 98 -
source/network/NetServer.cpp
309 309 externalIPAddress, psPort, protocall, intClient, intPort, duration); 310 310 311 311 // Cache root descriptor URL to try to avoid discovery next time. 312 g_ConfigDB.SetValueString(CFG_USER, "network.upnprootdescurl", urls.controlURL); 313 g_ConfigDB.WriteFile(CFG_USER); 312 g_ConfigDB.SetValueAndWriteOnFile(CFG_USER, "network.upnprootdescurl", urls.controlURL); 314 313 LOGMESSAGE("Net server: cached UPnP root descriptor URL as %s", urls.controlURL); 315 314 316 315 // Make sure everything is properly freed. -
source/ps/ConfigDB.cpp
29 29 typedef std::map<CStr, CConfigValueSet> TConfigMap; 30 30 TConfigMap CConfigDB::m_Map[CFG_LAST]; 31 31 VfsPath CConfigDB::m_ConfigFile[CFG_LAST]; 32 bool CConfigDB::m_HasChanges[CFG_LAST]; 33 bool CConfigDB::m_IsDirty[CFG_LAST]; 32 34 33 35 static pthread_mutex_t cfgdb_mutex = PTHREAD_MUTEX_INITIALIZER; 34 36 … … 114 116 GETVAL(std::string) 115 117 #undef GETVAL 116 118 119 bool CConfigDB::HasChanges(EConfigNamespace ns) const 120 { 121 CHECK_NS(false); 122 123 CScopeLock s(&cfgdb_mutex); 124 return m_HasChanges[ns]; 125 } 126 127 bool CConfigDB::IsDirty(EConfigNamespace ns) const 128 { 129 CHECK_NS(false); 130 131 CScopeLock s(&cfgdb_mutex); 132 return m_IsDirty[ns]; 133 } 134 135 void CConfigDB::SetDirty(EConfigNamespace ns) 136 { 137 CHECK_NS(;); 138 139 CScopeLock s(&cfgdb_mutex); 140 m_IsDirty[ns] = true; 141 } 142 117 143 void CConfigDB::GetValues(EConfigNamespace ns, const CStr& name, CConfigValueSet& values) const 118 144 { 119 145 CHECK_NS(;); … … 187 213 it = m_Map[ns].insert(m_Map[ns].begin(), make_pair(name, CConfigValueSet(1))); 188 214 189 215 it->second[0] = value; 216 m_HasChanges[ns] = true; 190 217 } 191 218 219 void CConfigDB::RemoveValue(EConfigNamespace ns, const CStr& name) 220 { 221 CHECK_NS(;); 222 223 CScopeLock s(&cfgdb_mutex); 224 TConfigMap::iterator it = m_Map[ns].find(name); 225 if (it == m_Map[ns].end()) 226 return; 227 m_Map[ns].erase(it); 228 m_HasChanges[ns] = true; 229 } 230 192 231 void CConfigDB::SetConfigFile(EConfigNamespace ns, const VfsPath& path) 193 232 { 194 233 CHECK_NS(;); … … 357 396 358 397 m_Map[ns].swap(newMap); 359 398 399 m_HasChanges[ns] = false; 360 400 return true; 361 401 } 362 402 … … 378 418 char* pos = (char*)buf.get(); 379 419 for (const std::pair<CStr, CConfigValueSet>& p : m_Map[ns]) 380 420 { 381 if (boost::algorithm::starts_with(p.first, "nosave."))382 continue;383 421 size_t i; 384 422 pos += sprintf(pos, "%s = ", p.first.c_str()); 385 423 for (i = 0; i < p.second.size() - 1; ++i) … … 395 433 return false; 396 434 } 397 435 436 m_HasChanges[ns] = false; 398 437 return true; 399 438 } 400 439 440 bool CConfigDB::SetValueAndWriteOnFile(EConfigNamespace ns, const CStr& name, const CStr& value) 441 { 442 CHECK_NS(false); 443 444 CScopeLock s(&cfgdb_mutex); 445 return SetValueAndWriteOnFile(ns, name, value, m_ConfigFile[ns]); 446 } 447 448 bool CConfigDB::SetValueAndWriteOnFile(EConfigNamespace ns, const CStr& name, const CStr& value, const VfsPath& path) 449 { 450 CHECK_NS(false); 451 452 CScopeLock s(&cfgdb_mutex); 453 bool changed = m_HasChanges[ns]; 454 455 // if there are no previous changes, we can just set the value and then write to file 456 if (!changed) 457 { 458 SetValueString(ns, name, value); 459 bool ret = WriteFile(ns, path); 460 m_HasChanges[ns] = !ret; 461 return ret; 462 } 463 464 // otherwise we set this value in the specified namespace 465 SetValueString(ns, name, value); 466 TConfigMap newMap; 467 m_Map[ns].swap(newMap); 468 if (!Reload(ns)) 469 { 470 m_Map[ns].swap(newMap); 471 m_HasChanges[ns] = true; 472 return false; 473 } 474 // and add it to be written on file 475 SetValueString(ns, name, value); 476 bool ret = WriteFile(ns, path); 477 m_Map[ns].swap(newMap); 478 m_HasChanges[ns] = changed || !ret; 479 return ret; 480 } 481 401 482 #undef CHECK_NS -
source/ps/ConfigDB.h
52 52 { 53 53 static std::map<CStr, CConfigValueSet> m_Map[]; 54 54 static VfsPath m_ConfigFile[]; 55 static bool m_HasChanges[]; 56 static bool m_IsDirty[]; 55 57 56 58 public: 57 59 CConfigDB(); … … 72 74 void GetValue(EConfigNamespace ns, const CStr& name, std::string& value); 73 75 74 76 /** 77 * Returns true if changed with respect to last write on file 78 */ 79 bool HasChanges(EConfigNamespace ns) const; 80 81 /** 82 * Returns true if dirty (i.e. should not anymore be writen on file) 83 */ 84 bool IsDirty(EConfigNamespace ns) const; 85 86 void SetDirty(EConfigNamespace ns); 87 88 /** 75 89 * Attempt to retrieve a vector of values corresponding to the given setting; 76 90 * will search CFG_COMMAND first, and then all namespaces from the specified 77 91 * namespace down. … … 96 110 * existed the value is replaced. 97 111 */ 98 112 void SetValueString(EConfigNamespace ns, const CStr& name, const CStr& value); 113 114 /** 115 * Remove a config value in the specified namespace. 116 */ 117 void RemoveValue(EConfigNamespace ns, const CStr& name); 99 118 100 119 /** 101 120 * Set the path to the config file used to populate the specified namespace … … 135 154 * false: if an error occurred 136 155 */ 137 156 bool WriteFile(EConfigNamespace ns) const; 157 158 /** 159 * Save a config value in the specified namespace (if the config variable 160 * existed the value is replaced) and write it to file specified by 'path' 161 * 162 * Returns: 163 * true: if the config value was successfully saved and written to the file 164 * false: if an error occurred 165 */ 166 bool SetValueAndWriteOnFile(EConfigNamespace ns, const CStr& name, const CStr& value, const VfsPath& path); 167 168 /** 169 * Save a config value in the specified namespace (if the config variable 170 * existed the value is replaced) and write it to file it was originally loaded from 171 * 172 * Returns: 173 * true: if the config value was successfully saved and written to the file 174 * false: if an error occurred 175 */ 176 177 bool SetValueAndWriteOnFile(EConfigNamespace ns, const CStr& name, const CStr& value); 138 178 }; 139 179 140 180 -
source/ps/UserReport.cpp
537 537 userID += hex; 538 538 } 539 539 540 g_ConfigDB.SetValueString(CFG_USER, "userreport.id", userID); 541 g_ConfigDB.WriteFile(CFG_USER); 540 g_ConfigDB.SetValueAndWriteOnFile(CFG_USER, "userreport.id", userID); 542 541 } 543 542 544 543 return userID; … … 554 553 void CUserReporter::SetReportingEnabled(bool enabled) 555 554 { 556 555 CStr val = CStr::FromInt(enabled ? REPORTER_VERSION : 0); 557 g_ConfigDB.SetValueString(CFG_USER, "userreport.enabledversion", val); 558 g_ConfigDB.WriteFile(CFG_USER); 556 g_ConfigDB.SetValueAndWriteOnFile(CFG_USER, "userreport.enabledversion", val); 559 557 560 558 if (m_Worker) 561 559 m_Worker->SetEnabled(enabled); -
source/ps/scripting/JSInterface_ConfigDB.cpp
42 42 return true; 43 43 } 44 44 45 bool JSI_ConfigDB::HasChanges(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString) 46 { 47 EConfigNamespace cfgNs; 48 if (!GetConfigNamespace(cfgNsString, cfgNs)) 49 return false; 50 51 return g_ConfigDB.HasChanges(cfgNs); 52 } 53 54 bool JSI_ConfigDB::IsDirty(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString) 55 { 56 EConfigNamespace cfgNs; 57 if (!GetConfigNamespace(cfgNsString, cfgNs)) 58 return false; 59 60 return g_ConfigDB.IsDirty(cfgNs); 61 } 62 63 bool JSI_ConfigDB::SetDirty(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString) 64 { 65 EConfigNamespace cfgNs; 66 if (!GetConfigNamespace(cfgNsString, cfgNs)) 67 return false; 68 69 g_ConfigDB.SetDirty(cfgNs); 70 return true; 71 } 72 45 73 std::string JSI_ConfigDB::GetValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name) 46 74 { 47 75 EConfigNamespace cfgNs; … … 63 91 return true; 64 92 } 65 93 94 bool JSI_ConfigDB::RemoveValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name) 95 { 96 EConfigNamespace cfgNs; 97 if (!GetConfigNamespace(cfgNsString, cfgNs)) 98 return false; 99 100 g_ConfigDB.RemoveValue(cfgNs, name); 101 return true; 102 } 103 66 104 bool JSI_ConfigDB::WriteFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const Path& path) 67 105 { 68 106 EConfigNamespace cfgNs; … … 73 111 return ret; 74 112 } 75 113 114 bool JSI_ConfigDB::CreateValueAndWriteOnFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path) 115 { 116 EConfigNamespace cfgNs; 117 if (!GetConfigNamespace(cfgNsString, cfgNs)) 118 return false; 119 120 bool ret = g_ConfigDB.SetValueAndWriteOnFile(cfgNs, name, value, path); 121 return ret; 122 } 123 76 124 bool JSI_ConfigDB::Reload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString) 77 125 { 78 126 EConfigNamespace cfgNs; … … 95 143 96 144 void JSI_ConfigDB::RegisterScriptFunctions(ScriptInterface& scriptInterface) 97 145 { 146 scriptInterface.RegisterFunction<bool, std::wstring, &JSI_ConfigDB::HasChanges>("ConfigDB_HasChanges"); 147 scriptInterface.RegisterFunction<bool, std::wstring, &JSI_ConfigDB::IsDirty>("ConfigDB_IsDirty"); 148 scriptInterface.RegisterFunction<bool, std::wstring, &JSI_ConfigDB::SetDirty>("ConfigDB_SetDirty"); 98 149 scriptInterface.RegisterFunction<std::string, std::wstring, std::string, &JSI_ConfigDB::GetValue>("ConfigDB_GetValue"); 99 150 scriptInterface.RegisterFunction<bool, std::wstring, std::string, std::string, &JSI_ConfigDB::CreateValue>("ConfigDB_CreateValue"); 151 scriptInterface.RegisterFunction<bool, std::wstring, std::string, &JSI_ConfigDB::RemoveValue>("ConfigDB_RemoveValue"); 100 152 scriptInterface.RegisterFunction<bool, std::wstring, Path, &JSI_ConfigDB::WriteFile>("ConfigDB_WriteFile"); 153 scriptInterface.RegisterFunction<bool, std::wstring, std::string, std::string, Path, &JSI_ConfigDB::CreateValueAndWriteOnFile>("ConfigDB_CreateValueAndWriteOnFile"); 101 154 scriptInterface.RegisterFunction<bool, std::wstring, Path, &JSI_ConfigDB::SetFile>("ConfigDB_SetFile"); 102 155 scriptInterface.RegisterFunction<bool, std::wstring, &JSI_ConfigDB::Reload>("ConfigDB_Reload"); 103 104 156 } -
source/ps/scripting/JSInterface_ConfigDB.h
24 24 namespace JSI_ConfigDB 25 25 { 26 26 bool GetConfigNamespace(const std::wstring& cfgNsString, EConfigNamespace& cfgNs); 27 bool HasChanges(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString); 28 bool IsDirty(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString); 29 bool SetDirty(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString); 27 30 std::string GetValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name); 28 31 bool CreateValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value); 32 bool RemoveValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name); 29 33 bool WriteFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path); 34 bool CreateValueAndWriteOnFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path); 30 35 bool Reload(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString); 31 36 bool SetFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path); 32 37 void RegisterScriptFunctions(ScriptInterface& scriptInterface);