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