]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.c
Merge branch 'master' into terencehill/music_player
[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, 19)
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")
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_minstagib"))
70                 s = strcat(s, ", ", _("MinstaGib"));
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_start_weapon_laser") == 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_powerups") == 0)
102                 s = strcat(s, ", ", _("No powerups"));
103         if(cvar("g_powerups") > 0)
104                 s = strcat(s, ", ", _("Powerups"));
105         if(cvar("g_touchexplode") > 0)
106                 s = strcat(s, ", ", _("Touch explode"));
107         if(s == "")
108                 return ZCTX(_("MUT^None"));
109         else
110                 return substring(s, 2, strlen(s) - 2);
111 }
112
113 float checkCompatibility_pinata(entity me)
114 {
115         if(cvar("g_minstagib"))
116                 return 0;
117         if(cvar("g_nix"))
118                 return 0;
119         if(cvar_string("g_weaponarena") != "0")
120                 return 0;
121         return 1;
122 }
123 float checkCompatibility_weaponstay(entity me)
124 {
125         return checkCompatibility_pinata(me);
126 }
127 float checkCompatibility_newtoys(entity me)
128 {
129         if(cvar("g_minstagib"))
130                 return 0;
131         if(cvar_string("g_weaponarena") == "most")
132                 return 1;
133         if(cvar_string("g_weaponarena") == "all")
134                 return 1;
135         if(cvar_string("g_weaponarena") != "0")
136                 return 0;
137         return 1;
138 }
139 float checkCompatibility_weaponarena_weapon(entity me)
140 {
141         if(cvar("g_minstagib"))
142                 return 0;
143         if(cvar_string("g_weaponarena") == "most")
144                 return 0;
145         if(cvar_string("g_weaponarena") == "all")
146                 return 0;
147         if(cvar_string("g_weaponarena") == "0")
148                 return 0;
149         if(cvar_string("g_start_weapon_laser") == "0")
150                 return 0;
151         return 1;
152 }
153
154 void XonoticMutatorsDialog_fill(entity me)
155 {
156         entity e, s, w;
157         float i, j;
158         me.TR(me);
159                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Gameplay mutators:")));
160         me.TR(me);
161                 me.TDempty(me, 0.2);
162                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_dodging", _("Dodging")));
163         me.TR(me);
164                 me.TDempty(me, 0.2);
165                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_touchexplode", _("Touch explode")));
166         me.TR(me);
167                 me.TDempty(me, 0.2);
168                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_cloaked", _("Cloaked")));
169         me.TR(me);
170                 me.TDempty(me, 0.2);
171                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_midair", _("Midair")));
172         me.TR(me);
173                 me.TDempty(me, 0.2);
174                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_vampire", _("Vampire")));
175                         setDependent(e, "g_minstagib", 0, 0);
176         me.TR(me);
177                 me.TDempty(me, 0.2);
178                 s = makeXonoticSlider(10, 50, 1, "g_bloodloss");
179                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(0, 1, s, _("Blood loss")));
180                         setDependent(e, "g_minstagib", 0, 0);
181         me.TR(me);
182                 me.TDempty(me, 0.4);
183                 me.TD(me, 1, 1.6, s);
184         me.TR(me);
185                 me.TDempty(me, 0.2);
186                 s = makeXonoticSlider(80, 400, 8, "sv_gravity");
187                         s.valueDigits = 0;
188                         s.valueDisplayMultiplier = 0.125; // show gravity in percent
189                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(800, 1, s, _("Low gravity")));
190                         e.savedValue = 200; // good on silvercity
191         me.TR(me);
192                 me.TDempty(me, 0.4);
193                 me.TD(me, 1, 1.6, s);
194         me.TR(me);
195                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Weapon & item mutators:")));
196         me.TR(me);
197                 me.TDempty(me, 0.2);
198                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_grappling_hook", _("Grappling hook")));
199         me.TR(me);
200                 me.TDempty(me, 0.2);
201                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_jetpack", _("Jet pack")));
202         me.TR(me);
203                 me.TDempty(me, 0.2);
204                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_invincible_projectiles", _("Invincible Projectiles")));
205                         setDependent(e, "g_minstagib", 0, 0);
206         me.TR(me);
207                 me.TDempty(me, 0.2);
208                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_new_toys", _("New Toys")));
209                         setDependentWeird(e, checkCompatibility_newtoys);
210         me.TR(me);
211                 me.TDempty(me, 0.2);
212                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_rocket_flying", _("Rocket Flying")));
213                         setDependent(e, "g_minstagib", 0, 0);
214         me.TR(me);
215                 me.TDempty(me, 0.2);
216                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_pinata", _("Piñata")));
217                         setDependentWeird(e, checkCompatibility_pinata);
218         me.TR(me);
219                 me.TDempty(me, 0.2);
220                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_weapon_stay", _("Weapons stay")));
221                         setDependentWeird(e, checkCompatibility_weaponstay);
222         me.TR(me);
223
224         me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
225                 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
226         me.TR(me);
227                 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_weaponarena", "menu_weaponarena", _("Weapon arenas:")));
228                         e.getCvarValueFromCvar = TRUE;
229                         e.cvarOffValue = "0";
230         for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
231         {
232                 w = get_weaponinfo(i);
233                 if(w.spawnflags & WEP_FLAG_HIDDEN)
234                         continue;
235                 if((j & 1) == 0)
236                         me.TR(me);
237                 me.TDempty(me, 0.2);
238                 me.TD(me, 1, 1.8, e = makeXonoticWeaponarenaCheckBox(strzone(w.netname), strzone(w.message)));
239                         setDependentWeird(e, checkCompatibility_weaponarena_weapon);
240                 ++j;
241         }
242         me.TR(me);
243                 me.TDempty(me, 0.2);
244                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_weaponarena", "most", _("Most weapons")));
245                         e.cvarOffValue = "0";
246         me.TR(me);
247                 me.TDempty(me, 0.2);
248                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_weaponarena", "all", _("All weapons")));
249                         e.cvarOffValue = "0";
250         me.TR(me);
251                 me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Special arenas:")));
252         me.TR(me);
253                 me.TDempty(me, 0.2);
254                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_minstagib", "1", _("MinstaGib")));
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_nix", "1", _("NIX")));
259                         e.cvarOffValue = "0";
260         me.TR(me);
261                 me.TDempty(me, 0.4);
262                 me.TD(me, 1, 1.6, e = makeXonoticCheckBox(0, "g_nix_with_laser", _("with laser")));
263                         setDependent(e, "g_nix", 1, 1);
264         me.TR(me);
265                 me.TDempty(me, 0.2);
266                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_start_weapon_laser", "0", _("No start weapons")));
267                         e.cvarOffValue = "-1";
268                         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_porto g_start_weapon_minstanex g_start_weapon_hook g_start_weapon_hlac g_start_weapon_rifle g_start_weapon_fireball g_start_weapon_seeker g_start_weapon_tuba");
269
270         me.gotoRC(me, me.rows - 1, 0);
271                 me.TD(me, 1, me.columns, e = makeXonoticButton(_("OK"), '0 0 0'));
272                         e.onClick = Dialog_Close;
273                         e.onClickEntity = me;
274 }
275
276 void XonoticMutatorsDialog_close(entity me)
277 {
278         if(me.refilterEntity)
279                 me.refilterEntity.refilter(me.refilterEntity);
280         SUPER(XonoticMutatorsDialog).close(me);
281 }
282 #endif