- AmmoMenu
authorunc0rr
Sat, 23 Sep 2006 19:26:07 +0000
changeset 161 d8870bbf960e
parent 160 207f520b9e83
child 162 4822f6face35
- AmmoMenu - Many small fixes
QTfrontend/binds.h
hedgewars/CCHandlers.inc
hedgewars/GSHandlers.inc
hedgewars/hwengine.dpr
hedgewars/uConsole.pas
hedgewars/uConsts.pas
hedgewars/uKeys.pas
hedgewars/uLand.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Graphics/AmmoMenu/AmmoName.png
share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png
share/hedgewars/Data/Graphics/AmmoMenu/BrdrLines.png
share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt
share/hedgewars/Data/Graphics/AmmoMenu/Slot.png
share/hedgewars/Data/Graphics/AmmoMenu/SlotKeys.png
share/hedgewars/Data/Graphics/CMakeLists.txt
--- a/QTfrontend/binds.h	Fri Sep 22 18:09:26 2006 +0000
+++ b/QTfrontend/binds.h	Sat Sep 23 19:26:07 2006 +0000
@@ -37,7 +37,7 @@
 #include <QString>
 #include <QtGlobal>
 
-#define BINDS_NUMBER 24
+#define BINDS_NUMBER 25
 
 struct BindAction
 {
@@ -58,6 +58,7 @@
 	{"+attack",	"space",	QT_TRANSLATE_NOOP("binds", "attack"),	false},
 	{"put",	"mousel",	QT_TRANSLATE_NOOP("binds", "put"),	false},
 	{"switch",	"tab",	QT_TRANSLATE_NOOP("binds", "switch"),	true},
+	{"ammomenu",	"mouser",	QT_TRANSLATE_NOOP("binds", "ammo menu"),	false},
 	{"slot 1",	"f1",	QT_TRANSLATE_NOOP("binds", "slot 1"),	false},
 	{"slot 2",	"f2",	QT_TRANSLATE_NOOP("binds", "slot 2"),	false},
 	{"slot 3",	"f3",	QT_TRANSLATE_NOOP("binds", "slot 3"),	false},
--- a/hedgewars/CCHandlers.inc	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/CCHandlers.inc	Sat Sep 23 19:26:07 2006 +0000
@@ -369,3 +369,16 @@
    end
 end;
 
+procedure chAmmoMenu(var s: shortstring);
+begin
+if CheckNoTeamOrHH then exit;
+with CurrentTeam^ do
+     with Hedgehogs[CurrHedgehog] do
+          begin
+          if bShowAmmoMenu then bShowAmmoMenu:= false
+          else if ((Gear.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
+               or ((Gear.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true
+          end
+end;
+
+
--- a/hedgewars/GSHandlers.inc	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Sat Sep 23 19:26:07 2006 +0000
@@ -363,14 +363,14 @@
     HHGear: PGear;
 begin
 AllInactive:= false;
+HHGear:= PHedgehog(Gear.Hedgehog).Gear;
 dec(Gear.Timer);
-if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0) then
+if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0)or((HHGear.State and gstHHDriven) = 0) then
    begin
    DeleteGear(Gear);
    AfterAttack;
    exit
    end;
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
 if (Gear.Timer and $3F) = 0 then
    begin
    i:= round(Gear.X) - Gear.Radius  - GetRandom(2);
--- a/hedgewars/hwengine.dpr	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/hwengine.dpr	Sat Sep 23 19:26:07 2006 +0000
@@ -95,7 +95,6 @@
               GameState:= gsGame
               end;
      gsGame : begin
-              ProcessKbd;
               DoGameTick(Lag);
               DrawWorld(Lag, SDLPrimSurface);
               end;
--- a/hedgewars/uConsole.pas	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/uConsole.pas	Sat Sep 23 19:26:07 2006 +0000
@@ -288,6 +288,7 @@
 RegisterVariable('add'     , vtCommand, @chAdd          );
 RegisterVariable('skip'    , vtCommand, @chSkip         );
 RegisterVariable('say'     , vtCommand, @chSay          );
+RegisterVariable('ammomenu', vtCommand, @chAmmoMenu     );
 RegisterVariable('+left'   , vtCommand, @chLeft_p       );
 RegisterVariable('-left'   , vtCommand, @chLeft_m       );
 RegisterVariable('+right'  , vtCommand, @chRight_p      );
--- a/hedgewars/uConsts.pas	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/uConsts.pas	Sat Sep 23 19:26:07 2006 +0000
@@ -41,13 +41,14 @@
      TGameType  = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview);
      TPathType  = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps,
                    ptMapCurrent, ptDemos, ptSounds, ptGraves, ptFonts, ptForts,
-                   ptLocale);
+                   ptLocale, ptAmmoMenu);
      TSprite    = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame,
                    sprLag, sprArrow, sprGrenade, sprTargetP, sprUFO,
                    sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff,
                    sprMineOn, sprCase, sprFAid, sprDynamite, sprPower,
                    sprClusterBomb, sprClusterParticle, sprFlame, sprHorizont,
