Advertisement
Guest User

Untitled

a guest
Aug 14th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.34 KB | None | 0 0
  1. Index: binaries/data/mods/mod/gui/common/functions_msgbox.js
  2. ===================================================================
  3. --- binaries/data/mods/mod/gui/common/functions_msgbox.js   (revision 22653)
  4. +++ binaries/data/mods/mod/gui/common/functions_msgbox.js   (working copy)
  5. @@ -1,52 +1,20 @@
  6. -// We want to pass callback functions for the different buttons in a convenient way.
  7. -// Because passing functions accross compartment boundaries is a pain, we just store them here together with some optional arguments.
  8. -// The messageBox page will return the code of the pressed button and the according function will be called.
  9. -var g_MessageBoxBtnFunctions = [];
  10. -var g_MessageBoxCallbackArgs = [];
  11. -
  12. -function messageBoxCallbackFunction(btnCode)
  13. -{
  14. -   if (btnCode !== undefined && g_MessageBoxBtnFunctions[btnCode])
  15. -   {
  16. -       // Cache the variables to make it possible to call a messageBox from a callback function.
  17. -       let callbackFunction = g_MessageBoxBtnFunctions[btnCode];
  18. -       let callbackArgs = g_MessageBoxCallbackArgs[btnCode];
  19. -
  20. -       g_MessageBoxBtnFunctions = [];
  21. -       g_MessageBoxCallbackArgs = [];
  22. -
  23. -       if (callbackArgs !== undefined)
  24. -           callbackFunction(callbackArgs);
  25. -       else
  26. -           callbackFunction();
  27. -       return;
  28. -   }
  29. -
  30. -   g_MessageBoxBtnFunctions = [];
  31. -   g_MessageBoxCallbackArgs = [];
  32. -}
  33. -
  34.  function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, mbCallbackArgs)
  35.  {
  36. -   if (g_MessageBoxBtnFunctions && g_MessageBoxBtnFunctions.length)
  37. -   {
  38. -       warn("A messagebox was called when a previous callback function is still set, aborting!");
  39. -       return;
  40. -   }
  41. -
  42. -   g_MessageBoxBtnFunctions = mbBtnCode;
  43. -   g_MessageBoxCallbackArgs = mbCallbackArgs || g_MessageBoxCallbackArgs;
  44. -
  45. -   Engine.PushGuiPage("page_msgbox.xml", {
  46. -       "width": mbWidth,
  47. -       "height": mbHeight,
  48. -       "message": mbMessage,
  49. -       "title": mbTitle,
  50. -       "buttonCaptions": mbButtonCaptions,
  51. -       "callback": mbBtnCode && "messageBoxCallbackFunction"
  52. -   });
  53. +   Engine.PushGuiPage(
  54. +       "page_msgbox.xml",
  55. +       {
  56. +           "width": mbWidth,
  57. +           "height": mbHeight,
  58. +           "message": mbMessage,
  59. +           "title": mbTitle,
  60. +           "buttonCaptions": mbButtonCaptions
  61. +       },
  62. +       btnCode => {
  63. +           if (mbBtnCode !== undefined && mbBtnCode[btnCode])
  64. +               mbBtnCode[btnCode](mbCallbackArgs ? mbCallbackArgs[btnCode] : undefined);
  65. +       });
  66.  }
  67.  
  68.  function openURL(url)
  69.  {
  70.     Engine.OpenURL(url);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement