added help panel and colorized help text

added con_drawHelp and con_col*
letting the mod know we support the "cap_ExtraColorCodes" extension
con_colText overrides ^7 in the console and the help panel
extended console back scroll arrows all the way
This commit is contained in:
myT 2017-12-27 05:13:33 +01:00
parent f60ce0d1e8
commit 3c52752dd3
27 changed files with 729 additions and 232 deletions

View file

@ -1,6 +1,24 @@
DD Mmm 17 - 1.49
add: console color customization cvars
con_colBG <RGBA> (default: "101013F6") - console and help panel background
con_colBorder <RGBA> (default: "4778B2FF") - the console and help panel borders
con_colArrow <RGBA> (default: "4778B2FF") - console backscroll arrows
con_colShadow <RGBA> (default: "000000FF") - text shadows
con_colHL <RGBA> (default: "303033FF") - auto-completion highlight (see con_completionStyle 1)
con_colText <RGB> (default: "E2E2E2") - normal text
con_colCVar <RGB> (default: "4778B2") - cvar names
con_colCmd <RGB> (default: "4FA7BD") - command names
con_colValue <RGB> (default: "E5BC39") - cvar values
con_colHelp <RGB> (default: "ABC1C6") - help text
add: con_drawHelp <bitmask> (default: 1) controls the help panel displayed below the console
1 = enables the help panel
2 = draws the help panel even if the current cvar/cmd has no help text
4 = draws the list of modules the current cvar/cmd belongs to
8 = draws the list of attributes of the current cvar
fix: console/messagemode input buffers would ignore the last off-screen color modifier when scrolled
fix: console/messagemode input buffers would sometimes display the cursor at the wrong position

View file

@ -311,7 +311,9 @@ static qbool CL_CG_GetValue( char* value, int valueSize, const char* key )
{ "trap_Error2", CG_EXT_ERROR2 },
// commands
{ "screenshotnc", 1 },
{ "screenshotncJPEG", 1 }
{ "screenshotncJPEG", 1 },
// capabilities
{ "cap_ExtraColorCodes", 1 }
};
for ( int i = 0; i < ARRAY_LEN( syscalls ); ++i ) {

View file

@ -30,12 +30,37 @@ static cvar_t* con_notifytime;
static cvar_t* con_scale;
static cvar_t* con_scaleMode; // 0 = without res, 1 = with res, 2 = 8x12
static cvar_t* con_speed;
static cvar_t* con_drawHelp;
#define COLOR_LIST(X) \
X(BG, "101013F6", qtrue, "RGBA color of the background") \
X(Border, "4778B2FF", qtrue, "RGBA color of the border") \
X(Arrow, "4778B2FF", qtrue, "RGBA color of backscroll arrows") \
X(Shadow, "000000FF", qtrue, "RGBA color of text shadows") \
X(Text, "E2E2E2", qfalse, "RGB color of text") \
X(CVar, "4778B2", qfalse, "RGB color of variable names") \
X(Cmd, "4FA7BD", qfalse, "RGB color of command names") \
X(Value, "E5BC39", qfalse, "RGB color of variable values") \
X(Help, "ABC1C6", qfalse, "RGB color of help text") \
X(HL, "303033FF", qtrue, help_con_colHL)
#define COLOR_LIST_ITEM( Name, Default, HasAlpha, Help ) \
static cvar_t* con_col##Name; \
static vec4_t col##Name;
COLOR_LIST( COLOR_LIST_ITEM )
#undef COLOR_LIST_ITEM
#define CON_NOTIFYLINES 4
#define CON_TEXTSIZE (256*1024)
// con_drawHelp flags
#define DRAWHELP_ENABLE_BIT 1
#define DRAWHELP_NOTFOUND_BIT 2
#define DRAWHELP_MODULES_BIT 4
#define DRAWHELP_ATTRIBS_BIT 8
#define DRAWHELP_MAX 15
struct console_t {
qbool initialized;
@ -60,6 +85,14 @@ struct console_t {
// for transparent notify lines
qbool wasActive; // was active before Con_PushConsoleInvisible was called?
char helpText[MAXPRINTMSG];
int helpX; // char index
float helpY; // top coordinate
int helpWidth; // char count of the longest line
int helpLines; // line count
qbool helpDraw;
float helpXAdjust;
};
static console_t con;
@ -71,6 +104,74 @@ static console_t con;
int g_console_field_width = CONSOLE_WIDTH;
static qbool IsValidHexChar( char c )
{
return
( c >= '0' && c <= '9' ) ||
( c >= 'a' && c <= 'f' ) ||
( c >= 'A' && c <= 'F' );
}
static qbool IsValidHexColor( const char* s, qbool hasAlpha )
{
const int chars = hasAlpha ? 8 : 6;
for ( int i = 0; i < chars; ++i ) {
if ( *s == '\0' || !IsValidHexChar(*s) )
return qfalse;
s++;
}
return *s == '\0';
}
static void GetFloatColor( float* c, cvar_t* cvar, qbool hasAlpha )
{
c[0] = 1.0f;
c[1] = 1.0f;
c[2] = 1.0f;
c[3] = 1.0f;
const char* s = cvar->string;
if ( !IsValidHexColor(s, hasAlpha) ) {
s = cvar->resetString;
if ( !IsValidHexColor(s, hasAlpha) )
return;
}
unsigned int uc[4];
if ( hasAlpha ) {
if ( sscanf(s, "%02X%02X%02X%02X", &uc[0], &uc[1], &uc[2], &uc[3]) != 4 )
return;
c[0] = uc[0] / 255.0f;
c[1] = uc[1] / 255.0f;
c[2] = uc[2] / 255.0f;
c[3] = uc[3] / 255.0f;
} else {
if ( sscanf(s, "%02X%02X%02X", &uc[0], &uc[1], &uc[2]) != 3 )
return;
c[0] = uc[0] / 255.0f;
c[1] = uc[1] / 255.0f;
c[2] = uc[2] / 255.0f;
c[3] = 1.0f;
}
}
const float* ConsoleColorFromChar( char ccode )
{
if ( ccode == COLOR_WHITE )
return colText;
if ( ccode == COLOR_CVAR )
return colCVar;
if ( ccode == COLOR_CMD )
return colCmd;
if ( ccode == COLOR_VAL )
return colValue;
if ( ccode == COLOR_HELP )
return colHelp;
return ColorFromChar( ccode );
}
float Con_SetConsoleVisibility( float fraction )
{
const float oldValue = con.displayFrac;
@ -287,6 +388,9 @@ static void Con_ResizeFont()
static const cvarTableItem_t con_cvars[] =
{
#define COLOR_LIST_ITEM( Name, Default, HasAlpha, Help ) { &con_col##Name, "con_col" #Name, Default, CVAR_ARCHIVE, CVART_STRING, NULL, NULL, Help },
COLOR_LIST( COLOR_LIST_ITEM )
#undef COLOR_LIST_ITEM
// con_scale:
// bugs in the renderer's overflow handling will cause crashes
// if the console has too many polys/verts because of too small a font
@ -294,7 +398,8 @@ static const cvarTableItem_t con_cvars[] =
{ &con_notifytime, "con_notifytime", "3", CVAR_ARCHIVE, CVART_FLOAT, "-1", "30", help_con_notifytime },
{ &con_scale, "con_scale", "1.2", CVAR_ARCHIVE, CVART_FLOAT, "0.25", "10", "console text scaling factor" },
{ &con_scaleMode, "con_scaleMode", "0", CVAR_ARCHIVE, CVART_INTEGER, "0", "2", help_con_scaleMode },
{ &con_speed, "con_speed", "1000", CVAR_ARCHIVE, CVART_FLOAT, "0.1", "1000", "console opening/closing speed" }
{ &con_speed, "con_speed", "1000", CVAR_ARCHIVE, CVART_FLOAT, "0.1", "1000", "console opening/closing speed" },
{ &con_drawHelp, "con_drawHelp", "1", CVAR_ARCHIVE, CVART_BITMASK, "0", XSTRING(DRAWHELP_MAX), help_con_drawHelp }
};
@ -437,19 +542,18 @@ static void Con_DrawInput()
const int length = g_consoleField.acLength;
if ( length > 0 ) {
// note that Field_Draw takes integers as arguments so we need to truncate our coordinates and font sizes to match
const vec4_t highlightColor = { 0.5f, 0.5f, 0.2f, 0.45f };
const int offset = g_consoleField.acOffset;
re.SetColor( highlightColor );
re.SetColor( colHL );
re.DrawStretchPic( con.xadjust + (offset + 1) * (int)con.cw, y, length * (int)con.cw, (int)con.ch, 0, 0, 0, 0, cls.whiteShader );
}
}
re.SetColor( colorBlack );
re.SetColor( colShadow );
SCR_DrawChar( con.xadjust + 1, y + 1, con.cw, con.ch, ']' );
re.SetColor( colorWhite );
re.SetColor( colText );
SCR_DrawChar( con.xadjust, y, con.cw, con.ch, ']' );
Field_Draw( &g_consoleField, con.xadjust + con.cw, y, con.cw, con.ch );
Field_Draw( &g_consoleField, con.xadjust + con.cw, y, con.cw, con.ch, qtrue );
}
@ -507,16 +611,16 @@ static void Con_DrawNotify()
if (chat_team)
{
SCR_DrawStringEx( 8, y, cw, ch, "say_team:", qtrue, qtrue, NULL );
SCR_DrawString( 8, y, cw, ch, "say_team:", qfalse );
skip = 10;
}
else
{
SCR_DrawStringEx( 8, y, cw, ch, "say:", qtrue, qtrue, NULL );
SCR_DrawString( 8, y, cw, ch, "say:", qfalse );
skip = 5;
}
Field_Draw( &chatField, skip * cw, y, cw, ch );
Field_Draw( &chatField, skip * cw, y, cw, ch, qfalse );
y += ch;
}
@ -534,12 +638,110 @@ static void Con_FillRect( float x, float y, float w, float h, const vec4_t color
}
static void QDECL Con_HelpPrintf( const char* fmt, ... )
{
va_list argptr;
va_start( argptr, fmt );
Q_vsnprintf( con.helpText, sizeof(con.helpText), fmt, argptr );
va_end( argptr );
const float* color = colText;
const char* c = con.helpText;
while ( *c != '\0' ) {
// measure the length of the current word
int wl = 0;
while ( c[wl] != '\0' && c[wl] > ' ' )
wl++;
const qbool wordBreak = (wl > 0) && (con.helpX + wl >= CONSOLE_WIDTH) && (wl < CONSOLE_WIDTH);
const qbool forcedBreak = con.helpX >= CONSOLE_WIDTH;
if ( *c == '\n' || forcedBreak || wordBreak ) {
if ( !forcedBreak && !wordBreak )
c++;
con.helpWidth = max( con.helpWidth, con.helpX );
con.helpX = 0;
con.helpY += con.ch;
con.helpLines++;
continue;
}
if ( Q_IsColorString(c) ) {
color = ConsoleColorFromChar( c[1] );
c += 2;
continue;
}
if ( con.helpDraw ) {
re.SetColor( colShadow );
SCR_DrawChar( con.helpXAdjust + con.helpX * con.cw + 1, con.helpY + 1, con.cw, con.ch, *c );
re.SetColor( color );
SCR_DrawChar( con.helpXAdjust + con.helpX * con.cw, con.helpY, con.cw, con.ch, *c );
}
c++;
con.helpX++;
}
}
static void Con_DrawHelp()
{
if( !(con_drawHelp->integer & DRAWHELP_ENABLE_BIT) )
return;
if ( *g_consoleField.buffer == '\0' )
return;
if ( con.displayFrac == 0.0f || con.displayFrac < con.finalFrac )
return;
Cmd_TokenizeString( g_consoleField.buffer );
if ( Cmd_Argc() < 1 )
return;
const char* name = Cmd_Argv(0);
if ( *name == '/' || *name == '\\' )
name++;
if ( *name == '\0' )
return;
const qbool printAlways = (con_drawHelp->integer & DRAWHELP_NOTFOUND_BIT) != 0;
const qbool printModules = (con_drawHelp->integer & DRAWHELP_MODULES_BIT) != 0;
const qbool printAttribs = (con_drawHelp->integer & DRAWHELP_ATTRIBS_BIT) != 0;
con.helpDraw = qfalse;
con.helpX = 0;
con.helpWidth = 0;
con.helpLines = 0;
con.helpXAdjust = con.xadjust + 2 * con.cw;
const printHelpResult_t result = Com_PrintHelp( name, &Con_HelpPrintf, qfalse, printModules, printAttribs );
if ( result == PHR_NOTFOUND || ( result == PHR_NOHELP && !printAlways ) )
return;
const float d = (int)con.ch;
const float x = (int)(con.helpXAdjust - con.cw);
const float y = (int)(cls.glconfig.vidHeight * con.displayFrac);
const float w = (int)((con.helpWidth + 2) * con.cw);
const float h = (int)((con.helpLines + 1) * con.ch);
con.helpDraw = qtrue;
con.helpX = 0;
con.helpY = y + 1.5f * con.ch;
const float yh = (int)(con.helpY - con.ch / 2.0f);
re.SetColor( colBG );
re.DrawTriangle( x, y, x + d, y + d, x, y + d, 0, 0, 0, 0, 0, 0, cls.whiteShader );
Con_FillRect( x, yh, w, h, colBG );
Con_FillRect( x + 1, yh + h + 0, w - 1, 1, colBorder );
Con_FillRect( x + 2, yh + h + 1, w - 2, 1, colBorder );
Con_FillRect( x + w + 0, yh + 1, 1, h + 1, colBorder );
Con_FillRect( x + w + 1, yh + 2, 1, h + 0, colBorder );
Com_PrintHelp( name, &Con_HelpPrintf, qfalse, printModules, printAttribs );
}
static void Con_DrawSolidConsole( float frac )
{
int i, x, y;
int rows;
int row;
vec4_t fill;
int scanlines = Com_Clamp( 0, cls.glconfig.vidHeight, cls.glconfig.vidHeight * frac );
if (scanlines <= 0)
@ -547,12 +749,10 @@ static void Con_DrawSolidConsole( float frac )
// draw the background
y = scanlines - 2;
MAKERGBA( fill, 0.33f, 0.33f, 0.33f, 1.0 );
Con_FillRect( 0, 0, cls.glconfig.vidWidth, y, fill );
MAKERGBA( fill, 0.25f, 0.25f, 0.25f, 1.0 );
Con_FillRect( 0, y, cls.glconfig.vidWidth, 2, fill );
Con_FillRect( 0, 0, cls.glconfig.vidWidth, y, colBG );
Con_FillRect( 0, y, cls.glconfig.vidWidth, 2, colBorder );
re.SetColor( colText );
i = sizeof( Q3_VERSION )/sizeof(char) - 1;
x = cls.glconfig.vidWidth - SMALLCHAR_WIDTH;
while (--i >= 0) {
@ -568,10 +768,10 @@ static void Con_DrawSolidConsole( float frac )
// draw the console text from the bottom up
if (con.display != con.current) {
// draw arrows to show the buffer is backscrolled
// draw arrows to show the buffer is backscrolled
const int xEnd = ( cls.glconfig.vidWidth - con.xadjust ) / con.cw;
re.SetColor( colorBlack );
for (x = 0; x < xEnd; x += 4)
re.SetColor( colArrow );
for (x = 0; x < xEnd; x += 4)
SCR_DrawChar( con.xadjust + x * con.cw, y, con.cw, con.ch, '^' );
y -= con.ch;
--rows;
@ -583,7 +783,7 @@ static void Con_DrawSolidConsole( float frac )
}
char color = COLOR_WHITE;
re.SetColor( ColorFromChar( color ) );
re.SetColor( ConsoleColorFromChar( color ) );
con.rowsVisible = 0;
for (i = 0; i < rows; ++i, --row, y -= con.ch )
@ -599,17 +799,17 @@ static void Con_DrawSolidConsole( float frac )
con.rowsVisible++;
const short* text = con.text + (row % con.totallines)*con.linewidth;
re.SetColor( colorBlack );
for (int j = 0; j < con.linewidth; ++j) {
SCR_DrawChar( 1 + con.xadjust + j * con.cw, 1 + y, con.cw, con.ch, (text[j] & 0xFF) );
re.SetColor( colShadow );
for (int i = 0; i < con.linewidth; ++i) {
SCR_DrawChar( 1 + con.xadjust + i * con.cw, 1 + y, con.cw, con.ch, (text[i] & 0xFF) );
}
re.SetColor( colorWhite );
re.SetColor( colText );
for (int j = 0; j < con.linewidth; ++j) {
if ((text[j] >> 8) != color) {
color = (text[j] >> 8);
re.SetColor( ColorFromChar( color ) );
re.SetColor( ConsoleColorFromChar( color ) );
}
SCR_DrawChar( con.xadjust + j * con.cw, y, con.cw, con.ch, (text[j] & 0xFF) );
}
@ -617,6 +817,7 @@ static void Con_DrawSolidConsole( float frac )
Con_DrawInput();
CL_MapDownload_DrawConsole( con.cw, con.ch );
Con_DrawHelp();
re.SetColor( NULL );
}
@ -675,6 +876,10 @@ void Con_RunConsole()
if (con.finalFrac < con.displayFrac)
con.displayFrac = con.finalFrac;
}
#define COLOR_LIST_ITEM( Name, Default, HasAlpha, Help ) GetFloatColor( col##Name, con_col##Name, HasAlpha );
COLOR_LIST( COLOR_LIST_ITEM )
#undef COLOR_LIST_ITEM
}

