-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathmenu_options.c
1375 lines (1159 loc) · 45.9 KB
/
menu_options.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 2011 ezQuake team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Options Menu module
Uses Ctrl_Tab and Settings modules
Naming convention:
function mask | usage | purpose
--------------|----------|-----------------------------
Menu_Opt_* | external | interface for menu.c
CT_Opt_* | external | interface for Ctrl_Tab.c
made by:
johnnycz, Jan 2006
*/
#include "quakedef.h"
#include "settings.h"
#include "settings_page.h"
#include "Ctrl_EditBox.h"
#include "vx_stuff.h"
#include "vx_tracker.h"
#include "gl_model.h"
#include "gl_local.h"
#include "tr_types.h"
#include "teamplay.h"
#include "EX_FileList.h"
#include "Ctrl.h"
#include "Ctrl_Tab.h"
#include "input.h"
#include "qsound.h"
#include "menu.h"
#include "keys.h"
#include "hud.h"
#include "hud_common.h"
typedef enum {
OPTPG_MISC,
OPTPG_PLAYER,
OPTPG_FPS,
OPTPG_HUD,
OPTPG_DEMO_SPEC,
OPTPG_BINDS,
OPTPG_SYSTEM,
OPTPG_CONFIG,
} options_tab_t;
CTab_t options_tab;
int options_unichar; // variable local to this module
extern cvar_t scr_scaleMenu;
extern int menuwidth;
extern int menuheight;
extern qbool m_entersound; // todo - put into menu.h
void M_Menu_Help_f (void); // todo - put into menu.h
extern cvar_t scr_scaleMenu;
qbool OnMenuAdvancedChange(cvar_t*, char*);
cvar_t menu_advanced = {"menu_advanced", "0"};
//=============================================================================
// <SETTINGS>
enum {mode_fastest, mode_faithful, mode_higheyecandy, mode_eyecandy, mode_undef} fps_mode = mode_undef;
extern cvar_t scr_fov, scr_newHud, cl_staticsounds, r_fullbrightSkins, cl_deadbodyfilter, cl_muzzleflash, r_fullbright;
extern cvar_t scr_sshot_format;
void ResetConfigs_f(void);
static qbool AlwaysRun(void) { return cl_forwardspeed.value > 200; }
const char* AlwaysRunRead(void) { return AlwaysRun() ? "on" : "off"; }
void AlwaysRunToggle(qbool back) {
if (AlwaysRun()) {
Cvar_SetValue (&cl_forwardspeed, 200);
Cvar_SetValue (&cl_backspeed, 200);
Cvar_SetValue (&cl_sidespeed, 200);
} else {
Cvar_SetValue (&cl_forwardspeed, 400);
Cvar_SetValue (&cl_backspeed, 400);
Cvar_SetValue (&cl_sidespeed, 400);
}
}
static qbool InvertMouse(void) { return m_pitch.value < 0; }
const char* InvertMouseRead(void) { return InvertMouse() ? "on" : "off"; }
void InvertMouseToggle(qbool back) { Cvar_SetValue(&m_pitch, -m_pitch.value); }
static qbool AutoSW(void) { return (w_switch.value > 2) || (!w_switch.value) || (b_switch.value > 2) || (!b_switch.value); }
const char* AutoSWRead(void) { return AutoSW() ? "on" : "off"; }
void AutoSWToggle(qbool back) {
if (AutoSW()) {
Cvar_SetValue (&w_switch, 1);
Cvar_SetValue (&b_switch, 1);
} else {
Cvar_SetValue (&w_switch, 8);
Cvar_SetValue (&b_switch, 8);
}
}
static int GFXPreset(void) {
if (fps_mode == mode_undef) {
switch ((int) cl_deadbodyfilter.value) {
case 0: fps_mode = mode_eyecandy; break;
case 1: fps_mode = cl_muzzleflash.value ? mode_faithful : mode_eyecandy; break;
default: fps_mode = mode_fastest; break;
}
}
return fps_mode;
}
const char* GFXPresetRead(void) {
switch (GFXPreset()) {
case mode_fastest: return "fastest";
case mode_higheyecandy: return "high eyecandy";
case mode_faithful: return "faithful";
default: return "eyecandy";
}
}
void GFXPresetToggle(qbool back) {
if (back) fps_mode--; else fps_mode++;
if (fps_mode < 0) fps_mode = mode_undef - 1;
if (fps_mode >= mode_undef) fps_mode = 0;
switch (GFXPreset()) {
case mode_fastest: Cbuf_AddText ("exec cfg/gfx_gl_fast.cfg\n"); return;
case mode_higheyecandy: Cbuf_AddText ("exec cfg/gfx_gl_higheyecandy.cfg\n"); return;
case mode_faithful: Cbuf_AddText ("exec cfg/gfx_gl_faithful.cfg\n"); return;
case mode_eyecandy: Cbuf_AddText ("exec cfg/gfx_gl_eyecandy.cfg\n"); return;
}
}
const char* amf_tracker_frags_enum[] = {"off", "related", "all" };
const char* mvdautohud_enum[] = { "off", "simple", "customizable" };
const char* mvdautotrack_enum[] = { "off", "auto", "custom", "multitrack", "simple" };
const char* funcharsmode_enum[] = { "ctrl+key", "ctrl+y" };
const char* ignoreopponents_enum[] = { "off", "always", "on match" };
const char* msgfilter_enum[] = { "off", "say+spec", "team", "say+team+spec" };
const char* allowscripts_enum[] = { "off", "simple", "all" };
const char* scrautoid_enum[] = { "off", "nick", "health+armor", "health+armor+type", "all (rl)", "all (best gun)" };
const char* coloredtext_enum[] = { "off", "simple", "frag messages" };
const char* autorecord_enum[] = { "off", "don't save", "auto save" };
const char* hud_enum[] = { "classic", "new", "combined" };
const char* ignorespec_enum[] = { "off", "on (as player)", "on (always)" };
const char* gender_enum[] = { "Male", "m", "Female", "f", "Neutral", "n", "Not specified", "" };
const char* scr_sshot_format_enum[] = {
"JPG", "jpg", "PNG", "png", "TGA", "tga" };
extern cvar_t mvd_autotrack, mvd_moreinfo, mvd_status, cl_weaponpreselect, cl_weaponhide, con_funchars_mode, con_notifytime, scr_consize, ignore_opponents, _con_notifylines,
ignore_qizmo_spec, ignore_spec, msg_filter, crosshair, crosshairsize, cl_smartjump, scr_coloredText,
cl_rollangle, cl_rollspeed, v_gunkick, v_kickpitch, v_kickroll, v_kicktime, v_viewheight, match_auto_sshot, match_auto_record, match_auto_logconsole,
r_fastturb, r_grenadetrail, cl_drawgun, r_viewmodelsize, r_viewmodeloffset, scr_clock, scr_gameclock, show_fps, rate, cl_c2sImpulseBackup,
name, team, skin, topcolor, bottomcolor, cl_teamtopcolor, cl_teambottomcolor, cl_teamquadskin, cl_teampentskin, cl_teambothskin, /*cl_enemytopcolor, cl_enemybottomcolor, */
cl_enemyquadskin, cl_enemypentskin, cl_enemybothskin, demo_dir, qizmo_dir, qwdtools_dir, cl_fakename, cl_fakename_suffix,
cl_chatsound, con_sound_mm1_volume, con_sound_mm2_volume, con_sound_spec_volume, con_sound_other_volume, s_khz, s_desiredsamples,
ruleset, scr_sshot_dir, log_dir, cl_nolerp, cl_confirmquit, log_readable, ignore_flood, ignore_flood_duration, con_timestamps, scr_consize, scr_conspeed, cl_chatmode, cl_chasecam,
enemyforceskins, teamforceskins, vid_vsync_lag_fix, cl_sayfilter_coloredtext, cl_sayfilter_sendboth,
mvd_autotrack_lockteam, qtv_adjustbuffer, cl_earlypackets, cl_useimagesinfraglog, con_completion_format, menu_ingame, sys_inactivesound
;
#ifdef _WIN32
extern cvar_t demo_format, sys_highpriority, cl_window_caption, vid_flashonactivity;
void CL_RegisterQWURLProtocol_f(void);
#endif
extern cvar_t scr_autoid, gl_crosshairalpha, gl_smoothfont, amf_hidenails, amf_hiderockets, gl_anisotropy, gl_lumaTextures, gl_textureless, gl_colorlights, scr_conalpha, scr_conback, gl_clear, gl_powerupshells, gl_powerupshells_size,
scr_teaminfo
;
void CL_Autotrack_f(void);
const char* bandwidth_enum[] = {
"Modem (33k)", "3800", "Modem (56k)", "5670",
"ISDN (112k)", "9856", "Cable (128k)", "14336",
"ADSL (> 256k)", "30000" };
const char* cl_c2sImpulseBackup_enum[] = {
"Perfect", "0", "Low", "2", "Medium", "4",
"High", "6" };
const char* ignore_flood_enum[] = {
"Off", "0", "say/spec", "1", "say/say_team/spec", "2" };
#ifdef _WIN32
const char* demoformat_enum[] = { "QuakeWorld Demo", "qwd", "Qizmo compressed QWD", "qwz", "MultiViewDemo", "mvd" };
#endif
const char* cl_chatmode_enum[] = {
"All Commands", "All Chat", "First Word" };
const char* con_completion_format_enum[] = {
"Old", "New:Current+Default", "New:Current", "New:Default", "New:Current+Default,if changed", "New:Without values"
};
const char* scr_conback_enum[] = {
"Off", "On Load", "Always", };
const char* s_khz_enum[] = {
"11 kHz", "11", "22 kHz", "22", "44 kHz", "44"
#if defined(__linux__) || defined(__FreeBSD__)
,"48 kHz", "48"
#endif
};
const char* s_desired_samples_enum[] = {
"(default)", "0", "128", "128", "256", "256", "512", "512", "1024", "1024"
};
const char* cl_nolerp_enum[] = {"on", "off"};
const char* ruleset_enum[] = { "ezQuake default", "default", "Smackdown", "smackdown", "Thunderdome", "thunderdome", "Moscow TF League", "mtfl", "QuakeCon", "qcon" };
const char *mediaroot_enum[] = { "relative to exe", "relative to home", "full path" };
const char *teamforceskins_enum[] = { "off", "use player's name", "use player's userid", "set t1, t2, t3, ..." };
const char *enemyforceskins_enum[] = { "off", "use player's name", "use player's userid", "set e1, e2, e3, ..." };
#ifdef _WIN32
const char *priority_enum[] = { "low", "-1", "normal", "0", "high", "1" };
#endif
void DefaultConfig(void) { Cbuf_AddText("cfg_reset full\n"); }
settings_page settmisc;
void CT_Opt_Settings_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page) {
Settings_Draw(x, y, w, h, &settmisc);
}
int CT_Opt_Settings_Key (int k, wchar unichar, CTab_t *tab, CTabPage_t *page) {
return Settings_Key(&settmisc, k, unichar);
}
void OnShow_SettMain(void) { Settings_OnShow(&settmisc); }
qbool CT_Opt_Settings_Mouse_Event(const mouse_state_t *ms)
{
return Settings_Mouse_Event(&settmisc, ms);
}
// </SETTINGS>
//=============================================================================
settings_page settview;
void CT_Opt_View_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page) {
Settings_Draw(x, y, w, h, &settview);
}
int CT_Opt_View_Key (int k, wchar unichar, CTab_t *tab, CTabPage_t *page) {
return Settings_Key(&settview, k, unichar);
}
void OnShow_SettView(void) { Settings_OnShow(&settview); }
qbool CT_Opt_View_Mouse_Event(const mouse_state_t *ms)
{
return Settings_Mouse_Event(&settview, ms);
}
settings_page settplayer;
void CT_Opt_Player_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page) {
Settings_Draw(x, y, w, h, &settplayer);
}
int CT_Opt_Player_Key (int k, wchar unichar, CTab_t *tab, CTabPage_t *page) {
return Settings_Key(&settplayer, k, unichar);
}
void OnShow_SettPlayer(void) { Settings_OnShow(&settplayer); }
qbool CT_Opt_Player_Mouse_Event(const mouse_state_t *ms)
{
return Settings_Mouse_Event(&settplayer, ms);
}
//=============================================================================
// <BINDS>
extern cvar_t in_raw, in_m_smooth, m_rate, in_m_os_parameters;
const char* in_raw_enum[] = { "off", "on" };
const char* in_m_os_parameters_enum[] = { "off", "Keep accel settings", "Keep speed settings", "Keep all settings" };
void Menu_Input_Restart(void) { Cbuf_AddText("in_restart\n"); }
settings_page settbinds;
void CT_Opt_Binds_Draw (int x2, int y2, int w, int h, CTab_t *tab, CTabPage_t *page) {
Settings_Draw(x2, y2, w, h, &settbinds);
}
int CT_Opt_Binds_Key (int k, wchar unichar, CTab_t *tab, CTabPage_t *page) {
return Settings_Key(&settbinds, k, unichar);
}
void OnShow_SettBinds(void) { Settings_OnShow(&settbinds); }
qbool CT_Opt_Binds_Mouse_Event(const mouse_state_t *ms)
{
return Settings_Mouse_Event(&settbinds, ms);
}
// </BINDS>
//=============================================================================
//=============================================================================
// <FPS>
extern cvar_t v_bonusflash;
extern cvar_t cl_rocket2grenade;
extern cvar_t v_damagecshift;
extern cvar_t r_fastsky;
extern cvar_t r_drawflame;
extern cvar_t gl_simpleitems;
extern cvar_t gl_simpleitems_orientation;
extern cvar_t gl_part_inferno;
extern cvar_t amf_lightning;
extern cvar_t r_drawflat;
const char* explosiontype_enum[] =
{ "fire + sparks", "fire only", "teleport", "blood", "big blood", "dbl gunshot", "blob effect", "big explosion", "plasma", "sparks", "off" };
const char* muzzleflashes_enum[] =
{ "off", "on", "own off" };
const char* simpleitemsorientation_enum[] =
{"Parallel upright", "Facing upright", "Parallel", "Oriented"};
const char* deadbodyfilter_enum[] =
{ "off", "fast", "instant", "DM off, TF on" };
const char* rocketmodel_enum[] =
{ "rocket", "grenade" };
const char* rockettrail_enum[] =
{ "off", "normal", "grenade", "alt normal", "slight blood", "big blood", "tracer 1", "tracer 2", "plasma", "lavaball", "fuel rod", "plasma 2", "alt normal 2", "motion trail" };
const char* powerupglow_enum[] =
{ "off", "on", "own off" };
const char* grenadetrail_enum[] =
{ "off", "normal", "grenade", "alt normal", "slight blood", "big blood", "tracer 1", "tracer 2", "plasma", "lavaball", "fuel rod", "plasma 2", "alt normal 2", "motion trail" };
extern cvar_t cl_maxfps;
const char* FpslimitRead(void) {
switch ((int) cl_maxfps.value) {
case 0: return "no limit";
case 72: return "72 (old std)";
case 77: return "77 (standard)";
default: return "custom";
}
}
void FpslimitToggle(qbool back) {
if (back) {
switch ((int) cl_maxfps.value) {
case 0: Cvar_SetValue(&cl_maxfps, 77); return;
case 72: Cvar_SetValue(&cl_maxfps, 0); return;
case 77: Cvar_SetValue(&cl_maxfps, 72); return;
}
} else {
switch ((int) cl_maxfps.value) {
case 0: Cvar_SetValue(&cl_maxfps, 72); return;
case 72: Cvar_SetValue(&cl_maxfps, 77); return;
case 77: Cvar_SetValue(&cl_maxfps, 0); return;
}
}
}
const char* gl_max_size_enum[] = {
"low", "1", "medium", "8", "high", "256", "max", "2048"
};
extern cvar_t gl_texturemode;
const char* gl_texturemode_enum[] = {
"very low", "GL_NEAREST_MIPMAP_NEAREST",
"low", "GL_LINEAR",
"medium", "GL_LINEAR_MIPMAP_NEAREST",
"high", "GL_LINEAR_MIPMAP_LINEAR",
"very high", "GL_NEAREST"
};
settings_page settfps;
void CT_Opt_FPS_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
{
Settings_Draw(x, y, w, h, &settfps);
}
int CT_Opt_FPS_Key (int k, wchar unichar, CTab_t *tab, CTabPage_t *page) {
return Settings_Key(&settfps, k, unichar);
}
void OnShow_SettFPS(void) { Settings_OnShow(&settfps); }
qbool CT_Opt_FPS_Mouse_Event(const mouse_state_t *ms)
{
return Settings_Mouse_Event(&settfps, ms);
}
// </FPS>
//=============================================================================
//=============================================================================
// <SYSTEM>
// these variables serve as a temporary storage for user selected settings
// they get initialized with current settings when the page is showed
typedef struct menu_video_settings_s {
int res;
int bpp;
qbool usedesktopres;
qbool fullscreen;
} menu_system_settings_t;
qbool mss_askmode = false;
// here we store the configuration that user selected in menu
menu_system_settings_t mss_selected;
// here we store the current video config in case the new video settings weren't successfull
menu_system_settings_t mss_previous;
// will apply given video settings
static void ApplyVideoSettings(const menu_system_settings_t *s)
{
const SDL_DisplayMode *current;
current = VID_GetDisplayMode(s->res);
if (current == NULL) {
return;
}
Cvar_SetValue(&vid_width, current->w);
Cvar_SetValue(&vid_height, current->h);
Cvar_SetValue(&r_displayRefresh,current->refresh_rate);
Cvar_SetValue(&r_colorbits, s->bpp);
Cvar_SetValue(&r_fullscreen, s->fullscreen);
Cbuf_AddText("vid_restart\n");
Com_DPrintf("askmode: %s\n", mss_askmode ? "on" : "off");
}
// will store current video settings into the given structure
static void StoreCurrentVideoSettings(menu_system_settings_t *out)
{
out->usedesktopres = vid_usedesktopres.integer ? true : false;
out->res = VID_GetCurrentModeIndex();
out->bpp = (int) r_colorbits.value;
out->fullscreen = (int) r_fullscreen.value;
}
// performed when user hits the "apply" button
void VideoApplySettings (void)
{
StoreCurrentVideoSettings(&mss_previous);
ApplyVideoSettings(&mss_selected);
mss_askmode = true;
}
// two possible results of the "keep these video settings?" dialogue
static void KeepNewVideoSettings (void) { mss_askmode = false; }
static void CancelNewVideoSettings (void) {
mss_askmode = false;
ApplyVideoSettings(&mss_previous);
}
const char* BitDepthRead(void)
{
return mss_selected.bpp == 32 ? "32 bit" : mss_selected.bpp == 16 ? "16 bit" : "use desktop settings";
}
const char* ResolutionRead(void)
{
static char buf[64];
const SDL_DisplayMode *mode;
mode = VID_GetDisplayMode(mss_selected.res);
if (mode == NULL) {
return "";
}
snprintf(buf, sizeof(buf), "%dx%d@%dHz", mode->w, mode->h, mode->refresh_rate);
return buf;
}
const char* FullScreenRead(void)
{
return mss_selected.fullscreen ? "on" : "off";
}
void ResolutionToggle(qbool back)
{
int count = VID_GetModeIndexCount();
if (back) {
mss_selected.res--;
} else {
mss_selected.res++;
}
mss_selected.res = (mss_selected.res + count) % count;
}
void BitDepthToggle(qbool back) {
if (back) {
switch (mss_selected.bpp) {
case 0: mss_selected.bpp = 32; return;
case 16: mss_selected.bpp = 0; return;
default: mss_selected.bpp = 16; return;
}
} else {
switch (mss_selected.bpp) {
case 0: mss_selected.bpp = 16; return;
case 16: mss_selected.bpp = 32; return;
case 32: mss_selected.bpp = 0; return;
}
}
}
void FullScreenToggle(qbool back) { mss_selected.fullscreen = mss_selected.fullscreen ? 0 : 1; }
settings_page settsystem;
void CT_Opt_System_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
{
#define ASKBOXWIDTH 300
if(mss_askmode)
{
UI_DrawBox((w-ASKBOXWIDTH)/2, h/2 - 16, ASKBOXWIDTH, 32);
UI_Print_Center((w-ASKBOXWIDTH)/2, h/2 - 8, ASKBOXWIDTH, "Do you wish to keep these settings?", false);
UI_Print_Center((w-ASKBOXWIDTH)/2, h/2, ASKBOXWIDTH, "(y/n)", true);
}
else
{
Settings_Draw(x,y,w,h, &settsystem);
}
}
int CT_Opt_System_Key (int key, wchar unichar, CTab_t *tab, CTabPage_t *page)
{
if (mss_askmode)
{
if (key == 'y' || key == K_ENTER)
{
KeepNewVideoSettings();
}
else if(key == 'n' || key == K_ESCAPE)
{
CancelNewVideoSettings();
}
return true;
}
else
{
return Settings_Key(&settsystem, key, unichar);
}
}
void OnShow_SettSystem(void)
{
StoreCurrentVideoSettings(&mss_selected);
Settings_OnShow(&settsystem);
}
qbool CT_Opt_System_Mouse_Event(const mouse_state_t *ms)
{
return Settings_Mouse_Event(&settsystem, ms);
}
// </SYSTEM>
// *********
// <CONFIG>
// Menu Options Config Page Mode
filelist_t configs_filelist;
CEditBox filenameeb;
enum { MOCPM_SETTINGS, MOCPM_CHOOSECONFIG, MOCPM_CHOOSESCRIPT, MOCPM_ENTERFILENAME } MOpt_configpage_mode = MOCPM_SETTINGS;
extern cvar_t cfg_backup, cfg_save_aliases, cfg_save_binds, cfg_save_cmdline,
cfg_save_cmds, cfg_save_cvars, cfg_save_unchanged, cfg_save_userinfo, cfg_use_home, cfg_save_onquit, cfg_use_gamedir, cfg_legacy_exec;
void MOpt_ImportConfig(void) {
MOpt_configpage_mode = MOCPM_CHOOSECONFIG;
// hope few doubled trinary operator won't hurt your brains
if (cfg_use_home.integer)
FL_SetCurrentDir(&configs_filelist, (cfg_use_gamedir.integer) ? va("%s/%s", com_homedir, (strcmp(com_gamedirfile, "qw") == 0) ? "" : com_gamedirfile) : com_homedir);
else
FL_SetCurrentDir(&configs_filelist, (cfg_use_gamedir.integer) ? va("%s/%s/configs", com_basedir, (strcmp(com_gamedirfile, "qw") == 0) ? "ezquake" : com_gamedirfile) : va("%s/ezquake/configs", com_basedir));
}
void MOpt_ExportConfig(void) {
MOpt_configpage_mode = MOCPM_ENTERFILENAME;
filenameeb.text[0] = 0;
filenameeb.pos = 0;
}
void MOpt_LoadScript(void) {
MOpt_configpage_mode = MOCPM_CHOOSESCRIPT;
FL_SetCurrentDir(&configs_filelist, "./ezquake/cfg");
}
void MOpt_CfgSaveAllOn(void) {
S_LocalSound("misc/basekey.wav");
Cvar_SetValue(&cfg_backup, 1);
Cvar_SetValue(&cfg_legacy_exec, 1);
Cvar_SetValue(&cfg_save_aliases, 1);
Cvar_SetValue(&cfg_save_binds, 1);
Cvar_SetValue(&cfg_save_cmdline, 1);
Cvar_SetValue(&cfg_save_cmds, 1);
Cvar_SetValue(&cfg_save_cvars, 1);
Cvar_SetValue(&cfg_save_unchanged, 1);
Cvar_SetValue(&cfg_save_userinfo, 2);
}
const char* MOpt_legacywrite_enum[] = { "off", "non-qw dir frontend.cfg", "also config.cfg", "non-qw config.cfg" };
const char* MOpt_userinfo_enum[] = { "off", "all but player", "all" };
void MOpt_LoadCfg(void) {
S_LocalSound("misc/basekey.wav");
Cbuf_AddText("cfg_load\n");
}
void MOpt_SaveCfg(void) {
S_LocalSound("doors/runeuse.wav");
Cbuf_AddText("cfg_save\n");
}
settings_page settconfig;
#define INPUTBOXWIDTH 300
#define INPUTBOXHEIGHT 48
void MOpt_FilenameInputBoxDraw(int x, int y, int w, int h)
{
UI_DrawBox(x + (w-INPUTBOXWIDTH) / 2, y + (h-INPUTBOXHEIGHT) / 2, INPUTBOXWIDTH, INPUTBOXHEIGHT);
UI_Print_Center(x, y + h/2 - 8, w, "Enter the config file name", false);
CEditBox_Draw(&filenameeb, x + (w-INPUTBOXWIDTH)/2 + 16, y + h/2 + 8, true);
}
qbool MOpt_FileNameInputBoxKey(int key)
{
CEditBox_Key(&filenameeb, key, key);
return true;
}
char *MOpt_FileNameInputBoxGetText(void)
{
return filenameeb.text;
}
void CT_Opt_Config_Draw(int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
{
switch (MOpt_configpage_mode) {
case MOCPM_SETTINGS:
Settings_Draw(x,y,w,h,&settconfig);
break;
case MOCPM_CHOOSESCRIPT:
case MOCPM_CHOOSECONFIG:
FL_Draw(&configs_filelist, x,y,w,h);
break;
case MOCPM_ENTERFILENAME:
MOpt_FilenameInputBoxDraw(x,y,w,h);
break;
}
}
int CT_Opt_Config_Key(int key, wchar unichar, CTab_t *tab, CTabPage_t *page)
{
switch (MOpt_configpage_mode) {
case MOCPM_SETTINGS:
return Settings_Key(&settconfig, key, unichar);
break;
case MOCPM_CHOOSECONFIG:
if (key == K_ENTER || key == K_MOUSE1) {
Cbuf_AddText(va("cfg_load \"%s\"\n", COM_SkipPath(FL_GetCurrentEntry(&configs_filelist)->name)));
MOpt_configpage_mode = MOCPM_SETTINGS;
return true;
} else if (key == K_ESCAPE || key == K_MOUSE2) {
MOpt_configpage_mode = MOCPM_SETTINGS;
return true;
} else return FL_Key(&configs_filelist, key);
case MOCPM_CHOOSESCRIPT:
if (key == K_ENTER || key == K_MOUSE1) {
Cbuf_AddText(va("exec \"cfg/%s\"\n", COM_SkipPath(FL_GetCurrentEntry(&configs_filelist)->name)));
MOpt_configpage_mode = MOCPM_SETTINGS;
return true;
} else if (key == K_ESCAPE || key == K_MOUSE2) {
MOpt_configpage_mode = MOCPM_SETTINGS;
return true;
} else return FL_Key(&configs_filelist, key);
case MOCPM_ENTERFILENAME:
if (key == K_ENTER || key == K_MOUSE1) {
Cbuf_AddText(va("cfg_save \"%s\"\n", MOpt_FileNameInputBoxGetText()));
MOpt_configpage_mode = MOCPM_SETTINGS;
return true;
} else if (key == K_ESCAPE || key == K_MOUSE2) {
MOpt_configpage_mode = MOCPM_SETTINGS;
return true;
} else return MOpt_FileNameInputBoxKey(key);
}
return false;
}
void OnShow_SettConfig(void) { Settings_OnShow(&settconfig); }
qbool CT_Opt_Config_Mouse_Event(const mouse_state_t *ms)
{
if (MOpt_configpage_mode == MOCPM_CHOOSECONFIG || MOpt_configpage_mode == MOCPM_CHOOSESCRIPT) {
if (FL_Mouse_Event(&configs_filelist, ms))
return true;
else if (ms->button_up == 1 || ms->button_up == 2)
return CT_Opt_Config_Key(K_MOUSE1 - 1 + ms->button_up, 0, &options_tab, options_tab.pages + OPTPG_CONFIG);
return true;
}
else
{
return Settings_Mouse_Event(&settconfig, ms);
}
}
// </CONFIG>
// *********
CTabPage_Handlers_t options_misc_handlers = {
CT_Opt_Settings_Draw,
CT_Opt_Settings_Key,
OnShow_SettMain,
CT_Opt_Settings_Mouse_Event
};
CTabPage_Handlers_t options_player_handlers = {
CT_Opt_Player_Draw,
CT_Opt_Player_Key,
OnShow_SettPlayer,
CT_Opt_Player_Mouse_Event
};
CTabPage_Handlers_t options_graphics_handlers = {
CT_Opt_FPS_Draw,
CT_Opt_FPS_Key,
OnShow_SettFPS,
CT_Opt_FPS_Mouse_Event
};
CTabPage_Handlers_t options_view_handlers = {
CT_Opt_View_Draw,
CT_Opt_View_Key,
OnShow_SettView,
CT_Opt_View_Mouse_Event
};
CTabPage_Handlers_t options_controls_handlers = {
CT_Opt_Binds_Draw,
CT_Opt_Binds_Key,
OnShow_SettBinds,
CT_Opt_Binds_Mouse_Event
};
CTabPage_Handlers_t options_system_handlers = {
CT_Opt_System_Draw,
CT_Opt_System_Key,
OnShow_SettSystem,
CT_Opt_System_Mouse_Event
};
CTabPage_Handlers_t options_config_handlers = {
CT_Opt_Config_Draw,
CT_Opt_Config_Key,
OnShow_SettConfig,
CT_Opt_Config_Mouse_Event
};
void Menu_Options_Key(int key, wchar unichar) {
int handled = CTab_Key(&options_tab, key, unichar);
options_unichar = unichar;
if (!handled && (key == K_ESCAPE || key == K_MOUSE2))
M_Menu_Main_f();
}
void Menu_Options_Draw(void) {
int x, y, w, h;
M_Unscale_Menu();
// this will add top, left and bottom padding
// right padding is not added because it causes annoying scrollbar behaviour
// when mouse gets off the scrollbar to the right side of it
w = vid.width - OPTPADDING; // here used to be a limit to 512x... size
h = vid.height - OPTPADDING*2;
x = OPTPADDING;
y = OPTPADDING;
CTab_Draw(&options_tab, x, y, w, h);
}
// PLAYER TAB
setting settplayer_arr[] = {
ADDSET_BOOL ("Advanced Options", menu_advanced),
ADDSET_SEPARATOR("Player Settings"),
ADDSET_STRING ("Name", name),
ADDSET_STRING ("Teamchat Name", cl_fakename),
ADDSET_ADVANCED_SECTION(),
ADDSET_STRING ("Teamchat Name Suffix", cl_fakename_suffix),
ADDSET_BASIC_SECTION(),
ADDSET_ENUM ("Gender", gender, gender_enum),
ADDSET_STRING ("Team", team),
ADDSET_ADVANCED_SECTION(),
ADDSET_SKIN ("Skin", skin),
ADDSET_BASIC_SECTION(),
ADDSET_COLOR ("Shirt Color", topcolor),
ADDSET_COLOR ("Pants Color", bottomcolor),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Fullbright Skins", r_fullbrightSkins),
ADDSET_ENUM ("Ruleset", ruleset, ruleset_enum),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("Weapon Handling"),
ADDSET_CUSTOM ("Gun Autoswitch", AutoSWRead, AutoSWToggle, "Switches to the weapon picked up if it is more powerful than what you're currently holding."),
ADDSET_BOOL ("Gun Preselect", cl_weaponpreselect),
ADDSET_BOOL ("Gun Auto Hide", cl_weaponhide),
ADDSET_SEPARATOR("Movement"),
ADDSET_CUSTOM ("Always Run", AlwaysRunRead, AlwaysRunToggle, "Maximum forward speed at all times."),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Smart Jump", cl_smartjump),
ADDSET_NAMED ("Movement Scripts", allow_scripts, allowscripts_enum),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("Team Skin & Colors"),
ADDSET_COLOR ("Shirt Color", cl_teamtopcolor),
ADDSET_COLOR ("Pants Color", cl_teambottomcolor),
ADDSET_ADVANCED_SECTION(),
ADDSET_SKIN ("Skin", cl_teamskin),
ADDSET_NAMED ("Force Skins", teamforceskins, teamforceskins_enum),
ADDSET_SKIN ("Quad Skin", cl_teamquadskin),
ADDSET_SKIN ("Pent Skin", cl_teampentskin),
ADDSET_SKIN ("Quad+Pent Skin", cl_teambothskin),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("Enemy Skin & Colors"),
ADDSET_COLOR ("Shirt Color", cl_enemytopcolor),
ADDSET_COLOR ("Pants Color", cl_enemybottomcolor),
ADDSET_ADVANCED_SECTION(),
ADDSET_SKIN ("Skin", cl_enemyskin),
ADDSET_NAMED ("Force Skins", enemyforceskins, enemyforceskins_enum),
ADDSET_SKIN ("Quad Skin", cl_enemyquadskin),
ADDSET_SKIN ("Pent Skin", cl_enemypentskin),
ADDSET_SKIN ("Quad+Pent Skin", cl_enemybothskin),
ADDSET_BASIC_SECTION(),
};
// GRAPHICS TAB
setting settfps_arr[] = {
ADDSET_BOOL ("Advanced Options", menu_advanced),
ADDSET_SEPARATOR("Presets"),
ADDSET_CUSTOM ("GFX Preset", GFXPresetRead, GFXPresetToggle, "Select different graphic presets."),
ADDSET_SEPARATOR("Field Of View"),
ADDSET_ADVANCED_SECTION(),
ADDSET_NUMBER("Draw Distance", r_farclip, 4096, 8192, 4096),
ADDSET_BASIC_SECTION(),
ADDSET_NUMBER ("View Size (fov)", scr_fov, 40, 140, 2),
ADDSET_NUMBER ("Screen Size", scr_viewsize, 30, 120, 5),
ADDSET_ADVANCED_SECTION(),
ADDSET_NUMBER ("Rollangle", cl_rollangle, 0, 30, 2),
ADDSET_NUMBER ("Rollspeed", cl_rollspeed, 0, 30, 2),
ADDSET_BOOL ("Gun Kick", v_gunkick),
ADDSET_NUMBER ("Kick Pitch", v_kickpitch, 0, 10, 0.5),
ADDSET_NUMBER ("Kick Roll", v_kickroll, 0, 10, 0.5),
ADDSET_NUMBER ("Kick Time", v_kicktime, 0, 10, 0.5),
ADDSET_NUMBER ("View Height", v_viewheight, -7, 4, 0.5),
ADDSET_BASIC_SECTION(),
ADDSET_ADVANCED_SECTION(),
ADDSET_SEPARATOR("Textures"),
ADDSET_BOOL ("Luma", gl_lumaTextures),
ADDSET_ENUM ("Detail", gl_max_size, gl_max_size_enum),
ADDSET_NUMBER ("Miptex", gl_miptexLevel, 0, 3, 1),
ADDSET_BOOL ("No Textures", gl_textureless),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("Player & Weapon Model"),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Powerup Luma", gl_powerupshells),
ADDSET_NUMBER ("Powerup Luma Size", gl_powerupshells_size, 0, 10, 1),
ADDSET_NUMBER ("Weapon Opacity", cl_drawgun, 0, 1, 0.05),
ADDSET_BASIC_SECTION(),
ADDSET_NUMBER ("Weapon Size", r_viewmodelsize, 0.1, 1, 0.05),
ADDSET_ADVANCED_SECTION(),
ADDSET_NUMBER ("Weapon Shift", r_viewmodeloffset, -10, 10, 1),
ADDSET_NAMED ("Weapon Muzzleflashes", cl_muzzleflash, muzzleflashes_enum),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("Environment"),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Fullbright World", r_fullbright),
ADDSET_BOOL ("Simple Sky", r_fastsky),
ADDSET_BOOL ("Simple Walls", r_drawflat),
ADDSET_BOOL ("Simple Turbs", r_fastturb),
ADDSET_BOOL ("Simple Items", gl_simpleitems),
ADDSET_NAMED ("Simple Items Orientation", gl_simpleitems_orientation, simpleitemsorientation_enum),
ADDSET_BOOL ("Draw Flame", r_drawflame),
ADDSET_BOOL ("Backpack Filter", cl_backpackfilter),
ADDSET_BASIC_SECTION(),
ADDSET_BOOL ("Gib Filter", cl_gibfilter),
ADDSET_ADVANCED_SECTION(),
ADDSET_NAMED ("Dead Body Filter", cl_deadbodyfilter, deadbodyfilter_enum),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("Projectiles"),
ADDSET_NAMED ("Explosion Type", r_explosiontype, explosiontype_enum),
ADDSET_ADVANCED_SECTION(),
ADDSET_NAMED ("Rocket Model", cl_rocket2grenade, rocketmodel_enum),
ADDSET_BASIC_SECTION(),
ADDSET_NAMED ("Rocket Trail", r_rockettrail, rockettrail_enum),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Rocket Light", r_rocketlight),
ADDSET_NAMED ("Grenade Trail", r_grenadetrail, grenadetrail_enum),
ADDSET_BASIC_SECTION(),
ADDSET_NUMBER ("Fakeshaft", cl_fakeshaft, 0, 1, 0.05),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Hide Nails", amf_hidenails),
ADDSET_BOOL ("Hide Rockets", amf_hiderockets),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("Lighting"),
ADDSET_BOOL ("GL Bloom", r_bloom),
ADDSET_NAMED ("Powerup Glow", r_powerupglow, powerupglow_enum),
ADDSET_NUMBER ("Damage Flash", v_damagecshift, 0, 1, 0.1),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Pickup Flash", v_bonusflash),
ADDSET_BASIC_SECTION(),
ADDSET_BOOL ("Colored Lights", gl_colorlights),
ADDSET_BOOL ("Fast Lights", gl_flashblend),
ADDSET_BOOL ("Dynamic Lights", r_dynamic),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOL ("Darken Map", gl_lightmode),
ADDSET_BOOL ("Particle Shaft", amf_lightning),
ADDSET_BASIC_SECTION(),
};
// VIEW TAB
setting settview_arr[] = {
ADDSET_BOOL ("Advanced Options", menu_advanced),
ADDSET_SEPARATOR("Head Up Display"),
ADDSET_NAMED ("HUD Type", scr_newHud, hud_enum),
ADDSET_NUMBER ("Crosshair", crosshair, 0, 7, 1),
ADDSET_NUMBER ("Crosshair Size", crosshairsize, 0.2, 3, 0.2),
ADDSET_ADVANCED_SECTION(),
ADDSET_NUMBER ("Crosshair Alpha", gl_crosshairalpha, 0.1, 1, 0.1),
ADDSET_NAMED ("Overhead Name", scr_autoid, scrautoid_enum),
ADDSET_BASIC_SECTION(),
ADDSET_SEPARATOR("New HUD"),
ADDSET_BOOLLATE ("Gameclock", hud_gameclock_show),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOLLATE ("Big Gameclock", hud_gameclock_big),
ADDSET_BASIC_SECTION(),
ADDSET_BOOL ("Teaminfo Table", scr_teaminfo),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOLLATE ("Own Frags Announcer", hud_ownfrags_show),
ADDSET_BOOLLATE ("Teamholdbar", hud_teamholdbar_show),
ADDSET_BOOLLATE ("Teamholdinfo", hud_teamholdinfo_show),
ADDSET_BOOLLATE ("Clock", hud_clock_show),
ADDSET_BASIC_SECTION(),
ADDSET_BOOLLATE ("FPS", hud_fps_show),
ADDSET_ADVANCED_SECTION(),
ADDSET_BOOLLATE ("Radar", hud_radar_show),
ADDSET_BASIC_SECTION(),