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{
6 entity me;
8 me.configureXonoticListBox(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.

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

◆ XonoticTextBox_destroy()

void XonoticTextBox_destroy ( entity me)

Definition at line 12 of file textbox.qc.

13{
14 if (me.stringList >= 0)
15 {
16 buf_del(me.stringList);
17 me.stringList = -1;
18 }
19 strfree(me.text);
20}
#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 77 of file textbox.qc.

78{
79 string s = me.getTextBoxLine(me, i);
80 vector color = (me.allowColors) ? '1 1 1' : me.colorL;
81 if (me.align == 0.5)
82 draw_CenterText(0.5 * eX, s, me.realFontSize, color, 1, me.allowColors);
83 else
84 draw_Text(vec2(0, 0), s, me.realFontSize, color, me.alpha, me.allowColors);
85}
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 56 of file textbox.qc.

57{
58 if (me.stringList >= 0)
59 {
60 return bufstr_get(me.stringList, i);
61 }
62 return string_null;
63}
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 65 of file textbox.qc.

66{
67 me.itemAbsSize = '0 0 0';
68 SUPER(XonoticTextBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
69
70 me.itemAbsSize.y = absSize.y * me.itemHeight;
71 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
72 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
73 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
74 me.setText(me, strcat(me.text)); // rewrap
75}
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 22 of file textbox.qc.

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