engine: reject mbf21 and shit24 wads. there is no way to know if it is safe to ignore...
[k8vavoom.git] / source / chat.cpp
blobc0105d0a8424c32d878eff045ad3d2e2ed2bfdca
1 //**************************************************************************
2 //**
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
9 //**
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
12 //**
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
16 //**
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
21 //**
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //**
25 //**************************************************************************
26 #include "gamedefs.h"
27 #include "chat.h"
28 #include "iline.h"
29 #include "input.h"
30 #include "text.h"
33 bool chatmodeon;
36 static TILine w_chat(80);
37 static VCvarS ChatMacro0("Chatmacro0", "No", "Chat macro #0.", CVAR_Archive|CVAR_NoShadow);
38 static VCvarS ChatMacro1("Chatmacro1", "I'm ready to kick butt!", "Chat macro #1.", CVAR_Archive|CVAR_NoShadow);
39 static VCvarS ChatMacro2("Chatmacro2", "I'm OK.", "Chat macro #2.", CVAR_Archive|CVAR_NoShadow);
40 static VCvarS ChatMacro3("Chatmacro3", "I'm not looking too good!", "Chat macro #3.", CVAR_Archive|CVAR_NoShadow);
41 static VCvarS ChatMacro4("Chatmacro4", "Help!", "Chat macro #4.", CVAR_Archive|CVAR_NoShadow);
42 static VCvarS ChatMacro5("Chatmacro5", "You suck!", "Chat macro #5.", CVAR_Archive|CVAR_NoShadow);
43 static VCvarS ChatMacro6("Chatmacro6", "Next time, scumbag...", "Chat macro #6.", CVAR_Archive|CVAR_NoShadow);
44 static VCvarS ChatMacro7("Chatmacro7", "Come here!", "Chat macro #7.", CVAR_Archive|CVAR_NoShadow);
45 static VCvarS ChatMacro8("Chatmacro8", "I'll take care of it.", "Chat macro #8.", CVAR_Archive|CVAR_NoShadow);
46 static VCvarS ChatMacro9("Chatmacro9", "Yes", "Chat macro #9.", CVAR_Archive|CVAR_NoShadow);
47 static VCvarS *chat_macros[10] = {
48 &ChatMacro0,
49 &ChatMacro1,
50 &ChatMacro2,
51 &ChatMacro3,
52 &ChatMacro4,
53 &ChatMacro5,
54 &ChatMacro6,
55 &ChatMacro7,
56 &ChatMacro8,
57 &ChatMacro9,
61 //===========================================================================
63 // CT_Init
65 // Initialise chat mode data
67 //===========================================================================
68 void CT_Init () {
69 w_chat.SetVisChars(42);
70 chatmodeon = false;
74 //===========================================================================
76 // CT_Stop
78 //===========================================================================
79 static void CT_Stop () {
80 chatmodeon = false;
84 //===========================================================================
86 // CT_Responder
88 //===========================================================================
89 bool CT_Responder (event_t *ev) {
90 if (!chatmodeon) return false;
92 if (GInput->AltDown) {
93 if (ev->type != ev_keyup) return true;
94 if (ev->keycode >= '0' && ev->keycode <= '9') {
95 GCmdBuf << "Say " << VStr(chat_macros[ev->keycode-'0']->asStr()).quote() << "\n";
96 CT_Stop();
97 return true;
101 if (ev->keycode == K_ENTER || ev->keycode == K_PADENTER) {
102 if (ev->type != ev_keyup) return true;
103 if (w_chat.length() != 0) {
104 GCmdBuf << "Say " << VStr(w_chat.getCStr()).quote(true) << "\n";
106 CT_Stop();
107 return true;
110 if (ev->keycode == K_ESCAPE) {
111 if (ev->type != ev_keyup) return true;
112 CT_Stop();
113 return true;
116 if (ev->type != ev_keydown) return true;
117 return w_chat.Key(*ev);
121 //==========================================================================
123 // COMMAND ChatMode
125 //==========================================================================
126 COMMAND(ChatMode) {
127 w_chat.Init();
128 chatmodeon = true;
132 //===========================================================================
134 // CT_Drawer
136 //===========================================================================
137 void CT_Drawer () {
138 if (chatmodeon) {
139 T_SetFont(SmallFont);
140 T_SetAlign(hleft, vtop);
141 w_chat.DrawAt(25, 92, /*CR_UNTRANSLATED*/CR_GREEN);