# HG changeset patch # User unc0rr # Date 1217187444 0 # Node ID eb5a9f86f9c625567f1d7f7c8afcd9e84522c571 # Parent be9700b424b2ff8607e5a995f95d5d9d8e29c913 Add ability to resize engine's window diff -r be9700b424b2 -r eb5a9f86f9c6 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Sun Jul 27 19:21:30 2008 +0000 +++ b/hedgewars/CCHandlers.inc Sun Jul 27 19:37:24 2008 +0000 @@ -455,7 +455,7 @@ {$ENDIF} SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); -flags:= SDL_OPENGL; +flags:= SDL_OPENGL or SDL_RESIZABLE; if cFullScreen then flags:= flags or SDL_FULLSCREEN else SDL_WM_SetCaption('Hedgewars', nil); {$IFDEF DEBUGFILE} diff -r be9700b424b2 -r eb5a9f86f9c6 hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Sun Jul 27 19:21:30 2008 +0000 +++ b/hedgewars/GSHandlers.inc Sun Jul 27 19:37:24 2008 +0000 @@ -964,7 +964,7 @@ end until b; -t:= cScreenHeight - 4; +t:= - 4; for i:= 0 to Pred(TeamsCount) do with thexchar[i] do begin diff -r be9700b424b2 -r eb5a9f86f9c6 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Sun Jul 27 19:21:30 2008 +0000 +++ b/hedgewars/SDLh.pas Sun Jul 27 19:37:24 2008 +0000 @@ -57,6 +57,7 @@ SDL_KEYDOWN = 2; SDL_KEYUP = 3; SDL_QUITEV = 12; + SDL_VIDEORESIZE = 16; SDL_APPINPUTFOCUS = 2; @@ -65,6 +66,7 @@ SDL_GL_DOUBLEBUFFER = 5; SDL_OPENGL = 2; + SDL_RESIZABLE = $00000010; RMask = $FF; GMask = $FF00; @@ -167,9 +169,9 @@ TSDL_ActiveEvent = record type_: byte; - gain: byte; - state: byte; - end; + gain: byte; + state: byte; + end; TSDL_KeyboardEvent = record type_: Byte; @@ -181,6 +183,11 @@ TSDL_QuitEvent = record type_: Byte; end; + TSDL_ResizeEvent = record + type_: Byte; + w, h: LongInt; + end; + PSDL_Event = ^TSDL_Event; TSDL_Event = record case Byte of @@ -188,6 +195,7 @@ SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent); SDL_QUITEV: (quit: TSDL_QuitEvent); + SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); end; PByteArray = ^TByteArray; diff -r be9700b424b2 -r eb5a9f86f9c6 hedgewars/hwengine.dpr --- a/hedgewars/hwengine.dpr Sun Jul 27 19:21:30 2008 +0000 +++ b/hedgewars/hwengine.dpr Sun Jul 27 19:37:24 2008 +0000 @@ -132,6 +132,17 @@ halt end; +//////////////////////////////// +procedure Resize(w, h: LongInt); +begin +cScreenWidth:= w; +cScreenHeight:= h; +if cFullScreen then + ParseCommand('/fullscr 1', true) +else + ParseCommand('/fullscr 0', true); +end; + /////////////////// procedure MainLoop; var PrevTime, @@ -141,12 +152,13 @@ PrevTime:= SDL_GetTicks; repeat while SDL_PollEvent(@event) <> 0 do - case event.type_ of - SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode); - SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then - cHasFocus:= event.active.gain = 1; - SDL_QUITEV: isTerminated:= true - end; + case event.type_ of + SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode); + SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then + cHasFocus:= event.active.gain = 1; + SDL_VIDEORESIZE: Resize(max(event.resize.w, 320), max(event.resize.h, 240)); + SDL_QUITEV: isTerminated:= true + end; CurrTime:= SDL_GetTicks; if PrevTime + cTimerInterval <= CurrTime then begin diff -r be9700b424b2 -r eb5a9f86f9c6 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Sun Jul 27 19:21:30 2008 +0000 +++ b/hedgewars/uStore.pas Sun Jul 27 19:37:24 2008 +0000 @@ -128,7 +128,7 @@ begin r.x:= 0; r.y:= 0; - drY:= cScreenHeight - 4; + drY:= - 4; for t:= 0 to Pred(TeamsCount) do with TeamsArray[t]^ do begin diff -r be9700b424b2 -r eb5a9f86f9c6 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sun Jul 27 19:21:30 2008 +0000 +++ b/hedgewars/uWorld.pas Sun Jul 27 19:37:24 2008 +0000 @@ -52,7 +52,7 @@ var cWaterSprCount: LongInt; Captions: array[TCapGroup] of TCaptionStr; - AMxLeft, AMxCurr, SlotsNum: LongInt; + AMxShift, SlotsNum: LongInt; tmpSurface: PSDL_Surface; fpsTexture: PTexture = nil; @@ -65,8 +65,7 @@ prevPoint.Y:= cScreenHeight div 2; WorldDx:= - 1024 + cScreenWidth div 2; WorldDy:= - 512 + cScreenHeight div 2; -AMxLeft:= cScreenWidth - 210; -AMxCurr:= cScreenWidth +AMxShift:= 210 end; procedure ShowAmmoMenu; @@ -77,18 +76,18 @@ if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false; if bShowAmmoMenu then begin - if AMxCurr = cScreenWidth then prevPoint.X:= 0; - if AMxCurr > AMxLeft then dec(AMxCurr, MENUSPEED); + if AMxShift = 210 then prevPoint.X:= 0; + if AMxShift > 0 then dec(AMxShift, MENUSPEED); end else begin - if AMxCurr = AMxLeft then + if AMxShift = 0 then begin CursorPoint.X:= cScreenWidth div 2; CursorPoint.Y:= cScreenHeight div 2; prevPoint:= CursorPoint; SDL_WarpMouse(CursorPoint.X, CursorPoint.Y) end; - if AMxCurr < cScreenWidth then inc(AMxCurr, MENUSPEED); + if AMxShift < 210 then inc(AMxShift, MENUSPEED); end; if CurrentTeam = nil then exit; @@ -98,7 +97,7 @@ begin if Ammo = nil then exit; SlotsNum:= 0; - x:= AMxCurr; + x:= cScreenWidth - 210 + AMxShift; y:= cScreenHeight - 40; dec(y); DrawSprite(sprAMBorders, x, y, 0); @@ -137,9 +136,9 @@ if (Pos >= 0) then if Ammo^[Slot, Pos].Count > 0 then begin - DrawTexture(AMxCurr + 10, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); + DrawTexture(cScreenWidth - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); if Ammo^[Slot, Pos].Count < AMMO_INFINITE then - DrawTexture(AMxCurr + 175, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]); + DrawTexture(cScreenWidth + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]); if bSelected then begin bShowAmmoMenu:= false; @@ -151,7 +150,7 @@ end; bSelected:= false; -if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8) +if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8) end; procedure MoveCamera; forward; @@ -292,7 +291,7 @@ for t:= 0 to Pred(TeamsCount) do with TeamsArray[t]^ do begin - DrawTexture(cScreenWidth div 2 - NameTagTex^.w - 3, DrawHealthY, NameTagTex); + DrawTexture(cScreenWidth div 2 - NameTagTex^.w - 3, cScreenHeight + DrawHealthY, NameTagTex); r.x:= 0; r.y:= 0; @@ -300,14 +299,14 @@ r.h:= HealthTex^.h; DrawFromRect(cScreenWidth div 2, - DrawHealthY, + cScreenHeight + DrawHealthY, @r, HealthTex); inc(r.x, cTeamHealthWidth + 2); r.w:= 3; DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2, - DrawHealthY, + cScreenHeight + DrawHealthY, @r, HealthTex); end; @@ -338,7 +337,7 @@ end; // AmmoMenu -if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu; +if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu; DrawChat; @@ -426,10 +425,10 @@ if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit; -if AMxCurr < cScreenWidth then +if AMxShift < 210 then begin - if CursorPoint.X < AMxCurr + 35 then CursorPoint.X:= AMxCurr + 35; - if CursorPoint.X > AMxCurr + 200 then CursorPoint.X:= AMxCurr + 200; + if CursorPoint.X < cScreenWidth + AMxShift - 175 then CursorPoint.X:= cScreenWidth + AMxShift - 175; + if CursorPoint.X > cScreenWidth + AMxShift - 10 then CursorPoint.X:= cScreenWidth + AMxShift - 10; if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33; if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76; prevPoint:= CursorPoint;