-#ifdef INTERFACE
-CLASS(XonoticPicker) EXTENDS(Item)
- METHOD(XonoticPicker, configureXonoticPicker, void(entity))
- METHOD(XonoticPicker, mousePress, float(entity, vector))
- METHOD(XonoticPicker, mouseRelease, float(entity, vector))
- METHOD(XonoticPicker, mouseMove, float(entity, vector))
- METHOD(XonoticPicker, mouseDrag, float(entity, vector))
- METHOD(XonoticPicker, keyDown, float(entity, float, float, float))
- METHOD(XonoticPicker, draw, void(entity))
- ATTRIB(XonoticPicker, focusable, float, 1)
- ATTRIB(XonoticPicker, disabled, float, 0)
- ATTRIB(XonoticPicker, alpha, float, 1)
- ATTRIB(XonoticPicker, disabledAlpha, float, SKINALPHA_DISABLED)
-
- ATTRIB(XonoticPicker, rows, float, 3)
- ATTRIB(XonoticPicker, columns, float, 2)
-
- METHOD(XonoticPicker, moveFocus, void(entity, vector, vector))
- METHOD(XonoticPicker, cellSelect, void(entity, vector))
- METHOD(XonoticPicker, cellDraw, void(entity, vector, vector, float))
- METHOD(XonoticPicker, cellIsValid, bool(entity, vector))
- ATTRIB(XonoticPicker, realCellSize, vector, '0 0 0')
- ATTRIB(XonoticPicker, selectedCell, vector, '-1 -1 0')
- ATTRIB(XonoticPicker, focusedCell, vector, '-1 -1 0')
- ATTRIB(XonoticPicker, focusedCellTime, float, 0)
- ATTRIB(XonoticPicker, pressedCell, vector, '-1 -1 0')
-ENDCLASS(XonoticPicker)
-entity makeXonoticPicker();
-#endif
-
-#ifdef IMPLEMENTATION
+#include "picker.qh"
+
+.bool pressed;
entity makeXonoticPicker()
{
entity me;
- me = spawnXonoticPicker();
+ me = NEW(XonoticPicker);
me.configureXonoticPicker(me);
return me;
}
}
if(me.focusedCell != prevFocusedCell)
- me.focusedCellTime = time;
+ me.focusedCellAlpha = SKINALPHA_LISTBOX_FOCUSED;
return 1;
}
{
switch(key)
{
+ case K_END:
+ case K_KP_END:
+ // lower left cell then left arrow to select the last valid cell
+ me.focusedCell = eY * (me.rows - 1);
case K_LEFTARROW:
case K_KP_LEFTARROW:
me.moveFocus(me, me.focusedCell, '-1 0 0');
return 1;
+ case K_HOME:
+ case K_KP_HOME:
+ // upper right cell then right arrow to select the first valid cell
+ me.focusedCell = eX * (me.columns - 1);
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
me.moveFocus(me, me.focusedCell, '1 0 0');
case K_KP_DOWNARROW:
me.moveFocus(me, me.focusedCell, '0 1 0');
return 1;
- case K_HOME:
- case K_KP_HOME:
- me.focusedCell = '0 0 0';
- return 1;
- case K_END:
- case K_KP_END:
- me.focusedCell_x = me.columns - 1;
- me.focusedCell_y = me.rows - 1;
- return 1;
case K_ENTER:
case K_KP_ENTER:
case K_INS:
if(me.focusedCell != initialCell) // Recursion break
if(!me.cellIsValid(me, me.focusedCell))
me.moveFocus(me, initialCell, step);
+
+ me.focusedCellAlpha = SKINALPHA_LISTBOX_FOCUSED;
}
void XonoticPicker_cellSelect(entity me, vector cell)
return true;
}
-void XonoticPicker_cellDraw(entity me, vector cell, vector cellPos, float highlightTime)
+void XonoticPicker_cellDraw(entity me, vector cell, vector cellPos)
{
}
else if(cell == me.focusedCell && me.focused)
{
if(!me.pressed || me.focusedCell == me.pressedCell)
- draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, me.focusedCellTime));
+ {
+ me.focusedCellAlpha = getFadedAlpha(me.focusedCellAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
+ draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_FOCUSED, me.focusedCellAlpha);
+ }
}
- me.cellDraw(me, cell, cellPos, (me.focusedCell == cell) ? me.focusedCellTime : 0);
+ me.cellDraw(me, cell, cellPos);
}
}
SUPER(XonoticPicker).draw(me);
}
-#endif