Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: binaries/data/mods/mod/gui/common/functions_msgbox.js
- ===================================================================
- --- binaries/data/mods/mod/gui/common/functions_msgbox.js (revision 22653)
- +++ binaries/data/mods/mod/gui/common/functions_msgbox.js (working copy)
- @@ -1,52 +1,20 @@
- -// We want to pass callback functions for the different buttons in a convenient way.
- -// Because passing functions accross compartment boundaries is a pain, we just store them here together with some optional arguments.
- -// The messageBox page will return the code of the pressed button and the according function will be called.
- -var g_MessageBoxBtnFunctions = [];
- -var g_MessageBoxCallbackArgs = [];
- -
- -function messageBoxCallbackFunction(btnCode)
- -{
- - if (btnCode !== undefined && g_MessageBoxBtnFunctions[btnCode])
- - {
- - // Cache the variables to make it possible to call a messageBox from a callback function.
- - let callbackFunction = g_MessageBoxBtnFunctions[btnCode];
- - let callbackArgs = g_MessageBoxCallbackArgs[btnCode];
- -
- - g_MessageBoxBtnFunctions = [];
- - g_MessageBoxCallbackArgs = [];
- -
- - if (callbackArgs !== undefined)
- - callbackFunction(callbackArgs);
- - else
- - callbackFunction();
- - return;
- - }
- -
- - g_MessageBoxBtnFunctions = [];
- - g_MessageBoxCallbackArgs = [];
- -}
- -
- function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, mbCallbackArgs)
- {
- - if (g_MessageBoxBtnFunctions && g_MessageBoxBtnFunctions.length)
- - {
- - warn("A messagebox was called when a previous callback function is still set, aborting!");
- - return;
- - }
- -
- - g_MessageBoxBtnFunctions = mbBtnCode;
- - g_MessageBoxCallbackArgs = mbCallbackArgs || g_MessageBoxCallbackArgs;
- -
- - Engine.PushGuiPage("page_msgbox.xml", {
- - "width": mbWidth,
- - "height": mbHeight,
- - "message": mbMessage,
- - "title": mbTitle,
- - "buttonCaptions": mbButtonCaptions,
- - "callback": mbBtnCode && "messageBoxCallbackFunction"
- - });
- + Engine.PushGuiPage(
- + "page_msgbox.xml",
- + {
- + "width": mbWidth,
- + "height": mbHeight,
- + "message": mbMessage,
- + "title": mbTitle,
- + "buttonCaptions": mbButtonCaptions
- + },
- + btnCode => {
- + if (mbBtnCode !== undefined && mbBtnCode[btnCode])
- + mbBtnCode[btnCode](mbCallbackArgs ? mbCallbackArgs[btnCode] : undefined);
- + });
- }
- function openURL(url)
- {
- Engine.OpenURL(url);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement