UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_console.cpp File Reference

Console related code. More...

#include "cl_console.h"
#include "client.h"
#include "cgame/cl_game.h"
#include "input/cl_keys.h"
#include "renderer/r_draw.h"
#include "../shared/utf8.h"
Include dependency graph for cl_console.cpp:

Go to the source code of this file.

Data Structures

struct  console_t

Macros

#define ColorIndex(c)
#define CONSOLE_CHAR_ALIGN   4
#define NUM_CON_TIMES   8
#define CON_TEXTSIZE   32768
#define CONSOLE_CURSOR_CHAR   11
#define CONSOLE_HISTORY_FILENAME   "history"

Functions

static void Con_Clear (void)
static void Con_DrawText (const short *text, int x, int y, size_t width)
void Con_DrawString (const char *txt, int x, int y, unsigned int width)
static void Key_ClearTyping (void)
void Con_ToggleConsole_f (void)
static void Con_ToggleChat_f (void)
static void Con_Clear_f (void)
 Clears the console buffer.
void Con_Scroll (int scroll)
 Scrolls the console.
void Con_CheckResize (void)
 If the line width has changed, reformat the buffer.
void Con_LoadConsoleHistory (void)
 Load the console history.
void Con_SaveConsoleHistory (void)
 Stores the console history.
void Con_Init (void)
static void Con_Linefeed (void)
void Con_Print (const char *txt)
 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 text will appear at the top of the game window.
void Con_Close (void)
 Hide the gameconsole if active.
static void Con_DrawInput (void)
 The input line scrolls horizontally if typing goes beyond the right edge.
void Con_DrawConsole (float frac)
 Draws the console with the solid background.

Variables

static const uint32_t g_color_table []
static console_t con
static cvar_tcon_notifytime
static cvar_tcon_history
static cvar_tcon_background
const int con_fontHeight = 12
const int con_fontWidth = 10
const int con_fontShift = 3

Detailed Description

Console related code.

Definition in file cl_console.cpp.

Macro Definition Documentation

◆ ColorIndex

#define ColorIndex ( c)
Value:
(((c) - '0') & 0x07)

Definition at line 36 of file cl_console.cpp.

Referenced by Con_DrawString(), and Con_Print().

◆ CON_TEXTSIZE

#define CON_TEXTSIZE   32768

Definition at line 53 of file cl_console.cpp.

Referenced by Con_CheckResize().

◆ CONSOLE_CHAR_ALIGN

#define CONSOLE_CHAR_ALIGN   4

Definition at line 51 of file cl_console.cpp.

Referenced by Con_DrawConsole(), and Con_DrawInput().

◆ CONSOLE_CURSOR_CHAR

#define CONSOLE_CURSOR_CHAR   11

Definition at line 54 of file cl_console.cpp.

Referenced by Con_DrawInput().

◆ CONSOLE_HISTORY_FILENAME

#define CONSOLE_HISTORY_FILENAME   "history"

Definition at line 55 of file cl_console.cpp.

Referenced by Con_LoadConsoleHistory(), and Con_SaveConsoleHistory().

◆ NUM_CON_TIMES

#define NUM_CON_TIMES   8

Definition at line 52 of file cl_console.cpp.

Function Documentation

◆ Con_CheckResize()

void Con_CheckResize ( void )

If the line width has changed, reformat the buffer.

Definition at line 184 of file cl_console.cpp.

References con, Con_Clear(), con_fontShift, CON_TEXTSIZE, i, and viddef.

Referenced by SCR_DrawConsole().

◆ Con_Clear()

void Con_Clear ( void )
static

Definition at line 79 of file cl_console.cpp.

References con, CON_COLOR_WHITE, i, and lengthof.

Referenced by Con_CheckResize(), and Con_Clear_f().

◆ Con_Clear_f()

void Con_Clear_f ( void )
static

Clears the console buffer.

Definition at line 163 of file cl_console.cpp.

References Con_Clear().

Referenced by Con_Init().

◆ Con_Close()

void Con_Close ( void )

Hide the gameconsole if active.

Definition at line 393 of file cl_console.cpp.

References cls, key_console, key_game, and Key_SetDest().

◆ Con_DrawConsole()

◆ Con_DrawInput()

void Con_DrawInput ( void )
static

The input line scrolls horizontally if typing goes beyond the right edge.

Definition at line 402 of file cl_console.cpp.

References ca_active, CL_Milliseconds(), cls, con, CON_COLOR_WHITE, Con_DrawText(), con_fontHeight, CONSOLE_CHAR_ALIGN, CONSOLE_CURSOR_CHAR, editLine, i, key_console, keyLinePos, keyLines, lengthof, and MAXCMDLINE.

Referenced by Con_DrawConsole().

◆ Con_DrawString()

void Con_DrawString ( const char * txt,
int x,
int y,
unsigned int width )
Parameters
txtThe character buffer to draw
x,yThe coordinates on the screen
widthCharacters to draw

