- Implement zoom-in and zoom-out
authorunc0rr
Sat, 13 Jun 2009 15:39:26 +0000
changeset 2162 2bce91404d49
parent 2161 0c8634241fa4
child 2163 12730f5e79b9
- Implement zoom-in and zoom-out - Some bugfixes. Ammo menu doesn't work.
hedgewars/CCHandlers.inc
hedgewars/hwengine.dpr
hedgewars/uConsole.pas
hedgewars/uKeys.pas
hedgewars/uMisc.pas
hedgewars/uWorld.pas
--- a/hedgewars/CCHandlers.inc	Sat Jun 13 15:30:40 2009 +0000
+++ b/hedgewars/CCHandlers.inc	Sat Jun 13 15:39:26 2009 +0000
@@ -665,6 +665,16 @@
 isSpeed:= false
 end;
 
+procedure chZoomIn(var s: shortstring);
+begin
+if zoom < 4.0 then zoom:= zoom + 0.25;
+end;
+
+procedure chZoomOut(var s: shortstring);
+begin
+if zoom > 0.25 then zoom:= zoom - 0.25;
+end;
+
 procedure chChat(var s: shortstring);
 begin
 GameState:= gsChat;
--- a/hedgewars/hwengine.dpr	Sat Jun 13 15:30:40 2009 +0000
+++ b/hedgewars/hwengine.dpr	Sat Jun 13 15:39:26 2009 +0000
@@ -97,7 +97,7 @@
 				end;
 			FinishProgress;
 			PlayMusic;
-			SetScale(1.5);
+			SetScale(zoom);
 			GameState:= gsGame
 			end;
 	gsConfirm,
--- a/hedgewars/uConsole.pas	Sat Jun 13 15:30:40 2009 +0000
+++ b/hedgewars/uConsole.pas	Sat Jun 13 15:39:26 2009 +0000
@@ -258,6 +258,8 @@
 RegisterVariable('confirm' , vtCommand, @chConfirm      , true );
 RegisterVariable('+speedup', vtCommand, @chSpeedup_p    , true );
 RegisterVariable('-speedup', vtCommand, @chSpeedup_m    , true );
+RegisterVariable('zoomin'  , vtCommand, @chZoomIn       , true );
+RegisterVariable('zoomout' , vtCommand, @chZoomOut      , true );
 RegisterVariable('skip'    , vtCommand, @chSkip         , false);
 RegisterVariable('history' , vtCommand, @chHistory      , true );
 RegisterVariable('chat'    , vtCommand, @chChat         , true );
--- a/hedgewars/uKeys.pas	Sat Jun 13 15:30:40 2009 +0000
+++ b/hedgewars/uKeys.pas	Sat Jun 13 15:39:26 2009 +0000
@@ -139,6 +139,9 @@
 DefaultBinds[121]:= 'confirm';
 DefaultBinds[127]:= 'rotmask';
 
+DefaultBinds[ 61]:= 'zoomout';
+DefaultBinds[ 45]:= 'zoomin';
+
 DefaultBinds[KeyNameToCode('f12')]:= 'fullscr';
 
 SetDefaultBinds
--- a/hedgewars/uMisc.pas	Sat Jun 13 15:30:40 2009 +0000
+++ b/hedgewars/uMisc.pas	Sat Jun 13 15:39:26 2009 +0000
@@ -59,6 +59,7 @@
 	cBits            : LongInt = 32;
 	cBitsStr         : string[2] = '32';
 	cTagsMask        : byte = 7;
+	zoom             : GLfloat = 2.0;
 
 	cWaterLine       : LongInt = LAND_HEIGHT;
 	cVisibleWater    : LongInt = 128;
--- a/hedgewars/uWorld.pas	Sat Jun 13 15:30:40 2009 +0000
+++ b/hedgewars/uWorld.pas	Sat Jun 13 15:39:26 2009 +0000
@@ -448,7 +448,7 @@
 
 if GameState = gsConfirm then DrawCentered(0, cScreenHeight div 2, ConfirmTexture);
 
-SetScale(1.5);
+SetScale(zoom);
 
 glDisable(GL_TEXTURE_2D);
 glDisable(GL_BLEND)
@@ -479,6 +479,7 @@
 	and cHasFocus then
 	begin
 	SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
+	CursorPoint.X:= CursorPoint.X - cScreenWidth div 2;
 //	CursorPoint.X:= round((CursorPoint.X - cScreenWidth / 2) * 2 / cScaleFactor);
 //	CursorPoint.Y:= round(CursorPoint.Y * 2 / cScaleFactor);
 	end;
@@ -547,11 +548,11 @@
       begin
       WorldDx:= WorldDx - CursorPoint.X + prevPoint.X;
       WorldDy:= WorldDy - CursorPoint.Y + prevPoint.Y;
-      CursorPoint.X:= (cScreenWidth  shr 1);
-      CursorPoint.Y:= (cScreenHeight shr 1);
+      CursorPoint.X:= 0;
+      CursorPoint.Y:= cScreenHeight div 2;
       end;
 
-if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
+if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, CursorPoint.Y);
 prevPoint:= CursorPoint;
 if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater;
 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;