Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
--- a/hedgewars/VGSHandlers.inc Wed Nov 24 20:36:46 2010 -0500
+++ b/hedgewars/VGSHandlers.inc Thu Nov 25 22:56:28 2010 -0500
@@ -627,3 +627,23 @@
else
dec(Gear^.FrameTicks, Steps);
end;
+
+////////////////////////////////////////////////////////////////////////////////
+procedure doStepCircle(Gear: PVisualGear; Steps: Longword);
+var tmp: byte;
+begin
+with Gear^ do
+ if Frame <> 0 then
+ begin
+ inc(FrameTicks, Steps);
+ if (FrameTicks mod Frame) = 0 then
+ begin
+ tmp:= Gear^.Tint and $FF;
+ if tdY >= 0 then inc(tmp)
+ else dec(tmp);
+ if tmp < round(dX) then tdY:= 1;
+ if tmp > round(dY) then tdY:= -1;
+ Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or tmp
+ end
+ end
+end;
--- a/hedgewars/uRender.pas Wed Nov 24 20:36:46 2010 -0500
+++ b/hedgewars/uRender.pas Thu Nov 25 22:56:28 2010 -0500
@@ -20,7 +20,7 @@
procedure DrawCentered(X, Top: LongInt; Source: PTexture);
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
procedure DrawFillRect(r: TSDL_Rect);
-procedure DrawCircle(X, Y, Radius: LongInt; Width: Single; r, g, b, a: Byte);
+procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
procedure Tint(r, g, b, a: Byte); inline;
procedure Tint(c: Longword); inline;
@@ -351,7 +351,7 @@
glEnable(GL_TEXTURE_2D)
end;
-procedure DrawCircle(X, Y, Radius: LongInt; Width: Single; r, g, b, a: Byte);
+procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
var
i: LongInt;
CircleVertex: array [0..359] of TVertex2f;
--- a/hedgewars/uTypes.pas Wed Nov 24 20:36:46 2010 -0500
+++ b/hedgewars/uTypes.pas Thu Nov 25 22:56:28 2010 -0500
@@ -75,8 +75,7 @@
vgtSteam, vgtAmmo, vgtSmoke, vgtSmokeWhite, vgtHealth, vgtShell,
vgtDust, vgtSplash, vgtDroplet, vgtSmokeRing, vgtBeeTrace, vgtEgg,
vgtFeather, vgtHealthTag, vgtSmokeTrace, vgtEvilTrace, vgtExplosion,
- vgtBigExplosion, vgtChunk, vgtNote, vgtLineTrail,
- vgtBulletHit);
+ vgtBigExplosion, vgtChunk, vgtNote, vgtLineTrail, vgtBulletHit, vgtCircle);
TGearsType = set of TGearType;
@@ -365,4 +364,4 @@
implementation
-end.
\ No newline at end of file
+end.
--- a/hedgewars/uVisualGears.pas Wed Nov 24 20:36:46 2010 -0500
+++ b/hedgewars/uVisualGears.pas Thu Nov 25 22:56:28 2010 -0500
@@ -25,7 +25,7 @@
procedure initModule;
procedure freeModule;
-function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0): PVisualGear;
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0; Critical: Boolean = false): PVisualGear;
procedure ProcessVisualGears(Steps: Longword);
procedure KickFlakes(Radius, X, Y: LongInt);
procedure DrawVisualGears(Layer: LongWord);
@@ -92,22 +92,24 @@
@doStepChunk,
@doStepNote,
@doStepLineTrail,
- @doStepBulletHit
+ @doStepBulletHit,
+ @doStepCircle
);
-function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0): PVisualGear;
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0; Critical: Boolean = false): PVisualGear;
var gear: PVisualGear;
t: Longword;
sp: real;
begin
if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we are scrolling now
- if Kind <> vgtCloud then
+ if (Kind <> vgtCloud) and not Critical then
begin
AddVisualGear:= nil;
exit
end;
if ((cReducedQuality and rqFancyBoom) <> 0) and
+ not Critical and
not (Kind in
[vgtTeamHealthSorter,
vgtSmallDamageTag,
@@ -466,6 +468,9 @@
vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
vgtHealthTag: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+ vgtCircle: DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer,
+ ((Gear^.Tint shr 24) and $FF), ((Gear^.Tint shr 16) and $FF), ((Gear^.Tint shr 8) and $FF), Gear^.Tint and $FF);
+// Consider adding a version of DrawCircle that does not set Tint internally, and just call it here...
end;
Gear:= Gear^.NextGear
end