Definition at line 105 of file cl_console.cpp.

References ColorIndex, CON_COLOR_WHITE, Con_DrawText(), lengthof, Q_IsColorString, and Sys_Error().

Referenced by SCR_DrawString().

◆ Con_DrawText()

void Con_DrawText ( const short * text,
int x,
int y,
size_t width )
static
Parameters
textThe character buffer to draw - color encoded
x,yThe coordinates on the screen
widthCharacters to draw

Definition at line 92 of file cl_console.cpp.

References con_fontShift, g_color_table, and R_DrawChar().

Referenced by Con_DrawConsole(), Con_DrawInput(), and Con_DrawString().

◆ Con_Init()

◆ Con_Linefeed()

void Con_Linefeed ( void )
static

Definition at line 301 of file cl_console.cpp.

References con, CON_COLOR_WHITE, and i.

Referenced by Con_Print().

◆ Con_LoadConsoleHistory()

void Con_LoadConsoleHistory ( void )

Load the console history.

See also
Con_SaveConsoleHistory

Definition at line 223 of file cl_console.cpp.

References con_history, CONSOLE_HISTORY_FILENAME, editLine, f, FILE_READ, FS_OpenFile(), historyLine, keyLines, MAXCMDLINE, MAXKEYLINES, and Q_strncpyz().

Referenced by Con_Init().

◆ Con_Print()

void Con_Print ( const char * txt)

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 text will appear at the top of the game window.

See also
Sys_ConsoleOutput

Definition at line 318 of file cl_console.cpp.

References ColorIndex, con, CON_COLOR_WHITE, Con_Linefeed(), len, Q_IsColorString, and UTF8_char_len().

Referenced by Com_vPrintf().

◆ Con_SaveConsoleHistory()

void Con_SaveConsoleHistory ( void )

Stores the console history.

See also
Con_LoadConsoleHistory

Definition at line 250 of file cl_console.cpp.

References Com_Printf(), con_history, CONSOLE_HISTORY_FILENAME, f, FILE_WRITE, FS_OpenFile(), FS_Write(), historyLine, i, keyLines, and MAXCMDLINE.

Referenced by CL_Shutdown().

◆ Con_Scroll()

void Con_Scroll ( int scroll)

Scrolls the console.

Parameters
[in]scrollLines to scroll

Definition at line 172 of file cl_console.cpp.

References con.

Referenced by Key_Console().

◆ Con_ToggleChat_f()

void Con_ToggleChat_f ( void )
static

Definition at line 149 of file cl_console.cpp.

References ca_active, cls, Key_ClearTyping(), key_console, key_game, and Key_SetDest().

Referenced by Con_Init().

◆ Con_ToggleConsole_f()

void Con_ToggleConsole_f ( void )

Definition at line 138 of file cl_console.cpp.

References cls, Key_ClearTyping(), key_console, key_game, and Key_SetDest().

Referenced by Con_Init(), IN_Frame(), and Key_Event().

◆ Key_ClearTyping()

void Key_ClearTyping ( void )
static

Definition at line 132 of file cl_console.cpp.

References editLine, keyLinePos, and keyLines.

Referenced by Con_ToggleChat_f(), and Con_ToggleConsole_f().

Variable Documentation

◆ con

◆ con_background

cvar_t* con_background
static

Definition at line 74 of file cl_console.cpp.

Referenced by Con_DrawConsole(), and Con_Init().

◆ con_fontHeight

const int con_fontHeight = 12

Definition at line 75 of file cl_console.cpp.

Referenced by Con_DrawConsole(), Con_DrawInput(), R_DrawChar(), and SCR_UpdateScreen().

◆ con_fontShift

const int con_fontShift = 3

Definition at line 77 of file cl_console.cpp.

Referenced by Con_CheckResize(), Con_DrawConsole(), and Con_DrawText().

◆ con_fontWidth

const int con_fontWidth = 10

Definition at line 76 of file cl_console.cpp.

Referenced by Con_DrawConsole(), Con_Init(), R_DrawChar(), and SCR_UpdateScreen().

◆ con_history

cvar_t* con_history
static

Definition at line 73 of file cl_console.cpp.

Referenced by Con_Init(), Con_LoadConsoleHistory(), and Con_SaveConsoleHistory().

◆ con_notifytime

cvar_t* con_notifytime
static

Definition at line 72 of file cl_console.cpp.

Referenced by Con_Init().

◆ g_color_table

const uint32_t g_color_table[]
static
Initial value:
=
{
0xFF000000,
0xFF0000FF,
0xFF00FF00,
0xFF00FFFF,
0xFFFF0000,
0xFFFFFF00,
0xFFFF00FF,
0xFFFFFFFF
}

Definition at line 39 of file cl_console.cpp.

Referenced by Con_DrawConsole(), and Con_DrawText().