25 |
25 |
26 procedure initModule; |
26 procedure initModule; |
27 procedure freeModule; |
27 procedure freeModule; |
28 procedure ReloadLines; |
28 procedure ReloadLines; |
29 procedure CleanupInput; |
29 procedure CleanupInput; |
|
30 procedure CloseChat; |
|
31 procedure RestoreChat; |
30 procedure AddChatString(s: shortstring); |
32 procedure AddChatString(s: shortstring); |
31 procedure DrawChat; |
33 procedure DrawChat; |
32 procedure KeyPressChat(keysym: TSDL_Keysym); |
34 procedure KeyPressChat(keysym: TSDL_Keysym); |
33 procedure SendHogSpeech(s: shortstring); |
35 procedure SendHogSpeech(s: shortstring); |
34 procedure CopyToClipboard(var newContent: shortstring); |
36 procedure CopyToClipboard(var newContent: shortstring); |
52 TChatCmd = (ccQuit, ccPause, ccShowHistory, ccFullScreen); |
54 TChatCmd = (ccQuit, ccPause, ccShowHistory, ccFullScreen); |
53 |
55 |
54 var Strs: array[0 .. MaxStrIndex] of TChatLine; |
56 var Strs: array[0 .. MaxStrIndex] of TChatLine; |
55 MStrs: array[0 .. MaxStrIndex] of shortstring; |
57 MStrs: array[0 .. MaxStrIndex] of shortstring; |
56 LocalStrs: array[0 .. MaxStrIndex] of shortstring; |
58 LocalStrs: array[0 .. MaxStrIndex] of shortstring; |
|
59 oldInput: shortstring; |
57 missedCount: LongWord; |
60 missedCount: LongWord; |
58 lastStr: LongWord; |
61 lastStr: LongWord; |
59 localLastStr: LongInt; |
62 localLastStr: LongInt; |
60 history: LongInt; |
63 history: LongInt; |
61 visibleCount: LongWord; |
64 visibleCount: LongWord; |
780 //SDL_EnableKeyRepeat(0,0); |
783 //SDL_EnableKeyRepeat(0,0); |
781 isInChatMode:= false; |
784 isInChatMode:= false; |
782 ResetKbd; |
785 ResetKbd; |
783 end; |
786 end; |
784 |
787 |
|
788 procedure OpenChat(s: shortstring); |
|
789 var i: Integer; |
|
790 begin |
|
791 if GameState = gsConfirm then |
|
792 ParseCommand('quit', true); |
|
793 isInChatMode:= true; |
|
794 SDL_StopTextInput(); |
|
795 SDL_StartTextInput(); |
|
796 //Make REALLY sure unexpected events are flushed (1 time is insufficient as of SDL 2.0.7) |
|
797 for i := 1 to 2 do |
|
798 begin |
|
799 SDL_PumpEvents(); |
|
800 SDL_FlushEvent(SDL_TEXTINPUT); |
|
801 end; |
|
802 if length(s) = 0 then |
|
803 SetLine(InputStr, '', true) |
|
804 else |
|
805 begin |
|
806 SetLine(InputStr, s, true); |
|
807 cursorPos:= length(s); |
|
808 UpdateCursorCoords(); |
|
809 end; |
|
810 end; |
|
811 |
|
812 procedure CloseChat; |
|
813 begin |
|
814 oldInput:= InputStr.s; |
|
815 SetLine(InputStr, '', true); |
|
816 ResetCursor(); |
|
817 CleanupInput(); |
|
818 end; |
|
819 |
|
820 procedure RestoreChat; |
|
821 begin |
|
822 if length(oldInput) > 0 then |
|
823 OpenChat(oldInput); |
|
824 oldInput:= ''; |
|
825 end; |
|
826 |
785 procedure DelBytesFromInputStrBack(endIdx: integer; count: byte); |
827 procedure DelBytesFromInputStrBack(endIdx: integer; count: byte); |
786 var startIdx: integer; |
828 var startIdx: integer; |
787 begin |
829 begin |
788 // nothing to do if count is 0 |
830 // nothing to do if count is 0 |
789 if count = 0 then |
831 if count = 0 then |
1060 if Length(InputStr.s) > 0 then |
1102 if Length(InputStr.s) > 0 then |
1061 begin |
1103 begin |
1062 SetLine(InputStr, '', true); |
1104 SetLine(InputStr, '', true); |
1063 ResetCursor(); |
1105 ResetCursor(); |
1064 end |
1106 end |
1065 else CleanupInput |
1107 else |
|
1108 CleanupInput; |
|
1109 oldInput:= ''; |
1066 end; |
1110 end; |
1067 SDL_SCANCODE_RETURN, SDL_SCANCODE_KP_ENTER: |
1111 SDL_SCANCODE_RETURN, SDL_SCANCODE_KP_ENTER: |
1068 begin |
1112 begin |
1069 if Length(InputStr.s) > 0 then |
1113 if Length(InputStr.s) > 0 then |
1070 begin |
1114 begin |
1335 inc(visibleCount); |
1379 inc(visibleCount); |
1336 end; |
1380 end; |
1337 end; |
1381 end; |
1338 |
1382 |
1339 procedure chChat(var s: shortstring); |
1383 procedure chChat(var s: shortstring); |
1340 var i: Integer; |
|
1341 begin |
1384 begin |
1342 s:= s; // avoid compiler hint |
1385 s:= s; // avoid compiler hint |
1343 isInChatMode:= true; |
|
1344 SDL_StopTextInput(); |
|
1345 SDL_StartTextInput(); |
|
1346 //Make REALLY sure unexpected events are flushed (1 time is insufficient as of SDL 2.0.7) |
|
1347 for i := 1 to 2 do |
|
1348 begin |
|
1349 SDL_PumpEvents(); |
|
1350 SDL_FlushEvent(SDL_TEXTINPUT); |
|
1351 end; |
|
1352 //SDL_EnableKeyRepeat(200,45); |
|
1353 if length(s) = 0 then |
1386 if length(s) = 0 then |
1354 SetLine(InputStr, '', true) |
1387 OpenChat('') |
1355 else |
1388 else |
1356 begin |
1389 OpenChat('/clan '); |
1357 SetLine(InputStr, '/clan ', true); |
|
1358 cursorPos:= 6; |
|
1359 UpdateCursorCoords(); |
|
1360 end; |
|
1361 end; |
1390 end; |
1362 |
1391 |
1363 procedure initModule; |
1392 procedure initModule; |
1364 var i: ShortInt; |
1393 var i: ShortInt; |
1365 begin |
1394 begin |