author | unc0rr |
Fri, 24 Jan 2014 09:48:46 +0400 | |
changeset 10066 | 1a6e1aad58d6 |
parent 10040 | 4ac87acbaed9 |
child 10104 | cb0b750bd8a3 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9998 | 3 |
* Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com> |
4976 | 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); |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
27 |
|
4380 | 28 |
procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
29 |
procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline; |
7013 | 30 |
procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt); |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
31 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
32 |
procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline; |
7013 | 33 |
procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt); |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
34 |
procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte); |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
35 |
procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
36 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
37 |
function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
7013 | 38 |
function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
4380 | 39 |
function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
40 |
||
41 |
implementation |
|
7063 | 42 |
uses uUtils, uVariables, uConsts, uTextures, SysUtils, uDebug; |
4380 | 43 |
|
44 |
procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
|
45 |
var r: TSDL_Rect; |
|
46 |
begin |
|
47 |
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
|
48 |
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
|
49 |
SDL_FillRect(Surface, @r, 0); |
4380 | 50 |
|
51 |
BorderColor:= SDL_MapRGB(Surface^.format, BorderColor shr 16, BorderColor shr 8, BorderColor and $FF); |
|
52 |
FillColor:= SDL_MapRGB(Surface^.format, FillColor shr 16, FillColor shr 8, FillColor and $FF); |
|
53 |
||
54 |
r.y:= rect^.y + 1; |
|
55 |
r.h:= rect^.h - 2; |
|
56 |
SDL_FillRect(Surface, @r, BorderColor); |
|
57 |
r.x:= rect^.x + 1; |
|
58 |
r.w:= rect^.w - 2; |
|
59 |
r.y:= rect^.y; |
|
60 |
r.h:= rect^.h; |
|
61 |
SDL_FillRect(Surface, @r, BorderColor); |
|
62 |
r.x:= rect^.x + 2; |
|
63 |
r.y:= rect^.y + 1; |
|
64 |
r.w:= rect^.w - 4; |
|
65 |
r.h:= rect^.h - 2; |
|
66 |
SDL_FillRect(Surface, @r, FillColor); |
|
67 |
r.x:= rect^.x + 1; |
|
68 |
r.y:= rect^.y + 2; |
|
69 |
r.w:= rect^.w - 2; |
|
70 |
r.h:= rect^.h - 4; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
71 |
SDL_FillRect(Surface, @r, FillColor); |
4380 | 72 |
end; |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
73 |
(* |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
74 |
function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
75 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
76 |
WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
77 |
end;*) |
4380 | 78 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
79 |
function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect; |
4380 | 80 |
var w, h: LongInt; |
81 |
tmpsurf: PSDL_Surface; |
|
82 |
clr: TSDL_Color; |
|
6750 | 83 |
finalRect, textRect: TSDL_Rect; |
4380 | 84 |
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
|
85 |
TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h); |
6749
6bb0cea803bd
Clamp name/team name textures to avoid long team / hog name abuse. Limit width in px instead of chars to avoid unicode issues.
nemo
parents:
6700
diff
changeset
|
86 |
if (maxLength <> 0) and (w > maxLength) then w := maxLength; |
4380 | 87 |
finalRect.x:= X; |
88 |
finalRect.y:= Y; |
|
6982 | 89 |
finalRect.w:= w + cFontBorder * 2 + 4; |
90 |
finalRect.h:= h + cFontBorder * 2; |
|
6750 | 91 |
textRect.x:= X; |
92 |
textRect.y:= Y; |
|
93 |
textRect.w:= w; |
|
94 |
textRect.h:= h; |
|
7546
b50556f2a0e8
This union hasn't been needed for 5 years, and makes using other headers harder.
nemo
parents:
7069
diff
changeset
|
95 |
DrawRoundRect(@finalRect, cWhiteColor, cNearBlackColor, Surface, true); |
4380 | 96 |
clr.r:= (Color shr 16) and $FF; |
97 |
clr.g:= (Color shr 8) and $FF; |
|
98 |
clr.b:= Color and $FF; |
|
99 |
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr); |
|
6982 | 100 |
finalRect.x:= X + cFontBorder + 2; |
101 |
finalRect.y:= Y + cFontBorder; |
|
4380 | 102 |
SDLTry(tmpsurf <> nil, true); |
6750 | 103 |
SDL_UpperBlit(tmpsurf, @textRect, Surface, @finalRect); |
4380 | 104 |
SDL_FreeSurface(tmpsurf); |
105 |
finalRect.x:= X; |
|
106 |
finalRect.y:= Y; |
|
6982 | 107 |
finalRect.w:= w + cFontBorder * 2 + 4; |
108 |
finalRect.h:= h + cFontBorder * 2; |
|
4380 | 109 |
WriteInRoundRect:= finalRect; |
110 |
end; |
|
111 |
||
112 |
procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); |
|
113 |
var y, x, i, j: LongInt; |
|
114 |
tmpPixel: Longword; |
|
115 |
pixels: PLongWordArray; |
|
116 |
begin |
|
117 |
TryDo(Surface^.format^.BytesPerPixel = 4, 'flipSurface failed, expecting 32 bit surface', true); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
118 |
SDL_LockSurface(Surface); |
4380 | 119 |
pixels:= Surface^.pixels; |
120 |
if Vertical then |
|
121 |
for y := 0 to (Surface^.h div 2) - 1 do |
|
122 |
for x := 0 to Surface^.w - 1 do |
|
123 |
begin |
|
124 |
i:= y * Surface^.w + x; |
|
125 |
j:= (Surface^.h - y - 1) * Surface^.w + x; |
|
126 |
tmpPixel:= pixels^[i]; |
|
127 |
pixels^[i]:= pixels^[j]; |
|
128 |
pixels^[j]:= tmpPixel; |
|
129 |
end |
|
130 |
else |
|
131 |
for x := 0 to (Surface^.w div 2) - 1 do |
|
132 |
for y := 0 to Surface^.h -1 do |
|
133 |
begin |
|
134 |
i:= y*Surface^.w + x; |
|
135 |
j:= y*Surface^.w + (Surface^.w - x - 1); |
|
136 |
tmpPixel:= pixels^[i]; |
|
137 |
pixels^[i]:= pixels^[j]; |
|
138 |
pixels^[j]:= tmpPixel; |
|
139 |
end; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
140 |
SDL_UnlockSurface(Surface); |
4380 | 141 |
end; |
142 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
143 |
procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline; |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
144 |
begin |
7013 | 145 |
copyToXYFromRect(src, dest, 0, 0, src^.w, src^.h, destX, destY); |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
146 |
end; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
147 |
|
7013 | 148 |
procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt); |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
149 |
var i, j, maxDest, maxSrc, iX, iY: LongInt; |
4380 | 150 |
srcPixels, destPixels: PLongWordArray; |
151 |
r0, g0, b0, a0, r1, g1, b1, a1: Byte; |
|
152 |
begin |
|
153 |
maxDest:= (dest^.pitch div 4) * dest^.h; |
|
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
154 |
maxSrc:= (src^.pitch div 4) * src^.h; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
155 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
156 |
SDL_LockSurface(src); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
157 |
SDL_LockSurface(dest); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
158 |
|
4380 | 159 |
srcPixels:= src^.pixels; |
160 |
destPixels:= dest^.pixels; |
|
161 |
||
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
162 |
for iX:= 0 to srcW - 1 do |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
163 |
for iY:= 0 to srcH - 1 do |
4380 | 164 |
begin |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
165 |
i:= (destY + iY) * (dest^.pitch div 4) + (destX + iX); |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
166 |
j:= (srcY + iY) * (src^.pitch div 4) + (srcX + iX); |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
167 |
if (i < maxDest) and (j < maxSrc) and (srcPixels^[j] and AMask <> 0) then |
4380 | 168 |
begin |
169 |
SDL_GetRGBA(destPixels^[i], dest^.format, @r0, @g0, @b0, @a0); |
|
170 |
SDL_GetRGBA(srcPixels^[j], src^.format, @r1, @g1, @b1, @a1); |
|
171 |
r0:= (r0 * (255 - LongInt(a1)) + r1 * LongInt(a1)) div 255; |
|
172 |
g0:= (g0 * (255 - LongInt(a1)) + g1 * LongInt(a1)) div 255; |
|
173 |
b0:= (b0 * (255 - LongInt(a1)) + b1 * LongInt(a1)) div 255; |
|
174 |
a0:= (a0 * (255 - LongInt(a1)) + a1 * LongInt(a1)) div 255; |
|
175 |
destPixels^[i]:= SDL_MapRGBA(dest^.format, r0, g0, b0, a0); |
|
176 |
end; |
|
177 |
end; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
178 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
179 |
SDL_UnlockSurface(src); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
180 |
SDL_UnlockSurface(dest); |
4380 | 181 |
end; |
182 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
183 |
procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
184 |
begin |
7013 | 185 |
DrawSpriteFrame2Surf(sprite, dest, x, y, 0); |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
186 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
187 |
|
7013 | 188 |
procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y,frame: LongInt); |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
189 |
var numFramesFirstCol, row, col: LongInt; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
190 |
begin |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
191 |
numFramesFirstCol:= SpritesData[sprite].imageHeight div SpritesData[sprite].Height; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
192 |
row:= Frame mod numFramesFirstCol; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
193 |
col:= Frame div numFramesFirstCol; |
10015 | 194 |
|
195 |
copyToXYFromRect(SpritesData[sprite].Surface, dest, |
|
196 |
col*SpritesData[sprite].Width, |
|
197 |
row*SpritesData[sprite].Height, |
|
198 |
SpritesData[sprite].Width, |
|
199 |
spritesData[sprite].Height, |
|
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
200 |
x,y); |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
201 |
end; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
202 |
|
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
203 |
procedure DrawLine2Surf(dest: PSDL_Surface; x0, y0,x1,y1: LongInt; r,g,b: byte); |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
204 |
var |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
205 |
dx,dy,err,e2,sx,sy: LongInt; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
206 |
yMax: LongInt; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
207 |
destPixels: PLongwordArray; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
208 |
begin |
6992 | 209 |
//max:= (dest^.pitch div 4) * dest^.h; |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
210 |
yMax:= dest^.pitch div 4; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
211 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
212 |
SDL_LockSurface(dest); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
213 |
|
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
214 |
destPixels:= dest^.pixels; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
215 |
|
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
216 |
dx:= abs(x1-x0); |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
217 |
dy:= abs(y1-y0); |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
218 |
if x0 < x1 then sx:= 1 else sx:= -1; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
219 |
if y0 < y1 then sy:= 1 else sy:= -1; |
10015 | 220 |
err:= dx-dy; |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
221 |
|
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
222 |
while(true) do |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
223 |
begin |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
224 |
destPixels^[(y0 * yMax) + x0]:= SDL_MapRGB(dest^.format, r,g,b); //But will it blend? no |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
225 |
|
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
226 |
if (x0 = x1) and (y0 = y1) then break; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
227 |
|
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
228 |
e2:= 2*err; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
229 |
if e2 > -dy then |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
230 |
begin |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
231 |
err:= err - dy; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
232 |
x0 := x0 + sx; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
233 |
end; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
234 |
|
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
235 |
if e2 < dx then |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
236 |
begin |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
237 |
err:= err + dx; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
238 |
y0:=y0+sy |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
239 |
end; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
240 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
241 |
SDL_UnlockSurface(dest); |
6620
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
242 |
end; |
b211d0b690de
Expanded copyToXY, it doesn't copy the whole src sprite, srcX/Y to srcW/h, added DrawSprite2Surf and DrawLine2Surf
Xeli
parents:
6580
diff
changeset
|
243 |
|
4380 | 244 |
procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL, apparently |
245 |
var y, x, i, j: LongInt; |
|
246 |
srcPixels, destPixels: PLongWordArray; |
|
247 |
begin |
|
248 |
TryDo(src^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true); |
|
249 |
TryDo(dest^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true); |
|
250 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
251 |
SDL_LockSurface(src); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
252 |
SDL_LockSurface(dest); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
253 |
|
4380 | 254 |
srcPixels:= src^.pixels; |
255 |
destPixels:= dest^.pixels; |
|
256 |
||
257 |
j:= 0; |
|
258 |
for x := 0 to src^.w - 1 do |
|
259 |
for y := 0 to src^.h - 1 do |
|
260 |
begin |
|
261 |
i:= (src^.h - 1 - y) * (src^.pitch div 4) + x; |
|
262 |
destPixels^[j]:= srcPixels^[i]; |
|
263 |
inc(j) |
|
264 |
end; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
265 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
266 |
SDL_UnlockSurface(src); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
267 |
SDL_UnlockSurface(dest); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
268 |
|
4380 | 269 |
end; |
270 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
271 |
function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
272 |
begin |
7013 | 273 |
RenderStringTex:= RenderStringTexLim(s, Color, font, 0); |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
274 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
275 |
|
7013 | 276 |
function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
4380 | 277 |
var w, h: LongInt; |
278 |
finalSurface: PSDL_Surface; |
|
279 |
begin |
|
7069 | 280 |
if length(s) = 0 then s:= _S' '; |
4380 | 281 |
font:= CheckCJKFont(s, font); |
282 |
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
|
283 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); |
6749
6bb0cea803bd
Clamp name/team name textures to avoid long team / hog name abuse. Limit width in px instead of chars to avoid unicode issues.
nemo
parents:
6700
diff
changeset
|
284 |
if (maxLength <> 0) and (w > maxLength) then w := maxLength; |
4380 | 285 |
|
6982 | 286 |
finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2, |
4380 | 287 |
32, RMask, GMask, BMask, AMask); |
288 |
||
289 |
TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true); |
|
290 |
||
6749
6bb0cea803bd
Clamp name/team name textures to avoid long team / hog name abuse. Limit width in px instead of chars to avoid unicode issues.
nemo
parents:
6700
diff
changeset
|
291 |
WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength); |
4380 | 292 |
|
293 |
TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
|
294 |
||
7013 | 295 |
RenderStringTexLim:= Surface2Tex(finalSurface, false); |
4380 | 296 |
|
297 |
SDL_FreeSurface(finalSurface); |
|
298 |
end; |
|
299 |
||
300 |
||
301 |
function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
|
302 |
var textWidth, textHeight, x, y, w, h, i, j, pos, prevpos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt; |
|
303 |
finalSurface, tmpsurf, rotatedEdge: PSDL_Surface; |
|
304 |
rect: TSDL_Rect; |
|
10040 | 305 |
chars: set of char = [#9,' ',';',':','?','!',',']; |
4380 | 306 |
substr: shortstring; |
307 |
edge, corner, tail: TSPrite; |
|
308 |
begin |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
309 |
case SpeechType of |
4380 | 310 |
1: begin; |
311 |
edge:= sprSpeechEdge; |
|
312 |
corner:= sprSpeechCorner; |
|
313 |
tail:= sprSpeechTail; |
|
314 |
end; |
|
315 |
2: begin; |
|
316 |
edge:= sprThoughtEdge; |
|
317 |
corner:= sprThoughtCorner; |
|
318 |
tail:= sprThoughtTail; |
|
319 |
end; |
|
320 |
3: begin; |
|
321 |
edge:= sprShoutEdge; |
|
322 |
corner:= sprShoutCorner; |
|
323 |
tail:= sprShoutTail; |
|
324 |
end; |
|
325 |
end; |
|
326 |
edgeHeight:= SpritesData[edge].Height; |
|
327 |
edgeWidth:= SpritesData[edge].Width; |
|
328 |
cornerWidth:= SpritesData[corner].Width; |
|
329 |
cornerHeight:= SpritesData[corner].Height; |
|
330 |
// This one screws up WrapText |
|
331 |
//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...'; |
|
332 |
// This one does not |
|
333 |
//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... '; |
|
334 |
||
335 |
numLines:= 0; |
|
336 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
337 |
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
|
338 |
s:= '...'; |
4380 | 339 |
font:= CheckCJKFont(s, font); |
340 |
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
|
341 |
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
|
342 |
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
|
343 |
w:= 8; |
4380 | 344 |
j:= 0; |
345 |
if (length(s) > 20) then |
|
346 |
begin |
|
347 |
w:= 0; |
|
348 |
i:= round(Sqrt(length(s)) * 2); |
|
349 |
s:= WrapText(s, #1, chars, i); |
|
350 |
pos:= 1; prevpos:= 0; line:= 0; |
|
351 |
// Find the longest line for the purposes of centring the text. Font dependant. |
|
352 |
while pos <= length(s) do |
|
353 |
begin |
|
354 |
if (s[pos] = #1) or (pos = length(s)) then |
|
355 |
begin |
|
356 |
inc(numlines); |
|
357 |
if s[pos] <> #1 then inc(pos); |
|
358 |
while s[prevpos+1] = ' ' do inc(prevpos); |
|
359 |
substr:= copy(s, prevpos+1, pos-prevpos-1); |
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
w:= i; |
4380 | 364 |
prevpos:= pos; |
365 |
end; |
|
366 |
inc(pos); |
|
367 |
end; |
|
368 |
end |
|
369 |
else numLines := 1; |
|
370 |
||
371 |
textWidth:=((w-(cornerWidth-edgeWidth)*2) div edgeWidth)*edgeWidth+edgeWidth; |
|
372 |
textHeight:=(((numlines * h + 2)-((cornerHeight-edgeWidth)*2)) div edgeWidth)*edgeWidth; |
|
373 |
||
374 |
textHeight:=max(textHeight,edgeWidth); |
|
375 |
//textWidth:=max(textWidth,SpritesData[tail].Width); |
|
376 |
rect.x:= 0; |
|
377 |
rect.y:= 0; |
|
378 |
rect.w:= textWidth + (cornerWidth * 2); |
|
379 |
rect.h:= textHeight + cornerHeight*2 - edgeHeight + SpritesData[tail].Height; |
|
380 |
//s:= inttostr(w) + ' ' + inttostr(numlines) + ' ' + inttostr(rect.x) + ' '+inttostr(rect.y) + ' ' + inttostr(rect.w) + ' ' + inttostr(rect.h); |
|
381 |
||
382 |
finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, 32, RMask, GMask, BMask, AMask); |
|
383 |
||
384 |
TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true); |
|
385 |
||
386 |
//////////////////////////////// CORNERS /////////////////////////////// |
|
387 |
copyToXY(SpritesData[corner].Surface, finalSurface, 0, 0); /////////////////// NW |
|
388 |
||
389 |
flipSurface(SpritesData[corner].Surface, true); // store all 4 versions in memory to avoid repeated flips? |
|
390 |
x:= 0; |
|
391 |
y:= textHeight + cornerHeight -1; |
|
392 |
copyToXY(SpritesData[corner].Surface, finalSurface, x, y); /////////////////// SW |
|
393 |
||
394 |
flipSurface(SpritesData[corner].Surface, false); |
|
395 |
x:= rect.w-cornerWidth-1; |
|
396 |
y:= textHeight + cornerHeight -1; |
|
397 |
copyToXY(SpritesData[corner].Surface, finalSurface, x, y); /////////////////// SE |
|
398 |
||
399 |
flipSurface(SpritesData[corner].Surface, true); |
|
400 |
x:= rect.w-cornerWidth-1; |
|
401 |
y:= 0; |
|
402 |
copyToXY(SpritesData[corner].Surface, finalSurface, x, y); /////////////////// NE |
|
403 |
flipSurface(SpritesData[corner].Surface, false); // restore original position |
|
404 |
//////////////////////////////// END CORNERS /////////////////////////////// |
|
405 |
||
406 |
//////////////////////////////// EDGES ////////////////////////////////////// |
|
407 |
x:= cornerWidth; |
|
408 |
y:= 0; |
|
409 |
while x < rect.w-cornerWidth-1 do |
|
410 |
begin |
|
411 |
copyToXY(SpritesData[edge].Surface, finalSurface, x, y); ///////////////// top edge |
|
412 |
inc(x,edgeWidth); |
|
413 |
end; |
|
414 |
flipSurface(SpritesData[edge].Surface, true); |
|
415 |
x:= cornerWidth; |
|
416 |
y:= textHeight + cornerHeight*2 - edgeHeight-1; |
|
417 |
while x < rect.w-cornerWidth-1 do |
|
418 |
begin |
|
419 |
copyToXY(SpritesData[edge].Surface, finalSurface, x, y); ///////////////// bottom edge |
|
420 |
inc(x,edgeWidth); |
|
421 |
end; |
|
422 |
flipSurface(SpritesData[edge].Surface, true); // restore original position |
|
423 |
||
424 |
rotatedEdge:= SDL_CreateRGBSurface(SDL_SWSURFACE, edgeHeight, edgeWidth, 32, RMask, GMask, BMask, AMask); |
|
425 |
x:= rect.w - edgeHeight - 1; |
|
426 |
y:= cornerHeight; |
|
427 |
//// initially was going to rotate in place, but the SDL spec claims width/height are read only |
|
428 |
copyRotatedSurface(SpritesData[edge].Surface,rotatedEdge); |
|
429 |
while y < textHeight + cornerHeight do |
|
430 |
begin |
|
431 |
copyToXY(rotatedEdge, finalSurface, x, y); |
|
432 |
inc(y,edgeWidth); |
|
433 |
end; |
|
434 |
flipSurface(rotatedEdge, false); // restore original position |
|
435 |
x:= 0; |
|
436 |
y:= cornerHeight; |
|
437 |
while y < textHeight + cornerHeight do |
|
438 |
begin |
|
439 |
copyToXY(rotatedEdge, finalSurface, x, y); |
|
440 |
inc(y,edgeWidth); |
|
441 |
end; |
|
442 |
//////////////////////////////// END EDGES ////////////////////////////////////// |
|
443 |
||
444 |
x:= cornerWidth; |
|
445 |
y:= textHeight + cornerHeight * 2 - edgeHeight - 1; |
|
446 |
copyToXY(SpritesData[tail].Surface, finalSurface, x, y); |
|
447 |
||
448 |
rect.x:= edgeHeight; |
|
449 |
rect.y:= edgeHeight; |
|
450 |
rect.w:= rect.w - edgeHeight * 2; |
|
451 |
rect.h:= textHeight + cornerHeight * 2 - edgeHeight * 2; |
|
452 |
i:= rect.w; |
|
453 |
j:= rect.h; |
|
454 |
SDL_FillRect(finalSurface, @rect, cWhiteColor); |
|
455 |
||
456 |
pos:= 1; prevpos:= 0; line:= 0; |
|
457 |
while pos <= length(s) do |
|
458 |
begin |
|
459 |
if (s[pos] = #1) or (pos = length(s)) then |
|
460 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
461 |
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
|
462 |
inc(pos); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
463 |
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
|
464 |
inc(prevpos); |
4380 | 465 |
substr:= copy(s, prevpos+1, pos-prevpos-1); |
466 |
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
|
467 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
468 |
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
|
469 |
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
|
470 |
// 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
|
471 |
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
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
inc(line); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
476 |
prevpos:= pos; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
477 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6286
diff
changeset
|
478 |
end; |
4380 | 479 |
inc(pos); |
480 |
end; |
|
481 |
||
482 |
RenderSpeechBubbleTex:= Surface2Tex(finalSurface, true); |
|
483 |
||
484 |
SDL_FreeSurface(rotatedEdge); |
|
485 |
SDL_FreeSurface(finalSurface); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7546
diff
changeset
|
486 |
|
4380 | 487 |
end; |
488 |
||
4611 | 489 |
end. |