# HG changeset patch # User Xeli # Date 1313602772 -7200 # Node ID 480d451152a5e7b9aca2c496f32b34ea41b6cd6b # Parent bc37bad14800b97cb2be1d569cc07d1c699b2ac1 open ammo when clicking the current hog diff -r bc37bad14800 -r 480d451152a5 hedgewars/uTouch.pas --- a/hedgewars/uTouch.pas Wed Aug 17 18:09:25 2011 +0200 +++ b/hedgewars/uTouch.pas Wed Aug 17 19:39:32 2011 +0200 @@ -16,6 +16,7 @@ procedure deleteFinger(id: SDL_FingerId); procedure onTouchClick(x,y: Longword; pointerId: SDL_FingerId); +function isOnCurrentHog(id: SDL_FingerId): boolean; function fingerHasMoved(id: SDL_FingerId): boolean; function calculateDelta(id1, id2: SDL_FingerId): hwFloat; function getSecondPointer(id: SDL_FingerId): SDL_FingerId; @@ -102,9 +103,11 @@ exit end; - + if isOnCurrentHog(pointerId) then + begin bShowAmmoMenu := true; invertCursor := false; + end; //WriteToConsole(Format('%s, %s : %d, %d', [cstr(CurrentHedgehog^.Gear^.X), cstr(CurrentHedgehog^.Gear^.Y), x-WorldDX, y-WorldDY])); end; @@ -166,6 +169,15 @@ if ((SDL_GetTicks - timeSinceDown[id]) < clickTime) AND not(fingerHasMoved(id)) then onTouchClick(xyCoord[id*2], xyCoord[id*2+1], id); end; +function isOnCurrentHog(id: SDL_FingerId): boolean; +var + x,y : hwFloat; +begin + x := CurrentHedgehog^.Gear^.X; + y := CurrentHedgehog^.Gear^.Y; + isOnCurrentHog := Distance(int2hwFloat((xyCoord[id*2] - WorldDX) - (cScreenWidth div 2))-x, int2hwFloat(xyCoord[id*2+1] - WorldDy)-y) < int2hwFloat(20); +end; + //Method to calculate the distance this finger has moved since the downEvent function fingerHasMoved(id: SDL_FingerId): boolean; begin