--- a/QTfrontend/hwform.cpp Thu Jan 03 17:14:14 2013 +0200
+++ b/QTfrontend/hwform.cpp Fri Jan 04 02:58:19 2013 +0100
@@ -553,72 +553,49 @@
GoToPage(ID_PAGE_VIDEOS);
}
+//TODO: maybe find a better place for this?
+QString HWForm::stringifyPageId(quint32 id)
+{
+ QString pageName;
+ switch (id)
+ {
+ case ID_PAGE_SETUP_TEAM : pageName = "PAGE_SETUP_TEAM"; break;
+ case ID_PAGE_SETUP : pageName = "PAGE_SETUP"; break;
+ case ID_PAGE_MULTIPLAYER : pageName = "PAGE_MULTIPLAYER"; break;
+ case ID_PAGE_DEMOS : pageName = "PAGE_DEMOS"; break;
+ case ID_PAGE_NET : pageName = "PAGE_NET"; break;
+ case ID_PAGE_NETGAME : pageName = "PAGE_NETGAME"; break;
+ case ID_PAGE_INFO : pageName = "PAGE_INFO"; break;
+ case ID_PAGE_MAIN : pageName = "PAGE_MAIN"; break;
+ case ID_PAGE_GAMESTATS : pageName = "PAGE_GAMESTATS"; break;
+ case ID_PAGE_SINGLEPLAYER : pageName = "PAGE_SINGLEPLAYER"; break;
+ case ID_PAGE_TRAINING : pageName = "PAGE_TRAINING"; break;
+ case ID_PAGE_SELECTWEAPON : pageName = "PAGE_SELECTWEAPON"; break;
+ case ID_PAGE_NETSERVER : pageName = "PAGE_NETSERVER"; break;
+ case ID_PAGE_INGAME : pageName = "PAGE_INGAME"; break;
+ case ID_PAGE_ROOMSLIST : pageName = "PAGE_ROOMSLIST"; break;
+ case ID_PAGE_CONNECTING : pageName = "PAGE_CONNECTING"; break;
+ case ID_PAGE_SCHEME : pageName = "PAGE_SCHEME"; break;
+ case ID_PAGE_ADMIN : pageName = "PAGE_ADMIN"; break;
+ case ID_PAGE_CAMPAIGN : pageName = "PAGE_CAMPAIGN"; break;
+ case ID_PAGE_DRAWMAP : pageName = "PAGE_DRAWMAP"; break;
+ case ID_PAGE_DATADOWNLOAD : pageName = "PAGE_DATADOWNLOAD"; break;
+ case ID_PAGE_FEEDBACK : pageName = "PAGE_FEEDBACK"; break;
+ case ID_PAGE_VIDEOS : pageName = "PAGE_VIDEOS"; break;
+ case MAX_PAGE : pageName = "MAX_PAGE"; break;
+ default : pageName = "UNKNOWN_PAGE"; break;
+ }
+ return pageName;
+}
+
void HWForm::OnPageShown(quint8 id, quint8 lastid)
{
#ifdef USE_XFIRE
updateXfire();
#endif
- QString openPrefix = "Debug: (PAGE_OPENED: ";
- QString openSuffix = ")";
- QString closePrefix = "Debug: (PAGE_LEFT: ";
- QString closeSuffix = ")";
-
- switch (lastid) { //Print the id of the page we're leaving
- case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- default : qDebug("%sUNKNOWN PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- } //end switch(lastid)
- switch (id) { //Print the id of the opened page
- case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- default : qDebug("%sUNKNOWN PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- } //end switch(id)
-
+ qDebug("Leaving %s, entering %s", qPrintable(stringifyPageId(lastid)), qPrintable(stringifyPageId(id)));
+
if (id == ID_PAGE_DATADOWNLOAD)
{
ui.pageDataDownload->fetchList();
--- a/QTfrontend/hwform.h Thu Jan 03 17:14:14 2013 +0200
+++ b/QTfrontend/hwform.h Fri Jan 04 02:58:19 2013 +0100
@@ -148,6 +148,7 @@
void closeEvent(QCloseEvent *event);
void CustomizePalettes();
void resizeEvent(QResizeEvent * event);
+ QString stringifyPageId(quint32 id);
//void keyReleaseEvent(QKeyEvent *event);
enum PageIDs
--- a/QTfrontend/main.cpp Thu Jan 03 17:14:14 2013 +0200
+++ b/QTfrontend/main.cpp Fri Jan 04 02:58:19 2013 +0100
@@ -39,9 +39,11 @@
#ifdef _WIN32
#include <Shlobj.h>
+#elif defined __APPLE__
+#include "CocoaInitializer.h"
#endif
-#ifdef __APPLE__
-#include "CocoaInitializer.h"
+#ifndef _WIN32
+#include <signal.h>
#endif
@@ -87,6 +89,12 @@
else
season = SEASON_NONE;
}
+#ifndef _WIN32
+void terminateFrontend(int signal)
+{
+ QCoreApplication::exit(0);
+}
+#endif
bool checkForDir(const QString & dir)
{
@@ -136,6 +144,10 @@
atexit(releaseCocoaPool);
#endif
+#ifndef _WIN32
+ signal(SIGINT, &terminateFrontend);
+#endif
+
HWApplication app(argc, argv);
QLabel *splash = NULL;
--- a/hedgewars/uGears.pas Thu Jan 03 17:14:14 2013 +0200
+++ b/hedgewars/uGears.pas Fri Jan 04 02:58:19 2013 +0100
@@ -78,6 +78,7 @@
stSpawn, stNTurn);
upd: Longword;
snowLeft,snowRight: LongInt;
+ NewTurnTick: LongWord;
//SDMusic: shortstring;
// For better maintainability the step handlers of gears are stored in
@@ -189,6 +190,16 @@
i, AliveCount: LongInt;
s: shortstring;
begin
+ScriptCall('onGameTick');
+if GameTicks mod 20 = 0 then ScriptCall('onGameTick20');
+if GameTicks = NewTurnTick then
+ begin
+ ScriptCall('onNewTurn');
+{$IFDEF SDL13}
+ uTouch.NewTurnBeginning();
+{$ENDIF}
+ end;
+
PrvInactive:= AllInactive;
AllInactive:= true;
@@ -383,7 +394,8 @@
SwitchHedgehog;
AfterSwitchHedgehog;
- bBetweenTurns:= false
+ bBetweenTurns:= false;
+ NewTurnTick:= GameTicks + 1
end;
step:= Low(step)
end;
@@ -470,8 +482,6 @@
inc(hiTicks) // we do not recieve a message for this
end;
AddRandomness(CheckSum);
-ScriptCall('onGameTick');
-if GameTicks mod 20 = 0 then ScriptCall('onGameTick20');
inc(GameTicks)
end;
@@ -1396,6 +1406,7 @@
upd:= 0;
//SDMusic:= 'hell.ogg';
+ NewTurnTick:= $FFFFFFFF;
end;
procedure freeModule;
--- a/hedgewars/uTeams.pas Thu Jan 03 17:14:14 2013 +0200
+++ b/hedgewars/uTeams.pas Fri Jan 04 02:58:19 2013 +0100
@@ -321,11 +321,6 @@
end;
ReadyTimeLeft:= 0
end;
-
-{$IFDEF SDL13}
-uTouch.NewTurnBeginning();
-{$ENDIF}
-ScriptCall('onNewTurn');
end;
function AddTeam(TeamColor: Longword): PTeam;
--- a/share/hedgewars/Data/Maps/Basketball/map.lua Thu Jan 03 17:14:14 2013 +0200
+++ b/share/hedgewars/Data/Maps/Basketball/map.lua Fri Jan 04 02:58:19 2013 +0100
@@ -1,6 +1,6 @@
-- Hedgewars - Basketball for 2+ Players
-loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+HedgewarsScriptLoad("Scripts/Locale.lua")()
local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
--- a/share/hedgewars/Data/Maps/CTF_Blizzard/map.lua Thu Jan 03 17:14:14 2013 +0200
+++ b/share/hedgewars/Data/Maps/CTF_Blizzard/map.lua Fri Jan 04 02:58:19 2013 +0100
@@ -91,7 +91,7 @@
-- add support for more players
-- re-enable sudden death, but set water rise to 0
-loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+HedgewarsScriptLoad("Scripts/Locale.lua")()
---------------------------------------------------------------
----------lots of bad variables and things
--- a/share/hedgewars/Data/Maps/Control/map.lua Thu Jan 03 17:14:14 2013 +0200
+++ b/share/hedgewars/Data/Maps/Control/map.lua Fri Jan 04 02:58:19 2013 +0100
@@ -49,7 +49,7 @@
--script begins
-----------------
-loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+HedgewarsScriptLoad("Scripts/Locale.lua")()
---------------------------------------------------------------
----------lots of bad variables and things
--- a/share/hedgewars/Data/Maps/Knockball/map.lua Thu Jan 03 17:14:14 2013 +0200
+++ b/share/hedgewars/Data/Maps/Knockball/map.lua Fri Jan 04 02:58:19 2013 +0100
@@ -1,6 +1,6 @@
-- Hedgewars - Knockball for 2+ Players
-loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+HedgewarsScriptLoad("Scripts/Locale.lua")()
local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
--- a/share/hedgewars/Data/Maps/TrophyRace/map.lua Thu Jan 03 17:14:14 2013 +0200
+++ b/share/hedgewars/Data/Maps/TrophyRace/map.lua Fri Jan 04 02:58:19 2013 +0100
@@ -1,6 +1,6 @@
-- Hedgewars - Roperace for 2+ Players
-loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+HedgewarsScriptLoad("Scripts/Locale.lua")()
-- store number of hedgehogs
local numhhs = 0
--- a/share/hedgewars/Data/Scripts/Locale.lua Thu Jan 03 17:14:14 2013 +0200
+++ b/share/hedgewars/Data/Scripts/Locale.lua Fri Jan 04 02:58:19 2013 +0100
@@ -1,11 +1,11 @@
-- Library for localizing strings in lua scripts
-local lang = loadfile(GetUserDataPath() .. "Locale/" .. tostring(L) .. ".lua")
+local lang = HedgewarsScriptLoad("Locale/" .. tostring(L) .. ".lua")
if lang ~= nil then
lang()
else
- lang = loadfile(GetDataPath() .. "Locale/" .. tostring(L) .. ".lua")
+ lang = HedgewarsScriptLoad("Locale/" .. tostring(L) .. ".lua")
if lang ~= nil then
lang()
end