From c98659628f16bd70b9230041daf5f7f7777adf8e Mon Sep 17 00:00:00 2001 From: elexis Date: Mon, 14 Nov 2016 13:43:27 +0000 Subject: [PATCH] GUI cleanup. Remove sprintf from untranslated error messages, unneeded braces and comments, add missing quotes. git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@18934 3db68df2-c116-0410-a063-a993310a9797 --- .../public/gui/common/functions_utility_error.js | 45 ++++++++-------------- binaries/data/mods/public/gui/loading/loading.js | 2 - binaries/data/mods/public/gui/session/input.js | 28 +++----------- 3 files changed, 23 insertions(+), 52 deletions(-) rewrite binaries/data/mods/public/gui/common/functions_utility_error.js (67%) diff --git a/binaries/data/mods/public/gui/common/functions_utility_error.js b/binaries/data/mods/public/gui/common/functions_utility_error.js dissimilarity index 67% index 915b495d23..856518f3be 100644 --- a/binaries/data/mods/public/gui/common/functions_utility_error.js +++ b/binaries/data/mods/public/gui/common/functions_utility_error.js @@ -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 - }); - } - - Engine.ResetCursor(); -} +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(); +} diff --git a/binaries/data/mods/public/gui/loading/loading.js b/binaries/data/mods/public/gui/loading/loading.js index 5294d34835..24e8aa4db6 100644 --- a/binaries/data/mods/public/gui/loading/loading.js +++ b/binaries/data/mods/public/gui/loading/loading.js @@ -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(); diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index bdee1c2d8d..c611630b46 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -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; } -- 2.11.4.GIT