cursor x/y when targeting for mikade's visual effects. this is not synced
authornemo
Wed, 03 Jun 2015 07:30:12 -0400
changeset 10978 54a49174dbec
parent 10976 56f07b52213a
child 10979 a332a60df7ce
cursor x/y when targeting for mikade's visual effects. this is not synced
hedgewars/uScript.pas
hedgewars/uWorld.pas
--- a/hedgewars/uScript.pas	Tue Jun 02 18:37:40 2015 +0100
+++ b/hedgewars/uScript.pas	Wed Jun 03 07:30:12 2015 -0400
@@ -87,7 +87,8 @@
     uIO,
     uVisualGearsList,
     uGearsHandlersMess,
-    uPhysFSLayer
+    uPhysFSLayer,
+    SDLh
 {$IFNDEF PAS2C}
     , typinfo
 {$ENDIF}
@@ -101,6 +102,7 @@
     ScriptLoaded : boolean;
     mapDims : boolean;
     PointsBuffer: shortstring;
+    prevCursorPoint: TPoint;  // why is tpoint still in sdlh...
 
 procedure ScriptPrepareAmmoStore; forward;
 procedure ScriptApplyAmmoStore; forward;
@@ -2615,6 +2617,8 @@
     exit;
 
 // push game variables so they may be modified by the script
+ScriptSetInteger('CursorX', CursorPoint.X);
+ScriptSetInteger('CursorY', CursorPoint.Y);
 ScriptSetInteger('BorderColor', ExplosionBorderColor);
 ScriptSetInteger('GameFlags', GameFlags);
 ScriptSetString('Seed', cSeed);
@@ -2773,6 +2777,23 @@
 ScriptSetInteger('GameTime', GameTicks);
 ScriptSetInteger('TotalRounds', TotalRounds);
 ScriptSetInteger('WaterLine', cWaterLine);
+if isCursorVisible and (not bShowAmmoMenu) then
+    if (prevCursorPoint.X <> CursorPoint.X) or 
+       (prevCursorPoint.Y <> CursorPoint.Y) then
+        begin
+        ScriptSetInteger('CursorX', CursorPoint.X - WorldDx);
+        ScriptSetInteger('CursorY', cScreenHeight - CursorPoint.Y- WorldDy);
+        prevCursorPoint.X:= CursorPoint.X;
+        prevCursorPoint.Y:= CursorPoint.Y;
+        end
+else
+    begin
+    ScriptSetInteger('CursorX', NoPointX);
+    ScriptSetInteger('CursorY', NoPointX);
+    prevCursorPoint.X:= NoPointX;
+    prevCursorPoint.Y:= NoPointX
+    end;
+
 if not mapDims then
     begin
     mapDims:= true;
@@ -3329,6 +3350,8 @@
 begin
 mapDims:= false;
 PointsBuffer:= '';
+prevCursorPoint.X:= NoPointX;
+prevCursorPoint.Y:= 0;
 end;
 
 procedure freeModule;
--- a/hedgewars/uWorld.pas	Tue Jun 02 18:37:40 2015 +0100
+++ b/hedgewars/uWorld.pas	Wed Jun 03 07:30:12 2015 -0400
@@ -1659,35 +1659,32 @@
 
 
 // Cursor
-if isCursorVisible then
+if isCursorVisible and (not bShowAmmoMenu) then
     begin
-    if (not bShowAmmoMenu) then
-        begin
-        if not CurrentTeam^.ExtDriven then TargetCursorPoint:= CursorPoint;
-        with CurrentHedgehog^ do
-            if (Gear <> nil) and ((Gear^.State and gstChooseTarget) <> 0) then
+    if not CurrentTeam^.ExtDriven then TargetCursorPoint:= CursorPoint;
+    with CurrentHedgehog^ do
+        if (Gear <> nil) and ((Gear^.State and gstChooseTarget) <> 0) then
+            begin
+        if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) or (((GameFlags and gfMoreWind) <> 0) and ((CurAmmoType = amDrillStrike) or (CurAmmoType = amAirAttack))) then
+            DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
+        i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos;
+        with Ammoz[CurAmmoType] do
+            if PosCount > 1 then
                 begin
-            if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) or (((GameFlags and gfMoreWind) <> 0) and ((CurAmmoType = amDrillStrike) or (CurAmmoType = amAirAttack))) then
-                DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
-            i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos;
-            with Ammoz[CurAmmoType] do
-                if PosCount > 1 then
+                if (CurAmmoType = amGirder) or (CurAmmoType = amTeleport) then
                     begin
-                    if (CurAmmoType = amGirder) or (CurAmmoType = amTeleport) then
-                        begin
-                    // pulsating transparency
-                        if ((GameTicks div 16) mod $80) >= $40 then
-                            Tint($FF, $FF, $FF, $C0 - (GameTicks div 16) mod $40)
-                        else
-                            Tint($FF, $FF, $FF, $80 + (GameTicks div 16) mod $40);
-                        end;
-                    DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
-                    Untint();
+                // pulsating transparency
+                    if ((GameTicks div 16) mod $80) >= $40 then
+                        Tint($FF, $FF, $FF, $C0 - (GameTicks div 16) mod $40)
+                    else
+                        Tint($FF, $FF, $FF, $80 + (GameTicks div 16) mod $40);
                     end;
+                DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
+                Untint();
                 end;
-        //DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8)
-        DrawTextureF(SpritesData[sprArrow].Texture, cDefaultZoomLevel / cScaleFactor, TargetCursorPoint.X + round(SpritesData[sprArrow].Width / cScaleFactor), cScreenHeight + round(SpritesData[sprArrow].Height / cScaleFactor) - TargetCursorPoint.Y, (RealTicks shr 6) mod 8, 1, SpritesData[sprArrow].Width, SpritesData[sprArrow].Height);
-        end
+            end;
+    //DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8)
+    DrawTextureF(SpritesData[sprArrow].Texture, cDefaultZoomLevel / cScaleFactor, TargetCursorPoint.X + round(SpritesData[sprArrow].Width / cScaleFactor), cScreenHeight + round(SpritesData[sprArrow].Height / cScaleFactor) - TargetCursorPoint.Y, (RealTicks shr 6) mod 8, 1, SpritesData[sprArrow].Width, SpritesData[sprArrow].Height);
     end;
 
 // debug stuff