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