Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
crosshairpicker.qc
Go to the documentation of this file.
1#include "crosshairpicker.qh"
2
4{
5 if(cell.x < 0 || cell.x >= me.columns || cell.y < 0 || cell.y >= me.rows)
6 return "";
7 return ftos(31 + cell.y * me.columns + cell.x);
8}
9
11{
12 float crosshair = stof(crosshair_str) - 31;
13 if(crosshair - floor(crosshair) > 0)
14 return '-1 -1 0';
15 return mod(crosshair, me.columns) * eX + floor(crosshair / me.columns) * eY;
16}
17
19{
20 entity me;
22 me.configureXonoticCrosshairPicker(me);
23 return me;
24}
25
27{
28 int crosshair_count = me.columns * me.rows;
29 for (int i = 0; i < crosshair_count; ++i)
30 draw_PreloadPicture(strcat("/gfx/crosshair", ftos(31 + i)));
31
32 me.configureXonoticPicker(me);
34}
35
37{
38 cvar_set("crosshair", crosshairpicker_cellToCrosshair(me, me.focusedCell));
39 SUPER(XonoticCrosshairPicker).cellSelect(me, me.focusedCell);
40}
41
43{
44 if(crosshairpicker_cellToCrosshair(me, cell) == "")
45 return false;
46 return true;
47}
48
50{
51 string s = strcat("/gfx/crosshair", crosshairpicker_cellToCrosshair(me, cell));
53 sz = globalToBoxSize(sz, me.size);
54
55 float ar = sz.x / sz.y;
56 sz.x = me.realCellSize.x;
57 sz.y = sz.x / ar;
58 sz *= 0.95;
59
60 vector crosshairPos = cellPos + 0.5 * me.realCellSize;
61 draw_Picture(crosshairPos - 0.5 * sz, s, sz, SKINCOLOR_CROSSHAIRPICKER_CROSSHAIR, SKINALPHA_CROSSHAIRPICKER_CROSSHAIR);
62
63 if(cvar("crosshair_dot"))
64 draw_Picture(crosshairPos - 0.5 * sz * cvar("crosshair_dot_size"), "/gfx/crosshairdot", sz * cvar("crosshair_dot_size"), SKINCOLOR_CROSSHAIRPICKER_CROSSHAIR, SKINALPHA_CROSSHAIRPICKER_CROSSHAIR);
65}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity makeXonoticCrosshairPicker()
bool XonoticCrosshairPicker_cellIsValid(entity me, vector cell)
void XonoticCrosshairPicker_cellDraw(entity me, vector cell, vector cellPos)
void XonoticCrosshairPicker_configureXonoticCrosshairPicker(entity me)
string crosshairpicker_cellToCrosshair(entity me, vector cell)
void XonoticCrosshairPicker_cellSelect(entity me, vector cell)
vector crosshairpicker_crosshairToCell(entity me, string crosshair_str)
void draw_Picture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:72
vector draw_PictureSize(string pic)
Definition draw.qc:80
vector globalToBoxSize(vector v, vector theScale)
Definition draw.qc:38
string draw_PreloadPicture(string pic)
Definition draw.qc:60
float mod(float val, float m)
void cvar_set(string name, string value)
float stof(string val,...)
float cvar(string name)
const string cvar_string(string name)
string ftos(float f)
float floor(float f)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231
vector
Definition self.qh:92
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44