Switching between fullscreen and windowed modes on 'F' key
authorunc0rr
Mon, 25 Sep 2006 19:48:51 +0000
changeset 166 2920ab2bf329
parent 165 9b9144948668
child 167 805fa9a27e9e
Switching between fullscreen and windowed modes on 'F' key
QTfrontend/binds.h
hedgewars/CCHandlers.inc
hedgewars/hwengine.dpr
hedgewars/uConsole.pas
--- a/QTfrontend/binds.h	Sun Sep 24 21:32:18 2006 +0000
+++ b/QTfrontend/binds.h	Mon Sep 25 19:48:51 2006 +0000
@@ -37,7 +37,7 @@
 #include <QString>
 #include <QtGlobal>
 
-#define BINDS_NUMBER 25
+#define BINDS_NUMBER 26
 
 struct BindAction
 {
@@ -72,6 +72,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},
+	{"fullscr",	"f",	QT_TRANSLATE_NOOP("binds", "change mode"),	false},
 	{"capture",	"f11",	QT_TRANSLATE_NOOP("binds", "capture"),	false},
 	{"quit",	"f10",	QT_TRANSLATE_NOOP("binds", "quit"),	true}
 };
--- a/hedgewars/CCHandlers.inc	Sun Sep 24 21:32:18 2006 +0000
+++ b/hedgewars/CCHandlers.inc	Mon Sep 25 19:48:51 2006 +0000
@@ -386,4 +386,19 @@
           end
 end;
 
+procedure chFullScr(var s: shortstring);
+var flags: Longword;
+begin
+if Length(s) = 0 then cFullScreen:= not cFullScreen
+                 else cFullScreen:= s = '1';
+   
+flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL;
+if cFullScreen then flags:= flags or SDL_FULLSCREEN
+               else SDL_WM_SetCaption('Hedgewars', nil);
+SDL_FreeSurface(SDLPrimSurface);
+SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
+TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
+PixelFormat:= SDLPrimSurface.format;
+SDL_ShowCursor(0)
+end;
 
--- a/hedgewars/hwengine.dpr	Sun Sep 24 21:32:18 2006 +0000
+++ b/hedgewars/hwengine.dpr	Mon Sep 25 19:48:51 2006 +0000
@@ -205,15 +205,9 @@
 end;
 
 procedure ShowMainWindow;
-var flags: Longword;
 begin
-flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL;
-if cFullScreen then flags:= flags or SDL_FULLSCREEN
-               else SDL_WM_SetCaption('Hedgewars', nil);
-SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
-TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
-PixelFormat:= SDLPrimSurface.format;
-SDL_ShowCursor(0);
+if cFullScreen then ParseCommand('fullscr 1')
+               else ParseCommand('fullscr 0')
 end;
 
 ///////////////
--- a/hedgewars/uConsole.pas	Sun Sep 24 21:32:18 2006 +0000
+++ b/hedgewars/uConsole.pas	Mon Sep 25 19:48:51 2006 +0000
@@ -307,6 +307,7 @@
 RegisterVariable('put'     , vtCommand, @chPut          );
 RegisterVariable('ljump'   , vtCommand, @chLJump        );
 RegisterVariable('hjump'   , vtCommand, @chHJump        );
+RegisterVariable('fullscr' , vtCommand, @chFullScr      );
 
 finalization
 FreeVariablesList