View file

@ -843,20 +843,20 @@ static const cvarTableItem_t cl_cvars[] =
{ NULL, "cl_drawMouseLag", "0", 0, CVART_BOOL, NULL, NULL, "draws sampling to display/upload delays" },
{ &m_speed, "m_speed", "2", CVAR_ARCHIVE, CVART_FLOAT, "0", "100", "mouse sensitivity" },
{ &m_accel, "m_accel", "0", CVAR_ARCHIVE, CVART_FLOAT, "0", NULL, "mouse acceleration" },
{ &m_accelStyle, "m_accelStyle", "0", CVAR_ARCHIVE, CVART_INTEGER, "0", "1", "0=original, 1=new" },
{ &m_accelOffset, "m_accelOffset", "5", CVAR_ARCHIVE, CVART_FLOAT, "0.001", "5000", "offset for the power function\nfor m_accelStyle 1 only" },
{ &m_limit, "m_limit", "0", CVAR_ARCHIVE, CVART_FLOAT, "0", NULL, "mouse speed cap (0=disabled)\nfor m_accelStyle 0 only" },
{ &m_accelStyle, "m_accelStyle", "0", CVAR_ARCHIVE, CVART_INTEGER, "0", "1", help_m_accelStyle },
{ &m_accelOffset, "m_accelOffset", "5", CVAR_ARCHIVE, CVART_FLOAT, "0.001", "5000", help_m_accelOffset },
{ &m_limit, "m_limit", "0", CVAR_ARCHIVE, CVART_FLOAT, "0", NULL, help_m_limit },
{ &m_pitch, "m_pitch", "0.022", CVAR_ARCHIVE, CVART_FLOAT, "-100", "100", "post-accel vertical mouse sens." },
{ &m_yaw, "m_yaw", "0.022", CVAR_ARCHIVE, CVART_FLOAT, "-100", "100", "post-accel horizontal mouse sens." },
{ &m_forward, "m_forward", "0.25", CVAR_ARCHIVE, CVART_FLOAT, "-32767", "32767", "forward/backwards mouse sensitivity (+strafe)" },
{ &m_side, "m_side", "0.25", CVAR_ARCHIVE, CVART_FLOAT, "-32767", "32767", "left/right mouse sensitivity (+strafe)" },
{ &m_forward, "m_forward", "0.25", CVAR_ARCHIVE, CVART_FLOAT, "-32767", "32767", help_m_forward },
{ &m_side, "m_side", "0.25", CVAR_ARCHIVE, CVART_FLOAT, "-32767", "32767", help_m_side },
{ &m_filter, "m_filter", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "mouse smoothing" },
{ &cl_pitchspeed, "cl_pitchspeed", "140", CVAR_ARCHIVE, CVART_FLOAT, "0", NULL, "+lookup +lookdown speed" },
{ &cl_yawspeed, "cl_yawspeed", "140", CVAR_ARCHIVE, CVART_FLOAT, "0", NULL, "+right +left speed" },
{ &cl_pitchspeed, "cl_pitchspeed", "140", CVAR_ARCHIVE, CVART_FLOAT, "0", NULL, help_cl_pitchspeed },
{ &cl_yawspeed, "cl_yawspeed", "140", CVAR_ARCHIVE, CVART_FLOAT, "0", NULL, help_cl_yawspeed },
{ &cl_anglespeedkey, "cl_anglespeedkey", "1.5", 0, CVART_FLOAT },
{ &cl_run, "cl_run", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "running enabled (0=walk)" },
{ &cl_freelook, "cl_freelook", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "0 means you can't look up/down" },
{ &cl_showMouseRate, "cl_showmouserate", "0", 0, CVART_BOOL, NULL, NULL, "prints info when m_accel != 0" },
{ &cl_run, "cl_run", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_cl_run },
{ &cl_freelook, "cl_freelook", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_cl_freelook },
{ &cl_showMouseRate, "cl_showmouserate", "0", 0, CVART_BOOL, NULL, NULL, help_cl_showMouseRate },
{ &cl_nodelta, "cl_nodelta", "0", 0, CVART_BOOL, NULL, NULL, "disables delta-compression on uploaded user commands" },
{ &cl_debugMove, "cl_debugMove", "0", 0, CVART_INTEGER, "0", "2", help_cl_debugMove }
};

