]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'origin/master' into terencehill/menu_weaponarena_weapon...
authorSamual Lenks <samual@xonotic.org>
Sun, 28 Apr 2013 23:09:42 +0000 (19:09 -0400)
committerSamual Lenks <samual@xonotic.org>
Sun, 28 Apr 2013 23:09:42 +0000 (19:09 -0400)
defaultXonotic.cfg
qcsrc/menu/classes.c
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.c
qcsrc/menu/xonotic/radiobutton.c
qcsrc/menu/xonotic/weaponarenacheckbox.c [new file with mode: 0644]
tooltips.db
tooltips.db.it

index d6ff518627fab2fe808af71593aae4eb0d81f839..de83c9ae57901fc412fcbc804a1a5eae42de5be0 100644 (file)
@@ -989,8 +989,7 @@ seta menu_slist_showfull 1 "show servers even if they are full and have no slots
 seta menu_slist_showempty 1 "show servers even if they are no empty and have no opponents to play against"
 seta menu_slist_modfilter "" // set to either: !modname or modname. modname of = means "same as we are running now".
 
-// for menu weapon arena
-set menu_weaponarena_with_laser 0 "also enable the Laser in this weapon arena"
+seta menu_weaponarena ""
 
 seta menu_maxplayers 16 "maxplayers value when the menu starts a game"
 
index 0a3a55c5f1d4bc214045b2c32731adac5779c156..f00971674ef8bca06675809fcc1526744450969b 100644 (file)
@@ -43,6 +43,7 @@
 #include "xonotic/slider_resolution.c"
 #include "xonotic/checkbox.c"
 #include "xonotic/checkbox_string.c"
+#include "xonotic/weaponarenacheckbox.c"
 #include "xonotic/radiobutton.c"
 #include "xonotic/nexposee.c"
 #include "xonotic/rootdialog.c"
index d0a1e9f23f47416fb75125d9017ec578e65a762f..979402a9e1d946abb4b434e90ddedf921f97c803 100644 (file)
@@ -110,59 +110,6 @@ string XonoticMutatorsDialog_toString(entity me)
                return substring(s, 2, strlen(s) - 2);
 }
 
-
-
-// WARNING: dirty hack. TODO clean this up by putting this behaviour in extra classes.
-void loadCvarsLaserWeaponArenaWeaponButton(entity me)
-{
-       tokenize_console(cvar_string("g_weaponarena"));
-       me.checked = (argv(0) == me.cvarValue);
-}
-
-void saveCvarsLaserWeaponArenaWeaponButton(entity me)
-{
-       string suffix;
-
-       suffix = "";
-       if(me.cvarValue != "laser" && me.cvarValue != "most")
-               if(cvar("menu_weaponarena_with_laser"))
-                       suffix = " laser";
-       if(me.checked)
-               cvar_set("g_weaponarena", strcat(me.cvarValue, suffix));
-       else
-               cvar_set("g_weaponarena", me.cvarOffValue);
-}
-
-.void(entity) draw_weaponarena;
-.void(entity) saveCvars_weaponarena;
-void saveCvarsLaserWeaponArenaLaserButton(entity me)
-{
-       // run the old function
-       me.saveCvars_weaponarena(me);
-
-       me.disabled = ((cvar_string("g_weaponarena") == "0") || (cvar_string("g_weaponarena") == "laser") || (cvar_string("g_weaponarena") == "most"));
-
-       if not(me.disabled)
-       {
-               // check for the laser suffix
-               string s;
-               s = cvar_string("g_weaponarena");
-               if(me.checked && substring(s, strlen(s) - 6, 6) != " laser")
-                       s = strcat(s, " laser");
-               else if(!me.checked && substring(s, strlen(s) - 6, 6) == " laser")
-                       s = substring(s, 0, strlen(s) - 6);
-               cvar_set("g_weaponarena", s);
-       }
-}
-
-void preDrawLaserWeaponArenaLaserButton(entity me)
-{
-       me.disabled = ((cvar_string("g_weaponarena") == "0") || (cvar_string("g_weaponarena") == "laser") || (cvar_string("g_weaponarena") == "most"));
-       // run the old function
-       me.draw_weaponarena(me);
-}
-// WARNING: end of dirty hack. Do not try this at home.
-
 float checkCompatibility_pinata(entity me)
 {
        if(cvar("g_minstagib"))
@@ -189,12 +136,25 @@ float checkCompatibility_newtoys(entity me)
                return 0;
        return 1;
 }
+float checkCompatibility_weaponarena_weapon(entity me)
+{
+       if(cvar("g_minstagib"))
+               return 0;
+       if(cvar_string("g_weaponarena") == "most")
+               return 0;
+       if(cvar_string("g_weaponarena") == "all")
+               return 0;
+       if(cvar_string("g_weaponarena") == "0")
+               return 0;
+       if(cvar_string("g_start_weapon_laser") == "0")
+               return 0;
+       return 1;
+}
 
 void XonoticMutatorsDialog_fill(entity me)
 {
        entity e, s, w;
        float i, j;
-       string str, hstr;
        me.TR(me);
                me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Gameplay mutators:")));
        me.TR(me);
@@ -259,10 +219,11 @@ void XonoticMutatorsDialog_fill(entity me)
        me.TR(me);
 
        me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
-               me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Weapon arenas:")));
+               me.TD(me, 1, 2, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
        me.TR(me);
-               me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
+               me.TD(me, 1, 2, e = makeXonoticRadioButton(1, "g_weaponarena", "menu_weaponarena", _("Weapon arenas:")));
+                       e.getCvarValueFromCvar = TRUE;
+                       e.cvarOffValue = "0";
        for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
        {
                w = get_weaponinfo(i);
@@ -270,47 +231,35 @@ void XonoticMutatorsDialog_fill(entity me)
                        continue;
                if(j & 1 == 0)
                        me.TR(me);
-               str = w.netname;
-               hstr = w.message;
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_weaponarena", strzone(str), strzone(hstr)));
-                       e.cvarOffValue = "0";
-                       // custom load/save logic that ignores a " laser" suffix, or adds it 
-                       e.loadCvars = loadCvarsLaserWeaponArenaWeaponButton;
-                       e.saveCvars = saveCvarsLaserWeaponArenaWeaponButton;
-                       e.loadCvars(e);
+               me.TD(me, 1, 1.8, e = makeXonoticWeaponarenaCheckBox(strzone(w.netname), strzone(w.message)));
+                       setDependentWeird(e, checkCompatibility_weaponarena_weapon);
                ++j;
        }
        me.TR(me);
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "menu_weaponarena_with_laser", _("with laser")));
-                       // hook the draw function to gray it out
-                       e.draw_weaponarena = e.draw;
-                       e.draw = preDrawLaserWeaponArenaLaserButton;
-                       // hook the save function to notify about the cvar
-                       e.saveCvars_weaponarena = e.saveCvars;
-                       e.saveCvars = saveCvarsLaserWeaponArenaLaserButton;
+               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_weaponarena", "most", _("Most weapons")));
+                       e.cvarOffValue = "0";
+       me.TR(me);
        me.TR(me);
                me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Special arenas:")));
        me.TR(me);
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_minstagib", string_null, _("MinstaGib")));
+               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_minstagib", "1", _("MinstaGib")));
+                       e.cvarOffValue = "0";
        me.TR(me);
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_nix", string_null, _("NIX")));
+               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_nix", "1", _("NIX")));
+                       e.cvarOffValue = "0";
        me.TR(me);
                me.TDempty(me, 0.4);
                me.TD(me, 1, 1.6, e = makeXonoticCheckBox(0, "g_nix_with_laser", _("with laser")));
                        setDependent(e, "g_nix", 1, 1);
-       me.TR(me);
-               me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_weaponarena", "most", _("Most weapons")));
-                       e.cvarOffValue = "0";
        me.TR(me);
                me.TDempty(me, 0.2);
                me.TD(me, 1, 1.8, e = makeXonoticRadioButton(1, "g_start_weapon_laser", "0", _("No start weapons")));
                        e.cvarOffValue = "-1";
-                       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_rifle g_start_weapon_hlac g_start_weapon_seeker g_start_weapon_minstanex g_start_weapon_hook g_start_weapon_porto g_start_weapon_tuba g_start_weapon_minelayer");
+                       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");
 
        me.gotoRC(me, me.rows - 1, 0);
                me.TD(me, 1, me.columns, e = makeXonoticButton(_("OK"), '0 0 0'));
index 8c353eae6725aec683419db78b88d6e3ce5274d5..4ac5aa7b188030dc40c316a4982d71370946d9bc 100644 (file)
@@ -13,6 +13,7 @@ CLASS(XonoticRadioButton) EXTENDS(RadioButton)
        ATTRIB(XonoticRadioButton, cvarName, string, string_null)
        ATTRIB(XonoticRadioButton, cvarValue, string, string_null)
        ATTRIB(XonoticRadioButton, cvarOffValue, string, string_null)
+       ATTRIB(XonoticRadioButton, getCvarValueFromCvar, float, 0)
        METHOD(XonoticRadioButton, loadCvars, void(entity))
        METHOD(XonoticRadioButton, saveCvars, void(entity))
 
@@ -98,7 +99,12 @@ void XonoticRadioButton_saveCvars(entity me)
                if(me.cvarName)
                {
                        if(me.checked)
-                               cvar_set(me.cvarName, me.cvarValue);
+                       {
+                               if(me.getCvarValueFromCvar)
+                                       cvar_set(me.cvarName, cvar_string(me.cvarValue));
+                               else
+                                       cvar_set(me.cvarName, me.cvarValue);
+                       }
                        else if(me.cvarOffValue)
                                cvar_set(me.cvarName, me.cvarOffValue);
                }
diff --git a/qcsrc/menu/xonotic/weaponarenacheckbox.c b/qcsrc/menu/xonotic/weaponarenacheckbox.c
new file mode 100644 (file)
index 0000000..163f9c6
--- /dev/null
@@ -0,0 +1,57 @@
+#ifdef INTERFACE
+CLASS(XonoticWeaponarenaCheckBox) EXTENDS(CheckBox)
+       METHOD(XonoticWeaponarenaCheckBox, configureXonoticWeaponarenaCheckBox, void(entity, string, string))
+       METHOD(XonoticWeaponarenaCheckBox, setChecked, void(entity, float))
+       ATTRIB(XonoticWeaponarenaCheckBox, fontSize, float, SKINFONTSIZE_NORMAL)
+       ATTRIB(XonoticWeaponarenaCheckBox, image, string, SKINGFX_CHECKBOX)
+       ATTRIB(XonoticWeaponarenaCheckBox, netname, string, string_null)
+
+       METHOD(XonoticWeaponarenaCheckBox, loadCvars, void(entity))
+       METHOD(XonoticWeaponarenaCheckBox, saveCvars, void(entity))
+ENDCLASS(XonoticWeaponarenaCheckBox)
+entity makeXonoticWeaponarenaCheckBox(string, string);
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeXonoticWeaponarenaCheckBox(string theWeapon, string theText)
+{
+       entity me;
+       me = spawnXonoticWeaponarenaCheckBox();
+       me.configureXonoticWeaponarenaCheckBox(me, theWeapon, theText);
+       return me;
+}
+void XonoticWeaponarenaCheckBox_configureXonoticWeaponarenaCheckBox(entity me, string theWeapon, string theText)
+{
+       me.netname = theWeapon;
+       me.checked = FALSE;
+       me.loadCvars(me);
+       me.configureCheckBox(me, theText, me.fontSize, me.image);
+}
+void XonoticWeaponarenaCheckBox_setChecked(entity me, float foo)
+{
+       me.checked = !me.checked;
+       me.saveCvars(me);
+}
+void XonoticWeaponarenaCheckBox_loadCvars(entity me)
+{
+       float n = tokenize_console(cvar_string("menu_weaponarena"));
+       float i;
+       for(i=0; i<n; ++i)
+       {
+               if(argv(i) == me.netname)
+               {
+                       me.checked = TRUE;
+                       break;
+               }
+       }
+}
+
+void XonoticWeaponarenaCheckBox_saveCvars(entity me)
+{
+       if(me.checked)
+               localcmd(strcat("\nmenu_cmd addtolist menu_weaponarena ", me.netname, "\n"));
+       else
+               localcmd(strcat("\nmenu_cmd removefromlist menu_weaponarena ", me.netname, "\n"));
+       localcmd("\ng_weaponarena \"$menu_weaponarena\"\n");
+}
+#endif
index 1301bda978a75ff5d4fe3d0d7ed17798d780a3cf..0f80a81332fc7483c773cdf53627da8c155eb85b 100644 (file)
@@ -40,7 +40,6 @@
 \g_pinata\Players will drop all weapons they possessed when they are killed
 \g_weapon_stay\Weapons stay after they are picked up
 \g_weaponarena\Selecting a weapon arena will give all players that weapon at spawn as well as unlimited ammo, and disable all other weapon pickups.
-\menu_weaponarena_with_laser\Also enable the laser in the weapon arena
 \g_minstagib\Players will be given the Minstanex, which is a railgun with infinite damage. If the player runs out of ammo, he will have 10 seconds to find some or if he fails to do so, face death. The secondary fire mode is a laser which does not inflict any damage and is good for doing trickjumps.
 \g_nix\No items Xonotic - instead of pickup items, everyone plays with the same weapon. After some time, a countdown will start, after which everyone will switch to another weapon.
 \g_nix_with_laser\Always carry the laser as an additional weapon in Nix
index 180076f7719061b60d2b74d6d3c6c799b8ddde8b..e1d1825dddd850a4cea441ce6d7504793003b34f 100644 (file)
@@ -27,7 +27,7 @@
 \g_maplist_votable\Numero di mappe che sono mostrate nel voto delle mappe alla fine di una partita
 \sv_vote_simple_majority_factor\La semplice maggioranza vince il voto
 \XonoticMultiplayerDialog/Impostazioni avanzate...\Impostazioni avanzate del server
-\XonoticMultiplayerDialog/Mutatori...\Mutatori e arene dedicate ad armi
+\XonoticMultiplayerDialog/Mutatori...\Mutatori e arene di armi
 \g_dodging\Abilita schivamento
 \g_cloaked\Tutti i giocatori sono quasi invisibili
 \g_footsteps\Abilita suoni dei passi
@@ -40,7 +40,6 @@
 \g_pinata\I giocatori rilasceranno tutte le armi che possedevano appena vengono uccisi
 \g_weapon_stay\Le armi rimangono dopo che vengono raccolte
 \g_weaponarena\Selezionando un'arena dedicata ad un'arma si darà a tutti i giocatori quell'arma con munizioni infinite, e disabiliterà tutti gli altri raccoglimenti delle armi.
-\menu_weaponarena_with_laser\Abilita anche il laser nelle arene dedicate ad un'arma
 \g_minstagib\Ai giocatori sarà dato il Minstanex, che è un railgun con danni illimitati. Se il giocatore rimane senza munizioni, avrà 10 secondi per trovarne alcune, altrimenti morirà. Il fuoco secondario è un laser che non infligge nessun danno ed è buono per effettuare vari trickjump.
 \g_nix\"No items Xonotic" - invece di raccogliere oggetti, ognuno giocherà con la stessa arma. Dopo un pò di tempo, un conto alla rovescia inizierà, dopo il quale ognuno passerà ad un'altra arma.
 \g_nix_with_laser\Porta sempre il laser come arma aggiuntiva nella modalità "No items Xonotic"