mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-20 00:11:32 +00:00
Merge remote-tracking branch 'yquake2/master'
This commit is contained in:
commit
c0fe05fc03
12 changed files with 292 additions and 113 deletions
|
@ -423,6 +423,7 @@ set(Client-Source
|
||||||
${CLIENT_SRC_DIR}/cl_effects.c
|
${CLIENT_SRC_DIR}/cl_effects.c
|
||||||
${CLIENT_SRC_DIR}/cl_entities.c
|
${CLIENT_SRC_DIR}/cl_entities.c
|
||||||
${CLIENT_SRC_DIR}/cl_input.c
|
${CLIENT_SRC_DIR}/cl_input.c
|
||||||
|
${CLIENT_SRC_DIR}/cl_image.c
|
||||||
${CLIENT_SRC_DIR}/cl_inventory.c
|
${CLIENT_SRC_DIR}/cl_inventory.c
|
||||||
${CLIENT_SRC_DIR}/cl_keyboard.c
|
${CLIENT_SRC_DIR}/cl_keyboard.c
|
||||||
${CLIENT_SRC_DIR}/cl_lights.c
|
${CLIENT_SRC_DIR}/cl_lights.c
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -985,6 +985,7 @@ GAME_OBJS_ = \
|
||||||
CLIENT_OBJS_ := \
|
CLIENT_OBJS_ := \
|
||||||
src/backends/generic/misc.o \
|
src/backends/generic/misc.o \
|
||||||
src/client/cl_cin.o \
|
src/client/cl_cin.o \
|
||||||
|
src/client/cl_image.o \
|
||||||
src/client/cl_console.o \
|
src/client/cl_console.o \
|
||||||
src/client/cl_download.o \
|
src/client/cl_download.o \
|
||||||
src/client/cl_effects.o \
|
src/client/cl_effects.o \
|
||||||
|
@ -1012,7 +1013,6 @@ CLIENT_OBJS_ := \
|
||||||
src/client/sound/sdl.o \
|
src/client/sound/sdl.o \
|
||||||
src/client/sound/sound.o \
|
src/client/sound/sound.o \
|
||||||
src/client/sound/wave.o \
|
src/client/sound/wave.o \
|
||||||
src/client/cl_image.o \
|
|
||||||
src/client/vid/vid.o \
|
src/client/vid/vid.o \
|
||||||
src/common/argproc.o \
|
src/common/argproc.o \
|
||||||
src/common/clientserver.o \
|
src/common/clientserver.o \
|
||||||
|
|
|
@ -403,7 +403,7 @@ void *
|
||||||
Sys_GetGameAPI(void *parms)
|
Sys_GetGameAPI(void *parms)
|
||||||
{
|
{
|
||||||
typedef void *(*fnAPI)(void *);
|
typedef void *(*fnAPI)(void *);
|
||||||
fnAPI GetGameAPI;
|
fnAPI GetGameAPI;
|
||||||
|
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
char *path;
|
char *path;
|
||||||
|
|
|
@ -60,8 +60,8 @@ DrawAltStringScaled(int x, int y, const char *s, float factor)
|
||||||
void
|
void
|
||||||
Key_ClearTyping(void)
|
Key_ClearTyping(void)
|
||||||
{
|
{
|
||||||
key_lines[edit_line][1] = 0; /* clear any typing */
|
key_lines[edit_line][0] = '\0';
|
||||||
key_linepos = 1;
|
key_linepos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -471,6 +471,10 @@ Con_DrawInput(void)
|
||||||
int i;
|
int i;
|
||||||
float scale;
|
float scale;
|
||||||
char *text;
|
char *text;
|
||||||
|
char ch;
|
||||||
|
int txtlen;
|
||||||
|
int linepos;
|
||||||
|
int draw_icon;
|
||||||
|
|
||||||
if (cls.key_dest == key_menu)
|
if (cls.key_dest == key_menu)
|
||||||
{
|
{
|
||||||
|
@ -485,29 +489,50 @@ Con_DrawInput(void)
|
||||||
|
|
||||||
scale = SCR_GetConsoleScale();
|
scale = SCR_GetConsoleScale();
|
||||||
text = key_lines[edit_line];
|
text = key_lines[edit_line];
|
||||||
|
linepos = key_linepos;
|
||||||
/* add the cursor frame */
|
|
||||||
text[key_linepos] = 10 + ((int)(cls.realtime >> 8) & 1);
|
|
||||||
|
|
||||||
/* fill out remainder with spaces */
|
|
||||||
for (i = key_linepos + 1; i < con.linewidth; i++)
|
|
||||||
{
|
|
||||||
text[i] = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* prestep if horizontally scrolling */
|
/* prestep if horizontally scrolling */
|
||||||
if (key_linepos >= con.linewidth)
|
if (linepos >= (con.linewidth - 1))
|
||||||
{
|
{
|
||||||
text += 1 + key_linepos - con.linewidth;
|
int ofs = 1 + linepos - con.linewidth;
|
||||||
|
|
||||||
|
text += ofs;
|
||||||
|
linepos -= ofs;
|
||||||
|
|
||||||
|
draw_icon = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Draw_CharScaled(8 * scale, con.vislines - 22 * scale, CON_INPUT_INDICATOR, scale);
|
||||||
|
draw_icon = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < con.linewidth; i++)
|
txtlen = strlen(text);
|
||||||
{
|
|
||||||
Draw_CharScaled(((i + 1) << 3) * scale, con.vislines - 22 * scale, text[i], scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* remove cursor */
|
for (i = 0; i < (con.linewidth - draw_icon); i++)
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
{
|
||||||
|
if (i == linepos)
|
||||||
|
{
|
||||||
|
if (cls.realtime & 8)
|
||||||
|
{
|
||||||
|
ch = CON_INPUT_CURSOR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ch = (text[i] == '\0') ? 10 : text[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i >= txtlen)
|
||||||
|
{
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ch = text[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw_CharScaled(((i + 1 + draw_icon) << 3) * scale, con.vislines - 22 * scale, ch, scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
|
|
||||||
#include "header/client.h"
|
#include "header/client.h"
|
||||||
|
|
||||||
|
void Key_ClearTyping(void);
|
||||||
|
void IN_GetClipboardText(char *out, size_t n);
|
||||||
|
int IN_SetClipboardText(const char *s);
|
||||||
|
|
||||||
static cvar_t *cfg_unbindall;
|
static cvar_t *cfg_unbindall;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -270,7 +274,7 @@ CompleteCommand(void)
|
||||||
{
|
{
|
||||||
const char *cmd, *s;
|
const char *cmd, *s;
|
||||||
|
|
||||||
s = key_lines[edit_line] + 1;
|
s = key_lines[edit_line];
|
||||||
|
|
||||||
if ((*s == '\\') || (*s == '/'))
|
if ((*s == '\\') || (*s == '/'))
|
||||||
{
|
{
|
||||||
|
@ -278,74 +282,68 @@ CompleteCommand(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = Cmd_CompleteCommand(s);
|
cmd = Cmd_CompleteCommand(s);
|
||||||
|
if (!cmd)
|
||||||
if (cmd)
|
|
||||||
{
|
{
|
||||||
key_lines[edit_line][1] = '/';
|
return;
|
||||||
strcpy(key_lines[edit_line] + 2, cmd);
|
|
||||||
key_linepos = strlen(cmd) + 2;
|
|
||||||
|
|
||||||
if (Cmd_IsComplete(cmd))
|
|
||||||
{
|
|
||||||
key_lines[edit_line][key_linepos] = ' ';
|
|
||||||
key_linepos++;
|
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
*key_lines[edit_line] = '/';
|
||||||
|
strcpy(key_lines[edit_line] + 1, cmd);
|
||||||
|
key_linepos = strlen(cmd) + 1;
|
||||||
|
|
||||||
|
if (Cmd_IsComplete(cmd))
|
||||||
|
{
|
||||||
|
key_lines[edit_line][key_linepos] = ' ';
|
||||||
|
key_linepos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
key_lines[edit_line][key_linepos] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CompleteMapNameCommand(void)
|
CompleteMapNameCommand(void)
|
||||||
{
|
{
|
||||||
int i;
|
const char *s, *cmdArg;
|
||||||
const char *s, *t, *cmdArg;
|
|
||||||
const char *mapCmdString = "map ";
|
const char *mapCmdString = "map ";
|
||||||
|
|
||||||
s = key_lines[edit_line] + 1;
|
s = key_lines[edit_line];
|
||||||
|
|
||||||
if ((*s == '\\') || (*s == '/'))
|
if ((*s == '\\') || (*s == '/'))
|
||||||
{
|
{
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = s;
|
if (strncmp(mapCmdString, s, strlen(mapCmdString)) != 0)
|
||||||
|
|
||||||
for (i = 0; i < strlen(mapCmdString); i++)
|
|
||||||
{
|
{
|
||||||
if (t[i] == mapCmdString[i])
|
return;
|
||||||
{
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdArg = Cmd_CompleteMapCommand(s);
|
cmdArg = Cmd_CompleteMapCommand(s + strlen(mapCmdString));
|
||||||
|
|
||||||
if (cmdArg)
|
if (cmdArg)
|
||||||
{
|
{
|
||||||
key_lines[edit_line][1] = '/';
|
snprintf(key_lines[edit_line], MAXCMDLINE, "/%s%s", mapCmdString, cmdArg);
|
||||||
strcpy(key_lines[edit_line] + 2, mapCmdString);
|
|
||||||
key_linepos = strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
strcpy(key_lines[edit_line] + key_linepos, cmdArg);
|
|
||||||
key_linepos = key_linepos + strlen(cmdArg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interactive line editing and console scrollback
|
* Interactive line editing and console scrollback
|
||||||
*/
|
*/
|
||||||
|
static int
|
||||||
|
IsInConsole(void)
|
||||||
|
{
|
||||||
|
return cls.key_dest == key_console ||
|
||||||
|
(cls.key_dest == key_game &&
|
||||||
|
(cls.state == ca_disconnected || cls.state == ca_connecting));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Key_Console(int key)
|
Key_Console(int key)
|
||||||
{
|
{
|
||||||
|
char txt[2];
|
||||||
|
char cliptext[256];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ignore keypad in console to prevent duplicate
|
* Ignore keypad in console to prevent duplicate
|
||||||
* entries through key presses processed as a
|
* entries through key presses processed as a
|
||||||
|
@ -375,35 +373,63 @@ Key_Console(int key)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == 'l')
|
if (keydown[K_CTRL])
|
||||||
{
|
{
|
||||||
if (keydown[K_CTRL])
|
if (key == 'l')
|
||||||
{
|
{
|
||||||
Cbuf_AddText("clear\n");
|
Cbuf_AddText("clear\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key == 'c' || key == 'x')
|
||||||
|
{
|
||||||
|
if (*key_lines[edit_line] != '\0')
|
||||||
|
{
|
||||||
|
if (IN_SetClipboardText(key_lines[edit_line]))
|
||||||
|
{
|
||||||
|
Com_Printf("Copy to clipboard failed.\n");
|
||||||
|
}
|
||||||
|
else if (key == 'x')
|
||||||
|
{
|
||||||
|
Key_ClearTyping();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == 'v')
|
||||||
|
{
|
||||||
|
IN_GetClipboardText(cliptext, sizeof(cliptext));
|
||||||
|
|
||||||
|
if (*cliptext != '\0')
|
||||||
|
{
|
||||||
|
key_linepos += Q_strins(key_lines[edit_line], cliptext, key_linepos, MAXCMDLINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((key == K_ENTER) || (key == K_KP_ENTER))
|
if ((key == K_ENTER) || (key == K_KP_ENTER))
|
||||||
{
|
{
|
||||||
/* slash text are commands, else chat */
|
/* slash text are commands, else chat */
|
||||||
if ((key_lines[edit_line][1] == '\\') ||
|
if ((*key_lines[edit_line] == '\\') || (*key_lines[edit_line] == '/'))
|
||||||
(key_lines[edit_line][1] == '/'))
|
|
||||||
{
|
{
|
||||||
Cbuf_AddText(key_lines[edit_line] + 2); /* skip the > */
|
Cbuf_AddText(key_lines[edit_line] + 1); /* skip the > */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Cbuf_AddText(key_lines[edit_line] + 1); /* valid command */
|
Cbuf_AddText(key_lines[edit_line]); /* valid command */
|
||||||
}
|
}
|
||||||
|
|
||||||
Cbuf_AddText("\n");
|
Cbuf_AddText("\n");
|
||||||
Com_Printf("%s\n", key_lines[edit_line]);
|
Com_Printf("%c%s\n", CON_INPUT_INDICATOR, key_lines[edit_line]);
|
||||||
|
|
||||||
edit_line = (edit_line + 1) & (NUM_KEY_LINES - 1);
|
edit_line = (edit_line + 1) & (NUM_KEY_LINES - 1);
|
||||||
history_line = edit_line;
|
history_line = edit_line;
|
||||||
key_lines[edit_line][0] = ']';
|
|
||||||
key_lines[edit_line][1] = '\0';
|
Key_ClearTyping();
|
||||||
key_linepos = 1;
|
|
||||||
|
|
||||||
if (cls.state == ca_disconnected)
|
if (cls.state == ca_disconnected)
|
||||||
{
|
{
|
||||||
|
@ -423,12 +449,32 @@ Key_Console(int key)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((key == K_BACKSPACE) || (key == K_LEFTARROW) ||
|
if (key == K_LEFTARROW)
|
||||||
(key == K_KP_LEFTARROW) ||
|
{
|
||||||
|
if (key_linepos > 0)
|
||||||
|
{
|
||||||
|
key_linepos--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == K_RIGHTARROW)
|
||||||
|
{
|
||||||
|
if (key_lines[edit_line][key_linepos] != '\0')
|
||||||
|
{
|
||||||
|
key_linepos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((key == K_BACKSPACE) ||
|
||||||
((key == 'h') && (keydown[K_CTRL])))
|
((key == 'h') && (keydown[K_CTRL])))
|
||||||
{
|
{
|
||||||
if (key_linepos > 1)
|
if (key_linepos > 0)
|
||||||
{
|
{
|
||||||
|
Q_strdel(key_lines[edit_line], key_linepos - 1, 1);
|
||||||
key_linepos--;
|
key_linepos--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,9 +483,11 @@ Key_Console(int key)
|
||||||
|
|
||||||
if (key == K_DEL)
|
if (key == K_DEL)
|
||||||
{
|
{
|
||||||
memmove(key_lines[edit_line] + key_linepos,
|
if (key_lines[edit_line][key_linepos] != '\0')
|
||||||
key_lines[edit_line] + key_linepos + 1,
|
{
|
||||||
sizeof(key_lines[edit_line]) - key_linepos - 1);
|
Q_strdel(key_lines[edit_line], key_linepos, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +499,7 @@ Key_Console(int key)
|
||||||
history_line = (history_line - 1) & (NUM_KEY_LINES-1);
|
history_line = (history_line - 1) & (NUM_KEY_LINES-1);
|
||||||
}
|
}
|
||||||
while (history_line != edit_line &&
|
while (history_line != edit_line &&
|
||||||
!key_lines[history_line][1]);
|
key_lines[history_line][0] == '\0');
|
||||||
|
|
||||||
if (history_line == edit_line)
|
if (history_line == edit_line)
|
||||||
{
|
{
|
||||||
|
@ -459,7 +507,8 @@ Key_Console(int key)
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
||||||
key_linepos = (int)strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,17 +525,16 @@ Key_Console(int key)
|
||||||
history_line = (history_line + 1) & (NUM_KEY_LINES-1);
|
history_line = (history_line + 1) & (NUM_KEY_LINES-1);
|
||||||
}
|
}
|
||||||
while (history_line != edit_line &&
|
while (history_line != edit_line &&
|
||||||
!key_lines[history_line][1]);
|
key_lines[history_line][0] == '\0');
|
||||||
|
|
||||||
if (history_line == edit_line)
|
if (history_line == edit_line)
|
||||||
{
|
{
|
||||||
key_lines[edit_line][0] = ']';
|
Key_ClearTyping();
|
||||||
key_linepos = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
memmove(key_lines[edit_line], key_lines[history_line], sizeof(key_lines[edit_line]));
|
||||||
key_linepos = (int)strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -521,7 +569,7 @@ Key_Console(int key)
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key_linepos = 1;
|
key_linepos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -536,7 +584,7 @@ Key_Console(int key)
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key_linepos = (int)strlen(key_lines[edit_line]);
|
key_linepos = strlen(key_lines[edit_line]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -547,32 +595,10 @@ Key_Console(int key)
|
||||||
return; /* non printable character */
|
return; /* non printable character */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_linepos < MAXCMDLINE - 1)
|
*txt = key;
|
||||||
{
|
*(txt + 1) = '\0';
|
||||||
int last;
|
|
||||||
int length;
|
|
||||||
|
|
||||||
length = strlen(key_lines[edit_line]);
|
key_linepos += Q_strins(key_lines[edit_line], txt, key_linepos, MAXCMDLINE);
|
||||||
|
|
||||||
if (length >= MAXCMDLINE - 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
last = key_lines[edit_line][key_linepos];
|
|
||||||
|
|
||||||
memmove(key_lines[edit_line] + key_linepos + 1,
|
|
||||||
key_lines[edit_line] + key_linepos,
|
|
||||||
length - key_linepos);
|
|
||||||
|
|
||||||
key_lines[edit_line][key_linepos] = key;
|
|
||||||
key_linepos++;
|
|
||||||
|
|
||||||
if (!last)
|
|
||||||
{
|
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean chat_team;
|
qboolean chat_team;
|
||||||
|
@ -953,7 +979,7 @@ Key_WriteConsoleHistory()
|
||||||
int lineIdx = (edit_line+i) & (NUM_KEY_LINES-1);
|
int lineIdx = (edit_line+i) & (NUM_KEY_LINES-1);
|
||||||
const char* line = key_lines[lineIdx];
|
const char* line = key_lines[lineIdx];
|
||||||
|
|
||||||
if(line[1] != '\0' && strcmp(lastWrittenLine, line ) != 0)
|
if(*line != '\0' && strcmp(lastWrittenLine, line) != 0)
|
||||||
{
|
{
|
||||||
// if the line actually contains something besides the ] prompt,
|
// if the line actually contains something besides the ] prompt,
|
||||||
// and is not identical to the last written line, write it to the file
|
// and is not identical to the last written line, write it to the file
|
||||||
|
@ -1000,6 +1026,7 @@ Key_ReadConsoleHistory()
|
||||||
history_line = i;
|
history_line = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing newlines
|
// remove trailing newlines
|
||||||
int lastCharIdx = strlen(key_lines[i])-1;
|
int lastCharIdx = strlen(key_lines[i])-1;
|
||||||
while((key_lines[i][lastCharIdx] == '\n' || key_lines[i][lastCharIdx] == '\r') && lastCharIdx >= 0)
|
while((key_lines[i][lastCharIdx] == '\n' || key_lines[i][lastCharIdx] == '\r') && lastCharIdx >= 0)
|
||||||
|
@ -1007,8 +1034,17 @@ Key_ReadConsoleHistory()
|
||||||
key_lines[i][lastCharIdx] = '\0';
|
key_lines[i][lastCharIdx] = '\0';
|
||||||
--lastCharIdx;
|
--lastCharIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* backwards compatibility with old history files */
|
||||||
|
if(key_lines[i][0] == ']')
|
||||||
|
{
|
||||||
|
memmove(key_lines[i], key_lines[i] + 1, MAXCMDLINE - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* don't remember the input line */
|
||||||
|
Key_ClearTyping();
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,12 +1068,11 @@ Key_Init(void)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < NUM_KEY_LINES; i++)
|
for (i = 0; i < NUM_KEY_LINES; i++)
|
||||||
{
|
{
|
||||||
key_lines[i][0] = ']';
|
key_lines[i][0] = '\0';
|
||||||
key_lines[i][1] = 0;
|
|
||||||
}
|
}
|
||||||
// can't call Key_ReadConsoleHistory() here because FS_Gamedir() isn't set yet
|
// can't call Key_ReadConsoleHistory() here because FS_Gamedir() isn't set yet
|
||||||
|
|
||||||
key_linepos = 1;
|
key_linepos = 0;
|
||||||
|
|
||||||
/* init 128 bit ascii characters in console mode */
|
/* init 128 bit ascii characters in console mode */
|
||||||
for (i = 32; i < 128; i++)
|
for (i = 32; i < 128; i++)
|
||||||
|
@ -1045,6 +1080,7 @@ Key_Init(void)
|
||||||
consolekeys[i] = true;
|
consolekeys[i] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
consolekeys[K_DEL] = true;
|
||||||
consolekeys[K_ENTER] = true;
|
consolekeys[K_ENTER] = true;
|
||||||
consolekeys[K_KP_ENTER] = true;
|
consolekeys[K_KP_ENTER] = true;
|
||||||
consolekeys[K_TAB] = true;
|
consolekeys[K_TAB] = true;
|
||||||
|
@ -1380,6 +1416,15 @@ Key_Event(int key, qboolean down, qboolean special)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: Better way to do CTRL+<key> actions in the console?
|
||||||
|
special should be set to true in this case.
|
||||||
|
*/
|
||||||
|
if (keydown[K_CTRL] && IsInConsole() &&
|
||||||
|
key >= 'a' && key <= 'z')
|
||||||
|
{
|
||||||
|
special = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* All input subsystems handled after this point only
|
/* All input subsystems handled after this point only
|
||||||
care for key down events (=> if(!down) returns above). */
|
care for key down events (=> if(!down) returns above). */
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#ifndef CL_HEADER_CONSOLE_H
|
#ifndef CL_HEADER_CONSOLE_H
|
||||||
#define CL_HEADER_CONSOLE_H
|
#define CL_HEADER_CONSOLE_H
|
||||||
|
|
||||||
|
#define CON_INPUT_INDICATOR ']'
|
||||||
|
#define CON_INPUT_CURSOR 11
|
||||||
|
|
||||||
#define NUM_CON_TIMES 4
|
#define NUM_CON_TIMES 4
|
||||||
#define CON_TEXTSIZE 32768
|
#define CON_TEXTSIZE 32768
|
||||||
|
|
||||||
|
|
|
@ -59,4 +59,12 @@ void IN_Update(void);
|
||||||
*/
|
*/
|
||||||
void In_FlushQueue(void);
|
void In_FlushQueue(void);
|
||||||
|
|
||||||
|
/* Clipboard get/set */
|
||||||
|
|
||||||
|
/* Copy clipboard to buffer of size n */
|
||||||
|
void IN_GetClipboardText(char *out, size_t n);
|
||||||
|
|
||||||
|
/* Copy text to clipboard */
|
||||||
|
int IN_SetClipboardText(const char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2302,3 +2302,25 @@ IN_Shutdown(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
void
|
||||||
|
IN_GetClipboardText(char *out, size_t n)
|
||||||
|
{
|
||||||
|
char *s = SDL_GetClipboardText();
|
||||||
|
|
||||||
|
if (!s || *s == '\0')
|
||||||
|
{
|
||||||
|
*out = '\0';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_strlcpy(out, s, n - 1);
|
||||||
|
|
||||||
|
SDL_free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
IN_SetClipboardText(const char *s)
|
||||||
|
{
|
||||||
|
return SDL_SetClipboardText(s);
|
||||||
|
}
|
||||||
|
|
|
@ -2410,3 +2410,25 @@ IN_Shutdown(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
void
|
||||||
|
IN_GetClipboardText(char *out, size_t n)
|
||||||
|
{
|
||||||
|
char *s = SDL_GetClipboardText();
|
||||||
|
|
||||||
|
if (!s || *s == '\0')
|
||||||
|
{
|
||||||
|
*out = '\0';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_strlcpy(out, s, n - 1);
|
||||||
|
|
||||||
|
SDL_free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
IN_SetClipboardText(const char *s)
|
||||||
|
{
|
||||||
|
return SDL_SetClipboardText(s);
|
||||||
|
}
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ CMod_LoadSubmodels(const char *name, cmodel_t *map_cmodels, int *numcmodels,
|
||||||
|
|
||||||
if (count > MAX_MAP_MODELS)
|
if (count > MAX_MAP_MODELS)
|
||||||
{
|
{
|
||||||
Com_Error(ERR_DROP, "%s: Map has too many models", __func__);
|
Com_Error(ERR_DROP, "%s: Map %s has too many models", __func__, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
*numcmodels = count;
|
*numcmodels = count;
|
||||||
|
@ -1708,7 +1708,7 @@ CMod_LoadEntityString(const char *name, const char **map_entitystring, int *nume
|
||||||
}
|
}
|
||||||
else if (bufLen != -1)
|
else if (bufLen != -1)
|
||||||
{
|
{
|
||||||
/* If the .ent file is too small, don't load. */
|
/* If the .ent file is too small or large, don't load. */
|
||||||
Com_Printf("%s: .ent file %s too small.\n", __func__, entname);
|
Com_Printf("%s: .ent file %s too small.\n", __func__, entname);
|
||||||
FS_FreeFile(buffer);
|
FS_FreeFile(buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,6 +334,13 @@ char *Q_strlwr(char *s);
|
||||||
int Q_strlcpy(char *dst, const char *src, int size);
|
int Q_strlcpy(char *dst, const char *src, int size);
|
||||||
int Q_strlcat(char *dst, const char *src, int size);
|
int Q_strlcat(char *dst, const char *src, int size);
|
||||||
|
|
||||||
|
/* Delete n characters from s starting at index i */
|
||||||
|
void Q_strdel(char *s, size_t i, size_t n);
|
||||||
|
|
||||||
|
/* Insert src into dest starting at index i, total, n is the total size of the buffer */
|
||||||
|
/* Returns length of src on success, 0 if there is not enough space in dest for src */
|
||||||
|
size_t Q_strins(char *dest, const char *src, size_t i, size_t n);
|
||||||
|
|
||||||
/* ============================================= */
|
/* ============================================= */
|
||||||
|
|
||||||
/* Unicode wrappers that also make sure it's a regular file around fopen(). */
|
/* Unicode wrappers that also make sure it's a regular file around fopen(). */
|
||||||
|
|
|
@ -1150,6 +1150,52 @@ Q_strlcat(char *dst, const char *src, int size)
|
||||||
return (d - dst) + Q_strlcpy(d, src, size);
|
return (d - dst) + Q_strlcpy(d, src, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Q_strdel(char *s, size_t i, size_t n)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (!n)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = strlen(s);
|
||||||
|
|
||||||
|
if (i >= len || n > (len - i))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove(s + i, s + i + n, len - i);
|
||||||
|
s[len - n] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
Q_strins(char *dest, const char *src, size_t i, size_t n)
|
||||||
|
{
|
||||||
|
size_t dlen;
|
||||||
|
size_t slen;
|
||||||
|
|
||||||
|
if (!src || *src == '\0')
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
slen = strlen(src);
|
||||||
|
dlen = strlen(dest);
|
||||||
|
|
||||||
|
if (i > dlen || (dlen + slen + 1) > n)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove(dest + i + slen, dest + i, dlen - i + 1);
|
||||||
|
memcpy(dest + i, src, slen);
|
||||||
|
|
||||||
|
return slen;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An unicode compatible fopen() Wrapper for Windows.
|
* An unicode compatible fopen() Wrapper for Windows.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue