147 rr.y:= 0; |
147 rr.y:= 0; |
148 rr.w:= w; |
148 rr.w:= w; |
149 rr.h:= h; |
149 rr.h:= h; |
150 |
150 |
151 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); |
151 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); |
152 TryDo(texsurf <> nil, errmsgCreateSurface, true); |
152 if not checkFails(texsurf <> nil, errmsgCreateSurface, true) then |
153 TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
153 checkFails(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
|
154 |
|
155 if not allOK then exit(nil); |
154 |
156 |
155 DrawRoundRect(@rr, cWhiteColor, cNearBlackColor, texsurf, true); |
157 DrawRoundRect(@rr, cWhiteColor, cNearBlackColor, texsurf, true); |
156 |
158 |
157 rr.x:= 2; |
159 rr.x:= 2; |
158 rr.y:= 2; |
160 rr.y:= 2; |
194 r.x:= 0; |
196 r.x:= 0; |
195 r.y:= 0; |
197 r.y:= 0; |
196 r.w:= 32; |
198 r.w:= 32; |
197 r.h:= 32; |
199 r.h:= 32; |
198 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); |
200 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); |
199 TryDo(texsurf <> nil, errmsgCreateSurface, true); |
201 if not checkFails(texsurf <> nil, errmsgCreateSurface, true) then |
200 TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
202 checkFails(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
|
203 if not allOK then exit; |
201 |
204 |
202 r.w:= 26; |
205 r.w:= 26; |
203 r.h:= 19; |
206 r.h:= 19; |
204 |
207 |
205 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); |
208 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); |
227 end |
230 end |
228 else if (Flag = 'cpu') or (Flag = 'cpu_plain') then |
231 else if (Flag = 'cpu') or (Flag = 'cpu_plain') then |
229 Flag:= 'hedgewars'; |
232 Flag:= 'hedgewars'; |
230 |
233 |
231 flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone); |
234 flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone); |
232 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
235 if not checkFails(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true) then |
233 |
236 begin |
234 case maxLevel of |
237 case maxLevel of |
235 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); |
238 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); |
236 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); |
239 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); |
237 3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5); |
240 3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5); |
238 4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9); |
241 4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9); |
239 5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11) |
242 5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11) |
240 end; |
243 end; |
241 |
244 |
242 copyToXY(flagsurf, texsurf, 2, 2); |
245 copyToXY(flagsurf, texsurf, 2, 2); |
243 SDL_FreeSurface(flagsurf); |
246 SDL_FreeSurface(flagsurf); |
244 flagsurf:= nil; |
247 flagsurf:= nil; |
245 |
248 end; |
246 |
249 |
247 // restore black border pixels inside the flag |
250 // restore black border pixels inside the flag |
248 PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; |
251 PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; |
249 PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; |
252 PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; |
250 PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; |
253 PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; |
473 |
478 |
474 // name of weapons in ammo menu |
479 // name of weapons in ammo menu |
475 for ai:= Low(TAmmoType) to High(TAmmoType) do |
480 for ai:= Low(TAmmoType) to High(TAmmoType) do |
476 with Ammoz[ai] do |
481 with Ammoz[ai] do |
477 begin |
482 begin |
478 TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true); |
483 if checkFails(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true) then exit; |
479 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels); |
484 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels); |
480 TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true); |
485 if checkFails(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true) then exit; |
481 tmpsurf:= doSurfaceConversion(tmpsurf); |
486 tmpsurf:= doSurfaceConversion(tmpsurf); |
482 FreeAndNilTexture(NameTex); |
487 FreeAndNilTexture(NameTex); |
483 NameTex:= Surface2Tex(tmpsurf, false); |
488 NameTex:= Surface2Tex(tmpsurf, false); |
484 SDL_FreeSurface(tmpsurf) |
489 SDL_FreeSurface(tmpsurf) |
485 end; |
490 end; |
627 end; |
632 end; |
628 |
633 |
629 tmpsurf:= doSurfaceConversion(tmpsurf); |
634 tmpsurf:= doSurfaceConversion(tmpsurf); |
630 |
635 |
631 if (imageFlags and ifTransparent) <> 0 then |
636 if (imageFlags and ifTransparent) <> 0 then |
632 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
637 if checkFails(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true) then exit; |
633 |
638 |
634 WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
639 WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
635 |
640 |
636 LoadImage:= tmpsurf //Result |
641 LoadImage:= tmpsurf //Result |
637 end; |
642 end; |
877 // add borders space |
882 // add borders space |
878 inc(w, wa); |
883 inc(w, wa); |
879 inc(h, ha + 8); |
884 inc(h, ha + 8); |
880 |
885 |
881 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); |
886 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); |
882 TryDo(tmpsurf <> nil, 'RenderHelpWindow: fail to create surface', true); |
887 if checkFails(tmpsurf <> nil, 'RenderHelpWindow: fail to create surface', true) then exit(nil); |
883 |
888 |
884 // render border and background |
889 // render border and background |
885 r.x:= 0; |
890 r.x:= 0; |
886 r.y:= 0; |
891 r.y:= 0; |
887 r.w:= w; |
892 r.w:= w; |