forked from 0ad/0ad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
2,167 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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" | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.