-                   sprSky);
+                   sprSky, sprAMBorders, sprAMSlot, sprAMSlotName, sprAMAmmos,
+                   sprAMSlotKeys);
      TGearType  = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
                    gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite,
@@ -194,7 +195,8 @@
                                                'Data/Graphics/Graves',          // ptGraves
                                                'Data/Fonts',                    // ptFonts
                                                'Data/Forts',                    // ptForts
-                                               'Data/Locale'                    // ptLocale
+                                               'Data/Locale',                   // ptLocale
+                                               'Data/Graphics/AmmoMenu'          // ptAmmoMenu
                                                );
 
       StuffLoadData: array[TStuff] of record
@@ -249,7 +251,12 @@
                      (FileName:'ClParticle'; Path: ptGraphics; Width:  16; Height: 16; hasAlpha: false),// sprClusterParticle
                      (FileName:     'Flame'; Path: ptGraphics; Width:  16; Height: 16; hasAlpha: false),// sprFlame
                      (FileName:  'horizont'; Path: ptCurrTheme;Width:   0; Height:  0; hasAlpha: false),// sprHorizont
-                     (FileName:       'Sky'; Path: ptCurrTheme;Width:   0; Height:  0; hasAlpha: false) // sprSky
+                     (FileName:       'Sky'; Path: ptCurrTheme;Width:   0; Height:  0; hasAlpha: false),// sprSky
+                     (FileName: 'BrdrLines'; Path: ptAmmoMenu; Width: 202; Height:  1; hasAlpha: false),// sprAMBorders
+                     (FileName:      'Slot'; Path: ptAmmoMenu; Width: 202; Height: 33; hasAlpha: false),// sprAMSlot
+                     (FileName:  'AmmoName'; Path: ptAmmoMenu; Width: 202; Height: 33; hasAlpha: false),// sprAMSlotName
+                     (FileName:     'Ammos'; Path: ptAmmoMenu; Width:  32; Height: 32; hasAlpha: false),// sprAMAmmos
+                     (FileName:  'SlotKeys'; Path: ptAmmoMenu; Width:  32; Height: 32; hasAlpha: false) // sprAMSlotKeys
                      );
       Soundz: array[TSound] of record
                                        FileName: String[31];
--- a/hedgewars/uKeys.pas	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/uKeys.pas	Sat Sep 23 19:26:07 2006 +0000
@@ -41,6 +41,8 @@
 procedure ProcessKbdDemo;
 procedure InitKbdKeyTable;
 
+var KbdKeyPressed: boolean;
+
 implementation
 uses SDLh, uTeams, uConsole, uConsts, uMisc;
 const KeyNumber = 1024;
@@ -51,7 +53,7 @@
 function KeyNameToCode(name: string): word;
 begin
 Result:= cKeyMaxIndex;
-while (Result>0)and(KeyNames[Result]<>name) do dec(Result)
+while (Result > 0) and (KeyNames[Result] <> name) do dec(Result)
 end;
 
 procedure ProcessKbd;
@@ -63,15 +65,18 @@
    or (GameState = gsConsole)
    or (CurrentTeam.ExtDriven)
    or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].BotLevel <> 0) then exit;
