115 var w, h: LongInt; |
115 var w, h: LongInt; |
116 tmpsurf: PSDL_Surface; |
116 tmpsurf: PSDL_Surface; |
117 clr: TSDL_Color; |
117 clr: TSDL_Color; |
118 Result: TSDL_Rect; |
118 Result: TSDL_Rect; |
119 begin |
119 begin |
120 TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), w, h); |
120 TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), w, h); |
121 Result.x:= X; |
121 Result.x:= X; |
122 Result.y:= Y; |
122 Result.y:= Y; |
123 Result.w:= w + FontBorder * 2 + 4; |
123 Result.w:= w + FontBorder * 2 + 4; |
124 Result.h:= h + FontBorder * 2; |
124 Result.h:= h + FontBorder * 2; |
125 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface, true); |
125 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface, true); |
126 clr.r:= Color shr 16; |
126 clr.r:= Color shr 16; |
127 clr.g:= (Color shr 8) and $FF; |
127 clr.g:= (Color shr 8) and $FF; |
128 clr.b:= Color and $FF; |
128 clr.b:= Color and $FF; |
129 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr.value); |
129 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr.value); |
130 Result.x:= X + FontBorder + 2; |
130 tmpsurf:= doSurfaceConversion(tmpsurf); |
131 Result.y:= Y + FontBorder; |
131 Result.x:= X + FontBorder + 2; |
132 SDLTry(tmpsurf <> nil, true); |
132 Result.y:= Y + FontBorder; |
133 SDL_UpperBlit(tmpsurf, nil, Surface, @Result); |
133 SDLTry(tmpsurf <> nil, true); |
134 SDL_FreeSurface(tmpsurf); |
134 SDL_UpperBlit(tmpsurf, nil, Surface, @Result); |
135 Result.x:= X; |
135 SDL_FreeSurface(tmpsurf); |
136 Result.y:= Y; |
136 Result.x:= X; |
137 Result.w:= w + FontBorder * 2 + 4; |
137 Result.y:= Y; |
138 Result.h:= h + FontBorder * 2; |
138 Result.w:= w + FontBorder * 2 + 4; |
139 WriteInRoundRect:= Result |
139 Result.h:= h + FontBorder * 2; |
|
140 WriteInRoundRect:= Result |
140 end; |
141 end; |
141 |
142 |
142 procedure StoreLoad; |
143 procedure StoreLoad; |
143 var s: string; |
144 var s: string; |
144 |
145 |
388 AddProgress; |
389 AddProgress; |
389 |
390 |
390 for ai:= Low(TAmmoType) to High(TAmmoType) do |
391 for ai:= Low(TAmmoType) to High(TAmmoType) do |
391 with Ammoz[ai] do |
392 with Ammoz[ai] do |
392 begin |
393 begin |
393 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(trAmmo[NameId]), $FFFFFF); |
394 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(trAmmo[NameId]), cWhiteColor); |
|
395 tmpsurf:= doSurfaceConversion(tmpsurf); |
394 NameTex:= Surface2Tex(tmpsurf, false); |
396 NameTex:= Surface2Tex(tmpsurf, false); |
395 SDL_FreeSurface(tmpsurf) |
397 SDL_FreeSurface(tmpsurf) |
396 end; |
398 end; |
397 |
399 |
398 for i:= Low(CountTexz) to High(CountTexz) do |
400 for i:= Low(CountTexz) to High(CountTexz) do |
399 begin |
401 begin |
400 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), $FFFFFF); |
402 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColor); |
|
403 tmpsurf:= doSurfaceConversion(tmpsurf); |
401 CountTexz[i]:= Surface2Tex(tmpsurf, false); |
404 CountTexz[i]:= Surface2Tex(tmpsurf, false); |
402 SDL_FreeSurface(tmpsurf) |
405 SDL_FreeSurface(tmpsurf) |
403 end; |
406 end; |
404 |
407 |
405 {$IFDEF DUMP} |
408 {$IFDEF DUMP} |
986 while s[prevpos+1] = ' 'do inc(prevpos); |
989 while s[prevpos+1] = ' 'do inc(prevpos); |
987 substr:= copy(s, prevpos+1, pos-prevpos-1); |
990 substr:= copy(s, prevpos+1, pos-prevpos-1); |
988 if Length(substr) <> 0 then |
991 if Length(substr) <> 0 then |
989 begin |
992 begin |
990 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), cColorNearBlack); |
993 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), cColorNearBlack); |
|
994 tmpsurf:= doSurfaceConversion(tmpsurf); |
991 rect.x:= edgeHeight + 1 + ((i - w) div 2); |
995 rect.x:= edgeHeight + 1 + ((i - w) div 2); |
992 // trying to more evenly position the text, vertically |
996 // trying to more evenly position the text, vertically |
993 rect.y:= edgeHeight + ((j-(numLines*h)) div 2) + line * h; |
997 rect.y:= edgeHeight + ((j-(numLines*h)) div 2) + line * h; |
994 SDLTry(tmpsurf <> nil, true); |
998 SDLTry(tmpsurf <> nil, true); |
995 SDL_UpperBlit(tmpsurf, nil, Result, @rect); |
999 SDL_UpperBlit(tmpsurf, nil, Result, @rect); |
1017 end; |
1021 end; |
1018 |
1022 |
1019 function LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface; |
1023 function LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface; |
1020 var tmpsurf: PSDL_Surface; |
1024 var tmpsurf: PSDL_Surface; |
1021 s: shortstring; |
1025 s: shortstring; |
1022 convertedSurf: PSDL_Surface; |
|
1023 begin |
1026 begin |
1024 WriteToConsole(msgLoading + filename + '... '); |
1027 WriteToConsole(msgLoading + filename + '... '); |
1025 |
1028 |
1026 s:= filename + '.png'; |
1029 s:= filename + '.png'; |
1027 tmpsurf:= IMG_Load(Str2PChar(s)); |
1030 tmpsurf:= IMG_Load(Str2PChar(s)); |
1057 OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); |
1060 OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); |
1058 //dummy surface to replace non-critical textures that failed to load due to their size |
1061 //dummy surface to replace non-critical textures that failed to load due to their size |
1059 exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)); |
1062 exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)); |
1060 end; |
1063 end; |
1061 |
1064 |
1062 //for more information http://www.idevgames.com/forum/showpost.php?p=85864&postcount=7 |
1065 tmpsurf:= doSurfaceConversion(tmpsurf); |
1063 if (tmpsurf^.format^.bitsperpixel = 24) or ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) then |
|
1064 begin |
|
1065 convertedSurf:= SDL_ConvertSurface(tmpsurf, @convFormat, SDL_SWSURFACE); |
|
1066 SDL_FreeSurface(tmpsurf); |
|
1067 tmpsurf:= convertedSurf; |
|
1068 end; |
|
1069 |
1066 |
1070 if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
1067 if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
1071 //if (imageFlags and ifAlpha) <> 0 then Result:= SDL_DisplayFormatAlpha(tmpsurf) else Result:= SDL_DisplayFormat(tmpsurf); |
1068 //if (imageFlags and ifAlpha) <> 0 then Result:= SDL_DisplayFormatAlpha(tmpsurf) else Result:= SDL_DisplayFormat(tmpsurf); |
1072 WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); |
1069 WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); |
1073 WriteLnToConsole(msgOK); |
1070 WriteLnToConsole(msgOK); |