From: terencehill Date: Sun, 30 Aug 2015 18:12:54 +0000 (+0200) Subject: Make work tooltips of those special TextSliders that reconfigure their self at runtim... X-Git-Tag: xonotic-v0.8.2~1808^2~21 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=993ac3bc4622f6647b5a3a33a6187aee9d788db7;p=xonotic%2Fxonotic-data.pk3dir.git Make work tooltips of those special TextSliders that reconfigure their self at runtime based on gametype --- diff --git a/qcsrc/menu/xonotic/button.qc b/qcsrc/menu/xonotic/button.qc index 05316c3c3..a9a8fe216 100644 --- a/qcsrc/menu/xonotic/button.qc +++ b/qcsrc/menu/xonotic/button.qc @@ -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 diff --git a/qcsrc/menu/xonotic/checkbox.qc b/qcsrc/menu/xonotic/checkbox.qc index 1925d9c96..88fbfaa2a 100644 --- a/qcsrc/menu/xonotic/checkbox.qc +++ b/qcsrc/menu/xonotic/checkbox.qc @@ -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) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc index a4974ecee..619433068 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc @@ -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; diff --git a/qcsrc/menu/xonotic/gametypebutton.qc b/qcsrc/menu/xonotic/gametypebutton.qc index f7abf0f3f..161c62bfc 100644 --- a/qcsrc/menu/xonotic/gametypebutton.qc +++ b/qcsrc/menu/xonotic/gametypebutton.qc @@ -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; diff --git a/qcsrc/menu/xonotic/inputbox.qc b/qcsrc/menu/xonotic/inputbox.qc index 6b532a0b3..c72339caf 100644 --- a/qcsrc/menu/xonotic/inputbox.qc +++ b/qcsrc/menu/xonotic/inputbox.qc @@ -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) diff --git a/qcsrc/menu/xonotic/radiobutton.qc b/qcsrc/menu/xonotic/radiobutton.qc index ef919d8ad..7e9993924 100644 --- a/qcsrc/menu/xonotic/radiobutton.qc +++ b/qcsrc/menu/xonotic/radiobutton.qc @@ -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) diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 4a74a4ca6..41e11e383 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -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); } } diff --git a/qcsrc/menu/xonotic/slider.qc b/qcsrc/menu/xonotic/slider.qc index 8971c873c..1ffc7c987 100644 --- a/qcsrc/menu/xonotic/slider.qc +++ b/qcsrc/menu/xonotic/slider.qc @@ -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) { diff --git a/qcsrc/menu/xonotic/textslider.qc b/qcsrc/menu/xonotic/textslider.qc index b1c53046e..d55dfc621 100644 --- a/qcsrc/menu/xonotic/textslider.qc +++ b/qcsrc/menu/xonotic/textslider.qc @@ -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) { diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index e0387a0dc..2554759f3 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -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; diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index 22b748d55..2ee8a4d03 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -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);