# HG changeset patch # User Xeli # Date 1328552182 -3600 # Node ID b4a3310f29742ac617aebf752fd25ad766469275 # Parent c2fa29fe2a58ba399ee3bf593a8be57f04358779 show buttons on the screen, similar to the iOS overlay diff -r c2fa29fe2a58 -r b4a3310f2974 hedgewars/uTypes.pas --- a/hedgewars/uTypes.pas Mon Feb 06 23:17:45 2012 +0400 +++ b/hedgewars/uTypes.pas Mon Feb 06 19:16:22 2012 +0100 @@ -58,6 +58,9 @@ sprFinger, sprAirBomb, sprAirplane, sprAmAirplane, sprAmGirder, sprHHTelepMask, sprSwitch, sprParachute, sprTarget, sprRopeNode, sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR, +{$IFDEF ANDROID} + sprFireButton, sprArrowUp, sprArrowDown, sprArrowLeft, sprArrowRight, sprBackjump, sprForwardjump, +{$ENDIF} sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun, sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer, sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath, @@ -83,7 +86,7 @@ sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb, sprBulletHit, sprSnowball, sprHandSnowball, sprSnow, sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis, - sprFireButton, sprSlider + sprSlider ); // Gears that interact with other Gears and/or Land diff -r c2fa29fe2a58 -r b4a3310f2974 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Mon Feb 06 23:17:45 2012 +0400 +++ b/hedgewars/uVariables.pas Mon Feb 06 19:16:22 2012 +0100 @@ -192,6 +192,20 @@ LuaGoals : shortstring; +///////////////////////////////////// +//Buttons +{$IFDEF MOBILE} + buttonScale: GLFloat; + + arrowUpX, arrowUpY, arrowUpW, arrowUpH: LongInt; + arrowDownX, arrowDownY, arrowDownW, arrowDownH: LongInt; + arrowLeftX, arrowLeftY, arrowLeftW, arrowLeftH: LongInt; + arrowRightX, arrowRightY, arrowRightW, arrowRightH: LongInt; + + firebuttonX, fireButtonY, fireButtonW, fireButtonH: LongInt; + backjumpX, backjumpY, backjumpW, backjumpH: LongInt; + forwardjumpX, forwardjumpY, forwardjumpW, forwardjumpH: LongInt; +{$ENDIF} const cHHFileName = 'Hedgehog'; cCHFileName = 'Crosshair'; @@ -380,6 +394,22 @@ Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprWindL (FileName: 'WindR'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprWindR +{$IFDEF ANDROID} + (FileName: 'firebutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprFireButton + (FileName: 'arrowUp'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowUp + (FileName: 'arrowDown'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowDown + (FileName: 'arrowLeft'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowLeft + (FileName: 'arrowRight'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowRight + (FileName: 'backjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprBackjump + (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprForwardJump +{$ENDIF} (FileName: 'Flake'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil; Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprFlake (FileName: 'amRope'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; @@ -631,8 +661,6 @@ Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprSDDroplet (FileName: 'TARDIS'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 48; Height: 79; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprTardis - (FileName: 'firebutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 450; Height: 150; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprFireButton (FileName: 'slider'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 5; Height: 17; imageWidth: 5; imageHeight: 15; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false) // sprSlider ); diff -r c2fa29fe2a58 -r b4a3310f2974 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Mon Feb 06 23:17:45 2012 +0400 +++ b/hedgewars/uWorld.pas Mon Feb 06 19:16:22 2012 +0100 @@ -198,6 +198,46 @@ SkyOffset:= 0; HorizontOffset:= 0; +{$IFDEF ANDROID} +//positioning of the buttons +buttonScale:= 1.5/cDefaultZoomLevel; +firebuttonX:= (cScreenWidth shr 1) - Round(spritesData[sprFireButton].Texture^.h * buttonScale); +firebuttonY:= -Round(spritesData[sprFireButton].Texture^.h* buttonScale) + cScreenHeight; +firebuttonW:= Round(spritesData[sprFireButton].Texture^.w * buttonScale); +firebuttonH:= Round(spritesData[sprFireButton].Texture^.h * buttonScale); + +backjumpX:= (cScreenWidth shr 1) - Round(spritesData[sprbackjump].Texture^.h * 2 * buttonScale); +backjumpY:= -Round(spritesData[sprbackjump].Texture^.h * 1.2 * buttonScale) + cScreenHeight; +backjumpW:= Round(spritesData[sprbackjump].Texture^.w * buttonScale); +backjumpH:= Round(spritesData[sprbackjump].Texture^.h * buttonScale); + +forwardjumpX:= (cScreenWidth shr 1) - Round(spritesData[sprforwardjump].Texture^.h * 1.2 * buttonScale); +forwardjumpY:= -Round(spritesData[sprforwardjump].Texture^.h * 2 * buttonScale) + cScreenHeight; +forwardjumpW:= Round(spritesData[sprforwardjump].Texture^.w * buttonScale); +forwardjumpH:= Round(spritesData[sprforwardjump].Texture^.h * buttonScale); + +arrowLeftX:= -(cScreenWidth shr 1); +arrowLeftY:= -Round(spritesData[sprArrowLeft].Texture^.h*buttonScale) + cScreenHeight - Round(spritesData[sprArrowLeft].Texture^.h*buttonScale); +arrowLeftW:= Round(spritesData[sprArrowLeft].Texture^.h * buttonScale); +arrowLeftH:= Round(spritesData[sprArrowLeft].Texture^.h * buttonScale); + +arrowRightX:= -(cScreenWidth shr 1)+ Round(spritesData[sprArrowUp].Texture^.h * buttonScale *2); +arrowRightY:= -Round(spritesData[sprArrowRight].Texture^.h*buttonScale) + cScreenHeight - Round(spritesData[sprArrowRight].Texture^.h*buttonScale); +arrowLeftW:= Round(spritesData[sprArrowRight].Texture^.w * buttonScale); +arrowLeftH:= Round(spritesData[sprArrowRight].Texture^.h * buttonScale); + +arrowUpX:= -(cScreenWidth shr 1) + Round(spritesData[sprArrowUp].Texture^.h * buttonScale); +arrowUpY:= -Round(spritesData[sprArrowUp].Texture^.h*buttonScale) + cScreenHeight - Round(spritesData[sprArrowUp].Texture^.h*buttonScale*2); +arrowUpW:= Round(spritesData[sprArrowUp].Texture^.w * buttonScale); +arrowUpH:= Round(spritesData[sprArrowUp].Texture^.h * buttonScale); + +arrowDownX:= -(cScreenWidth shr 1) + Round(spritesData[sprArrowUp].Texture^.h * buttonScale); +arrowDownY:= -Round(spritesData[sprArrowDown].Texture^.h*buttonscale) + cScreenHeight; +arrowDownW:= Round(spritesData[sprArrowDown].Texture^.w * buttonScale); +arrowDownH:= Round(spritesData[sprArrowDown].Texture^.h * buttonScale); + + +{$ENDIF} end; procedure InitCameraBorders; @@ -887,6 +927,7 @@ highlight: Boolean; smallScreenOffset, offsetX, offsetY, screenBottom: LongInt; VertexBuffer: array [0..3] of TVertex2f; + scale: GLFloat; begin if (cReducedQuality and rqNoBackground) = 0 then begin @@ -1053,7 +1094,14 @@ {$IFDEF ANDROID} // Draw buttons Related to the Touch interface -DrawTexture(Round(-cScreenWidth*0.5 + cScreenHeight*0.02),Round((cScreenHeight*0.98)-(spritesData[sprFireButton].Height*0.4) ),spritesData[sprFireButton].Texture, 0.4); +DrawTexture(arrowLeftX, arrowLeftY,spritesData[sprArrowLeft].Texture, buttonScale); +DrawTexture(arrowRightX, arrowRightY,spritesData[sprArrowRight].Texture, buttonScale); +DrawTexture(arrowUpX, arrowUpY,spritesData[sprArrowUp].Texture, buttonScale); +DrawTexture(arrowDownX, arrowDownY,spritesData[sprArrowDown].Texture, buttonScale); + +DrawTexture(fireButtonX, firebuttonY, spritesData[sprFireButton].Texture, buttonScale); +DrawTexture(backjumpX, backjumpY, spritesData[sprBackjump].Texture, buttonScale); +DrawTexture(forwardjumpX, forwardjumpY, spritesData[sprForwardjump].Texture, buttonScale); {$ENDIF} // Teams Healths