]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
Clean up MENUQC #includes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_create_mutators.qc
1 #include "../../common/weapons/weapons.qh"
2
3 #ifdef INTERFACE
4 CLASS(XonoticMutatorsDialog) EXTENDS(XonoticDialog)
5         METHOD(XonoticMutatorsDialog, toString, string(entity))
6         METHOD(XonoticMutatorsDialog, fill, void(entity))
7         METHOD(XonoticMutatorsDialog, showNotify, void(entity))
8         METHOD(XonoticMutatorsDialog, close, void(entity))
9         ATTRIB(XonoticMutatorsDialog, title, string, _("Mutators"))
10         ATTRIB(XonoticMutatorsDialog, color, vector, SKINCOLOR_DIALOG_MUTATORS)
11         ATTRIB(XonoticMutatorsDialog, intendedWidth, float, 0.9)
12         ATTRIB(XonoticMutatorsDialog, rows, float, 20)
13         ATTRIB(XonoticMutatorsDialog, columns, float, 6)
14         ATTRIB(XonoticMutatorsDialog, refilterEntity, entity, NULL)
15 ENDCLASS(XonoticMutatorsDialog)
16 #endif
17
18 #ifdef IMPLEMENTATION
19 void XonoticMutatorsDialog_showNotify(entity me)
20 {
21         loadAllCvars(me);
22 }
23
24 string weaponarenastring;
25 string weaponarenastring_cvar;
26 string WeaponArenaString()
27 {
28         string s;
29         float n, i, j;
30         entity e;
31         s = cvar_string("g_weaponarena");
32         if(s == "0")
33                 return "";
34         if(s == "all" || s == "1")
35                 return _("All Weapons Arena");
36         if(s == "most")
37                 return _("Most Weapons Arena");
38         if(s == weaponarenastring_cvar)
39                 return weaponarenastring;
40         if(weaponarenastring)
41                 strunzone(weaponarenastring);
42         if(weaponarenastring_cvar)
43                 strunzone(weaponarenastring_cvar);
44
45         weaponarenastring_cvar = strzone(s);
46
47         n = tokenize_console(s);
48         s = "";
49         for(i = 0; i < n; ++i)
50         {
51                 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
52                 {
53                         e = get_weaponinfo(j);
54                         if(argv(i) == e.netname)
55                                 s = strcat(s, " & ", e.message);
56                 }
57         }
58         s = sprintf(_("%s Arena"), substring(s, 3, strlen(s) - 3));
59
60         weaponarenastring = strzone(s);
61
62         return weaponarenastring;
63 }
64
65 string XonoticMutatorsDialog_toString(entity me)
66 {
67         string s;
68         s = "";
69         if(cvar("g_dodging"))
70                 s = strcat(s, ", ", _("Dodging"));
71         if(cvar("g_instagib"))
72                 s = strcat(s, ", ", _("InstaGib"));
73         if(cvar("g_new_toys"))
74                 s = strcat(s, ", ", _("New Toys"));
75         if(cvar("g_nix"))
76                 s = strcat(s, ", ", _("NIX"));
77         if(cvar("g_rocket_flying"))
78                 s = strcat(s, ", ", _("Rocket Flying"));
79         if(cvar("g_invincible_projectiles"))
80                 s = strcat(s, ", ", _("Invincible Projectiles"));
81         if(cvar_string("g_weaponarena") != "0")
82                 s = strcat(s, ", ", WeaponArenaString());
83         if(cvar("g_balance_blaster_weaponstart") == 0)
84                 s = strcat(s, ", ", _("No start weapons"));
85         if(cvar("sv_gravity") < stof(cvar_defstring("sv_gravity")))
86                 s = strcat(s, ", ", _("Low gravity"));
87         if(cvar("g_cloaked"))
88                 s = strcat(s, ", ", _("Cloaked"));
89         if(cvar("g_grappling_hook"))
90                 s = strcat(s, ", ", _("Hook"));
91         if(cvar("g_midair"))
92                 s = strcat(s, ", ", _("Midair"));
93         if(cvar("g_vampire"))
94                 s = strcat(s, ", ", _("Vampire"));
95         if(cvar("g_pinata"))
96                 s = strcat(s, ", ", _("Piñata"));
97         if(cvar("g_weapon_stay"))
98                 s = strcat(s, ", ", _("Weapons stay"));
99         if(cvar("g_bloodloss") > 0)
100                 s = strcat(s, ", ", _("Blood loss"));
101         if(cvar("g_jetpack"))
102                 s = strcat(s, ", ", _("Jet pack"));
103         if(cvar("g_buffs"))
104                 s = strcat(s, ", ", _("Buffs"));
105         if(cvar("g_overkill"))
106                 s = strcat(s, ", ", _("Overkill"));
107         if(cvar("g_powerups") == 0)
108                 s = strcat(s, ", ", _("No powerups"));
109         if(cvar("g_powerups") > 0)
110                 s = strcat(s, ", ", _("Powerups"));
111         if(cvar("g_touchexplode") > 0)
112                 s = strcat(s, ", ", _("Touch explode"));
113         if(s == "")
114                 return ZCTX(_("MUT^None"));
115         else
116                 return substring(s, 2, strlen(s) - 2);
117 }
118
119 float checkCompatibility_pinata(entity me)
120 {
121         if(cvar("g_instagib"))
122                 return 0;
123         if(cvar("g_nix"))
124                 return 0;
125         if(cvar_string("g_weaponarena") != "0")
126                 return 0;
127         return 1;
128 }
129 float checkCompatibility_weaponstay(entity me)
130 {
131         return checkCompatibility_pinata(me);
132 }
133 float checkCompatibility_newtoys(entity me)
134 {
135         if(cvar("g_instagib"))
136                 return 0;
137         if(cvar_string("g_weaponarena") == "most")
138                 return 1;
139         if(cvar_string("g_weaponarena") == "all" || cvar_string("g_weaponarena") == "1")
140                 return 1;
141         if(cvar_string("g_weaponarena") != "0")
142                 return 0;
143         return 1;
144 }
145 float checkCompatibility_weaponarena_weapon(entity me)
146 {
147         if(cvar("g_instagib"))
148                 return 0;
149         if(cvar_string("g_weaponarena") == "most")
150                 return 0;
151         if(cvar_string("g_weaponarena") == "all" || cvar_string("g_weaponarena") == "1")
152                 return 0;
153         if(cvar_string("g_weaponarena") == "0")
154                 return 0;
155         if(cvar_string("g_balance_blaster_weaponstart") == "0")
156                 return 0;
157         return 1;
158 }
159
160 void XonoticMutatorsDialog_fill(entity me)
161 {
162         entity e, s, w;
163         float i, j;
164         me.TR(me);
165                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Gameplay mutators:")));
166         me.TR(me);
167                 me.TDempty(me, 0.2);
168                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_dodging", _("Dodging")));
169         me.TR(me);
170                 me.TDempty(me, 0.2);
171                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_touchexplode", _("Touch explode")));
172         me.TR(me);
173                 me.TDempty(me, 0.2);
174                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_cloaked", _("Cloaked")));
175         me.TR(me);
176                 me.TDempty(me, 0.2);
177                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_buffs", _("Buffs")));
178         me.TR(me);
179                 me.TDempty(me, 0.2);
180                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_midair", _("Midair")));
181         me.TR(me);
182                 me.TDempty(me, 0.2);
183                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_vampire", _("Vampire")));
184                         setDependent(e, "g_instagib", 0, 0);
185         me.TR(me);
186                 me.TDempty(me, 0.2);
187                 s = makeXonoticSlider(10, 50, 1, "g_bloodloss");
188                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(0, 1, s, _("Blood loss")));
189                         setDependent(e, "g_instagib", 0, 0);
190         me.TR(me);
191                 me.TDempty(me, 0.4);
192                 me.TD(me, 1, 1.6, s);
193         me.TR(me);
194                 me.TDempty(me, 0.2);
195                 s = makeXonoticSlider(80, 400, 8, "sv_gravity");
196                         s.valueDigits = 0;
197                         s.valueDisplayMultiplier = 0.125; // show gravity in percent
198                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(800, 1, s, _("Low gravity")));
199                         e.savedValue = 200; // good on silvercity
200         me.TR(me);
201                 me.TDempty(me, 0.4);
202                 me.TD(me, 1, 1.6, s);
203         me.TR(me);
204                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Weapon & item mutators:")));
205         me.TR(me);
206                 me.TDempty(me, 0.2);
207                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_grappling_hook", _("Grappling hook")));
208         me.TR(me);
209                 me.TDempty(me, 0.2);
210                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_jetpack", _("Jet pack")));
211         me.TR(me);
212                 me.TDempty(me, 0.2);
213                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_invincible_projectiles", _("Invincible Projectiles")));
214                         setDependent(e, "g_instagib", 0, 0);
215         me.TR(me);
216                 me.TDempty(me, 0.2);
217                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_new_toys", _("New Toys")));
218                         setDependentWeird(e, checkCompatibility_newtoys);
219         me.TR(me);
220                 me.TDempty(me, 0.2);
221                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_rocket_flying", _("Rocket Flying")));
222                         setDependent(e, "g_instagib", 0, 0);
223         me.TR(me);
224                 me.TDempty(me, 0.2);
225                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_pinata", _("Piñata")));
226                         setDependentWeird(e, checkCompatibility_pinata);
227         me.TR(me);
228                 me.TDempty(me, 0.2);
229                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_weapon_stay", _("Weapons stay")));
230                         setDependentWeird(e, checkCompatibility_weaponstay);
231         me.TR(me);
232
233         me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
234                 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
235         me.TR(me);
236                 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_weaponarena", "menu_weaponarena", _("Weapon arenas:")));
237                         e.getCvarValueFromCvar = true;
238                         e.cvarOffValue = "0";
239         for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
240         {
241                 w = get_weaponinfo(i);
242                 if(w.spawnflags & WEP_FLAG_HIDDEN)
243                         continue;
244                 if((j & 1) == 0)
245                         me.TR(me);
246                 me.TDempty(me, 0.2);
247                 me.TD(me, 1, 1.8, e = makeXonoticWeaponarenaCheckBox(strzone(w.netname), strzone(w.message)));
248                         setDependentWeird(e, checkCompatibility_weaponarena_weapon);
249                 ++j;
250         }
251         me.TR(me);
252                 me.TDempty(me, 0.2);
253                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_weaponarena", "most", _("Most weapons")));
254                         e.cvarOffValue = "0";
255         me.TR(me);
256                 me.TDempty(me, 0.2);
257                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_weaponarena", "all", _("All weapons")));
258                         e.cvarOffValue = "0";
259         me.TR(me);
260                 me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Special arenas:")));
261         me.TR(me);
262                 me.TDempty(me, 0.2);
263                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_instagib", "1", _("InstaGib")));
264                         e.cvarOffValue = "0";
265         me.TR(me);
266                 me.TDempty(me, 0.2);
267                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_nix", "1", _("NIX")));
268                         e.cvarOffValue = "0";
269         me.TR(me);
270                 me.TDempty(me, 0.4);
271                 me.TD(me, 1, 1.6, e = makeXonoticCheckBox(0, "g_nix_with_blaster", _("with blaster")));
272                         setDependent(e, "g_nix", 1, 1);
273         me.TR(me);
274                 me.TDempty(me, 0.2);
275                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_balance_blaster_weaponstart", "0", _("No start weapons")));
276                         e.cvarOffValue = "-1";
277                         makeMulti(e, "g_balance_shotgun_weaponstart g_balance_machinegun_weaponstart g_balance_devastator_weaponstart g_balance_minelayer_weaponstart g_balance_electro_weaponstart g_balance_crylink_weaponstart g_balance_hagar_weaponstart g_balance_porto_weaponstart g_balance_vaporizer_weaponstart g_balance_hook_weaponstart g_balance_rifle_weaponstart g_balance_fireball_weaponstart g_balance_seeker_weaponstart g_balance_tuba_weaponstart g_balance_arc_weaponstart g_balance_vortex_weaponstart g_balance_mortar_weaponstart");
278
279         me.gotoRC(me, me.rows - 1, 0);
280                 me.TD(me, 1, me.columns, e = makeXonoticButton(_("OK"), '0 0 0'));
281                         e.onClick = Dialog_Close;
282                         e.onClickEntity = me;
283 }
284
285 void XonoticMutatorsDialog_close(entity me)
286 {
287         if(me.refilterEntity)
288                 me.refilterEntity.refilter(me.refilterEntity);
289         SUPER(XonoticMutatorsDialog).close(me);
290 }
291 #endif