Pause support (mouse cursor is released when the game is paused)
authorunc0rr
Mon, 27 Nov 2006 17:29:08 +0000
changeset 281 5b483aa9f2ab
parent 280 4d6e365befc1
child 282 b1e3387389b6
Pause support (mouse cursor is released when the game is paused)
QTfrontend/binds.h
hedgewars/CCHandlers.inc
hedgewars/hwengine.dpr
hedgewars/uConsole.pas
hedgewars/uGame.pas
hedgewars/uLocale.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Locale/en.txt
share/hedgewars/Data/Locale/ru.txt
--- a/QTfrontend/binds.h	Sun Nov 26 21:19:24 2006 +0000
+++ b/QTfrontend/binds.h	Mon Nov 27 17:29:08 2006 +0000
@@ -22,7 +22,7 @@
 #include <QString>
 #include <QtGlobal>
 
-#define BINDS_NUMBER 29
+#define BINDS_NUMBER 30
 
 struct BindAction
 {
@@ -58,6 +58,7 @@
 	{"timer 3",	"3",	QT_TRANSLATE_NOOP("binds", "timer 3 sec"),	false},
 	{"timer 4",	"4",	QT_TRANSLATE_NOOP("binds", "timer 4 sec"),	false},
 	{"timer 5",	"5",	QT_TRANSLATE_NOOP("binds", "timer 5 sec"),	true},
+	{"pause",	"p",	QT_TRANSLATE_NOOP("binds", "pause"),	false},
 	{"+voldown",	"9",	QT_TRANSLATE_NOOP("binds", "volume down"),	false},
 	{"+volup",	"0",	QT_TRANSLATE_NOOP("binds", "volume up"),	false},
 	{"fullscr",	"f",	QT_TRANSLATE_NOOP("binds", "change mode"),	false},
--- a/hedgewars/CCHandlers.inc	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/CCHandlers.inc	Mon Nov 27 17:29:08 2006 +0000
@@ -415,8 +415,7 @@
 AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf))));
 {$ENDIF}
 TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
-PixelFormat:= SDLPrimSurface.format;
-SDL_ShowCursor(0)
+PixelFormat:= SDLPrimSurface.format
 end;
 
 procedure chVol_p(var s: shortstring);
@@ -436,3 +435,9 @@
 FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear
 end;
 
+procedure chPause(var s: shortstring);
+begin
+isPaused:= not isPaused;
+SDL_ShowCursor(ord(isPaused))
+end;
+
--- a/hedgewars/hwengine.dpr	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/hwengine.dpr	Mon Nov 27 17:29:08 2006 +0000
@@ -188,7 +188,8 @@
 procedure ShowMainWindow;
 begin
 if cFullScreen then ParseCommand('fullscr 1')
-               else ParseCommand('fullscr 0')
+               else ParseCommand('fullscr 0');
+SDL_ShowCursor(0)
 end;
 
 ///////////////
--- a/hedgewars/uConsole.pas	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/uConsole.pas	Mon Nov 27 17:29:08 2006 +0000
@@ -303,6 +303,7 @@
 RegisterVariable('+voldown', vtCommand, @chVol_m        , true );
 RegisterVariable('-voldown', vtCommand, @chVol_p        , true );
 RegisterVariable('findhh'  , vtCommand, @chFindhh       , true );
+RegisterVariable('pause'   , vtCommand, @chPause        , true );
 
 finalization
 FreeVariablesList
--- a/hedgewars/uGame.pas	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/uGame.pas	Mon Nov 27 17:29:08 2006 +0000
@@ -31,6 +31,7 @@
 const SendEmptyPacketTicks: LongWord = 0;
 var i: integer;
 begin
+if isPaused then exit;
 if not CurrentTeam.ExtDriven then
    begin
    NetGetNextCmd; // its for the case when receiving "/say" message
@@ -42,7 +43,6 @@
       SendEmptyPacketTicks:= 0
       end
    end;
-
 if Lag > 100 then Lag:= 100
 else if GameType = gmtSave then Lag:= 2500;
 
--- a/hedgewars/uLocale.pas	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/uLocale.pas	Mon Nov 27 17:29:08 2006 +0000
@@ -22,7 +22,7 @@
                    sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
                    sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
                    sidParachute, sidAirAttack);
-     TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume);
+     TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused);
 var trammo: array[TAmmoStrId] of string;
     trmsg: array[TMsgStrId] of string;
 
--- a/hedgewars/uMisc.pas	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/uMisc.pas	Mon Nov 27 17:29:08 2006 +0000
@@ -23,6 +23,7 @@
 var isCursorVisible : boolean = false;
     isTerminated    : boolean = false;
     isInLag         : boolean = false;
+    isPaused        : boolean = false;
     isSoundEnabled  : boolean = true;
     isSEBackup      : boolean = true;
     isInMultiShoot  : boolean = false;
--- a/hedgewars/uStore.pas	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/uStore.pas	Mon Nov 27 17:29:08 2006 +0000
@@ -42,9 +42,10 @@
 
 var PixelFormat: PSDL_PixelFormat;
  SDLPrimSurface: PSDL_Surface;
+   PauseSurface: PSDL_Surface;
 
 implementation
-uses uMisc, uConsole, uLand;
+uses uMisc, uConsole, uLand, uLocale;
 
 var StoreSurface,
        HHSurface: PSDL_Surface;
@@ -308,6 +309,8 @@
 
 InitHealth;
 
+PauseSurface:= RenderString(trmsg[sidPaused], $FFFF00, fntBig);
+
 {$IFDEF DUMP}
 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
 SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
--- a/hedgewars/uWorld.pas	Sun Nov 26 21:19:24 2006 +0000
+++ b/hedgewars/uWorld.pas	Mon Nov 27 17:29:08 2006 +0000
@@ -170,7 +170,7 @@
     end;
 
 begin
-MoveCamera;
+if not isPaused then MoveCamera;
 
 // Sky
 inc(RealTicks, Lag);
@@ -371,6 +371,8 @@
 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
 {$ENDIF}
 
+if isPaused then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, PauseSurface, Surface);
+
 inc(Frames);
 inc(CountTicks, Lag);
 if CountTicks >= 1000 then
--- a/share/hedgewars/Data/Locale/en.txt	Sun Nov 26 21:19:24 2006 +0000
+++ b/share/hedgewars/Data/Locale/en.txt	Mon Nov 27 17:29:08 2006 +0000
@@ -20,4 +20,5 @@
 01:00=Let's fight!
 01:01=Round draw
 01:02=%1 wins!
-01:03=Volume %1%
\ No newline at end of file
+01:03=Volume %1%
+01:04=Paused
\ No newline at end of file
--- a/share/hedgewars/Data/Locale/ru.txt	Sun Nov 26 21:19:24 2006 +0000
+++ b/share/hedgewars/Data/Locale/ru.txt	Mon Nov 27 17:29:08 2006 +0000
@@ -20,4 +20,5 @@
 01:00=Вперёд к победе!
 01:01=Ничья
 01:02=Победила команда %1!
-01:03=Громкость %1%
\ No newline at end of file
+01:03=Громкость %1%
+01:04=Пауза
\ No newline at end of file