33 procedure SendHogSpeech(s: shortstring); |
33 procedure SendHogSpeech(s: shortstring); |
34 procedure CopyToClipboard(var newContent: shortstring); |
34 procedure CopyToClipboard(var newContent: shortstring); |
35 procedure TextInput(var event: TSDL_TextInputEvent); |
35 procedure TextInput(var event: TSDL_TextInputEvent); |
36 |
36 |
37 implementation |
37 implementation |
38 uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore; |
38 uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore, uLocale |
|
39 {$IFDEF USE_VIDEO_RECORDING}, uVideoRec{$ENDIF}; |
39 |
40 |
40 const MaxStrIndex = 27; |
41 const MaxStrIndex = 27; |
41 MaxInputStrLen = 200; |
42 MaxInputStrLen = 200; |
42 |
43 |
43 type TChatLine = record |
44 type TChatLine = record |
69 LastKeyPressTick: LongWord; |
70 LastKeyPressTick: LongWord; |
70 |
71 |
71 |
72 |
72 const |
73 const |
73 colors: array[#0..#9] of TSDL_Color = ( |
74 colors: array[#0..#9] of TSDL_Color = ( |
74 (r:$FF; g:$FF; b:$FF; a:$FF), // #0 unused, feel free to take it for anything |
75 (r:$FF; g:$FF; b:$00; a:$FF), // #0 warning message [Yellow] |
75 (r:$FF; g:$FF; b:$FF; a:$FF), // #1 chat message [White] |
76 (r:$FF; g:$FF; b:$FF; a:$FF), // #1 chat message [White] |
76 (r:$FF; g:$00; b:$FF; a:$FF), // #2 action message [Purple] |
77 (r:$FF; g:$00; b:$FF; a:$FF), // #2 action message [Purple] |
77 (r:$90; g:$FF; b:$90; a:$FF), // #3 join/leave message [Lime] |
78 (r:$90; g:$FF; b:$90; a:$FF), // #3 join/leave message [Lime] |
78 (r:$FF; g:$FF; b:$A0; a:$FF), // #4 team message [Light Yellow] |
79 (r:$FF; g:$FF; b:$A0; a:$FF), // #4 team message [Light Yellow] |
79 (r:$FF; g:$00; b:$00; a:$FF), // #5 error messages [Red] |
80 (r:$FF; g:$00; b:$00; a:$FF), // #5 error messages [Red] |
548 exit |
557 exit |
549 end; |
558 end; |
550 |
559 |
551 if (s[1] = '/') then |
560 if (s[1] = '/') then |
552 begin |
561 begin |
553 // These 3 are same as above, only are to make the hedgehog say it on next attack |
562 if (Length(s) <= 1) then |
|
563 begin |
|
564 // empty chat command |
|
565 AddChatString(#0 + shortstring(trcmd[sidCmdUnknown])); |
|
566 exit; |
|
567 end; |
|
568 |
|
569 // Ignore message-type commands with empty argument list |
|
570 if (copy(s, 2, 2) = 'me') and (Length(s) = 3) then |
|
571 exit; |
|
572 if ((copy(s, 2, 3) = 'hsa') or (copy(s, 2, 3) = 'hta') or (copy(s, 2, 3) = 'hya')) and (Length(s) = 4) then |
|
573 exit; |
|
574 if ((copy(s, 2, 4) = 'team') or (copy(s, 2, 4) = 'clan')) and (Length(s) = 5) then |
|
575 exit; |
|
576 |
|
577 // Speech bubble, but on next attack |
554 if (copy(s, 2, 4) = 'hsa ') then |
578 if (copy(s, 2, 4) = 'hsa ') then |
555 begin |
579 begin |
556 if CurrentTeam^.ExtDriven then |
580 if CurrentTeam^.ExtDriven then |
557 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
581 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
558 else |
582 else |
559 SendHogSpeech(#4 + copy(s, 6, Length(s)-5)); |
583 SendHogSpeech(#4 + copy(s, 6, Length(s)-5)); |
560 exit |
584 exit |
561 end; |
585 end; |
562 |
586 |
|
587 // Thinking bubble, but on next attack |
563 if (copy(s, 2, 4) = 'hta ') then |
588 if (copy(s, 2, 4) = 'hta ') then |
564 begin |
589 begin |
565 if CurrentTeam^.ExtDriven then |
590 if CurrentTeam^.ExtDriven then |
566 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
591 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
567 else |
592 else |
568 SendHogSpeech(#5 + copy(s, 6, Length(s)-5)); |
593 SendHogSpeech(#5 + copy(s, 6, Length(s)-5)); |
569 exit |
594 exit |
570 end; |
595 end; |
571 |
596 |
|
597 // Yelling bubble, but on next attack |
572 if (copy(s, 2, 4) = 'hya ') then |
598 if (copy(s, 2, 4) = 'hya ') then |
573 begin |
599 begin |
574 if CurrentTeam^.ExtDriven then |
600 if CurrentTeam^.ExtDriven then |
575 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
601 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
576 else |
602 else |
577 SendHogSpeech(#6 + copy(s, 6, Length(s)-5)); |
603 SendHogSpeech(#6 + copy(s, 6, Length(s)-5)); |
578 exit |
604 exit |
579 end; |
605 end; |
580 |
606 |
581 if (copy(s, 2, 5) = 'team ') and (length(s) > 6) then |
607 // "/clan" or "/team" ("/team" is an alias for "/clan") |
582 begin |
608 if ((copy(s, 2, 5) = 'clan ') or (copy(s, 2, 5) = 'team ')) then |
583 ParseCommand(s, true); |
609 begin |
|
610 if (Length(s) > 6) then |
|
611 ParseCommand('team ' + copy(s, 7, Length(s) - 6), true); |
584 exit |
612 exit |
585 end; |
613 end; |
586 |
614 |
587 if (copy(s, 2, 3) = 'me ') then |
615 if (copy(s, 2, 3) = 'me ') then |
588 begin |
616 begin |
598 exit |
626 exit |
599 end; |
627 end; |
600 |
628 |
601 // debugging commands |
629 // debugging commands |
602 if (copy(s, 2, 7) = 'debugvl') then |
630 if (copy(s, 2, 7) = 'debugvl') then |
|
631 // This command intentionally not documented in /help |
603 begin |
632 begin |
604 cViewLimitsDebug:= (not cViewLimitsDebug); |
633 cViewLimitsDebug:= (not cViewLimitsDebug); |
605 UpdateViewLimits(); |
634 UpdateViewLimits(); |
606 exit |
635 exit |
607 end; |
636 end; |
608 |
637 |
609 if (copy(s, 2, 3) = 'lua') then |
638 if (copy(s, 2, 3) = 'lua') then |
610 begin |
639 begin |
|
640 LuaCmdUsed:= true; |
611 AddFileLog('/lua issued'); |
641 AddFileLog('/lua issued'); |
|
642 {$IFDEF USE_VIDEO_RECORDING} |
|
643 if flagPrerecording then |
|
644 begin |
|
645 AddFileLog('Force-stopping prerecording! Lua commands can not be recorded'); |
|
646 StopPreRecording; |
|
647 end; |
|
648 {$ENDIF} |
612 if gameType <> gmtNet then |
649 if gameType <> gmtNet then |
613 begin |
650 begin |
614 liveLua:= (not liveLua); |
651 liveLua:= (not liveLua); |
615 if liveLua then |
652 if liveLua then |
616 begin |
653 begin |
617 AddFileLog('[Lua] chat input string parsing enabled'); |
654 AddFileLog('[Lua] chat input string parsing enabled'); |
618 AddChatString(#3 + 'Lua parsing: ON'); |
655 AddChatString(#3 + shortstring(trmsg[sidLuaParsingOn])); |
619 end |
656 end |
620 else |
657 else |
621 begin |
658 begin |
622 AddFileLog('[Lua] chat input string parsing disabled'); |
659 AddFileLog('[Lua] chat input string parsing disabled'); |
623 AddChatString(#3 + 'Lua parsing: OFF'); |
660 AddChatString(#3 + shortstring(trmsg[sidLuaParsingOff])); |
624 end; |
661 end; |
625 UpdateInputLinePrefix(); |
662 UpdateInputLinePrefix(); |
626 end; |
663 end |
|
664 else |
|
665 AddChatString(#5 + shortstring(trmsg[sidLuaParsingDenied])); |
|
666 exit |
|
667 end; |
|
668 |
|
669 // Help commands |
|
670 if (copy(s, 2, 11) = 'help taunts') then |
|
671 begin |
|
672 AddChatString(#3 + shortstring(trcmd[sidCmdHeaderTaunts])); |
|
673 AddChatString(#3 + shortstring(trcmd[sidCmdSpeech])); |
|
674 AddChatString(#3 + shortstring(trcmd[sidCmdThink])); |
|
675 AddChatString(#3 + shortstring(trcmd[sidCmdYell])); |
|
676 AddChatString(#3 + shortstring(trcmd[sidCmdSpeechNumberHint])); |
|
677 AddChatString(#3 + shortstring(trcmd[sidCmdHsa])); |
|
678 AddChatString(#3 + shortstring(trcmd[sidCmdHta])); |
|
679 AddChatString(#3 + shortstring(trcmd[sidCmdHya])); |
|
680 AddChatString(#3 + shortstring(trcmd[sidCmdHurrah])); |
|
681 AddChatString(#3 + shortstring(trcmd[sidCmdIlovelotsoflemonade])); |
|
682 AddChatString(#3 + shortstring(trcmd[sidCmdJuggle])); |
|
683 AddChatString(#3 + shortstring(trcmd[sidCmdRollup])); |
|
684 AddChatString(#3 + shortstring(trcmd[sidCmdShrug])); |
|
685 AddChatString(#3 + shortstring(trcmd[sidCmdWave])); |
|
686 exit |
|
687 end; |
|
688 |
|
689 if (copy(s, 2, 9) = 'help room') then |
|
690 begin |
|
691 if (gameType = gmtNet) then |
|
692 SendConsoleCommand('/help') |
|
693 else |
|
694 AddChatString(#0 + shortstring(trcmd[sidCmdHelpRoomFail])); |
|
695 exit; |
|
696 end; |
|
697 |
|
698 if (copy(s, 2, 4) = 'help') then |
|
699 begin |
|
700 AddChatString(#3 + shortstring(trcmd[sidCmdHeaderBasic])); |
|
701 if gameType = gmtNet then |
|
702 AddChatString(#3 + shortstring(trcmd[sidCmdPauseNet])) |
|
703 else |
|
704 AddChatString(#3 + shortstring(trcmd[sidCmdPause])); |
|
705 AddChatString(#3 + shortstring(trcmd[sidCmdFullscreen])); |
|
706 AddChatString(#3 + shortstring(trcmd[sidCmdQuit])); |
|
707 if gameType <> gmtNet then |
|
708 AddChatString(#3 + shortstring(trcmd[sidLua])); |
|
709 // history and help commands needs to be close to the end because they are always visible |
|
710 // with a short chat history length. |
|
711 AddChatString(#3 + shortstring(trcmd[sidCmdTeam])); |
|
712 AddChatString(#3 + shortstring(trcmd[sidCmdMe])); |
|
713 AddChatString(#3 + shortstring(trcmd[sidCmdTogglechat])); |
|
714 AddChatString(#3 + shortstring(trcmd[sidCmdHistory])); |
|
715 AddChatString(#3 + shortstring(trcmd[sidCmdHelp])); |
|
716 AddChatString(#3 + shortstring(trcmd[sidCmdHelpTaunts])); |
|
717 if gameType = gmtNet then |
|
718 AddChatString(#3 + shortstring(trcmd[sidCmdHelpRoom])); |
627 exit |
719 exit |
628 end; |
720 end; |
629 |
721 |
630 // hedghog animations/taunts and engine commands |
722 // hedghog animations/taunts and engine commands |
631 if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then |
723 if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then |