icculus quake2 doxygen
1.0 dev
qmenu.c
Go to the documentation of this file.
1
/*
2
Copyright (C) 1997-2001 Id Software, Inc.
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13
See the GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19
*/
20
#include <string.h>
21
#include <ctype.h>
22
23
#include "
client.h
"
24
#include "
qmenu.h
"
25
26
static
void
Action_DoEnter
(
menuaction_s
*a );
27
static
void
Action_Draw
(
menuaction_s
*a );
28
static
void
Menu_DrawStatusBar
(
const
char
*
string
);
29
//static void Menulist_DoEnter( menulist_s *l );
30
static
void
MenuList_Draw
(
menulist_s
*l );
31
static
void
Separator_Draw
(
menuseparator_s
*s );
32
static
void
Slider_DoSlide
(
menuslider_s
*s,
int
dir );
33
static
void
Slider_Draw
(
menuslider_s
*s );
34
//static void SpinControl_DoEnter( menulist_s *s );
35
static
void
SpinControl_Draw
(
menulist_s
*s );
36
static
void
SpinControl_DoSlide
(
menulist_s
*s,
int
dir );
37
38
#define RCOLUMN_OFFSET 16
39
#define LCOLUMN_OFFSET -16
40
41
extern
refexport_t
re
;
42
extern
viddef_t
viddef
;
43
44
#define VID_WIDTH viddef.width
45
#define VID_HEIGHT viddef.height
46
47
#ifdef QMAX
48
#define Draw_Char(x,y,z) re.DrawChar((x),(y),(z),1)
49
#else
50
#define Draw_Char re.DrawChar
51
#endif
52
53
#define Draw_Fill re.DrawFill
54
55
void
Action_DoEnter
(
menuaction_s
*a )
56
{
57
if
( a->
generic
.
callback
)
58
a->
generic
.
callback
( a );
59
}
60
61
void
Action_Draw
(
menuaction_s
*a )
62
{
63
if
( a->
generic
.
flags
&
QMF_LEFT_JUSTIFY
)
64
{
65
if
( a->
generic
.
flags
&
QMF_GRAYED
)
66
Menu_DrawStringDark
( a->
generic
.
x
+ a->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
, a->
generic
.
y
+ a->
generic
.
parent
->
y
, a->
generic
.
name
);
67
else
68
Menu_DrawString
( a->
generic
.
x
+ a->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
, a->
generic
.
y
+ a->
generic
.
parent
->
y
, a->
generic
.
name
);
69
}
70
else
71
{
72
if
( a->
generic
.
flags
&
QMF_GRAYED
)
73
Menu_DrawStringR2LDark
( a->
generic
.
x
+ a->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
, a->
generic
.
y
+ a->
generic
.
parent
->
y
, a->
generic
.
name
);
74
else
75
Menu_DrawStringR2L
( a->
generic
.
x
+ a->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
, a->
generic
.
y
+ a->
generic
.
parent
->
y
, a->
generic
.
name
);
76
}
77
if
( a->
generic
.
ownerdraw
)
78
a->
generic
.
ownerdraw
( a );
79
}
80
81
qboolean
Field_DoEnter
(
menufield_s
*f )
82
{
83
if
( f->
generic
.
callback
)
84
{
85
f->
generic
.
callback
( f );
86
return
true
;
87
}
88
return
false
;
89
}
90
91
void
Field_Draw
(
menufield_s
*f )
92
{
93
int
i
;
94
char
tempbuffer[128]=
""
;
95
96
if
( f->
generic
.
name
)
97
Menu_DrawStringR2LDark
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
, f->
generic
.
y
+ f->
generic
.
parent
->
y
, f->
generic
.
name
);
98
99
strncpy( tempbuffer, f->
buffer
+ f->
visible_offset
, f->
visible_length
);
100
101
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ 16, f->
generic
.
y
+ f->
generic
.
parent
->
y
- 4, 18 );
102
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ 16, f->
generic
.
y
+ f->
generic
.
parent
->
y
+ 4, 24 );
103
104
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ 24 + f->
visible_length
* 8, f->
generic
.
y
+ f->
generic
.
parent
->
y
- 4, 20 );
105
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ 24 + f->
visible_length
* 8, f->
generic
.
y
+ f->
generic
.
parent
->
y
+ 4, 26 );
106
107
for
(
i
= 0;
i
< f->
visible_length
;
i
++ )
108
{
109
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ 24 +
i
* 8, f->
generic
.
y
+ f->
generic
.
parent
->
y
- 4, 19 );
110
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ 24 +
i
* 8, f->
generic
.
y
+ f->
generic
.
parent
->
y
+ 4, 25 );
111
}
112
113
Menu_DrawString
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ 24, f->
generic
.
y
+ f->
generic
.
parent
->
y
, tempbuffer );
114
115
if
(
Menu_ItemAtCursor
( f->
generic
.
parent
) == f )
116
{
117
int
offset;
118
119
if
( f->
visible_offset
)
120
offset = f->
visible_length
;
121
else
122
offset = f->
cursor
;
123
124
if
( ( (
int
) (
Sys_Milliseconds
() / 250 ) ) & 1 )
125
{
126
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ ( offset + 2 ) * 8 + 8,
127
f->
generic
.
y
+ f->
generic
.
parent
->
y
,
128
11 );
129
}
130
else
131
{
132
Draw_Char
( f->
generic
.
x
+ f->
generic
.
parent
->
x
+ ( offset + 2 ) * 8 + 8,
133
f->
generic
.
y
+ f->
generic
.
parent
->
y
,
134
' '
);
135
}
136
}
137
}
138
139
qboolean
Field_Key
(
menufield_s
*f,
int
key )
140
{
141
extern
int
keydown
[];
142
143
switch
( key )
144
{
145
case
K_KP_SLASH
:
146
key =
'/'
;
147
break
;
148
case
K_KP_MINUS
:
149
key =
'-'
;
150
break
;
151
case
K_KP_PLUS
:
152
key =
'+'
;
153
break
;
154
case
K_KP_HOME
:
155
key =
'7'
;
156
break
;
157
case
K_KP_UPARROW
:
158
key =
'8'
;
159
break
;
160
case
K_KP_PGUP
:
161
key =
'9'
;
162
break
;
163
case
K_KP_LEFTARROW
:
164
key =
'4'
;
165
break
;
166
case
K_KP_5
:
167
key =
'5'
;
168
break
;
169
case
K_KP_RIGHTARROW
:
170
key =
'6'
;
171
break
;
172
case
K_KP_END
:
173
key =
'1'
;
174
break
;
175
case
K_KP_DOWNARROW
:
176
key =
'2'
;
177
break
;
178
case
K_KP_PGDN
:
179
key =
'3'
;
180
break
;
181
case
K_KP_INS
:
182
key =
'0'
;
183
break
;
184
case
K_KP_DEL
:
185
key =
'.'
;
186
break
;
187
}
188
189
if
( key > 127 )
190
{
191
switch
( key )
192
{
193
case
K_DEL
:
194
default
:
195
return
false
;
196
}
197
}
198
199
/*
200
** support pasting from the clipboard
201
*/
202
if
( ( toupper( key ) ==
'V'
&&
keydown
[
K_CTRL
] ) ||
203
( ( ( key ==
K_INS
) || ( key ==
K_KP_INS
) ) &&
keydown
[
K_SHIFT
] ) )
204
{
205
char
*cbd;
206
207
if
( ( cbd =
Sys_GetClipboardData
() ) != 0 )
208
{
209
strtok( cbd,
"\n\r\b"
);
210
211
strncpy( f->
buffer
, cbd, f->
length
- 1 );
212
f->
cursor
= strlen( f->
buffer
);
213
f->
visible_offset
= f->
cursor
- f->
visible_length
;
214
if
( f->
visible_offset
< 0 )
215
f->
visible_offset
= 0;
216
217
free( cbd );
218
}
219
return
true
;
220
}
221
222
switch
( key )
223
{
224
case
K_KP_LEFTARROW
:
225
case
K_LEFTARROW
:
226
case
K_BACKSPACE
:
227
if
( f->
cursor
> 0 )
228
{
229
memmove( &f->
buffer
[f->
cursor
-1], &f->
buffer
[f->
cursor
], strlen( &f->
buffer
[f->
cursor
] ) + 1 );
230
f->
cursor
--;
231
232
if
( f->
visible_offset
)
233
{
234
f->
visible_offset
--;
235
}
236
}
237
break
;
238
239
case
K_KP_DEL
:
240
case
K_DEL
:
241
memmove( &f->
buffer
[f->
cursor
], &f->
buffer
[f->
cursor
+1], strlen( &f->
buffer
[f->
cursor
+1] ) + 1 );
242
break
;
243
244
case
K_KP_ENTER
:
245
case
K_ENTER
:
246
case
K_ESCAPE
:
247
case
K_TAB
:
248
return
false
;
249
250
case
K_SPACE
:
251
default
:
252
if
( !isdigit( key ) && ( f->
generic
.
flags
&
QMF_NUMBERSONLY
) )
253
return
false
;
254
255
if
( f->
cursor
< f->
length
)
256
{
257
f->
buffer
[f->
cursor
++] = key;
258
f->
buffer
[f->
cursor
] = 0;
259
260
if
( f->
cursor
> f->
visible_length
)
261
{
262
f->
visible_offset
++;
263
}
264
}
265
}
266
267
return
true
;
268
}
269
270
void
Menu_AddItem
(
menuframework_s
*menu,
void
*item )
271
{
272
if
( menu->
nitems
== 0 )
273
menu->
nslots
= 0;
274
275
if
( menu->
nitems
<
MAXMENUITEMS
)
276
{
277
menu->
items
[menu->
nitems
] = item;
278
( (
menucommon_s
* ) menu->
items
[menu->
nitems
] )->parent = menu;
279
menu->
nitems
++;
280
}
281
282
menu->
nslots
=
Menu_TallySlots
( menu );
283
}
284
285
/*
286
** Menu_AdjustCursor
287
**
288
** This function takes the given menu, the direction, and attempts
289
** to adjust the menu's cursor so that it's at the next available
290
** slot.
291
*/
292
void
Menu_AdjustCursor
(
menuframework_s
*m,
int
dir )
293
{
294
menucommon_s
*citem;
295
296
/*
297
** see if it's in a valid spot
298
*/
299
if
( m->
cursor
>= 0 && m->
cursor
< m->
nitems
)
300
{
301
if
( ( citem =
Menu_ItemAtCursor
( m ) ) != 0 )
302
{
303
if
( citem->
type
!=
MTYPE_SEPARATOR
)
304
return
;
305
}
306
}
307
308
/*
309
** it's not in a valid spot, so crawl in the direction indicated until we
310
** find a valid spot
311
*/
312
if
( dir == 1 )
313
{
314
while
( 1 )
315
{
316
citem =
Menu_ItemAtCursor
( m );
317
if
( citem )
318
if
( citem->
type
!=
MTYPE_SEPARATOR
)
319
break
;
320
m->
cursor
+= dir;
321
if
( m->
cursor
>= m->
nitems
)
322
m->
cursor
= 0;
323
}
324
}
325
else
326
{
327
while
( 1 )
328
{
329
citem =
Menu_ItemAtCursor
( m );
330
if
( citem )
331
if
( citem->
type
!=
MTYPE_SEPARATOR
)
332
break
;
333
m->
cursor
+= dir;
334
if
( m->
cursor
< 0 )
335
m->
cursor
= m->
nitems
- 1;
336
}
337
}
338
}
339
340
void
Menu_Center
(
menuframework_s
*menu )
341
{
342
int
height
;
343
344
height
= ( (
menucommon_s
* ) menu->
items
[menu->
nitems
-1])->y;
345
height
+= 10;
346
347
menu->
y
= (
VID_HEIGHT
-
height
) / 2;
348
}
349
350
void
Menu_Draw
(
menuframework_s
*menu )
351
{
352
int
i
;
353
menucommon_s
*item;
354
355
/*
356
** draw contents
357
*/
358
for
(
i
= 0;
i
< menu->
nitems
;
i
++ )
359
{
360
switch
( ( (
menucommon_s
* ) menu->
items
[
i
] )->type )
361
{
362
case
MTYPE_FIELD
:
363
Field_Draw
( (
menufield_s
* ) menu->
items
[
i
] );
364
break
;
365
case
MTYPE_SLIDER
:
366
Slider_Draw
( (
menuslider_s
* ) menu->
items
[
i
] );
367
break
;
368
case
MTYPE_LIST
:
369
MenuList_Draw
( (
menulist_s
* ) menu->
items
[
i
] );
370
break
;
371
case
MTYPE_SPINCONTROL
:
372
SpinControl_Draw
( (
menulist_s
* ) menu->
items
[
i
] );
373
break
;
374
case
MTYPE_ACTION
:
375
Action_Draw
( (
menuaction_s
* ) menu->
items
[
i
] );
376
break
;
377
case
MTYPE_SEPARATOR
:
378
Separator_Draw
( (
menuseparator_s
* ) menu->
items
[
i
] );
379
break
;
380
}
381
}
382
383
item =
Menu_ItemAtCursor
( menu );
384
385
if
( item && item->
cursordraw
)
386
{
387
item->
cursordraw
( item );
388
}
389
else
if
( menu->
cursordraw
)
390
{
391
menu->
cursordraw
( menu );
392
}
393
else
if
( item && item->
type
!=
MTYPE_FIELD
)
394
{
395
if
( item->
flags
&
QMF_LEFT_JUSTIFY
)
396
{
397
Draw_Char
( menu->
x
+ item->
x
- 24 + item->
cursor_offset
, menu->
y
+ item->
y
, 12 + ( (
int
) (
Sys_Milliseconds
()/250 ) & 1 ) );
398
}
399
else
400
{
401
Draw_Char
( menu->
x
+ item->
cursor_offset
, menu->
y
+ item->
y
, 12 + ( (
int
) (
Sys_Milliseconds
()/250 ) & 1 ) );
402
}
403
}
404
405
if
( item )
406
{
407
if
( item->
statusbarfunc
)
408
item->
statusbarfunc
( (
void
* ) item );
409
else
if
( item->statusbar )
410
Menu_DrawStatusBar
( item->statusbar );
411
else
412
Menu_DrawStatusBar
( menu->
statusbar
);
413
414
}
415
else
416
{
417
Menu_DrawStatusBar
( menu->
statusbar
);
418
}
419
}
420
421
void
Menu_DrawStatusBar
(
const
char
*
string
)
422
{
423
if
(
string
)
424
{
425
int
l = strlen(
string
);
426
int
maxcol =
VID_WIDTH
/ 8;
427
int
col = maxcol / 2 - l / 2;
428
429
Draw_Fill
( 0,
VID_HEIGHT
-8,
VID_WIDTH
, 8, 4 );
430
Menu_DrawString
( col*8,
VID_HEIGHT
- 8,
string
);
431
}
432
else
433
{
434
Draw_Fill
( 0,
VID_HEIGHT
-8,
VID_WIDTH
, 8, 0 );
435
}
436
}
437
438
void
Menu_DrawString
(
int
x
,
int
y
,
const
char
*
string
)
439
{
440
unsigned
i
;
441
442
for
(
i
= 0;
i
< strlen(
string
);
i
++ )
443
{
444
Draw_Char
( (
x
+
i
*8 ),
y
,
string
[
i
] );
445
}
446
}
447
448
void
Menu_DrawStringDark
(
int
x
,
int
y
,
const
char
*
string
)
449
{
450
unsigned
i
;
451
452
for
(
i
= 0;
i
< strlen(
string
);
i
++ )
453
{
454
Draw_Char
( (
x
+
i
*8 ),
y
,
string
[
i
] + 128 );
455
}
456
}
457
458
void
Menu_DrawStringR2L
(
int
x
,
int
y
,
const
char
*
string
)
459
{
460
unsigned
i
;
461
462
for
(
i
= 0;
i
< strlen(
string
);
i
++ )
463
{
464
Draw_Char
( (
x
-
i
*8 ),
y
,
string
[strlen(
string
)-
i
-1] );
465
}
466
}
467
468
void
Menu_DrawStringR2LDark
(
int
x
,
int
y
,
const
char
*
string
)
469
{
470
unsigned
i
;
471
472
for
(
i
= 0;
i
< strlen(
string
);
i
++ )
473
{
474
Draw_Char
( (
x
-
i
*8 ),
y
,
string
[strlen(
string
)-
i
-1]+128 );
475
}
476
}
477
478
void
*
Menu_ItemAtCursor
(
menuframework_s
*m )
479
{
480
if
( m->
cursor
< 0 || m->
cursor
>= m->
nitems
)
481
return
0;
482
483
return
m->
items
[m->
cursor
];
484
}
485
486
qboolean
Menu_SelectItem
(
menuframework_s
*s )
487
{
488
menucommon_s
*item = (
menucommon_s
* )
Menu_ItemAtCursor
( s );
489
490
if
( item )
491
{
492
switch
( item->
type
)
493
{
494
case
MTYPE_FIELD
:
495
return
Field_DoEnter
( (
menufield_s
* ) item ) ;
496
case
MTYPE_ACTION
:
497
Action_DoEnter
( (
menuaction_s
* ) item );
498
return
true
;
499
case
MTYPE_LIST
:
500
// Menulist_DoEnter( ( menulist_s * ) item );
501
return
false
;
502
case
MTYPE_SPINCONTROL
:
503
// SpinControl_DoEnter( ( menulist_s * ) item );
504
return
false
;
505
}
506
}
507
return
false
;
508
}
509
510
void
Menu_SetStatusBar
(
menuframework_s
*m,
const
char
*
string
)
511
{
512
m->
statusbar
= string;
513
}
514
515
void
Menu_SlideItem
(
menuframework_s
*s,
int
dir )
516
{
517
menucommon_s
*item = (
menucommon_s
* )
Menu_ItemAtCursor
( s );
518
519
if
( item )
520
{
521
switch
( item->
type
)
522
{
523
case
MTYPE_SLIDER
:
524
Slider_DoSlide
( (
menuslider_s
* ) item, dir );
525
break
;
526
case
MTYPE_SPINCONTROL
:
527
SpinControl_DoSlide
( (
menulist_s
* ) item, dir );
528
break
;
529
}
530
}
531
}
532
533
int
Menu_TallySlots
(
menuframework_s
*menu )
534
{
535
int
i
;
536
int
total = 0;
537
538
for
(
i
= 0;
i
< menu->
nitems
;
i
++ )
539
{
540
if
( ( (
menucommon_s
* ) menu->
items
[
i
] )->type ==
MTYPE_LIST
)
541
{
542
int
nitems = 0;
543
const
char
**n = ( (
menulist_s
* ) menu->
items
[
i
] )->itemnames;
544
545
while
(*n)
546
nitems++, n++;
547
548
total += nitems;
549
}
550
else
551
{
552
total++;
553
}
554
}
555
556
return
total;
557
}
558
559
#if 0 // unused
560
void
Menulist_DoEnter(
menulist_s
*l )
561
{
562
int
start;
563
564
start = l->
generic
.
y
/ 10 + 1;
565
566
l->
curvalue
= l->
generic
.
parent
->
cursor
- start;
567
568
if
( l->
generic
.
callback
)
569
l->
generic
.
callback
( l );
570
}
571
#endif
572
573
void
MenuList_Draw
(
menulist_s
*l )
574
{
575
const
char
**n;
576
int
y
= 0;
577
578
Menu_DrawStringR2LDark
( l->
generic
.
x
+ l->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
, l->
generic
.
y
+ l->
generic
.
parent
->
y
, l->
generic
.
name
);
579
580
n = l->
itemnames
;
581
582
Draw_Fill
( l->
generic
.
x
- 112 + l->
generic
.
parent
->
x
, l->
generic
.
parent
->
y
+ l->
generic
.
y
+ l->
curvalue
*10 + 10, 128, 10, 16 );
583
while
( *n )
584
{
585
Menu_DrawStringR2LDark
( l->
generic
.
x
+ l->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
, l->
generic
.
y
+ l->
generic
.
parent
->
y
+
y
+ 10, *n );
586
587
n++;
588
y
+= 10;
589
}
590
}
591
592
void
Separator_Draw
(
menuseparator_s
*s )
593
{
594
if
( s->
generic
.
name
)
595
Menu_DrawStringR2LDark
( s->
generic
.
x
+ s->
generic
.
parent
->
x
, s->
generic
.
y
+ s->
generic
.
parent
->
y
, s->
generic
.
name
);
596
}
597
598
void
Slider_DoSlide
(
menuslider_s
*s,
int
dir )
599
{
600
s->
curvalue
+= dir;
601
602
if
( s->
curvalue
> s->
maxvalue
)
603
s->
curvalue
= s->
maxvalue
;
604
else
if
( s->
curvalue
< s->
minvalue
)
605
s->
curvalue
= s->
minvalue
;
606
607
if
( s->
generic
.
callback
)
608
s->
generic
.
callback
( s );
609
}
610
611
#define SLIDER_RANGE 10
612
613
void
Slider_Draw
(
menuslider_s
*s )
614
{
615
int
i
;
616
617
Menu_DrawStringR2LDark
( s->
generic
.
x
+ s->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
,
618
s->
generic
.
y
+ s->
generic
.
parent
->
y
,
619
s->
generic
.
name
);
620
621
s->
range
= ( s->
curvalue
- s->
minvalue
) / (
float
) ( s->
maxvalue
- s->
minvalue
);
622
623
if
( s->
range
< 0)
624
s->
range
= 0;
625
if
( s->
range
> 1)
626
s->
range
= 1;
627
Draw_Char
( s->
generic
.
x
+ s->
generic
.
parent
->
x
+
RCOLUMN_OFFSET
, s->
generic
.
y
+ s->
generic
.
parent
->
y
, 128);
628
for
(
i
= 0;
i
<
SLIDER_RANGE
;
i
++ )
629
Draw_Char
(
RCOLUMN_OFFSET
+ s->
generic
.
x
+
i
*8 + s->
generic
.
parent
->
x
+ 8, s->
generic
.
y
+ s->
generic
.
parent
->
y
, 129);
630
Draw_Char
(
RCOLUMN_OFFSET
+ s->
generic
.
x
+
i
*8 + s->
generic
.
parent
->
x
+ 8, s->
generic
.
y
+ s->
generic
.
parent
->
y
, 130);
631
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);
632
}
633
634
#if 0 // unused
635
void
SpinControl_DoEnter(
menulist_s
*s )
636
{
637
s->
curvalue
++;
638
if
( s->
itemnames
[s->
curvalue
] == 0 )
639
s->
curvalue
= 0;
640
641
if
( s->
generic
.
callback
)
642
s->
generic
.
callback
( s );
643
}
644
#endif
645
646
void
SpinControl_DoSlide
(
menulist_s
*s,
int
dir )
647
{
648
s->
curvalue
+= dir;
649
650
if
( s->
curvalue
< 0 )
651
s->
curvalue
= 0;
652
else
if
( s->
itemnames
[s->
curvalue
] == 0 )
653
s->
curvalue
--;
654
655
if
( s->
generic
.
callback
)
656
s->
generic
.
callback
( s );
657
}
658
659
void
SpinControl_Draw
(
menulist_s
*s )
660
{
661
char
buffer
[100];
662
663
if
( s->
generic
.
name
)
664
{
665
Menu_DrawStringR2LDark
( s->
generic
.
x
+ s->
generic
.
parent
->
x
+
LCOLUMN_OFFSET
,
666
s->
generic
.
y
+ s->
generic
.
parent
->
y
,
667
s->
generic
.
name
);
668
}
669
if
( !strchr( s->
itemnames
[s->
curvalue
],
'\n'
) )
670
{
671
Menu_DrawString
(
RCOLUMN_OFFSET
+ s->
generic
.
x
+ s->
generic
.
parent
->
x
, s->
generic
.
y
+ s->
generic
.
parent
->
y
, s->
itemnames
[s->
curvalue
] );
672
}
673
else
674
{
675
strcpy(
buffer
, s->
itemnames
[s->
curvalue
] );
676
*strchr(
buffer
,
'\n'
) = 0;
677
Menu_DrawString
(
RCOLUMN_OFFSET
+ s->
generic
.
x
+ s->
generic
.
parent
->
x
, s->
generic
.
y
+ s->
generic
.
parent
->
y
,
buffer
);
678
strcpy(
buffer
, strchr( s->
itemnames
[s->
curvalue
],
'\n'
) + 1 );
679
Menu_DrawString
(
RCOLUMN_OFFSET
+ s->
generic
.
x
+ s->
generic
.
parent
->
x
, s->
generic
.
y
+ s->
generic
.
parent
->
y
+ 10,
buffer
);
680
}
681
}
682
K_KP_PLUS
@ K_KP_PLUS
Definition:
keys.h:74
menucommon_s::cursordraw
void(* cursordraw)(void *self)
Definition:
qmenu.h:79
keydown
qboolean keydown[K_LAST]
Definition:
keys.c:44
menuseparator_s
Definition:
qmenu.h:118
height
GLsizei height
Definition:
qgl_win.c:69
menufield_s::visible_offset
int visible_offset
Definition:
qmenu.h:90
RCOLUMN_OFFSET
#define RCOLUMN_OFFSET
Definition:
qmenu.c:38
K_KP_UPARROW
@ K_KP_UPARROW
Definition:
keys.h:61
Draw_Char
#define Draw_Char
Definition:
qmenu.c:50
Field_DoEnter
qboolean Field_DoEnter(menufield_s *f)
Definition:
qmenu.c:81
_tag_menuframework::items
void * items[64]
Definition:
qmenu.h:56
VID_WIDTH
#define VID_WIDTH
Definition:
qmenu.c:44
menufield_s::generic
menucommon_s generic
Definition:
qmenu.h:84
menufield_s::visible_length
int visible_length
Definition:
qmenu.h:89
K_KP_PGDN
@ K_KP_PGDN
Definition:
keys.h:68
menucommon_s::type
int type
Definition:
qmenu.h:66
_tag_menuframework::y
int y
Definition:
qmenu.h:51
menuslider_s::generic
menucommon_s generic
Definition:
qmenu.h:95
menufield_s::length
int length
Definition:
qmenu.h:88
MAXMENUITEMS
#define MAXMENUITEMS
Definition:
qmenu.h:23
SpinControl_Draw
static void SpinControl_Draw(menulist_s *s)
Definition:
qmenu.c:659
qboolean
qboolean
Definition:
q_shared.h:56
x
GLint GLenum GLint x
Definition:
qgl_win.c:116
i
int i
Definition:
q_shared.c:305
K_KP_LEFTARROW
@ K_KP_LEFTARROW
Definition:
keys.h:63
menucommon_s::flags
unsigned flags
Definition:
qmenu.h:72
MenuList_Draw
static void MenuList_Draw(menulist_s *l)
Definition:
qmenu.c:573
menucommon_s::x
int x
Definition:
qmenu.h:68
menuslider_s::range
float range
Definition:
qmenu.h:101
buffer
GLenum GLfloat * buffer
Definition:
qgl_win.c:151
QMF_LEFT_JUSTIFY
#define QMF_LEFT_JUSTIFY
Definition:
qmenu.h:45
_tag_menuframework::statusbar
const char * statusbar
Definition:
qmenu.h:58
menucommon_s::ownerdraw
void(* ownerdraw)(void *self)
Definition:
qmenu.h:78
menuaction_s::generic
menucommon_s generic
Definition:
qmenu.h:115
Menu_DrawStringR2L
void Menu_DrawStringR2L(int x, int y, const char *string)
Definition:
qmenu.c:458
Menu_DrawStringDark
void Menu_DrawStringDark(int x, int y, const char *string)
Definition:
qmenu.c:448
Menu_Center
void Menu_Center(menuframework_s *menu)
Definition:
qmenu.c:340
viddef_t
Definition:
vid.h:27
K_KP_HOME
@ K_KP_HOME
Definition:
keys.h:60
qmenu.h
K_ENTER
@ K_ENTER
Definition:
keys.h:26
viddef
viddef_t viddef
Definition:
vid_dll.c:49
QMF_GRAYED
#define QMF_GRAYED
Definition:
qmenu.h:46
menuslider_s::minvalue
float minvalue
Definition:
qmenu.h:97
K_KP_INS
@ K_KP_INS
Definition:
keys.h:70
Menu_DrawStringR2LDark
void Menu_DrawStringR2LDark(int x, int y, const char *string)
Definition:
qmenu.c:468
Menu_DrawString
void Menu_DrawString(int x, int y, const char *string)
Definition:
qmenu.c:438
K_LEFTARROW
@ K_LEFTARROW
Definition:
keys.h:35
K_KP_MINUS
@ K_KP_MINUS
Definition:
keys.h:73
menufield_s::cursor
int cursor
Definition:
qmenu.h:87
K_ESCAPE
@ K_ESCAPE
Definition:
keys.h:27
Action_DoEnter
static void Action_DoEnter(menuaction_s *a)
Definition:
qmenu.c:55
Menu_Draw
void Menu_Draw(menuframework_s *menu)
Definition:
qmenu.c:350
Draw_Fill
#define Draw_Fill
Definition:
qmenu.c:53
menucommon_s::y
int y
Definition:
qmenu.h:68
menucommon_s
Definition:
qmenu.h:64
menulist_s
Definition:
qmenu.h:104
MTYPE_LIST
#define MTYPE_LIST
Definition:
qmenu.h:26
Menu_ItemAtCursor
void * Menu_ItemAtCursor(menuframework_s *m)
Definition:
qmenu.c:478
Menu_SelectItem
qboolean Menu_SelectItem(menuframework_s *s)
Definition:
qmenu.c:486
Menu_AdjustCursor
void Menu_AdjustCursor(menuframework_s *m, int dir)
Definition:
qmenu.c:292
K_KP_RIGHTARROW
@ K_KP_RIGHTARROW
Definition:
keys.h:65
menucommon_s::callback
void(* callback)(void *self)
Definition:
qmenu.h:76
menuslider_s::maxvalue
float maxvalue
Definition:
qmenu.h:98
refexport_t
Definition:
ref.h:151
re
refexport_t re
Definition:
vid_dll.c:31
_tag_menuframework::cursordraw
void(* cursordraw)(struct _tag_menuframework *m)
Definition:
qmenu.h:60
_tag_menuframework::cursor
int cursor
Definition:
qmenu.h:52
K_INS
@ K_INS
Definition:
keys.h:53
menucommon_s::cursor_offset
int cursor_offset
Definition:
qmenu.h:70
K_CTRL
@ K_CTRL
Definition:
keys.h:39
VID_HEIGHT
#define VID_HEIGHT
Definition:
qmenu.c:45
K_KP_END
@ K_KP_END
Definition:
keys.h:66
MTYPE_ACTION
#define MTYPE_ACTION
Definition:
qmenu.h:27
menuaction_s
Definition:
qmenu.h:113
Slider_DoSlide
static void Slider_DoSlide(menuslider_s *s, int dir)
Definition:
qmenu.c:598
K_KP_ENTER
@ K_KP_ENTER
Definition:
keys.h:69
SLIDER_RANGE
#define SLIDER_RANGE
Definition:
qmenu.c:611
_tag_menuframework
Definition:
qmenu.h:49
_tag_menuframework::nitems
int nitems
Definition:
qmenu.h:54
menulist_s::curvalue
int curvalue
Definition:
qmenu.h:108
K_KP_DEL
@ K_KP_DEL
Definition:
keys.h:71
y
GLint y
Definition:
qgl_win.c:115
SpinControl_DoSlide
static void SpinControl_DoSlide(menulist_s *s, int dir)
Definition:
qmenu.c:646
MTYPE_SLIDER
#define MTYPE_SLIDER
Definition:
qmenu.h:25
Menu_DrawStatusBar
static void Menu_DrawStatusBar(const char *string)
Definition:
qmenu.c:421
Menu_SetStatusBar
void Menu_SetStatusBar(menuframework_s *m, const char *string)
Definition:
qmenu.c:510
Field_Draw
void Field_Draw(menufield_s *f)
Definition:
qmenu.c:91
LCOLUMN_OFFSET
#define LCOLUMN_OFFSET
Definition:
qmenu.c:39
_tag_menuframework::x
int x
Definition:
qmenu.h:51
menuslider_s::curvalue
float curvalue
Definition:
qmenu.h:99
menucommon_s::statusbarfunc
void(* statusbarfunc)(void *self)
Definition:
qmenu.h:77
menuslider_s
Definition:
qmenu.h:93
menucommon_s::name
const char * name
Definition:
qmenu.h:67
K_KP_SLASH
@ K_KP_SLASH
Definition:
keys.h:72
K_TAB
@ K_TAB
Definition:
keys.h:25
menufield_s
Definition:
qmenu.h:82
Field_Key
qboolean Field_Key(menufield_s *f, int key)
Definition:
qmenu.c:139
menulist_s::itemnames
const char ** itemnames
Definition:
qmenu.h:110
MTYPE_SPINCONTROL
#define MTYPE_SPINCONTROL
Definition:
qmenu.h:28
K_SHIFT
@ K_SHIFT
Definition:
keys.h:40
K_SPACE
@ K_SPACE
Definition:
keys.h:28
K_KP_5
@ K_KP_5
Definition:
keys.h:64
K_KP_PGUP
@ K_KP_PGUP
Definition:
keys.h:62
_tag_menuframework::nslots
int nslots
Definition:
qmenu.h:55
Menu_SlideItem
void Menu_SlideItem(menuframework_s *s, int dir)
Definition:
qmenu.c:515
MTYPE_FIELD
#define MTYPE_FIELD
Definition:
qmenu.h:30
Separator_Draw
static void Separator_Draw(menuseparator_s *s)
Definition:
qmenu.c:592
menuseparator_s::generic
menucommon_s generic
Definition:
qmenu.h:120
Sys_Milliseconds
int Sys_Milliseconds(void)
Definition:
q_shwin.c:120
K_DEL
@ K_DEL
Definition:
keys.h:54
menulist_s::generic
menucommon_s generic
Definition:
qmenu.h:106
Menu_TallySlots
int Menu_TallySlots(menuframework_s *menu)
Definition:
qmenu.c:533
MTYPE_SEPARATOR
#define MTYPE_SEPARATOR
Definition:
qmenu.h:29
Menu_AddItem
void Menu_AddItem(menuframework_s *menu, void *item)
Definition:
qmenu.c:270
Sys_GetClipboardData
char * Sys_GetClipboardData(void)
Definition:
sys_win.c:401
menucommon_s::parent
menuframework_s * parent
Definition:
qmenu.h:69
K_BACKSPACE
@ K_BACKSPACE
Definition:
keys.h:32
K_KP_DOWNARROW
@ K_KP_DOWNARROW
Definition:
keys.h:67
menufield_s::buffer
char buffer[80]
Definition:
qmenu.h:86
client.h
QMF_NUMBERSONLY
#define QMF_NUMBERSONLY
Definition:
qmenu.h:47
Action_Draw
static void Action_Draw(menuaction_s *a)
Definition:
qmenu.c:61
Slider_Draw
static void Slider_Draw(menuslider_s *s)
Definition:
qmenu.c:613
src
client
qmenu.c
Generated by
1.8.17