Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/options/options.js
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | "tooltip": (value, option) => | ||||
"min": option.min.toFixed(2), | "min": option.min.toFixed(2), | ||||
"max": option.max.toFixed(2) | "max": option.max.toFixed(2) | ||||
}) | }) | ||||
} | } | ||||
}; | }; | ||||
function init(data, hotloadData) | function init(data, hotloadData) | ||||
{ | { | ||||
g_OptionsShown = true; | |||||
g_HasCallback = hotloadData && hotloadData.callback || data && data.callback; | g_HasCallback = hotloadData && hotloadData.callback || data && data.callback; | ||||
g_SelectedCategory = hotloadData ? hotloadData.selectedCategory : 0; | g_SelectedCategory = hotloadData ? hotloadData.selectedCategory : 0; | ||||
g_Options = Engine.ReadJSONFile("gui/options/options.json"); | g_Options = Engine.ReadJSONFile("gui/options/options.json"); | ||||
translateObjectKeys(g_Options, ["label", "tooltip"]); | translateObjectKeys(g_Options, ["label", "tooltip"]); | ||||
deepfreeze(g_Options); | deepfreeze(g_Options); | ||||
placeTabButtons(); | placeTabButtons(); | ||||
displayOptions(); | displayOptions(); | ||||
setOptionsHotkey(closePage); | |||||
} | } | ||||
function getHotloadData() | function getHotloadData() | ||||
{ | { | ||||
return { | return { | ||||
"selectedCategory": g_SelectedCategory, | "selectedCategory": g_SelectedCategory, | ||||
"callback": g_HasCallback | "callback": g_HasCallback | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | function saveChanges() | ||||
reallySaveChanges(); | reallySaveChanges(); | ||||
} | } | ||||
function reallySaveChanges() | function reallySaveChanges() | ||||
{ | { | ||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg"); | Engine.ConfigDB_WriteFile("user", "config/user.cfg"); | ||||
Engine.ConfigDB_SetChanges("user", false); | Engine.ConfigDB_SetChanges("user", false); | ||||
enableButtons(); | enableButtons(); | ||||
Polakrity: `Close without save` and `Save and Close` better? | |||||
Not Done Inline Actions"Keep temporary and close" and "Save and close"? Because it keeps the setted option while game is running until exit. ffffffff: "Keep temporary and close" and "Save and close"?
Because it keeps the setted option while game… | |||||
} | } | ||||
/** | /** | ||||
* Close GUI page and call callbacks if they exist. | * Close GUI page and call callbacks if they exist. | ||||
**/ | **/ | ||||
function closePage() | function closePage() | ||||
{ | { | ||||
if (Engine.ConfigDB_HasChanges("user")) | if (Engine.ConfigDB_HasChanges("user")) | ||||
messageBox( | messageBox( | ||||
500, 200, | 500, 200, | ||||
translate("You have unsaved changes, do you want to close this window?"), | translate("You have unsaved changes, do you want to close this window?"), | ||||
translate("Warning"), | translate("Warning"), | ||||
[translate("No"), translate("Yes")], | [translate("No"), translate("Keep temporary and close"), translate("Save and close")], | ||||
[null, closePageWithoutConfirmation]); | [null, closePageWithoutConfirmation, () => { | ||||
saveChanges(); | |||||
closePageWithoutConfirmation(); | |||||
}] | |||||
); | |||||
Not Done Inline Actionsa save and close thing is good but the "no" should be kept too, (It could be more clear to the user what the save button actually does, but out of scope I guess) bb: a save and close thing is good but the "no" should be kept too, (It could be more clear to the… | |||||
else | else | ||||
closePageWithoutConfirmation(); | closePageWithoutConfirmation(); | ||||
} | } | ||||
function closePageWithoutConfirmation() | function closePageWithoutConfirmation() | ||||
{ | { | ||||
Not Done Inline Actionsmultiple statements should be spread over different lines bb: multiple statements should be spread over different lines | |||||
if (g_HasCallback) | if (g_HasCallback) | ||||
Engine.PopGuiPageCB(); | Engine.PopGuiPageCB(); | ||||
else | else | ||||
Engine.PopGuiPage(); | Engine.PopGuiPage(); | ||||
g_OptionsShown = false; | |||||
} | } |
Wildfire Games · Phabricator
Close without save and Save and Close better?