Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
crosshairpicker.qc File Reference
#include "crosshairpicker.qh"
Include dependency graph for crosshairpicker.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

string crosshairpicker_cellToCrosshair (entity me, vector cell)
vector crosshairpicker_crosshairToCell (entity me, string crosshair_str)
entity makeXonoticCrosshairPicker ()
void XonoticCrosshairPicker_cellDraw (entity me, vector cell, vector cellPos)
bool XonoticCrosshairPicker_cellIsValid (entity me, vector cell)
void XonoticCrosshairPicker_cellSelect (entity me, vector cell)
void XonoticCrosshairPicker_configureXonoticCrosshairPicker (entity me)

Function Documentation

◆ crosshairpicker_cellToCrosshair()

string crosshairpicker_cellToCrosshair ( entity me,
vector cell )

Definition at line 3 of file crosshairpicker.qc.

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}
string ftos(float f)

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

Referenced by XonoticCrosshairPicker_cellDraw(), XonoticCrosshairPicker_cellIsValid(), and XonoticCrosshairPicker_cellSelect().

◆ crosshairpicker_crosshairToCell()

vector crosshairpicker_crosshairToCell ( entity me,
string crosshair_str )

Definition at line 10 of file crosshairpicker.qc.

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}
float mod(float val, float m)
float stof(string val,...)
float floor(float f)
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44

References entity(), eX, eY, floor(), mod(), stof(), and vector.

Referenced by XonoticCrosshairPicker_configureXonoticCrosshairPicker().

◆ makeXonoticCrosshairPicker()

entity makeXonoticCrosshairPicker ( )

Definition at line 18 of file crosshairpicker.qc.

19{
20 entity me;
22 me.configureXonoticCrosshairPicker(me);
23 return me;
24}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

Referenced by XonoticCrosshairPicker::cellDraw(), and XonoticGameCrosshairSettingsTab_fill().

◆ XonoticCrosshairPicker_cellDraw()

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

Definition at line 49 of file crosshairpicker.qc.

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}
string crosshairpicker_cellToCrosshair(entity me, vector cell)
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
float cvar(string name)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
vector
Definition self.qh:92

References crosshairpicker_cellToCrosshair(), cvar(), draw_Picture(), draw_PictureSize(), entity(), globalToBoxSize(), strcat(), and vector.

◆ XonoticCrosshairPicker_cellIsValid()

bool XonoticCrosshairPicker_cellIsValid ( entity me,
vector cell )

Definition at line 42 of file crosshairpicker.qc.

43{
44 if(crosshairpicker_cellToCrosshair(me, cell) == "")
45 return false;
46 return true;
47}

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

◆ XonoticCrosshairPicker_cellSelect()

void XonoticCrosshairPicker_cellSelect ( entity me,
vector cell )

Definition at line 36 of file crosshairpicker.qc.

37{
38 cvar_set("crosshair", crosshairpicker_cellToCrosshair(me, me.focusedCell));
39 SUPER(XonoticCrosshairPicker).cellSelect(me, me.focusedCell);
40}
void cvar_set(string name, string value)
#define SUPER(cname)
Definition oo.qh:231

References crosshairpicker_cellToCrosshair(), cvar_set(), entity(), SUPER, and vector.

◆ XonoticCrosshairPicker_configureXonoticCrosshairPicker()

void XonoticCrosshairPicker_configureXonoticCrosshairPicker ( entity me)

Definition at line 26 of file crosshairpicker.qc.

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}
vector crosshairpicker_crosshairToCell(entity me, string crosshair_str)
string draw_PreloadPicture(string pic)
Definition draw.qc:60
const string cvar_string(string name)

References crosshairpicker_crosshairToCell(), cvar_string(), draw_PreloadPicture(), entity(), ftos(), strcat(), and SUPER.