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