]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c
new weapon arena menu controls, enjoy! Original code by MirceaKitsune
[divverent/nexuiz.git] / data / qcsrc / menu / nexuiz / dialog_multiplayer_create_mutators.c
1 #ifdef INTERFACE
2 CLASS(NexuizMutatorsDialog) EXTENDS(NexuizDialog)
3         METHOD(NexuizMutatorsDialog, toString, string(entity))
4         METHOD(NexuizMutatorsDialog, fill, void(entity))
5         METHOD(NexuizMutatorsDialog, showNotify, void(entity))
6         METHOD(NexuizMutatorsDialog, close, void(entity))
7         ATTRIB(NexuizMutatorsDialog, title, string, "Mutators")
8         ATTRIB(NexuizMutatorsDialog, color, vector, SKINCOLOR_DIALOG_MUTATORS)
9         ATTRIB(NexuizMutatorsDialog, intendedWidth, float, 0.8)
10         ATTRIB(NexuizMutatorsDialog, rows, float, 16)
11         ATTRIB(NexuizMutatorsDialog, columns, float, 6)
12         ATTRIB(NexuizMutatorsDialog, refilterEntity, entity, NULL)
13 ENDCLASS(NexuizMutatorsDialog)
14 #endif
15
16 #ifdef IMPLEMENTATION
17 void showNotifyNexuizMutatorsDialog(entity me)
18 {
19         loadAllCvars(me);
20 }
21
22 string weaponarenastring;
23 string weaponarenastring_cvar;
24 string WeaponArenaString()
25 {
26         string s;
27         float n, i, j;
28         entity e;
29         s = cvar_string("g_weaponarena");
30         if(s == "0")
31                 return "";
32         if(s == "all")
33                 return "All Weapons Arena";
34         if(s == "most")
35                 return "Most Weapons Arena";
36         if(s == weaponarenastring_cvar)
37                 return weaponarenastring;
38         if(weaponarenastring)
39                 strunzone(weaponarenastring);
40         if(weaponarenastring_cvar)
41                 strunzone(weaponarenastring_cvar);
42
43         weaponarenastring_cvar = strzone(s);
44
45         n = tokenize_sane(s);
46         s = "";
47         for(i = 0; i < n; ++i)
48         {
49                 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
50                 {
51                         e = get_weaponinfo(j);
52                         if(argv(i) == e.netname)
53                                 s = strcat(s, " & ", e.message);
54                 }
55         }
56         s = strcat(substring(s, 3, strlen(s) - 3), " Arena");
57         
58         weaponarenastring = strzone(s);
59
60         return weaponarenastring;
61 }
62
63 string toStringNexuizMutatorsDialog(entity me)
64 {
65         string s;
66         s = "";
67         if(cvar("g_minstagib"))
68                 s = strcat(s, ", MinstaGib");
69         if(cvar("g_nixnex"))
70                 s = strcat(s, ", NixNex");
71         if(cvar_string("g_weaponarena") != "0")
72                 s = strcat(s, ", ", WeaponArenaString());
73         if(cvar("sv_gravity") < 800)
74                 s = strcat(s, ", Low gravity");
75         if(cvar("g_cloaked"))
76                 s = strcat(s, ", Cloaked");
77         if(cvar("g_footsteps"))
78                 s = strcat(s, ", Steps");
79         if(cvar("g_grappling_hook"))
80                 s = strcat(s, ", Hook");
81         if(cvar("g_laserguided_missile"))
82                 s = strcat(s, ", LG missiles");
83         if(cvar("g_midair"))
84                 s = strcat(s, ", Midair");
85         if(cvar("g_vampire"))
86                 s = strcat(s, ", Vampire");
87         if(s == "")
88                 return "None";
89         else
90                 return substring(s, 2, strlen(s) - 2);
91 }
92 void fillNexuizMutatorsDialog(entity me)
93 {
94         entity e, s, w;
95         float i, j;
96         string str, hstr;
97         me.TR(me);
98                 me.TD(me, 1, 2, makeNexuizTextLabel(0, "Game mutators:"));
99         me.TR(me);
100                 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_cloaked", "Cloaked"));
101         me.TR(me);
102                 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_footsteps", "Footsteps"));
103         me.TR(me);
104                 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_grappling_hook", "Grappling hook"));
105         me.TR(me);
106                 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_laserguided_missile", "Laser guided missiles"));
107         me.TR(me);
108                 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_midair", "Midair"));
109         me.TR(me);
110                 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_vampire", "Vampire"));
111
112         me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
113                 me.TD(me, 1, 4, makeNexuizTextLabel(0, "Weapon arenas:"));
114         me.TR(me);
115                 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, string_null, string_null, "Regular (no arena)"));
116         for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i, ++j)
117         {
118                 w = get_weaponinfo(i);
119                 if(j & 1 == 0)
120                         me.TR(me);
121                 str = w.netname;
122                 hstr = w.message;
123                 if not(w.spawnflags & WEPSPAWNFLAG_CANCLIMB)
124                 {
125                         str = strcat(str, " laser");
126                         hstr = strcat(hstr, " & Laser");
127                 }
128                 me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_weaponarena", strzone(str), strzone(hstr)));
129                         e.cvarOffValue = "0";
130         }
131         me.TR(me);
132                 me.TD(me, 1, 4, makeNexuizTextLabel(0, "Special arenas:"));
133         me.TR(me);
134                 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_minstagib", string_null, "MinstaGib"));
135         me.TR(me);
136                 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_nixnex", string_null, "NixNex"));
137         me.TR(me);
138                 me.TDempty(me, 0.2);
139                 me.TD(me, 1, 3.8, e = makeNexuizCheckBox(1, "g_nixnex_with_laser", "with laser"));
140                         setDependent(e, "g_nixnex", 1, 1);
141         me.TR(me);
142                 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_weaponarena", "all", "All weapons"));
143                         e.cvarOffValue = "0";
144
145         me.gotoRC(me, me.rows - 2, 0);
146                 s = makeNexuizSlider(80, 400, 8, "sv_gravity");
147                         s.valueDigits = 0;
148                         s.valueDisplayMultiplier = 0.125; // show gravity in percent
149                 me.TD(me, 1, 1, e = makeNexuizSliderCheckBox(800, 1, s, "Low gravity"));
150                         e.savedValue = 200; // good on silvercity
151                 me.TD(me, 1, 5, s);
152
153         me.gotoRC(me, me.rows - 1, 0);
154                 me.TD(me, 1, me.columns, e = makeNexuizButton("OK", '0 0 0'));
155                         e.onClick = Dialog_Close;
156                         e.onClickEntity = me;
157 }
158
159 void closeNexuizMutatorsDialog(entity me)
160 {
161         if(me.refilterEntity)
162                 me.refilterEntity.refilter(me.refilterEntity);
163         closeDialog(me);
164 }
165 #endif