Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/options/options.js
/** | /** | ||||
* Translated JSON file contents. | * Translated JSON file contents. | ||||
*/ | */ | ||||
var g_Options; | var g_Options; | ||||
/** | /** | ||||
* Remember whether to unpause running singleplayer games. | * Names of session functions to be called after closing the page. | ||||
*/ | |||||
var g_HasCallback; | |||||
/** | |||||
* Functions to call after closing the page. | |||||
*/ | */ | ||||
var g_CloseCallbacks; | var g_CloseCallbacks; | ||||
/** | /** | ||||
* Vertical size of a tab button. | * Vertical size of a tab button. | ||||
*/ | */ | ||||
var g_TabButtonHeight = 30; | var g_TabButtonHeight = 30; | ||||
▲ Show 20 Lines • Show All 144 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_CloseCallbacks = new Set(); | g_CloseCallbacks = hotloadData ? hotloadData.closeCallbacks : new Set(); | ||||
g_HasCallback = hotloadData && hotloadData.callback || data && data.callback; | |||||
g_TabCategorySelected = hotloadData ? hotloadData.tabCategorySelected : 0; | g_TabCategorySelected = hotloadData ? hotloadData.tabCategorySelected : 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( | ||||
g_Options, | g_Options, | ||||
g_TabButtonHeight, | g_TabButtonHeight, | ||||
g_TabButtonDist, | g_TabButtonDist, | ||||
selectPanel, | selectPanel, | ||||
displayOptions); | displayOptions); | ||||
} | } | ||||
function getHotloadData() | function getHotloadData() | ||||
{ | { | ||||
return { | return { | ||||
"tabCategorySelected": g_TabCategorySelected, | "tabCategorySelected": g_TabCategorySelected, | ||||
"callback": g_HasCallback | "closeCallbacks": g_CloseCallbacks | ||||
}; | }; | ||||
} | } | ||||
/** | /** | ||||
* Sets up labels and controls of all options of the currently selected category. | * Sets up labels and controls of all options of the currently selected category. | ||||
*/ | */ | ||||
function displayOptions() | function displayOptions() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | messageBox( | ||||
[translate("No"), translate("Yes")], | [translate("No"), translate("Yes")], | ||||
[null, closePageWithoutConfirmation]); | [null, closePageWithoutConfirmation]); | ||||
else | else | ||||
closePageWithoutConfirmation(); | closePageWithoutConfirmation(); | ||||
} | } | ||||
function closePageWithoutConfirmation() | function closePageWithoutConfirmation() | ||||
{ | { | ||||
if (g_HasCallback) | Engine.PopGuiPage(g_CloseCallbacks); | ||||
Engine.PopGuiPageCB(g_CloseCallbacks); | |||||
else | |||||
Engine.PopGuiPage(); | |||||
} | } |
Wildfire Games · Phabricator