branch | sdl2transition |
changeset 9699 | fab319c85a39 |
parent 9697 | 198c3ed28fe8 |
child 9798 | f2b18754742f |
9697:198c3ed28fe8 | 9699:fab319c85a39 |
---|---|
19 {$INCLUDE "options.inc"} |
19 {$INCLUDE "options.inc"} |
20 |
20 |
21 unit uChat; |
21 unit uChat; |
22 |
22 |
23 interface |
23 interface |
24 uses SDLh; |
|
24 |
25 |
25 procedure initModule; |
26 procedure initModule; |
26 procedure freeModule; |
27 procedure freeModule; |
27 procedure ReloadLines; |
28 procedure ReloadLines; |
28 procedure CleanupInput; |
29 procedure CleanupInput; |
29 procedure AddChatString(s: shortstring); |
30 procedure AddChatString(s: shortstring); |
30 procedure DrawChat; |
31 procedure DrawChat; |
32 procedure SendHogSpeech(s: shortstring); |
|
33 |
|
34 {$IFDEF SDL2} |
|
35 procedure KeyPressChat(Sym: Longword); |
|
36 procedure TextInput(var event: TSDL_TextInputEvent); |
|
37 {$ELSE} |
|
31 procedure KeyPressChat(Key, Sym: Longword); |
38 procedure KeyPressChat(Key, Sym: Longword); |
32 procedure SendHogSpeech(s: shortstring); |
39 {$ENDIF} |
33 |
40 |
34 implementation |
41 implementation |
35 uses SDLh, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO; |
42 uses uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO; |
36 |
43 |
37 const MaxStrIndex = 27; |
44 const MaxStrIndex = 27; |
38 |
45 |
39 type TChatLine = record |
46 type TChatLine = record |
40 Tex: PTexture; |
47 Tex: PTexture; |
313 {$ENDIF} |
320 {$ENDIF} |
314 GameState:= gsGame; |
321 GameState:= gsGame; |
315 ResetKbd; |
322 ResetKbd; |
316 end; |
323 end; |
317 |
324 |
325 {$IFDEF SDL2} |
|
326 procedure TextInput(var event: TSDL_TextInputEvent); |
|
327 var s: shortstring; |
|
328 l: byte; |
|
329 begin |
|
330 l:= 0; |
|
331 while event.text[l] <> #0 do |
|
332 begin |
|
333 s[l + 1]:= event.text[l]; |
|
334 inc(l) |
|
335 end; |
|
336 s[0]:= char(l); |
|
337 |
|
338 if byte(InputStr.s[0]) + l > 240 then exit; |
|
339 |
|
340 InputStrL[byte(InputStr.s[0]) + l]:= InputStr.s[0]; |
|
341 SetLine(InputStr, InputStr.s + s, true) |
|
342 end; |
|
343 |
|
344 procedure KeyPressChat(Sym: Longword); |
|
345 {$ELSE} |
|
318 procedure KeyPressChat(Key, Sym: Longword); |
346 procedure KeyPressChat(Key, Sym: Longword); |
347 {$ENDIF} |
|
319 const firstByteMark: array[0..3] of byte = (0, $C0, $E0, $F0); |
348 const firstByteMark: array[0..3] of byte = (0, $C0, $E0, $F0); |
320 var i, btw, index: integer; |
349 var i, btw, index: integer; |
321 utf8: shortstring; |
350 utf8: shortstring; |
322 action: boolean; |
351 action: boolean; |
323 begin |
352 begin |
362 // ignore me!!! |
391 // ignore me!!! |
363 end; |
392 end; |
364 else |
393 else |
365 action:= false; |
394 action:= false; |
366 end; |
395 end; |
396 |
|
397 {$IFNDEF SDL2} |
|
367 if not action and (Key <> 0) then |
398 if not action and (Key <> 0) then |
368 begin |
399 begin |
369 if (Key < $80) then |
400 if (Key < $80) then |
370 btw:= 1 |
401 btw:= 1 |
371 else if (Key < $800) then |
402 else if (Key < $800) then |
389 exit; |
420 exit; |
390 |
421 |
391 InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; |
422 InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; |
392 SetLine(InputStr, InputStr.s + utf8, true) |
423 SetLine(InputStr, InputStr.s + utf8, true) |
393 end |
424 end |
425 {$ENDIF} |
|
394 end; |
426 end; |
395 |
427 |
396 procedure chChatMessage(var s: shortstring); |
428 procedure chChatMessage(var s: shortstring); |
397 begin |
429 begin |
398 AddChatString(s) |
430 AddChatString(s) |