63 TempSurface, |
63 TempSurface, |
64 HHSurface: PSDL_Surface; |
64 HHSurface: PSDL_Surface; |
65 |
65 |
66 procedure StoreInit; |
66 procedure StoreInit; |
67 begin |
67 begin |
68 StoreSurface := SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
68 StoreSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
69 TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true); |
69 TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true); |
70 SDL_FillRect(StoreSurface, nil, 0); |
70 SDL_FillRect(StoreSurface, nil, 0); |
71 |
71 |
72 TempSurface := SDL_CreateRGBSurface(SDL_HWSURFACE, 724, 320, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
72 TempSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 724, 900, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
73 TryDo( TempSurface <> nil, errmsgCreateSurface + ': temp' , true); |
73 TryDo( TempSurface <> nil, errmsgCreateSurface + ': temp' , true); |
74 |
74 |
75 TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
75 TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
76 TryDo(SDL_SetColorKey( TempSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
76 TryDo(SDL_SetColorKey( TempSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
77 end; |
77 end; |
115 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: integer; Color: LongWord; Font: THWFont; s: string): TSDL_Rect; |
115 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: integer; Color: LongWord; Font: THWFont; s: string): TSDL_Rect; |
116 var w, h: integer; |
116 var w, h: integer; |
117 tmpsurf: PSDL_Surface; |
117 tmpsurf: PSDL_Surface; |
118 clr: TSDL_Color; |
118 clr: TSDL_Color; |
119 begin |
119 begin |
120 TTF_SizeText(Fontz[Font].Handle, PChar(s), w, h); |
120 TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), w, h); |
121 Result.x:= X; |
121 Result.x:= X; |
122 Result.y:= Y; |
122 Result.y:= Y; |
123 Result.w:= w + 6; |
123 Result.w:= w + 6; |
124 Result.h:= h + 6; |
124 Result.h:= h + 2; |
125 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface); |
125 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface); |
126 SDL_GetRGB(Color, Surface.format, @clr.r, @clr.g, @clr.b); |
126 SDL_GetRGB(Color, Surface.format, @clr.r, @clr.g, @clr.b); |
127 tmpsurf:= TTF_RenderText_Blended(Fontz[Font].Handle, PChar(s), clr); |
127 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr); |
128 Result.x:= X + 3; |
128 Result.x:= X + 3; |
129 Result.y:= Y + 3; |
129 Result.y:= Y + 1; |
130 SDL_UpperBlit(tmpsurf, nil, Surface, @Result); |
130 SDL_UpperBlit(tmpsurf, nil, Surface, @Result); |
131 SDL_FreeSurface(tmpsurf); |
131 SDL_FreeSurface(tmpsurf); |
132 Result.x:= X; |
132 Result.x:= X; |
133 Result.y:= Y; |
133 Result.y:= Y; |
134 Result.w:= w + 6; |
134 Result.w:= w + 6; |
135 Result.h:= h + 6 |
135 Result.h:= h + 2 |
136 end; |
136 end; |
137 |
137 |
138 procedure StoreLoad; |
138 procedure StoreLoad; |
139 var i: TStuff; |
139 var i: TStuff; |
140 ii: TSprite; |
140 ii: TSprite; |
188 r.x:= 0; |
188 r.x:= 0; |
189 r.y:= 256; |
189 r.y:= 256; |
190 r.w:= 16; |
190 r.w:= 16; |
191 r.h:= 16; |
191 r.h:= 16; |
192 s:= Pathz[ptGraphics] + '/' + cCHFileName; |
192 s:= Pathz[ptGraphics] + '/' + cCHFileName; |
193 WriteToConsole(msgLoading + s + ' '); |
193 tmpsurf:= LoadImage(PChar(s), false); |
194 tmpsurf:= IMG_Load(PChar(s)); |
|
195 TryDo(tmpsurf <> nil, msgFailed, true); |
|
196 WriteLnToConsole(msgOK); |
|
197 TransColor:= SDL_MapRGB(tmpsurf.format, $FF, $FF, $FF); |
194 TransColor:= SDL_MapRGB(tmpsurf.format, $FF, $FF, $FF); |
198 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, TransColor) = 0, errmsgTransparentSet, true); |
195 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, TransColor) = 0, errmsgTransparentSet, true); |
199 |
196 |
200 Team:= TeamsList; |
197 Team:= TeamsList; |
201 while Team<>nil do |
198 while Team<>nil do |
396 r: TSDL_Rect; |
393 r: TSDL_Rect; |
397 begin |
394 begin |
398 r.x:= X; |
395 r.x:= X; |
399 r.y:= Y; |
396 r.y:= Y; |
400 SDL_GetRGB(cWhiteColor, PixelFormat, @clr.r, @clr.g, @clr.b); |
397 SDL_GetRGB(cWhiteColor, PixelFormat, @clr.r, @clr.g, @clr.b); |
401 tmpsurf:= TTF_RenderText_Solid(Fontz[Font].Handle, PChar(s), clr); |
398 tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr); |
402 SDL_UpperBlit(tmpsurf, nil, Surface, @r); |
399 SDL_UpperBlit(tmpsurf, nil, Surface, @r); |
403 SDL_FreeSurface(tmpsurf) |
400 SDL_FreeSurface(tmpsurf) |
404 end; |
401 end; |
405 |
402 |
406 procedure DrawLand(X, Y: integer; Surface: PSDL_Surface); |
403 procedure DrawLand(X, Y: integer; Surface: PSDL_Surface); |
489 |
486 |
490 function LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface; |
487 function LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface; |
491 var tmpsurf: PSDL_Surface; |
488 var tmpsurf: PSDL_Surface; |
492 begin |
489 begin |
493 WriteToConsole(msgLoading + filename + '... '); |
490 WriteToConsole(msgLoading + filename + '... '); |
494 tmpsurf:= IMG_Load(PChar(filename)); |
491 tmpsurf:= IMG_Load(PChar(filename + '.' + cBitsStr + '.png')); |
|
492 if tmpsurf = nil then |
|
493 tmpsurf:= IMG_Load(PChar(filename + '.png')); |
495 TryDo(tmpsurf <> nil, msgFailed, true); |
494 TryDo(tmpsurf <> nil, msgFailed, true); |
496 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
495 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
497 if cFullScreen then |
496 if cFullScreen then |
498 begin |
497 begin |
499 if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
498 if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |