]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
When fraglimit and teams sliders can't be configured for a certain gametype show... 256/head
authorterencehill <piuntn@gmail.com>
Sun, 15 Nov 2015 14:02:54 +0000 (15:02 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 15 Nov 2015 14:02:54 +0000 (15:02 +0100)
GameType_ConfigureSliders now really configures both fraglimit and teams sliders, not just the former

qcsrc/menu/item/slider.qc
qcsrc/menu/xonotic/dialog_multiplayer_create.qc

index f065e34b18071f8173c567469ab6a83586782f8c..e3220f57d9d49c392d8f6a8fa036bb1fb24091c0 100644 (file)
                save = draw_alpha;
                if (me.disabled) draw_alpha *= me.disabledAlpha;
                draw_ButtonPicture('0 0 0', strcat(me.src, "_s"), eX * (1 - me.textSpace) + eY, me.color2, 1);
+               if (me.valueMax > me.valueMin) // valid?
                if (almost_in_bounds(me.valueMin, me.sliderValue, me.valueMax))
                {
                        controlLeft = (me.sliderValue - me.valueMin) / (me.valueMax - me.valueMin) * (1 - me.textSpace - me.controlWidth);
                                me.sliderAnim = NULL;
                        }
 
-               me.setText(me, me.valueToText(me, me.value));
+               if (me.valueMax > me.valueMin) // valid?
+                       me.setText(me, me.valueToText(me, me.value));
                draw_alpha = save;
                SUPER(Slider).draw(me);
                me.text = string_null;  // TEMPSTRING!
index eeab84e363b4cf4098b9635f2c972c3edeee71fb..f165d992381c1df1b52767a132e5de513fed9925 100644 (file)
@@ -21,37 +21,47 @@ entity makeXonoticServerCreateTab();
 
 #ifdef IMPLEMENTATION
 
-void GameType_ConfigureSliders(entity e, entity l, string pLabel, float pMin, float pMax, float pStep, string pCvar, string theTooltip)
+void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
 {
-       if(pCvar == "")
+       int i;
+       entity e = me.sliderFraglimit;
+       entity l = me.labelFraglimit;
+       e.configureXonoticTextSlider(e, pCvar, pTooltip);
+       e.disabled = l.disabled = !pCvar;
+       l.setText(l, pLabel);
+
+       // clear old values
+       for(i = 0; i < e.nValues; ++i);
        {
-               e.configureXonoticTextSlider(e, string_null, string_null);
-               l.setText(l, pLabel);
-               e.disabled = l.disabled = true;
-       }
-       else
-       {
-               e.configureXonoticTextSlider(e, pCvar, theTooltip);
-
-               // clear old values
-               int i;
-               for(i = 0; i <= e.nValues; ++i);
+               if(e.(valueStrings[i]))
+               {
+                       strunzone(e.(valueStrings[i]));
+                       e.(valueStrings[i]) = string_null;
+               }
+               if(e.(valueIdentifiers[i]))
                {
-                       if(e.(valueStrings[i])) { strunzone(e.(valueStrings[i])); }
-                       if(e.(valueIdentifiers[i])) { strunzone(e.(valueIdentifiers[i])); }
+                       strunzone(e.(valueIdentifiers[i]));
+                       e.(valueIdentifiers[i]) = string_null;
                }
-               e.clearValues(e);
+       }
+       e.clearValues(e);
 
+       if(pCvar != "")
+       {
                // set new values
                e.addValue(e, strzone(_("Default")), strzone("-1"));
                for(i = pMin; i <= pMax; i += pStep) { e.addValue(e, strzone(ftos(i)), strzone(ftos(i))); }
                e.addValue(e, strzone(_("Unlimited")), strzone("0"));
-               e.configureXonoticTextSliderValues(e);
-
-               // set text field
-               l.setText(l, pLabel);
-               e.disabled = l.disabled = false;
        }
+       e.configureXonoticTextSliderValues(e);
+
+
+       entity t = me.sliderTeams;
+       entity tl = me.labelTeams;
+       t.configureXonoticTextSlider(t, tCvar, string_null);
+       tl.disabled = t.disabled = !tCvar;
+       t.nValues = (tCvar == "") ? 0 : 4; // instead of clearing / readding the very same values
+       t.configureXonoticTextSliderValues(t);
 }
 
 entity makeXonoticServerCreateTab()
@@ -212,45 +222,24 @@ void XonoticServerCreateTab_fill(entity me)
 
 void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
 {
-       // tell the map list to update
-       float gt;
-       entity e, l;
-       gt = MapInfo_CurrentGametype();
-       e = me.sliderFraglimit;
-       l = me.labelFraglimit;
-
-       switch(gt)
+       switch(MapInfo_CurrentGametype())
        {
-               case MAPINFO_TYPE_CTF:            GameType_ConfigureSliders(e, l, _("Capture limit:"),   1,   20, 1,  "capturelimit_override", string_null); break;
-               case MAPINFO_TYPE_DOMINATION:     GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "g_domination_point_limit", string_null); break;
-               case MAPINFO_TYPE_KEYHUNT:        GameType_ConfigureSliders(e, l, _("Point limit:"),   200, 1500, 50, "g_keyhunt_point_limit", string_null); break;
-               case MAPINFO_TYPE_LMS:            GameType_ConfigureSliders(e, l, _("Lives:"),           3,   50,  1, "g_lms_lives_override", string_null); break;
-               case MAPINFO_TYPE_RACE:           GameType_ConfigureSliders(e, l, _("Laps:"),            1,   25,  1, "g_race_laps_limit", string_null); break;
-               case MAPINFO_TYPE_NEXBALL:        GameType_ConfigureSliders(e, l, _("Goals:"),           1,   50,  1, "g_nexball_goallimit", string_null); break;
-               case MAPINFO_TYPE_ASSAULT:        GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "", string_null); break;
-               case MAPINFO_TYPE_ONSLAUGHT:      GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "", string_null); break;
-               case MAPINFO_TYPE_CTS:            GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "", string_null); break;
-               case MAPINFO_TYPE_INVASION:       GameType_ConfigureSliders(e, l, _("Point limit:"),     5,    0,  5, "", string_null); break;
-               case MAPINFO_TYPE_TEAM_DEATHMATCH:GameType_ConfigureSliders(e, l, _("Point limit:"),     5,  100,  5, "g_tdm_point_limit", string_null); break;
-               default:                          GameType_ConfigureSliders(e, l, _("Frag limit:"),      5,  100,  5, "fraglimit_override", _("The amount of frags needed before the match will end")); break;
+               case MAPINFO_TYPE_CA:              GameType_ConfigureSliders(me, _("Frag limit:"),      5,  100,  5, "fraglimit_override",        "g_ca_teams_override",          _("The amount of frags needed before the match will end")); break;
+               case MAPINFO_TYPE_FREEZETAG:       GameType_ConfigureSliders(me, _("Frag limit:"),      5,  100,  5, "fraglimit_override",        "g_freezetag_teams_override",   _("The amount of frags needed before the match will end")); break;
+               case MAPINFO_TYPE_CTF:             GameType_ConfigureSliders(me, _("Capture limit:"),   1,   20,  1, "capturelimit_override",     string_null,                    _("The amount of captures needed before the match will end")); break;
+               case MAPINFO_TYPE_DOMINATION:      GameType_ConfigureSliders(me, _("Point limit:"),    50,  500, 10, "g_domination_point_limit",  "g_domination_teams_override",  _("The amount of points needed before the match will end")); break;
+               case MAPINFO_TYPE_KEYHUNT:         GameType_ConfigureSliders(me, _("Point limit:"),   200, 1500, 50, "g_keyhunt_point_limit",     "g_keyhunt_teams_override",     _("The amount of points needed before the match will end")); break;
+               case MAPINFO_TYPE_LMS:             GameType_ConfigureSliders(me, _("Lives:"),           3,   50,  1, "g_lms_lives_override",      string_null,                    string_null); break;
+               case MAPINFO_TYPE_RACE:            GameType_ConfigureSliders(me, _("Laps:"),            1,   25,  1, "g_race_laps_limit",         string_null,                    string_null); break;
+               case MAPINFO_TYPE_NEXBALL:         GameType_ConfigureSliders(me, _("Goals:"),           1,   50,  1, "g_nexball_goallimit",       string_null,                    _("The amount of goals needed before the match will end")); break;
+               case MAPINFO_TYPE_ASSAULT:         GameType_ConfigureSliders(me, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null); break;
+               case MAPINFO_TYPE_ONSLAUGHT:       GameType_ConfigureSliders(me, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null); break;
+               case MAPINFO_TYPE_CTS:             GameType_ConfigureSliders(me, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null); break;
+               case MAPINFO_TYPE_INVASION:        GameType_ConfigureSliders(me, _("Point limit:"),    50,  500, 10, string_null,                 string_null,                    string_null); break;
+               case MAPINFO_TYPE_TEAM_DEATHMATCH: GameType_ConfigureSliders(me, _("Point limit:"),     5,  100,  5, "g_tdm_point_limit",         "g_tdm_teams_override",         _("The amount of points needed before the match will end")); break;
+               default:                           GameType_ConfigureSliders(me, _("Frag limit:"),      5,  100,  5, "fraglimit_override",        string_null,                    _("The amount of frags needed before the match will end")); break;
        }
 
-       string x = string_null;
-       string theTooltip = string_null;
-       e = me.sliderTeams;
-       switch(gt)
-       {
-               // old tooltip: _("Override the default amount of teams in teamgames")
-               case MAPINFO_TYPE_CA:               x = "g_ca_teams_override";          break;
-               case MAPINFO_TYPE_DOMINATION:       x = "g_domination_teams_override";  break;
-               case MAPINFO_TYPE_FREEZETAG:        x = "g_freezetag_teams_override";   break;
-               case MAPINFO_TYPE_KEYHUNT:          x = "g_keyhunt_teams_override";     break;
-               case MAPINFO_TYPE_TEAM_DEATHMATCH:  x = "g_tdm_teams_override";         break;
-       }
-       e.configureXonoticTextSlider(e, x, theTooltip);
-       e.configureXonoticTextSliderValues(e);
-       me.sliderTeams.disabled = me.labelTeams.disabled = !x;
-
        me.mapListBox.refilter(me.mapListBox);
 }