--- a/hedgewars/uScript.pas Sun Jan 30 20:04:34 2011 +0100
+++ b/hedgewars/uScript.pas Sun Jan 30 17:54:02 2011 -0500
@@ -58,7 +58,10 @@
uUtils,
uCaptions,
uDebug,
- uCollisions;
+ uCollisions,
+ uRenderUtils,
+ uTextures,
+ SDLh;
var luaState : Plua_State;
ScriptAmmoLoadout : shortstring;
@@ -549,11 +552,52 @@
end;
function lc_setclancolor(L : Plua_State) : LongInt; Cdecl;
-var gear : PGear;
+var clan : PClan;
+ team : PTeam;
+ hh : THedgehog;
+ i, j : LongInt;
+ r, rr: TSDL_Rect;
+ texsurf: PSDL_Surface;
begin
if lua_gettop(L) <> 2 then
LuaError('Lua: Wrong number of parameters passed to SetClanColor!')
- else ClansArray[lua_tointeger(L, 1)]^.Color:= lua_tointeger(L, 2) shr 8;
+ else
+ begin
+ clan := ClansArray[lua_tointeger(L, 1)];
+ clan^.Color:= lua_tointeger(L, 2) shr 8;
+ for i:= 0 to Pred(clan^.TeamsNumber) do
+ begin
+ team:= clan^.Teams[i];
+ for j:= 0 to 7 do
+ begin
+ hh:= team^.Hedgehogs[i];
+ if (hh.Gear <> nil) and (hh.GearHidden <> nil) then
+ begin
+ FreeTexture(hh.NameTagTex);
+ hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16);
+ RenderHealth(hh);
+ end;
+ end;
+ FreeTexture(team^.NameTagTex);
+ team^.NameTagTex:= RenderStringTex(clan^.Teams[i]^.TeamName, clan^.Color, fnt16);
+ r.w:= cTeamHealthWidth + 5;
+ r.h:= team^.NameTagTex^.h;
+
+ texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask);
+ TryDo(texsurf <> nil, errmsgCreateSurface, true);
+ TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+
+ DrawRoundRect(@r, cWhiteColor, cNearBlackColorChannels.value, texsurf, true);
+ rr:= r;
+ inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
+ DrawRoundRect(@rr, clan^.Color, clan^.Color, texsurf, false);
+
+ FreeTexture(team^.HealthTex);
+ team^.HealthTex:= Surface2Tex(texsurf, false);
+ SDL_FreeSurface(texsurf);
+ MakeCrossHairs
+ end
+ end;
lc_setclancolor:= 0
end;