1
0
forked from 0ad/0ad

Delete gui/common/functions_utility_error.js.

Move the one function in it that is globally called from the engine to
the other function that is called equally.

This was SVN commit r19781.
This commit is contained in:
elexis 2017-06-15 22:44:24 +00:00
parent ab67d1a6f3
commit bedb13ea28
5 changed files with 26 additions and 27 deletions

View File

@ -122,6 +122,27 @@ function displayGamestateNotifications()
setTimeout(displayGamestateNotifications, 1000);
}
/**
* This function is called from the engine whenever starting a game fails.
*/
function cancelOnLoadGameError(msg)
{
Engine.EndGame();
Engine.SwitchGuiPage("page_pregame.xml");
if (msg)
Engine.PushGuiPage("page_msgbox.xml", {
"width": 500,
"height": 200,
"message": '[font="sans-bold-18"]' + msg + '[/font]',
"title": translate("Loading Aborted"),
"mode": 2
});
Engine.ResetCursor();
}
/**
* Also called from the C++ side when ending the game.
* The current page can be the summary screen or a message box, so it can't be moved to session/.

View File

@ -1,17 +0,0 @@
function cancelOnError(msg)
{
Engine.EndGame();
Engine.SwitchGuiPage("page_pregame.xml");
if (msg)
Engine.PushGuiPage("page_msgbox.xml", {
"width": 500,
"height": 200,
"message": '[font="sans-bold-18"]' + msg + '[/font]',
"title": translate("Loading Aborted"),
"mode": 2
});
Engine.ResetCursor();
}

View File

@ -8,7 +8,6 @@
<objects>
<script file="gui/common/functions_global_object.js"/>
<script file="gui/common/functions_utility_error.js"/>
<script file="gui/loading/loading.js"/>

View File

@ -3,7 +3,6 @@
<objects>
<script file="gui/common/music.js"/>
<script file="gui/common/functions_global_object.js"/>
<script file="gui/common/functions_utility_error.js"/>
<script file="gui/pregame/mainmenu.js"/>
<script directory="gui/pregame/backgrounds/"/>

View File

@ -1631,16 +1631,13 @@ void CancelLoad(const CStrW& message)
JSAutoRequest rq(cx);
JS::RootedValue global(cx, pScriptInterface->GetGlobalObject());
// Cancel loader
LDR_Cancel();
// Call the cancelOnError GUI function, defined in ..gui/common/functions_utility_error.js
// So all GUI pages that load games should include this script
if (g_GUI && g_GUI->HasPages())
{
if (pScriptInterface->HasProperty(global, "cancelOnError" ))
pScriptInterface->CallFunctionVoid(global, "cancelOnError", message);
}
if (g_GUI &&
g_GUI->HasPages() &&
pScriptInterface->HasProperty(global, "cancelOnLoadGameError"))
pScriptInterface->CallFunctionVoid(global, "cancelOnLoadGameError", message);
}
bool InDevelopmentCopy()