Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/options/options.js
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Lines | control[optionType.guiSetter] = function() { | ||||
optionType.sanitizeValue(value, control, option); | optionType.sanitizeValue(value, control, option); | ||||
const oldValue = optionType.configToValue(Engine.ConfigDB_GetValue("user", option.config)); | const oldValue = optionType.configToValue(Engine.ConfigDB_GetValue("user", option.config)); | ||||
control.tooltip = option.tooltip + (optionType.tooltip ? "\n" + optionType.tooltip(value, option) : ""); | control.tooltip = option.tooltip + (optionType.tooltip ? "\n" + optionType.tooltip(value, option) : ""); | ||||
const hasChanges = Engine.ConfigDB_HasChanges("user"); | const hasChanges = Engine.ConfigDB_HasChanges("user"); | ||||
Engine.ConfigDB_CreateValue("user", option.config, String(value)); | Engine.ConfigDB_CreateValue("user", option.config, String(value)); | ||||
Engine.ConfigDB_SetChanges("user", true); | |||||
g_ChangedKeys.add(option.config); | g_ChangedKeys.add(option.config); | ||||
fireConfigChangeHandlers(new Set([option.config])); | fireConfigChangeHandlers(new Set([option.config])); | ||||
if (option.timeout) | if (option.timeout) | ||||
optionType.timeout(option, oldValue, hasChanges, value); | optionType.timeout(option, oldValue, hasChanges, value); | ||||
if (option.function) | if (option.function) | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
for (let category in g_Options) | for (let category in g_Options) | ||||
for (let option of g_Options[category].options) | for (let option of g_Options[category].options) | ||||
{ | { | ||||
Engine.ConfigDB_RemoveValue("user", option.config); | Engine.ConfigDB_RemoveValue("user", option.config); | ||||
g_ChangedKeys.add(option.config); | g_ChangedKeys.add(option.config); | ||||
} | } | ||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg"); | Engine.ConfigDB_SaveChanges("user"); | ||||
revertChanges(); | revertChanges(); | ||||
} | } | ||||
function revertChange(option, oldValue, hadChanges) | function revertChange(option, oldValue, hadChanges) | ||||
{ | { | ||||
Engine.ConfigDB_CreateValue("user", option.config, String(oldValue)); | |||||
if (!hadChanges) | if (!hadChanges) | ||||
Engine.ConfigDB_SetChanges("user", false); | Engine.ConfigDB_SetChanges("user", false); | ||||
Engine.ConfigDB_CreateValue("user", option.config, String(oldValue)); | |||||
if (option.function) | if (option.function) | ||||
Engine[option.function](oldValue); | Engine[option.function](oldValue); | ||||
displayOptions(); | displayOptions(); | ||||
} | } | ||||
function revertChanges() | function revertChanges() | ||||
{ | { | ||||
Engine.ConfigDB_Reload("user"); | Engine.ConfigDB_Reload("user"); | ||||
Engine.ConfigDB_SetChanges("user", false); | |||||
for (let category in g_Options) | for (let category in g_Options) | ||||
for (let option of g_Options[category].options) | for (let option of g_Options[category].options) | ||||
if (option.function) | if (option.function) | ||||
Engine[option.function]( | Engine[option.function]( | ||||
g_OptionType[option.type].configToValue( | g_OptionType[option.type].configToValue( | ||||
Engine.ConfigDB_GetValue("user", option.config))); | Engine.ConfigDB_GetValue("user", option.config))); | ||||
Show All 26 Lines | for (let i = 0; i < g_Options[category].options.length; ++i) | ||||
return; | return; | ||||
} | } | ||||
reallySaveChanges(); | reallySaveChanges(); | ||||
} | } | ||||
function reallySaveChanges() | function reallySaveChanges() | ||||
{ | { | ||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg"); | Engine.ConfigDB_SaveChanges("user"); | ||||
Engine.ConfigDB_SetChanges("user", false); | |||||
enableButtons(); | enableButtons(); | ||||
} | } | ||||
/** | /** | ||||
* Close GUI page and inform the parent GUI page which options changed. | * Close GUI page and inform the parent GUI page which options changed. | ||||
**/ | **/ | ||||
function closePage() | function closePage() | ||||
{ | { | ||||
Show All 15 Lines |
Wildfire Games · Phabricator