hedgewars/uStore.pas
changeset 690 e9d35e319328
parent 689 f4ec46c48ed2
child 704 9b096d05004e
equal deleted inserted replaced
689:f4ec46c48ed2 690:e9d35e319328
    28 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface);
    28 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface);
    29 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt; Surface: PSDL_Surface);
    29 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt; Surface: PSDL_Surface);
    30 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source, Surface: PSDL_Surface);
    30 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source, Surface: PSDL_Surface);
    31 procedure DrawLand (X, Y: LongInt; Surface: PSDL_Surface);
    31 procedure DrawLand (X, Y: LongInt; Surface: PSDL_Surface);
    32 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    32 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    33 procedure DrawCaption(X, Y: LongInt; Rect: TSDL_Rect; Surface: PSDL_Surface);
       
    34 procedure DrawCentered(X, Top: LongInt; Source, Surface: PSDL_Surface);
    33 procedure DrawCentered(X, Top: LongInt; Source, Surface: PSDL_Surface);
    35 procedure DrawFromStoreRect(X, Y: LongInt; Rect: PSDL_Rect; Surface: PSDL_Surface);
    34 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceSurface, DestSurface: PSDL_Surface);
    36 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface);
    35 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface);
    37 function  RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
    36 function  RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
    38 procedure RenderHealth(var Hedgehog: THedgehog);
    37 procedure RenderHealth(var Hedgehog: THedgehog);
    39 procedure AddProgress;
    38 procedure AddProgress;
    40 procedure FinishProgress;
    39 procedure FinishProgress;
    45    PauseSurface: PSDL_Surface;
    44    PauseSurface: PSDL_Surface;
    46 
    45 
    47 implementation
    46 implementation
    48 uses uMisc, uConsole, uLand, uLocale;
    47 uses uMisc, uConsole, uLand, uLocale;
    49 
    48 
    50 var StoreSurface,
    49 var
    51        HHSurface: PSDL_Surface;
    50     HHSurface: PSDL_Surface;
    52 
    51 
    53 procedure StoreInit;
    52 procedure StoreInit;
    54 begin
    53 begin
    55 StoreSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat^.RMask, PixelFormat^.GMask, PixelFormat^.BMask, PixelFormat^.AMask);
    54 
    56 TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true);
       
    57 SDL_FillRect(StoreSurface, nil, 0);
       
    58 
       
    59 TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
       
    60 end;
    55 end;
    61 
    56 
    62 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
    57 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
    63 var r: TSDL_Rect;
    58 var r: TSDL_Rect;
    64 begin
    59 begin
   123         i: LongInt;
   118         i: LongInt;
   124         r, rr: TSDL_Rect;
   119         r, rr: TSDL_Rect;
   125         drY: LongInt;
   120         drY: LongInt;
   126     begin
   121     begin
   127     r.x:= 0;
   122     r.x:= 0;
   128     r.y:= 272;
   123     r.y:= 0;
   129     drY:= cScreenHeight - 4;
   124     drY:= cScreenHeight - 4;
   130     for t:= 0 to Pred(TeamsCount) do
   125     for t:= 0 to Pred(TeamsCount) do
   131      with TeamsArray[t]^ do
   126      with TeamsArray[t]^ do
   132       begin
   127       begin
   133       r.w:= 104;
       
   134       NameTag:= RenderString(TeamName, Clan^.Color, Font);
   128       NameTag:= RenderString(TeamName, Clan^.Color, Font);
       
   129 
   135       r.w:= cTeamHealthWidth + 5;
   130       r.w:= cTeamHealthWidth + 5;
   136       r.h:= NameTag^.h;
   131       r.h:= NameTag^.h;
   137       DrawRoundRect(@r, cWhiteColor, cColorNearBlack, StoreSurface, true);
   132 
   138       HealthRect:= r;
   133       HealthSurf:= SDL_CreateRGBSurface(SDL_HWSURFACE, r.w, r.h, cBits, PixelFormat^.RMask, PixelFormat^.GMask, PixelFormat^.BMask, PixelFormat^.AMask);
       
   134       TryDo(HealthSurf <> nil, errmsgCreateSurface, true);
       
   135 
       
   136       DrawRoundRect(@r, cWhiteColor, cColorNearBlack, HealthSurf, true);
   139       rr:= r;
   137       rr:= r;
   140       inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
   138       inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
   141       DrawRoundRect(@rr, Clan^.AdjColor, Clan^.AdjColor, StoreSurface, false);
   139       DrawRoundRect(@rr, Clan^.AdjColor, Clan^.AdjColor, HealthSurf, false);
   142       inc(r.y, r.h);
   140 
   143       dec(drY, r.h + 2);
   141       dec(drY, r.h + 2);
   144       DrawHealthY:= drY;
   142       DrawHealthY:= drY;
   145       for i:= 0 to 7 do
   143       for i:= 0 to 7 do
   146           with Hedgehogs[i] do
   144           with Hedgehogs[i] do
   147                if Gear <> nil then
   145                if Gear <> nil then
   362 const r: TSDL_Rect = (x: 0; y: 0; w: 2048; h: 1024);
   360 const r: TSDL_Rect = (x: 0; y: 0; w: 2048; h: 1024);
   363 begin
   361 begin
   364 DrawFromRect(X, Y, @r, LandSurface, Surface)
   362 DrawFromRect(X, Y, @r, LandSurface, Surface)
   365 end;
   363 end;
   366 
   364 
   367 procedure DrawFromStoreRect(X, Y: LongInt; Rect: PSDL_Rect; Surface: PSDL_Surface);
       
   368 begin
       
   369 DrawFromRect(X, Y, Rect, StoreSurface, Surface)
       
   370 end;
       
   371 
       
   372 procedure DrawCaption(X, Y: LongInt; Rect: TSDL_Rect; Surface: PSDL_Surface);
       
   373 begin
       
   374 DrawFromRect(X - (Rect.w) div 2, Y, @Rect, StoreSurface, Surface)
       
   375 end;
       
   376 
       
   377 procedure DrawCentered(X, Top: LongInt; Source, Surface: PSDL_Surface);
   365 procedure DrawCentered(X, Top: LongInt; Source, Surface: PSDL_Surface);
   378 var r: TSDL_Rect;
   366 var r: TSDL_Rect;
   379 begin
   367 begin
   380 r.x:= X - Source^.w div 2;
   368 r.x:= X - Source^.w div 2;
   381 r.y:= Top;
   369 r.y:= Top;
   399 var ii: TSprite;
   387 var ii: TSprite;
   400 begin
   388 begin
   401 for ii:= Low(TSprite) to High(TSprite) do
   389 for ii:= Low(TSprite) to High(TSprite) do
   402     SDL_FreeSurface(SpritesData[ii].Surface);
   390     SDL_FreeSurface(SpritesData[ii].Surface);
   403 SDL_FreeSurface(  HHSurface  );
   391 SDL_FreeSurface(  HHSurface  );
   404 SDL_FreeSurface(LandSurface  );
   392 SDL_FreeSurface(LandSurface  )
   405 SDL_FreeSurface(StoreSurface )
       
   406 end;
   393 end;
   407 
   394 
   408 function  RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
   395 function  RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
   409 var w, h: LongInt;
   396 var w, h: LongInt;
   410     Result: PSDL_Surface;
   397     Result: PSDL_Surface;