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, 17)
11 ATTRIB(NexuizMutatorsDialog, columns, float, 6)
12 ATTRIB(NexuizMutatorsDialog, refilterEntity, entity, NULL)
13 ENDCLASS(NexuizMutatorsDialog)
17 void showNotifyNexuizMutatorsDialog(entity me)
22 string weaponarenastring;
23 string weaponarenastring_cvar;
24 string WeaponArenaString()
29 s = cvar_string("g_weaponarena");
33 return "All Weapons Arena";
35 return "Most Weapons Arena";
36 if(s == weaponarenastring_cvar)
37 return weaponarenastring;
39 strunzone(weaponarenastring);
40 if(weaponarenastring_cvar)
41 strunzone(weaponarenastring_cvar);
43 weaponarenastring_cvar = strzone(s);
47 for(i = 0; i < n; ++i)
49 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
51 e = get_weaponinfo(j);
52 if(argv(i) == e.netname)
53 s = strcat(s, " & ", e.message);
56 s = strcat(substring(s, 3, strlen(s) - 3), " Arena");
58 weaponarenastring = strzone(s);
60 return weaponarenastring;
63 string toStringNexuizMutatorsDialog(entity me)
67 if(cvar("g_minstagib"))
68 s = strcat(s, ", MinstaGib");
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");
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");
84 s = strcat(s, ", Midair");
86 s = strcat(s, ", Vampire");
88 s = strcat(s, ", Pinata");
89 if(cvar("g_weapon_stay"))
90 s = strcat(s, ", Weapons stay");
91 if(cvar("g_bloodloss") > 0)
92 s = strcat(s, ", Bloodloss");
96 return substring(s, 2, strlen(s) - 2);
101 // WARNING: dirty hack. TODO clean this up by putting this behaviour in extra classes.
102 void loadCvarsLaserWeaponArenaWeaponButton(entity me)
104 tokenize_sane(cvar_string("g_weaponarena"));
105 me.checked = (argv(0) == me.cvarValue);
108 void saveCvarsLaserWeaponArenaWeaponButton(entity me)
113 if(me.cvarValue != "laser")
114 if(cvar("menu_weaponarena_with_laser"))
117 cvar_set("g_weaponarena", strcat(me.cvarValue, suffix));
119 cvar_set("g_weaponarena", me.cvarOffValue);
122 .void(entity) draw_weaponarena;
123 .void(entity) saveCvars_weaponarena;
124 void saveCvarsLaserWeaponArenaLaserButton(entity me)
126 // run the old function
127 me.saveCvars_weaponarena(me);
129 me.disabled = ((cvar_string("g_weaponarena") == "0") || (cvar_string("g_weaponarena") == "laser"));
133 // check for the laser suffix
135 s = cvar_string("g_weaponarena");
136 if(me.checked && substring(s, strlen(s) - 6, 6) != " laser")
137 s = strcat(s, " laser");
138 else if(!me.checked && substring(s, strlen(s) - 6, 6) == " laser")
139 s = substring(s, 0, strlen(s) - 6);
140 cvar_set("g_weaponarena", s);
144 void preDrawLaserWeaponArenaLaserButton(entity me)
146 me.disabled = ((cvar_string("g_weaponarena") == "0") || (cvar_string("g_weaponarena") == "laser"));
147 // run the old function
148 me.draw_weaponarena(me);
150 // WARNING: end of dirty hack. Do not try this at home.
154 void fillNexuizMutatorsDialog(entity me)
160 me.TD(me, 1, 2, makeNexuizTextLabel(0, "Game mutators:"));
162 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_cloaked", "Cloaked"));
164 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_footsteps", "Footsteps"));
166 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_grappling_hook", "Grappling hook"));
168 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_laserguided_missile", "Laser guided missiles"));
170 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_midair", "Midair"));
172 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_vampire", "Vampire"));
174 me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_pinata", "Pinata"));
176 me.TD(me, 1, 2, e = makeNexuizCheckBoxEx(2, 0, "g_weapon_stay", "Weapons stay"));
178 s = makeNexuizSlider(10, 50, 1, "g_bloodloss");
179 me.TD(me, 1, 2, e = makeNexuizSliderCheckBox(0, 1, s, "Blood loss"));
182 me.TD(me, 1, 1.8, s);
184 s = makeNexuizSlider(80, 400, 8, "sv_gravity");
186 s.valueDisplayMultiplier = 0.125; // show gravity in percent
187 me.TD(me, 1, 2, e = makeNexuizSliderCheckBox(800, 1, s, "Low gravity"));
188 e.savedValue = 200; // good on silvercity
191 me.TD(me, 1, 1.8, s);
193 me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
194 me.TD(me, 1, 4, makeNexuizTextLabel(0, "Weapon arenas:"));
196 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, string_null, string_null, "Regular (no arena)"));
197 for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i, ++j)
199 w = get_weaponinfo(i);
204 me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_weaponarena", strzone(str), strzone(hstr)));
205 e.cvarOffValue = "0";
206 // custom load/save logic that ignores a " laser" suffix, or adds it
207 e.loadCvars = loadCvarsLaserWeaponArenaWeaponButton;
208 e.saveCvars = saveCvarsLaserWeaponArenaWeaponButton;
213 me.TD(me, 1, 3.8, e = makeNexuizCheckBox(0, "menu_weaponarena_with_laser", "with laser"));
214 // hook the draw function to gray it out
215 e.draw_weaponarena = e.draw;
216 e.draw = preDrawLaserWeaponArenaLaserButton;
217 // hook the save function to notify about the cvar
218 e.saveCvars_weaponarena = e.saveCvars;
219 e.saveCvars = saveCvarsLaserWeaponArenaLaserButton;
221 me.TD(me, 1, 4, makeNexuizTextLabel(0, "Special arenas:"));
223 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_minstagib", string_null, "MinstaGib"));
225 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_nixnex", string_null, "NixNex"));
228 me.TD(me, 1, 3.8, e = makeNexuizCheckBox(0, "g_nixnex_with_laser", "with laser"));
229 setDependent(e, "g_nixnex", 1, 1);
231 me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_weaponarena", "most", "Most weapons"));
232 e.cvarOffValue = "0";
234 me.gotoRC(me, me.rows - 1, 0);
235 me.TD(me, 1, me.columns, e = makeNexuizButton("OK", '0 0 0'));
236 e.onClick = Dialog_Close;
237 e.onClickEntity = me;
240 void closeNexuizMutatorsDialog(entity me)
242 if(me.refilterEntity)
243 me.refilterEntity.refilter(me.refilterEntity);