60 procedure DrawCentered(X, Top: LongInt; Source: PTexture); |
60 procedure DrawCentered(X, Top: LongInt; Source: PTexture); |
61 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
61 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
62 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
62 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
63 procedure DrawFillRect(r: TSDL_Rect); |
63 procedure DrawFillRect(r: TSDL_Rect); |
64 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
64 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
65 function CheckCJKFont(s: string; font: THWFont): THWFont; |
65 function CheckCJKFont(s: ansistring; font: THWFont): THWFont; |
66 function RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture; |
66 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
67 function RenderSpeechBubbleTex(s: string; SpeechType: Longword; font: THWFont): PTexture; |
67 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
68 procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); |
68 procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); |
69 //procedure rotateSurface(Surface: PSDL_Surface); |
69 //procedure rotateSurface(Surface: PSDL_Surface); |
70 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
70 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
71 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: Integer); |
71 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: Integer); |
72 procedure RenderHealth(var Hedgehog: THedgehog); |
72 procedure RenderHealth(var Hedgehog: THedgehog); |
73 procedure AddProgress; |
73 procedure AddProgress; |
74 procedure FinishProgress; |
74 procedure FinishProgress; |
75 function LoadImage(const filename: string; imageFlags: LongInt): PSDL_Surface; |
75 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
76 procedure SetupOpenGL; |
76 procedure SetupOpenGL; |
77 procedure SetScale(f: GLfloat); |
77 procedure SetScale(f: GLfloat); |
78 function RenderHelpWindow(caption, subcaption, description, extra: shortstring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
78 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
79 procedure RenderWeaponTooltip(atype: TAmmoType); |
79 procedure RenderWeaponTooltip(atype: TAmmoType); |
80 procedure ShowWeaponTooltip(x, y: LongInt); |
80 procedure ShowWeaponTooltip(x, y: LongInt); |
81 procedure FreeWeaponTooltip; |
81 procedure FreeWeaponTooltip; |
82 |
82 |
83 implementation |
83 implementation |
144 finalRect.w:= w + FontBorder * 2 + 4; |
144 finalRect.w:= w + FontBorder * 2 + 4; |
145 finalRect.h:= h + FontBorder * 2; |
145 finalRect.h:= h + FontBorder * 2; |
146 WriteInRoundRect:= finalRect; |
146 WriteInRoundRect:= finalRect; |
147 end; |
147 end; |
148 |
148 |
149 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: string): TSDL_Rect; |
149 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
150 var w, h: LongInt; |
150 var w, h: LongInt; |
151 tmpsurf: PSDL_Surface; |
151 tmpsurf: PSDL_Surface; |
152 clr: TSDL_Color; |
152 clr: TSDL_Color; |
153 finalRect: TSDL_Rect; |
153 finalRect: TSDL_Rect; |
154 begin |
154 begin |
822 (* two more to check. pascal WideChar is only 16 bit though |
822 (* two more to check. pascal WideChar is only 16 bit though |
823 ((#$20000 <= u) and (u >= #$2A6DF)) or // CJK Unified Ideographs Extension B |
823 ((#$20000 <= u) and (u >= #$2A6DF)) or // CJK Unified Ideographs Extension B |
824 ((#$2F800 <= u) and (u >= #$2FA1F))) // CJK Compatibility Ideographs Supplement *) |
824 ((#$2F800 <= u) and (u >= #$2FA1F))) // CJK Compatibility Ideographs Supplement *) |
825 end; |
825 end; |
826 |
826 |
827 function RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture; |
827 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; |
828 var w, h : LongInt; |
828 var w, h : LongInt; |
829 finalSurface: PSDL_Surface; |
829 finalSurface: PSDL_Surface; |
830 begin |
830 begin |
831 if length(s) = 0 then s:= ' '; |
831 if length(s) = 0 then s:= ' '; |
832 font:= CheckCJKFont(s, font); |
832 font:= CheckCJKFont(s, font); |
844 RenderStringTex:= Surface2Tex(finalSurface, false); |
844 RenderStringTex:= Surface2Tex(finalSurface, false); |
845 |
845 |
846 SDL_FreeSurface(finalSurface); |
846 SDL_FreeSurface(finalSurface); |
847 end; |
847 end; |
848 |
848 |
849 function RenderSpeechBubbleTex(s: string; SpeechType: Longword; font: THWFont): PTexture; |
849 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; |
850 var textWidth, textHeight, x, y, w, h, i, j, pos, prevpos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt; |
850 var textWidth, textHeight, x, y, w, h, i, j, pos, prevpos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt; |
851 finalSurface, tmpsurf, rotatedEdge: PSDL_Surface; |
851 finalSurface, tmpsurf, rotatedEdge: PSDL_Surface; |
852 rect: TSDL_Rect; |
852 rect: TSDL_Rect; |
853 chars: TSysCharSet = [#9,' ','.',';',':','?','!',',']; |
853 chars: TSysCharSet = [#9,' ','.',';',':','?','!',',']; |
854 substr: shortstring; |
854 substr: shortstring; |
1036 if Hedgehog.HealthTagTex <> nil then |
1036 if Hedgehog.HealthTagTex <> nil then |
1037 FreeTexture(Hedgehog.HealthTagTex); |
1037 FreeTexture(Hedgehog.HealthTagTex); |
1038 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) |
1038 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) |
1039 end; |
1039 end; |
1040 |
1040 |
1041 function LoadImage(const filename: string; imageFlags: LongInt): PSDL_Surface; |
1041 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
1042 var tmpsurf: PSDL_Surface; |
1042 var tmpsurf: PSDL_Surface; |
1043 s: shortstring; |
1043 s: shortstring; |
1044 begin |
1044 begin |
1045 WriteToConsole(msgLoading + filename + ' [flags: ' + inttostr(imageFlags) + ']... '); |
1045 WriteToConsole(msgLoading + filename + ' [flags: ' + inttostr(imageFlags) + ']... '); |
1046 |
1046 |
1136 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); |
1136 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); |
1137 {$ENDIF} |
1137 {$ENDIF} |
1138 |
1138 |
1139 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
1139 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
1140 |
1140 |
1141 vendor:= LowerCase(string(pchar(glGetString(GL_VENDOR)))); |
1141 vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR)))); |
1142 {$IFDEF DEBUGFILE} |
1142 {$IFDEF DEBUGFILE} |
1143 AddFileLog('OpenGL-- Renderer: ' + string(pchar(glGetString(GL_RENDERER)))); |
1143 AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); |
1144 AddFileLog(' |----- Vendor: ' + vendor); |
1144 AddFileLog(' |----- Vendor: ' + vendor); |
1145 AddFileLog(' |----- Version: ' + string(pchar(glGetString(GL_VERSION)))); |
1145 AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); |
1146 AddFileLog(' \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); |
1146 AddFileLog(' \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); |
1147 {$ENDIF} |
1147 {$ENDIF} |
1148 |
1148 |
1149 if MaxTextureSize <= 0 then |
1149 if MaxTextureSize <= 0 then |
1150 begin |
1150 begin |
1343 destPixels^[j]:= srcPixels^[i]; |
1343 destPixels^[j]:= srcPixels^[i]; |
1344 inc(j) |
1344 inc(j) |
1345 end; |
1345 end; |
1346 end; |
1346 end; |
1347 |
1347 |
1348 function RenderHelpWindow(caption, subcaption, description, extra: shortstring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
1348 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
1349 var tmpsurf: PSDL_SURFACE; |
1349 var tmpsurf: PSDL_SURFACE; |
1350 w, h, i, j: LongInt; |
1350 w, h, i, j: LongInt; |
1351 font: THWFont; |
1351 font: THWFont; |
1352 r, r2: TSDL_Rect; |
1352 r, r2: TSDL_Rect; |
1353 wa, ha: LongInt; |
1353 wa, ha: LongInt; |
1354 tmpline, tmpline2, tmpdesc: shortstring; |
1354 tmpline, tmpline2, tmpdesc: ansistring; |
1355 begin |
1355 begin |
1356 // make sure there is a caption as well as a sub caption - description is optional |
1356 // make sure there is a caption as well as a sub caption - description is optional |
1357 if caption = '' then caption:= '???'; |
1357 if caption = '' then caption:= '???'; |
1358 if subcaption = '' then subcaption:= ' '; |
1358 if subcaption = '' then subcaption:= ' '; |
1359 |
1359 |