]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make work tooltips of those special TextSliders that reconfigure their self at runtim...
authorterencehill <piuntn@gmail.com>
Sun, 30 Aug 2015 18:12:54 +0000 (20:12 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 30 Aug 2015 18:12:54 +0000 (20:12 +0200)
qcsrc/menu/xonotic/button.qc
qcsrc/menu/xonotic/checkbox.qc
qcsrc/menu/xonotic/dialog_multiplayer_create.qc
qcsrc/menu/xonotic/gametypebutton.qc
qcsrc/menu/xonotic/inputbox.qc
qcsrc/menu/xonotic/radiobutton.qc
qcsrc/menu/xonotic/serverlist.qc
qcsrc/menu/xonotic/slider.qc
qcsrc/menu/xonotic/textslider.qc
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

index 05316c3c3c8a3313b1e2b59474565830a5eb7eee..a9a8fe2160773595473d5e5cb5754c3105396e00 100644 (file)
@@ -45,6 +45,6 @@ void XonoticButton_configureXonoticButton(entity me, string theText, vector theC
                me.colorC = theColor;
                me.colorF = theColor;
        }
-       me.tooltip = strzone(theTooltip);
+       setZonedTooltip(me, theTooltip, string_null);
 }
 #endif
index 1925d9c966ef9476225f0c634c4480b480b98e09..88fbfaa2a77483aa58aedd8a47f1f17057f3ef24 100644 (file)
@@ -79,9 +79,9 @@ void XonoticCheckBox_configureXonoticCheckBox(entity me, float theYesValue, floa
        if(theCvar)
        {
                me.cvarName = theCvar;
-               me.tooltip = getZonedTooltip(theTooltip, theCvar);
                me.loadCvars(me);
        }
+       setZonedTooltip(me, theTooltip, theCvar);
        me.configureCheckBox(me, theText, me.fontSize, me.image);
 }
 void XonoticCheckBox_setChecked(entity me, float val)
index a4974eceebf804e9ae77a6c6a2299206dd8811e2..61943306834959ccabb76577097e0af3b819ec0c 100644 (file)
@@ -21,17 +21,18 @@ entity makeXonoticServerCreateTab();
 
 #ifdef IMPLEMENTATION
 
