hedgewars/uScript.pas
changeset 9656 18422d205080
parent 9648 3a3defce1b28
child 9670 1954f692e8c6
equal deleted inserted replaced
9655:e154ccca4dad 9656:18422d205080
   779 function lc_setclancolor(L : Plua_State) : LongInt; Cdecl;
   779 function lc_setclancolor(L : Plua_State) : LongInt; Cdecl;
   780 var clan : PClan;
   780 var clan : PClan;
   781     team : PTeam;
   781     team : PTeam;
   782     hh   : THedgehog;
   782     hh   : THedgehog;
   783     i, j : LongInt;
   783     i, j : LongInt;
   784     r, rr: TSDL_Rect;
       
   785     texsurf: PSDL_Surface;
       
   786 begin
   784 begin
   787     if lua_gettop(L) <> 2 then
   785     if lua_gettop(L) <> 2 then
   788         LuaError('Lua: Wrong number of parameters passed to SetClanColor!')
   786         LuaError('Lua: Wrong number of parameters passed to SetClanColor!')
   789     else
   787     else
   790         begin
   788         begin
   791         clan := ClansArray[lua_tointeger(L, 1)];
   789         clan := ClansArray[lua_tointeger(L, 1)];
   792         clan^.Color:= lua_tointeger(L, 2) shr 8;
   790         clan^.Color:= lua_tointeger(L, 2) shr 8;
       
   791 
   793         for i:= 0 to Pred(clan^.TeamsNumber) do
   792         for i:= 0 to Pred(clan^.TeamsNumber) do
   794             begin
   793             begin
   795             team:= clan^.Teams[i];
   794             team:= clan^.Teams[i];
   796             for j:= 0 to 7 do
   795             for j:= 0 to 7 do
   797                 begin
   796                 begin
   803                     RenderHealth(hh);
   802                     RenderHealth(hh);
   804                     end;
   803                     end;
   805                 end;
   804                 end;
   806             FreeTexture(team^.NameTagTex);
   805             FreeTexture(team^.NameTagTex);
   807             team^.NameTagTex:= RenderStringTex(clan^.Teams[i]^.TeamName, clan^.Color, fnt16);
   806             team^.NameTagTex:= RenderStringTex(clan^.Teams[i]^.TeamName, clan^.Color, fnt16);
   808             r.w:= cTeamHealthWidth + 5;
   807             end;
   809             r.h:= team^.NameTagTex^.h;
   808 
   810 
   809         clan^.HealthTex:= makeHealthBarTexture(cTeamHealthWidth + 5, clan^.Teams[0]^.NameTagTex^.h, clan^.Color);
   811             texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask);
   810         end;
   812             TryDo(texsurf <> nil, errmsgCreateSurface, true);
   811 
   813             TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
       
   814 
       
   815             DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true);
       
   816             rr:= r;
       
   817             inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
       
   818             DrawRoundRect(@rr, clan^.Color, clan^.Color, texsurf, false);
       
   819 
       
   820             FreeTexture(team^.HealthTex);
       
   821             team^.HealthTex:= Surface2Tex(texsurf, false);
       
   822             SDL_FreeSurface(texsurf);
       
   823             MakeCrossHairs
       
   824             end
       
   825         end;
       
   826     lc_setclancolor:= 0
   812     lc_setclancolor:= 0
   827 end;
   813 end;
   828 
   814 
   829 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
   815 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
   830 var gear : PGear;
   816 var gear : PGear;
  1896     lc_hedgewarsscriptload:= 0;
  1882     lc_hedgewarsscriptload:= 0;
  1897 end;
  1883 end;
  1898 
  1884 
  1899 
  1885 
  1900 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl;
  1886 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl;
  1901 var gear: PGear;
       
  1902 begin
  1887 begin
  1903     if lua_gettop(L) <> 4 then
  1888     if lua_gettop(L) <> 4 then
  1904         LuaError('Lua: Wrong number of parameters passed to DeclareAchievement!')
  1889         LuaError('Lua: Wrong number of parameters passed to DeclareAchievement!')
  1905     else
  1890     else
  1906         declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4));
  1891         declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4));