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

Go to the source code of this file.

Functions

entity makeXonoticTextBox ()
void XonoticTextBox_destroy (entity me)
void XonoticTextBox_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
string XonoticTextBox_getTextBoxLine (entity me, int i)
void XonoticTextBox_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void XonoticTextBox_setText (entity me, string txt)

Function Documentation

◆ makeXonoticTextBox()

entity makeXonoticTextBox ( )

Definition at line 4 of file textbox.qc.

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

References entity(), and NEW.

Referenced by XonoticServerToSTab_fill(), XonoticToSDialog_fill(), and XonoticWelcomeDialog_fill().

◆ XonoticTextBox_destroy()

void XonoticTextBox_destroy ( entity me)

Definition at line 11 of file textbox.qc.

12{
13 if (me.stringList >= 0)
14 {
15 buf_del(me.stringList);
16 me.stringList = -1;
17 }
18 strfree(me.text);
19}
#define strfree(this)
Definition string.qh:59

References entity(), and strfree.

◆ XonoticTextBox_drawListBoxItem()

void XonoticTextBox_drawListBoxItem ( entity me,
int i,
vector absSize,
bool isSelected,
bool isFocused )

Definition at line 76 of file textbox.qc.

77{
78 string s = me.getTextBoxLine(me, i);
79 vector color = (me.allowColors) ? '1 1 1' : me.colorL;
80 if (me.align == 0.5)
81 draw_CenterText(0.5 * eX, s, me.realFontSize, color, 1, me.allowColors);
82 else
83 draw_Text(vec2(0, 0), s, me.realFontSize, color, me.alpha, me.allowColors);
84}
vector color
Definition dynlight.qc:15
void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:282
void draw_CenterText(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:298
vector
Definition self.qh:92
const vector eX
Definition vector.qh:44
#define vec2(...)
Definition vector.qh:90

References color, draw_CenterText(), draw_Text(), entity(), eX, vec2, and vector.

◆ XonoticTextBox_getTextBoxLine()

string XonoticTextBox_getTextBoxLine ( entity me,
int i )

Definition at line 55 of file textbox.qc.

56{
57 if (me.stringList >= 0)
58 {
59 return bufstr_get(me.stringList, i);
60 }
61 return string_null;
62}
string string_null
Definition nil.qh:9

References entity(), and string_null.

◆ XonoticTextBox_resizeNotify()

void XonoticTextBox_resizeNotify ( entity me,
vector relOrigin,
vector relSize,
vector absOrigin,
vector absSize )

Definition at line 64 of file textbox.qc.

65{
66 me.itemAbsSize = '0 0 0';
67 SUPER(XonoticTextBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
68
69 me.itemAbsSize.y = absSize.y * me.itemHeight;
70 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
71 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
72 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
73 me.setText(me, strcat(me.text)); // rewrap
74}
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define SUPER(cname)
Definition oo.qh:231

References entity(), strcat(), SUPER, and vector.

◆ XonoticTextBox_setText()

void XonoticTextBox_setText ( entity me,
string txt )

Definition at line 21 of file textbox.qc.

22{
23 if (me.stringList >= 0)
24 {
25 buf_del(me.stringList);
26 me.stringList = -1;
27 }
28
29 strcpy(me.text, txt);
30
31 int buf;
32 int line = 0;
33
34 string t;
35
36 buf = buf_create();
37 string separator = (me.escapedNewLines) ? "\\n" : "\n";
38 for (int i = 0, n = tokenizebyseparator(txt, separator); i < n; ++i)
39 {
40 t = substring(argv(i), 0, -1);
43 {
44 t = getWrappedLine(1 - me.controlWidth, me.realFontSize,
46 bufstr_set(buf, line, t);
47 ++line;
48 }
49 }
50
51 me.stringList = buf;
52 me.nItems = line+1;
53}
string getWrappedLine(float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition util.qc:1131
string getWrappedLine_remaining
Definition util.qh:147
#define tokenizebyseparator
#define buf_create
float draw_TextWidth_WithoutColors(string s, vector theFontSize)
Definition draw.qc:397
float draw_TextWidth_WithColors(string s, vector theFontSize)
Definition draw.qc:392
string substring(string s, float start, float length)
string argv(float n)
#define strcpy(this, s)
Definition string.qh:52

References argv(), buf_create, draw_TextWidth_WithColors(), draw_TextWidth_WithoutColors(), entity(), getWrappedLine(), getWrappedLine_remaining, strcpy, substring(), and tokenizebyseparator.