View file

@ -213,7 +213,7 @@ EDIT FIELDS
// handles horizontal scrolling and cursor blinking
// position and char sizes are in pixels
void Field_Draw( field_t* edit, int x, int y, int cw, int ch )
void Field_Draw( field_t* edit, int x, int y, int cw, int ch, qbool extColors )
{
int len;
int drawLen;
@ -222,6 +222,7 @@ void Field_Draw( field_t* edit, int x, int y, int cw, int ch )
char str[MAX_STRING_CHARS];
int i;
int colorCode;
const float* firstColor;
drawLen = edit->widthInChars + 1;
len = strlen( edit->buffer );
@ -259,7 +260,8 @@ void Field_Draw( field_t* edit, int x, int y, int cw, int ch )
Com_Memcpy( str, edit->buffer + prestep, drawLen );
str[ drawLen ] = 0;
SCR_DrawStringEx( x, y, cw, ch, str, qtrue, qtrue, ColorFromChar( colorCode ) );
firstColor = extColors ? ConsoleColorFromChar( colorCode ) : ColorFromChar( colorCode );
SCR_DrawStringEx( x, y, cw, ch, str, extColors ? DSC_CONSOLE : DSC_NORMAL, qtrue, firstColor );
if ( (int)( cls.realtime >> 8 ) & 1 ) {
return; // off blink
@ -272,7 +274,10 @@ void Field_Draw( field_t* edit, int x, int y, int cw, int ch )
}
i = drawLen - strlen( str );
firstColor = extColors ? ConsoleColorFromChar( COLOR_WHITE ) : ColorFromChar( COLOR_WHITE );
re.SetColor( firstColor );
SCR_DrawChar( x + ( edit->cursor - prestep - i ) * cw, y, cw, ch, cursorChar );
re.SetColor( NULL );
}

View file

@ -2002,11 +2002,11 @@ static const cvarTableItem_t cl_cvars[] =
{ &cl_shownet, "cl_shownet", "0", CVAR_TEMP, CVART_INTEGER, "-2", "4", help_cl_shownet },
{ &cl_showSend, "cl_showSend", "0", CVAR_TEMP, CVART_BOOL, NULL, NULL, help_cl_showSend },
{ &cl_showTimeDelta, "cl_showTimeDelta", "0", CVAR_TEMP, CVART_BOOL, NULL, NULL, "prints delta adjustment values and events" },
{ &rconPassword, "rconPassword", "", CVAR_TEMP, CVART_STRING, NULL, NULL, "server password, used by /rcon" },
{ &rconPassword, "rconPassword", "", CVAR_TEMP, CVART_STRING, NULL, NULL, help_rconPassword },
{ &cl_timedemo, "timedemo", "0", 0, CVART_BOOL, NULL, NULL, "demo benchmarking mode" },
{ &cl_aviFrameRate, "cl_aviFrameRate", "25", CVAR_ARCHIVE, CVART_INTEGER, "1", "250", "frame-rate for /video" },
{ &cl_aviMotionJpeg, "cl_aviMotionJpeg", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "/video stores frames as JPEGs" },
{ &rconAddress, "rconAddress", "", 0, CVART_STRING, NULL, NULL, "IP address of the server to /rcon to" },
{ &cl_aviFrameRate, "cl_aviFrameRate", "25", CVAR_ARCHIVE, CVART_INTEGER, "1", "250", help_cl_aviFrameRate },
{ &cl_aviMotionJpeg, "cl_aviMotionJpeg", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_cl_aviMotionJpeg },
{ &rconAddress, "rconAddress", "", 0, CVART_STRING, NULL, NULL, help_rconAddress },
{ &cl_maxpackets, "cl_maxpackets", "125", CVAR_ARCHIVE, CVART_INTEGER, "15", "125", "max. packet upload rate" },
{ &cl_packetdup, "cl_packetdup", "1", CVAR_ARCHIVE, CVART_INTEGER, "0", "5", "number of extra transmissions per packet" },
{ &cl_allowDownload, "cl_allowDownload", "1", CVAR_ARCHIVE, CVART_INTEGER, "-1", "1", help_cl_allowDownload },
@ -2016,7 +2016,7 @@ static const cvarTableItem_t cl_cvars[] =
{ NULL, "name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE, CVART_STRING, NULL, NULL, "your name" },
{ NULL, "rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE, CVART_INTEGER, "4000", "99999", "network transfer rate" },
{ NULL, "snaps", "30", CVAR_USERINFO | CVAR_ARCHIVE, CVART_INTEGER }, // documented by the mod
{ NULL, "password", "", CVAR_USERINFO, CVART_STRING, NULL, NULL, "used by /connect" },
{ NULL, "password", "", CVAR_USERINFO, CVART_STRING, NULL, NULL, "used by /" S_COLOR_CMD "connect" },
{ &cl_matchAlerts, "cl_matchAlerts", "7", CVAR_ARCHIVE, CVART_BITMASK, "0", XSTRING(MAF_MAX), help_cl_matchAlerts }
};

View file

@ -86,8 +86,8 @@ void SCR_DrawChar( float x, float y, float cw, float ch, int c )
// draws a string with a drop shadow, optionally with colorcodes
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string, qbool allowColor, qbool showColorCodes, const float* firstColor )
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string, drawStringColors_t colors, qbool showColorCodes, const float* firstColor )
{
float xx;
const char* s;
@ -114,14 +114,19 @@ void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string,
// draw the text, possibly with colors
s = string;
xx = x;
re.SetColor( firstColor ? firstColor : colorWhite );
if ( firstColor == NULL )
firstColor = colors == DSC_CONSOLE ? ConsoleColorFromChar( COLOR_WHITE ) : colorWhite;
re.SetColor( firstColor );
while ( *s ) {
if ( allowColor && Q_IsColorString( s ) ) {
re.SetColor( ColorFromChar( s[1] ) );
if ( Q_IsColorString( s ) ) {
if ( colors == DSC_NORMAL )
re.SetColor( ColorFromChar( s[1] ) );
else if ( colors == DSC_CONSOLE )
re.SetColor( ConsoleColorFromChar( s[1] ) );
if ( !showColorCodes ) {
s += 2;
continue;
}
}
}
SCR_DrawChar( xx, y, cw, ch, *s );
xx += cw;
@ -131,12 +136,12 @@ void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string,
re.SetColor( NULL );
}
// draws a string with a drop shadow, optionally with colorcodes
void SCR_DrawString( float x, float y, float cw, float ch, const char* string, qbool allowColor )
void SCR_DrawString(float x, float y, float cw, float ch, const char* s, qbool allowColor)
{
SCR_DrawStringEx( x, y, cw, ch, string, allowColor, qfalse, NULL );
SCR_DrawStringEx( x, y, cw, ch, s, allowColor ? DSC_NORMAL : DSC_NONE, qfalse, NULL );
}

View file

@ -765,7 +765,9 @@ static qbool CL_UI_GetValue( char* value, int valueSize, const char* key )
{ "trap_EnableErrorCallback", UI_EXT_ENABLEERRORCALLBACK },
// commands
{ "screenshotnc", 1 },
{ "screenshotncJPEG", 1 }
{ "screenshotncJPEG", 1 },
// capabilities
{ "cap_ExtraColorCodes", 1 }
};
for ( int i = 0; i < ARRAY_LEN( syscalls ); ++i ) {

View file

@ -433,11 +433,18 @@ void Con_ScrollPages( int pages ); // positive means down
void Con_Top();
void Con_Bottom();
void Con_Close();
const float* ConsoleColorFromChar( char ccode );
//
// cl_scrn.c
//
typedef enum {
DSC_NONE,
DSC_NORMAL,
DSC_CONSOLE // extended mode
} drawStringColors_t;
void SCR_Init();
void SCR_UpdateScreen();
@ -446,7 +453,7 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h );
void SCR_DrawChar( float x, float y, float cw, float ch, int c );
void SCR_DrawString( float x, float y, float cw, float ch, const char* s, qbool allowColor );
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* s, qbool allowColor, qbool showColorCodes, const float* firstColor );
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* s, drawStringColors_t colors, qbool showColorCodes, const float* firstColor );
void SCR_DebugGraph( float value, int color );

