]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow to display tooltips in XonoticRegisteredSettingsList, add tooltip for "Models"
authorterencehill <piuntn@gmail.com>
Wed, 2 Sep 2015 12:26:14 +0000 (14:26 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 2 Sep 2015 12:26:14 +0000 (14:26 +0200)
qcsrc/menu/xonotic/dialog_settings_game.qc
qcsrc/menu/xonotic/dialog_settings_game_model.qc

index 497e1e5e77dff8cd7d163be44f945dd92258e24b..cde5d40a6efd2c9287208eb6c74505667aeb129b 100644 (file)
@@ -12,6 +12,13 @@ CLASS(SettingSource, DataSource)
         if (returns) returns(it.title, string_null);
         return it;
     }
+    METHOD(SettingSource, getEntryTooltip, entity(int i, void(string theTooltip) returns))
+    {
+        Lazy l = SETTINGS[i];
+        entity it = l.m_get();
+        if (returns) returns(it.tooltip);
+        return it;
+    }
     METHOD(SettingSource, reload, int(string filter)) { return SETTINGS_COUNT; }
 ENDCLASS(SettingSource)
 
@@ -30,15 +37,23 @@ CLASS(XonoticRegisteredSettingsList, XonoticListBox)
     ATTRIB(XonoticRegisteredSettingsList, source, DataSource, NULL)
        ATTRIB(XonoticRegisteredSettingsList, onChange, void(entity, entity), func_null)
        ATTRIB(XonoticRegisteredSettingsList, onChangeEntity, entity, NULL)
+       METHOD(XonoticRegisteredSettingsList, focusedItemChangeNotify, void(entity));
+
        string XonoticRegisteredSettingsList_cb_name;
-       void XonoticRegisteredSettingsList_cb(string _name, string _icon)
+       string XonoticRegisteredSettingsList_cb_tooltip;
+       void XonoticRegisteredSettingsList_getNameIcon_cb(string _name, string _icon)
        {
                XonoticRegisteredSettingsList_cb_name = _name;
        }
+       void XonoticRegisteredSettingsList_getTooltip_cb(string _tooltip)
+       {
+               XonoticRegisteredSettingsList_cb_tooltip = _tooltip;
+       }
+
        METHOD(XonoticRegisteredSettingsList, drawListBoxItem, void(entity this, int i, vector absSize, bool isSelected, bool isFocused))
        {
                if (!this.source) return;
-               if (!this.source.getEntry(i, XonoticRegisteredSettingsList_cb)) return;
+               if (!this.source.getEntry(i, XonoticRegisteredSettingsList_getNameIcon_cb)) return;
                string name = XonoticRegisteredSettingsList_cb_name;
                if (isSelected) {
                        draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
@@ -49,6 +64,26 @@ CLASS(XonoticRegisteredSettingsList, XonoticListBox)
                string s = draw_TextShortenToWidth(strdecolorize(name), 1, 0, this.realFontSize);
                draw_Text(this.realUpperMargin * eY + (0.5 * this.realFontSize.x) * eX, s, this.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
        }
+
+       METHOD(XonoticRegisteredSettingsList, focusedItemChangeNotify, void(entity this))
+       {
+               if (this.focusedItem == -1 || !this.source)
+               {
+                       clearTooltip(this);
+                       return;
+               }
+               if (!this.source.getEntryTooltip(this.focusedItem, XonoticRegisteredSettingsList_getTooltip_cb))
+               {
+                       clearTooltip(this);
+                       return;
+               }
+               string theTooltip = XonoticRegisteredSettingsList_cb_tooltip;
+               if(theTooltip != "")
+                       setZonedTooltip(this, theTooltip, string_null);
+               else
+                       clearTooltip(this);
+       }
+
        METHOD(XonoticRegisteredSettingsList, refilter, void(entity this))
        {
                if (!this.source) {
index 17dbdee08fe9059e03a898b476cfddfa3bc6360b..6e2779badf9977a26c41af172ca1f972991f5170 100644 (file)
@@ -5,6 +5,7 @@ CLASS(XonoticGameModelSettingsTab, XonoticTab)
        METHOD(XonoticGameModelSettingsTab, fill, void(entity));
        METHOD(XonoticGameModelSettingsTab, showNotify, void(entity));
        ATTRIB(XonoticGameModelSettingsTab, title, string, _("Models"))
+       ATTRIB(XonoticGameModelSettingsTab, tooltip, string, _("Customize how players and items are displayed in game"))
        ATTRIB(XonoticGameModelSettingsTab, intendedWidth, float, 0.9)
        ATTRIB(XonoticGameModelSettingsTab, rows, float, 13)
        ATTRIB(XonoticGameModelSettingsTab, columns, float, 5)