55 end; |
55 end; |
56 |
56 |
57 var ConsoleLines: array[byte] of TTextLine; |
57 var ConsoleLines: array[byte] of TTextLine; |
58 CurrLine: LongInt = 0; |
58 CurrLine: LongInt = 0; |
59 InputStr: TTextLine; |
59 InputStr: TTextLine; |
|
60 InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char |
60 Variables: PVariable = nil; |
61 Variables: PVariable = nil; |
61 |
62 |
62 procedure SetLine(var tl: TTextLine; str: shortstring); |
63 procedure SetLine(var tl: TTextLine; str: shortstring); |
63 begin |
64 begin |
64 with tl do |
65 with tl do |
118 |
119 |
119 procedure DrawConsole(Surface: PSDL_Surface); |
120 procedure DrawConsole(Surface: PSDL_Surface); |
120 var x, y: LongInt; |
121 var x, y: LongInt; |
121 |
122 |
122 procedure DrawLine(var tl: TTextLine; X, Y: LongInt); |
123 procedure DrawLine(var tl: TTextLine; X, Y: LongInt); |
|
124 var tmpSurface: PSDL_Surface; |
123 begin |
125 begin |
124 with tl do |
126 with tl do |
125 begin |
127 begin |
126 if updatetex then |
128 if updatetex then |
127 begin |
129 begin |
128 if s[0] <> #0 then tex:= RenderStringTex(s, $FFFFFF, fnt16) |
130 if s[0] <> #0 then |
129 else tex:= nil; |
131 begin |
|
132 tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF); |
|
133 tex:= Surface2Tex(tmpSurface); |
|
134 SDL_FreeSurface(tmpSurface) |
|
135 end else tex:= nil; |
130 updatetex:= false |
136 updatetex:= false |
131 end; |
137 end; |
132 |
138 |
133 if tex <> nil then |
139 if tex <> nil then |
134 DrawTexture(X, Y, tex); |
140 DrawTexture(X, Y, tex); |
135 end |
141 end |
136 end; |
142 end; |
137 |
143 |
138 begin |
144 begin |
139 glEnable(GL_TEXTURE_2D); |
145 glEnable(GL_TEXTURE_2D); |
|
146 glEnable(GL_BLEND); |
140 |
147 |
141 for y:= 0 to cConsoleHeight div 256 + 1 do |
148 for y:= 0 to cConsoleHeight div 256 + 1 do |
142 for x:= 0 to cScreenWidth div 256 + 1 do |
149 for x:= 0 to cScreenWidth div 256 + 1 do |
143 DrawSprite(sprConsoleBG, x * 256, cConsoleHeight - 256 - y * 256, 0, Surface); |
150 DrawSprite(sprConsoleBG, x * 256, cConsoleHeight - 256 - y * 256, 0, Surface); |
144 |
151 |
145 for y:= 0 to cConsoleHeight div Fontz[fnt16].Height do |
152 for y:= 0 to cConsoleHeight div Fontz[fnt16].Height do |
146 DrawLine(ConsoleLines[(CurrLine - 1 - y + cLinesCount) mod cLinesCount], 4, cConsoleHeight - (y + 2) * (Fontz[fnt16].Height + 2)); |
153 DrawLine(ConsoleLines[(CurrLine - 1 - y + cLinesCount) mod cLinesCount], 4, cConsoleHeight - (y + 2) * (Fontz[fnt16].Height + 2)); |
147 |
154 |
148 DrawLine(InputStr, 4, cConsoleHeight - Fontz[fnt16].Height - 2); |
155 DrawLine(InputStr, 4, cConsoleHeight - Fontz[fnt16].Height - 2); |
149 |
156 |
|
157 glDisable(GL_BLEND); |
150 glDisable(GL_TEXTURE_2D); |
158 glDisable(GL_TEXTURE_2D); |
151 end; |
159 end; |
152 |
160 |
153 procedure WriteToConsole(s: shortstring); |
161 procedure WriteToConsole(s: shortstring); |
154 var Len: LongInt; |
162 var Len: LongInt; |
294 begin |
302 begin |
295 utf8:= char((Key or $80) and $BF) + utf8; |
303 utf8:= char((Key or $80) and $BF) + utf8; |
296 Key:= Key shr 6 |
304 Key:= Key shr 6 |
297 end; |
305 end; |
298 utf8:= char(Key or firstByteMark[btw]) + utf8; |
306 utf8:= char(Key or firstByteMark[btw]) + utf8; |
|
307 |
|
308 InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; |
299 SetLine(InputStr, InputStr.s + utf8) |
309 SetLine(InputStr, InputStr.s + utf8) |
300 end |
310 end |
301 end; |
311 end; |
302 |
312 |
303 function GetLastConsoleLine: shortstring; |
313 function GetLastConsoleLine: shortstring; |