View file

@ -1,17 +1,17 @@
#define help_cl_timeNudge \
"id's crippled timenudge\n" \
"This still exists in CPMA, but should always be 0.\n" \
"This still exists in CPMA, but should always be " S_COLOR_VAL "0 " S_COLOR_HELP ".\n" \
"All it really does now is mess up the automatic adaptive nudges."
#define help_cl_shownet \
"prints network info\n" \
" -2 = commandTime\n" \
" -1 = entity removed/changed events\n" \
" 0 = disabled\n" \
" 1 = message lengths\n" \
" 2 = message types, commandTime, etc\n" \
" 3 = 2 + entity parsing details\n" \
" 4 = 2 + player state details"
S_COLOR_VAL " -2 " S_COLOR_HELP "= Command time\n" \
S_COLOR_VAL " -1 " S_COLOR_HELP "= Entity removed/changed events\n" \
S_COLOR_VAL " 0 " S_COLOR_HELP "= Disabled\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Message lengths\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Message types, command time, etc\n" \
S_COLOR_VAL " 3 " S_COLOR_HELP "= " S_COLOR_VAL "2 " S_COLOR_HELP "+ entity parsing details\n" \
S_COLOR_VAL " 4 " S_COLOR_HELP "= " S_COLOR_VAL "2 " S_COLOR_HELP "+ player state details"
#define help_cl_showSend \
"prints client to server packet info\n" \
@ -20,29 +20,29 @@
#define help_cl_allowDownload \
"selects the download system\n" \
" -1 = id's old download system\n" \
" 0 = downloads disabled\n" \
" 1 = CNQ3's new download system"
S_COLOR_VAL " -1 " S_COLOR_HELP "= Id's old download system\n" \
S_COLOR_VAL " 0 " S_COLOR_HELP "= Downloads disabled\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= CNQ3's new download system"
#define help_con_scaleMode \
"console text scaling mode\n" \
" 0 = text size scales with con_scale but not the resolution\n" \
" 1 = text size scales with con_scale and the resolution\n" \
" 2 = text size is always 8x12"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Text size scales with con_scale but not the resolution\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Text size scales with con_scale and the resolution\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Text size is always 8x12"
#define help_plus_minus \
"\nAbout commands starting with '+' or '-':\n" \
"- If '+cmdname' is called from a bind, the command is executed every frame until the bind key is released.\n" \
"- If '+cmdname' is not called from a bind, the command is executed every frame until '-cmdname' is called."
"- If '" S_COLOR_CMD "+cmdname" S_COLOR_HELP "' is called from a bind, the command is executed every frame until the bind key is released.\n" \
"- If '" S_COLOR_CMD "+cmdname" S_COLOR_HELP "' is not called from a bind, the command is executed every frame until '" S_COLOR_CMD "-cmdname" S_COLOR_HELP "' is called."
#define help_cl_debugMove \
"prints a graph of view angle deltas\n" \
" 0 = disabled\n" \
" 1 = horizontal axis\n" \
" 2 = vertical axis"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Disabled\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Horizontal axis\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Vertical axis"
#define help_bind_extra \
"Use /bindkeylist to print the list of key names."
"Use " S_COLOR_CMD "bindkeylist " S_COLOR_HELP "to print the list of key names."
#define help_bind \
"binds a command to a key\n" \
@ -54,17 +54,72 @@ help_bind_extra
#define help_cl_matchAlerts \
"lets you know when a match is starting\n" \
" 1 = when unfocused (otherwise only when minimized)\n" \
" 2 = flash the task bar (Windows only)\n" \
" 4 = beep once (Windows only)\n" \
" 8 = unmute"
S_COLOR_VAL " 1 " S_COLOR_HELP "= When unfocused (otherwise only when minimized)\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Flash the task bar (Windows only)\n" \
S_COLOR_VAL " 4 " S_COLOR_HELP "= Beep once (Windows only)\n" \
S_COLOR_VAL " 8 " S_COLOR_HELP "= Unmute"
#define help_s_autoMute \
"selects when the audio output should be disabled\n" \
" 0 = never\n" \
" 1 = window is not focused\n" \
" 2 = window is minimized"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Never\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Window is not focused\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Window is minimized"
#define help_con_notifytime \
"seconds messages stay visible in the notify area\n" \
"If -1, CPMA will draw the notify area with the 'Console' SuperHUD element."
"If " S_COLOR_VAL "-1" S_COLOR_HELP ", CPMA will draw the notify area with the 'Console' SuperHUD element."
#define help_m_accelStyle \
S_COLOR_VAL "0" S_COLOR_HELP "=original, " S_COLOR_VAL "1" S_COLOR_HELP "=new"
#define help_m_accelOffset \
"offset for the power function\n" \
"For " S_COLOR_CVAR "m_accelStyle " S_COLOR_VAL "1 " S_COLOR_HELP "only."
#define help_m_limit \
"mouse speed cap (" S_COLOR_VAL "0" S_COLOR_HELP "=disabled)\n" \
"For " S_COLOR_CVAR "m_accelStyle " S_COLOR_VAL "0 " S_COLOR_HELP "only."
#define help_m_forward \
"forward/backwards mouse sensitivity (" S_COLOR_CMD "+strafe" S_COLOR_HELP ")"
#define help_m_side \
"left/right mouse sensitivity (" S_COLOR_CMD "+strafe" S_COLOR_HELP ")"
#define help_cl_pitchspeed \
S_COLOR_CMD "+lookup +lookdown " S_COLOR_HELP "speed"
#define help_cl_yawspeed \
S_COLOR_CMD "+right +left " S_COLOR_HELP "speed"
#define help_cl_run \
"running enabled (" S_COLOR_VAL "0" S_COLOR_HELP "=walk)"
#define help_cl_freelook \
S_COLOR_VAL "0 " S_COLOR_HELP "means you can't look up/down"
#define help_cl_showMouseRate \
"prints info when " S_COLOR_CVAR "m_accel " S_COLOR_HELP "!= " S_COLOR_VAL "0"
#define help_rconPassword \
"server password, used by /" S_COLOR_CMD "rcon"
#define help_cl_aviFrameRate \
"frame-rate for /" S_COLOR_CMD "video"
#define help_cl_aviMotionJpeg \
"/" S_COLOR_CMD "video " S_COLOR_HELP "stores frames as JPEGs"
#define help_rconAddress \
"IP address of the server to /" S_COLOR_CMD "rcon " S_COLOR_HELP "to"
#define help_con_colHL \
"RGBA color of auto-completion highlights\n" \
"This requires " S_COLOR_CVAR "con_completionStyle " S_COLOR_VAL "1" S_COLOR_HELP "."
#define help_con_drawHelp \
"draws help text below the console\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Enables the help panel below the console\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Draws the help panel even if the cvar/cmd has no help text\n" \
S_COLOR_VAL " 4 " S_COLOR_HELP "= Draws the list of modules\n" \
S_COLOR_VAL " 8 " S_COLOR_HELP "= Draws the list of attributes (cvars only)"

View file

@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "keycodes.h"
void Field_Draw( field_t* edit, int x, int y, int cw, int ch );
void Field_Draw( field_t* edit, int x, int y, int cw, int ch, qbool extColors );
extern history_t g_history;
extern field_t g_consoleField;

View file

@ -65,47 +65,19 @@ static void Cmd_Help_f()
Com_Printf( "yeah... no\n" );
return;
}
qbool isCvar = qfalse;
const char *desc;
const char *help;
module_t firstModule;
int moduleMask;
if ( Cvar_GetHelp( &desc, &help, arg1 ) ) {
isCvar = qtrue;
Cvar_GetModuleInfo( &firstModule, &moduleMask, arg1 );
} else if ( Cmd_GetHelp( &desc, &help, arg1 ) ) {
Cmd_GetModuleInfo( &firstModule, &moduleMask, arg1 );
} else {
Com_Printf( "found no cvar/command with the name '%s'\n", arg1 );
return;
}
if ( isCvar ) {
Cvar_PrintFirstHelpLine( arg1 );
}
Com_PrintModules( firstModule, moduleMask );
if ( !desc ) {
Com_Printf( "no help text found for %s '%s'\n", isCvar ? "cvar" : "command", arg1 );
return;
}
const char firstLetter = toupper( *desc );
Com_Printf( COLOR_HELP"%c%s.\n", firstLetter, desc + 1 );
if ( help )
Com_Printf( COLOR_HELP"%s\n", help );
Com_PrintHelp( arg1, &Com_Printf, qtrue, qtrue, qtrue );
}
static void Cmd_PrintSearchResult( const char *name, const char *desc, const char *help, const char *pattern )
static void Cmd_PrintSearchResult( const char *name, const char *desc, const char *help, const char *pattern, qbool cvar )
{
const char* const color = cvar ? S_COLOR_CVAR : S_COLOR_CMD;
if ( Q_stristr(name, pattern) || (desc && Q_stristr(desc, pattern)) || (help && Q_stristr(help, pattern)) ) {
if ( desc )
Com_Printf( " %s - %s\n", name, desc );
Com_Printf( " %s%s ^7- " S_COLOR_HELP "%s\n", color, name, desc );
else
Com_Printf( " %s\n", name );
Com_Printf( " %s%s\n", color, name );
}
}
@ -687,7 +659,7 @@ void Cmd_EnumHelp( search_callback_t callback, const char* pattern )
cmd_function_t* cmd;
for ( cmd = cmd_functions; cmd; cmd = cmd->next) {
callback( cmd->name, cmd->desc, cmd->help, pattern );
callback( cmd->name, cmd->desc, cmd->help, pattern, qfalse );
}
}

View file

