24 uses SDLh, uTypes; |
24 uses SDLh, uTypes; |
25 |
25 |
26 procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); |
26 procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); |
27 |
27 |
28 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
28 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
29 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline; |
29 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); |
30 procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt); |
30 procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt); |
31 |
31 |
32 function GetSurfaceFrameCoordinateX(Surface: PSDL_Surface; Frame, frameWidth, frameHeight: LongInt): LongInt; |
32 function GetSurfaceFrameCoordinateX(Surface: PSDL_Surface; Frame, frameWidth, frameHeight: LongInt): LongInt; |
33 function GetSurfaceFrameCoordinateY(Surface: PSDL_Surface; Frame, frameHeight: LongInt): LongInt; |
33 function GetSurfaceFrameCoordinateY(Surface: PSDL_Surface; Frame, frameHeight: LongInt): LongInt; |
34 |
34 |
35 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline; |
35 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); |
36 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt); |
36 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt); |
37 procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte); |
37 procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte); |
38 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
38 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
39 |
39 |
40 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
40 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
41 function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
41 function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; |
42 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
42 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
43 |
43 |
44 function IsTooDarkToRead(TextColor: Longword): boolean; inline; |
44 function IsTooDarkToRead(TextColor: Longword): boolean; |
45 |
45 |
46 implementation |
46 implementation |
47 uses uVariables, uConsts, uTextures, SysUtils, uUtils, uDebug; |
47 uses uVariables, uConsts, uTextures, SysUtils, uUtils, uDebug; |
48 |
48 |
49 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
49 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
97 ny:= Surface^.h div frameHeight; // number of vertical frames |
97 ny:= Surface^.h div frameHeight; // number of vertical frames |
98 if ny = 0 then ny:= 1; // one frame is minimum |
98 if ny = 0 then ny:= 1; // one frame is minimum |
99 GetSurfaceFrameCoordinateY:= (Frame mod ny) * frameHeight; |
99 GetSurfaceFrameCoordinateY:= (Frame mod ny) * frameHeight; |
100 end; |
100 end; |
101 |
101 |
102 function IsTooDarkToRead(TextColor: LongWord): boolean; inline; |
102 function IsTooDarkToRead(TextColor: LongWord): boolean; |
103 var clr: TSDL_Color; |
103 var clr: TSDL_Color; |
104 begin |
104 begin |
105 clr.r:= (TextColor shr 16) and $FF; |
105 clr.r:= (TextColor shr 16) and $FF; |
106 clr.g:= (TextColor shr 8) and $FF; |
106 clr.g:= (TextColor shr 8) and $FF; |
107 clr.b:= TextColor and $FF; |
107 clr.b:= TextColor and $FF; |
176 pixels^[j]:= tmpPixel; |
176 pixels^[j]:= tmpPixel; |
177 end; |
177 end; |
178 SDL_UnlockSurface(Surface); |
178 SDL_UnlockSurface(Surface); |
179 end; |
179 end; |
180 |
180 |
181 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline; |
181 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); |
182 begin |
182 begin |
183 // copy from complete src |
183 // copy from complete src |
184 copyToXYFromRect(src, dest, 0, 0, src^.w, src^.h, destX, destY); |
184 copyToXYFromRect(src, dest, 0, 0, src^.w, src^.h, destX, destY); |
185 end; |
185 end; |
186 |
186 |
252 |
252 |
253 SDL_UnlockSurface(src); |
253 SDL_UnlockSurface(src); |
254 SDL_UnlockSurface(dest); |
254 SDL_UnlockSurface(dest); |
255 end; |
255 end; |
256 |
256 |
257 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline; |
257 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); |
258 begin |
258 begin |
259 DrawSpriteFrame2Surf(sprite, dest, x, y, 0); |
259 DrawSpriteFrame2Surf(sprite, dest, x, y, 0); |
260 end; |
260 end; |
261 |
261 |
262 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y,frame: LongInt); |
262 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y,frame: LongInt); |