complete transition of longword->sdl_color for TTF bindings
authorkoda
Fri, 18 Dec 2009 02:47:28 +0000
changeset 2665 50b4e544c163
parent 2664 949c189ba568
child 2666 2b8c8f16421e
complete transition of longword->sdl_color for TTF bindings
hedgewars/SDLh.pas
hedgewars/uLand.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
--- a/hedgewars/SDLh.pas	Fri Dec 18 02:33:45 2009 +0000
+++ b/hedgewars/SDLh.pas	Fri Dec 18 02:47:28 2009 +0000
@@ -658,10 +658,9 @@
 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
 function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName;
-(* TSDL_Color -> Longword conversion is workaround over freepascal bug.
-   See http://www.freepascal.org/mantis/view.php?id=7613 for details *)
+
 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
-function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName;
+function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
 function  TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
 
 function  TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
@@ -672,7 +671,7 @@
 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
 
 function  Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
-function  Mix_SetDistance(channel: LongInt; distance: Byte): LongInt;  cdecl; external SDL_MixerLibName;
+function  Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName;
 function  Mix_VolumeMusic(volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
 
 function  Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName;
--- a/hedgewars/uLand.pas	Fri Dec 18 02:33:45 2009 +0000
+++ b/hedgewars/uLand.pas	Fri Dec 18 02:47:28 2009 +0000
@@ -704,7 +704,7 @@
                 Land[cpY + y, cpX + x]:= 0
             else if p^[x] = (AMask or RMask) then
                 Land[cpY + y, cpX + x]:= COLOR_INDESTRUCTIBLE
-            else if p^[x] = cWhiteColor then
+            else if p^[x] = $FFFFFFFF then
                 Land[cpY + y, cpX + x]:= COLOR_LAND;
 
             end;
--- a/hedgewars/uMisc.pas	Fri Dec 18 02:33:45 2009 +0000
+++ b/hedgewars/uMisc.pas	Fri Dec 18 02:47:28 2009 +0000
@@ -82,11 +82,10 @@
 	TimeTrialStartTime: Longword = 0;
 	TimeTrialStopTime : Longword = 0;
 	
-	cBlackColor		: TSDL_Color = (r:$00; g:$00; b:$00; unused:$00);
+	cWhiteColorChannels	: TSDL_Color = (r:$FF; g:$FF; b:$FF; unused:$FF);
+	cNearBlackColor		: TSDL_Color = (r:$00; g:$00; b:$10; unused:$FF);
 	cWhiteColor		: Longword = $FFFFFFFF;
 	cYellowColor		: Longword = $FFFFFF00;
-//	cYellowColor		: TSDL_Color = (r:$FF; g:$FF; b:$00; unused:$FF);
-	cNearBlackColor		: Longword = $FF000010;
 	cExplosionBorderColor	: LongWord = $FF808080;
 
 	cShowFPS      : boolean = false;
--- a/hedgewars/uStore.pas	Fri Dec 18 02:33:45 2009 +0000
+++ b/hedgewars/uStore.pas	Fri Dec 18 02:47:28 2009 +0000
@@ -123,11 +123,11 @@
 Result.y:= Y;
 Result.w:= w + FontBorder * 2 + 4;
 Result.h:= h + FontBorder * 2;
-DrawRoundRect(@Result, cWhiteColor, cNearBlackColor, Surface, true);
+DrawRoundRect(@Result, cWhiteColor, cNearBlackColor.value, Surface, true);
 clr.r:= Color shr 16;
 clr.g:= (Color shr 8) and $FF;
 clr.b:= Color and $FF;
-tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr.value);
+tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr);
 tmpsurf:= doSurfaceConversion(tmpsurf);
 Result.x:= X + FontBorder + 2;
 Result.y:= Y + FontBorder;
@@ -166,7 +166,7 @@
 		TryDo(texsurf <> nil, errmsgCreateSurface, true);
 		TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
 
-		DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true);
+		DrawRoundRect(@r, cWhiteColor, cNearBlackColor.value, texsurf, true);
 		rr:= r;
 		inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
 		DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false);
@@ -338,16 +338,14 @@
 for ai:= Low(TAmmoType) to High(TAmmoType) do
 	with Ammoz[ai] do
 		begin
-		tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(trAmmo[NameId]), cWhiteColor);
-		tmpsurf:= doSurfaceConversion(tmpsurf);
+		tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
 		NameTex:= Surface2Tex(tmpsurf, false);
 		SDL_FreeSurface(tmpsurf)
 		end;
 
 for i:= Low(CountTexz) to High(CountTexz) do
 	begin
-	tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColor);
-	tmpsurf:= doSurfaceConversion(tmpsurf);	
+	tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
 	CountTexz[i]:= Surface2Tex(tmpsurf, false);
 	SDL_FreeSurface(tmpsurf)
 	end;
@@ -937,14 +935,7 @@
         substr:= copy(s, prevpos+1, pos-prevpos-1);
         if Length(substr) <> 0 then
            begin
-           tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), 
-{$IFDEF ENDIAN_LITTLE}
-		cNearBlackColor
-{$ELSE}
-		$100000FF
-{$ENDIF}
-		); // do not remove me
-	   tmpsurf:= doSurfaceConversion(tmpsurf);
+           tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), cNearBlackColor);
            rect.x:= edgeHeight + 1 + ((i - w) div 2);
            // trying to more evenly position the text, vertically
            rect.y:= edgeHeight + ((j-(numLines*h)) div 2) + line * h;
--- a/hedgewars/uWorld.pas	Fri Dec 18 02:33:45 2009 +0000
+++ b/hedgewars/uWorld.pas	Fri Dec 18 02:47:28 2009 +0000
@@ -575,8 +575,7 @@
       CountTicks:= 0;
       s:= inttostr(FPS) + ' fps';
       if fpsTexture <> nil then FreeTexture(fpsTexture);
-      tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColor);
-	tmpSurface:= doSurfaceConversion(tmpSurface);
+      tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
       fpsTexture:= Surface2Tex(tmpSurface, false);
       SDL_FreeSurface(tmpSurface)
       end;