#ifdef IMPLEMENTATION
+string KEY_NOT_BOUND_CMD = "// not bound";
+
#define MAX_KEYS_PER_FUNCTION 2
#define MAX_KEYBINDS 256
string Xonotic_KeyBinds_Functions[MAX_KEYBINDS];
string s;
Xonotic_KeyBinds_Count = 0;
- fh = fopen("keybinds.txt", FILE_READ);
+ fh = fopen(language_filename("keybinds.txt"), FILE_READ);
if(fh < 0)
return;
while((s = fgets(fh)))
me.configureXonoticKeyBinder(me);
return me;
}
-void configureXonoticKeyBinderXonoticKeyBinder(entity me)
+void XonoticKeyBinder_configureXonoticKeyBinder(entity me)
{
me.configureXonoticListBox(me);
if(Xonotic_KeyBinds_Count < 0)
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);
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;
{
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");
+ localcmd("-zoom\n"); // to make sure we aren't in togglezoom'd state
}
-void editUserbindXonoticKeyBinder(entity me, string theName, string theCommandPress, string theCommandRelease)
+void XonoticKeyBinder_editUserbind(entity me, string theName, string theCommandPress, string theCommandRelease)
{
string func, descr;
{
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("-zoom\n"); // to make sure we aren't in togglezoom'd state
}
-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)
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));
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;
}
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;
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