+
+KbdKeyPressed:= false;
 pkbd:= SDL_GetKeyState(nil);
 i:= SDL_GetMouseState(nil, nil);
 pkbd^[1]:= (i and 1);
-pkbd^[2]:= ((i shl 1) and 1);
-pkbd^[3]:= ((i shl 2) and 1);
+pkbd^[2]:= ((i shr 1) and 1);
+pkbd^[3]:= ((i shr 2) and 1);
 for i:= 1 to cKeyMaxIndex do
-    if CurrentTeam.Aliases[i][0]<>#0 then
-       begin
-       if CurrentTeam.Aliases[i][1]='+' then
+    if CurrentTeam.Aliases[i][0] <> #0 then
+      begin
+      if (i > 3) and (pkbd^[i] <> 0) then KbdKeyPressed:= true;
+      if CurrentTeam.Aliases[i][1] = '+' then
           begin
           if (pkbd^[i] <> 0)and(tkbd[i]  = 0) then ParseCommand(CurrentTeam.Aliases[i]) else
           if (pkbd^[i] =  0)and(tkbd[i] <> 0) then
--- a/hedgewars/uLand.pas	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/uLand.pas	Sat Sep 23 19:26:07 2006 +0000
@@ -470,12 +470,17 @@
      end;
 end;
 
+function SelectTemplate: integer;
+begin
+Result:= getrandom(Succ(High(EdgeTemplates)))
+end;
+
 procedure GenLandSurface;
 var tmpsurf: PSDL_Surface;
 begin
 WriteLnToConsole('Generating land...');
 
-GenBlank(EdgeTemplates[getrandom(Succ(High(EdgeTemplates)))]);
+GenBlank(EdgeTemplates[SelectTemplate]);
 
 AddProgress;
 with PixelFormat^ do
@@ -573,7 +578,7 @@
 var x, y, xx, yy, t, bit: integer;
 begin
 WriteLnToConsole('Generating preview...');
-GenBlank(EdgeTemplates[getrandom(Succ(High(EdgeTemplates)))]);
+GenBlank(EdgeTemplates[SelectTemplate]);
 
 for y:= 0 to 127 do
     for x:= 0 to 31 do
--- a/hedgewars/uStore.pas	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/uStore.pas	Sat Sep 23 19:26:07 2006 +0000
@@ -41,7 +41,7 @@
 procedure StoreRelease;
 procedure DrawGear(Stuff : TStuff; X, Y: integer; Surface: PSDL_Surface);
 procedure DrawSpriteFromRect(r: TSDL_Rect; X, Y, Height, Position: integer; Surface: PSDL_Surface);
-procedure DrawSprite (Sprite: TSprite; X, Y, Position: integer; Surface: PSDL_Surface);
+procedure DrawSprite (Sprite: TSprite; X, Y, Frame: integer; Surface: PSDL_Surface);
 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: integer; Surface: PSDL_Surface);
 procedure DrawLand (X, Y: integer; Surface: PSDL_Surface);
 procedure DXOutText(X, Y: Integer; Font: THWFont; s: string; Surface: PSDL_Surface);
@@ -364,12 +364,12 @@
 DrawFromRect(X, Y, @r, StoreSurface, Surface)
 end;
 
-procedure DrawSprite(Sprite: TSprite; X, Y, Position: integer; Surface: PSDL_Surface);
+procedure DrawSprite (Sprite: TSprite; X, Y, Frame: integer; Surface: PSDL_Surface);
 var r: TSDL_Rect;
 begin
 r.x:= 0;
 r.w:= SpritesData[Sprite].Width;
-r.y:= Position * SpritesData[Sprite].Height;
+r.y:= Frame * SpritesData[Sprite].Height;
 r.h:= SpritesData[Sprite].Height;
 DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
 end;
--- a/hedgewars/uWorld.pas	Fri Sep 22 18:09:26 2006 +0000
+++ b/hedgewars/uWorld.pas	Sat Sep 23 19:26:07 2006 +0000
@@ -48,15 +48,16 @@
 {$ENDIF}
 var FollowGear: PGear = nil;
     WindBarWidth: integer = 0;
