Now that they are correct, allow the use of numpad keys in the menu.
const float K_ALT = 132;
const float K_CTRL = 133;
const float K_SHIFT = 134;
+
const float K_F1 = 135;
const float K_F2 = 136;
const float K_F3 = 137;
const float K_F10 = 144;
const float K_F11 = 145;
const float K_F12 = 146;
+
const float K_INS = 147;
const float K_DEL = 148;
const float K_PGDN = 149;
const float K_HOME = 151;
const float K_END = 152;
-const float K_KP_HOME = 160;
-const float K_KP_UPARROW = 161;
-const float K_KP_PGUP = 162;
-const float K_KP_LEFTARROW = 163;
-const float K_KP_5 = 164;
-const float K_KP_RIGHTARROW = 165;
-const float K_KP_END = 166;
-const float K_KP_DOWNARROW = 167;
-const float K_KP_PGDN = 168;
-const float K_KP_ENTER = 169;
-const float K_KP_INS = 170;
-const float K_KP_DEL = 171;
-const float K_KP_SLASH = 172;
-const float K_KP_MINUS = 173;
-const float K_KP_PLUS = 174;
+const float K_NUMLOCK = 154;
+const float K_CAPSLOCK = 155;
+const float K_SCROLLOCK = 156;
+
+const float K_KP_0 = 157;
+const float K_KP_INS = K_KP_0;
+const float K_KP_1 = 158;
+const float K_KP_END = K_KP_1;
+const float K_KP_2 = 159;
+const float K_KP_DOWNARROW = K_KP_2;
+const float K_KP_3 = 160;
+const float K_KP_PGDN = K_KP_3;
+const float K_KP_4 = 161;
+const float K_KP_LEFTARROW = K_KP_4;
+const float K_KP_5 = 162;
+const float K_KP_6 = 163;
+const float K_KP_RIGHTARROW = K_KP_6;
+const float K_KP_7 = 164;
+const float K_KP_HOME = K_KP_7;
+const float K_KP_8 = 165;
+const float K_KP_UPARROW = K_KP_8;
+const float K_KP_9 = 166;
+const float K_KP_PGUP = K_KP_9;
+const float K_KP_PERIOD = 167;
+const float K_KP_DEL = K_KP_PERIOD;
+const float K_KP_DIVIDE = 168;
+const float K_KP_SLASH = K_KP_DIVIDE;
+const float K_KP_MULTIPLY = 169;
+const float K_KP_MINUS = 170;
+const float K_KP_PLUS = 171;
+const float K_KP_ENTER = 172;
+const float K_KP_EQUALS = 173;
const float K_PAUSE = 255;
}
switch(key)
{
+ case K_KP_LEFTARROW:
case K_LEFTARROW:
me.cursorPos -= 1;
return 1;
+ case K_KP_RIGHTARROW:
case K_RIGHTARROW:
me.cursorPos += 1;
return 1;
+ case K_KP_HOME:
case K_HOME:
me.cursorPos = 0;
return 1;
+ case K_KP_END:
case K_END:
me.cursorPos = strlen(me.text);
return 1;
me.setText(me, strcat(substring(me.text, 0, me.cursorPos), substring(me.text, me.cursorPos + 1, strlen(me.text) - me.cursorPos - 1)));
}
return 1;
+ case K_KP_DEL:
case K_DEL:
if(shift & S_CTRL)
me.setText(me, "");
me.scrollPos = min(me.scrollPos + 0.5, me.nItems * me.itemHeight - 1);
me.setSelected(me, max(me.selectedItem, ceil(me.scrollPos / me.itemHeight)));
}
- else if(key == K_PGUP)
+ else if(key == K_PGUP || key == K_KP_PGUP)
me.setSelected(me, me.selectedItem - 1 / me.itemHeight);
- else if(key == K_PGDN)
+ else if(key == K_PGDN || key == K_KP_PGDN)
me.setSelected(me, me.selectedItem + 1 / me.itemHeight);
- else if(key == K_UPARROW)
+ else if(key == K_UPARROW || key == K_KP_UPARROW)
me.setSelected(me, me.selectedItem - 1);
- else if(key == K_DOWNARROW)
+ else if(key == K_DOWNARROW || key == K_KP_DOWNARROW)
me.setSelected(me, me.selectedItem + 1);
- else if(key == K_HOME)
+ else if(key == K_HOME || key == K_KP_HOME)
{
me.scrollPos = 0;
me.setSelected(me, 0);
}
- else if(key == K_END)
+ else if(key == K_END || key == K_KP_END)
{
me.scrollPos = max(0, me.nItems * me.itemHeight - 1);
me.setSelected(me, me.nItems - 1);
if(me.disabled)
return 0;
inRange = (almost_in_bounds(me.valueMin, me.value, me.valueMax));
- if(key == K_LEFTARROW)
+ if(key == K_LEFTARROW || key == K_KP_LEFTARROW)
{
if(inRange)
me.setValue(me, median(me.valueMin, me.value - me.valueKeyStep, me.valueMax));
me.setValue(me, me.valueMax);
return 1;
}
- if(key == K_RIGHTARROW)
+ if(key == K_RIGHTARROW || key == K_KP_RIGHTARROW)
{
if(inRange)
me.setValue(me, median(me.valueMin, me.value + me.valueKeyStep, me.valueMax));
me.setValue(me, me.valueMin);
return 1;
}
- if(key == K_PGUP)
+ if(key == K_PGUP || key == K_KP_PGUP)
{
if(inRange)
me.setValue(me, median(me.valueMin, me.value - me.valuePageStep, me.valueMax));
me.setValue(me, me.valueMax);
return 1;
}
- if(key == K_PGDN)
+ if(key == K_PGDN || key == K_KP_PGDN)
{
if(inRange)
me.setValue(me, median(me.valueMin, me.value + me.valuePageStep, me.valueMax));
me.setValue(me, me.valueMin);
return 1;
}
- if(key == K_HOME)
+ if(key == K_HOME || key == K_KP_HOME)
{
me.setValue(me, me.valueMin);
return 1;
}
- if(key == K_END)
+ if(key == K_END || key == K_KP_END)
{
me.setValue(me, me.valueMax);
return 1;
switch(key)
{
case K_LEFTARROW:
+ case K_KP_LEFTARROW:
me.selectedCharacterCell = mod(me.selectedCharacterCell + 159, 160);
return 1;
case K_RIGHTARROW:
+ case K_KP_RIGHTARROW:
me.selectedCharacterCell = mod(me.selectedCharacterCell + 1, 160);
return 1;
case K_UPARROW:
+ case K_KP_UPARROW:
me.selectedCharacterCell = mod(me.selectedCharacterCell + 144, 160);
return 1;
case K_DOWNARROW:
+ case K_KP_DOWNARROW:
me.selectedCharacterCell = mod(me.selectedCharacterCell + 16, 160);
return 1;
case K_HOME:
+ case K_KP_HOME:
me.selectedCharacterCell = 0;
return 1;
case K_END:
+ case K_KP_END:
me.selectedCharacterCell = 159;
return 1;
case K_SPACE:
case K_ENTER:
case K_INS:
+ case K_KP_INS:
me.controlledTextbox.enterText(me.controlledTextbox, CharMap_CellToChar(me.selectedCharacterCell));
return 1;
default:
draw_CenterText(me.realUpperMargin * eY + 0.5 * eX, s, me.realFontSize, theColor, theAlpha, 0);
}
-float XonoticCreditsList_keyDown(entity me, float scan, float ascii, float shift)
+float XonoticCreditsList_keyDown(entity me, float key, float ascii, float shift)
{
float i;
me.dragScrollTimer = time;
me.scrolling = 0;
-
- if(scan == K_PGUP)
+ if(key == K_PGUP || key == K_KP_PGUP)
me.scrollPos = max(me.scrollPos - 0.5, 0);
- else if(scan == K_PGDN)
+ else if(key == K_PGDN || key == K_KP_PGDN)
me.scrollPos = min(me.scrollPos + 0.5, me.nItems * me.itemHeight - 1);
- else if(scan == K_UPARROW)
+ else if(key == K_UPARROW || key == K_KP_UPARROW)
me.scrollPos = max(me.scrollPos - me.itemHeight, 0);
- else if(scan == K_DOWNARROW)
+ else if(key == K_DOWNARROW || key == K_KP_DOWNARROW)
me.scrollPos = min(me.scrollPos + me.itemHeight, me.nItems * me.itemHeight - 1);
else
- return SUPER(XonoticCreditsList).keyDown(me, scan, ascii, shift);
+ return SUPER(XonoticCreditsList).keyDown(me, key, ascii, shift);
i = min(me.selectedItem, floor((me.scrollPos + 1) / me.itemHeight - 1));
i = max(i, ceil(me.scrollPos / me.itemHeight));