]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
Compact weapon flag checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_create_mutators.qc
index 63b55a19b9514200ab86e1fe3e298afb7aea5a22..33fe3575a8bde07be1326970f232e4087667cf6d 100644 (file)
@@ -30,25 +30,22 @@ string WeaponArenaString()
                return _("Most Weapons Arena");
        if(s == weaponarenastring_cvar)
                return weaponarenastring;
-       if(weaponarenastring)
-               strunzone(weaponarenastring);
-       if(weaponarenastring_cvar)
-               strunzone(weaponarenastring_cvar);
 
-       weaponarenastring_cvar = strzone(s);
+       strcpy(weaponarenastring_cvar, s);
 
        n = tokenize_console(s);
        s = "";
        for(int j = 0; j < n; ++j)
        {
-               FOREACH(Weapons, it != WEP_Null, {
-                       if(argv(j) == it.netname)
-                               s = cons_mid(s, " & ", it.m_name);
-               });
+               Weapon wep = Weapons_fromstr(argv(j));
+               if(wep != WEP_Null)
+               {
+                       s = cons_mid(s, " & ", wep.m_name);
+               }
        }
        s = sprintf(_("%s Arena"), s);
 
-       weaponarenastring = strzone(s);
+       strcpy(weaponarenastring, s);
 
        return weaponarenastring;
 }
@@ -91,7 +88,7 @@ string XonoticMutatorsDialog_toString(entity me)
        if(cvar("g_bloodloss") > 0)
                s = cons_mid(s, ", ", _("Blood loss"));
        if(cvar("g_jetpack"))
-               s = cons_mid(s, ", ", _("Jet pack"));
+               s = cons_mid(s, ", ", _("Jetpack"));
        if(cvar("g_buffs") > 0)
                s = cons_mid(s, ", ", _("Buffs"));
        if(cvar("g_overkill"))
@@ -213,7 +210,7 @@ void XonoticMutatorsDialog_fill(entity me)
                        _("Players spawn with the grappling hook")));
        me.TR(me);
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_jetpack", _("Jet pack"),
+               me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_jetpack", _("Jetpack"),
                        _("Players spawn with the jetpack")));
        me.TR(me);
                me.TDempty(me, 0.2);
@@ -241,32 +238,38 @@ void XonoticMutatorsDialog_fill(entity me)
 
        me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
                me.TD(me, 1, 2, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
+       string weaponarena_tooltip = strzone(_("Players will be given a set of weapons at spawn as well as unlimited ammo, without weapon pickups"));
        me.TR(me);
-               me.TD(me, 1, 2, e = makeXonoticRadioButton_T(1, "g_weaponarena", "menu_weaponarena", _("Weapon arenas:"),
-                       _("Selecting a weapon arena will give all players that weapon at spawn as well as unlimited ammo, and disable all other weapon pickups.")));
+               me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Weapon arenas:")));
+       me.TR(me);
+               me.TDempty(me, 0.2);
+               me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "menu_weaponarena", _("Custom weapons"), weaponarena_tooltip));
                        e.cvarValueIsAnotherCvar = true;
                        e.cvarOffValue = "0";
+
+               me.TDempty(me, 0.1); // fix initial position
        for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
        {
                w = Weapons_from(i);
-               if(w.spawnflags & WEP_FLAG_HIDDEN)
+               if (w.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK))
                        continue;
-               if((j & 1) == 0)
+               if ((j % 3) == 0)
+               {
                        me.TR(me);
-               me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticWeaponarenaCheckBox(strzone(w.netname), strzone(w.m_name)));
+                       me.TDempty(me, 0.4);
+               }
+               me.TD(me, 1, 1.2, e = makeXonoticWeaponarenaCheckBox(strzone(w.netname), strzone(w.m_name)));
                        setDependentWeird(e, checkCompatibility_weaponarena_weapon);
                ++j;
        }
+
        me.TR(me);
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "most", _("Most weapons"),
-                       _("Selecting a weapon arena will give all players that weapon at spawn as well as unlimited ammo, and disable all other weapon pickups.")));
+               me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "most", _("Most weapons"), weaponarena_tooltip));
                        e.cvarOffValue = "0";
        me.TR(me);
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "all", _("All weapons"),
-                       _("Selecting a weapon arena will give all players that weapon at spawn as well as unlimited ammo, and disable all other weapon pickups.")));
+               me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "all", _("All weapons"), weaponarena_tooltip));
                        e.cvarOffValue = "0";
        me.TR(me);
                me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Special arenas:")));