33 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt); |
33 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt); |
34 procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte); |
34 procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte); |
35 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
35 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
36 |
36 |
37 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
37 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
38 function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
38 function RenderStringTexPChar(s: PChar; Color: Longword; font: THWFont): PTexture; |
|
39 function RenderStringTexLim(s: PChar; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
39 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
40 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
40 |
41 |
41 implementation |
42 implementation |
42 uses uUtils, uVariables, uConsts, uTextures, SysUtils, uDebug; |
43 uses uUtils, uVariables, uConsts, uTextures, SysUtils, uDebug; |
43 |
44 |
268 |
269 |
269 end; |
270 end; |
270 |
271 |
271 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
272 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
272 begin |
273 begin |
273 RenderStringTex:= RenderStringTexLim(s, Color, font, 0); |
274 RenderStringTex:= RenderStringTexLim(Str2PChar(s), Color, font, 0); |
274 end; |
275 end; |
275 |
276 |
276 function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
277 function RenderStringTexPChar(s: PChar; Color: Longword; font: THWFont): PTexture; |
|
278 begin |
|
279 RenderStringTexPChar:= RenderStringTexLim(s, Color, font, 0); |
|
280 end; |
|
281 |
|
282 function RenderStringTexLim(s: PChar; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
277 var w, h: LongInt; |
283 var w, h: LongInt; |
278 finalSurface: PSDL_Surface; |
284 finalSurface: PSDL_Surface; |
279 begin |
285 begin |
280 if length(s) = 0 then s:= _S' '; |
286 if StrLength(s) = 0 then s:= Str2PChar(''); // conversion because pas2c ain't smart enough yet; |
281 font:= CheckCJKFont(s, font); |
287 font:= CheckCJKFont(s, font); |
282 w:= 0; h:= 0; // avoid compiler hints |
288 w:= 0; h:= 0; // avoid compiler hints |
283 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); |
289 TTF_SizeUTF8(Fontz[font].Handle, s, @w, @h); |
284 if (maxLength <> 0) and (w > maxLength) then w := maxLength; |
290 if (maxLength <> 0) and (w > maxLength) then w := maxLength; |
285 |
291 |
286 finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2, |
292 finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2, |
287 32, RMask, GMask, BMask, AMask); |
293 32, RMask, GMask, BMask, AMask); |
288 |
294 |
334 |
340 |
335 numLines:= 0; |
341 numLines:= 0; |
336 |
342 |
337 if length(s) = 0 then |
343 if length(s) = 0 then |
338 s:= '...'; |
344 s:= '...'; |
339 font:= CheckCJKFont(s, font); |
345 font:= CheckCJKFont(Str2PChar(s), font); |
340 w:= 0; h:= 0; // avoid compiler hints |
346 w:= 0; h:= 0; // avoid compiler hints |
341 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); |
347 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); |
342 if w<8 then |
348 if w<8 then |
343 w:= 8; |
349 w:= 8; |
344 j:= 0; |
350 j:= 0; |