]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/keybinder.c
fix another typo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / keybinder.c
index c2d124c04113b34fabc35e42754fcfb2f8567a05..1d8dc96425a79ddf7ad2e8e658c9421c0944a835 100644 (file)
@@ -33,6 +33,8 @@ void KeyBinder_Bind_Edit(entity btn, entity me);
 
 #ifdef IMPLEMENTATION
 
+string KEY_NOT_BOUND_COMMAND = "// not bound";
+
 #define MAX_KEYS_PER_FUNCTION 2
 #define MAX_KEYBINDS 256
 string Xonotic_KeyBinds_Functions[MAX_KEYBINDS];
@@ -68,7 +70,7 @@ entity makeXonoticKeyBinder()
        me.configureXonoticKeyBinder(me);
        return me;
 }
-void configureXonoticKeyBinderXonoticKeyBinder(entity me)
+void XonoticKeyBinder_configureXonoticKeyBinder(entity me)
 {
        me.configureXonoticListBox(me);
        if(Xonotic_KeyBinds_Count < 0)
@@ -76,7 +78,7 @@ void configureXonoticKeyBinderXonoticKeyBinder(entity me)
        me.nItems = Xonotic_KeyBinds_Count;
        me.setSelected(me, 0);
 }
-void resizeNotifyXonoticKeyBinder(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+void XonoticKeyBinder_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 {
        SUPER(XonoticKeyBinder).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
 
@@ -103,7 +105,7 @@ void KeyBinder_Bind_Change(entity btn, entity me)
        me.keyGrabButton.forcePressed = 1;
        keyGrabber = me;
 }
-void keyGrabbedXonoticKeyBinder(entity me, float key, float ascii)
+void XonoticKeyBinder_keyGrabbed(entity me, float key, float ascii)
 {
        float n, j, k, nvalid;
        string func;
@@ -130,12 +132,13 @@ void keyGrabbedXonoticKeyBinder(entity me, float key, float ascii)
                {
                        k = stof(argv(j));
                        if(k != -1)
-                               localcmd("\nunbind \"", keynumtostring(k), "\"\n");
+                               //localcmd("\nunbind \"", keynumtostring(k), "\"\n");
+                               localcmd("\nbind \"", keynumtostring(k), "\" \"", KEY_NOT_BOUND_CMD, "\"\n");
                }
        }
        localcmd("\nbind \"", keynumtostring(key), "\" \"", func, "\"\n");
 }
-void editUserbindXonoticKeyBinder(entity me, string theName, string theCommandPress, string theCommandRelease)
+void XonoticKeyBinder_editUserbind(entity me, string theName, string theCommandPress, string theCommandRelease)
 {
        string func, descr;
 
@@ -191,11 +194,12 @@ void KeyBinder_Bind_Clear(entity btn, entity me)
        {
                k = stof(argv(j));
                if(k != -1)
-                       localcmd("\nunbind \"", keynumtostring(k), "\"\n");
+                       //localcmd("\nunbind \"", keynumtostring(k), "\"\n");
+                       localcmd("\nbind \"", keynumtostring(k), "\" \"", KEY_NOT_BOUND_CMD, "\"\n");
        }
 
 }
-void clickListBoxItemXonoticKeyBinder(entity me, float i, vector where)
+void XonoticKeyBinder_clickListBoxItem(entity me, float i, vector where)
 {
        if(i == me.lastClickedServer)
                if(time < me.lastClickedTime + 0.3)
@@ -206,7 +210,7 @@ void clickListBoxItemXonoticKeyBinder(entity me, float i, vector where)
        me.lastClickedServer = i;
        me.lastClickedTime = time;
 }
-void setSelectedXonoticKeyBinder(entity me, float i)
+void XonoticKeyBinder_setSelected(entity me, float i)
 {
        // handling of "unselectable" items
        i = floor(0.5 + bound(0, i, me.nItems - 1));
@@ -233,17 +237,19 @@ void setSelectedXonoticKeyBinder(entity me, float i)
                me.userbindEditButton.disabled = (substring(Xonotic_KeyBinds_Descriptions[i], 0, 1) != "$");
        SUPER(XonoticKeyBinder).setSelected(me, i);
 }
-float keyDownXonoticKeyBinder(entity me, float key, float ascii, float shift)
+float XonoticKeyBinder_keyDown(entity me, float key, float ascii, float shift)
 {
        float r;
        r = 1;
        switch(key)
        {
                case K_ENTER:
+               case K_KP_ENTER:
                case K_SPACE:
                        KeyBinder_Bind_Change(me, me);
                        break;
                case K_DEL:
+               case K_KP_DEL:
                case K_BACKSPACE:
                        KeyBinder_Bind_Clear(me, me);
                        break;
@@ -253,7 +259,7 @@ float keyDownXonoticKeyBinder(entity me, float key, float ascii, float shift)
        }
        return r;
 }
-void drawListBoxItemXonoticKeyBinder(entity me, float i, vector absSize, float isSelected)
+void XonoticKeyBinder_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
 {
        string s;
        float j, k, n;
@@ -297,7 +303,8 @@ void drawListBoxItemXonoticKeyBinder(entity me, float i, vector absSize, float i
                                theAlpha *= SKINALPHA_DISABLED;
        }
 
-       draw_Text(me.realUpperMargin * eY + extraMargin * eX, descr, me.realFontSize, theColor, theAlpha, 0);
+       s = draw_TextShortenToWidth(descr, me.columnFunctionSize, 0, me.realFontSize);
+       draw_Text(me.realUpperMargin * eY + extraMargin * eX, s, me.realFontSize, theColor, theAlpha, 0);
        if(func != "")
        {
                n = tokenize(findkeysforcommand(func)); // uses '...' strings