2001-07-16 21:39:50 +00:00
|
|
|
/*
|
|
|
|
console.c
|
|
|
|
|
|
|
|
(description)
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program 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 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-07-16 21:39:50 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2002-01-16 21:53:42 +00:00
|
|
|
#include <errno.h>
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2004-01-20 05:57:39 +00:00
|
|
|
#ifdef __QNXNTO__
|
|
|
|
# include <locale.h>
|
|
|
|
#endif
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/cbuf.h"
|
2001-07-16 21:39:50 +00:00
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/draw.h"
|
2002-03-18 16:47:04 +00:00
|
|
|
#include "QF/dstring.h"
|
2003-05-06 02:19:13 +00:00
|
|
|
#include "QF/gib.h"
|
2001-07-16 21:39:50 +00:00
|
|
|
#include "QF/input.h"
|
|
|
|
#include "QF/keys.h"
|
|
|
|
#include "QF/qargs.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2003-07-25 22:21:47 +00:00
|
|
|
#include "QF/render.h"
|
2001-07-16 21:39:50 +00:00
|
|
|
#include "QF/screen.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
2001-07-20 18:51:00 +00:00
|
|
|
#include "QF/vid.h"
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2021-11-08 02:20:04 +00:00
|
|
|
#include "QF/input/event.h"
|
|
|
|
|
2012-02-13 12:58:34 +00:00
|
|
|
#include "QF/plugin/general.h"
|
|
|
|
#include "QF/plugin/console.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
2012-02-13 12:58:34 +00:00
|
|
|
|
2021-06-12 13:50:51 +00:00
|
|
|
#include "QF/ui/view.h"
|
|
|
|
|
|
|
|
#include "QF/ui/inputline.h"
|
|
|
|
|
2001-07-20 18:51:00 +00:00
|
|
|
#include "compat.h"
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2001-09-19 03:39:04 +00:00
|
|
|
static general_data_t plugin_info_general_data;
|
2002-01-18 19:19:33 +00:00
|
|
|
console_data_t con_data;
|
2001-09-19 03:39:04 +00:00
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static old_console_t con_main;
|
|
|
|
static old_console_t con_chat;
|
|
|
|
static old_console_t *con;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static float con_cursorspeed = 4;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
static float con_notifytime;
|
|
|
|
static cvar_t con_notifytime_cvar = {
|
|
|
|
.name = "con_notifytime",
|
|
|
|
.description =
|
|
|
|
"How long in seconds messages are displayed on screen",
|
|
|
|
.default_value = "3",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &con_notifytime },
|
|
|
|
};
|
|
|
|
static float con_alpha;
|
|
|
|
static cvar_t con_alpha_cvar = {
|
|
|
|
.name = "con_alpha",
|
|
|
|
.description =
|
|
|
|
"alpha value for the console background",
|
|
|
|
.default_value = "0.6",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &con_alpha },
|
|
|
|
};
|
|
|
|
static float con_size;
|
|
|
|
static cvar_t con_size_cvar = {
|
|
|
|
.name = "con_size",
|
|
|
|
.description =
|
|
|
|
"Fraction of the screen the console covers when down",
|
|
|
|
.default_value = "0.5",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &con_size },
|
|
|
|
};
|
|
|
|
static float con_speed;
|
|
|
|
static cvar_t con_speed_cvar = {
|
|
|
|
.name = "con_speed",
|
|
|
|
.description =
|
|
|
|
"How quickly the console scrolls up or down",
|
|
|
|
.default_value = "300",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &con_speed },
|
|
|
|
};
|
|
|
|
static exprenum_t cl_conmode_enum;
|
|
|
|
static exprtype_t cl_conmode_type = {
|
|
|
|
.name = "cl_conmode",
|
2022-04-24 11:46:06 +00:00
|
|
|
.size = sizeof (con_data.exec_line),
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
.data = &cl_conmode_enum,
|
|
|
|
.get_string = cexpr_enum_get_string,
|
|
|
|
};
|
|
|
|
static int cl_exec_line_command (void *data, const char *line);
|
|
|
|
static int cl_exec_line_chat (void *data, const char *line);
|
|
|
|
static int cl_exec_line_rcon (void *data, const char *line);
|
|
|
|
static int (*cl_conmode_values[])(void *, const char *) = {
|
|
|
|
cl_exec_line_command,
|
|
|
|
cl_exec_line_chat,
|
|
|
|
cl_exec_line_rcon,
|
|
|
|
};
|
|
|
|
static exprsym_t cl_conmode_symbols[] = {
|
|
|
|
{"command", &cl_conmode_type, cl_conmode_values + 0},
|
|
|
|
{"chat", &cl_conmode_type, cl_conmode_values + 1},
|
|
|
|
{"rcon", &cl_conmode_type, cl_conmode_values + 1},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
static exprtab_t cl_conmode_symtab = {
|
|
|
|
cl_conmode_symbols,
|
|
|
|
};
|
|
|
|
static exprenum_t cl_conmode_enum = {
|
|
|
|
&cl_conmode_type,
|
|
|
|
&cl_conmode_symtab,
|
|
|
|
};
|
|
|
|
static cvar_t cl_conmode_cvar = {
|
|
|
|
.name = "cl_conmode",
|
|
|
|
.description =
|
|
|
|
"Set the console input mode (command, chat, rcon)",
|
|
|
|
.default_value = "command",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:46:06 +00:00
|
|
|
.value = { .type = &cl_conmode_type, .value = &con_data.exec_line },
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
};
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
#define NUM_CON_TIMES 4
|
2002-01-16 21:53:42 +00:00
|
|
|
static float con_times[NUM_CON_TIMES]; // realtime time the line was generated
|
2001-07-16 21:39:50 +00:00
|
|
|
// for transparent notify lines
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static int con_totallines; // total lines in console scrollback
|
2021-11-08 02:20:04 +00:00
|
|
|
static con_state_t con_state;
|
|
|
|
static int con_event_id;
|
|
|
|
static int con_saved_focos;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static qboolean con_debuglog;
|
2002-01-16 23:06:28 +00:00
|
|
|
static qboolean chat_team;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
#define MAXCMDLINE 256
|
2002-01-16 21:53:42 +00:00
|
|
|
static inputline_t *input_line;
|
2002-01-16 23:06:28 +00:00
|
|
|
static inputline_t *say_line;
|
|
|
|
static inputline_t *say_team_line;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
static view_t *console_view;
|
|
|
|
static view_t *say_view;
|
|
|
|
static view_t *notify_view;
|
|
|
|
static view_t *menu_view;
|
2003-05-14 21:17:32 +00:00
|
|
|
static view_t *hud_view;
|
2003-05-06 02:19:13 +00:00
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static qboolean con_initialized;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
|
|
|
ClearNotify (void)
|
2002-01-16 16:27:56 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_CON_TIMES; i++)
|
|
|
|
con_times[i] = 0;
|
|
|
|
}
|
|
|
|
|
2021-11-08 02:20:04 +00:00
|
|
|
static void
|
|
|
|
C_SetState (con_state_t state)
|
|
|
|
{
|
2021-11-28 13:42:01 +00:00
|
|
|
con_state_t old_state = con_state;
|
2021-11-08 02:20:04 +00:00
|
|
|
con_state = state;
|
|
|
|
if (con_state == con_inactive) {
|
|
|
|
IE_Set_Focus (con_saved_focos);
|
2021-11-28 13:42:01 +00:00
|
|
|
} else if (old_state == con_inactive) {
|
2021-11-08 02:20:04 +00:00
|
|
|
con_saved_focos = IE_Get_Focus ();
|
|
|
|
IE_Set_Focus (con_event_id);
|
|
|
|
}
|
2021-11-28 13:42:01 +00:00
|
|
|
if (con_state == con_menu && old_state != con_menu) {
|
|
|
|
Menu_Enter ();
|
|
|
|
}
|
2021-11-08 02:20:04 +00:00
|
|
|
}
|
2002-01-16 21:53:42 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
ToggleConsole_f (void)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2021-11-08 02:20:04 +00:00
|
|
|
switch (con_state) {
|
2021-11-28 13:42:01 +00:00
|
|
|
case con_menu:
|
|
|
|
case con_message:
|
|
|
|
return;
|
2021-11-08 02:20:04 +00:00
|
|
|
case con_inactive:
|
|
|
|
C_SetState (con_active);
|
|
|
|
break;
|
|
|
|
case con_active:
|
|
|
|
C_SetState (con_inactive);
|
|
|
|
break;
|
|
|
|
case con_fullscreen:
|
|
|
|
break;
|
2002-01-16 21:53:42 +00:00
|
|
|
}
|
2021-11-28 13:42:01 +00:00
|
|
|
Con_ClearTyping (input_line, 0);
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
ClearNotify ();
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
|
|
|
Clear_f (void)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
|
|
|
con_main.numlines = 0;
|
|
|
|
con_chat.numlines = 0;
|
|
|
|
memset (con_main.text, ' ', CON_TEXTSIZE);
|
|
|
|
memset (con_chat.text, ' ', CON_TEXTSIZE);
|
|
|
|
con_main.display = con_main.current;
|
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
|
|
|
MessageMode_f (void)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2021-11-28 13:42:01 +00:00
|
|
|
if (con_state != con_inactive)
|
2001-07-16 21:39:50 +00:00
|
|
|
return;
|
|
|
|
chat_team = false;
|
2021-11-28 13:42:01 +00:00
|
|
|
C_SetState (con_message);
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
|
|
|
MessageMode2_f (void)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2021-11-28 13:42:01 +00:00
|
|
|
if (con_state != con_inactive)
|
2001-07-16 21:39:50 +00:00
|
|
|
return;
|
|
|
|
chat_team = true;
|
2021-11-28 13:42:01 +00:00
|
|
|
C_SetState (con_message);
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
|
|
|
Resize (old_console_t *con)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2001-09-10 12:56:23 +00:00
|
|
|
char tbuf[CON_TEXTSIZE];
|
|
|
|
int width, oldwidth, oldtotallines, numlines, numchars, i, j;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2021-07-10 09:04:34 +00:00
|
|
|
width = (r_data->vid->conview->xlen >> 3) - 2;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
if (width < 1) { // video hasn't been initialized yet
|
|
|
|
width = 38;
|
|
|
|
con_linewidth = width;
|
|
|
|
con_totallines = CON_TEXTSIZE / con_linewidth;
|
|
|
|
memset (con->text, ' ', CON_TEXTSIZE);
|
|
|
|
} else {
|
|
|
|
oldwidth = con_linewidth;
|
|
|
|
con_linewidth = width;
|
|
|
|
oldtotallines = con_totallines;
|
|
|
|
con_totallines = CON_TEXTSIZE / con_linewidth;
|
|
|
|
numlines = oldtotallines;
|
|
|
|
|
|
|
|
if (con_totallines < numlines)
|
|
|
|
numlines = con_totallines;
|
|
|
|
|
|
|
|
numchars = oldwidth;
|
|
|
|
|
|
|
|
if (con_linewidth < numchars)
|
|
|
|
numchars = con_linewidth;
|
|
|
|
|
|
|
|
memcpy (tbuf, con->text, CON_TEXTSIZE);
|
|
|
|
memset (con->text, ' ', CON_TEXTSIZE);
|
|
|
|
|
|
|
|
for (i = 0; i < numlines; i++) {
|
|
|
|
for (j = 0; j < numchars; j++) {
|
|
|
|
con->text[(con_totallines - 1 - i) * con_linewidth + j] =
|
|
|
|
tbuf[((con->current - i + oldtotallines) %
|
|
|
|
oldtotallines) * oldwidth + j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
ClearNotify ();
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
2002-02-16 04:21:03 +00:00
|
|
|
say_team_line->width = con_linewidth - 9;
|
|
|
|
say_line->width = con_linewidth - 4;
|
|
|
|
input_line->width = con_linewidth;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-07-16 21:39:50 +00:00
|
|
|
con->current = con_totallines - 1;
|
|
|
|
con->display = con->current;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-01-16 21:53:42 +00:00
|
|
|
C_CheckResize
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
If the line width has changed, reformat the buffer.
|
|
|
|
*/
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
|
|
|
C_CheckResize (void)
|
|
|
|
{
|
|
|
|
Resize (&con_main);
|
|
|
|
Resize (&con_chat);
|
2003-05-07 07:10:15 +00:00
|
|
|
|
2021-07-10 09:04:34 +00:00
|
|
|
view_resize (con_data.view, r_data->vid->conview->xlen,
|
|
|
|
r_data->vid->conview->ylen);
|
2002-01-16 21:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
Condump_f (void)
|
|
|
|
{
|
|
|
|
int line = con->current - con->numlines;
|
|
|
|
const char *start, *end;
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *file;
|
2021-03-29 08:24:30 +00:00
|
|
|
const char *name;
|
2002-01-16 21:53:42 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("usage: condump <filename>\n");
|
2002-01-16 21:53:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strchr (Cmd_Argv (1), '/') || strchr (Cmd_Argv (1), '\\')) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("invalid character in filename\n");
|
2002-01-16 21:53:42 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-31 07:01:20 +00:00
|
|
|
name = va (0, "%s/%s.txt", qfs_gamedir->dir.def, Cmd_Argv (1));//FIXME
|
2002-01-16 21:53:42 +00:00
|
|
|
|
2003-02-14 22:36:10 +00:00
|
|
|
if (!(file = QFS_WOpen (name, 0))) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("could not open %s for writing: %s\n", name,
|
2002-01-16 21:53:42 +00:00
|
|
|
strerror (errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (line < con->current) {
|
|
|
|
start = &con->text[(line % con_totallines) * con_linewidth];
|
|
|
|
end = start + con_linewidth;
|
|
|
|
while (end > start && end[-1] != ' ')
|
|
|
|
end--;
|
|
|
|
Qprintf (file, "%.*s\n", (int)(end - start), start);
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Qclose (file);
|
|
|
|
}
|
|
|
|
|
2007-04-07 05:50:29 +00:00
|
|
|
static int
|
|
|
|
cl_exec_line_command (void *data, const char *line)
|
2002-02-28 04:12:20 +00:00
|
|
|
{
|
2007-04-07 05:50:29 +00:00
|
|
|
Cbuf_AddText (con_data.cbuf, line);
|
|
|
|
Cbuf_AddText (con_data.cbuf, "\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2002-02-28 04:12:20 +00:00
|
|
|
|
2007-04-07 05:50:29 +00:00
|
|
|
static int
|
|
|
|
cl_exec_line_chat (void *data, const char *line)
|
|
|
|
{
|
|
|
|
Cbuf_AddText (con_data.cbuf, "say ");
|
|
|
|
Cbuf_AddText (con_data.cbuf, line);
|
|
|
|
Cbuf_AddText (con_data.cbuf, "\n");
|
|
|
|
return 0;
|
2002-02-28 04:12:20 +00:00
|
|
|
}
|
|
|
|
|
2007-04-07 05:50:29 +00:00
|
|
|
static int
|
|
|
|
cl_exec_line_rcon (void *data, const char *line)
|
|
|
|
{
|
|
|
|
Cbuf_AddText (con_data.cbuf, "rcon ");
|
|
|
|
Cbuf_AddText (con_data.cbuf, line);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_AddText (con_data.cbuf, "\n");
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("rcon %s\n", line);
|
2007-04-07 05:50:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-28 13:42:01 +00:00
|
|
|
static void
|
|
|
|
con_end_message (inputline_t *line)
|
|
|
|
{
|
|
|
|
Con_ClearTyping (line, 1);
|
|
|
|
C_SetState (con_inactive);
|
|
|
|
}
|
|
|
|
|
2002-01-16 23:06:28 +00:00
|
|
|
static void
|
2011-03-26 23:03:39 +00:00
|
|
|
C_Say (inputline_t *il)
|
2002-01-16 23:06:28 +00:00
|
|
|
{
|
2011-03-26 23:03:39 +00:00
|
|
|
const char *line = il->line;
|
2021-11-28 13:42:01 +00:00
|
|
|
if (*line) {
|
|
|
|
Cbuf_AddText (con_data.cbuf, "say \"");
|
|
|
|
Cbuf_AddText (con_data.cbuf, line);
|
|
|
|
Cbuf_AddText (con_data.cbuf, "\"\n");
|
|
|
|
}
|
|
|
|
con_end_message (il);
|
2002-01-16 23:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-03-26 23:03:39 +00:00
|
|
|
C_SayTeam (inputline_t *il)
|
2002-01-16 23:06:28 +00:00
|
|
|
{
|
2011-03-26 23:03:39 +00:00
|
|
|
const char *line = il->line;
|
2002-08-28 21:03:24 +00:00
|
|
|
|
2021-11-28 13:42:01 +00:00
|
|
|
if (*line) {
|
|
|
|
Cbuf_AddText (con_data.cbuf, "say_team \"");
|
|
|
|
Cbuf_AddText (con_data.cbuf, line);
|
|
|
|
Cbuf_AddText (con_data.cbuf, "\"\n");
|
|
|
|
}
|
|
|
|
con_end_message (il);
|
2002-01-16 23:06:28 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
|
|
|
Linefeed (void)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
|
|
|
con->x = 0;
|
|
|
|
if (con->display == con->current)
|
|
|
|
con->display++;
|
|
|
|
con->current++;
|
|
|
|
if (con->numlines < con_totallines)
|
|
|
|
con->numlines++;
|
|
|
|
memset (&con->text[(con->current % con_totallines) * con_linewidth],
|
|
|
|
' ', con_linewidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-07-20 18:51:00 +00:00
|
|
|
C_Print
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
Handles cursor positioning, line wrapping, etc
|
|
|
|
All console printing must go through this in order to be logged to disk
|
|
|
|
If no console is visible, the notify window will pop up.
|
|
|
|
*/
|
2021-03-27 10:52:59 +00:00
|
|
|
static __attribute__((format(PRINTF, 1, 0))) void
|
2001-07-20 18:51:00 +00:00
|
|
|
C_Print (const char *fmt, va_list args)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2002-01-16 21:53:42 +00:00
|
|
|
char *s;
|
2002-03-08 23:11:42 +00:00
|
|
|
static dstring_t *buffer;
|
|
|
|
int mask, c, l, y;
|
|
|
|
static int cr;
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
buffer = dstring_new ();
|
|
|
|
|
|
|
|
dvsprintf (buffer, fmt, args);
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
// log all messages to file
|
|
|
|
if (con_debuglog)
|
2021-01-31 07:01:20 +00:00
|
|
|
Sys_DebugLog (va (0, "%s/%s/qconsole.log", qfs_userpath,//FIXME
|
2003-02-14 22:36:10 +00:00
|
|
|
qfs_gamedir->dir.def), "%s", buffer->str);
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
if (!con_initialized)
|
|
|
|
return;
|
|
|
|
|
2002-03-08 23:11:42 +00:00
|
|
|
s = buffer->str;
|
2002-01-16 21:53:42 +00:00
|
|
|
|
|
|
|
if (s[0] == 1 || s[0] == 2) {
|
2001-07-16 21:39:50 +00:00
|
|
|
mask = 128; // go to colored text
|
2002-01-16 21:53:42 +00:00
|
|
|
s++;
|
2001-07-16 21:39:50 +00:00
|
|
|
} else
|
|
|
|
mask = 0;
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
while ((c = (byte)*s)) {
|
2001-07-16 21:39:50 +00:00
|
|
|
// count word length
|
|
|
|
for (l = 0; l < con_linewidth; l++)
|
2002-01-16 21:53:42 +00:00
|
|
|
if (s[l] <= ' ')
|
2001-07-16 21:39:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// word wrap
|
|
|
|
if (l != con_linewidth && (con->x + l > con_linewidth))
|
|
|
|
con->x = 0;
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
*s++ = sys_char_map[c];
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
if (cr) {
|
|
|
|
con->current--;
|
|
|
|
cr = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!con->x) {
|
2002-01-16 21:53:42 +00:00
|
|
|
Linefeed ();
|
2001-07-16 21:39:50 +00:00
|
|
|
// mark time for transparent overlay
|
2009-03-16 11:49:52 +00:00
|
|
|
if (con->current >= 0 && con_data.realtime)
|
2002-01-16 21:53:42 +00:00
|
|
|
con_times[con->current % NUM_CON_TIMES] = *con_data.realtime;
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case '\n':
|
|
|
|
con->x = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '\r':
|
|
|
|
con->x = 0;
|
|
|
|
cr = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // display character and advance
|
|
|
|
y = con->current % con_totallines;
|
2002-01-16 21:53:42 +00:00
|
|
|
con->text[y * con_linewidth + con->x] = c | mask | con_data.ormask;
|
2001-07-16 21:39:50 +00:00
|
|
|
con->x++;
|
|
|
|
if (con->x >= con_linewidth)
|
|
|
|
con->x = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2002-01-16 21:53:42 +00:00
|
|
|
|
|
|
|
// echo to debugging console
|
2021-12-20 12:03:40 +00:00
|
|
|
// but don't print the highchars flag (leading \x01)
|
2002-03-08 23:11:42 +00:00
|
|
|
if ((byte)buffer->str[0] > 2)
|
|
|
|
fputs (buffer->str, stdout);
|
|
|
|
else if ((byte)buffer->str[0])
|
|
|
|
fputs (buffer->str + 1, stdout);
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
/* DRAWING */
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2002-01-17 02:27:53 +00:00
|
|
|
static void
|
2002-08-20 21:19:53 +00:00
|
|
|
DrawInputLine (int x, int y, int cursor, inputline_t *il)
|
2002-01-17 02:27:53 +00:00
|
|
|
{
|
|
|
|
const char *s = il->lines[il->edit_line] + il->scroll;
|
|
|
|
|
|
|
|
if (il->scroll) {
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_Character (x, y, '<' | 0x80);
|
|
|
|
r_funcs->Draw_nString (x + 8, y, s + 1, il->width - 2);
|
2002-01-17 02:27:53 +00:00
|
|
|
} else {
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_nString (x, y, s, il->width - 1);
|
2002-01-17 02:27:53 +00:00
|
|
|
}
|
2009-03-16 11:49:52 +00:00
|
|
|
if (cursor && con_data.realtime) {
|
2002-08-20 21:19:53 +00:00
|
|
|
float t = *con_data.realtime * con_cursorspeed;
|
|
|
|
int ch = 10 + ((int) (t) & 1);
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_Character (x + ((il->linepos - il->scroll) << 3), y, ch);
|
2002-08-20 21:19:53 +00:00
|
|
|
}
|
2002-01-17 02:27:53 +00:00
|
|
|
if (strlen (s) >= il->width)
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_Character (x + ((il->width - 1) << 3), y, '>' | 0x80);
|
2002-01-17 02:27:53 +00:00
|
|
|
}
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2002-08-20 21:19:53 +00:00
|
|
|
void
|
|
|
|
C_DrawInputLine (inputline_t *il)
|
|
|
|
{
|
2011-07-09 12:16:38 +00:00
|
|
|
DrawInputLine (il->x, il->y, il->cursor, il);
|
2002-08-20 21:19:53 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
2003-05-06 02:19:13 +00:00
|
|
|
draw_input (view_t *view)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2021-11-28 13:42:01 +00:00
|
|
|
if (con_state == con_inactive)
|
2021-11-08 02:20:04 +00:00
|
|
|
return;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
DrawInputLine (view->xabs + 8, view->yabs, 1, input_line);
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
2003-05-06 02:19:13 +00:00
|
|
|
draw_download (view_t *view)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2022-03-30 17:57:38 +00:00
|
|
|
static dstring_t *dlbar;
|
2003-05-06 02:19:13 +00:00
|
|
|
const char *text;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2007-03-20 14:16:43 +00:00
|
|
|
if (!con_data.dl_name || !*con_data.dl_name->str)
|
2003-05-06 02:19:13 +00:00
|
|
|
return;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2022-03-30 17:57:38 +00:00
|
|
|
if (!dlbar) {
|
|
|
|
dlbar = dstring_new ();
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:16:43 +00:00
|
|
|
text = QFS_SkipPath(con_data.dl_name->str);
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2022-03-30 17:57:38 +00:00
|
|
|
int line_size = con_linewidth - ((con_linewidth * 7) / 40);
|
|
|
|
int dot_space = line_size - strlen (text) - 8;
|
|
|
|
const char *ellipsis = "";
|
|
|
|
int txt_size = con_linewidth / 3;
|
|
|
|
if (strlen (text) > (size_t) txt_size) {
|
|
|
|
ellipsis = "...";
|
|
|
|
dot_space = line_size - txt_size - 11;
|
|
|
|
} else {
|
|
|
|
txt_size = strlen (text);
|
|
|
|
}
|
2003-05-06 02:19:13 +00:00
|
|
|
// where's the dot go?
|
2022-03-30 17:57:38 +00:00
|
|
|
int n = 0;
|
|
|
|
if (con_data.dl_percent) {
|
|
|
|
n = dot_space * *con_data.dl_percent / 100;
|
|
|
|
}
|
|
|
|
char *dots = alloca (dot_space + 1);
|
|
|
|
dots[dot_space] = 0;
|
|
|
|
for (int j = 0; j < dot_space; j++) {
|
|
|
|
if (j == n) {
|
|
|
|
dots[j++] = '\x83';
|
|
|
|
} else {
|
|
|
|
dots[j++] = '\x81';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dsprintf (dlbar, "%.*s%s: \x80%s\x82 %02d%%", txt_size, text, ellipsis, dots, *con_data.dl_percent);
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
// draw it
|
2022-03-30 17:57:38 +00:00
|
|
|
r_funcs->Draw_String (view->xabs, view->yabs, dlbar->str);
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
2003-05-06 02:19:13 +00:00
|
|
|
draw_console_text (view_t *view)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2001-09-10 12:56:23 +00:00
|
|
|
char *text;
|
|
|
|
int row, rows, i, x, y;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
rows = view->ylen >> 3; // rows of text to draw
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
x = view->xabs + 8;
|
|
|
|
y = view->yabs + view->ylen - 8;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
// draw from the bottom up
|
|
|
|
if (con->display != con->current) {
|
|
|
|
// draw arrows to show the buffer is backscrolled
|
2003-05-06 02:19:13 +00:00
|
|
|
for (i = 0; i < con_linewidth; i += 4)
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_Character (x + (i << 3), y, '^');
|
2001-07-16 21:39:50 +00:00
|
|
|
|
|
|
|
y -= 8;
|
|
|
|
rows--;
|
|
|
|
}
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-07-16 21:39:50 +00:00
|
|
|
row = con->display;
|
|
|
|
for (i = 0; i < rows; i++, y -= 8, row--) {
|
|
|
|
if (row < 0)
|
|
|
|
break;
|
|
|
|
if (con->current - row >= con_totallines)
|
|
|
|
break; // past scrollback wrap point
|
|
|
|
|
|
|
|
text = con->text + (row % con_totallines) * con_linewidth;
|
|
|
|
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_nString(x, y, text, con_linewidth);
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
2003-05-06 02:19:13 +00:00
|
|
|
}
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
static void
|
|
|
|
draw_console (view_t *view)
|
|
|
|
{
|
2003-07-25 22:21:47 +00:00
|
|
|
byte alpha;
|
|
|
|
|
2021-11-08 02:20:04 +00:00
|
|
|
if (con_state == con_fullscreen) {
|
2003-07-25 22:21:47 +00:00
|
|
|
alpha = 255;
|
|
|
|
} else {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
float y = r_data->vid->conview->ylen * con_size;
|
|
|
|
alpha = 255 * con_alpha * view->ylen / y;
|
2003-07-25 22:21:47 +00:00
|
|
|
alpha = min (alpha, 255);
|
|
|
|
}
|
2003-05-06 02:19:13 +00:00
|
|
|
// draw the background
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_ConsoleBackground (view->ylen, alpha);
|
2003-05-06 02:19:13 +00:00
|
|
|
|
|
|
|
// draw everything else
|
|
|
|
view_draw (view);
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
2003-05-06 02:19:13 +00:00
|
|
|
draw_say (view_t *view)
|
2001-07-16 21:39:50 +00:00
|
|
|
{
|
2012-02-14 08:28:09 +00:00
|
|
|
r_data->scr_copytop = 1;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:30:38 +00:00
|
|
|
if (chat_team) {
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_String (view->xabs + 8, view->yabs, "say_team:");
|
2003-05-06 02:30:38 +00:00
|
|
|
DrawInputLine (view->xabs + 80, view->yabs, 1, say_team_line);
|
|
|
|
} else {
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_String (view->xabs + 8, view->yabs, "say:");
|
2003-05-06 02:30:38 +00:00
|
|
|
DrawInputLine (view->xabs + 40, view->yabs, 1, say_line);
|
2003-05-06 02:19:13 +00:00
|
|
|
}
|
|
|
|
}
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
static void
|
|
|
|
draw_notify (view_t *view)
|
|
|
|
{
|
|
|
|
int i, x, y;
|
|
|
|
char *text;
|
|
|
|
float time;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2009-03-16 11:49:52 +00:00
|
|
|
if (!con_data.realtime)
|
|
|
|
return;
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
x = view->xabs + 8;
|
|
|
|
y = view->yabs;
|
|
|
|
for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) {
|
|
|
|
if (i < 0)
|
|
|
|
continue;
|
|
|
|
time = con_times[i % NUM_CON_TIMES];
|
|
|
|
if (time == 0)
|
|
|
|
continue;
|
|
|
|
time = *con_data.realtime - time;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (time > con_notifytime)
|
2003-05-06 02:19:13 +00:00
|
|
|
continue;
|
|
|
|
text = con->text + (i % con_totallines) * con_linewidth;
|
2001-07-16 21:39:50 +00:00
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
r_data->scr_copytop = 1;
|
2001-09-19 03:39:04 +00:00
|
|
|
|
2012-04-11 07:38:15 +00:00
|
|
|
r_funcs->Draw_nString (x, y, text, con_linewidth);
|
2003-05-06 02:19:13 +00:00
|
|
|
y += 8;
|
|
|
|
}
|
2001-07-16 21:39:50 +00:00
|
|
|
}
|
2001-07-20 18:51:00 +00:00
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
static void
|
2003-07-25 22:21:47 +00:00
|
|
|
setup_console (void)
|
|
|
|
{
|
2021-11-11 06:43:07 +00:00
|
|
|
float lines = 0;
|
2003-07-25 22:21:47 +00:00
|
|
|
|
2021-11-08 02:20:04 +00:00
|
|
|
switch (con_state) {
|
2021-11-28 13:42:01 +00:00
|
|
|
case con_message:
|
|
|
|
case con_menu:
|
2021-11-08 02:20:04 +00:00
|
|
|
case con_inactive:
|
|
|
|
lines = 0;
|
|
|
|
break;
|
|
|
|
case con_active:
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
lines = r_data->vid->conview->ylen * bound (0.2, con_size,
|
2021-11-08 02:20:04 +00:00
|
|
|
1);
|
|
|
|
break;
|
|
|
|
case con_fullscreen:
|
|
|
|
lines = con_data.lines = r_data->vid->conview->ylen;
|
|
|
|
break;
|
2003-07-25 22:21:47 +00:00
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (con_speed) {
|
2012-07-18 05:50:49 +00:00
|
|
|
if (lines < con_data.lines) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
con_data.lines -= max (0.2, con_speed) * *con_data.frametime;
|
2012-07-18 05:50:49 +00:00
|
|
|
con_data.lines = max (con_data.lines, lines);
|
|
|
|
} else if (lines > con_data.lines) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
con_data.lines += max (0.2, con_speed) * *con_data.frametime;
|
2012-07-18 05:50:49 +00:00
|
|
|
con_data.lines = min (con_data.lines, lines);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
con_data.lines = lines;
|
2003-07-25 22:21:47 +00:00
|
|
|
}
|
2022-03-21 10:21:54 +00:00
|
|
|
if (con_data.lines > r_data->vid->conview->ylen) {
|
|
|
|
con_data.lines = r_data->vid->conview->ylen;
|
|
|
|
}
|
2021-07-10 09:04:34 +00:00
|
|
|
if (con_data.lines >= r_data->vid->conview->ylen - r_data->lineadj)
|
2012-02-14 08:28:09 +00:00
|
|
|
r_data->scr_copyeverything = 1;
|
2003-07-25 22:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
C_DrawConsole (void)
|
2002-01-16 21:53:42 +00:00
|
|
|
{
|
2003-07-25 22:21:47 +00:00
|
|
|
setup_console ();
|
|
|
|
|
|
|
|
if (console_view->ylen != con_data.lines)
|
|
|
|
view_resize (console_view, console_view->xlen, con_data.lines);
|
2003-05-06 02:30:38 +00:00
|
|
|
|
2021-11-28 13:42:01 +00:00
|
|
|
say_view->visible = con_state == con_message;
|
2003-07-25 22:21:47 +00:00
|
|
|
console_view->visible = con_data.lines != 0;
|
2021-11-28 13:42:01 +00:00
|
|
|
menu_view->visible = con_state == con_menu;
|
2003-05-06 02:19:13 +00:00
|
|
|
|
2007-04-09 00:22:17 +00:00
|
|
|
con_data.view->draw (con_data.view);
|
2002-01-16 21:53:42 +00:00
|
|
|
}
|
|
|
|
|
2001-09-16 05:41:28 +00:00
|
|
|
static void
|
|
|
|
C_ProcessInput (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-01-18 19:19:33 +00:00
|
|
|
static void
|
|
|
|
C_NewMap (void)
|
|
|
|
{
|
2010-08-24 07:20:07 +00:00
|
|
|
static dstring_t *old_gamedir = 0;
|
2002-01-18 19:19:33 +00:00
|
|
|
|
2010-08-24 07:20:07 +00:00
|
|
|
if (!old_gamedir || !strequal (old_gamedir->str, qfs_gamedir->gamedir))
|
2002-01-18 19:19:33 +00:00
|
|
|
Menu_Load ();
|
2010-08-24 07:20:07 +00:00
|
|
|
if (!old_gamedir)
|
|
|
|
old_gamedir = dstring_newstr ();
|
|
|
|
dstring_copystr (old_gamedir, qfs_gamedir->gamedir);
|
2002-01-18 19:19:33 +00:00
|
|
|
}
|
|
|
|
|
2003-05-14 21:17:32 +00:00
|
|
|
static void
|
2003-05-23 02:50:15 +00:00
|
|
|
C_GIB_HUD_Enable_f (void)
|
2003-05-14 21:17:32 +00:00
|
|
|
{
|
|
|
|
hud_view->visible = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-05-23 02:50:15 +00:00
|
|
|
C_GIB_HUD_Disable_f (void)
|
2003-05-14 21:17:32 +00:00
|
|
|
{
|
|
|
|
hud_view->visible = 0;
|
|
|
|
}
|
|
|
|
|
2011-03-26 23:03:39 +00:00
|
|
|
static void
|
|
|
|
exec_line (inputline_t *il)
|
|
|
|
{
|
|
|
|
Con_ExecLine (il->line);
|
|
|
|
}
|
2021-11-08 02:20:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
con_key_event (const IE_event_t *event)
|
|
|
|
{
|
|
|
|
inputline_t *il;
|
|
|
|
__auto_type key = &event->key;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (con_curr_keydest == key_menu) {
|
|
|
|
Menu_KeyEvent (key, unicode, down);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (down) {
|
|
|
|
if (key == key_toggleconsole) {
|
|
|
|
ToggleConsole_f ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2021-11-28 13:42:01 +00:00
|
|
|
if (con_state == con_message) {
|
2021-11-08 02:20:04 +00:00
|
|
|
if (chat_team) {
|
|
|
|
il = say_team_line;
|
|
|
|
} else {
|
|
|
|
il = say_line;
|
|
|
|
}
|
2021-11-28 13:42:01 +00:00
|
|
|
if (key->code == QFK_ESCAPE) {
|
|
|
|
con_end_message (il);
|
|
|
|
return;
|
|
|
|
}
|
2021-11-08 02:20:04 +00:00
|
|
|
} else {
|
|
|
|
switch (key->code) {
|
2021-11-22 05:40:34 +00:00
|
|
|
case QFK_ESCAPE:
|
|
|
|
ToggleConsole_f ();
|
|
|
|
break;
|
2021-11-08 02:20:04 +00:00
|
|
|
case QFK_PAGEUP:
|
|
|
|
if (key->shift & ies_control)
|
|
|
|
con->display = 0;
|
|
|
|
else
|
|
|
|
con->display -= 10;
|
|
|
|
if (con->display < con->current - con->numlines)
|
|
|
|
con->display = con->current - con->numlines;
|
|
|
|
return;
|
|
|
|
case QFK_PAGEDOWN:
|
|
|
|
if (key->shift & ies_control)
|
|
|
|
con->display = con->current;
|
|
|
|
else
|
|
|
|
con->display += 10;
|
|
|
|
if (con->display > con->current)
|
|
|
|
con->display = con->current;
|
|
|
|
return;
|
|
|
|
#if 0
|
|
|
|
case QFM_WHEEL_UP:
|
|
|
|
con->display -= 3;
|
|
|
|
if (con->display < con->current - con->numlines)
|
|
|
|
con->display = con->current - con->numlines;
|
|
|
|
return;
|
|
|
|
case QFM_WHEEL_DOWN:
|
|
|
|
con->display += 3;
|
|
|
|
if (con->display > con->current)
|
|
|
|
con->display = con->current;
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
il = input_line;
|
|
|
|
}
|
2021-11-28 13:42:01 +00:00
|
|
|
|
2021-11-08 02:20:04 +00:00
|
|
|
if (key->unicode) {
|
|
|
|
Con_ProcessInputLine (il, key->code >= 256 ? (int) key->code
|
|
|
|
: key->unicode);
|
|
|
|
} else {
|
|
|
|
Con_ProcessInputLine (il, key->code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
con_mouse_event (const IE_event_t *event)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
con_event_handler (const IE_event_t *ie_event, void *data)
|
|
|
|
{
|
2021-11-28 13:42:01 +00:00
|
|
|
if (con_state == con_menu) {
|
|
|
|
return Menu_EventHandler (ie_event);
|
|
|
|
}
|
2021-11-08 02:20:04 +00:00
|
|
|
static void (*handlers[ie_event_count]) (const IE_event_t *ie_event) = {
|
|
|
|
[ie_key] = con_key_event,
|
|
|
|
[ie_mouse] = con_mouse_event,
|
|
|
|
};
|
2022-03-30 15:16:29 +00:00
|
|
|
if ((unsigned) ie_event->type >= ie_event_count
|
2021-11-08 02:20:04 +00:00
|
|
|
|| !handlers[ie_event->type]) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
handlers[ie_event->type] (ie_event);
|
|
|
|
return 1;
|
|
|
|
}
|
2013-01-16 04:18:54 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
static void
|
|
|
|
C_Init (void)
|
|
|
|
{
|
|
|
|
view_t *view;
|
|
|
|
|
2004-01-20 05:57:39 +00:00
|
|
|
#ifdef __QNXNTO__
|
|
|
|
setlocale (LC_ALL, "C-TRADITIONAL");
|
|
|
|
#endif
|
|
|
|
|
2021-11-08 02:20:04 +00:00
|
|
|
con_event_id = IE_Add_Handler (con_event_handler, 0);
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
Menu_Init ();
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&con_notifytime_cvar, 0, 0);
|
|
|
|
|
|
|
|
Cvar_Register (&con_alpha_cvar, 0, 0);
|
|
|
|
Cvar_Register (&con_size_cvar, 0, 0);
|
|
|
|
Cvar_Register (&con_speed_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_conmode_cvar, 0, 0);
|
2003-07-25 22:21:47 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
con_debuglog = COM_CheckParm ("-condebug");
|
|
|
|
|
2009-12-23 02:08:49 +00:00
|
|
|
// The console will get resized, so assume initial size is 320x200
|
2003-05-06 02:19:13 +00:00
|
|
|
con_data.view = view_new (0, 0, 320, 200, grav_northeast);
|
|
|
|
console_view = view_new (0, 0, 320, 200, grav_northwest);
|
2003-05-06 02:30:38 +00:00
|
|
|
say_view = view_new (0, 0, 320, 8, grav_northwest);
|
2003-05-06 02:19:13 +00:00
|
|
|
notify_view = view_new (0, 8, 320, 32, grav_northwest);
|
|
|
|
menu_view = view_new (0, 0, 320, 200, grav_center);
|
2009-12-23 02:08:49 +00:00
|
|
|
hud_view = view_new (0, 0, 320, 200, grav_northeast);
|
2003-05-06 02:19:13 +00:00
|
|
|
|
|
|
|
view_add (con_data.view, say_view);
|
|
|
|
view_add (con_data.view, notify_view);
|
2003-05-14 21:17:32 +00:00
|
|
|
view_add (con_data.view, hud_view);
|
2003-05-06 02:19:13 +00:00
|
|
|
view_add (con_data.view, console_view);
|
|
|
|
view_add (con_data.view, menu_view);
|
|
|
|
|
|
|
|
console_view->draw = draw_console;
|
2003-05-06 02:25:46 +00:00
|
|
|
console_view->visible = 0;
|
2003-05-06 02:19:13 +00:00
|
|
|
console_view->resize_x = console_view->resize_y = 1;
|
|
|
|
|
|
|
|
say_view->draw = draw_say;
|
2003-05-06 02:25:46 +00:00
|
|
|
say_view->visible = 0;
|
2003-05-06 02:19:13 +00:00
|
|
|
say_view->resize_x = 1;
|
|
|
|
|
|
|
|
notify_view->draw = draw_notify;
|
|
|
|
notify_view->resize_x = 1;
|
|
|
|
|
|
|
|
menu_view->draw = Menu_Draw;
|
2003-05-06 02:25:46 +00:00
|
|
|
menu_view->visible = 0;
|
2003-05-06 02:19:13 +00:00
|
|
|
|
2003-05-14 21:17:32 +00:00
|
|
|
hud_view->draw = Menu_Draw_Hud;
|
|
|
|
hud_view->visible = 0;
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
view = view_new (0, 0, 320, 170, grav_northwest);
|
|
|
|
view->draw = draw_console_text;
|
|
|
|
view->resize_x = view->resize_y = 1;
|
|
|
|
view_add (console_view, view);
|
|
|
|
|
|
|
|
view = view_new (0, 12, 320, 10, grav_southwest);
|
|
|
|
view->draw = draw_input;
|
|
|
|
view->resize_x = 1;
|
|
|
|
view_add (console_view, view);
|
|
|
|
|
|
|
|
view = view_new (0, 2, 320, 11, grav_southwest);
|
|
|
|
view->draw = draw_download;
|
|
|
|
view->resize_x = 1;
|
|
|
|
view_add (console_view, view);
|
|
|
|
|
|
|
|
con = &con_main;
|
|
|
|
con_linewidth = -1;
|
|
|
|
|
|
|
|
input_line = Con_CreateInputLine (32, MAXCMDLINE, ']');
|
|
|
|
input_line->complete = Con_BasicCompleteCommandLine;
|
2011-03-26 23:03:39 +00:00
|
|
|
input_line->enter = exec_line;
|
2003-05-06 02:19:13 +00:00
|
|
|
input_line->width = con_linewidth;
|
|
|
|
input_line->user_data = 0;
|
|
|
|
input_line->draw = 0;
|
|
|
|
|
|
|
|
say_line = Con_CreateInputLine (32, MAXCMDLINE, ' ');
|
|
|
|
say_line->complete = 0;
|
|
|
|
say_line->enter = C_Say;
|
|
|
|
say_line->width = con_linewidth - 5;
|
|
|
|
say_line->user_data = 0;
|
|
|
|
say_line->draw = 0;
|
|
|
|
|
|
|
|
say_team_line = Con_CreateInputLine (32, MAXCMDLINE, ' ');
|
|
|
|
say_team_line->complete = 0;
|
|
|
|
say_team_line->enter = C_SayTeam;
|
|
|
|
say_team_line->width = con_linewidth - 10;
|
|
|
|
say_team_line->user_data = 0;
|
|
|
|
say_team_line->draw = 0;
|
|
|
|
|
|
|
|
C_CheckResize ();
|
|
|
|
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Console initialized.\n");
|
2003-05-06 02:19:13 +00:00
|
|
|
|
|
|
|
// register our commands
|
|
|
|
Cmd_AddCommand ("toggleconsole", ToggleConsole_f,
|
|
|
|
"Toggle the console up and down");
|
2021-11-28 12:17:06 +00:00
|
|
|
Cmd_AddCommand ("togglechat", ToggleConsole_f,
|
2003-05-06 02:19:13 +00:00
|
|
|
"Toggle the console up and down");
|
|
|
|
Cmd_AddCommand ("messagemode", MessageMode_f,
|
|
|
|
"Prompt to send a message to everyone");
|
|
|
|
Cmd_AddCommand ("messagemode2", MessageMode2_f,
|
|
|
|
"Prompt to send a message to only people on your team");
|
|
|
|
Cmd_AddCommand ("clear", Clear_f, "Clear the console");
|
|
|
|
Cmd_AddCommand ("condump", Condump_f, "dump the console text to a "
|
|
|
|
"file");
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
// register GIB builtins
|
2003-05-23 02:50:15 +00:00
|
|
|
GIB_Builtin_Add ("HUD::enable", C_GIB_HUD_Enable_f);
|
|
|
|
GIB_Builtin_Add ("HUD::disable", C_GIB_HUD_Disable_f);
|
2003-05-14 21:17:32 +00:00
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
con_initialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-07-12 14:15:26 +00:00
|
|
|
C_shutdown (void)
|
2003-05-06 02:19:13 +00:00
|
|
|
{
|
2021-12-29 12:50:38 +00:00
|
|
|
IE_Remove_Handler (con_event_id);
|
2003-05-06 02:19:13 +00:00
|
|
|
}
|
|
|
|
|
2001-07-20 18:51:00 +00:00
|
|
|
static general_funcs_t plugin_info_general_funcs = {
|
2021-06-26 06:43:17 +00:00
|
|
|
.init = C_Init,
|
|
|
|
.shutdown = C_shutdown,
|
2001-07-20 18:51:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static console_funcs_t plugin_info_console_funcs = {
|
2021-06-26 06:43:17 +00:00
|
|
|
.print = C_Print,
|
|
|
|
.process_input = C_ProcessInput,
|
|
|
|
.draw_console = C_DrawConsole,
|
|
|
|
.check_resize = C_CheckResize,
|
|
|
|
.new_map = C_NewMap,
|
2021-11-08 02:20:04 +00:00
|
|
|
.set_state = C_SetState,
|
2001-07-20 18:51:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_funcs_t plugin_info_funcs = {
|
2021-06-26 06:43:17 +00:00
|
|
|
.general = &plugin_info_general_funcs,
|
|
|
|
.console = &plugin_info_console_funcs,
|
2001-07-20 18:51:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_data_t plugin_info_data = {
|
2021-06-26 06:43:17 +00:00
|
|
|
.general = &plugin_info_general_data,
|
|
|
|
.console = &con_data,
|
2001-07-20 18:51:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_t plugin_info = {
|
|
|
|
qfp_console,
|
|
|
|
0,
|
|
|
|
QFPLUGIN_VERSION,
|
|
|
|
"0.1",
|
|
|
|
"client console driver",
|
|
|
|
"Copyright (C) 1996-1997 id Software, Inc.\n"
|
2001-09-10 12:56:23 +00:00
|
|
|
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge "
|
|
|
|
"project\n"
|
2001-07-20 18:51:00 +00:00
|
|
|
"Please see the file \"AUTHORS\" for a list of contributors",
|
|
|
|
&plugin_info_funcs,
|
|
|
|
&plugin_info_data,
|
|
|
|
};
|
|
|
|
|
2003-08-01 19:53:46 +00:00
|
|
|
PLUGIN_INFO(console, client)
|
2001-07-20 18:51:00 +00:00
|
|
|
{
|
|
|
|
return &plugin_info;
|
|
|
|
}
|