]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/languagelist.qc
Merge branch 'master' into terencehill/menu_listbox_changes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / languagelist.qc
index 9d217fc514e463a5a6566889f287dde15f9c5c53..4ff17755679258c1404b25954ad56ba0fe0df925 100644 (file)
@@ -1,8 +1,10 @@
-#ifdef INTERFACE
-CLASS(XonoticLanguageList) EXTENDS(XonoticListBox)
+#ifndef LANGUAGELIST_H
+#define LANGUAGELIST_H
+#include "listbox.qc"
+CLASS(XonoticLanguageList, XonoticListBox)
        METHOD(XonoticLanguageList, configureXonoticLanguageList, void(entity))
        ATTRIB(XonoticLanguageList, rowsPerItem, float, 1)
-       METHOD(XonoticLanguageList, drawListBoxItem, void(entity, int, vector, bool, float))
+       METHOD(XonoticLanguageList, drawListBoxItem, void(entity, int, vector, bool, bool))
        METHOD(XonoticLanguageList, resizeNotify, void(entity, vector, vector, vector, vector))
        METHOD(XonoticLanguageList, setSelected, void(entity, float))
        METHOD(XonoticLanguageList, loadCvars, void(entity))
@@ -43,7 +45,7 @@ const float LANGPARM_COUNT = 4;
 entity makeXonoticLanguageList()
 {
        entity me;
-       me = spawnXonoticLanguageList();
+       me = NEW(XonoticLanguageList);
        me.configureXonoticLanguageList(me);
        return me;
 }
@@ -55,13 +57,16 @@ void XonoticLanguageList_configureXonoticLanguageList(entity me)
        me.loadCvars(me);
 }
 
-void XonoticLanguageList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime)
+void XonoticLanguageList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
 {
        string s, p;
        if(isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
-       else if(highlightedTime)
-               draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, getHighlightAlpha(SKINALPHA_LISTBOX_SELECTED * 0.1, highlightedTime));
+       else if(isFocused)
+       {
+               me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
+               draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
+       }
 
        s = me.languageParameter(me, i, LANGPARM_NAME_LOCALIZED);
 
@@ -116,17 +121,17 @@ void XonoticLanguageList_loadCvars(entity me)
        {
                if(me.languageParameter(me, i, LANGPARM_ID) == "en")
                {
-                       me.selectedItem = i;
+                       SUPER(XonoticLanguageList).setSelected(me, i);
                        break;
                }
        }
 
-        // otherwise, find the language
+       // otherwise, find the language
        for(i = 0; i < n; ++i)
        {
                if(me.languageParameter(me, i, LANGPARM_ID) == s)
                {
-                       me.selectedItem = i;
+                       SUPER(XonoticLanguageList).setSelected(me, i);
                        break;
                }
        }