@ -2729,9 +2729,9 @@ static void PrintCmdMatches( const char *s )
const char h = help != NULL ? 'h' : ' ';
if ( desc )
Com_sprintf( msg, sizeof(msg), " %c " COLOR_CMD "%s - " COLOR_HELP "%s\n", h, s, desc );
Com_sprintf( msg, sizeof(msg), " %c " S_COLOR_CMD "%s ^7- " S_COLOR_HELP "%s\n", h, s, desc );
else
Com_sprintf( msg, sizeof(msg), " %c " COLOR_CMD "%s\n", h, s );
Com_sprintf( msg, sizeof(msg), " %c " S_COLOR_CMD "%s\n", h, s );
Com_TruncatePrintString( msg, sizeof(msg), CONSOLE_WIDTH );
Com_Printf( msg );
@ -2749,11 +2749,12 @@ static void PrintCvarMatches( const char *s )
Cvar_GetHelp( &desc, &help, s );
const char h = help != NULL ? 'h' : ' ';
const char u = ( Cvar_Flags(s) & CVAR_USER_CREATED ) != 0 ? '?' : h;
const char* const q = Cvar_Type(s) == CVART_STRING ? "\"" : "";
if ( desc )
Com_sprintf( msg, sizeof(msg), " %c " COLOR_CVAR "%s^7 = \"" COLOR_VAL "%s^7\" - " COLOR_HELP "%s\n", u, s, Cvar_VariableString( s ), desc );
Com_sprintf( msg, sizeof(msg), " %c " S_COLOR_CVAR "%s^7 = %s" S_COLOR_VAL "%s^7%s - " S_COLOR_HELP "%s\n", u, s, q, Cvar_VariableString( s ), q, desc );
else
Com_sprintf( msg, sizeof(msg), " %c " COLOR_CVAR "%s^7 = \"" COLOR_VAL "%s^7\"\n", u, s, Cvar_VariableString( s ) );
Com_sprintf( msg, sizeof(msg), " %c " S_COLOR_CVAR "%s^7 = %s" S_COLOR_VAL "%s^7%s\n", u, s, q, Cvar_VariableString( s ), q );
Com_TruncatePrintString( msg, sizeof(msg), CONSOLE_WIDTH );
Com_Printf( msg );
@ -3322,7 +3323,7 @@ void Com_TruncatePrintString( char* buffer, int size, int maxLength )
}
void Com_PrintModules( module_t firstModule, int moduleMask )
static void Com_PrintModules( module_t firstModule, int moduleMask, printf_t print )
{
#define MODULE_ITEM(Enum, Desc) Desc,
static const char* ModuleNames[MODULE_COUNT + 1] =
@ -3332,21 +3333,68 @@ void Com_PrintModules( module_t firstModule, int moduleMask )
};
#undef MODULE_ITEM
if ( firstModule == MODULE_NONE || moduleMask == 0 )
if ( firstModule == MODULE_NONE || moduleMask == 0 ) {
print( "Module: Unknown\n" );
return;
}
const int otherModules = moduleMask & (~(1 << firstModule));
if ( otherModules )
Com_Printf( "Modules: " );
print( "Modules: " );
else
Com_Printf( "Module: " );
Com_Printf( "%s", ModuleNames[firstModule] );
print( "Module: " );
print( "%s", ModuleNames[firstModule] );
for ( int i = 0; i < 32; ++i ) {
if ( (otherModules >> i) & 1 )
Com_Printf( ", %s", ModuleNames[i] );
print( ", %s", ModuleNames[i] );
}
Com_Printf("\n");
print( "\n" );
}
printHelpResult_t Com_PrintHelp( const char* name, printf_t print, qbool printNotFound, qbool printModules, qbool printFlags )
{
qbool isCvar = qfalse;
const char *desc;
const char *help;
module_t firstModule;
int moduleMask;
if ( Cvar_GetHelp( &desc, &help, name ) ) {
isCvar = qtrue;
Cvar_GetModuleInfo( &firstModule, &moduleMask, name );
} else if ( Cmd_GetHelp( &desc, &help, name ) ) {
Cmd_GetModuleInfo( &firstModule, &moduleMask, name );
} else {
if ( printNotFound )
print( "found no cvar/command with the name '%s'\n", name );
return PHR_NOTFOUND;
}
if ( isCvar )
Cvar_PrintFirstHelpLine( name, print );
else
print( S_COLOR_CMD "%s\n", name );
if ( printModules )
Com_PrintModules( firstModule, moduleMask, print );
if ( isCvar && printFlags )
Cvar_PrintFlags( name, print );
if ( !desc ) {
if ( printNotFound )
print( "no help text found for %s %s%s\n",
isCvar ? "cvar" : "command", isCvar ? S_COLOR_CVAR : S_COLOR_CMD, name );
return PHR_NOHELP;
}
const char firstLetter = toupper( *desc );
print( S_COLOR_HELP "%c%s" S_COLOR_HELP ".\n", firstLetter, desc + 1 );
if ( help )
print( S_COLOR_HELP "%s\n", help );
return PHR_HADHELP;
}

View file

@ -7,7 +7,7 @@
#define help_toggle \
"toggles the boolean value of a variable\n" \
"non-0 becomes 0 and 0 becomes 1"
"Non-" S_COLOR_VAL "0 " S_COLOR_HELP "becomes " S_COLOR_VAL "0 " S_COLOR_HELP "and " S_COLOR_VAL "0 " S_COLOR_HELP "becomes " S_COLOR_VAL "1" S_COLOR_HELP "."
#define help_cvarlist \
"lists and filters all cvars\n" \
@ -27,20 +27,20 @@ help_pattern_matching \
#define help_com_logfile \
"console logging to qconsole.log\n" \
" 0 = disabled\n" \
" 1 = enabled\n" \
" 2 = enabled and flushes the file after every write"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Disabled\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Enabled\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Enabled and flushes the file after every write"
#define help_com_viewlog \
"early console window visibility\n" \
" 0 = hidden\n" \
" 1 = visible\n" \
" 2 = minimized"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Hidden\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Visible\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Minimized"
#define help_con_completionStyle \
"auto-completion style\n" \
" 0 = legacy: always prints all results\n" \
" 1 = ET-style: prints once then cycles reults"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Legacy, always print all results\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= ET-style, print once then cycle"
#define help_qport \
"internal network port\n" \
@ -48,12 +48,11 @@ help_pattern_matching \
#define help_vm_load \
"\n" \
" 0 = shared library (native code)\n" \
" 1 = interpreted QVM\n" \
" 2 = JIT-compiled QVM"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Shared library (native code)\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Interpreted QVM\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= JIT-compiled QVM"
#define help_com_maxfps \
"max. allowed framerate\n" \
"It's highly recommended to only use 125 or 250 with V-Sync disabled." \
"If you get the 'connection interruped' message with 250,\n" \
"set it back to 125."
"It's highly recommended to only use " S_COLOR_VAL "125 " S_COLOR_HELP "or " S_COLOR_VAL "250 " S_COLOR_HELP "with V-Sync disabled.\n" \
"If you see 'connection interruped' with " S_COLOR_VAL "250" S_COLOR_HELP ", set it back to " S_COLOR_VAL "125" S_COLOR_HELP "."

View file

