Skip to content

Commit 1f82591

Browse files
committed
Make the console more like Anox's; introduced con_image and con_size vars to adjust the console.
1 parent d000a83 commit 1f82591

File tree

8 files changed

+73
-47
lines changed

8 files changed

+73
-47
lines changed

engine/client/cl_scrn.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ void SCR_DrawDebugGraph( void )
156156

157157
x = scr_vrect.x;
158158
y = scr_vrect.y + scr_vrect.height;
159-
Draw_Fill( x, y - scr_graphheight->value,
160-
w, scr_graphheight->value, 8 );
159+
Draw_Fill( x, y - scr_graphheight->value, w, scr_graphheight->value, chr::ColourF32( 0.0f, 0.0f, 0.0f, 1.0f ) );
161160

162161
for ( a = 0; a < w; a++ )
163162
{
@@ -169,7 +168,7 @@ void SCR_DrawDebugGraph( void )
169168
if ( v < 0 )
170169
v += scr_graphheight->value * ( 1 + ( int ) ( -v / scr_graphheight->value ) );
171170
h = ( int ) v % ( int ) scr_graphheight->value;
172-
Draw_Fill( x + w - 1 - a, y - h, 1, h, color );
171+
Draw_Fill( x + w - 1 - a, y - h, 1, h, chr::ColourF32( Q_BYTE_TO_FLOAT( color ), 1.0f, 1.0f, 1.0f ) );
173172
}
174173
}
175174

@@ -527,20 +526,20 @@ void SCR_DrawConsole( void )
527526

528527
if ( cls.state == ca_disconnected || cls.state == ca_connecting )
529528
{// forced full screen console
530-
Con_DrawConsole( 1.0 );
529+
Con_DrawConsole();
531530
return;
532531
}
533532

534533
if ( cls.state != ca_active || !cl.refresh_prepped )
535534
{// connected, but can't render
536-
Con_DrawConsole( 0.5 );
537-
Draw_Fill( 0, viddef.height / 2, viddef.width, viddef.height / 2, 0 );
535+
Con_DrawConsole();
536+
Draw_Fill( 0, viddef.height / 2, viddef.width, viddef.height / 2, chr::COLOURF32_BLACK );
538537
return;
539538
}
540539

541540
if ( scr_con_current )
542541
{
543-
Con_DrawConsole( scr_con_current );
542+
Con_DrawConsole();
544543
}
545544
else
546545
{
@@ -777,10 +776,11 @@ void SCR_TileClear( void )
777776
#define STAT_MINUS 10// num frame for '-' stats digit
778777
static const char *sb_nums[ 2 ][ 11 ] =
779778
{
780-
{ "num0", "num1", "num2", "num3", "num4", "num5",
781-
"num6", "num7", "num8", "num9", "white" },
782-
{ "num0", "num1", "num2", "num3", "num4", "num5",
783-
"num6", "num7", "num8", "num9", "white" } };
779+
{"num0", "num1", "num2", "num3", "num4", "num5",
780+
"num6", "num7", "num8", "num9", "white"},
781+
{"num0", "num1", "num2", "num3", "num4", "num5",
782+
"num6", "num7", "num8", "num9", "white"}
783+
};
784784

785785
#define ICON_WIDTH 24
786786
#define ICON_HEIGHT 24

engine/client/console.cpp

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2525

2626
console_t con;
2727

28-
cvar_t *con_notifytime;
28+
static cvar_t *con_notifytime;
29+
static cvar_t *con_image;
30+
static cvar_t *con_size;
2931

3032
#define MAXCMDLINE 256
3133
extern char key_lines[ 32 ][ MAXCMDLINE ];
@@ -102,7 +104,7 @@ void Con_ToggleConsole_f( void )
102104
Con_ToggleChat_f
103105
================
104106
*/
105-
void Con_ToggleChat_f( void )
107+
static void Con_ToggleChat_f()
106108
{
107109
Key_ClearTyping();
108110

@@ -125,7 +127,7 @@ void Con_ToggleChat_f( void )
125127
Con_Clear_f
126128
================
127129
*/
128-
void Con_Clear_f( void ) { memset( con.text, ' ', CON_TEXTSIZE ); }
130+
void Con_Clear_f() { memset( con.text, ' ', CON_TEXTSIZE ); }
129131

130132
/*
131133
================
@@ -134,7 +136,7 @@ Con_Dump_f
134136
Save the console contents out to a file
135137
================
136138
*/
137-
void Con_Dump_f( void )
139+
void Con_Dump_f()
138140
{
139141
int l, x;
140142
char *line;
@@ -194,7 +196,7 @@ void Con_Dump_f( void )
194196
Con_ClearNotify
195197
================
196198
*/
197-
void Con_ClearNotify( void )
199+
void Con_ClearNotify()
198200
{
199201
int i;
200202

@@ -206,7 +208,7 @@ void Con_ClearNotify( void )
206208
Con_MessageMode_f
207209
================
208210
*/
209-
void Con_MessageMode_f( void )
211+
void Con_MessageMode_f()
210212
{
211213
chat_team = false;
212214
cls.key_dest = key_message;
@@ -217,7 +219,7 @@ void Con_MessageMode_f( void )
217219
Con_MessageMode2_f
218220
================
219221
*/
220-
void Con_MessageMode2_f( void )
222+
void Con_MessageMode2_f()
221223
{
222224
chat_team = true;
223225
cls.key_dest = key_message;
@@ -230,7 +232,7 @@ Con_CheckResize
230232
If the line width has changed, reformat the buffer.
231233
================
232234
*/
233-
void Con_CheckResize( void )
235+
void Con_CheckResize()
234236
{
235237
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
236238
char tbuf[ CON_TEXTSIZE ];
@@ -297,7 +299,9 @@ void Con_Init( void )
297299
//
298300
// register our commands
299301
//
300-
con_notifytime = Cvar_Get( "con_notifytime", "3", 0 );
302+
con_notifytime = Cvar_Get( "con_notifytime", "3", CVAR_ARCHIVE );
303+
con_image = Cvar_Get( "con_image", "", CVAR_ARCHIVE );
304+
con_size = Cvar_Get( "con_size", "0.8", CVAR_ARCHIVE );
301305

302306
Cmd_AddCommand( "toggleconsole", Con_ToggleConsole_f );
303307
Cmd_AddCommand( "togglechat", Con_ToggleChat_f );
@@ -527,23 +531,30 @@ Con_DrawConsole
527531
Draws the console with the solid background
528532
================
529533
*/
530-
void Con_DrawConsole( float frac )
534+
void Con_DrawConsole()
531535
{
532536
int i, j, x, y, n;
533537
int rows;
534538
char *text;
535539
int row;
536-
int lines;
537-
char dlbar[ 1024 ];
538540

539-
lines = viddef.height * frac;
541+
float frac = ( cls.state == ca_disconnected || cls.state == ca_connecting ) ? 1.0f : con_size->value;
542+
543+
int lines = viddef.height * frac;
540544
if ( lines <= 0 ) return;
541545

542546
if ( lines > viddef.height ) lines = viddef.height;
543547

544548
// draw the background
545-
Draw_StretchPic( 0, -viddef.height + lines, viddef.width, viddef.height,
546-
"conback" );
549+
if ( *con_image->string != '\0' )
550+
{
551+
Draw_StretchPic( 0, -viddef.height + lines, viddef.width, viddef.height, con_image->string );
552+
}
553+
else
554+
{
555+
Draw_Fill( 0, -viddef.height + lines, viddef.width, viddef.height, chr::ColourF32( 0.0f, 0.0f, 0.0f, 0.5f ) );
556+
}
557+
547558
SCR_AddDirtyPoint( 0, 0 );
548559
SCR_AddDirtyPoint( viddef.width - 1, lines - 1 );
549560

@@ -595,7 +606,8 @@ void Con_DrawConsole( float frac )
595606
// figure out width
596607
if ( cls.download )
597608
{
598-
if ( ( text = strrchr( cls.downloadname, '/' ) ) != NULL )
609+
char dlbar[ 1024 ];
610+
if ( ( text = strrchr( cls.downloadname, '/' ) ) != nullptr )
599611
text++;
600612
else
601613
text = cls.downloadname;

engine/client/console.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void Con_DrawCharacter( int cx, int line, int num );
5353

5454
void Con_CheckResize( void );
5555
void Con_Init( void );
56-
void Con_DrawConsole( float frac );
56+
void Con_DrawConsole();
5757
void Con_Print( char *txt );
5858
void Con_CenteredPrint( char *text );
5959
void Con_Clear_f( void );

engine/client/menu.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ void M_Menu_Credits_f( void )
15211521
}
15221522
else
15231523
{
1524-
credits = idcredits;
1524+
credits = idcredits;
15251525
}
15261526

15271527
credits_start_time = cls.realtime;
@@ -2271,7 +2271,7 @@ void StartServer_MenuInit( void )
22712271
/*
22722272
** maxclients determines the maximum number of players that can join
22732273
** the game. If maxclients is only "1" then we should default the menu
2274-
** option to 8 players, otherwise use whatever its current value is.
2274+
** option to 8 players, otherwise use whatever its current value is.
22752275
** Clamping will be done when the server is actually started.
22762276
*/
22772277
s_maxclients_field.generic.type = MTYPE_FIELD;
@@ -3510,6 +3510,7 @@ M_Draw
35103510
*/
35113511
void M_Draw( void )
35123512
{
3513+
#if 0
35133514
if ( cls.key_dest != key_menu )
35143515
return;
35153516

@@ -3532,6 +3533,9 @@ void M_Draw( void )
35323533
S_StartLocalSound( menu_in_sound );
35333534
m_entersound = false;
35343535
}
3536+
#else
3537+
# pragma message "TODO"
3538+
#endif
35353539
}
35363540

35373541

engine/client/qmenu.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ void Menu_Draw( menuframework_s *menu )
410410

411411
void Menu_DrawStatusBar( const char *string )
412412
{
413+
#if 0
413414
if ( string )
414415
{
415416
int l = strlen( string );
@@ -424,6 +425,9 @@ void Menu_DrawStatusBar( const char *string )
424425
{
425426
Draw_Fill( 0, VID_HEIGHT - 8, VID_WIDTH, 8, 0 );
426427
}
428+
#else
429+
# pragma message "TODO"
430+
#endif
427431
}
428432

429433
void Menu_DrawString( int x, int y, const char *string )
@@ -531,7 +535,7 @@ int Menu_TallySlots( menuframework_s *menu )
531535
if ( ( ( menucommon_s * ) menu->items[ i ] )->type == MTYPE_LIST )
532536
{
533537
int nitems = 0;
534-
const char **n = ( ( menulist_s *) menu->items[ i ] )->itemnames;
538+
const char **n = ( ( menulist_s * ) menu->items[ i ] )->itemnames;
535539

536540
while ( *n )
537541
nitems++, n++;
@@ -549,6 +553,7 @@ int Menu_TallySlots( menuframework_s *menu )
549553

550554
void MenuList_Draw( menulist_s *l )
551555
{
556+
#if 0
552557
const char **n;
553558
int y = 0;
554559

@@ -564,6 +569,9 @@ void MenuList_Draw( menulist_s *l )
564569
n++;
565570
y += 10;
566571
}
572+
#else
573+
# pragma message "TODO"
574+
#endif
567575
}
568576

569577
void Separator_Draw( menuseparator_s *s )

engine/renderer/ref_gl/gl_draw.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -248,37 +248,36 @@ Draw_Fill
248248
Fills a box of pixels with a single color
249249
=============
250250
*/
251-
void Draw_Fill( int x, int y, int w, int h, int c )
251+
void Draw_Fill( int x, int y, int w, int h, const chr::ColourF32 &c )
252252
{
253-
union
253+
if ( c.a <= 0.0f )
254254
{
255-
unsigned c{ 0 };
256-
byte v[ 4 ];
257-
} color;
255+
return;
256+
}
258257

259-
if ( ( unsigned ) c > 255 )
258+
if ( c.a != 1.0f )
260259
{
261-
Com_Error( ERR_FATAL, "Draw_Fill: bad color" );
262-
return;
260+
glEnable( GL_BLEND );
263261
}
264262

265263
glDisable( GL_TEXTURE_2D );
266264

267-
color.c = d_8to24table[ c ];
268-
glColor3f( color.v[ 0 ] / 255.0,
269-
color.v[ 1 ] / 255.0,
270-
color.v[ 2 ] / 255.0 );
265+
glColor4fv( ( float * ) &c );
271266

272267
glBegin( GL_QUADS );
273-
274268
glVertex2f( x, y );
275269
glVertex2f( x + w, y );
276270
glVertex2f( x + w, y + h );
277271
glVertex2f( x, y + h );
278-
279272
glEnd();
280-
glColor3f( 1, 1, 1 );
273+
274+
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
281275
glEnable( GL_TEXTURE_2D );
276+
277+
if ( c.a != 1.0f )
278+
{
279+
glDisable( GL_BLEND );
280+
}
282281
}
283282

284283
//=============================================================================

engine/renderer/ref_gl/gl_local.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void Draw_Pic( int x, int y, const char *name );
180180
void Draw_StretchPic( int x, int y, int w, int h, const char *name );
181181
void Draw_Char( int x, int y, int c );
182182
void Draw_TileClear( int x, int y, int w, int h, const char *name );
183-
void Draw_Fill( int x, int y, int w, int h, int c );
183+
void Draw_Fill( int x, int y, int w, int h, const chr::ColourF32 &c );
184184
void Draw_FadeScreen( void );
185185
void Draw_StretchRaw( int x, int y, int w, int h, int cols, int rows,
186186
byte *data );

game/q_shared.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ namespace chr
149149
float r, g, b, a;
150150
};
151151

152+
static constexpr ColourF32 COLOURF32_WHITE = { 1.0f, 1.0f, 1.0f, 1.0f };
153+
static constexpr ColourF32 COLOURF32_BLACK = { 0.0f, 0.0f, 0.0f, 1.0f };
154+
152155
static inline ColourF32 ConvertColourU8ToColourF32( const ColourU8 &src )
153156
{
154157
return ( ColourF32 ) {

0 commit comments

Comments
 (0)