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

Go to the source code of this file.

Functions

string wrapGuideText (string desc, float maxWidth, vector theFontSize)
 wraps text and creates dot point lists from lines starting with "* "
void XonoticGuideDescription_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
void XonoticGuideDescription_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void XonoticGuideDescription_setDescription (entity me, string desc)

Function Documentation

◆ wrapGuideText()

string wrapGuideText ( string desc,
float maxWidth,
vector theFontSize )

wraps text and creates dot point lists from lines starting with "* "

Definition at line 10 of file description.qc.

11{
12 string wrapped = "";
13 bool keep_indenting = false;
14 const int n = tokenizebyseparator(desc, "\n");
15 for (int i = 0; i < n; ++i)
16 {
17 string s, line = "";
19 bool dotpoint = false, indent = false;
20 if (substring(getWrappedLine_remaining, 0, 2) == "* ")
21 {
22 dotpoint = true;
23 // We use Middle Dot (U+00B7) because it has the same width as space
24 // and makes the alignment with wrapped lines perfect.
26 }
27 else if (keep_indenting)
28 {
29 dotpoint = true;
30 indent = true;
31 }
33 {
34 if (indent) // indent lines inside dot point lists
36 s = getWrappedLine(maxWidth, theFontSize, draw_TextWidth_WithColors);
37 indent = dotpoint;
38 line = strcat(line, "\n", s);
39 }
40 wrapped = strcat(wrapped, line);
41
42 // if the current line is indented, the following non-empty lines must be indented too
43 keep_indenting = (indent && i + 1 < n && argv(i+1) != "");
44 }
45 return strcat(wrapped, "\n\n");
46}
string getWrappedLine(float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition util.qc:995
string getWrappedLine_remaining
Definition util.qh:147
#define tokenizebyseparator
float draw_TextWidth_WithColors(string s, vector theFontSize)
Definition draw.qc:391
string substring(string s, float start, float length)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

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

Referenced by XonoticGuideDescription_setDescription().

◆ XonoticGuideDescription_drawListBoxItem()

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

Definition at line 3 of file description.qc.

4{
5 tokenizebyseparator(me.m_descriptionWrapped, "\n");
6 draw_Text(me.keepspaceLeft * eX, argv(i), me.realFontSize, '1 1 1', 1, true);
7}
void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:282
const vector eX
Definition vector.qh:44

References argv(), draw_Text(), entity(), eX, tokenizebyseparator, and vector.

◆ XonoticGuideDescription_resizeNotify()

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

Definition at line 63 of file description.qc.

64{
65 SUPER(XonoticGuideDescription).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 me.keepspaceLeft = me.keepspaceRight = me.realFontSize.x;
72 me.setDescription(me, me.m_description);
73}
#define SUPER(cname)
Definition oo.qh:231

References entity(), SUPER, and vector.

◆ XonoticGuideDescription_setDescription()

void XonoticGuideDescription_setDescription ( entity me,
string desc )

Definition at line 48 of file description.qc.

49{
50 if (me.m_description && me.m_description != desc)
51 strunzone(me.m_description);
52 me.m_description = strzone(desc);
53
54 strfree(me.m_descriptionWrapped);
55
56 const float maxWidth = 1 - me.keepspaceLeft - me.keepspaceRight;
57 me.m_descriptionWrapped = strzone(wrapGuideText(me.m_description, maxWidth, me.realFontSize));
58
59 me.nItems = tokenizebyseparator(me.m_descriptionWrapped, "\n");
60 me.setSelected(me, 0); // reset scrollbar position
61}
string wrapGuideText(string desc, float maxWidth, vector theFontSize)
wraps text and creates dot point lists from lines starting with "* "
void strunzone(string s)
string strzone(string s)
#define strfree(this)
Definition string.qh:59

References entity(), strfree, strunzone(), strzone(), tokenizebyseparator, and wrapGuideText().