2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
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
|
2011-05-15 13:23:13 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
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 the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
// console.c
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
|
|
|
|
|
|
|
console_t con_main;
|
2011-06-16 02:03:57 +00:00
|
|
|
console_t *con_current; // points to whatever is the visible console
|
|
|
|
console_t *con_chat; // points to a chat console
|
2012-11-27 03:23:19 +00:00
|
|
|
conline_t *con_footerline; //temp text at the bottom of the console
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
#define Font_ScreenWidth() (vid.pixelwidth)
|
2009-07-05 18:45:53 +00:00
|
|
|
|
2009-07-07 20:00:19 +00:00
|
|
|
static int Con_DrawProgress(int left, int right, int y);
|
2012-11-27 03:23:19 +00:00
|
|
|
static int Con_DrawConsoleLines(conline_t *l, int sx, int ex, int y, int top, qboolean selactive, int selsx, int selex, int selsy, int seley);
|
2009-07-05 18:45:53 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
#ifdef QTERM
|
|
|
|
#include <windows.h>
|
|
|
|
typedef struct qterm_s {
|
2005-01-13 16:29:20 +00:00
|
|
|
console_t *console;
|
2004-08-23 00:15:46 +00:00
|
|
|
qboolean running;
|
|
|
|
HANDLE process;
|
|
|
|
HANDLE pipein;
|
|
|
|
HANDLE pipeout;
|
|
|
|
|
|
|
|
HANDLE pipeinih;
|
|
|
|
HANDLE pipeoutih;
|
|
|
|
|
|
|
|
struct qterm_s *next;
|
|
|
|
} qterm_t;
|
|
|
|
|
|
|
|
qterm_t *qterms;
|
|
|
|
qterm_t *activeqterm;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//int con_linewidth; // characters across screen
|
|
|
|
//int con_totallines; // total lines in console scrollback
|
|
|
|
|
|
|
|
float con_cursorspeed = 4;
|
|
|
|
|
|
|
|
|
2006-02-11 02:09:43 +00:00
|
|
|
cvar_t con_numnotifylines = SCVAR("con_notifylines","4"); //max lines to show
|
|
|
|
cvar_t con_notifytime = SCVAR("con_notifytime","3"); //seconds
|
|
|
|
cvar_t con_centernotify = SCVAR("con_centernotify", "0");
|
2007-10-08 12:56:17 +00:00
|
|
|
cvar_t con_displaypossibilities = SCVAR("con_displaypossibilities", "1");
|
2009-07-05 18:45:53 +00:00
|
|
|
cvar_t con_maxlines = SCVAR("con_maxlines", "1024");
|
2006-02-11 02:09:43 +00:00
|
|
|
cvar_t cl_chatmode = SCVAR("cl_chatmode", "2");
|
2011-06-16 02:03:57 +00:00
|
|
|
cvar_t con_numnotifylines_chat = CVAR("con_numnotifylines_chat", "8");
|
|
|
|
cvar_t con_notifytime_chat = CVAR("con_notifytime_chat", "8");
|
|
|
|
cvar_t con_separatechat = CVAR("con_separatechat", "0");
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2004-12-26 04:47:34 +00:00
|
|
|
#define NUM_CON_TIMES 24
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-18 20:23:56 +00:00
|
|
|
static conline_t *selstartline, *selendline;
|
|
|
|
static unsigned int selstartoffset, selendoffset;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
qboolean con_initialized;
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
/*makes sure the console object works*/
|
|
|
|
void Con_Finit (console_t *con)
|
|
|
|
{
|
|
|
|
if (con->current == NULL)
|
|
|
|
{
|
|
|
|
con->oldest = con->current = Z_Malloc(sizeof(conline_t));
|
|
|
|
con->linecount = 0;
|
|
|
|
}
|
|
|
|
if (con->display == NULL)
|
|
|
|
con->display = con->current;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
/*returns a bitmask:
|
|
|
|
1: currently active
|
|
|
|
2: has text that has not been seen yet
|
|
|
|
*/
|
|
|
|
int Con_IsActive (console_t *con)
|
2005-01-13 16:29:20 +00:00
|
|
|
{
|
2006-02-02 01:13:52 +00:00
|
|
|
return (con == con_current) | (con->unseentext*2);
|
2005-01-13 16:29:20 +00:00
|
|
|
}
|
2011-04-30 17:21:10 +00:00
|
|
|
/*kills a console_t object. will never destroy the main console (which will only be cleared)*/
|
2005-01-13 16:29:20 +00:00
|
|
|
void Con_Destroy (console_t *con)
|
|
|
|
{
|
|
|
|
console_t *prev;
|
2011-04-30 17:21:10 +00:00
|
|
|
conline_t *t;
|
|
|
|
/*purge the lines from the console*/
|
|
|
|
while (con->current)
|
|
|
|
{
|
|
|
|
t = con->current;
|
|
|
|
con->current = t->older;
|
|
|
|
Z_Free(t);
|
|
|
|
}
|
|
|
|
con->display = con->current = con->oldest = NULL;
|
|
|
|
selstartline = NULL;
|
|
|
|
selendline = NULL;
|
2005-12-20 23:34:06 +00:00
|
|
|
|
|
|
|
if (con == &con_main)
|
2011-06-16 02:03:57 +00:00
|
|
|
{
|
2012-07-05 19:42:36 +00:00
|
|
|
/*main console is never destroyed, only cleared (unless shutting down)*/
|
|
|
|
if (con_initialized)
|
|
|
|
Con_Finit(con);
|
2005-12-20 23:34:06 +00:00
|
|
|
return;
|
2011-06-16 02:03:57 +00:00
|
|
|
}
|
2005-12-20 23:34:06 +00:00
|
|
|
|
2005-01-13 16:29:20 +00:00
|
|
|
for (prev = &con_main; prev->next; prev = prev->next)
|
|
|
|
{
|
|
|
|
if (prev->next == con)
|
|
|
|
{
|
|
|
|
prev->next = con->next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BZ_Free(con);
|
2005-12-20 23:34:06 +00:00
|
|
|
|
2006-02-02 01:13:52 +00:00
|
|
|
if (con_current == con)
|
|
|
|
con_current = &con_main;
|
2005-01-13 16:29:20 +00:00
|
|
|
}
|
2010-03-14 14:35:56 +00:00
|
|
|
/*obtains a console_t without creating*/
|
2005-01-13 16:29:20 +00:00
|
|
|
console_t *Con_FindConsole(char *name)
|
|
|
|
{
|
|
|
|
console_t *con;
|
|
|
|
for (con = &con_main; con; con = con->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(con->name, name))
|
|
|
|
return con;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-03-14 14:35:56 +00:00
|
|
|
/*creates a potentially duplicate console_t - please use Con_FindConsole first, as its confusing otherwise*/
|
2011-06-16 02:03:57 +00:00
|
|
|
console_t *Con_Create(char *name, unsigned int flags)
|
2005-01-13 16:29:20 +00:00
|
|
|
{
|
|
|
|
console_t *con;
|
2009-03-07 03:55:51 +00:00
|
|
|
con = Z_Malloc(sizeof(console_t));
|
2005-01-13 16:29:20 +00:00
|
|
|
Q_strncpyz(con->name, name, sizeof(con->name));
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
con->flags = flags;
|
2010-03-14 14:35:56 +00:00
|
|
|
Con_Finit(con);
|
2005-01-13 16:29:20 +00:00
|
|
|
con->next = con_main.next;
|
|
|
|
con_main.next = con;
|
|
|
|
|
|
|
|
return con;
|
|
|
|
}
|
2010-03-14 14:35:56 +00:00
|
|
|
/*sets a console as the active one*/
|
2005-12-20 23:34:06 +00:00
|
|
|
void Con_SetActive (console_t *con)
|
2005-01-13 16:29:20 +00:00
|
|
|
{
|
|
|
|
con_current = con;
|
2012-11-27 03:23:19 +00:00
|
|
|
|
|
|
|
if (con_footerline)
|
|
|
|
{
|
|
|
|
selstartline = NULL;
|
|
|
|
selendline = NULL;
|
|
|
|
Z_Free(con_footerline);
|
|
|
|
con_footerline = NULL;
|
|
|
|
}
|
2005-01-13 16:29:20 +00:00
|
|
|
}
|
2010-03-14 14:35:56 +00:00
|
|
|
/*for enumerating consoles*/
|
2005-12-20 23:34:06 +00:00
|
|
|
qboolean Con_NameForNum(int num, char *buffer, int buffersize)
|
|
|
|
{
|
|
|
|
console_t *con;
|
|
|
|
for (con = &con_main; con; con = con->next, num--)
|
|
|
|
{
|
|
|
|
if (num <= 0)
|
|
|
|
{
|
|
|
|
Q_strncpyz(buffer, con->name, buffersize);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (buffersize>0)
|
|
|
|
*buffer = '\0';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
/*print text to a console*/
|
2005-01-13 16:29:20 +00:00
|
|
|
void Con_PrintCon (console_t *con, char *txt);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef QTERM
|
|
|
|
void QT_Update(void)
|
|
|
|
{
|
|
|
|
char buffer[2048];
|
2004-09-13 04:16:52 +00:00
|
|
|
DWORD ret;
|
2004-08-23 00:15:46 +00:00
|
|
|
qterm_t *qt;
|
|
|
|
qterm_t *prev = NULL;
|
|
|
|
for (qt = qterms; qt; qt = (prev=qt)->next)
|
|
|
|
{
|
|
|
|
if (!qt->running)
|
|
|
|
{
|
2005-01-13 16:29:20 +00:00
|
|
|
if (Con_IsActive(qt->console))
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
2005-01-13 16:29:20 +00:00
|
|
|
|
|
|
|
Con_Destroy(qt->console);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (prev)
|
|
|
|
prev->next = qt->next;
|
|
|
|
else
|
|
|
|
qterms = qt->next;
|
|
|
|
|
|
|
|
CloseHandle(qt->pipein);
|
|
|
|
CloseHandle(qt->pipeout);
|
|
|
|
|
|
|
|
CloseHandle(qt->pipeinih);
|
|
|
|
CloseHandle(qt->pipeoutih);
|
|
|
|
CloseHandle(qt->process);
|
|
|
|
|
|
|
|
Z_Free(qt);
|
|
|
|
break; //be lazy.
|
|
|
|
}
|
|
|
|
if (WaitForSingleObject(qt->process, 0) == WAIT_TIMEOUT)
|
|
|
|
{
|
2004-09-13 04:16:52 +00:00
|
|
|
if ((ret=GetFileSize(qt->pipeout, NULL)))
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
if (ret!=INVALID_FILE_SIZE)
|
|
|
|
{
|
|
|
|
ReadFile(qt->pipeout, buffer, sizeof(buffer)-32, &ret, NULL);
|
|
|
|
buffer[ret] = '\0';
|
2005-01-13 16:29:20 +00:00
|
|
|
Con_PrintCon(qt->console, buffer);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-13 16:29:20 +00:00
|
|
|
Con_PrintCon(qt->console, "Process ended\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
qt->running = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-13 16:29:20 +00:00
|
|
|
void QT_KeyPress(void *user, int key)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
qbyte k[2];
|
2005-01-13 16:29:20 +00:00
|
|
|
qterm_t *qt = user;
|
2004-09-13 04:16:52 +00:00
|
|
|
DWORD send = key; //get around a gcc warning
|
2005-01-13 16:29:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
k[0] = key;
|
|
|
|
k[1] = '\0';
|
|
|
|
|
|
|
|
if (qt->running)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2005-01-13 16:29:20 +00:00
|
|
|
if (*k == '\r')
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
// *k = '\r';
|
|
|
|
// WriteFile(qt->pipein, k, 1, &key, NULL);
|
|
|
|
// Con_PrintCon(k, &qt->console);
|
2005-01-13 16:29:20 +00:00
|
|
|
*k = '\n';
|
|
|
|
}
|
|
|
|
if (GetFileSize(qt->pipein, NULL)<512)
|
|
|
|
{
|
|
|
|
WriteFile(qt->pipein, k, 1, &send, NULL);
|
|
|
|
Con_PrintCon(qt->console, k);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-13 16:29:20 +00:00
|
|
|
return;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QT_Create(char *command)
|
|
|
|
{
|
|
|
|
HANDLE StdIn[2];
|
|
|
|
HANDLE StdOut[2];
|
|
|
|
qterm_t *qt;
|
|
|
|
SECURITY_ATTRIBUTES sa;
|
|
|
|
STARTUPINFO SUInf;
|
|
|
|
PROCESS_INFORMATION ProcInfo;
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
qt = Z_Malloc(sizeof(*qt));
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
memset(&sa,0,sizeof(sa));
|
|
|
|
sa.nLength=sizeof(sa);
|
|
|
|
sa.bInheritHandle=true;
|
|
|
|
|
|
|
|
CreatePipe(&StdOut[0], &StdOut[1], &sa, 1024);
|
|
|
|
CreatePipe(&StdIn[1], &StdIn[0], &sa, 1024);
|
|
|
|
|
|
|
|
memset(&SUInf, 0, sizeof(SUInf));
|
|
|
|
SUInf.cb = sizeof(SUInf);
|
|
|
|
SUInf.dwFlags = STARTF_USESTDHANDLES;
|
|
|
|
/*
|
|
|
|
qt->pipeout = StdOut[0];
|
|
|
|
qt->pipein = StdIn[0];
|
|
|
|
*/
|
|
|
|
qt->pipeoutih = StdOut[1];
|
|
|
|
qt->pipeinih = StdIn[1];
|
|
|
|
|
2011-05-15 13:23:13 +00:00
|
|
|
if (!DuplicateHandle(GetCurrentProcess(), StdIn[0],
|
|
|
|
GetCurrentProcess(), &qt->pipein, 0,
|
|
|
|
FALSE, // not inherited
|
2004-08-23 00:15:46 +00:00
|
|
|
DUPLICATE_SAME_ACCESS))
|
|
|
|
qt->pipein = StdIn[0];
|
|
|
|
else
|
2011-05-15 13:23:13 +00:00
|
|
|
CloseHandle(StdIn[0]);
|
|
|
|
if (!DuplicateHandle(GetCurrentProcess(), StdOut[0],
|
|
|
|
GetCurrentProcess(), &qt->pipeout, 0,
|
|
|
|
FALSE, // not inherited
|
2004-08-23 00:15:46 +00:00
|
|
|
DUPLICATE_SAME_ACCESS))
|
|
|
|
qt->pipeout = StdOut[0];
|
|
|
|
else
|
2011-05-15 13:23:13 +00:00
|
|
|
CloseHandle(StdOut[0]);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
SUInf.hStdInput = qt->pipeinih;
|
|
|
|
SUInf.hStdOutput = qt->pipeoutih;
|
|
|
|
SUInf.hStdError = qt->pipeoutih; //we don't want to have to bother working out which one was written to first.
|
|
|
|
|
|
|
|
if (!SetStdHandle(STD_OUTPUT_HANDLE, SUInf.hStdOutput))
|
|
|
|
Con_Printf("Windows sucks\n");
|
|
|
|
if (!SetStdHandle(STD_ERROR_HANDLE, SUInf.hStdError))
|
|
|
|
Con_Printf("Windows sucks\n");
|
|
|
|
if (!SetStdHandle(STD_INPUT_HANDLE, SUInf.hStdInput))
|
|
|
|
Con_Printf("Windows sucks\n");
|
|
|
|
|
|
|
|
printf("Started app\n");
|
|
|
|
ret = CreateProcess(NULL, command, NULL, NULL, true, CREATE_NO_WINDOW, NULL, NULL, &SUInf, &ProcInfo);
|
|
|
|
|
|
|
|
qt->process = ProcInfo.hProcess;
|
|
|
|
CloseHandle(ProcInfo.hThread);
|
|
|
|
|
|
|
|
qt->running = true;
|
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
qt->console = Con_Create("QTerm", 0);
|
2005-01-13 16:29:20 +00:00
|
|
|
qt->console->redirect = QT_KeyPress;
|
|
|
|
Con_PrintCon(qt->console, "Started Process\n");
|
|
|
|
Con_SetVisible(qt->console);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
qt->next = qterms;
|
|
|
|
qterms = activeqterm = qt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Con_QTerm_f(void)
|
|
|
|
{
|
2005-04-16 16:21:27 +00:00
|
|
|
if(Cmd_IsInsecure())
|
2004-12-21 04:27:55 +00:00
|
|
|
Con_Printf("Server tried stuffcmding a restricted commandqterm %s\n", Cmd_Args());
|
|
|
|
else
|
|
|
|
QT_Create(Cmd_Args());
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Key_ClearTyping (void)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
key_lines[edit_line] = BZ_Realloc(key_lines[edit_line], 2);
|
|
|
|
key_lines[edit_line][0] = ']';
|
2004-08-23 00:15:46 +00:00
|
|
|
key_lines[edit_line][1] = 0; // clear any typing
|
|
|
|
key_linepos = 1;
|
|
|
|
}
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
void Con_History_Load(void)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
char line[8192];
|
2012-11-27 03:23:19 +00:00
|
|
|
unsigned char *cr;
|
|
|
|
vfsfile_t *file = FS_OpenVFS("conhistory.txt", "rb", FS_ROOT);
|
|
|
|
|
|
|
|
for (edit_line=0 ; edit_line<=CON_EDIT_LINES_MASK ; edit_line++)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
key_lines[edit_line] = BZ_Realloc(key_lines[edit_line], 2);
|
2012-11-27 03:23:19 +00:00
|
|
|
key_lines[edit_line][0] = ']';
|
|
|
|
key_lines[edit_line][1] = 0;
|
|
|
|
}
|
|
|
|
edit_line = 0;
|
|
|
|
key_linepos = 1;
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
line[0] = ']';
|
|
|
|
while (VFS_GETS(file, line+1, sizeof(line)-1))
|
2012-11-27 03:23:19 +00:00
|
|
|
{
|
|
|
|
//strip a trailing \r if its from windows.
|
2013-04-13 08:15:18 +00:00
|
|
|
cr = line + strlen(line);
|
|
|
|
if (cr > line && cr[-1] == '\r')
|
2012-11-27 03:23:19 +00:00
|
|
|
cr[-1] = '\0';
|
2013-04-13 08:15:18 +00:00
|
|
|
key_lines[edit_line] = BZ_Realloc(key_lines[edit_line], strlen(line)+1);
|
|
|
|
strcpy(key_lines[edit_line], line);
|
2012-11-27 03:23:19 +00:00
|
|
|
edit_line = (edit_line + 1) & CON_EDIT_LINES_MASK;
|
|
|
|
}
|
|
|
|
VFS_CLOSE(file);
|
|
|
|
}
|
|
|
|
history_line = edit_line;
|
|
|
|
}
|
|
|
|
void Con_History_Save(void)
|
|
|
|
{
|
|
|
|
vfsfile_t *file = FS_OpenVFS("conhistory.txt", "wb", FS_ROOT);
|
|
|
|
int line;
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
line = edit_line - CON_EDIT_LINES_MASK;
|
|
|
|
if (line < 0)
|
|
|
|
line = 0;
|
|
|
|
for(; line < edit_line; line++)
|
|
|
|
{
|
|
|
|
VFS_PUTS(file, key_lines[line]+1);
|
|
|
|
#ifdef _WIN32 //use an \r\n for readability with notepad.
|
|
|
|
VFS_PUTS(file, "\r\n");
|
|
|
|
#else
|
|
|
|
VFS_PUTS(file, "\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
VFS_CLOSE(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_ToggleConsole_f
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Con_ToggleConsole_f (void)
|
|
|
|
{
|
2004-11-17 17:57:09 +00:00
|
|
|
SCR_EndLoadingPlaque();
|
2004-08-23 00:15:46 +00:00
|
|
|
Key_ClearTyping ();
|
|
|
|
|
|
|
|
if (key_dest == key_console)
|
|
|
|
{
|
2008-11-09 22:29:28 +00:00
|
|
|
if (m_state)
|
|
|
|
key_dest = key_menu;
|
2009-04-06 00:34:32 +00:00
|
|
|
else
|
2004-08-23 00:15:46 +00:00
|
|
|
key_dest = key_game;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
key_dest = key_console;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_ToggleChat_f
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Con_ToggleChat_f (void)
|
|
|
|
{
|
|
|
|
Key_ClearTyping ();
|
|
|
|
|
|
|
|
if (key_dest == key_console)
|
|
|
|
{
|
|
|
|
if (cls.state == ca_active)
|
|
|
|
key_dest = key_game;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
key_dest = key_console;
|
|
|
|
}
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
void Con_ClearCon(console_t *con)
|
|
|
|
{
|
|
|
|
conline_t *t;
|
|
|
|
while (con->current)
|
|
|
|
{
|
|
|
|
t = con->current;
|
|
|
|
con->current = t->older;
|
|
|
|
Z_Free(t);
|
|
|
|
}
|
|
|
|
con->display = con->current = con->oldest = NULL;
|
|
|
|
selstartline = NULL;
|
|
|
|
selendline = NULL;
|
|
|
|
|
|
|
|
/*reset the line pointers, create an active line*/
|
|
|
|
Con_Finit(con);
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_Clear_f
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Con_Clear_f (void)
|
|
|
|
{
|
2010-03-14 14:35:56 +00:00
|
|
|
Con_ClearCon(&con_main);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Cmd_ConEcho_f(void)
|
|
|
|
{
|
|
|
|
console_t *con;
|
|
|
|
con = Con_FindConsole(Cmd_Argv(1));
|
|
|
|
if (!con)
|
2011-06-16 02:03:57 +00:00
|
|
|
con = Con_Create(Cmd_Argv(1), 0);
|
2010-03-14 14:35:56 +00:00
|
|
|
if (con)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-03-14 14:35:56 +00:00
|
|
|
Cmd_ShiftArgs(1, false);
|
|
|
|
Con_PrintCon(con, Cmd_Args());
|
|
|
|
Con_PrintCon(con, "\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
void Cmd_ConClear_f(void)
|
|
|
|
{
|
|
|
|
console_t *con;
|
|
|
|
con = Con_FindConsole(Cmd_Argv(1));
|
|
|
|
if (con)
|
|
|
|
Con_ClearCon(con);
|
|
|
|
}
|
|
|
|
void Cmd_ConClose_f(void)
|
|
|
|
{
|
|
|
|
console_t *con;
|
|
|
|
con = Con_FindConsole(Cmd_Argv(1));
|
|
|
|
if (con)
|
|
|
|
Con_Destroy(con);
|
|
|
|
}
|
|
|
|
void Cmd_ConActivate_f(void)
|
|
|
|
{
|
|
|
|
console_t *con;
|
|
|
|
con = Con_FindConsole(Cmd_Argv(1));
|
|
|
|
if (con)
|
|
|
|
Con_SetActive(con);
|
|
|
|
}
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_MessageMode_f
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Con_MessageMode_f (void)
|
|
|
|
{
|
|
|
|
chat_team = false;
|
|
|
|
key_dest = key_message;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_MessageMode2_f
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Con_MessageMode2_f (void)
|
|
|
|
{
|
|
|
|
chat_team = true;
|
|
|
|
key_dest = key_message;
|
|
|
|
}
|
|
|
|
|
2009-04-06 00:34:32 +00:00
|
|
|
void Con_ForceActiveNow(void)
|
|
|
|
{
|
|
|
|
key_dest = key_console;
|
|
|
|
scr_conlines = scr_con_current = vid.height;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_Init
|
|
|
|
================
|
|
|
|
*/
|
2005-09-27 04:05:32 +00:00
|
|
|
void Log_Init (void);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
void Con_Init (void)
|
|
|
|
{
|
2005-01-13 16:29:20 +00:00
|
|
|
con_current = &con_main;
|
2010-03-14 14:35:56 +00:00
|
|
|
Con_Finit(&con_main);
|
|
|
|
|
2005-03-10 03:55:18 +00:00
|
|
|
con_main.linebuffered = Con_ExecuteLine;
|
|
|
|
con_main.commandcompletion = true;
|
2011-04-30 17:21:10 +00:00
|
|
|
|
|
|
|
con_initialized = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
Con_Printf ("Console initialized.\n");
|
|
|
|
|
|
|
|
//
|
|
|
|
// register our commands
|
|
|
|
//
|
|
|
|
Cvar_Register (&con_notifytime, "Console controls");
|
2005-05-17 02:36:54 +00:00
|
|
|
Cvar_Register (&con_centernotify, "Console controls");
|
2004-12-26 04:47:34 +00:00
|
|
|
Cvar_Register (&con_numnotifylines, "Console controls");
|
2007-10-08 12:56:17 +00:00
|
|
|
Cvar_Register (&con_displaypossibilities, "Console controls");
|
2005-06-14 04:52:10 +00:00
|
|
|
Cvar_Register (&cl_chatmode, "Console controls");
|
2009-07-05 18:45:53 +00:00
|
|
|
Cvar_Register (&con_maxlines, "Console controls");
|
2011-06-16 02:03:57 +00:00
|
|
|
Cvar_Register (&con_numnotifylines_chat, "Console controls");
|
|
|
|
Cvar_Register (&con_notifytime_chat, "Console controls");
|
|
|
|
Cvar_Register (&con_separatechat, "Console controls");
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
|
|
|
|
Cmd_AddCommand ("togglechat", Con_ToggleChat_f);
|
|
|
|
Cmd_AddCommand ("messagemode", Con_MessageMode_f);
|
|
|
|
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f);
|
|
|
|
Cmd_AddCommand ("clear", Con_Clear_f);
|
|
|
|
#ifdef QTERM
|
|
|
|
Cmd_AddCommand ("qterm", Con_QTerm_f);
|
|
|
|
#endif
|
2010-03-14 14:35:56 +00:00
|
|
|
|
|
|
|
Cmd_AddCommand ("conecho", Cmd_ConEcho_f);
|
|
|
|
Cmd_AddCommand ("conclear", Cmd_ConClear_f);
|
|
|
|
Cmd_AddCommand ("conclose", Cmd_ConClose_f);
|
|
|
|
Cmd_AddCommand ("conactivate", Cmd_ConActivate_f);
|
|
|
|
|
2005-09-27 04:05:32 +00:00
|
|
|
Log_Init();
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2011-04-30 17:21:10 +00:00
|
|
|
void Con_Shutdown(void)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
int i;
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
Con_History_Save();
|
|
|
|
|
2013-04-13 08:15:18 +00:00
|
|
|
for (i = 0; i <= CON_EDIT_LINES_MASK; i++)
|
|
|
|
{
|
|
|
|
BZ_Free(key_lines[i]);
|
|
|
|
}
|
|
|
|
|
2011-04-30 17:21:10 +00:00
|
|
|
while(con_main.next)
|
|
|
|
{
|
|
|
|
Con_Destroy(con_main.next);
|
|
|
|
}
|
|
|
|
con_initialized = false;
|
2012-07-05 19:42:36 +00:00
|
|
|
Con_Destroy(&con_main);
|
2012-11-27 03:23:19 +00:00
|
|
|
|
|
|
|
selstartline = NULL;
|
|
|
|
selendline = NULL;
|
|
|
|
if (con_footerline)
|
|
|
|
Z_Free(con_footerline);
|
|
|
|
con_footerline = NULL;
|
2011-04-30 17:21:10 +00:00
|
|
|
}
|
|
|
|
|
2012-01-01 15:34:02 +00:00
|
|
|
void TTS_SayConString(conchar_t *stringtosay);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_Print
|
|
|
|
|
|
|
|
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.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
|
2005-01-13 16:29:20 +00:00
|
|
|
void Con_PrintCon (console_t *con, char *txt)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-05-24 10:11:17 +00:00
|
|
|
conchar_t expanded[4096];
|
|
|
|
conchar_t *c;
|
2009-10-04 22:03:16 +00:00
|
|
|
conline_t *oc;
|
2005-01-04 07:26:49 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
COM_ParseFunString(CON_WHITEMASK, txt, expanded, sizeof(expanded), false);
|
2005-12-20 23:34:06 +00:00
|
|
|
|
2009-05-24 10:11:17 +00:00
|
|
|
c = expanded;
|
|
|
|
while (*c)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
conchar_t *o;
|
|
|
|
|
2010-12-23 03:55:10 +00:00
|
|
|
switch (*c & (CON_CHARMASK))
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2005-01-04 07:26:49 +00:00
|
|
|
case '\r':
|
2012-03-19 06:30:41 +00:00
|
|
|
con->cr = true;
|
2005-01-04 07:26:49 +00:00
|
|
|
break;
|
2009-07-05 18:45:53 +00:00
|
|
|
case '\n':
|
2012-03-19 06:30:41 +00:00
|
|
|
con->cr = false;
|
2010-11-28 19:16:12 +00:00
|
|
|
while (con->linecount >= con_maxlines.ival)
|
2009-07-05 18:45:53 +00:00
|
|
|
{
|
|
|
|
if (con->oldest == con->current)
|
|
|
|
break;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-18 20:23:56 +00:00
|
|
|
if (selstartline == con->oldest)
|
|
|
|
selstartline = NULL;
|
|
|
|
if (selendline == con->oldest)
|
|
|
|
selendline = NULL;
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
if (con->display == con->oldest)
|
|
|
|
con->display = con->oldest->newer;
|
|
|
|
con->oldest = con->oldest->newer;
|
|
|
|
Z_Free(con->oldest->older);
|
|
|
|
con->oldest->older = NULL;
|
|
|
|
con->linecount--;
|
|
|
|
}
|
|
|
|
con->linecount++;
|
2011-06-16 02:03:57 +00:00
|
|
|
if (con->flags & CONF_NOTIMES)
|
|
|
|
con->current->time = 0;
|
|
|
|
else
|
|
|
|
con->current->time = realtime;
|
2012-01-01 15:34:02 +00:00
|
|
|
|
|
|
|
#if defined(_WIN32) && !defined(NOMEDIA)
|
|
|
|
if (con->current)
|
2012-01-17 07:57:46 +00:00
|
|
|
TTS_SayConString((conchar_t*)(con->current+1));
|
2012-01-01 15:34:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
con->current->newer = Z_Malloc(sizeof(conline_t) + sizeof(conchar_t));
|
2009-07-05 18:45:53 +00:00
|
|
|
con->current->newer->older = con->current;
|
|
|
|
con->current = con->current->newer;
|
|
|
|
con->current->length = 0;
|
2012-01-01 15:34:02 +00:00
|
|
|
o = (conchar_t *)(con->current+1)+con->current->length;
|
|
|
|
*o = 0;
|
2009-07-05 18:45:53 +00:00
|
|
|
if (con->display == con->current->older)
|
|
|
|
con->display = con->current;
|
|
|
|
break;
|
|
|
|
default:
|
2012-03-19 06:30:41 +00:00
|
|
|
if (con->cr)
|
2009-07-25 11:05:06 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
con->current->length = 0;
|
2012-03-19 06:30:41 +00:00
|
|
|
con->cr = false;
|
2009-07-25 11:05:06 +00:00
|
|
|
}
|
2009-07-18 20:23:56 +00:00
|
|
|
|
|
|
|
if (selstartline == con->current)
|
|
|
|
selstartline = NULL;
|
|
|
|
if (selendline == con->current)
|
|
|
|
selendline = NULL;
|
|
|
|
|
2009-10-04 22:03:16 +00:00
|
|
|
oc = con->current;
|
2012-01-01 15:34:02 +00:00
|
|
|
con->current = BZ_Realloc(con->current, sizeof(*con->current)+(con->current->length+2)*sizeof(conchar_t));
|
2009-10-04 22:03:16 +00:00
|
|
|
if (con->display == oc)
|
2009-07-05 18:45:53 +00:00
|
|
|
con->display = con->current;
|
2009-10-04 22:03:16 +00:00
|
|
|
if (con->oldest == oc)
|
|
|
|
con->oldest = con->current;
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
if (con->current->older)
|
|
|
|
con->current->older->newer = con->current;
|
|
|
|
o = (conchar_t *)(con->current+1)+con->current->length;
|
|
|
|
*o = *c;
|
2012-01-01 15:34:02 +00:00
|
|
|
o[1] = 0;
|
2009-07-05 18:45:53 +00:00
|
|
|
con->current->length+=1;
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-05-24 10:11:17 +00:00
|
|
|
c++;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-26 08:07:26 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
void Con_Print (char *txt)
|
|
|
|
{
|
2005-01-13 16:29:20 +00:00
|
|
|
Con_PrintCon(&con_main, txt); //client console
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Con_CycleConsole(void)
|
|
|
|
{
|
2011-06-16 02:03:57 +00:00
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
con_current = con_current->next;
|
|
|
|
if (!con_current)
|
|
|
|
con_current = &con_main;
|
|
|
|
|
|
|
|
if (con_current->flags & CONF_HIDDEN)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2005-09-27 04:05:32 +00:00
|
|
|
void Con_Log(char *s);
|
2005-09-26 08:07:26 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_Printf
|
|
|
|
|
|
|
|
Handles cursor positioning, line wrapping, etc
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CLIENTONLY
|
|
|
|
extern redirect_t sv_redirected;
|
|
|
|
extern char outputbuf[8000];
|
|
|
|
void SV_FlushRedirect (void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAXPRINTMSG 4096
|
|
|
|
// FIXME: make a buffer size safe vsprintf?
|
|
|
|
void VARGS Con_Printf (const char *fmt, ...)
|
2011-05-15 13:23:13 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
va_list argptr;
|
|
|
|
char msg[MAXPRINTMSG];
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
va_start (argptr,fmt);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg), fmt,argptr);
|
2004-08-23 00:15:46 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
#ifndef CLIENTONLY
|
|
|
|
// add to redirected message
|
|
|
|
if (sv_redirected)
|
|
|
|
{
|
|
|
|
if (strlen (msg) + strlen(outputbuf) > sizeof(outputbuf) - 1)
|
|
|
|
SV_FlushRedirect ();
|
|
|
|
strcat (outputbuf, msg);
|
|
|
|
if (sv_redirected != -1)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2004-11-23 01:10:10 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
// also echo to debugging console
|
|
|
|
Sys_Printf ("%s", msg); // also echo to debugging console
|
|
|
|
|
|
|
|
// log all messages to file
|
2005-09-26 08:07:26 +00:00
|
|
|
Con_Log (msg);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (!con_initialized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// write it to the scrollable buffer
|
|
|
|
Con_Print (msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VARGS Con_SafePrintf (char *fmt, ...)
|
2011-05-15 13:23:13 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
va_list argptr;
|
|
|
|
char msg[MAXPRINTMSG];
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg)-1, fmt,argptr);
|
2004-08-23 00:15:46 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
// write it to the scrollable buffer
|
2011-05-15 13:23:13 +00:00
|
|
|
Con_Printf ("%s", msg);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VARGS Con_TPrintf (translation_t text, ...)
|
2011-05-15 13:23:13 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
va_list argptr;
|
|
|
|
char msg[MAXPRINTMSG];
|
|
|
|
char *fmt = languagetext[text][cls.language];
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
va_start (argptr,text);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg), fmt,argptr);
|
2004-08-23 00:15:46 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
// write it to the scrollable buffer
|
|
|
|
Con_Printf ("%s", msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VARGS Con_SafeTPrintf (translation_t text, ...)
|
2011-05-15 13:23:13 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
va_list argptr;
|
|
|
|
char msg[MAXPRINTMSG];
|
|
|
|
char *fmt = languagetext[text][cls.language];
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
va_start (argptr,text);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg), fmt,argptr);
|
2004-08-23 00:15:46 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
// write it to the scrollable buffer
|
|
|
|
Con_Printf ("%s", msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_DPrintf
|
|
|
|
|
|
|
|
A Con_Printf that only shows up if the "developer" cvar is set
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void VARGS Con_DPrintf (char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char msg[MAXPRINTMSG];
|
2005-09-27 04:05:32 +00:00
|
|
|
extern cvar_t log_developer;
|
2009-07-05 18:45:53 +00:00
|
|
|
|
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
|
|
|
#ifdef CRAZYDEBUGGING
|
|
|
|
va_start (argptr,fmt);
|
|
|
|
vsnprintf (msg,sizeof(msg)-1, fmt,argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
Sys_Printf("%s", msg);
|
|
|
|
return;
|
|
|
|
#else
|
2005-09-26 08:07:26 +00:00
|
|
|
if (!developer.value && !log_developer.value)
|
|
|
|
return; // early exit
|
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
|
|
|
#endif
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg)-1, fmt,argptr);
|
2004-08-23 00:15:46 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
2005-09-26 08:07:26 +00:00
|
|
|
if (!developer.value)
|
|
|
|
Con_Log(msg);
|
|
|
|
else
|
2009-07-05 18:45:53 +00:00
|
|
|
Con_PrintCon(&con_main, msg);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
/*description text at the bottom of the console*/
|
|
|
|
void Con_Footerf(qboolean append, char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char msg[MAXPRINTMSG];
|
|
|
|
conchar_t marked[MAXPRINTMSG], *markedend;
|
|
|
|
int oldlen, newlen;
|
|
|
|
conline_t *newf;
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
|
|
|
vsnprintf (msg,sizeof(msg)-1, fmt,argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
markedend = COM_ParseFunString(COLOR_YELLOW << CON_FGSHIFT, msg, marked, sizeof(marked), false);
|
|
|
|
|
|
|
|
newlen = markedend - marked;
|
|
|
|
if (append)
|
|
|
|
oldlen = con_footerline->length;
|
|
|
|
else
|
|
|
|
oldlen = 0;
|
|
|
|
|
|
|
|
if (!newlen && !oldlen)
|
|
|
|
newf = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newf = Z_Malloc(sizeof(*newf) + (oldlen + newlen) * sizeof(conchar_t));
|
|
|
|
if (con_footerline)
|
|
|
|
memcpy(newf, con_footerline, sizeof(*con_footerline)+oldlen*sizeof(conchar_t));
|
|
|
|
markedend = (void*)(newf+1);
|
|
|
|
markedend += oldlen;
|
|
|
|
memcpy(markedend, marked, newlen*sizeof(conchar_t));
|
|
|
|
newf->length = oldlen + newlen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selstartline == con_footerline)
|
|
|
|
selstartline = NULL;
|
|
|
|
if (selendline == con_footerline)
|
|
|
|
selendline = NULL;
|
|
|
|
Z_Free(con_footerline);
|
|
|
|
con_footerline = newf;
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
DRAWING
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_DrawInput
|
|
|
|
|
|
|
|
The input line scrolls horizontally if typing goes beyond the right edge
|
2012-03-19 06:30:41 +00:00
|
|
|
y is the bottom of the input
|
|
|
|
return value is the top of the region
|
2004-08-23 00:15:46 +00:00
|
|
|
================
|
|
|
|
*/
|
2012-11-27 03:23:19 +00:00
|
|
|
int Con_DrawInput (int left, int right, int y, qboolean selactive, int selsx, int selex, int selsy, int seley)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
extern qboolean ActiveApp;
|
|
|
|
#endif
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
2009-07-05 18:45:53 +00:00
|
|
|
int lhs, rhs;
|
2004-08-23 00:15:46 +00:00
|
|
|
int p;
|
2012-03-19 06:30:41 +00:00
|
|
|
unsigned char *text, *fname = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
extern int con_commandmatch;
|
2012-03-19 06:30:41 +00:00
|
|
|
conchar_t maskedtext[2048];
|
2009-07-05 18:45:53 +00:00
|
|
|
conchar_t *endmtext;
|
2010-05-01 22:47:47 +00:00
|
|
|
conchar_t *cursor;
|
|
|
|
conchar_t *cchar;
|
|
|
|
qboolean cursorframe;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
int x;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-03-19 06:30:41 +00:00
|
|
|
y -= Font_CharHeight();
|
|
|
|
|
2012-07-20 01:46:05 +00:00
|
|
|
if (key_dest != key_console)// && con_current->vislines != vid.height)
|
2012-03-19 06:30:41 +00:00
|
|
|
return y; // don't draw anything (always draw if not active)
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-03-10 03:55:18 +00:00
|
|
|
if (!con_current->linebuffered)
|
2012-03-19 06:30:41 +00:00
|
|
|
return y; //fixme: draw any unfinished lines of the current console instead.
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
text = key_lines[edit_line];
|
|
|
|
|
2005-03-10 03:55:18 +00:00
|
|
|
//copy it to an alternate buffer and fill in text colouration escape codes.
|
|
|
|
//if it's recognised as a command, colour it yellow.
|
|
|
|
//if it's not a command, and the cursor is at the end of the line, leave it as is,
|
|
|
|
// but add to the end to show what the compleation will be.
|
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
i = text[key_linepos];
|
|
|
|
text[key_linepos] = 0;
|
2013-03-12 22:44:00 +00:00
|
|
|
cursor = COM_ParseFunString(CON_WHITEMASK, text, maskedtext, sizeof(maskedtext) - sizeof(maskedtext[0]), PFS_KEEPMARKUP | PFS_FORCEUTF8);
|
2010-05-01 22:47:47 +00:00
|
|
|
text[key_linepos] = i;
|
2013-03-12 22:44:00 +00:00
|
|
|
endmtext = COM_ParseFunString(CON_WHITEMASK, text, maskedtext, sizeof(maskedtext) - sizeof(maskedtext[0]), PFS_KEEPMARKUP | PFS_FORCEUTF8);
|
|
|
|
// endmtext = COM_ParseFunString(CON_WHITEMASK, text+key_linepos, cursor, ((char*)maskedtext)+sizeof(maskedtext) - (char*)(cursor+1), PFS_KEEPMARKUP | PFS_FORCEUTF8);
|
2005-03-10 03:55:18 +00:00
|
|
|
|
2013-04-13 08:15:18 +00:00
|
|
|
if ((char*)endmtext == (char*)(maskedtext-2) + sizeof(maskedtext))
|
|
|
|
endmtext[-1] = CON_WHITEMASK | '+' | CON_NONCLEARBG;
|
2009-07-05 18:45:53 +00:00
|
|
|
endmtext[1] = 0;
|
2009-04-06 00:34:32 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
i = 0;
|
|
|
|
x = left;
|
2005-03-10 03:55:18 +00:00
|
|
|
|
|
|
|
if (con_current->commandcompletion)
|
|
|
|
{
|
2012-01-17 07:57:46 +00:00
|
|
|
if (cl_chatmode.ival && (text[1] == '/' || (cl_chatmode.ival == 2 && Cmd_IsCommand(text+1))))
|
2005-03-10 03:55:18 +00:00
|
|
|
{ //color the first token yellow, it's a valid command
|
2009-07-05 18:45:53 +00:00
|
|
|
for (p = 1; (maskedtext[p]&CON_CHARMASK)>' '; p++)
|
|
|
|
maskedtext[p] = (maskedtext[p]&CON_CHARMASK) | (COLOR_YELLOW<<CON_FGSHIFT);
|
2005-03-10 03:55:18 +00:00
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
// else
|
|
|
|
// Plug_SpellCheckMaskedText(maskedtext+1, i-1, x, y, 8, si, con_current->linewidth);
|
2009-04-06 00:34:32 +00:00
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
if (cursor == endmtext) //cursor is at end
|
2005-03-10 03:55:18 +00:00
|
|
|
{
|
2009-04-06 00:34:32 +00:00
|
|
|
int cmdstart;
|
|
|
|
cmdstart = text[1] == '/'?2:1;
|
2012-11-27 03:23:19 +00:00
|
|
|
fname = Cmd_CompleteCommand(text+cmdstart, true, true, con_commandmatch, NULL);
|
2013-04-13 08:15:18 +00:00
|
|
|
if (fname && strlen(fname) < 256) //we can compleate it to:
|
2005-03-10 03:55:18 +00:00
|
|
|
{
|
2012-03-19 06:30:41 +00:00
|
|
|
for (p = min(strlen(fname), key_linepos-cmdstart); fname[p]>' '; p++)
|
2009-07-05 18:45:53 +00:00
|
|
|
maskedtext[p+cmdstart] = (unsigned int)fname[p] | (COLOR_GREEN<<CON_FGSHIFT);
|
2012-03-19 06:30:41 +00:00
|
|
|
if (p < key_linepos-cmdstart)
|
|
|
|
p = key_linepos-cmdstart;
|
|
|
|
maskedtext[p+cmdstart] = 0;
|
2013-04-13 08:15:18 +00:00
|
|
|
maskedtext[p+cmdstart+1] = 0;
|
2005-03-10 03:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
// else
|
|
|
|
// Plug_SpellCheckMaskedText(maskedtext+1, i-1, x, y, 8, si, con_current->linewidth);
|
2005-03-10 03:55:18 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
#ifdef _WIN32
|
2010-05-01 22:47:47 +00:00
|
|
|
if (!ActiveApp)
|
|
|
|
cursorframe = 0;
|
|
|
|
else
|
2009-04-01 22:03:56 +00:00
|
|
|
#endif
|
2010-05-01 22:47:47 +00:00
|
|
|
cursorframe = ((int)(realtime*con_cursorspeed)&1);
|
2005-03-10 03:55:18 +00:00
|
|
|
|
2012-10-13 00:56:31 +00:00
|
|
|
for (lhs = 0, i = cursor - maskedtext-1; i >= 0; i--)
|
2005-03-10 03:55:18 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
lhs += Font_CharWidth(maskedtext[i]);
|
|
|
|
}
|
2012-10-13 00:56:31 +00:00
|
|
|
for (rhs = 0, i = cursor - maskedtext; maskedtext[i]; i++)
|
2009-07-05 18:45:53 +00:00
|
|
|
{
|
|
|
|
rhs += Font_CharWidth(maskedtext[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//put the cursor in the middle
|
|
|
|
x = (right-left)/2;
|
|
|
|
//move the line to the right if there's not enough text to touch the right hand side
|
|
|
|
if (x < right-rhs)
|
|
|
|
x = right - rhs;
|
|
|
|
//if the left hand side is on the right of the left point (overrides right alignment)
|
|
|
|
if (x - lhs > 0)
|
|
|
|
x = lhs;
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
lhs = x - lhs + left;
|
2010-05-01 22:47:47 +00:00
|
|
|
for (cchar = maskedtext; cchar < cursor; cchar++)
|
2009-07-05 18:45:53 +00:00
|
|
|
{
|
2010-05-01 22:47:47 +00:00
|
|
|
lhs = Font_DrawChar(lhs, y, *cchar);
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
|
|
|
rhs = x + left;
|
2010-05-01 22:47:47 +00:00
|
|
|
if (cursorframe)
|
|
|
|
{
|
2012-02-14 15:50:34 +00:00
|
|
|
// extern cvar_t com_parseutf8;
|
|
|
|
// if (com_parseutf8.ival)
|
|
|
|
// Font_DrawChar(rhs, y, (*cursor&~(CON_BGMASK|CON_FGMASK)) | (COLOR_BLUE<<CON_BGSHIFT) | CON_NONCLEARBG | CON_WHITEMASK);
|
|
|
|
// else
|
2010-05-01 22:47:47 +00:00
|
|
|
Font_DrawChar(rhs, y, 0xe000|11|CON_WHITEMASK);
|
|
|
|
}
|
|
|
|
else if (*cursor)
|
|
|
|
Font_DrawChar(rhs, y, *cursor);
|
|
|
|
rhs += Font_CharWidth(*cursor);
|
|
|
|
for (cchar = cursor+1; *cchar; cchar++)
|
2009-07-05 18:45:53 +00:00
|
|
|
{
|
2010-05-01 22:47:47 +00:00
|
|
|
rhs = Font_DrawChar(rhs, y, *cchar);
|
2005-03-10 03:55:18 +00:00
|
|
|
}
|
2012-03-19 06:30:41 +00:00
|
|
|
|
|
|
|
/*if its getting completed to something, show some help about the command that is going to be used*/
|
2012-11-27 03:23:19 +00:00
|
|
|
if (con_footerline)
|
2012-03-19 06:30:41 +00:00
|
|
|
{
|
2012-11-27 03:23:19 +00:00
|
|
|
y = Con_DrawConsoleLines(con_footerline, left, right, y, 0, selactive, selsx, selex, selsy, seley);
|
2012-03-19 06:30:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*just above that, we have the tab completion list*/
|
|
|
|
if (con_commandmatch && con_displaypossibilities.value)
|
|
|
|
{
|
|
|
|
int lines;
|
|
|
|
conchar_t *starts[32];
|
|
|
|
conchar_t *ends[32];
|
|
|
|
conchar_t *end;
|
|
|
|
char *cmd;
|
|
|
|
int cmdstart;
|
|
|
|
cmdstart = text[1] == '/'?2:1;
|
|
|
|
end = maskedtext;
|
|
|
|
|
|
|
|
for (i = 1; ; i++)
|
|
|
|
{
|
2012-11-27 03:23:19 +00:00
|
|
|
cmd = Cmd_CompleteCommand (text+cmdstart, true, true, i, NULL);
|
2012-03-19 06:30:41 +00:00
|
|
|
if (!cmd)
|
2013-03-12 22:44:00 +00:00
|
|
|
{
|
|
|
|
if (i <= 2)
|
|
|
|
con_commandmatch = 0;
|
2012-03-19 06:30:41 +00:00
|
|
|
break;
|
2013-03-12 22:44:00 +00:00
|
|
|
}
|
2012-03-19 06:30:41 +00:00
|
|
|
|
|
|
|
end = COM_ParseFunString((COLOR_GREEN<<CON_FGSHIFT), va("%s\t", cmd), end, (maskedtext+sizeof(maskedtext)/sizeof(maskedtext[0])-1-end)*sizeof(maskedtext[0]), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
lines = Font_LineBreaks(maskedtext, end, right - left, 32, starts, ends);
|
|
|
|
while(lines-->0)
|
|
|
|
{
|
|
|
|
rhs = left;
|
|
|
|
y -= Font_CharHeight();
|
|
|
|
for (cchar = starts[lines]; cchar < ends[lines]; cchar++)
|
|
|
|
{
|
|
|
|
rhs = Font_DrawChar(rhs, y, *cchar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return y;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_DrawNotify
|
|
|
|
|
|
|
|
Draws the last few lines of output transparently over the game top
|
|
|
|
================
|
|
|
|
*/
|
2011-06-16 02:03:57 +00:00
|
|
|
void Con_DrawNotifyOne (console_t *con)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
conchar_t *starts[NUM_CON_TIMES], *ends[NUM_CON_TIMES];
|
|
|
|
conchar_t *c;
|
|
|
|
conline_t *l;
|
2011-06-16 02:03:57 +00:00
|
|
|
int lines=con->notif_l;
|
2009-07-05 18:45:53 +00:00
|
|
|
int line;
|
2011-06-16 02:03:57 +00:00
|
|
|
int x = con->notif_x, y = con->notif_y;
|
|
|
|
int w = con->notif_w;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
int maxlines;
|
|
|
|
float t;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
Font_BeginString(font_conchar, x, y, &x, &y);
|
2011-06-16 02:03:57 +00:00
|
|
|
Font_Transform(con->notif_w, 0, &w, NULL);
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
if (con->notif_l < 0)
|
|
|
|
con->notif_l = 0;
|
|
|
|
if (con->notif_l > NUM_CON_TIMES)
|
|
|
|
con->notif_l = NUM_CON_TIMES;
|
|
|
|
lines = maxlines = con->notif_l;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
if (x == 0 && y == 0 && con->notif_w == vid.width)
|
|
|
|
y = Con_DrawProgress(0, w, 0);
|
2009-07-05 18:45:53 +00:00
|
|
|
|
|
|
|
l = con->current;
|
|
|
|
if (!l->length)
|
|
|
|
l = l->older;
|
2011-06-16 02:03:57 +00:00
|
|
|
for (; l && lines > con->notif_l-maxlines; l = l->older)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2011-06-16 02:03:57 +00:00
|
|
|
t = l->time;
|
2009-07-05 18:45:53 +00:00
|
|
|
if (!t)
|
2011-06-16 02:03:57 +00:00
|
|
|
continue; //hidden from notify
|
2009-07-05 18:45:53 +00:00
|
|
|
t = realtime - t;
|
2011-06-16 02:03:57 +00:00
|
|
|
if (t > con->notif_t)
|
2009-07-05 18:45:53 +00:00
|
|
|
break;
|
2005-05-17 02:36:54 +00:00
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
line = Font_LineBreaks((conchar_t*)(l+1), (conchar_t*)(l+1)+l->length, w, lines, starts, ends);
|
2009-07-05 18:45:53 +00:00
|
|
|
if (!line && lines > 0)
|
|
|
|
{
|
|
|
|
lines--;
|
|
|
|
starts[lines] = NULL;
|
|
|
|
ends[lines] = NULL;
|
|
|
|
}
|
|
|
|
while(line --> 0 && lines > 0)
|
|
|
|
{
|
|
|
|
lines--;
|
|
|
|
starts[lines] = starts[line];
|
|
|
|
ends[lines] = ends[line];
|
|
|
|
}
|
|
|
|
if (lines == 0)
|
|
|
|
break;
|
|
|
|
}
|
2011-06-16 02:03:57 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
//clamp it properly
|
2011-06-16 02:03:57 +00:00
|
|
|
while (lines < con->notif_l-maxlines)
|
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
lines++;
|
2011-06-16 02:03:57 +00:00
|
|
|
}
|
|
|
|
if (con->flags & CONF_NOTIFY_BOTTOM)
|
|
|
|
y -= (con->notif_l - lines) * Font_CharHeight();
|
|
|
|
|
|
|
|
while (lines < con->notif_l)
|
2009-07-05 18:45:53 +00:00
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
if (con_centernotify.value)
|
|
|
|
{
|
|
|
|
for (c = starts[lines]; c < ends[lines]; c++)
|
2005-05-17 02:36:54 +00:00
|
|
|
{
|
2009-07-14 14:19:45 +00:00
|
|
|
x += Font_CharWidth(*c);
|
2005-05-17 02:36:54 +00:00
|
|
|
}
|
2011-06-16 02:03:57 +00:00
|
|
|
x = (w - x) / 2;
|
2005-05-17 02:36:54 +00:00
|
|
|
}
|
2010-03-14 14:35:56 +00:00
|
|
|
Font_LineDraw(x, y, starts[lines], ends[lines]);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-14 14:19:45 +00:00
|
|
|
y += Font_CharHeight();
|
2009-07-05 18:45:53 +00:00
|
|
|
|
|
|
|
lines++;
|
2005-05-17 02:36:54 +00:00
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
|
2011-06-16 02:03:57 +00:00
|
|
|
Font_EndString(font_conchar);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Con_DrawNotify (void)
|
|
|
|
{
|
|
|
|
console_t *con;
|
|
|
|
|
|
|
|
con_main.flags = CONF_NOTIFY;
|
|
|
|
/*keep the main console up to date*/
|
|
|
|
con_main.notif_l = con_numnotifylines.ival;
|
|
|
|
con_main.notif_w = vid.width;
|
|
|
|
con_main.notif_t = con_notifytime.value;
|
|
|
|
|
|
|
|
if (con_chat)
|
|
|
|
{
|
|
|
|
con_chat->notif_l = con_numnotifylines_chat.ival;
|
|
|
|
con_chat->notif_w = vid.width - 64;
|
|
|
|
con_chat->notif_y = vid.height - sb_lines - 8*4;
|
|
|
|
con_chat->notif_t = con_notifytime_chat.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (con = &con_main; con; con = con->next)
|
|
|
|
{
|
|
|
|
if (con->flags & CONF_NOTIFY)
|
|
|
|
Con_DrawNotifyOne(con);
|
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
|
|
|
|
if (key_dest == key_message)
|
2005-05-17 02:36:54 +00:00
|
|
|
{
|
2011-06-16 02:03:57 +00:00
|
|
|
int x, y;
|
2009-07-05 18:45:53 +00:00
|
|
|
conchar_t *starts[8];
|
|
|
|
conchar_t *ends[8];
|
|
|
|
conchar_t markup[MAXCMDLINE+64];
|
|
|
|
conchar_t *c;
|
|
|
|
int lines, i;
|
2011-06-16 02:03:57 +00:00
|
|
|
Font_BeginString(font_conchar, 0, 0, &x, &y);
|
|
|
|
y = con_main.notif_l * Font_CharHeight();
|
2009-07-05 18:45:53 +00:00
|
|
|
c = COM_ParseFunString(CON_WHITEMASK, va(chat_team?"say_team: %s":"say: %s", chat_buffer), markup, sizeof(markup), true);
|
|
|
|
*c++ = (0xe00a+((int)(realtime*con_cursorspeed)&1))|CON_WHITEMASK;
|
2009-11-04 21:16:50 +00:00
|
|
|
lines = Font_LineBreaks(markup, c, Font_ScreenWidth(), 8, starts, ends);
|
2009-07-05 18:45:53 +00:00
|
|
|
for (i = 0; i < lines; i++)
|
2005-05-17 02:36:54 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
x = 0;
|
2010-03-14 14:35:56 +00:00
|
|
|
Font_LineDraw(x, y, starts[i], ends[i]);
|
2009-07-05 18:45:53 +00:00
|
|
|
y += Font_CharHeight();
|
|
|
|
}
|
2011-06-16 02:03:57 +00:00
|
|
|
Font_EndString(font_conchar);
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-17 02:36:54 +00:00
|
|
|
|
2011-05-15 13:23:13 +00:00
|
|
|
//send all the stuff that was con_printed to sys_print.
|
2009-07-05 18:45:53 +00:00
|
|
|
//This is so that system consoles in windows can scroll up and have all the text.
|
2011-05-15 13:23:13 +00:00
|
|
|
void Con_PrintToSys(void)
|
2009-07-05 18:45:53 +00:00
|
|
|
{
|
|
|
|
console_t *curcon = &con_main;
|
|
|
|
conline_t *l;
|
|
|
|
int i;
|
|
|
|
conchar_t *t;
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
char buf[16];
|
|
|
|
extern cvar_t com_parseutf8;
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
for (l = curcon->oldest; l; l = l->newer)
|
|
|
|
{
|
|
|
|
t = (conchar_t*)(l+1);
|
|
|
|
//fixme: utf8?
|
|
|
|
for (i = 0; i < l->length; i++)
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
{
|
|
|
|
if (!(t[i] & CON_HIDDEN))
|
|
|
|
{
|
|
|
|
if (com_parseutf8.ival>0)
|
|
|
|
{
|
|
|
|
int cl = utf8_encode(buf, t[i]&CON_CHARMASK, sizeof(buf)-1);
|
|
|
|
if (cl)
|
|
|
|
{
|
|
|
|
buf[cl] = 0;
|
|
|
|
Sys_Printf("%s", buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Sys_Printf("%c", t[i]&0xff);
|
|
|
|
}
|
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
Sys_Printf("\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-07 20:00:19 +00:00
|
|
|
//returns the bottom of the progress bar
|
|
|
|
static int Con_DrawProgress(int left, int right, int y)
|
2009-07-05 18:45:53 +00:00
|
|
|
{
|
|
|
|
#ifdef RUNTIMELIGHTING
|
|
|
|
extern model_t *lightmodel;
|
|
|
|
extern int relitsurface;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
conchar_t dlbar[1024];
|
|
|
|
unsigned char progresspercenttext[128];
|
|
|
|
char *progresstext = NULL;
|
|
|
|
char *txt;
|
|
|
|
int x, tw;
|
|
|
|
int i, j;
|
|
|
|
int barwidth, barleft;
|
|
|
|
float progresspercent = 0;
|
|
|
|
*progresspercenttext = 0;
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
// draw the download bar
|
|
|
|
// figure out width
|
|
|
|
if (cls.downloadmethod)
|
|
|
|
{
|
|
|
|
unsigned int count, total;
|
|
|
|
qboolean extra;
|
|
|
|
progresstext = cls.downloadlocalname;
|
|
|
|
progresspercent = cls.downloadpercent;
|
2005-01-05 07:58:11 +00:00
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
CL_GetDownloadSizes(&count, &total, &extra);
|
|
|
|
|
|
|
|
if ((int)(realtime/2)&1 || total == 0)
|
|
|
|
sprintf(progresspercenttext, " %5.1f%% (%ukbps)", progresspercent, CL_DownloadRate()/1000);
|
2009-07-05 18:45:53 +00:00
|
|
|
else
|
2005-01-05 07:58:11 +00:00
|
|
|
{
|
2012-11-27 03:23:19 +00:00
|
|
|
sprintf(progresspercenttext, " %5.1f%% (%u%skb)", progresspercent, total/1024, extra?"+":"");
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef RUNTIMELIGHTING
|
|
|
|
else if (lightmodel)
|
|
|
|
{
|
|
|
|
if (relitsurface < lightmodel->numsurfaces)
|
|
|
|
{
|
|
|
|
progresstext = "light";
|
|
|
|
progresspercent = (relitsurface*100.0f) / lightmodel->numsurfaces;
|
|
|
|
sprintf(progresspercenttext, " %02d%%", (int)progresspercent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//at this point:
|
|
|
|
//progresstext: what is being downloaded/done (can end up truncated)
|
|
|
|
//progresspercent: its percentage (used only for the slider)
|
|
|
|
//progresspercenttext: that percent as text, essentually the right hand part of the bar.
|
|
|
|
|
|
|
|
if (progresstext)
|
|
|
|
{
|
|
|
|
//chop off any leading path
|
|
|
|
if ((txt = strrchr(progresstext, '/')) != NULL)
|
|
|
|
txt++;
|
|
|
|
else
|
|
|
|
txt = progresstext;
|
|
|
|
|
|
|
|
x = 0;
|
2011-05-15 13:23:13 +00:00
|
|
|
COM_ParseFunString(CON_WHITEMASK, txt, dlbar, sizeof(dlbar), false);
|
2009-07-05 18:45:53 +00:00
|
|
|
for (i = 0; dlbar[i]; )
|
|
|
|
{
|
|
|
|
x += Font_CharWidth(dlbar[i]);
|
|
|
|
i++;
|
2005-01-05 07:58:11 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
//if the string is wider than a third of the screen
|
|
|
|
if (x > (right - left)/3)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
//truncate the file name and add ...
|
|
|
|
x += 3*Font_CharWidth('.'|CON_WHITEMASK);
|
|
|
|
while (x > (right - left)/3 && i > 0)
|
2005-01-05 07:58:11 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
i--;
|
|
|
|
x -= Font_CharWidth(dlbar[i]);
|
2005-01-05 07:58:11 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
dlbar[i++] = '.'|CON_WHITEMASK;
|
|
|
|
dlbar[i++] = '.'|CON_WHITEMASK;
|
|
|
|
dlbar[i++] = '.'|CON_WHITEMASK;
|
|
|
|
dlbar[i] = 0;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
//i is the char index of the dlbar so far, x is the char width of it.
|
|
|
|
|
|
|
|
//add a couple chars
|
|
|
|
dlbar[i] = ':'|CON_WHITEMASK;
|
|
|
|
x += Font_CharWidth(dlbar[i]);
|
|
|
|
i++;
|
|
|
|
dlbar[i] = ' '|CON_WHITEMASK;
|
|
|
|
x += Font_CharWidth(dlbar[i]);
|
|
|
|
i++;
|
|
|
|
|
|
|
|
COM_ParseFunString(CON_WHITEMASK, progresspercenttext, dlbar+i, sizeof(dlbar)-i*sizeof(conchar_t), false);
|
|
|
|
for (j = i, tw = 0; dlbar[j]; )
|
|
|
|
{
|
|
|
|
tw += Font_CharWidth(dlbar[j]);
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
barwidth = (right-left) - (x + tw);
|
|
|
|
|
|
|
|
//draw the right hand side
|
|
|
|
x = right - tw;
|
|
|
|
for (j = i; dlbar[j]; j++)
|
|
|
|
x = Font_DrawChar(x, y, dlbar[j]);
|
|
|
|
|
|
|
|
//draw the left hand side
|
|
|
|
x = left;
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
x = Font_DrawChar(x, y, dlbar[j]);
|
|
|
|
|
|
|
|
//and in the middle we have lots of stuff
|
|
|
|
|
|
|
|
barwidth -= (Font_CharWidth(0xe080|CON_WHITEMASK) + Font_CharWidth(0xe082|CON_WHITEMASK));
|
|
|
|
x = Font_DrawChar(x, y, 0xe080|CON_WHITEMASK);
|
|
|
|
barleft = x;
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (x + Font_CharWidth(0xe081|CON_WHITEMASK) > barleft+barwidth)
|
|
|
|
break;
|
|
|
|
x = Font_DrawChar(x, y, 0xe081|CON_WHITEMASK);
|
|
|
|
}
|
|
|
|
x = Font_DrawChar(x, y, 0xe082|CON_WHITEMASK);
|
|
|
|
|
|
|
|
Font_DrawChar(barleft+(barwidth*progresspercent)/100 - Font_CharWidth(0xe083|CON_WHITEMASK)/2, y, 0xe083|CON_WHITEMASK);
|
2009-07-07 20:00:19 +00:00
|
|
|
|
|
|
|
y += Font_CharHeight();
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
2009-07-07 20:00:19 +00:00
|
|
|
return y;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
//draws console selection choices at the top of the screen, if multiple consoles are available
|
|
|
|
//its ctrl+tab to switch between them
|
|
|
|
int Con_DrawAlternateConsoles(int lines)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
char *txt;
|
|
|
|
int x, y = 0;
|
2011-06-16 02:03:57 +00:00
|
|
|
int consshown = 0;
|
|
|
|
console_t *con = &con_main;
|
|
|
|
|
|
|
|
for (con = &con_main; con; con = con->next)
|
|
|
|
{
|
|
|
|
if (!(con->flags & CONF_HIDDEN))
|
|
|
|
consshown++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lines == scr_conlines && consshown > 1)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
for (x = 0, con = &con_main; con; con = con->next)
|
2005-09-21 01:13:11 +00:00
|
|
|
{
|
2011-06-16 02:03:57 +00:00
|
|
|
if (con->flags & CONF_HIDDEN)
|
|
|
|
continue;
|
2009-07-05 18:45:53 +00:00
|
|
|
if (con == &con_main)
|
|
|
|
txt = "MAIN";
|
2005-09-21 01:13:11 +00:00
|
|
|
else
|
2009-07-05 18:45:53 +00:00
|
|
|
txt = con->name;
|
|
|
|
|
|
|
|
if (x != 0 && x+(strlen(txt)+1)*8 > vid.width)
|
2005-09-21 01:13:11 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
x = 0;
|
|
|
|
y += 8;
|
2005-09-21 01:13:11 +00:00
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
Draw_FunString(x, y, va("^&F%i%s", (con==con_current)+con->unseentext*4, txt));
|
|
|
|
x+=(strlen(txt)+1)*8;
|
2005-09-21 01:13:11 +00:00
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
y += 8;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
return y;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
//draws the conline_t list bottom-up within the width of the screen until the top of the screen is reached.
|
|
|
|
//if text is selected, the selstartline globals will be updated, so make sure the lines persist or check them.
|
|
|
|
static int Con_DrawConsoleLines(conline_t *l, int sx, int ex, int y, int top, qboolean selactive, int selsx, int selex, int selsy, int seley)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-11-27 03:23:19 +00:00
|
|
|
int linecount;
|
|
|
|
int linelength;
|
2009-07-05 18:45:53 +00:00
|
|
|
conchar_t *starts[64], *ends[sizeof(starts)/sizeof(starts[0])];
|
2012-11-27 03:23:19 +00:00
|
|
|
conchar_t *s;
|
2009-07-05 18:45:53 +00:00
|
|
|
int i;
|
2012-11-27 03:23:19 +00:00
|
|
|
int x;
|
2009-07-05 18:45:53 +00:00
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
//deactivate the selection if the start and end is outside
|
|
|
|
if (
|
|
|
|
(selsx < sx && selex < sx) ||
|
|
|
|
(selsx > ex && selex > ex) ||
|
|
|
|
(selsy < top && seley < top) ||
|
|
|
|
(selsy > y && seley > y)
|
|
|
|
)
|
|
|
|
selactive = false;
|
2006-02-02 01:13:52 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
if (selactive)
|
|
|
|
{
|
2012-11-27 03:23:19 +00:00
|
|
|
//clip it
|
|
|
|
if (selsx < sx)
|
|
|
|
selsx = sx;
|
|
|
|
if (selex < sx)
|
|
|
|
selex = sx;
|
2009-07-05 18:45:53 +00:00
|
|
|
|
|
|
|
if (selsy > y)
|
|
|
|
selsy = y;
|
|
|
|
if (seley > y)
|
|
|
|
seley = y;
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
//scale the y coord to be in lines instead of pixels
|
2009-07-05 18:45:53 +00:00
|
|
|
selsy -= y;
|
|
|
|
seley -= y;
|
|
|
|
selsy /= Font_CharHeight();
|
|
|
|
seley /= Font_CharHeight();
|
|
|
|
selsy--;
|
|
|
|
seley--;
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
//invert the selections to make sense, text-wise
|
2009-07-05 18:45:53 +00:00
|
|
|
if (selsy == seley)
|
|
|
|
{
|
|
|
|
//single line selected backwards
|
|
|
|
if (selex < selsx)
|
2006-02-02 01:13:52 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
x = selex;
|
|
|
|
selex = selsx;
|
|
|
|
selsx = x;
|
2006-02-02 01:13:52 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
if (seley < selsy)
|
|
|
|
{ //selection goes upwards
|
|
|
|
x = selsy;
|
|
|
|
selsy = seley;
|
|
|
|
seley = x;
|
|
|
|
|
|
|
|
x = selex;
|
|
|
|
selex = selsx;
|
|
|
|
selsx = x;
|
|
|
|
}
|
|
|
|
selsy *= Font_CharHeight();
|
|
|
|
seley *= Font_CharHeight();
|
|
|
|
selsy += y;
|
|
|
|
seley += y;
|
2006-02-02 01:13:52 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
if (l && l == con_current->current && l->length == 0)
|
|
|
|
l = l->older;
|
|
|
|
for (; l; l = l->older)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
s = (conchar_t*)(l+1);
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
linecount = Font_LineBreaks(s, s+l->length, ex-sx, sizeof(starts)/sizeof(starts[0]), starts, ends);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
//if Con_LineBreaks didn't find any lines at all, then it was an empty line, and we need to ensure that its still drawn
|
|
|
|
if (linecount == 0)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
linecount = 1;
|
|
|
|
starts[0] = ends[0] = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-03-14 14:35:56 +00:00
|
|
|
l->lines = linecount;
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
while (linecount-- > 0)
|
2008-11-09 22:29:28 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
s = starts[linecount];
|
|
|
|
linelength = ends[linecount] - s;
|
|
|
|
|
|
|
|
y -= Font_CharHeight();
|
|
|
|
|
|
|
|
if (top && y < top)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (selactive)
|
2008-11-09 22:29:28 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
if (y >= selsy)
|
|
|
|
{
|
|
|
|
if (y <= seley)
|
|
|
|
{
|
|
|
|
int sstart;
|
|
|
|
int send;
|
|
|
|
sstart = sx;
|
2009-11-04 21:16:50 +00:00
|
|
|
send = sstart;
|
|
|
|
for (i = 0; i < linelength; i++)
|
|
|
|
send += Font_CharWidth(s[i]);
|
2009-07-05 18:45:53 +00:00
|
|
|
|
|
|
|
//show something on blank lines
|
|
|
|
if (send == sstart)
|
|
|
|
send = sstart + Font_CharWidth(' ');
|
|
|
|
|
|
|
|
if (y >= seley)
|
|
|
|
{
|
|
|
|
send = sstart;
|
|
|
|
for (i = 0; i < linelength; i++)
|
|
|
|
{
|
|
|
|
send += Font_CharWidth(s[i]);
|
2009-07-18 20:23:56 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
if (send > selex)
|
|
|
|
break;
|
|
|
|
}
|
2009-07-18 20:23:56 +00:00
|
|
|
|
|
|
|
selendline = l;
|
|
|
|
if (s)
|
|
|
|
selendoffset = (s+i+1) - (conchar_t*)(l+1);
|
|
|
|
else
|
|
|
|
selendoffset = 0;
|
2013-03-12 22:44:00 +00:00
|
|
|
if (selendoffset > linelength)
|
|
|
|
selendoffset = linelength;
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
|
|
|
if (y <= selsy)
|
|
|
|
{
|
|
|
|
for (i = 0; i < linelength; i++)
|
|
|
|
{
|
|
|
|
x = Font_CharWidth(s[i]);
|
|
|
|
if (sstart + x > selsx)
|
|
|
|
break;
|
|
|
|
sstart += x;
|
|
|
|
}
|
2009-07-18 20:23:56 +00:00
|
|
|
|
|
|
|
selstartline = l;
|
|
|
|
if (s)
|
|
|
|
selstartoffset = (s+i) - (conchar_t*)(l+1);
|
|
|
|
else
|
|
|
|
selstartoffset = 0;
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ImagePaletteColour(0, 1.0);
|
|
|
|
R2D_FillBlock((sstart*vid.width)/vid.rotpixelwidth, (y*vid.height)/vid.rotpixelheight, ((send - sstart)*vid.width)/vid.rotpixelwidth, (Font_CharHeight()*vid.height)/vid.rotpixelheight);
|
2009-07-05 18:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ImageColours(1.0, 1.0, 1.0, 1.0);
|
2009-07-05 18:45:53 +00:00
|
|
|
|
|
|
|
x = sx;
|
2010-03-14 14:35:56 +00:00
|
|
|
Font_LineDraw(x, y, s, s+linelength);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-07-13 00:32:31 +00:00
|
|
|
if (y < top)
|
2009-07-05 18:45:53 +00:00
|
|
|
break;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2009-07-13 00:32:31 +00:00
|
|
|
if (y < top)
|
|
|
|
break;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2012-11-27 03:23:19 +00:00
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Con_DrawConsole
|
|
|
|
|
|
|
|
Draws the console with the solid background
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Con_DrawConsole (int lines, qboolean noback)
|
|
|
|
{
|
|
|
|
extern qboolean scr_con_forcedraw;
|
|
|
|
int x, y, sx, ex;
|
|
|
|
conline_t *l;
|
|
|
|
int selsx, selsy, selex, seley, selactive;
|
|
|
|
int top;
|
|
|
|
qboolean haveprogress;
|
|
|
|
|
|
|
|
if (lines <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef QTERM
|
|
|
|
if (qterms)
|
|
|
|
QT_Update();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// draw the background
|
|
|
|
if (!noback)
|
|
|
|
R2D_ConsoleBackground (0, lines, scr_con_forcedraw);
|
|
|
|
|
|
|
|
con_current->unseentext = false;
|
|
|
|
|
|
|
|
con_current->vislines = lines;
|
|
|
|
|
|
|
|
top = Con_DrawAlternateConsoles(lines);
|
|
|
|
|
|
|
|
x = 8;
|
|
|
|
y = lines;
|
|
|
|
|
|
|
|
selstartline = NULL;
|
|
|
|
selendline = NULL;
|
|
|
|
selactive = Key_GetConsoleSelectionBox(&selsx, &selsy, &selex, &seley);
|
|
|
|
|
|
|
|
Font_BeginString(font_conchar, x, y, &x, &y);
|
|
|
|
Font_BeginString(font_conchar, selsx, selsy, &selsx, &selsy);
|
|
|
|
Font_BeginString(font_conchar, selex, seley, &selex, &seley);
|
|
|
|
ex = Font_ScreenWidth();
|
|
|
|
sx = x;
|
|
|
|
ex -= sx;
|
|
|
|
|
|
|
|
y -= Font_CharHeight();
|
|
|
|
haveprogress = Con_DrawProgress(x, ex - x, y) != y;
|
|
|
|
y = Con_DrawInput (x, ex - x, y, selactive, selsx, selex, selsy, seley);
|
|
|
|
|
|
|
|
if (!con_current->display)
|
|
|
|
con_current->display = con_current->current;
|
|
|
|
l = con_current->display;
|
|
|
|
|
|
|
|
if (l != con_current->current)
|
|
|
|
{
|
|
|
|
y -= 8;
|
|
|
|
// draw arrows to show the buffer is backscrolled
|
|
|
|
for (x = sx ; x<ex; )
|
|
|
|
x = (Font_DrawChar (x, y, '^'|CON_WHITEMASK)-x)*4+x;
|
|
|
|
}
|
|
|
|
|
|
|
|
y = Con_DrawConsoleLines(l, sx, ex, y, top, selactive, selsx, selex, selsy, seley);
|
2009-07-05 18:45:53 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (!haveprogress && lines == vid.height)
|
|
|
|
{
|
2011-03-30 15:17:55 +00:00
|
|
|
char *version = version_string();
|
2009-11-04 21:16:50 +00:00
|
|
|
int i;
|
|
|
|
Font_BeginString(font_conchar, vid.width, lines, &x, &y);
|
|
|
|
y -= Font_CharHeight();
|
|
|
|
for (i = 0; version[i]; i++)
|
|
|
|
x -= Font_CharWidth(version[i] | CON_WHITEMASK|CON_HALFALPHA);
|
|
|
|
for (i = 0; version[i]; i++)
|
|
|
|
x = Font_DrawChar(x, y, version[i] | CON_WHITEMASK|CON_HALFALPHA);
|
|
|
|
}
|
|
|
|
|
|
|
|
Font_EndString(font_conchar);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-18 20:23:56 +00:00
|
|
|
|
2012-10-13 00:56:31 +00:00
|
|
|
char *Con_CopyConsole(qboolean nomarkup)
|
2009-07-18 20:23:56 +00:00
|
|
|
{
|
|
|
|
conchar_t *cur;
|
|
|
|
conline_t *l;
|
|
|
|
conchar_t *lend;
|
|
|
|
char *result;
|
|
|
|
int outlen, maxlen;
|
|
|
|
int finalendoffset;
|
|
|
|
|
|
|
|
if (!selstartline || !selendline)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
maxlen = 1024*1024;
|
|
|
|
result = Z_Malloc(maxlen+1);
|
|
|
|
|
2012-10-13 00:56:31 +00:00
|
|
|
// for (cur = (conchar_t*)(selstartline+1), finalendoffset = 0; cur < (conchar_t*)(selstartline+1) + selstartline->length; cur++, finalendoffset++)
|
|
|
|
// result[finalendoffset] = *cur & 0xffff;
|
|
|
|
|
2009-07-18 20:23:56 +00:00
|
|
|
l = selstartline;
|
|
|
|
cur = (conchar_t*)(l+1) + selstartoffset;
|
|
|
|
finalendoffset = selendoffset;
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2009-07-18 20:23:56 +00:00
|
|
|
if (selstartline == selendline)
|
|
|
|
{
|
|
|
|
if (selstartoffset+1 == finalendoffset)
|
|
|
|
{
|
|
|
|
//they only selected a single char?
|
|
|
|
//fix that up to select the entire token
|
|
|
|
while (cur > (conchar_t*)(l+1))
|
|
|
|
{
|
|
|
|
cur--;
|
2012-10-13 00:56:31 +00:00
|
|
|
if ((*cur & CON_CHARMASK) == ' ')
|
2009-07-18 20:23:56 +00:00
|
|
|
{
|
|
|
|
cur++;
|
|
|
|
break;
|
|
|
|
}
|
2012-10-13 00:56:31 +00:00
|
|
|
if (*cur == CON_LINKSTART)
|
|
|
|
break;
|
2009-07-18 20:23:56 +00:00
|
|
|
}
|
|
|
|
while (finalendoffset < selendline->length)
|
|
|
|
{
|
2012-10-13 00:56:31 +00:00
|
|
|
if ((((conchar_t*)(l+1))[finalendoffset] & CON_CHARMASK) != ' ')
|
2009-07-18 20:23:56 +00:00
|
|
|
finalendoffset++;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-13 00:56:31 +00:00
|
|
|
|
|
|
|
//scan backwards to find any link enclosure
|
|
|
|
for(lend = cur; lend >= (conchar_t*)(l+1); lend--)
|
|
|
|
{
|
|
|
|
if (*lend == CON_LINKSTART)
|
|
|
|
{
|
|
|
|
//found one
|
|
|
|
cur = lend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*lend == CON_LINKEND)
|
|
|
|
{
|
|
|
|
//some other link ended here. don't use its start.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//scan forwards to find the end of the selected link
|
|
|
|
for(lend = (conchar_t*)(selendline+1) + finalendoffset; lend < (conchar_t*)(selendline+1) + selendline->length; lend++)
|
|
|
|
{
|
|
|
|
if (*lend == CON_LINKEND)
|
|
|
|
{
|
|
|
|
finalendoffset = lend+1 - (conchar_t*)(selendline+1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-07-18 20:23:56 +00:00
|
|
|
|
|
|
|
outlen = 0;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (l == selendline)
|
|
|
|
lend = (conchar_t*)(l+1) + finalendoffset;
|
|
|
|
else
|
|
|
|
lend = (conchar_t*)(l+1) + l->length;
|
2012-10-13 00:56:31 +00:00
|
|
|
|
|
|
|
outlen = COM_DeFunString(cur, lend, result + outlen, maxlen - outlen, nomarkup) - result;
|
2009-07-18 20:23:56 +00:00
|
|
|
|
|
|
|
if (l == selendline)
|
|
|
|
break;
|
|
|
|
|
|
|
|
l = l->newer;
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
Con_Printf("Error: Bad console buffer\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-10-13 00:56:31 +00:00
|
|
|
|
|
|
|
if (outlen+3 > maxlen)
|
|
|
|
break;
|
2009-07-18 20:23:56 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
result[outlen++] = '\r';
|
|
|
|
#endif
|
|
|
|
result[outlen++] = '\n';
|
|
|
|
cur = (conchar_t*)(l+1);
|
|
|
|
}
|
|
|
|
result[outlen++] = 0;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Con_NotifyBox
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Con_NotifyBox (char *text)
|
|
|
|
{
|
|
|
|
double t1, t2;
|
|
|
|
|
|
|
|
// during startup for sound / cd warnings
|
|
|
|
Con_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n");
|
|
|
|
|
2011-05-15 13:23:13 +00:00
|
|
|
Con_Printf ("%s", text);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
Con_Printf ("Press a key.\n");
|
|
|
|
Con_Printf("\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n");
|
|
|
|
|
|
|
|
key_count = -2; // wait for a key down and up
|
|
|
|
key_dest = key_console;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
t1 = Sys_DoubleTime ();
|
|
|
|
SCR_UpdateScreen ();
|
|
|
|
Sys_SendKeyEvents ();
|
|
|
|
t2 = Sys_DoubleTime ();
|
|
|
|
realtime += t2-t1; // make the cursor blink
|
|
|
|
} while (key_count < 0);
|
|
|
|
|
|
|
|
Con_Printf ("\n");
|
|
|
|
key_dest = key_game;
|
|
|
|
}
|