Xonotic
picker.qc File Reference
#include "picker.qh"
+ Include dependency graph for picker.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

entity makeXonoticPicker ()
 
void XonoticPicker_cellDraw (entity me, vector cell, vector cellPos)
 
bool XonoticPicker_cellIsValid (entity me, vector cell)
 
void XonoticPicker_cellSelect (entity me, vector cell)
 
void XonoticPicker_configureXonoticPicker (entity me)
 
void XonoticPicker_draw (entity me)
 
float XonoticPicker_keyDown (entity me, float key, float ascii, float shift)
 
float XonoticPicker_mouseDrag (entity me, vector coords)
 
float XonoticPicker_mouseMove (entity me, vector coords)
 
float XonoticPicker_mouseRelease (entity me, vector coords)
 
void XonoticPicker_moveFocus (entity me, vector initialCell, vector step)
 

Variables

bool pressed
 

Function Documentation

◆ makeXonoticPicker()

entity makeXonoticPicker ( )

Definition at line 5 of file picker.qc.

References entity(), and NEW.

6 {
7  entity me;
8  me = NEW(XonoticPicker);
9  me.configureXonoticPicker(me);
10  return me;
11 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:

◆ XonoticPicker_cellDraw()

void XonoticPicker_cellDraw ( entity  me,
vector  cell,
vector  cellPos 
)

Definition at line 129 of file picker.qc.

130 {
131 }

◆ XonoticPicker_cellIsValid()

bool XonoticPicker_cellIsValid ( entity  me,
vector  cell 
)

Definition at line 124 of file picker.qc.

125 {
126  return true;
127 }

◆ XonoticPicker_cellSelect()

void XonoticPicker_cellSelect ( entity  me,
vector  cell 
)

Definition at line 119 of file picker.qc.

120 {
121  me.selectedCell = cell;
122 }

◆ XonoticPicker_configureXonoticPicker()

void XonoticPicker_configureXonoticPicker ( entity  me)

Definition at line 13 of file picker.qc.

References eX, and eY.

14 {
15  me.realCellSize = eX / me.columns + eY / me.rows;
16 }
const vector eY
Definition: vector.qh:45
const vector eX
Definition: vector.qh:44

◆ XonoticPicker_draw()

void XonoticPicker_draw ( entity  me)

Definition at line 133 of file picker.qc.

References draw_alpha, draw_Fill(), getFadedAlpha(), mod(), SUPER, and vector().

134 {
135  float save;
136 
137  me.focusable = !me.disabled;
138 
139  save = draw_alpha;
140  if(me.disabled)
141  draw_alpha *= me.disabledAlpha;
142 
143  vector cell, cellPos;
144  cell = '0 0 0';
145  cellPos = '0 0 0';
146 
147  for(cell_y = 0; cell.y < me.rows; ++cell.y)
148  {
149  cellPos_y = mod(cell.y, me.rows) / me.rows;
150  for(cell_x = 0; cell.x < me.columns; ++cell.x)
151  {
152  if(!me.cellIsValid(me, cell))
153  continue;
154 
155  cellPos_x = mod(cell.x, me.columns) / me.columns;
156 
157  if(cell == me.selectedCell)
158  draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
159  else if(cell == me.focusedCell && me.focused)
160  {
161  if(!me.pressed || me.focusedCell == me.pressedCell)
162  {
163  me.focusedCellAlpha = getFadedAlpha(me.focusedCellAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
164  draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_FOCUSED, me.focusedCellAlpha);
165  }
166  }
167 
168  me.cellDraw(me, cell, cellPos);
169  }
170  }
171 
172  draw_alpha = save;
173 
174  SUPER(XonoticPicker).draw(me);
175 }
#define SUPER(cname)
Definition: oo.qh:219
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:

◆ XonoticPicker_keyDown()

float XonoticPicker_keyDown ( entity  me,
float  key,
float  ascii,
float  shift 
)

Definition at line 69 of file picker.qc.

References eX, eY, K_DOWNARROW, K_END, K_ENTER, K_HOME, K_INS, K_KP_DOWNARROW, K_KP_END, K_KP_ENTER, K_KP_HOME, K_KP_INS, K_KP_LEFTARROW, K_KP_RIGHTARROW, K_KP_UPARROW, K_LEFTARROW, K_RIGHTARROW, and K_UPARROW.

70 {
71  switch(key)
72  {
73  case K_END:
74  case K_KP_END:
75  // lower left cell then left arrow to select the last valid cell
76  me.focusedCell = eY * (me.rows - 1);
77  case K_LEFTARROW:
78  case K_KP_LEFTARROW:
79  me.moveFocus(me, me.focusedCell, '-1 0 0');
80  return 1;
81  case K_HOME:
82  case K_KP_HOME:
83  // upper right cell then right arrow to select the first valid cell
84  me.focusedCell = eX * (me.columns - 1);
85  case K_RIGHTARROW:
86  case K_KP_RIGHTARROW:
87  me.moveFocus(me, me.focusedCell, '1 0 0');
88  return 1;
89  case K_UPARROW:
90  case K_KP_UPARROW:
91  me.moveFocus(me, me.focusedCell, '0 -1 0');
92  return 1;
93  case K_DOWNARROW:
94  case K_KP_DOWNARROW:
95  me.moveFocus(me, me.focusedCell, '0 1 0');
96  return 1;
97  case K_ENTER:
98  case K_KP_ENTER:
99  case K_INS:
100  case K_KP_INS:
101  me.cellSelect(me, me.focusedCell);
102  return 1;
103  }
104  return 0;
105 }
float K_KP_RIGHTARROW
Definition: keycodes.qc:60
float K_UPARROW
Definition: keycodes.qc:15
float K_KP_INS
Definition: keycodes.qc:49
const vector eY
Definition: vector.qh:45
float K_DOWNARROW
Definition: keycodes.qc:16
float K_HOME
Definition: keycodes.qc:41
float K_KP_DOWNARROW
Definition: keycodes.qc:53
float K_RIGHTARROW
Definition: keycodes.qc:18
float K_KP_ENTER
Definition: keycodes.qc:74
float K_END
Definition: keycodes.qc:42
const vector eX
Definition: vector.qh:44
float K_KP_HOME
Definition: keycodes.qc:62
float K_LEFTARROW
Definition: keycodes.qc:17
float K_ENTER
Definition: keycodes.qc:8
float K_KP_END
Definition: keycodes.qc:51
float K_INS
Definition: keycodes.qc:37
float K_KP_LEFTARROW
Definition: keycodes.qc:57
float K_KP_UPARROW
Definition: keycodes.qc:64

◆ XonoticPicker_mouseDrag()

float XonoticPicker_mouseDrag ( entity  me,
vector  coords 
)

Definition at line 37 of file picker.qc.

References METHOD, pressed, and vector().

38 {
39  return me.mouseMove(me, coords);
40 }
+ Here is the call graph for this function:

◆ XonoticPicker_mouseMove()

float XonoticPicker_mouseMove ( entity  me,
vector  coords 
)

Definition at line 18 of file picker.qc.

References floor(), and vector().

19 {
20  vector prevFocusedCell = me.focusedCell;
21  me.focusedCell_x = floor(coords.x * me.columns);
22  me.focusedCell_y = floor(coords.y * me.rows);
23 
24  if(me.focusedCell.x < 0 || me.focusedCell.y < 0 ||
25  me.focusedCell.x >= me.columns || me.focusedCell.y >= me.rows)
26  {
27  me.focusedCell = '-1 -1 0';
28  return 0;
29  }
30 
31  if(me.focusedCell != prevFocusedCell)
32  me.focusedCellAlpha = SKINALPHA_LISTBOX_FOCUSED;
33 
34  return 1;
35 }
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:

◆ XonoticPicker_mouseRelease()

float XonoticPicker_mouseRelease ( entity  me,
vector  coords 
)

Definition at line 55 of file picker.qc.

56 {
57  if(!me.pressed)
58  return 0;
59 
60  me.mouseMove(me, coords);
61 
62  if(me.focusedCell == me.pressedCell)
63  me.cellSelect(me, me.focusedCell);
64 
65  me.pressed = 0;
66  return 1;
67 }

◆ XonoticPicker_moveFocus()

void XonoticPicker_moveFocus ( entity  me,
vector  initialCell,
vector  step 
)

Definition at line 107 of file picker.qc.

References mod().

108 {
109  me.focusedCell_x = mod(me.focusedCell.x + step.x + me.columns, me.columns);
110  me.focusedCell_y = mod(me.focusedCell.y + step.y + me.rows, me.rows);
111 
112  if(me.focusedCell != initialCell) // Recursion break
113  if(!me.cellIsValid(me, me.focusedCell))
114  me.moveFocus(me, initialCell, step);
115 
116  me.focusedCellAlpha = SKINALPHA_LISTBOX_FOCUSED;
117 }
+ Here is the call graph for this function:

Variable Documentation

◆ pressed

bool pressed