author | koda |
Sun, 29 Jan 2012 02:45:12 +0100 | |
changeset 6611 | d9d00e537010 |
parent 6580 | 6155187bf599 |
child 6620 | b211d0b690de |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
||
4380 | 19 |
{$INCLUDE "options.inc"} |
4976 | 20 |
|
4380 | 21 |
unit uRenderUtils; |
22 |
||
23 |
interface |
|
24 |
uses SDLh, uTypes; |
|
25 |
||
26 |
procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); |
|
27 |
procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
|
28 |
procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); |
|
29 |
function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
|
30 |
function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
|
31 |
procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
|
32 |
||
33 |
implementation |
|
4404 | 34 |
uses uUtils, uVariables, uConsts, uTextures, sysutils, uDebug; |
4380 | 35 |
|
36 |
procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
|
37 |
var r: TSDL_Rect; |
|
38 |
begin |
|
39 |
r:= rect^; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
40 |
if Clear then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
41 |
SDL_FillRect(Surface, @r, 0); |
4380 | 42 |
|
43 |
BorderColor:= SDL_MapRGB(Surface^.format, BorderColor shr 16, BorderColor shr 8, BorderColor and $FF); |
|
44 |
FillColor:= SDL_MapRGB(Surface^.format, FillColor shr 16, FillColor shr 8, FillColor and $FF); |
|
45 |
||
46 |
r.y:= rect^.y + 1; |
|
47 |
r.h:= rect^.h - 2; |
|
48 |
SDL_FillRect(Surface, @r, BorderColor); |
|
49 |
r.x:= rect^.x + 1; |
|
50 |
r.w:= rect^.w - 2; |
|
51 |
r.y:= rect^.y; |
|
52 |
r.h:= rect^.h; |
|
53 |
SDL_FillRect(Surface, @r, BorderColor); |
|
54 |
r.x:= rect^.x + 2; |
|
55 |
r.y:= rect^.y + 1; |
|
56 |
r.w:= rect^.w - 4; |
|
57 |
r.h:= rect^.h - 2; |
|
58 |
SDL_FillRect(Surface, @r, FillColor); |
|
59 |
r.x:= rect^.x + 1; |
|
60 |
r.y:= rect^.y + 2; |
|
61 |
r.w:= rect^.w - 2; |
|
62 |
r.h:= rect^.h - 4; |
|
63 |
SDL_FillRect(Surface, @r, FillColor) |
|
64 |
end; |
|
65 |
||
66 |
function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
|
67 |
var w, h: LongInt; |
|
68 |
tmpsurf: PSDL_Surface; |
|
69 |
clr: TSDL_Color; |
|
70 |
finalRect: TSDL_Rect; |
|
71 |
begin |
|
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
4976
diff
changeset
|
72 |
TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h); |
4380 | 73 |
finalRect.x:= X; |
74 |
finalRect.y:= Y; |
|
75 |
finalRect.w:= w + FontBorder * 2 + 4; |
|
76 |
finalRect.h:= h + FontBorder * 2; |
|
77 |
DrawRoundRect(@finalRect, cWhiteColor, endian(cNearBlackColorChannels.value), Surface, true); |
|
78 |
clr.r:= (Color shr 16) and $FF; |
|
79 |
clr.g:= (Color shr 8) and $FF; |
|
80 |
clr.b:= Color and $FF; |
|
81 |
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr); |
|
82 |
finalRect.x:= X + FontBorder + 2; |
|
83 |
finalRect.y:= Y + FontBorder; |
|
84 |
SDLTry(tmpsurf <> nil, true); |
|
85 |
SDL_UpperBlit(tmpsurf, nil, Surface, @finalRect); |
|
86 |
SDL_FreeSurface(tmpsurf); |
|
87 |
finalRect.x:= X; |
|
88 |
finalRect.y:= Y; |
|
89 |
finalRect.w:= w + FontBorder * 2 + 4; |
|
90 |
finalRect.h:= h + FontBorder * 2; |
|
91 |
WriteInRoundRect:= finalRect; |
|
92 |
end; |
|
93 |
||
94 |
procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); |
|
95 |
var y, x, i, j: LongInt; |
|
96 |
tmpPixel: Longword; |
|
97 |
pixels: PLongWordArray; |
|
98 |
begin |
|
99 |
TryDo(Surface^.format^.BytesPerPixel = 4, 'flipSurface failed, expecting 32 bit surface', true); |
|
100 |
pixels:= Surface^.pixels; |
|
101 |
if Vertical then |
|
102 |
for y := 0 to (Surface^.h div 2) - 1 do |
|
103 |
for x := 0 to Surface^.w - 1 do |
|
104 |
begin |
|
105 |
i:= y * Surface^.w + x; |
|
106 |
j:= (Surface^.h - y - 1) * Surface^.w + x; |
|
107 |
tmpPixel:= pixels^[i]; |
|
108 |
pixels^[i]:= pixels^[j]; |
|
109 |
pixels^[j]:= tmpPixel; |
|
110 |
end |
|
111 |
else |
|
112 |
for x := 0 to (Surface^.w div 2) - 1 do |
|
113 |
for y := 0 to Surface^.h -1 do |
|
114 |
begin |
|
115 |
i:= y*Surface^.w + x; |
|
116 |
j:= y*Surface^.w + (Surface^.w - x - 1); |
|
117 |
tmpPixel:= pixels^[i]; |
|
118 |
pixels^[i]:= pixels^[j]; |
|
119 |
pixels^[j]:= tmpPixel; |
|
120 |
end; |
|
121 |
end; |
|
122 |
||
123 |
procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); |
|
124 |
var srcX, srcY, i, j, maxDest: LongInt; |
|
125 |
srcPixels, destPixels: PLongWordArray; |
|
126 |
r0, g0, b0, a0, r1, g1, b1, a1: Byte; |
|
127 |
begin |
|
128 |
maxDest:= (dest^.pitch div 4) * dest^.h; |
|
129 |
srcPixels:= src^.pixels; |
|
130 |
destPixels:= dest^.pixels; |
|
131 |
||
132 |
for srcX:= 0 to src^.w - 1 do |
|
133 |
for srcY:= 0 to src^.h - 1 do |
|
134 |
begin |
|
135 |
i:= (destY + srcY) * (dest^.pitch div 4) + destX + srcX; |
|
136 |
j:= srcY * (src^.pitch div 4) + srcX; |
|
137 |
if (i < maxDest) and (srcPixels^[j] and AMask <> 0) then |
|
138 |
begin |
|
139 |
SDL_GetRGBA(destPixels^[i], dest^.format, @r0, @g0, @b0, @a0); |
|
140 |
SDL_GetRGBA(srcPixels^[j], src^.format, @r1, @g1, @b1, @a1); |
|
141 |
r0:= (r0 * (255 - LongInt(a1)) + r1 * LongInt(a1)) div 255; |
|
142 |
g0:= (g0 * (255 - LongInt(a1)) + g1 * LongInt(a1)) div 255; |
|
143 |
b0:= (b0 * (255 - LongInt(a1)) + b1 * LongInt(a1)) div 255; |
|
144 |
a0:= (a0 * (255 - LongInt(a1)) + a1 * LongInt(a1)) div 255; |
|
145 |
destPixels^[i]:= SDL_MapRGBA(dest^.format, r0, g0, b0, a0); |
|
146 |
end; |
|
147 |
end; |
|
148 |
end; |
|
149 |
||
150 |
procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL, apparently |
|
151 |
var y, x, i, j: LongInt; |
|
152 |
srcPixels, destPixels: PLongWordArray; |
|
153 |
begin |
|
154 |
TryDo(src^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true); |
|
155 |
TryDo(dest^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true); |
|
156 |
||
157 |
srcPixels:= src^.pixels; |
|
158 |
destPixels:= dest^.pixels; |
|
159 |
||
160 |
j:= 0; |
|
161 |
for x := 0 to src^.w - 1 do |
|
162 |
for y := 0 to src^.h - 1 do |
|
163 |
begin |
|
164 |
i:= (src^.h - 1 - y) * (src^.pitch div 4) + x; |
|
165 |
destPixels^[j]:= srcPixels^[i]; |
|
166 |
inc(j) |
|
167 |
end; |
|
168 |
end; |
|
169 |
||
170 |
function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
|
171 |
var w, h: LongInt; |
|
172 |
finalSurface: PSDL_Surface; |
|
173 |
begin |
|
174 |
if length(s) = 0 then s:= ' '; |
|
175 |
font:= CheckCJKFont(s, font); |
|
176 |
w:= 0; h:= 0; // avoid compiler hints |
|
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
4976
diff
changeset
|
177 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); |
4380 | 178 |
|
179 |
finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + FontBorder * 2 + 4, h + FontBorder * 2, |
|
180 |
32, RMask, GMask, BMask, AMask); |
|
181 |
||
182 |
TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true); |
|
183 |
||
184 |
WriteInRoundRect(finalSurface, 0, 0, Color, font, s); |
|
185 |
||
186 |
TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
|
187 |
||
188 |
RenderStringTex:= Surface2Tex(finalSurface, false); |
|
189 |
||
190 |
SDL_FreeSurface(finalSurface); |
|
191 |
end; |
|
192 |
||
193 |
||
194 |
function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
|
195 |
var textWidth, textHeight, x, y, w, h, i, j, pos, prevpos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt; |
|
196 |
finalSurface, tmpsurf, rotatedEdge: PSDL_Surface; |
|
197 |
rect: TSDL_Rect; |
|
4611 | 198 |
chars: set of char = [#9,' ',';',':','?','!',',']; |
4380 | 199 |
substr: shortstring; |
200 |
edge, corner, tail: TSPrite; |
|
201 |
begin |
|
202 |
case SpeechType of |
|
203 |
1: begin; |
|
204 |
edge:= sprSpeechEdge; |
|
205 |
corner:= sprSpeechCorner; |
|
206 |
tail:= sprSpeechTail; |
|
207 |
end; |
|
208 |
2: begin; |
|
209 |
edge:= sprThoughtEdge; |
|
210 |
corner:= sprThoughtCorner; |
|
211 |
tail:= sprThoughtTail; |
|
212 |
end; |
|
213 |
3: begin; |
|
214 |
edge:= sprShoutEdge; |
|
215 |
corner:= sprShoutCorner; |
|
216 |
tail:= sprShoutTail; |
|
217 |
end; |
|
218 |
end; |
|
219 |
edgeHeight:= SpritesData[edge].Height; |
|
220 |
edgeWidth:= SpritesData[edge].Width; |
|
221 |
cornerWidth:= SpritesData[corner].Width; |
|
222 |
cornerHeight:= SpritesData[corner].Height; |
|
223 |
// This one screws up WrapText |
|
224 |
//s:= 'This is the song that never ends. ''cause it goes on and on my friends. Some people, started singing it not knowing what it was. And they''ll just go on singing it forever just because... This is the song that never ends...'; |
|
225 |
// This one does not |
|
226 |
//s:= 'This is the song that never ends. cause it goes on and on my friends. Some people, started singing it not knowing what it was. And they will go on singing it forever just because... This is the song that never ends... '; |
|
227 |
||
228 |
numLines:= 0; |
|
229 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
230 |
if length(s) = 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
231 |
s:= '...'; |
4380 | 232 |
font:= CheckCJKFont(s, font); |
233 |
w:= 0; h:= 0; // avoid compiler hints |
|
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
4976
diff
changeset
|
234 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
235 |
if w<8 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
236 |
w:= 8; |
4380 | 237 |
j:= 0; |
238 |
if (length(s) > 20) then |
|
239 |
begin |
|
240 |
w:= 0; |
|
241 |
i:= round(Sqrt(length(s)) * 2); |
|
242 |
s:= WrapText(s, #1, chars, i); |
|
243 |
pos:= 1; prevpos:= 0; line:= 0; |
|
244 |
// Find the longest line for the purposes of centring the text. Font dependant. |
|
245 |
while pos <= length(s) do |
|
246 |
begin |
|
247 |
if (s[pos] = #1) or (pos = length(s)) then |
|
248 |
begin |
|
249 |
inc(numlines); |
|
250 |
if s[pos] <> #1 then inc(pos); |
|
251 |
while s[prevpos+1] = ' ' do inc(prevpos); |
|
252 |
substr:= copy(s, prevpos+1, pos-prevpos-1); |
|
253 |
i:= 0; j:= 0; |
|
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
4976
diff
changeset
|
254 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(substr), @i, @j); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
255 |
if i > w then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
256 |
w:= i; |
4380 | 257 |
prevpos:= pos; |
258 |
end; |
|
259 |
inc(pos); |
|
260 |
end; |
|
261 |
end |
|
262 |
else numLines := 1; |
|
263 |
||
264 |
textWidth:=((w-(cornerWidth-edgeWidth)*2) div edgeWidth)*edgeWidth+edgeWidth; |
|
265 |
textHeight:=(((numlines * h + 2)-((cornerHeight-edgeWidth)*2)) div edgeWidth)*edgeWidth; |
|
266 |
||
267 |
textHeight:=max(textHeight,edgeWidth); |
|
268 |
//textWidth:=max(textWidth,SpritesData[tail].Width); |
|
269 |
rect.x:= 0; |
|
270 |
rect.y:= 0; |
|
271 |
rect.w:= textWidth + (cornerWidth * 2); |
|
272 |
rect.h:= textHeight + cornerHeight*2 - edgeHeight + SpritesData[tail].Height; |
|
273 |
//s:= inttostr(w) + ' ' + inttostr(numlines) + ' ' + inttostr(rect.x) + ' '+inttostr(rect.y) + ' ' + inttostr(rect.w) + ' ' + inttostr(rect.h); |
|
274 |
||
275 |
finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, 32, RMask, GMask, BMask, AMask); |
|
276 |
||
277 |
TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true); |
|
278 |
||
279 |
//////////////////////////////// CORNERS /////////////////////////////// |
|
280 |
copyToXY(SpritesData[corner].Surface, finalSurface, 0, 0); /////////////////// NW |
|
281 |
||
282 |
flipSurface(SpritesData[corner].Surface, true); // store all 4 versions in memory to avoid repeated flips? |
|
283 |
x:= 0; |
|
284 |
y:= textHeight + cornerHeight -1; |
|
285 |
copyToXY(SpritesData[corner].Surface, finalSurface, x, y); /////////////////// SW |
|
286 |
||
287 |
flipSurface(SpritesData[corner].Surface, false); |
|
288 |
x:= rect.w-cornerWidth-1; |
|
289 |
y:= textHeight + cornerHeight -1; |
|
290 |
copyToXY(SpritesData[corner].Surface, finalSurface, x, y); /////////////////// SE |
|
291 |
||
292 |
flipSurface(SpritesData[corner].Surface, true); |
|
293 |
x:= rect.w-cornerWidth-1; |
|
294 |
y:= 0; |
|
295 |
copyToXY(SpritesData[corner].Surface, finalSurface, x, y); /////////////////// NE |
|
296 |
flipSurface(SpritesData[corner].Surface, false); // restore original position |
|
297 |
//////////////////////////////// END CORNERS /////////////////////////////// |
|
298 |
||
299 |
//////////////////////////////// EDGES ////////////////////////////////////// |
|
300 |
x:= cornerWidth; |
|
301 |
y:= 0; |
|
302 |
while x < rect.w-cornerWidth-1 do |
|
303 |
begin |
|
304 |
copyToXY(SpritesData[edge].Surface, finalSurface, x, y); ///////////////// top edge |
|
305 |
inc(x,edgeWidth); |
|
306 |
end; |
|
307 |
flipSurface(SpritesData[edge].Surface, true); |
|
308 |
x:= cornerWidth; |
|
309 |
y:= textHeight + cornerHeight*2 - edgeHeight-1; |
|
310 |
while x < rect.w-cornerWidth-1 do |
|
311 |
begin |
|
312 |
copyToXY(SpritesData[edge].Surface, finalSurface, x, y); ///////////////// bottom edge |
|
313 |
inc(x,edgeWidth); |
|
314 |
end; |
|
315 |
flipSurface(SpritesData[edge].Surface, true); // restore original position |
|
316 |
||
317 |
rotatedEdge:= SDL_CreateRGBSurface(SDL_SWSURFACE, edgeHeight, edgeWidth, 32, RMask, GMask, BMask, AMask); |
|
318 |
x:= rect.w - edgeHeight - 1; |
|
319 |
y:= cornerHeight; |
|
320 |
//// initially was going to rotate in place, but the SDL spec claims width/height are read only |
|
321 |
copyRotatedSurface(SpritesData[edge].Surface,rotatedEdge); |
|
322 |
while y < textHeight + cornerHeight do |
|
323 |
begin |
|
324 |
copyToXY(rotatedEdge, finalSurface, x, y); |
|
325 |
inc(y,edgeWidth); |
|
326 |
end; |
|
327 |
flipSurface(rotatedEdge, false); // restore original position |
|
328 |
x:= 0; |
|
329 |
y:= cornerHeight; |
|
330 |
while y < textHeight + cornerHeight do |
|
331 |
begin |
|
332 |
copyToXY(rotatedEdge, finalSurface, x, y); |
|
333 |
inc(y,edgeWidth); |
|
334 |
end; |
|
335 |
//////////////////////////////// END EDGES ////////////////////////////////////// |
|
336 |
||
337 |
x:= cornerWidth; |
|
338 |
y:= textHeight + cornerHeight * 2 - edgeHeight - 1; |
|
339 |
copyToXY(SpritesData[tail].Surface, finalSurface, x, y); |
|
340 |
||
341 |
rect.x:= edgeHeight; |
|
342 |
rect.y:= edgeHeight; |
|
343 |
rect.w:= rect.w - edgeHeight * 2; |
|
344 |
rect.h:= textHeight + cornerHeight * 2 - edgeHeight * 2; |
|
345 |
i:= rect.w; |
|
346 |
j:= rect.h; |
|
347 |
SDL_FillRect(finalSurface, @rect, cWhiteColor); |
|
348 |
||
349 |
pos:= 1; prevpos:= 0; line:= 0; |
|
350 |
while pos <= length(s) do |
|
351 |
begin |
|
352 |
if (s[pos] = #1) or (pos = length(s)) then |
|
353 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
354 |
if s[pos] <> #1 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
355 |
inc(pos); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
356 |
while s[prevpos+1] = ' 'do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
357 |
inc(prevpos); |
4380 | 358 |
substr:= copy(s, prevpos+1, pos-prevpos-1); |
359 |
if Length(substr) <> 0 then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
360 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
361 |
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), cNearBlackColorChannels); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
362 |
rect.x:= edgeHeight + 1 + ((i - w) div 2); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
363 |
// trying to more evenly position the text, vertically |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
364 |
rect.y:= edgeHeight + ((j-(numLines*h)) div 2) + line * h; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
365 |
SDLTry(tmpsurf <> nil, true); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
366 |
SDL_UpperBlit(tmpsurf, nil, finalSurface, @rect); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
367 |
SDL_FreeSurface(tmpsurf); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
368 |
inc(line); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
369 |
prevpos:= pos; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
370 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
371 |
end; |
4380 | 372 |
inc(pos); |
373 |
end; |
|
374 |
||
375 |
RenderSpeechBubbleTex:= Surface2Tex(finalSurface, true); |
|
376 |
||
377 |
SDL_FreeSurface(rotatedEdge); |
|
378 |
SDL_FreeSurface(finalSurface); |
|
379 |
end; |
|
380 |
||
4611 | 381 |
end. |