UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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"

Go to the source code of this file.

Data Structures

struct  console_t
 

Macros

#define ColorIndex(c)   (((c) - '0') & 0x07)
 
#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. More...
 
void Con_Scroll (int scroll)
 Scrolls the console. More...
 
void Con_CheckResize (void)
 If the line width has changed, reformat the buffer. More...
 
void Con_LoadConsoleHistory (void)
 Load the console history. More...
 
void Con_SaveConsoleHistory (void)
 Stores the console history. More...
 
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. More...
 
void Con_Close (void)
 Hide the gameconsole if active. More...
 
static void Con_DrawInput (void)
 The input line scrolls horizontally if typing goes beyond the right edge. More...
 
void Con_DrawConsole (float frac)
 Draws the console with the solid background. More...
 

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

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

Definition at line 36 of file cl_console.cpp.

Referenced by Con_DrawString(), and Con_Print().

#define CON_TEXTSIZE   32768

Definition at line 53 of file cl_console.cpp.

Referenced by Con_CheckResize().

#define CONSOLE_CHAR_ALIGN   4

Definition at line 51 of file cl_console.cpp.

Referenced by Con_DrawConsole(), and Con_DrawInput().

#define CONSOLE_CURSOR_CHAR   11

Definition at line 54 of file cl_console.cpp.

Referenced by Con_DrawInput().

#define CONSOLE_HISTORY_FILENAME   "history"

Definition at line 55 of file cl_console.cpp.

Referenced by Con_LoadConsoleHistory(), and Con_SaveConsoleHistory().

#define NUM_CON_TIMES   8

Definition at line 52 of file cl_console.cpp.

Function Documentation

void Con_CheckResize ( void  )
static void Con_Clear ( void  )
static

Definition at line 79 of file cl_console.cpp.

References CON_COLOR_WHITE, i, lengthof, and console_t::text.

Referenced by Con_CheckResize(), and Con_Clear_f().

static 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().

void Con_Close ( void  )

Hide the gameconsole if active.

Definition at line 393 of file cl_console.cpp.

References cls, key_console, key_game, Key_SetDest(), and client_static_s::keyDest.

static void Con_DrawInput ( void  )
static
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().

static 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().

static void Con_Linefeed ( void  )
static
void Con_LoadConsoleHistory ( 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.

See also
Sys_ConsoleOutput

Definition at line 318 of file cl_console.cpp.

References ColorIndex, CON_COLOR_WHITE, Con_Linefeed(), console_t::currentLine, console_t::initialized, len, console_t::lineWidth, console_t::pos, Q_IsColorString, console_t::text, console_t::totalLines, and UTF8_char_len().

Referenced by Com_vPrintf().

void Con_SaveConsoleHistory ( void  )
void Con_Scroll ( int  scroll)

Scrolls the console.

Parameters
[in]scrollLines to scroll

Definition at line 172 of file cl_console.cpp.

References console_t::currentLine, and console_t::displayLine.

Referenced by Key_Console().

static void Con_ToggleChat_f ( void  )
static
void Con_ToggleConsole_f ( void  )
static 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

console_t con
static

Definition at line 71 of file cl_console.cpp.

cvar_t* con_background
static

Definition at line 74 of file cl_console.cpp.

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().

const int con_fontShift = 3

Definition at line 77 of file cl_console.cpp.

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

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().

cvar_t* con_history
static

Definition at line 73 of file cl_console.cpp.

cvar_t* con_notifytime
static

Definition at line 72 of file cl_console.cpp.

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().