Xonotic
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 text)
 

Function Documentation

◆ makeXonoticTextBox()

entity makeXonoticTextBox ( )

Definition at line 4 of file textbox.qc.

References entity(), and NEW.

Referenced by XonoticServerToSTab_fill().

5 {
6  entity me;
7  me = NEW(XonoticTextBox);
8  me.configureXonoticListBox(me);
9  return me;
10 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 }

◆ XonoticTextBox_drawListBoxItem()

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

Definition at line 86 of file textbox.qc.

References draw_Text(), and vec2.

87 {
88  string s = me.getTextBoxLine(me, i);
89  draw_Text(vec2(0, 0), s, me.realFontSize, me.colorL, me.alpha, true);
90 }
#define vec2(...)
Definition: vector.qh:90
+ Here is the call graph for this function:

◆ XonoticTextBox_getTextBoxLine()

string XonoticTextBox_getTextBoxLine ( entity  me,
int  i 
)

Definition at line 51 of file textbox.qc.

References string_null.

52 {
53  if (me.stringList >= 0)
54  {
55  return bufstr_get(me.stringList, i);
56  }
57  return string_null;
58 }
string string_null
Definition: nil.qh:9

◆ XonoticTextBox_resizeNotify()

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

Definition at line 62 of file textbox.qc.

References strcat(), string_null, and SUPER.

63 {
64  me.itemAbsSize = '0 0 0';
65  SUPER(XonoticTextBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
66 
67  me.itemAbsSize.y = absSize.y * me.itemHeight;
68  me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
69  me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
70  me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
71  string temp = string_null;
72  for (int i = 0; i < me.nItems; ++i)
73  {
74  if (!temp)
75  {
76  temp = me.getTextBoxLine(me, i);
77  }
78  else
79  {
80  temp = strcat(temp, "\n", me.getTextBoxLine(me, i));
81  }
82  }
83  me.setText(me, temp);
84 }
string string_null
Definition: nil.qh:9
#define SUPER(cname)
Definition: oo.qh:219
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:

◆ XonoticTextBox_setText()

void XonoticTextBox_setText ( entity  me,
string  text 
)

Definition at line 21 of file textbox.qc.

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

22 {
23  if (me.stringList >= 0)
24  {
25  buf_del(me.stringList);
26  me.stringList = -1;
27  }
28 
29  int buf;
30  int line = 0;
31 
32  string t;
33 
34  buf = buf_create();
35  for (int i = 0, n = tokenizebyseparator(text, "\n"); i < n; ++i)
36  {
37  t = substring(argv(i), 0, -1);
40  {
41  t = getWrappedLine(1, me.realFontSize, draw_TextWidth_WithColors);
42  bufstr_set(buf, line, t);
43  line++;
44  }
45  }
46 
47  me.stringList = buf;
48  me.nItems = line+1;
49 }
string getWrappedLine_remaining
Definition: util.qh:108
#define buf_create
Definition: dpextensions.qh:63
#define tokenizebyseparator
Definition: dpextensions.qh:21
string getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition: util.qc:880
+ Here is the call graph for this function: