Skip to content

Commit ef42520

Browse files
committed
ref: Draw_Line; engine: joystick setup menu
1 parent 2e9cecd commit ef42520

File tree

13 files changed

+492
-21
lines changed

13 files changed

+492
-21
lines changed

client/menu.c

+361
Large diffs are not rendered by default.

client/qmenu.c

+47-12
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ void Field_Draw( menufield_s *f )
8888
char tempbuffer[128]="";
8989

9090
if ( f->generic.name )
91-
Menu_DrawStringR2LDark( f->generic.x + f->generic.parent->x + LCOLUMN_OFFSET, f->generic.y + f->generic.parent->y, f->generic.name );
91+
{
92+
if ( f->generic.flags & QMF_INACTIVE )
93+
{
94+
Menu_DrawStringR2L( f->generic.x + f->generic.parent->x + LCOLUMN_OFFSET, f->generic.y + f->generic.parent->y, f->generic.name );
95+
}
96+
else
97+
{
98+
Menu_DrawStringR2LDark( f->generic.x + f->generic.parent->x + LCOLUMN_OFFSET, f->generic.y + f->generic.parent->y, f->generic.name );
99+
}
100+
}
92101

93102
strncpy( tempbuffer, f->buffer + f->visible_offset, f->visible_length );
94103

@@ -298,7 +307,7 @@ void Menu_AdjustCursor( menuframework_s *m, int dir )
298307
{
299308
if ( ( citem = Menu_ItemAtCursor( m ) ) != 0 )
300309
{
301-
if ( citem->type != MTYPE_SEPARATOR )
310+
if ( citem->type != MTYPE_SEPARATOR && !( citem->flags & QMF_INACTIVE ) )
302311
return;
303312
}
304313
}
@@ -313,7 +322,7 @@ void Menu_AdjustCursor( menuframework_s *m, int dir )
313322
{
314323
citem = Menu_ItemAtCursor( m );
315324
if ( citem )
316-
if ( citem->type != MTYPE_SEPARATOR )
325+
if ( citem->type != MTYPE_SEPARATOR && !( citem->flags & QMF_INACTIVE ) )
317326
break;
318327
m->cursor += dir;
319328
if ( m->cursor >= m->nitems )
@@ -326,7 +335,7 @@ void Menu_AdjustCursor( menuframework_s *m, int dir )
326335
{
327336
citem = Menu_ItemAtCursor( m );
328337
if ( citem )
329-
if ( citem->type != MTYPE_SEPARATOR )
338+
if ( citem->type != MTYPE_SEPARATOR && !( citem->flags & QMF_INACTIVE ) )
330339
break;
331340
m->cursor += dir;
332341
if ( m->cursor < 0 )
@@ -572,7 +581,14 @@ void MenuList_Draw( menulist_s *l )
572581
const char **n;
573582
int y = 0;
574583

575-
Menu_DrawStringR2LDark( l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET, l->generic.y + l->generic.parent->y, l->generic.name );
584+
if ( l->generic.flags & QMF_INACTIVE )
585+
{
586+
Menu_DrawStringR2L( l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET, l->generic.y + l->generic.parent->y, l->generic.name );
587+
}
588+
else
589+
{
590+
Menu_DrawStringR2LDark( l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET, l->generic.y + l->generic.parent->y, l->generic.name );
591+
}
576592

577593
n = l->itemnames;
578594

@@ -611,9 +627,18 @@ void Slider_Draw( menuslider_s *s )
611627
{
612628
int i;
613629

614-
Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
615-
s->generic.y + s->generic.parent->y,
616-
s->generic.name );
630+
if ( s->generic.flags & QMF_INACTIVE )
631+
{
632+
Menu_DrawStringR2L( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
633+
s->generic.y + s->generic.parent->y,
634+
s->generic.name );
635+
}
636+
else
637+
{
638+
Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
639+
s->generic.y + s->generic.parent->y,
640+
s->generic.name );
641+
}
617642

618643
s->range = ( s->curvalue - s->minvalue ) / ( float ) ( s->maxvalue - s->minvalue );
619644

@@ -625,7 +650,8 @@ void Slider_Draw( menuslider_s *s )
625650
for ( i = 0; i < SLIDER_RANGE; i++ )
626651
Draw_Char( RCOLUMN_OFFSET + s->generic.x + i*8 + s->generic.parent->x + 8, s->generic.y + s->generic.parent->y, 129);
627652
Draw_Char( RCOLUMN_OFFSET + s->generic.x + i*8 + s->generic.parent->x + 8, s->generic.y + s->generic.parent->y, 130);
628-
Draw_Char( ( int ) ( 8 + RCOLUMN_OFFSET + s->generic.parent->x + s->generic.x + (SLIDER_RANGE-1)*8 * s->range ), s->generic.y + s->generic.parent->y, 131);
653+
if ( !( s->generic.flags & QMF_INACTIVE ) )
654+
Draw_Char( ( int ) ( 8 + RCOLUMN_OFFSET + s->generic.parent->x + s->generic.x + (SLIDER_RANGE-1)*8 * s->range ), s->generic.y + s->generic.parent->y, 131);
629655
}
630656

