Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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.

6{
8 me.configureXonoticPicker(me);
9 return me;
10}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

◆ XonoticPicker_cellDraw()

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

Definition at line 128 of file picker.qc.

129{
130}

References entity(), and vector.

◆ XonoticPicker_cellIsValid()

bool XonoticPicker_cellIsValid ( entity me,
vector cell )

Definition at line 123 of file picker.qc.

124{
125 return true;
126}

References entity(), and vector.

◆ XonoticPicker_cellSelect()

void XonoticPicker_cellSelect ( entity me,
vector cell )

Definition at line 118 of file picker.qc.

119{
120 me.selectedCell = cell;
121}

References entity(), and vector.

◆ XonoticPicker_configureXonoticPicker()

void XonoticPicker_configureXonoticPicker ( entity me)

Definition at line 12 of file picker.qc.

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

References entity(), eX, and eY.

◆ XonoticPicker_draw()

void XonoticPicker_draw ( entity me)

Definition at line 132 of file picker.qc.

133{
134 float save;
135
136 me.focusable = !me.disabled;
137
138 save = draw_alpha;
139 if(me.disabled)
140 draw_alpha *= me.disabledAlpha;
141
142 vector cell, cellPos;
143 cell = '0 0 0';
144 cellPos = '0 0 0';
145
146 for(cell_y = 0; cell.y < me.rows; ++cell.y)
147 {
148 cellPos_y = mod(cell.y, me.rows) / me.rows;
149 for(cell_x = 0; cell.x < me.columns; ++cell.x)
150 {
151 if(!me.cellIsValid(me, cell))
152 continue;
153
154 cellPos_x = mod(cell.x, me.columns) / me.columns;
155
156 if(cell == me.selectedCell)
157 draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
158 else if(cell == me.focusedCell && me.focused)
159 {
160 if(!me.pressed || me.focusedCell == me.pressedCell)
161 {
162 me.focusedCellAlpha = getFadedAlpha(me.focusedCellAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
163 draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_FOCUSED, me.focusedCellAlpha);
164 }
165 }
166
167 me.cellDraw(me, cell, cellPos);
168 }
169 }
170
171 draw_alpha = save;
172
173 SUPER(XonoticPicker).draw(me);
174}
void draw_Fill(vector theOrigin, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:97
float draw_alpha
Definition draw.qh:9
float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
Definition util.qc:816
float mod(float val, float m)
#define SUPER(cname)
Definition oo.qh:231
vector
Definition self.qh:92

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

◆ XonoticPicker_keyDown()

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

Definition at line 68 of file picker.qc.

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

References entity(), 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.

◆ XonoticPicker_mouseDrag()

float XonoticPicker_mouseDrag ( entity me,
vector coords )

Definition at line 36 of file picker.qc.

37{
38 return me.mouseMove(me, coords);
39}

References entity(), and vector.

◆ XonoticPicker_mouseMove()

float XonoticPicker_mouseMove ( entity me,
vector coords )

Definition at line 17 of file picker.qc.

18{
19 vector prevFocusedCell = me.focusedCell;
20 me.focusedCell_x = floor(coords.x * me.columns);
21 me.focusedCell_y = floor(coords.y * me.rows);
22
23 if(me.focusedCell.x < 0 || me.focusedCell.y < 0 ||
24 me.focusedCell.x >= me.columns || me.focusedCell.y >= me.rows)
25 {
26 me.focusedCell = '-1 -1 0';
27 return 0;
28 }
29
30 if(me.focusedCell != prevFocusedCell)
31 me.focusedCellAlpha = SKINALPHA_LISTBOX_FOCUSED;
32
33 return 1;
34}
float floor(float f)

References entity(), floor(), and vector.

◆ XonoticPicker_mouseRelease()

float XonoticPicker_mouseRelease ( entity me,
vector coords )

Definition at line 54 of file picker.qc.

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

References entity(), and vector.

◆ XonoticPicker_moveFocus()

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

Definition at line 106 of file picker.qc.

107{
108 me.focusedCell_x = mod(me.focusedCell.x + step.x + me.columns, me.columns);
109 me.focusedCell_y = mod(me.focusedCell.y + step.y + me.rows, me.rows);
110
111 if(me.focusedCell != initialCell) // Recursion break
112 if(!me.cellIsValid(me, me.focusedCell))
113 me.moveFocus(me, initialCell, step);
114
115 me.focusedCellAlpha = SKINALPHA_LISTBOX_FOCUSED;
116}

References entity(), mod(), and vector.

Variable Documentation

◆ pressed

bool pressed

Definition at line 3 of file picker.qc.

Referenced by XonoticPicker::mousePress().