@ -122,7 +122,7 @@ void Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize
}
int Cvar_Flags(const char *var_name)
int Cvar_Flags( const char *var_name )
{
const cvar_t* var;
@ -133,6 +133,17 @@ int Cvar_Flags(const char *var_name)
}
cvarType_t Cvar_Type( const char *var_name )
{
const cvar_t* var;
if (!(var = Cvar_FindVar(var_name)))
return CVART_STRING;
return var->type;
}
void Cvar_CommandCompletion( void(*callback)(const char *s) )
{
for (const cvar_t* cvar = cvar_vars; cvar; cvar = cvar->next) {
@ -151,7 +162,7 @@ void Cvar_EnumHelp( search_callback_t callback, const char* pattern )
cvar_t* cvar;
for ( cvar = cvar_vars; cvar; cvar = cvar->next ) {
if( cvar->name && !(cvar->flags & CVAR_USER_CREATED) )
callback( cvar->name, cvar->desc, cvar->help, pattern );
callback( cvar->name, cvar->desc, cvar->help, pattern, qtrue );
}
}
@ -274,7 +285,7 @@ static cvar_t* Cvar_Set2( const char *var_name, const char *value, qbool force )
return var;
}
Com_Printf( "%s will be changed upon restarting.\n", var_name );
Com_Printf( S_COLOR_CVAR "%s ^7will be changed upon restarting.\n", var_name );
var->latchedString = CopyString(value);
var->modified = qtrue;
var->modificationCount++;
@ -566,56 +577,109 @@ static const char* Cvar_FormatRangeFloat( float vf )
}
static void Cvar_PrintTypeAndRange( const cvar_t *var )
void Cvar_PrintTypeAndRange( const char *var_name, printf_t print )
{
cvar_t* var = Cvar_FindVar( var_name );
if ( !var )
return;
if ( var->type == CVART_BOOL ) {
Com_Printf( "0|1" );
print( S_COLOR_VAL "0^7|" S_COLOR_VAL "1" );
} else if ( var->type == CVART_BITMASK ) {
Com_Printf( "bitmask" );
print( "bitmask" );
} else if ( var->type == CVART_FLOAT ) {
const float minV = var->validator.f.min;
const float maxV = var->validator.f.max;
if ( minV == -FLT_MAX && maxV == FLT_MAX ) {
Com_Printf( "float_value" );
print( "float_value" );
} else {
const char* min = minV == -FLT_MAX ? "-inf" : Cvar_FormatRangeFloat( minV );
const char* max = maxV == +FLT_MAX ? "+inf" : Cvar_FormatRangeFloat( maxV );
Com_Printf( "%s to %s", min, max );
print( S_COLOR_VAL "%s ^7to " S_COLOR_VAL "%s", min, max );
}
} else if ( var->type == CVART_INTEGER ) {
const int minV = var->validator.i.min;
const int maxV = var->validator.i.max;
const int diff = maxV - minV;
if( minV == INT_MIN && maxV == INT_MAX ) {
Com_Printf( "integer_value" );
print( "integer_value" );
} else if ( diff == 0 ) {
Com_Printf( "%d", minV );
print( S_COLOR_VAL "%d", minV );
} else if ( diff == 1 ) {
Com_Printf( "%d|%d", minV, minV + 1 );
print( S_COLOR_VAL "%d^7|" S_COLOR_VAL "%d", minV, minV + 1 );
} else if ( diff == 2 ) {
Com_Printf( "%d|%d|%d", minV, minV + 1, minV + 2 );
print( S_COLOR_VAL "%d^7|" S_COLOR_VAL "%d^7|" S_COLOR_VAL "%d", minV, minV + 1, minV + 2 );
} else if ( diff == 3 ) {
Com_Printf( "%d|%d|%d|%d", minV, minV + 1, minV + 2, minV + 3 );
print( S_COLOR_VAL "%d^7|" S_COLOR_VAL "%d^7|" S_COLOR_VAL "%d^7|" S_COLOR_VAL "%d", minV, minV + 1, minV + 2, minV + 3 );
} else {
const char* min = minV == INT_MIN ? "-inf" : va( "%d", minV );
const char* max = maxV == INT_MAX ? "+inf" : va( "%d", maxV );
Com_Printf( "%s to %s", min, max );
print( S_COLOR_VAL "%s ^7to " S_COLOR_VAL "%s", min, max );
}
} else {
Com_Printf( "string" );
print( "string" );
}
}
void Cvar_PrintFirstHelpLine( const char *var_name )
void Cvar_PrintFirstHelpLine( const char *var_name, printf_t print )
{
cvar_t* var = Cvar_FindVar( var_name );
if ( !var )
return;
Com_Printf( "%s <", var_name );
Cvar_PrintTypeAndRange( var );
Com_Printf( "> (default: %s)\n", var->resetString );
const char* const q = var->type == CVART_STRING ? "\"" : "";
print( S_COLOR_CVAR "%s ^7<", var_name );
Cvar_PrintTypeAndRange( var_name, print );
print( "> (default: %s" S_COLOR_VAL "%s^7%s)\n", q, var->resetString, q );
}
void Cvar_PrintFlags( const char *var_name, printf_t print )
{
cvar_t* var = Cvar_FindVar( var_name );
if ( !var )
return;
static const char* names[] = {
"Archived",
"User Info",
"Server Info",
"System Info",
"Init",
"Latched",
"Read-only",
"User-created",
"Temporary",
"Cheat-protected",
"No Reset",
"Server-created"
};
const int flags = var->flags;
int count = 0;
for ( int i = 0; i < ARRAY_LEN(names); ++i ) {
if ( (flags >> i) & 1 )
++count;
}
print( count != 1 ? "Attributes: " : "Attribute: " );
int printed = 0;
for ( int i = 0; i < ARRAY_LEN(names); ++i ) {
if ( !((flags >> i) & 1) )
continue;
if ( printed )
print( ", " );
print( names[i] );
++printed;
}
if ( count )
print( "\n" );
else
print( "None\n" );
}
@ -671,12 +735,12 @@ qbool Cvar_Command()
// perform a variable print or set
if ( Cmd_Argc() == 1 ) {
const char* q = v->type == CVART_STRING ? "\"" : "";
Com_Printf( "%s^7 is %s%s^7%s (", v->name, q, v->string, q );
Cvar_PrintTypeAndRange(v);
Com_Printf( " - default: %s%s^7%s)\n", q, v->resetString, q );
const char* const q = v->type == CVART_STRING ? "\"" : "";
Com_Printf( S_COLOR_CVAR "%s^7 is %s" S_COLOR_VAL "%s^7%s (", v->name, q, v->string, q );
Cvar_PrintTypeAndRange( v->name, &Com_Printf );
Com_Printf( "^7, default: %s" S_COLOR_VAL "%s^7%s)\n", q, v->resetString, q );
if ( v->latchedString ) {
Com_Printf( "latched: %s%s^7%s\n", q, v->latchedString, q );
Com_Printf( "latched: %s" S_COLOR_VAL "%s^7%s\n", q, v->latchedString, q );
}
return qtrue;
}

View file

@ -301,6 +301,12 @@ const /* vec4_t */ float* ColorFromChar( char ccode );
#define COLOR_CYAN '5'
#define COLOR_MAGENTA '6'
#define COLOR_WHITE '7'
#define COLOR_CVAR '\x20'
#define COLOR_CMD '\x21'
#define COLOR_VAL '\x22'
#define COLOR_HELP '\x23'
#define COLOR_WAR '\x24'
#define COLOR_ERR '\x25'
#define S_COLOR_BLACK "^0"
#define S_COLOR_RED "^1"
@ -310,6 +316,12 @@ const /* vec4_t */ float* ColorFromChar( char ccode );
#define S_COLOR_CYAN "^5"
#define S_COLOR_MAGENTA "^6"
#define S_COLOR_WHITE "^7"
#define S_COLOR_CVAR "^\x20"
#define S_COLOR_CMD "^\x21"
#define S_COLOR_VAL "^\x22"
#define S_COLOR_HELP "^\x23"
#define S_COLOR_WAR "^\x24"
#define S_COLOR_ERR "^\x25"
#define MAKERGB( v, r, g, b ) { v[0]=r;v[1]=g;v[2]=b; }
#define MAKERGBA( v, r, g, b, a ) { v[0]=r;v[1]=g;v[2]=b;v[3]=a; }

View file

@ -407,7 +407,7 @@ void Cmd_AutoCompleteArgument( const char* cmd_name, int startArg, int compArg )
// callback with each valid string
void Cmd_CommandCompletion( void(*callback)(const char* s) );
typedef void (*search_callback_t)( const char* name, const char* desc, const char* help, const char* pattern );
typedef void (*search_callback_t)( const char* name, const char* desc, const char* help, const char* pattern, qbool cvar );
void Cmd_EnumHelp( search_callback_t callback, const char* pattern );
// the functions that execute commands get their parameters with these
@ -505,6 +505,7 @@ typedef struct cvarTableItem_s {
const char* help;
} cvarTableItem_t;
typedef void ( QDECL *printf_t )( const char* fmt, ... );
cvar_t *Cvar_Get( const char *var_name, const char *value, int flags );
// creates the variable if it doesn't exist, or returns the existing one
@ -522,8 +523,10 @@ void Cvar_RegisterTable( const cvarTableItem_t* cvars, int count, module_t modul
void Cvar_SetModule( const char *var_name, module_t module );
void Cvar_GetModuleInfo( module_t *firstModule, int *moduleMask, const char *var_name );
void Cvar_PrintFirstHelpLine( const char *var_name );
void Cvar_PrintTypeAndRange( const char *var_name, printf_t print );
void Cvar_PrintFirstHelpLine( const char *var_name, printf_t print );
void Cvar_PrintFlags( const char *var_name, printf_t print );
void Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
// basically a slightly modified Cvar_Get for the interpreted modules
@ -548,6 +551,8 @@ void Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize
int Cvar_Flags( const char *var_name );
// returns CVAR_NONEXISTENT if cvar doesn't exist or the flags of that particular CVAR.
cvarType_t Cvar_Type( const char *var_name );
void Cvar_CommandCompletion( void(*callback)(const char *s) );
// callback with each valid string
@ -1142,18 +1147,18 @@ const char* Q_itohex( uint64_t number, qbool uppercase, qbool prefix );
void Help_AllocSplitText( char** desc, char** help, const char* combined );
#define COLOR_HELP "^7"
#define COLOR_CMD "^7"
#define COLOR_CVAR "^7"
#define COLOR_VAL "^7"
#define CONSOLE_WIDTH 78
void Com_TruncatePrintString( char* buffer, int size, int maxLength );
void Com_PrintModules( module_t firstModule, int moduleMask );
typedef enum {
PHR_NOTFOUND,
PHR_NOHELP,
PHR_HADHELP
} printHelpResult_t;
printHelpResult_t Com_PrintHelp( const char* name, printf_t print, qbool printNotFound, qbool printModules, qbool printFlags );
#endif // _QCOMMON_H_

View file

@ -53,3 +53,5 @@ extern dllSyscall_t syscall;
cpma_ext.Name = qtrue; \
} \
} while (0)
#define GET_CAP(Name) GET_CMD(Name)

View file