+    bShowAmmoMenu: boolean = false;
 
 implementation
-uses uStore, uMisc, uTeams, uIO, uConsole;
+uses uStore, uMisc, uTeams, uIO, uConsole, uKeys;
 const RealTicks: Longword = 0;
       Frames: Longword = 0;
       FPS: Longword = 0;
       CountTicks: Longword = 0;
       prevPoint: TPoint = (X: 0; Y: 0);
-      
+
 type TCaptionStr = record
                    Surf: PSDL_Surface;
                    StorePos: Longword;
@@ -66,6 +67,7 @@
 
 var cWaterSprCount: integer;
     Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr;
+    AMxLeft, AMxCurr: integer;
 
 procedure InitWorld;
 begin
@@ -75,7 +77,47 @@
 prevPoint.X:= cScreenWidth div 2;
 prevPoint.Y:= cScreenHeight div 2;
 WorldDx:=  - 1024 + cScreenWidth div 2;
-WorldDy:=  - 512 + cScreenHeight div 2
+WorldDy:=  - 512 + cScreenHeight div 2;
+AMxLeft:= cScreenWidth - 210;
+AMxCurr:= cScreenWidth
+end;
+
+procedure ShowAmmoMenu(Surface: PSDL_Surface);
+const MENUSPEED = 15;
+var x, y, i, t: integer;
+begin
+if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false;
+if      bShowAmmoMenu  and (AMxCurr > AMxLeft)      then dec(AMxCurr, MENUSPEED);
+if (not bShowAmmoMenu) and (AMxCurr < cScreenWidth) then inc(AMxCurr, MENUSPEED);
+
+if CurrentTeam = nil then exit;
+with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+     begin
+     if Ammo = nil then exit;
+     x:= AMxCurr;
+     y:= cScreenHeight - 40;
+     dec(y);
+     DrawSprite(sprAMBorders, x, y, 0, Surface);
+     dec(y);
+     DrawSprite(sprAMBorders, x, y, 1, Surface);
+     dec(y, 33);
+     DrawSprite(sprAMSlotName, x, y, 0, Surface);
+     for i:= cMaxSlotIndex downto 0 do
+         if Ammo[i, 0].Count > 0 then
+            begin
+            dec(y, 33);
+            DrawSprite(sprAMSlot, x, y, 0, Surface);
+            DrawSprite(sprAMSlotKeys, x + 2, y + 1, i, Surface);
+            t:= 0;
+            while (t <= cMaxSlotAmmoIndex) and (Ammo[i, t].Count > 0) do
+                  begin
+                  DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, integer(Ammo[i, t].AmmoType), Surface);
+                  inc(t)
+                  end
+            end;
+     dec(y, 1);
+     DrawSprite(sprAMBorders, x, y, 0, Surface)
+     end
 end;
 
 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
@@ -285,6 +327,9 @@
    DrawSpriteFromRect(r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
    end;
 
+// AmmoMenu
+if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface);
+
 // Cursor
 if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface);
 
Binary file share/hedgewars/Data/Graphics/AmmoMenu/AmmoName.png has changed
Binary file share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png has changed
Binary file share/hedgewars/Data/Graphics/AmmoMenu/BrdrLines.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt	Sat Sep 23 19:26:07 2006 +0000
@@ -0,0 +1,5 @@
+install(FILES
+	AmmoName.png
+	BrdrLines.png
+	Slot.png
+	DESTINATION ${SHAREPATH}Data/Graphics/AmmoMenu)
\ No newline at end of file
Binary file share/hedgewars/Data/Graphics/AmmoMenu/Slot.png has changed
Binary file share/hedgewars/Data/Graphics/AmmoMenu/SlotKeys.png has changed
--- a/share/hedgewars/Data/Graphics/CMakeLists.txt	Fri Sep 22 18:09:26 2006 +0000
+++ b/share/hedgewars/Data/Graphics/CMakeLists.txt	Sat Sep 23 19:26:07 2006 +0000
@@ -1,4 +1,5 @@
 add_subdirectory(Graves)
+add_subdirectory(AmmoMenu)
 install(FILES
 	Arrow.png
 	BigDigits.png