1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2019 EDuke32 developers and contributors
4 Copyright (C) 2019 Nuke.YKT
5 
6 This file is part of NBlood.
7 
8 NBlood is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License version 2
10 as published by the Free Software Foundation.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 */
22 //-------------------------------------------------------------------------
23 #pragma once
24 
25 #include "compat.h"
26 #include "build.h"
27 #include "player.h"
28 
29 #define kMessageLogSize 32
30 #define kMaxMessageTextLength 81
31 
32 enum MESSAGE_PRIORITY {
33     MESSAGE_PRIORITY_PICKUP = -10,
34     MESSAGE_PRIORITY_NORMAL = 0,
35     MESSAGE_PRIORITY_SECRET = 10,
36     MESSAGE_PRIORITY_INI = 20,
37     MESSAGE_PRIORITY_SYSTEM = 100
38 };
39 
40 class CGameMessageMgr
41 {
42 public:
43     struct messageStruct
44     {
45         ClockTicks lastTickWhenVisible;
46         char text[kMaxMessageTextLength];
47         int pal;
48         MESSAGE_PRIORITY priority;
49         bool deleted = false;
50     };
51     char state;
52     int x;
53     int y;
54     ClockTicks at9;
55     ClockTicks atd;
56     int nFont;
57     int fontHeight;
58     int maxNumberOfMessagesToDisplay;
59     int visibilityDurationInSecs;
60     char messageFlags;
61     int numberOfDisplayedMessages;
62     int messagesIndex;
63     int nextMessagesIndex;
64     messageStruct messages[kMessageLogSize];
65     CGameMessageMgr();
66     void SetState(char state);
67     void Add(const char *pText, char a2, const int pal = 0, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL);
68     void Display(void);
69     void Clear();
70     void SetMaxMessages(int nMessages);
71     void SetFont(int nFont);
72     void SetCoordinates(int x, int y);
73     void SetMessageTime(int nTime);
74     void SetMessageFlags(unsigned int nFlags);
75 private:
76     void SortMessagesByPriority(messageStruct** messages, int count);
77     void SortMessagesByTime(messageStruct** messages, int count);
78 };
79 
80 
81 class CPlayerMsg
82 {
83 public:
84     int at0;
85     char text[41];
CPlayerMsg()86     CPlayerMsg() { at0 = 0; text[0] = 0; }
87     void Clear(void);
88     void Term(void);
89     void Draw(void);
90     bool AddChar(char);
91     void DelChar(void);
92     void Set(const char *pzString);
93     void Send(void);
94     void ProcessKeys(void);
95 private:
96     bool IsWhitespaceOnly(const char* const pzString);
97 };
98 
99 class CCheatMgr
100 {
101 public:
102     static bool m_bPlayerCheated;
103     enum CHEATCODE
104     {
105         kCheatNone = 0,
106         kCheat1, // refills ammo, no cheat code for it
107         kCheatGriswold,
108         kCheatSatchel,
109         kCheatEvaGalli,
110         kCheatMpkfa,
111         kCheatCapInMyAss,
112         kCheatNoCapInMyAss,
113         kCheatIdaho,
114         kCheatKevorkian,
115         kCheatMcGee,
116         kCheatEdmark,
117         kCheatKrueger,
118         kCheatSterno,
119         kCheat14, // quake effect, not used
120         kCheatSpork,
121         kCheatGoonies,
122         kCheatClarice,
123         kCheatFrankenstein,
124         kCheatCheeseHead,
125         kCheatTequila,
126         kCheatFunkyShoes,
127         kCheatKeyMaster,
128         kCheatOneRing,
129         kCheatVoorhees,
130         kCheatJoJo,
131         kCheatGateKeeper,
132         kCheatRate,
133         kCheatMario,
134         kCheatLaraCroft,
135         kCheatHongKong,
136         kCheatMontana,
137         kCheatBunz,
138         kCheatCousteau,
139         kCheatForkYou,
140         kCheatLieberMan,
141         kCheatSpielberg,
142         kCheatCalgon,
143         kCheatMax
144     };
145     struct CHEATINFO
146     {
147         const char* pzString;
148         CHEATCODE id;
149         int flags;
150     };
151     static CHEATINFO s_CheatInfo[];
CCheatMgr()152     CCheatMgr() {}
153     bool Check(char *pzString);
154     void Process(CHEATCODE nCheatCode, char* pzArgs);
155     void sub_5BCF4(void);
156 };
157 
158 extern CPlayerMsg gPlayerMsg;
159 extern CCheatMgr gCheatMgr;
160 
161 void SetAmmo(bool stat);
162 void SetWeapons(bool stat);
163 void SetToys(bool stat);
164 void SetArmor(bool stat);
165 void SetKeys(bool stat);
166 void SetGodMode(bool god);
167 void SetClipMode(bool noclip);
168