-void GameType_ConfigureSliders(entity e, entity l, string pLabel, float pMin, float pMax, float pStep, string pCvar)
+void GameType_ConfigureSliders(entity e, entity l, string pLabel, float pMin, float pMax, float pStep, string pCvar, string theTooltip)
 {
        if(pCvar == "")
        {
+               e.cvarName = string_null; // FIXME XonoticTextSlider doesn't clear cvarName in configureXonoticTextSlider as it's not thought to re-configure itself
                e.configureXonoticTextSlider(e, string_null, string_null);
                l.setText(l, pLabel);
                e.disabled = l.disabled = true;
        }
        else
        {
-               e.configureXonoticTextSlider(e, pCvar, "-");
+               e.configureXonoticTextSlider(e, pCvar, theTooltip);
 
                // clear old values
                int i;
@@ -100,14 +101,10 @@ void XonoticServerCreateTab_fill(entity me)
        me.TR(me);
                me.TD(me, 1, 1, me.labelFraglimit = makeXonoticTextLabel(0, _("Frag limit:")));
                me.TD(me, 1, 2, e = me.sliderFraglimit = makeXonoticTextSlider("fraglimit_override"));
-               // TODO add logic to update tooltip. fraglimit_override tooltip:
-               // _("The amount of frags needed before the match will end")
-                       GameType_ConfigureSliders(me.sliderFraglimit, me.labelFraglimit, _("Frag limit:"), 5, 100, 5, "fraglimit_override");
 
        me.gotoRC(me, 15, 0);
                me.TD(me, 1, 1, me.labelTeams = makeXonoticTextLabel(0, _("Teams:")));
                me.TD(me, 1, 2, e = me.sliderTeams = makeXonoticTextSlider(string_null));
-                       // TODO add logic to change the default tooltip: _("The amount of frags needed before the match will end")
                        e.addValue(e, _("Default"), "0");
                        e.addValue(e, _("2 teams"), "2");
                        e.addValue(e, _("3 teams"), "3");
@@ -223,32 +220,35 @@ void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
 
        switch(gt)
        {
-               case MAPINFO_TYPE_CTF:        GameType_ConfigureSliders(e, l, _("Capture limit:"),   1,   20, 1, "capturelimit_override");     break;
-               case MAPINFO_TYPE_DOMINATION: GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "g_domination_point_limit"); break;
-               case MAPINFO_TYPE_KEYHUNT:    GameType_ConfigureSliders(e, l, _("Point limit:"),   200, 1500, 50, "g_keyhunt_point_limit");    break;
-               case MAPINFO_TYPE_LMS:        GameType_ConfigureSliders(e, l, _("Lives:"),           3,   50,  1, "g_lms_lives_override");     break;
-               case MAPINFO_TYPE_RACE:       GameType_ConfigureSliders(e, l, _("Laps:"),            1,   25,  1, "g_race_laps_limit");        break;
-               case MAPINFO_TYPE_NEXBALL:    GameType_ConfigureSliders(e, l, _("Goals:"),           1,   50,  1, "g_nexball_goallimit");      break;
-               case MAPINFO_TYPE_ASSAULT:    GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "");                         break;
-               case MAPINFO_TYPE_ONSLAUGHT:  GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "");                         break;
-               case MAPINFO_TYPE_CTS:        GameType_ConfigureSliders(e, l, _("Point limit:"),    50,  500, 10, "");                         break;
-               case MAPINFO_TYPE_INVASION:   GameType_ConfigureSliders(e, l, _("Point limit:"),     5,    0,  5, "");                         break;
-       case MAPINFO_TYPE_TEAM_DEATHMATCH:GameType_ConfigureSliders(e, l, _("Point limit:"),     5,  100,  5, "g_tdm_point_limit");        break;
-               default:                      GameType_ConfigureSliders(e, l, _("Frag limit:"),      5,  100,  5, "fraglimit_override");       break;
+               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;
        }
 
        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;
-               // TODO add logic to update tooltip
        }
-       e.configureXonoticTextSlider(e, x, string_null);
+       if(!x)
+               e.cvarName = string_null; // FIXME XonoticTextSlider doesn't clear cvarName in configureXonoticTextSlider as it's not thought to re-configure itself
+       e.configureXonoticTextSlider(e, x, theTooltip);
        e.configureXonoticTextSliderValues(e);
        if(!x)
                e.value = 0;
index f7abf0f3fc9449eb3ef8a25096098837e31c134d..161c62bfcb620f9dba827a6b903e166bcf0115b3 100644 (file)
@@ -37,9 +37,9 @@ void XonoticGametypeButton_configureXonoticGametypeButton(entity me, float theGr
        if(theCvar)
        {
                me.cvarName = theCvar;
-               me.tooltip = getZonedTooltip(theTooltip, theCvar);
                me.loadCvars(me);
        }
+       setZonedTooltip(me, theTooltip, theCvar);
        me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
        me.align = 0.5;
        me.onClick = GameTypeButton_Click;
index 6b532a0b32e0d7b3635806b894f7e6b8905aa1fe..c72339caf6e5b12dc6257f64b358c8c31353951d 100644 (file)
@@ -56,9 +56,9 @@ void XonoticInputBox_configureXonoticInputBox(entity me, float doEditColorCodes,
        if(theCvar)
        {
                me.cvarName = theCvar;
-               me.tooltip = getZonedTooltip(theTooltip, theCvar);
                me.loadCvars(me);
        }
+       setZonedTooltip(me, theTooltip, theCvar);
        me.cursorPos = strlen(me.text);
 }
 void XonoticInputBox_focusLeave(entity me)
index ef919d8ad2dc89713c6387badf562cb3f8c1373d..7e999392420a5ae283db81828e6aa8c9fd6eceea 100644 (file)
@@ -43,9 +43,9 @@ void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, s
        if(theCvar)
        {
                me.cvarName = theCvar;
-               me.tooltip = getZonedTooltip(theTooltip, theCvar);
                me.loadCvars(me);
        }
+       setZonedTooltip(me, theTooltip, theCvar);
        me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
 }
 void XonoticRadioButton_setChecked(entity me, float val)
