2 CLASS(XonoticMutatorsDialog) EXTENDS(XonoticDialog)
3 METHOD(XonoticMutatorsDialog, toString, string(entity))
4 METHOD(XonoticMutatorsDialog, fill, void(entity))
5 METHOD(XonoticMutatorsDialog, showNotify, void(entity))
6 METHOD(XonoticMutatorsDialog, close, void(entity))
7 ATTRIB(XonoticMutatorsDialog, title, string, _("Mutators"))
8 ATTRIB(XonoticMutatorsDialog, color, vector, SKINCOLOR_DIALOG_MUTATORS)
9 ATTRIB(XonoticMutatorsDialog, intendedWidth, float, 0.9)
10 ATTRIB(XonoticMutatorsDialog, rows, float, 17)
11 ATTRIB(XonoticMutatorsDialog, columns, float, 6)
12 ATTRIB(XonoticMutatorsDialog, refilterEntity, entity, NULL)
13 ENDCLASS(XonoticMutatorsDialog)
17 void XonoticMutatorsDialog_showNotify(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);
45 n = tokenize_console(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 = sprintf(_("%s Arena"), substring(s, 3, strlen(s) - 3));
58 weaponarenastring = strzone(s);
60 return weaponarenastring;
63 string XonoticMutatorsDialog_toString(entity me)
68 s = strcat(s, ", ", _("Dodging"));
69 if(cvar("g_minstagib"))
70 s = strcat(s, ", ", _("MinstaGib"));
72 s = strcat(s, ", ", _("NIX"));
73 if(cvar("g_rocket_flying"))
74 s = strcat(s, ", ", _("Rocket Flying"));
75 if(cvar_string("g_weaponarena") != "0")
76 s = strcat(s, ", ", WeaponArenaString());
77 if(cvar("g_start_weapon_laser") == 0)
78 s = strcat(s, ", ", _("No start weapons"));
79 if(cvar("sv_gravity") < 800)
80 s = strcat(s, ", ", _("Low gravity"));
82 s = strcat(s, ", ", _("Cloaked"));
83 if(cvar("g_grappling_hook"))
84 s = strcat(s, ", ", _("Hook"));
86 s = strcat(s, ", ", _("Midair"));
88 s = strcat(s, ", ", _("Vampire"));
90 s = strcat(s, ", ", _("Pinata"));
91 if(cvar("g_weapon_stay"))
92 s = strcat(s, ", ", _("Weapons stay"));
93 if(cvar("g_bloodloss") > 0)
94 s = strcat(s, ", ", _("Bloodloss"));
96 s = strcat(s, ", ", _("Jet pack"));
100 return substring(s, 2, strlen(s) - 2);
105 // WARNING: dirty hack. TODO clean this up by putting this behaviour in extra classes.
106 void loadCvarsLaserWeaponArenaWeaponButton(entity me)
108 tokenize_console(cvar_string("g_weaponarena"));
109 me.checked = (argv(0) == me.cvarValue);
112 void saveCvarsLaserWeaponArenaWeaponButton(entity me)
117 if(me.cvarValue != "laser" && me.cvarValue != "most")
118 if(cvar("menu_weaponarena_with_laser"))
121 cvar_set("g_weaponarena", strcat(me.cvarValue, suffix));
123 cvar_set("g_weaponarena", me.cvarOffValue);
126 .void(entity) draw_weaponarena;
127 .void(entity) saveCvars_weaponarena;
128 void saveCvarsLaserWeaponArenaLaserButton(entity me)
130 // run the old function
131 me.saveCvars_weaponarena(me);
133 me.disabled = ((cvar_string("g_weaponarena") == "0") || (cvar_string("g_weaponarena") == "laser") || (cvar_string("g_weaponarena") == "most"));
137 // check for the laser suffix
139 s = cvar_string("g_weaponarena");
140 if(me.checked && substring(s, strlen(s) - 6, 6) != " laser")
141 s = strcat(s, " laser");
142 else if(!me.checked && substring(s, strlen(s) - 6, 6) == " laser")
143 s = substring(s, 0, strlen(s) - 6);
144 cvar_set("g_weaponarena", s);
148 void preDrawLaserWeaponArenaLaserButton(entity me)
150 me.disabled = ((cvar_string("g_weaponarena") == "0") || (cvar_string("g_weaponarena") == "laser") || (cvar_string("g_weaponarena") == "most"));
151 // run the old function
152 me.draw_weaponarena(me);
154 // WARNING: end of dirty hack. Do not try this at home.
158 void XonoticMutatorsDialog_fill(entity me)
164 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Gameplay mutators:")));
167 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_dodging", _("Dodging")));
170 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_cloaked", _("Cloaked")));
173 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_midair", _("Midair")));
176 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_vampire", _("Vampire")));
179 s = makeXonoticSlider(10, 50, 1, "g_bloodloss");
180 me.TD(me, 1, 2, e = makeXonoticSliderCheckBox(0, 1, s, _("Blood loss")));
183 me.TD(me, 1, 1.8, s);
186 s = makeXonoticSlider(80, 400, 8, "sv_gravity");
188 s.valueDisplayMultiplier = 0.125; // show gravity in percent
189 me.TD(me, 1, 2, e = makeXonoticSliderCheckBox(800, 1, s, _("Low gravity")));
190 e.savedValue = 200; // good on silvercity
193 me.TD(me, 1, 1.8, s);
196 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Weapon & item mutators:")));
199 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_grappling_hook", _("Grappling hook")));
202 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_jetpack", _("Jet pack")));
205 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_rocket_flying", _("Rocket Flying")));
208 me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_pinata", _("Pinata")));
211 me.TD(me, 1, 2, e = makeXonoticCheckBoxEx(2, 0, "g_weapon_stay", _("Weapons stay")));
214 me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
215 me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Weapon arenas:")));
218 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
219 for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
221 w = get_weaponinfo(i);
222 if(w.spawnflags & WEP_FLAG_HIDDEN)
229 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_weaponarena", strzone(str), strzone(hstr)));
230 e.cvarOffValue = "0";
231 // custom load/save logic that ignores a " laser" suffix, or adds it
232 e.loadCvars = loadCvarsLaserWeaponArenaWeaponButton;
233 e.saveCvars = saveCvarsLaserWeaponArenaWeaponButton;
239 me.TD(me, 1, 1, e = makeXonoticCheckBox(0, "menu_weaponarena_with_laser", _("with laser")));
240 // hook the draw function to gray it out
241 e.draw_weaponarena = e.draw;
242 e.draw = preDrawLaserWeaponArenaLaserButton;
243 // hook the save function to notify about the cvar
244 e.saveCvars_weaponarena = e.saveCvars;
245 e.saveCvars = saveCvarsLaserWeaponArenaLaserButton;
247 me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Special arenas:")));
250 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_minstagib", string_null, _("MinstaGib")));
253 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_nix", string_null, _("NIX")));
256 me.TD(me, 1, 1, e = makeXonoticCheckBox(0, "g_nix_with_laser", _("with laser")));
257 setDependent(e, "g_nix", 1, 1);
260 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_weaponarena", "most", _("Most weapons")));
261 e.cvarOffValue = "0";
264 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_start_weapon_laser", "0", _("No start weapons")));
265 e.cvarOffValue = "-1";
266 makeMulti(e, "g_start_weapon_shotgun g_start_weapon_uzi g_start_weapon_grenadelauncher g_start_weapon_minelayer g_start_weapon_electro g_start_weapon_crylink g_start_weapon_nex g_start_weapon_hagar g_start_weapon_rocketlauncher g_start_weapon_sniperrifle g_start_weapon_hlac g_start_weapon_seeker g_start_weapon_minstanex g_start_weapon_hook g_start_weapon_porto g_start_weapon_tuba g_start_weapon_minelayer");
268 me.gotoRC(me, me.rows - 1, 0);
269 me.TD(me, 1, me.columns, e = makeXonoticButton(_("OK"), '0 0 0'));
270 e.onClick = Dialog_Close;
271 e.onClickEntity = me;
274 void XonoticMutatorsDialog_close(entity me)
276 if(me.refilterEntity)
277 me.refilterEntity.refilter(me.refilterEntity);
278 SUPER(XonoticMutatorsDialog).close(me);