forked from bradharding/doomretro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_console.h
280 lines (230 loc) · 10 KB
/
c_console.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
==============================================================================
DOOM Retro
The classic, refined DOOM source port. For Windows PC.
==============================================================================
Copyright © 1993-2024 by id Software LLC, a ZeniMax Media company.
Copyright © 2013-2024 by Brad Harding <mailto:[email protected]>.
This file is a part of DOOM Retro.
DOOM Retro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the license, or (at your
option) any later version.
DOOM Retro is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with DOOM Retro. If not, see <https://www.gnu.org/licenses/>.
DOOM is a registered trademark of id Software LLC, a ZeniMax Media
company, in the US and/or other countries, and is used without
permission. All other trademarks are the property of their respective
holders. DOOM Retro is in no way affiliated with nor endorsed by
id Software.
==============================================================================
*/
#pragma once
#include "d_event.h"
#include "doomdef.h"
#include "doomtype.h"
#include "hu_lib.h"
#include "r_defs.h"
#define CONSOLESTRINGSMAX 1024
#define CONSOLEFONTSTART 32
#define CONSOLEFONTEND 255
#define CONSOLEFONTSIZE (CONSOLEFONTEND - CONSOLEFONTSTART + 1)
#define CONSOLEAUTOMAPBEVELCOLOR 6
#define CONSOLEBACKCOLOR 12
#define CONSOLEBEVELCOLOR 0
#define CONSOLEBOLDCOLOR 80
#define CONSOLEBOLDITALICSCOLOR 93
#define CONSOLEBRANDINGCOLOR1 176
#define CONSOLEBRANDINGCOLOR2 182
#define CONSOLECARETCOLOR 4
#define CONSOLEDIVIDERCOLOR 100
#define CONSOLEINPUTCOLOR 4
#define CONSOLEOUTPUTCOLOR 88
#define CONSOLEOVERLAYWARNINGCOLOR 176
#define CONSOLEPLAYERMESSAGECOLOR 161
#define CONSOLESCROLLBARFACECOLOR 96
#define CONSOLESCROLLBARTRACKCOLOR 100
#define CONSOLESELECTEDINPUTBACKGROUNDCOLOR 100
#define CONSOLESELECTEDINPUTCOLOR 4
#define CONSOLETIMESTAMPCOLOR 161
#define CONSOLEWARNINGBOLDCOLOR 176
#define CONSOLEWARNINGCOLOR 180
#define NOBOLDCOLOR -1
#define NOBACKGROUNDCOLOR -1
#define CONSOLEDOWNSIZE 28
#define CONSOLEUPSIZE 12
#define CONSOLEHEIGHT ((gamestate == GS_TITLESCREEN ? SCREENHEIGHT : SCREENHEIGHT / 2) - 5)
#define CONSOLELINES (gamestate == GS_TITLESCREEN ? 27 : 13)
#define CONSOLETEXTX (vid_widescreen ? MAX(MAXWIDESCREENDELTA - 18, 10) : 10)
#define CONSOLETEXTY 8
#define CONSOLETEXTMAXLENGTH 1024
#define CONSOLELINEHEIGHT 14
#define CONSOLEBLANKLINES 12
#define CONSOLESCROLLBARWIDTH 5
#define CONSOLESCROLLBARHEIGHT (CONSOLEHEIGHT - (gamestate == GS_TITLESCREEN ? 26 : 22))
#define CONSOLESCROLLBARX (SCREENWIDTH - CONSOLETEXTX - CONSOLESCROLLBARWIDTH)
#define CONSOLETEXTPIXELWIDTH (SCREENWIDTH - CONSOLETEXTX * 2 - (scrollbardrawn ? CONSOLESCROLLBARWIDTH + 15 : 10))
#define CONSOLEINPUTX CONSOLETEXTX
#define CONSOLEINPUTY (CONSOLEHEIGHT - 16)
#define CONSOLEINPUTPIXELWIDTH (SCREENWIDTH - CONSOLETEXTX - brandwidth - 2)
#define OVERLAYTEXTX (vid_widescreen ? MAXWIDESCREENDELTA - 18 : 14)
#define OVERLAYTEXTY (vid_widescreen && r_screensize == r_screensize_max ? 17 : 11)
#define OVERLAYLINEHEIGHT 14
#define OVERLAYSPACING 7
#define MAPOVERLAYTEXTX 18
#define MAPOVERLAYTEXTY 18
#define WARNINGWIDTH 13
#define EMPTYVALUE "\"\""
#define stringize(text) #text
#define BOLDON "\x1A"
#define BOLDONCHAR '\x1A'
#define BOLDOFF "\x1B"
#define BOLDOFFCHAR '\x1B'
#define ITALICSON "\x1C"
#define ITALICSONCHAR '\x1C'
#define ITALICSOFF "\x1D"
#define ITALICSOFFCHAR '\x1D'
#define MONOSPACEDON "\x1E"
#define MONOSPACEDONCHAR '\x1E'
#define MONOSPACEDOFF "\x1F"
#define MONOSPACEDOFFCHAR '\x1F'
#define BOLD(text) BOLDON text BOLDOFF
#define BOLDER(text) BOLDON BOLDON text BOLDOFF BOLDOFF
#define ITALICS(text) ITALICSON text ITALICSOFF
#define BOLDITALICS(text) ITALICS(BOLD(text))
#define MONOSPACED(text) MONOSPACEDON text MONOSPACEDOFF
#if defined(_WIN32)
#define SDL_FILENAME "SDL2.dll"
#define SDL_MIXER_FILENAME "SDL2_mixer.dll"
#define SDL_IMAGE_FILENAME "SDL2_image.dll"
#elif defined(__APPLE__)
#define SDL_FILENAME "SDL2"
#define SDL_MIXER_FILENAME "SDL2_mixer"
#define SDL_IMAGE_FILENAME "SDL2_image"
#else
#define SDL_FILENAME "SDL2.so"
#define SDL_MIXER_FILENAME "SDL2_mixer.so"
#define SDL_IMAGE_FILENAME "SDL2_image.so"
#endif
#define MAXTABS 10
#define BINDLISTHEADER "CONTROL\t+ACTION/COMMAND(S)"
#define CMDLISTHEADER "CCMD\tDESCRIPTION"
#define CVARLISTHEADER "CVAR\tVALUE\tDESCRIPTION"
#define MAPLISTHEADER "\tMAP\tTITLE\tWAD"
#define MAPSTATSHEADER "STAT\tVALUE"
#define PLAYERSTATSHEADER "STAT\tCURRENT MAP\tTOTAL"
#define THINGLISTHEADER "\tTHING\tPOSITION\tANGLE\tFLAGS"
typedef enum
{
inputstring,
cheatstring,
outputstring,
dividerstring,
warningstring,
playerwarningstring,
playermessagestring,
headerstring,
STRINGTYPES
} stringtype_t;
typedef struct
{
char string[1024];
int count;
stringtype_t stringtype;
int wrap;
int indent;
patch_t *header;
int tabs[MAXTABS];
int tics;
char timestamp[9];
} console_t;
typedef struct
{
char *input;
int caretpos;
int selectstart;
int selectend;
} undohistory_t;
typedef struct
{
const char char1;
const char char2;
const int adjust;
} kern_t;
typedef struct
{
char text[255];
const int game;
} autocomplete_t;
extern patch_t *consolefont[CONSOLEFONTSIZE];
extern patch_t *degree;
extern patch_t *lsquote;
extern patch_t *ldquote;
extern patch_t *unknownchar;
extern patch_t *altunderscores;
extern patch_t *bindlist;
extern patch_t *cmdlist;
extern patch_t *cvarlist;
extern patch_t *maplist;
extern patch_t *mapstats;
extern patch_t *playerstats;
extern patch_t *thinglist;
extern console_t *console;
extern bool consoleactive;
extern int consoleheight;
extern int consoledirection;
extern char consoleinput[255];
extern int numconsolestrings;
extern size_t consolestringsmax;
extern int caretpos;
extern int selectstart;
extern int selectend;
extern bool pathoverlay;
extern char consolecheat[255];
extern char consolecheatparm[3];
extern char consolecmdparm[255];
extern int consolebrandingcolor1;
extern int consolebrandingcolor2;
extern bool scrollbardrawn;
extern const kern_t kern[];
extern const kern_t altkern[];
extern autocomplete_t autocompletelist[];
void C_Input(const char *string, ...);
void C_Cheat(const char *string);
void C_IntegerCVAROutput(const char *cvar, const int value);
void C_IntegerCVAROutputNoRepeat(const char *cvar, const int value);
void C_PercentCVAROutput(const char *cvar, const int value);
void C_StringCVAROutput(const char *cvar, const char *string);
void C_Output(const char *string, ...);
void C_TabbedOutput(const int tabs[MAXTABS], const char *string, ...);
void C_Header(const int tabs[MAXTABS], patch_t *header, const char *string);
void C_Warning(const int minwarninglevel, const char *string, ...);
void C_PlayerMessage(const char *string, ...);
void C_PlayerObituary(const char *string, ...);
void C_PlayerWarning(const char *string, ...);
void C_ResetWrappedLines(void);
void C_AddConsoleDivider(void);
void C_ClearConsole(void);
void C_Init(void);
void C_ShowConsole(bool reset);
void C_HideConsole(void);
void C_HideConsoleFast(void);
void C_Drawer(void);
bool C_ExecuteInputString(const char *input);
bool C_ValidateInput(char *input);
bool C_Responder(event_t *ev);
void C_PrintSDLVersions(void);
void C_UpdateFPSOverlay(void);
void C_UpdateTimerOverlay(void);
void C_UpdatePathOverlay(void);
void C_UpdatePlayerStatsOverlay(void);
void C_UpdatePlayerPositionOverlay(void);
char *C_CreateTimeStamp(const int index);
int C_TextWidth(const char *text, const bool formatting, const bool kerning);
#if defined(_WIN32)
void C_PrintCompileDate(void);
#endif