forked from mirrors/0ad
GUI cleanup.
Remove sprintf from untranslated error messages, unneeded braces and comments, add missing quotes. This was SVN commit r18934.
This commit is contained in:
@@ -1,28 +1,17 @@
|
||||
/*
|
||||
DESCRIPTION : Error-handling utility functions.
|
||||
NOTES :
|
||||
*/
|
||||
|
||||
// ====================================================================
|
||||
function cancelOnError(msg)
|
||||
{
|
||||
// Delete game objects
|
||||
Engine.EndGame();
|
||||
|
||||
// Return to pregame
|
||||
Engine.SwitchGuiPage("page_pregame.xml");
|
||||
|
||||
// Display error dialog if message given
|
||||
if (msg)
|
||||
{
|
||||
Engine.PushGuiPage("page_msgbox.xml", {
|
||||
width: 500,
|
||||
height: 200,
|
||||
message: '[font="sans-bold-18"]' + msg + '[/font]',
|
||||
title: translate("Loading Aborted"),
|
||||
mode: 2
|
||||
"width": 500,
|
||||
"height": 200,
|
||||
"message": '[font="sans-bold-18"]' + msg + '[/font]',
|
||||
"title": translate("Loading Aborted"),
|
||||
"mode": 2
|
||||
});
|
||||
}
|
||||
|
||||
Engine.ResetCursor();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ function init(data)
|
||||
{
|
||||
g_Data = data;
|
||||
|
||||
// Set to "hourglass" cursor.
|
||||
Engine.SetCursor("cursor-wait");
|
||||
|
||||
// Get tip image and corresponding tip text
|
||||
@@ -100,7 +99,6 @@ function displayProgress()
|
||||
*/
|
||||
function reallyStartGame()
|
||||
{
|
||||
// Switch GUI from loading screen to game session.
|
||||
Engine.SwitchGuiPage("page_session.xml", g_Data);
|
||||
|
||||
Engine.ResetCursor();
|
||||
|
||||
@@ -289,36 +289,31 @@ function determineAction(x, y, fromMinimap)
|
||||
if (preSelectedAction != ACTION_NONE)
|
||||
{
|
||||
for (var action of actions)
|
||||
{
|
||||
if (unitActions[action].preSelectedActionCheck)
|
||||
{
|
||||
var r = unitActions[action].preSelectedActionCheck(target, selection);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return { "type": "none", "cursor": "", "target": target };
|
||||
}
|
||||
|
||||
for (var action of actions)
|
||||
{
|
||||
if (unitActions[action].hotkeyActionCheck)
|
||||
{
|
||||
var r = unitActions[action].hotkeyActionCheck(target, selection);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
for (var action of actions)
|
||||
{
|
||||
if (unitActions[action].actionCheck)
|
||||
{
|
||||
var r = unitActions[action].actionCheck(target, selection);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return { "type": "none", "cursor": "", "target": target };
|
||||
}
|
||||
@@ -330,14 +325,10 @@ function tryPlaceBuilding(queued)
|
||||
{
|
||||
if (placementSupport.mode !== "building")
|
||||
{
|
||||
error(sprintf("[%(functionName)s] Called while in '%(mode)s' placement mode instead of 'building'", {
|
||||
"functionName": "tryPlaceBuilding",
|
||||
"mode": placementSupport.mode
|
||||
}));
|
||||
error("tryPlaceBuilding expected 'building', got '" + placementSupport.mode + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use the preview to check it's a valid build location
|
||||
if (!updateBuildingPlacementPreview())
|
||||
{
|
||||
// invalid location - don't build it
|
||||
@@ -373,21 +364,14 @@ function tryPlaceWall(queued)
|
||||
{
|
||||
if (placementSupport.mode !== "wall")
|
||||
{
|
||||
error(sprintf("[%(functionName)s] Called while in '%(mode)s' placement mode; expected 'wall' mode", {
|
||||
functionName: "tryPlaceWall",
|
||||
mode: placementSupport.mode
|
||||
}));
|
||||
error("tryPlaceWall expected 'wall', got '" + placementSupport.mode + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
var wallPlacementInfo = updateBuildingPlacementPreview(); // entities making up the wall (wall segments, towers, ...)
|
||||
if (!(wallPlacementInfo === false || typeof(wallPlacementInfo) === "object"))
|
||||
{
|
||||
error(sprintf("[%(functionName)s] Unexpected return value from %(function2Name)s: '%(value)s'; expected either 'false' or 'object'", {
|
||||
functionName: "tryPlaceWall",
|
||||
function2Name: "updateBuildingPlacementPreview",
|
||||
value: uneval(placementInfo)
|
||||
}));
|
||||
error("Invalid updateBuildingPlacementPreview return value: " + uneval(wallPlacementInfo));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1174,7 +1158,7 @@ function doAction(action, ev)
|
||||
if (unitActions[action.type] && unitActions[action.type].execute)
|
||||
return unitActions[action.type].execute(target, action, selection, queued);
|
||||
|
||||
error("Invalid action.type "+action.type);
|
||||
error("Invalid action.type " + action.type);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1196,7 +1180,7 @@ function handleMinimapEvent(target)
|
||||
var queued = Engine.HotkeyIsPressed("session.queue");
|
||||
if (unitActions[action.type] && unitActions[action.type].execute)
|
||||
return unitActions[action.type].execute(target, action, selection, queued);
|
||||
error("Invalid action.type "+action.type);
|
||||
error("Invalid action.type " + action.type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user