631657
void SpinControl_DoEnter( menulist_s *s )
@@ -657,9 +683,18 @@ void SpinControl_Draw( menulist_s *s )
657683

658684
if ( s->generic.name )
659685
{
660-
Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
661-
s->generic.y + s->generic.parent->y,
662-
s->generic.name );
686+
if ( s->generic.flags & QMF_INACTIVE )
687+
{
688+
Menu_DrawStringR2L( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
689+
s->generic.y + s->generic.parent->y,
690+
s->generic.name );
691+
}
692+
else
693+
{
694+
Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
695+
s->generic.y + s->generic.parent->y,
696+
s->generic.name );
697+
}
663698
}
664699
if ( !strchr( s->itemnames[s->curvalue], '\n' ) )
665700
{

client/qmenu.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4545
#define QMF_LEFT_JUSTIFY 0x00000001
4646
#define QMF_GRAYED 0x00000002
4747
#define QMF_NUMBERSONLY 0x00000004
48+
#define QMF_INACTIVE 0x00000008
4849

4950
typedef struct _tag_menuframework
5051
{

client/ref.h

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ typedef struct
174174
void (*DrawChar) (int x, int y, int c);
175175
void (*DrawTileClear) (int x, int y, int w, int h, char *name);
176176
void (*DrawFill) (int x, int y, int w, int h, int c);
177+
void (*DrawLine) (int x0, int y0, int x1, int y1, int c);
177178
void (*DrawFadeScreen) (void);
178179

179180
// Draw images for cinematic rendering (which can have a different palette). Note that calls

ref_gl/gl_draw.c

+34
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,40 @@ void Draw_Fill (int x, int y, int w, int h, int c)
279279
qglEnable (GL_TEXTURE_2D);
280280
}
281281

282+
283+
/*
284+
=============
285+
Draw_Line
286+
=============
287+
*/
288+
void Draw_Line (int x0, int y0, int x1, int y1, int c)
289+
{
290+
union
291+
{
292+
unsigned c;
293+
byte v[4];
294+
} color;
295+
296+
if ( (unsigned)c > 255)
297+
ri.Sys_Error (ERR_FATAL, "Draw_Line: bad color");
298+
299+
qglDisable (GL_TEXTURE_2D);
300+
301+
color.c = d_8to24table[c];
302+
qglColor3f (color.v[0]/255.0,
303+
color.v[1]/255.0,
304+
color.v[2]/255.0);
305+
306+
qglBegin (GL_LINES);
307+
308+
qglVertex2f (x0, y0);
309+
qglVertex2f (x1, y1);
310+
311+
qglEnd ();
312+
qglColor3f (1,1,1);
313+
qglEnable (GL_TEXTURE_2D);
314+
}
315+
282316
//=============================================================================
283317

284318
/*

ref_gl/gl_local.h

+1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ void Draw_StretchPic (int x, int y, int w, int h, char *name);
315315
void Draw_Char (int x, int y, int c);
316316
void Draw_TileClear (int x, int y, int w, int h, char *name);
317317
void Draw_Fill (int x, int y, int w, int h, int c);
318+
void Draw_Line (int x0, int y0, int x1, int y1, int c);
318319
void Draw_FadeScreen (void);
319320
void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data);
320321

ref_gl/gl_rmain.c

+1
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ refexport_t GetRefAPI (refimport_t rimp )
16981698
re.DrawChar = Draw_Char;
16991699
re.DrawTileClear = Draw_TileClear;
17001700
re.DrawFill = Draw_Fill;
1701+
re.DrawLine = Draw_Line;
17011702
re.DrawFadeScreen= Draw_FadeScreen;
17021703

17031704
re.DrawStretchRaw = Draw_StretchRaw;

ref_gu/gu_draw.c

+28-9
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,11 @@ Fills a box of pixels with a single color
251251
*/
252252
void Draw_Fill (int x, int y, int w, int h, int c)
253253
{
254-
union
255-
{
256-
unsigned c;
257-
byte v[4];
258-
} color;
259-
260254
if ( (unsigned)c > 255)
261255
ri.Sys_Error (ERR_FATAL, "Draw_Fill: bad color");
262256

263257
sceGuDisable (GU_TEXTURE_2D);
264-
265-
color.c = d_8to24table[c];
266-
sceGuColor (GU_HCOLOR_3UBV(color.v));
258+
sceGuColor (d_8to24table[c]);
267259

268260
gu_vert_hv_t* const out = (gu_vert_hv_t*)sceGuGetMemory (sizeof(gu_vert_hv_t) * 2);
269261
out[0].x = x;
@@ -278,6 +270,33 @@ void Draw_Fill (int x, int y, int w, int h, int c)
278270
sceGuEnable (GU_TEXTURE_2D);
279271
}
280272

273+
274+
/*
275+
=============
276+
Draw_Line
277+
=============
278+
*/
279+
void Draw_Line (int x0, int y0, int x1, int y1, int c)
280+
{
281+
if ( (unsigned)c > 255)
282+
ri.Sys_Error (ERR_FATAL, "Draw_Fill: bad color");
283+
284+
sceGuDisable (GU_TEXTURE_2D);
285+
sceGuColor (d_8to24table[c]);
286+
287+
gu_vert_hv_t* const out = (gu_vert_hv_t*)sceGuGetMemory (sizeof(gu_vert_hv_t) * 2);
288+
out[0].x = x0;
289+
out[0].y = y0;
290+
out[0].z = 0;
291+
out[1].x = x1;
292+
out[1].y = y1;
293+
out[1].z = 0;
294+
sceGuDrawArray (GU_LINES, GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, out);
295+
296+
sceGuColor (GU_HCOLOR_DEFAULT);
297+
sceGuEnable (GU_TEXTURE_2D);
298+
}
299+
281300
//=============================================================================
282301

283302
/*

ref_gu/gu_local.h

+1
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ void Draw_StretchPic (int x, int y, int w, int h, char *name);
336336
void Draw_Char (int x, int y, int c);
337337
void Draw_TileClear (int x, int y, int w, int h, char *name);
338338
void Draw_Fill (int x, int y, int w, int h, int c);
339+
void Draw_Line (int x0, int y0, int x1, int y1, int c);
339340
void Draw_FadeScreen (void);
340341
void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data);
341342

ref_gu/gu_rmain.c

+1
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,7 @@ refexport_t GetRefAPI (refimport_t rimp )
14561456
re.DrawChar = Draw_Char;
14571457
re.DrawTileClear = Draw_TileClear;
14581458
re.DrawFill = Draw_Fill;
1459+
re.DrawLine = Draw_Line;
14591460
re.DrawFadeScreen= Draw_FadeScreen;
14601461

14611462
re.DrawStretchRaw = Draw_StretchRaw;

ref_soft/r_draw.c

+14
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,20 @@ void Draw_Fill (int x, int y, int w, int h, int c)
417417
for (u=0 ; u<w ; u++)
418418
dest[u] = c;
419419
}
420+
421+
422+
/*
423+
=============
424+
Draw_Line
425+
426+
Bresenham's algorithm
427+
=============
428+
*/
429+
void Draw_Line (int x0, int y0, int x1, int y1, int c)
430+
{
431+
432+
}
433+
420434
//=============================================================================
421435

422436
/*

ref_soft/r_local.h

+1
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *d
783783
void Draw_Char (int x, int y, int c);
784784
void Draw_TileClear (int x, int y, int w, int h, char *name);
785785
void Draw_Fill (int x, int y, int w, int h, int c);
786+
void Draw_Line (int x0, int y0, int x1, int y1, int c);
786787
void Draw_FadeScreen (void);
787788

788789
void Draw_GetPalette (void);

ref_soft/r_main.c

+1
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,7 @@ refexport_t GetRefAPI (refimport_t rimp)
13921392
re.DrawChar = Draw_Char;
13931393
re.DrawTileClear = Draw_TileClear;
13941394
re.DrawFill = Draw_Fill;
1395+
re.DrawLine = Draw_Line;
13951396
re.DrawFadeScreen= Draw_FadeScreen;
13961397

13971398
re.DrawStretchRaw = Draw_StretchRaw;

0 commit comments

Comments
 (0)