]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/keybinder.qc
Listbox: highlight item under the cursor
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / keybinder.qc
index a083207715250430fc1a9dd465b66c8c68dca477..75f4e1f7c8238fa3ef300452bd24c7852311cb56 100644 (file)
@@ -1,8 +1,8 @@
 #ifdef INTERFACE
 CLASS(XonoticKeyBinder) EXTENDS(XonoticListBox)
        METHOD(XonoticKeyBinder, configureXonoticKeyBinder, void(entity))
-       ATTRIB(XonoticKeyBinder, rowsPerItem, float, 1)
-       METHOD(XonoticKeyBinder, drawListBoxItem, void(entity, float, vector, float))
+       ATTRIB(XonoticKeyBinder, rowsPerItem, int, 1)
+       METHOD(XonoticKeyBinder, drawListBoxItem, void(entity, int, vector, bool, float))
        METHOD(XonoticKeyBinder, doubleClickListBoxItem, void(entity, float, vector))
        METHOD(XonoticKeyBinder, resizeNotify, void(entity, vector, vector, vector, vector))
        METHOD(XonoticKeyBinder, setSelected, void(entity, float))
@@ -16,7 +16,7 @@ CLASS(XonoticKeyBinder) EXTENDS(XonoticListBox)
        ATTRIB(XonoticKeyBinder, columnKeysOrigin, float, 0)
        ATTRIB(XonoticKeyBinder, columnKeysSize, float, 0)
 
-       ATTRIB(XonoticKeyBinder, previouslySelected, float, -1)
+       ATTRIB(XonoticKeyBinder, previouslySelected, int, -1)
        ATTRIB(XonoticKeyBinder, inMouseHandler, float, 0)
        ATTRIB(XonoticKeyBinder, userbindEditButton, entity, NULL)
        ATTRIB(XonoticKeyBinder, keyGrabButton, entity, NULL)
@@ -34,15 +34,15 @@ void KeyBinder_Bind_Edit(entity btn, entity me);
 
 const string KEY_NOT_BOUND_CMD = "// not bound";
 
-const float MAX_KEYS_PER_FUNCTION = 2;
-const float MAX_KEYBINDS = 256;
+const int MAX_KEYS_PER_FUNCTION = 2;
+const int MAX_KEYBINDS = 256;
 string Xonotic_KeyBinds_Functions[MAX_KEYBINDS];
 string Xonotic_KeyBinds_Descriptions[MAX_KEYBINDS];
-float Xonotic_KeyBinds_Count = -1;
+int Xonotic_KeyBinds_Count = -1;
 
 void Xonotic_KeyBinds_Read()
 {
-       float fh;
+       int fh;
        string s;
 
        Xonotic_KeyBinds_Count = 0;
@@ -71,7 +71,8 @@ entity makeXonoticKeyBinder()
 }
 void replace_bind(string from, string to)
 {
-       float n, j, k;
+       int n, j;
+       float k; // not sure if float or int
        n = tokenize(findkeysforcommand(from, 0)); // uses '...' strings
        for(j = 0; j < n; ++j)
        {
@@ -130,9 +131,10 @@ void KeyBinder_Bind_Change(entity btn, entity me)
        me.clearButton.disabled = 1;
        keyGrabber = me;
 }
-void XonoticKeyBinder_keyGrabbed(entity me, float key, float ascii)
+void XonoticKeyBinder_keyGrabbed(entity me, int key, bool ascii)
 {
-       float n, j, k, nvalid;
+       int n, j, nvalid;
+       float k;
        string func;
 
        me.keyGrabButton.forcePressed = 0;
@@ -249,7 +251,7 @@ void XonoticKeyBinder_doubleClickListBoxItem(entity me, float i, vector where)
 {
        KeyBinder_Bind_Change(NULL, me);
 }
-void XonoticKeyBinder_setSelected(entity me, float i)
+void XonoticKeyBinder_setSelected(entity me, int i)
 {
        // handling of "unselectable" items
        i = floor(0.5 + bound(0, i, me.nItems - 1));
@@ -276,10 +278,9 @@ void XonoticKeyBinder_setSelected(entity me, float i)
                me.userbindEditButton.disabled = (substring(Xonotic_KeyBinds_Descriptions[i], 0, 1) != "$");
        SUPER(XonoticKeyBinder).setSelected(me, i);
 }
-float XonoticKeyBinder_keyDown(entity me, float key, float ascii, float shift)
+float XonoticKeyBinder_keyDown(entity me, int key, bool ascii, float shift)
 {
-       float r;
-       r = 1;
+       bool r = true;
        switch(key)
        {
                case K_ENTER:
@@ -298,10 +299,11 @@ float XonoticKeyBinder_keyDown(entity me, float key, float ascii, float shift)
        }
        return r;
 }
-void XonoticKeyBinder_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
+void XonoticKeyBinder_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime)
 {
        string s;
-       float j, k, n;
+       int j, n;
+       float k;
        vector theColor;
        float theAlpha;
        string func, descr;
@@ -326,6 +328,9 @@ void XonoticKeyBinder_drawListBoxItem(entity me, float i, vector absSize, float
                        else
                                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));
+
                theAlpha = SKINALPHA_KEYGRABBER_KEYS;
                theColor = SKINCOLOR_KEYGRABBER_KEYS;
                extraMargin = me.realFontSize.x * 0.5;