index 4a74a4ca6296a54b54e3b9af3bcea668bb311c4d..41e11e383b77d6b090d58c5983a5a3d9ea708f86 100644 (file)
@@ -437,17 +437,12 @@ void ServerList_Update_favoriteButton(entity btn, entity me)
        if(IsFavorite(me.ipAddressBox.text))
        {
                e.setText(e, _("Remove"));
-               if(e.tooltip)
-               {
-                       strunzone(e.tooltip);
-                       e.tooltip = string_null;
-               }
+               setZonedTooltip(e, string_null, string_null);
        }
        else
        {
                e.setText(e, _("Favorite"));
-               if(!e.tooltip)
-                       e.tooltip = strzone(_("Bookmark the currently highlighted server so that it's faster to find in the future"));
+               setZonedTooltip(e, _("Bookmark the currently highlighted server so that it's faster to find in the future"), string_null);
        }
 }
 
index 8971c873cfb61fde30b38d3d23506779b9b2a349..1ffc7c987e48e6c43735a6264585c41c302cebfd 100644 (file)
@@ -54,11 +54,11 @@ void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float th
                // slider out of bounds to hide the button before loading the cvar
                me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp);
                me.cvarName = theCvar;
-               me.tooltip = getZonedTooltip(theTooltip, theCvar);
                me.loadCvars(me);
        }
        else
                me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
+       setZonedTooltip(me, theTooltip, theCvar);
 }
 void XonoticSlider_setValue(entity me, float val)
 {
index b1c53046ee9c2f7a0307348ce3f0a538b60a1e2c..d55dfc6211528a2392702d89a2b35a501b66593f 100644 (file)
@@ -46,9 +46,9 @@ void XonoticTextSlider_configureXonoticTextSlider(entity me, string theCvar, str
        if(theCvar)
        {
                me.cvarName = theCvar;
-               me.tooltip = getZonedTooltip(theTooltip, theCvar);
                // me.loadCvars(me); // don't load it yet
        }
+       setZonedTooltip(me, theTooltip, theCvar);
 }
 void XonoticTextSlider_setValue(entity me, float val)
 {
index e0387a0dc7c0fcc9bcdf961a3b375c0c7502d9c2..2554759f3ce35422a997d1ef2aad201b974d1932 100644 (file)
@@ -17,21 +17,25 @@ float GL_Have_TextureCompression()
        return (GL_CheckExtension("GL_EXT_texture_compression_s3tc") && GL_CheckExtension("GL_ARB_texture_compression"));
 }
 
-string getZonedTooltip(string theTooltip, string theCvar)
+void setZonedTooltip(entity e, string theTooltip, string theCvar)
 {
-       if(theTooltip == "")
+       if(theTooltip == "") // no tooltip, use cvar description then
        {
                if(theCvar != "" && prvm_language == "en")
                {
                        string t = cvar_description(theCvar);
                        if(t != "" && t != "custom cvar")
-                               return strzone(t);
+                               theTooltip = t;
                }
        }
-       else if(theTooltip != "-")
-               return strzone(theTooltip);
+       else if(theTooltip == "-") // no cvar description as tooltip
+       {
+               theTooltip = string_null;
+       }
 
-       return string_null;
+       if(e.tooltip)
+               strunzone(e.tooltip);
+       e.tooltip = (theTooltip != "") ? strzone(theTooltip) : string_null;
 }
 
 .entity parent, firstChild, nextSibling;
index 22b748d55f2d4fa23d8e8850d804c1142389a562..2ee8a4d03ea563cf52bb6a2481c2939f0dbe611a 100644 (file)
@@ -19,7 +19,7 @@ void setDependentAND3(entity e, string theCvarName, float theCvarMin, float theC
 void setDependentStringNotEqual(entity e, string theCvarName, string theCvarValue);
 void setDependentWeird(entity e, float(entity) func);
 
-string getZonedTooltip(string theTooltip, string theCvar);
+void setZonedTooltip(entity e, string theTooltip, string theCvar);
 
 string resolvemod(string m);