@ -874,6 +874,62 @@ static const void* RB_StretchPic( const void* data )
}
static const void* RB_Triangle( const void* data )
{
const triangleCommand_t* cmd = (const triangleCommand_t*)data;
if ( !backEnd.projection2D )
RB_SetGL2D();
const shader_t* shader = cmd->shader;
if ( shader != tess.shader ) {
if ( tess.numIndexes ) {
RB_EndSurface();
}
backEnd.currentEntity = &backEnd.entity2D;
RB_BeginSurface( shader, 0 );
}
RB_CHECKOVERFLOW( 3, 3 );
int numVerts = tess.numVertexes;
int numIndexes = tess.numIndexes;
tess.numVertexes += 3;
tess.numIndexes += 3;
tess.indexes[ numIndexes + 0 ] = numVerts + 0;
tess.indexes[ numIndexes + 1 ] = numVerts + 1;
tess.indexes[ numIndexes + 2 ] = numVerts + 2;
*(int *)tess.vertexColors[ numVerts ] =
*(int *)tess.vertexColors[ numVerts + 1 ] =
*(int *)tess.vertexColors[ numVerts + 2 ] = *(int *)backEnd.color2D;
tess.xyz[ numVerts ][0] = cmd->x0;
tess.xyz[ numVerts ][1] = cmd->y0;
tess.xyz[ numVerts ][2] = 0;
tess.texCoords[ numVerts ][0][0] = cmd->s0;
tess.texCoords[ numVerts ][0][1] = cmd->t0;
tess.xyz[ numVerts + 1 ][0] = cmd->x1;
tess.xyz[ numVerts + 1 ][1] = cmd->y1;
tess.xyz[ numVerts + 1 ][2] = 0;
tess.texCoords[ numVerts + 1 ][0][0] = cmd->s1;
tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1;
tess.xyz[ numVerts + 2 ][0] = cmd->x2;
tess.xyz[ numVerts + 2 ][1] = cmd->y2;
tess.xyz[ numVerts + 2 ][2] = 0;
tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2;
tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2;
return (const void*)(cmd + 1);
}
static const void* RB_DrawSurfs( const void* data )
{
const drawSurfsCommand_t* cmd = (const drawSurfsCommand_t*)data;
@ -1062,6 +1118,9 @@ void RB_ExecuteRenderCommands( const void *data )
case RC_STRETCH_PIC:
data = RB_StretchPic( data );
break;
case RC_TRIANGLE:
data = RB_Triangle( data );
break;
case RC_DRAW_SURFS:
data = RB_DrawSurfs( data );
break;

View file

@ -131,6 +131,26 @@ void RE_StretchPic( float x, float y, float w, float h, float s1, float t1, floa
}
void RE_DrawTriangle( float x0, float y0, float x1, float y1, float x2, float y2, float s0, float t0, float s1, float t1, float s2, float t2, qhandle_t hShader )
{
R_CMD( triangleCommand_t, RC_TRIANGLE );
cmd->shader = R_GetShaderByHandle( hShader );
cmd->x0 = x0;
cmd->y0 = y0;
cmd->x1 = x1;
cmd->y1 = y1;
cmd->x2 = x2;
cmd->y2 = y2;
cmd->s0 = s0;
cmd->t0 = t0;
cmd->s1 = s1;
cmd->t1 = t1;
cmd->s2 = s2;
cmd->t2 = t2;
}
// if running in stereo, RE_BeginFrame will be called twice for each RE_EndFrame
void RE_BeginFrame( stereoFrame_t stereoFrame )

View file

@ -1,10 +1,10 @@
#define help_r_ext_max_anisotropy \
"max. allowed anisotropy ratio\n" \
"For anisotropic filtering to be enabled, this needs to be 2 or higher.\n" \
" 2 = 8- 16 tap filtering\n" \
" 4 = 16- 32 tap filtering\n" \
" 8 = 32- 64 tap filtering\n" \
" 16 = 64-128 tap filtering"
S_COLOR_VAL " 2 " S_COLOR_HELP "= 8- 16 tap filtering\n" \
S_COLOR_VAL " 4 " S_COLOR_HELP "= 16- 32 tap filtering\n" \
S_COLOR_VAL " 8 " S_COLOR_HELP "= 32- 64 tap filtering\n" \
S_COLOR_VAL " 16 " S_COLOR_HELP "= 64-128 tap filtering"
#define help_r_picmip \
"lowest allowed mip level\n" \
@ -15,22 +15,19 @@
"The maximum scale ratio is 2 on both the horizontal and vertical axis."
#define help_r_mode \
"video mode to use when r_fullscreen is 1\n" \
" 0 = no video mode change, desktop resolution\n" \
" 1 = no video mode change, custom resolution, custom upscaling\n" \
" 2 = video mode change, custom resolution\n" \
"Custom resolutions use r_width and r_height.\n" \
"Custom upscaling uses r_blitMode."
"video mode to use with " S_COLOR_CVAR "r_fullscreen " S_COLOR_VAL "1\n" \
S_COLOR_VAL " 0 " S_COLOR_HELP "= No video mode change, desktop resolution\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= No video mode change, custom resolution, custom upscaling\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Video mode change, custom resolution\n" \
"Custom resolution uses " S_COLOR_CVAR "r_width " S_COLOR_HELP "and " S_COLOR_CVAR "r_height" S_COLOR_HELP ".\n" \
"Custom upscaling uses " S_COLOR_CVAR "r_blitMode" S_COLOR_HELP "."
#define help_r_blitMode \
"image upscaling mode for r_mode 1\n" \
"This will only be active when r_fullscreen is 1 and r_mode is 1.\n" \
" 0 = aspect-ratio preserving upscale (black bars if necessary)\n" \
" 1 = no scaling, centered\n" \
" 2 = full-screen stretching (no black bars)"
#define help_r_mode01 \
"\nOnly used when r_mode is 0 or 1 and r_fullscreen is 1."
"image upscaling mode for " S_COLOR_CVAR "r_mode " S_COLOR_VAL "1\n" \
"This will only be active with " S_COLOR_CVAR "r_fullscreen " S_COLOR_VAL "1 " S_COLOR_HELP "and " S_COLOR_CVAR "r_mode " S_COLOR_VAL "1" S_COLOR_HELP ".\n" \
S_COLOR_VAL " 0 " S_COLOR_HELP "= Aspect-ratio preserving upscale (black bars if necessary)\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= No scaling, centered\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Full-screen stretching (no black bars)"
#define help_r_subdivisions \
"tessellation step size for patch surfaces\n" \
@ -39,14 +36,14 @@
#define help_r_gamma \
"gamma correction factor\n" \
" <1 = darker\n" \
" 1 = no change\n" \
" >1 = brighter"
S_COLOR_HELP " <" S_COLOR_VAL "1 " S_COLOR_HELP "= Darker\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= No change\n" \
S_COLOR_HELP " >" S_COLOR_VAL "1 " S_COLOR_HELP "= Brighter"
#define help_r_lodbias \
"MD3 models LOD bias\n" \
"For all MD3 models, including player characters.\n" \
"A higher number means a higher quality loss. 0 means no loss."
"A higher number means a higher quality loss. " S_COLOR_VAL "0 " S_COLOR_HELP "means no loss."
#define help_r_fastsky \
"makes the sky and portals pure black\n" \
@ -58,26 +55,26 @@
#define help_r_textureMode \
"texture filtering mode\n" \
" GL_NEAREST = no filtering\n" \
" GL_LINEAR_MIPMAP_NEAREST = bilinear filtering\n" \
" GL_LINEAR_MIPMAP_LINEAR = trilinear filtering\n" \
"For anisotropic filtering, refer to /help r_ext_max_anisotropy."
S_COLOR_VAL " GL_NEAREST " S_COLOR_HELP "= No filtering\n" \
S_COLOR_VAL " GL_LINEAR_MIPMAP_NEAREST " S_COLOR_HELP "= Bilinear filtering\n" \
S_COLOR_VAL " GL_LINEAR_MIPMAP_LINEAR " S_COLOR_HELP "= Trilinear filtering\n" \
"For anisotropic filtering, refer to " S_COLOR_CVAR "r_ext_max_anisotropy" S_COLOR_HELP "."
#define help_r_swapInterval \
"v-blanks to wait for before swapping buffers\n" \
" 0 = No V-Sync\n" \
" 1 = Synced to the monitor's refresh rate\n" \
" 2 = Synced to half the monitor's refresh rate\n" \
" 3 = Synced to one third of the monitor's refresh rate\n" \
" N = Synced to monitor_refresh_rate / N\n" \
"It is not recommended to use V-Sync."
S_COLOR_VAL " 0 " S_COLOR_HELP "= No V-Sync\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Synced to the monitor's refresh rate\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Synced to half the monitor's refresh rate\n" \
S_COLOR_VAL " 3 " S_COLOR_HELP "= Synced to one third of the monitor's refresh rate\n" \
S_COLOR_VAL " N " S_COLOR_HELP "= Synced to monitor_refresh_rate / " S_COLOR_VAL "N\n" \
S_COLOR_HELP "It is not recommended to use V-Sync."
#define help_r_lightmap \
"renders the lightmaps only\n" \
"Shaders with a lightmap stage will only draw the lightmap stage.\n" \
"This is mutually exclusive with r_fullbright."
"This is mutually exclusive with " S_COLOR_CVAR "r_fullbright" S_COLOR_HELP "."
#define help_r_fullbright \
"renders the diffuse textures only\n" \
"Shaders with a lightmap stage will not draw the lightmap stage.\n" \
"This is mutually exclusive with r_lightmap."
"This is mutually exclusive with " S_COLOR_CVAR "r_lightmap" S_COLOR_HELP "."

View file

@ -534,7 +534,7 @@ static const cvarTableItem_t r_cvars[] =
// latched and archived variables
//
{ &r_ext_max_anisotropy, "r_ext_max_anisotropy", "16", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0", "16", help_r_ext_max_anisotropy },
{ &r_msaa, "r_msaa", "4", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0", "16", "anti-aliasing sample count, 0=off" },
{ &r_msaa, "r_msaa", "4", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0", "16", "anti-aliasing sample count, " S_COLOR_VAL "0" S_COLOR_HELP "=off" },
{ &r_picmip, "r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0", "16", help_r_picmip },
{ &r_roundImagesDown, "r_roundImagesDown", "0", CVAR_ARCHIVE | CVAR_LATCH, CVART_BOOL, NULL, NULL, help_r_roundImagesDown },
{ &r_colorMipLevels, "r_colorMipLevels", "0", CVAR_LATCH, CVART_BOOL, NULL, NULL, "colorizes textures based on their mip level" },
@ -547,9 +547,9 @@ static const cvarTableItem_t r_cvars[] =
// should be called r_textureBrightness
{ &r_intensity, "r_intensity", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_FLOAT, "1", NULL, "brightness of non-lightmap map textures" },
{ &r_fullscreen, "r_fullscreen", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_BOOL, NULL, NULL, "full-screen mode" },
{ &r_width, "r_width", "1280", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "320", "65535", "custom window/render width" help_r_mode01 },
{ &r_height, "r_height", "720", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "240", "65535", "custom window/render height" help_r_mode01 },
{ &r_customaspect, "r_customaspect", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0.1", "10", "custom pixel aspect ratio" help_r_mode01 },
{ &r_width, "r_width", "1280", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "320", "65535", "custom window/render width" },
{ &r_height, "r_height", "720", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "240", "65535", "custom window/render height" },
{ &r_customaspect, "r_customaspect", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0.1", "10", "custom pixel aspect ratio" },
{ &r_vertexLight, "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH, CVART_BOOL, NULL, NULL, "disables lightmap texture blending" },
// note that r_subdivisions > 64 will create rendering artefacts because you'll see the other side of a curved surface when against it
{ &r_subdivisions, "r_subdivisions", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_FLOAT, "1", "64", help_r_subdivisions },
@ -557,7 +557,7 @@ static const cvarTableItem_t r_cvars[] =
//
// latched variables that can only change over a restart
//
{ &r_displayRefresh, "r_displayRefresh", "0", CVAR_LATCH, CVART_INTEGER, "0", "480", "0 lets the driver decide" },
{ &r_displayRefresh, "r_displayRefresh", "0", CVAR_LATCH, CVART_INTEGER, "0", "480", S_COLOR_VAL "0 " S_COLOR_HELP "lets the driver decide" },
{ &r_singleShader, "r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH },
//
@ -565,7 +565,7 @@ static const cvarTableItem_t r_cvars[] =
//
{ &r_lodbias, "r_lodbias", "0", CVAR_ARCHIVE, CVART_INTEGER, "0", "16", help_r_lodbias },
{ &r_flares, "r_flares", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "enables light flares" },
{ &r_ignoreGLErrors, "r_ignoreGLErrors", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "if 0, OpenGL errors are fatal" },
{ &r_ignoreGLErrors, "r_ignoreGLErrors", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "if " S_COLOR_VAL "0" S_COLOR_HELP ", OpenGL errors are fatal" },
{ &r_fastsky, "r_fastsky", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_r_fastsky },
{ &r_noportals, "r_noportals", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_r_noportals },
{ &r_dynamiclight, "r_dynamiclight", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "enables dynamic lights" },
@ -781,6 +781,7 @@ const refexport_t* GetRefAPI( const refimport_t* rimp )
re.SetColor = RE_SetColor;
re.DrawStretchPic = RE_StretchPic;
re.DrawTriangle = RE_DrawTriangle;
re.DrawStretchRaw = RE_StretchRaw;
re.UploadCinematic = RE_UploadCinematic;

View file

@ -1409,6 +1409,17 @@ typedef struct {
float s2, t2;
} stretchPicCommand_t;
typedef struct {
int commandId;
const shader_t* shader;
float x0, y0;
float x1, y1;
float x2, y2;
float s0, t0;
float s1, t1;
float s2, t2;
} triangleCommand_t;
typedef struct {
int commandId;
trRefdef_t refdef;
@ -1444,6 +1455,7 @@ typedef enum {
RC_END_OF_LIST,
RC_SET_COLOR,
RC_STRETCH_PIC,
RC_TRIANGLE,
RC_DRAW_SURFS,
RC_BEGIN_FRAME,
RC_SWAP_BUFFERS,
@ -1485,6 +1497,8 @@ void RE_EndFrame( int* pcFE, int* pc2D, int* pc3D );
void RE_SetColor( const float* rgba );
void RE_StretchPic( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader );
void RE_DrawTriangle( float x0, float y0, float x1, float y1, float x2, float y2,
float s0, float t0, float s1, float t1, float s2, float t2, qhandle_t hShader );
int SaveJPGToBuffer( byte* out, int quality, int image_width, int image_height, byte* image_buffer );
void RE_TakeVideoFrame( int width, int height,

View file

@ -136,6 +136,8 @@ typedef struct {
void (*SetColor)( const float* rgba ); // NULL = 1,1,1,1
void (*DrawStretchPic)( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader );
void (*DrawTriangle)( float x0, float y0, float x1, float y1, float x2, float y2,
float s0, float t0, float s1, float t1, float s2, float t2, qhandle_t hShader );
// Draw images for cinematic rendering, pass as 32 bit rgba
void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qbool dirty);

View file

@ -238,11 +238,14 @@ static qbool SV_G_GetValue( char* value, int valueSize, const char* key )
{
struct syscall_t { const char* name; int number; };
static const syscall_t syscalls[] = {
// syscalls
{ "trap_LocateInteropData", G_EXT_LOCATEINTEROPDATA },
{ "trap_Cvar_SetRange", G_EXT_CVAR_SETRANGE },
{ "trap_Cvar_SetHelp", G_EXT_CVAR_SETHELP },
{ "trap_Cmd_SetHelp", G_EXT_CMD_SETHELP },
{ "trap_Error2", G_EXT_ERROR2 }
{ "trap_Error2", G_EXT_ERROR2 },
// capabilities
{ "cap_ExtraColorCodes", 1 }
};
for ( int i = 0; i < ARRAY_LEN( syscalls ); ++i ) {

View file

@ -538,10 +538,10 @@ static const cvarTableItem_t sv_cvars[] =
{ &sv_privateClients, "sv_privateClients", "0", CVAR_SERVERINFO, CVART_INTEGER, "0", XSTRING(MAX_CLIENTS), "number of password-reserved player slots" },
{ &sv_hostname, "sv_hostname", "noname", CVAR_SERVERINFO | CVAR_ARCHIVE, CVART_STRING, NULL, NULL, "server name" },
{ &sv_maxclients, "sv_maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH, CVART_INTEGER, "0", XSTRING(MAX_CLIENTS), "max. player count" },
{ &sv_minRate, "sv_minRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "min. rate allowed, 0 means no limit" },
{ &sv_maxRate, "sv_maxRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "max. rate allowed, 0 means no limit" },
{ &sv_minPing, "sv_minPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "min. ping allowed, 0 means no limit" },
{ &sv_maxPing, "sv_maxPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "max. ping allowed, 0 means no limit" },
{ &sv_minRate, "sv_minRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "min. rate allowed, " S_COLOR_VAL "0 " S_COLOR_HELP "means no limit" },
{ &sv_maxRate, "sv_maxRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "max. rate allowed, " S_COLOR_VAL "0 " S_COLOR_HELP "means no limit" },
{ &sv_minPing, "sv_minPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "min. ping allowed, " S_COLOR_VAL "0 " S_COLOR_HELP "means no limit" },
{ &sv_maxPing, "sv_maxPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_INTEGER, "0", NULL, "max. ping allowed, " S_COLOR_VAL "0 " S_COLOR_HELP "means no limit" },
{ &sv_floodProtect, "sv_floodProtect", "1", CVAR_ARCHIVE | CVAR_SERVERINFO, CVART_BOOL, NULL, NULL, "prevents malicious users from lagging the entire server" },
// systeminfo vars
{ NULL, "sv_cheats", "0", CVAR_SYSTEMINFO | CVAR_ROM, CVART_BOOL, NULL, NULL, "enables cheat commands and changing cheat cvars" },
@ -552,8 +552,8 @@ static const cvarTableItem_t sv_cvars[] =
{ NULL, "sv_referencedPaks", "", CVAR_SYSTEMINFO | CVAR_ROM, CVART_STRING, NULL, NULL, "checksums of the paks you might need to download" },
{ NULL, "sv_referencedPakNames", "", CVAR_SYSTEMINFO | CVAR_ROM, CVART_STRING, NULL, NULL, "name of the paks you might need to download" },
// server vars
{ &sv_rconPassword, "rconPassword", "", CVAR_TEMP, CVART_STRING, NULL, NULL, "password for /rcon access" },
{ &sv_privatePassword, "sv_privatePassword", "", CVAR_TEMP, CVART_STRING, NULL, NULL, "password for the sv_privateClients slots" },
{ &sv_rconPassword, "rconPassword", "", CVAR_TEMP, CVART_STRING, NULL, NULL, "password for /" S_COLOR_CMD "rcon " S_COLOR_HELP "access" },
{ &sv_privatePassword, "sv_privatePassword", "", CVAR_TEMP, CVART_STRING, NULL, NULL, "password for the " S_COLOR_CVAR "sv_privateClients " S_COLOR_HELP "slots" },
{ &sv_fps, "sv_fps", "30", CVAR_TEMP, CVART_INTEGER, "10", "40", "snapshot generation frequency" },
{ &sv_timeout, "sv_timeout", "200", CVAR_TEMP, CVART_INTEGER, "0", NULL, "max. seconds allowed without any messages" },
{ &sv_zombietime, "sv_zombietime", "2", CVAR_TEMP, CVART_INTEGER, "0", NULL, "seconds to sink messages after disconnect" },
@ -561,9 +561,9 @@ static const cvarTableItem_t sv_cvars[] =
{ &sv_allowDownload, "sv_allowDownload", "0", CVAR_SERVERINFO, CVART_BOOL, NULL, NULL, "enables slow pk3 downloads directly from the server" },
{ &sv_reconnectlimit, "sv_reconnectlimit", "3", 0, CVART_INTEGER, "0", NULL, "min. seconds between connection attempts" },
{ &sv_padPackets, "sv_padPackets", "0", 0, CVART_BOOL, NULL, NULL, "add nop bytes to messages" },
{ &sv_killserver, "sv_killserver", "0", 0, CVART_BOOL, NULL, NULL, "menu system can set to 1 to shut server down" },
{ &sv_killserver, "sv_killserver", "0", 0, CVART_BOOL, NULL, NULL, "menu system can set to " S_COLOR_VAL "1 " S_COLOR_HELP "to shut server down" },
{ NULL, "sv_mapChecksum", "", CVAR_ROM, CVART_INTEGER, NULL, NULL, ".bsp file checksum" },
{ &sv_lanForceRate, "sv_lanForceRate", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "1 means uncapped rate on LAN" },
{ &sv_lanForceRate, "sv_lanForceRate", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, S_COLOR_VAL "1 " S_COLOR_HELP "means uncapped rate on LAN" },
{ &sv_strictAuth, "sv_strictAuth", "0", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "requires CD key authentication" },
{ &sv_minRestartDelay, "sv_minRestartDelay", "2", 0, CVART_INTEGER, "1", "48", "min. hours to wait before restarting the server" }
};

View file

@ -1,9 +1,9 @@
#define help_in_mouse \
"mouse input mode\n" \
" 0 = disabled\n" \
" 1 = raw input\n" \
" 2 = win32 input"
S_COLOR_VAL " 0 " S_COLOR_HELP "= Disabled\n" \
S_COLOR_VAL " 1 " S_COLOR_HELP "= Raw input\n" \
S_COLOR_VAL " 2 " S_COLOR_HELP "= Win32 input"
#define help_in_minimize \
"hotkey to minimize/restore the window\n" \
"Use /minimizekeynames to print the list of usable key names."
"Use " S_COLOR_CMD "minimizekeynames " S_COLOR_HELP "to print the list of usable key names."