47 procedure DXOutText(X, Y: Integer; Font: THWFont; s: string; Surface: PSDL_Surface); |
47 procedure DXOutText(X, Y: Integer; Font: THWFont; s: string; Surface: PSDL_Surface); |
48 procedure DrawCaption(X, Y: integer; Rect: TSDL_Rect; Surface: PSDL_Surface; const fromTempSurf: boolean = false); |
48 procedure DrawCaption(X, Y: integer; Rect: TSDL_Rect; Surface: PSDL_Surface; const fromTempSurf: boolean = false); |
49 procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface); |
49 procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface); |
50 procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface); |
50 procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface); |
51 procedure RenderHealth(var Hedgehog: THedgehog); |
51 procedure RenderHealth(var Hedgehog: THedgehog); |
52 function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect; |
52 function RenderString(var s: shortstring; Color, Pos: integer): PSDL_Surface; |
53 procedure AddProgress; |
53 procedure AddProgress; |
54 function LoadImage(filename: string; hasAlpha: boolean; const critical: boolean = true): PSDL_Surface; |
54 function LoadImage(filename: string; hasAlpha: boolean; const critical: boolean = true): PSDL_Surface; |
55 |
55 |
56 var PixelFormat: PSDL_PixelFormat; |
56 var PixelFormat: PSDL_PixelFormat; |
57 SDLPrimSurface: PSDL_Surface; |
57 SDLPrimSurface: PSDL_Surface; |
85 rr.y:= Y; |
85 rr.y:= Y; |
86 SDL_UpperBlit(tmpsurf, nil, Surface, @rr); |
86 SDL_UpperBlit(tmpsurf, nil, Surface, @rr); |
87 SDL_FreeSurface(tmpsurf); |
87 SDL_FreeSurface(tmpsurf); |
88 end; |
88 end; |
89 |
89 |
90 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface); |
90 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; const Clear: boolean = true); |
91 var r: TSDL_Rect; |
91 var r: TSDL_Rect; |
92 begin |
92 begin |
93 r:= rect^; |
93 r:= rect^; |
94 SDL_FillRect(Surface, @r, 0); |
94 if Clear then SDL_FillRect(Surface, @r, 0); |
95 r.y:= rect.y + 1; |
95 r.y:= rect.y + 1; |
96 r.h:= rect.h - 2; |
96 r.h:= rect.h - 2; |
97 SDL_FillRect(Surface, @r, BorderColor); |
97 SDL_FillRect(Surface, @r, BorderColor); |
98 r.x:= rect.x + 1; |
98 r.x:= rect.x + 1; |
99 r.w:= rect.w - 2; |
99 r.w:= rect.w - 2; |
161 r.w:= cTeamHealthWidth + 5; |
161 r.w:= cTeamHealthWidth + 5; |
162 DrawRoundRect(@r, cWhiteColor, cColorNearBlack, StoreSurface); |
162 DrawRoundRect(@r, cWhiteColor, cColorNearBlack, StoreSurface); |
163 Team.HealthRect:= r; |
163 Team.HealthRect:= r; |
164 rr:= r; |
164 rr:= r; |
165 inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); |
165 inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); |
166 DrawRoundRect(@rr, Team.Color, Team.Color, StoreSurface); |
166 DrawRoundRect(@rr, Team.Color, Team.Color, StoreSurface, false); |
167 inc(r.y, r.h); |
167 inc(r.y, r.h); |
168 dec(drY, r.h + 2); |
168 dec(drY, r.h + 2); |
169 Team.DrawHealthY:= drY; |
169 Team.DrawHealthY:= drY; |
170 for i:= 0 to 7 do |
170 for i:= 0 to 7 do |
171 if Team.Hedgehogs[i].Gear<>nil then |
171 if Team.Hedgehogs[i].Gear<>nil then |
459 str(Hedgehog.Gear.Damage, s); |
459 str(Hedgehog.Gear.Damage, s); |
460 Hedgehog.HealthTagRect:= WriteInRoundRect(TempSurface, Hedgehog.HealthRect.x + Hedgehog.HealthRect.w, Hedgehog.HealthRect.y, Hedgehog.Team.Color, fnt16, s) |
460 Hedgehog.HealthTagRect:= WriteInRoundRect(TempSurface, Hedgehog.HealthRect.x + Hedgehog.HealthRect.w, Hedgehog.HealthRect.y, Hedgehog.Team.Color, fnt16, s) |
461 end; |
461 end; |
462 end; |
462 end; |
463 |
463 |
464 function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect; |
464 function RenderString(var s: shortstring; Color, Pos: integer): PSDL_Surface; |
465 begin |
465 var w, h: integer; |
466 Result:= WriteInRoundRect(TempSurface, 64, Pos * Fontz[fntBig].Height, Color, fntBig, s); |
466 begin |
|
467 TTF_SizeUTF8(Fontz[fntBig].Handle, PChar(String(s)), w, h); |
|
468 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
|
469 WriteInRoundRect(Result, 0, 0, Color, fntBig, s); |
|
470 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true) |
467 end; |
471 end; |
468 |
472 |
469 procedure AddProgress; |
473 procedure AddProgress; |
470 const Step: Longword = 0; |
474 const Step: Longword = 0; |
471 ProgrSurf: PSDL_Surface = nil; |
475 ProgrSurf: PSDL_Surface = nil; |