Xonotic
demolist.qc File Reference
#include "demolist.qh"
#include "inputbox.qh"
+ Include dependency graph for demolist.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void DemoConfirm_ListClick_Check_Gamestatus (entity me)
 
void DemoList_Filter_Change (entity box, entity me)
 
void DemoList_Refresh_Click (entity btn, entity me)
 
void getDemos_for_ext (entity me, string ext, float subdir)
 
entity makeXonoticDemoList ()
 
void XonoticDemoList_configureXonoticDemoList (entity me)
 
string XonoticDemoList_demoName (entity me, float i)
 
void XonoticDemoList_destroy (entity me)
 
void XonoticDemoList_doubleClickListBoxItem (entity me, float i, vector where)
 
void XonoticDemoList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
 
void XonoticDemoList_getDemos (entity me)
 
float XonoticDemoList_keyDown (entity me, float scan, float ascii, float shift)
 
void XonoticDemoList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
void XonoticDemoList_showNotify (entity me)
 
void XonoticDemoList_startDemo (entity me)
 
void XonoticDemoList_timeDemo (entity me)
 

Function Documentation

◆ DemoConfirm_ListClick_Check_Gamestatus()

void DemoConfirm_ListClick_Check_Gamestatus ( entity  me)

Definition at line 167 of file demolist.qc.

References boxToGlobal(), boxToGlobalSize(), DialogOpenButton_Click_withCoords(), eX, eY, GAME_CONNECTED, GAME_ISSERVER, gamestatus, and main.

Referenced by XonoticDemoList_doubleClickListBoxItem(), and XonoticDemoList_keyDown().

168 {
169  if(!(gamestatus & (GAME_CONNECTED | GAME_ISSERVER))) // we're not in a match, lets watch the demo
170  {
171  me.startDemo(me);
172  }
173  else // already in a match, player has to confirm
174  {
176  me,
177  main.demostartconfirmDialog,
178  boxToGlobal(eY * (me.selectedItem * me.itemHeight - me.scrollPos), me.origin, me.size),
179  boxToGlobalSize(eY * me.itemHeight + eX * (1 - me.controlWidth), me.size)
180  );
181  }
182 }
const vector eY
Definition: vector.qh:45
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
const vector eX
Definition: vector.qh:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DemoList_Filter_Change()

void DemoList_Filter_Change ( entity  box,
entity  me 
)

Definition at line 132 of file demolist.qc.

References strcat(), strfree, string_null, strstrofs, and strzone().

133 {
134  strfree(me.filterString);
135 
136  if(box.text != "")
137  {
138  if (strstrofs(box.text, "*", 0) >= 0 || strstrofs(box.text, "?", 0) >= 0)
139  me.filterString = strzone(box.text);
140  else
141  me.filterString = strzone(strcat("*", box.text, "*"));
142  }
143  else
144  me.filterString = string_null;
145 
146  me.getDemos(me);
147 }
string string_null
Definition: nil.qh:9
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"))
#define strstrofs
Definition: dpextensions.qh:42
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:

◆ DemoList_Refresh_Click()

void DemoList_Refresh_Click ( entity  btn,
entity  me 
)

Definition at line 126 of file demolist.qc.

127 {
128  me.getDemos(me);
129  me.setSelected(me, 0); //always select the first element after a list update
130 }

◆ getDemos_for_ext()

void getDemos_for_ext ( entity  me,
string  ext,
float  subdir 
)

Definition at line 31 of file demolist.qc.

References rgb_to_hexcolor(), search_begin(), search_end(), search_getfilename(), search_getsize(), strcat(), strlen(), and substring().

Referenced by XonoticDemoList_getDemos().

32 {
33  string s;
34  if (subdir)
35  s="demos/*/";
36  else
37  s="demos/";
38  if(me.filterString)
39  s=strcat(s, me.filterString, ext);
40  else
41  s=strcat(s, "*", ext);
42 
43  float list, i, n;
44  list = search_begin(s, false, true);
45  if(list >= 0)
46  {
47  n = search_getsize(list);
48  for(i = 0; i < n; ++i)
49  {
50  s = search_getfilename(list, i); // get initial full file name
51  s = substring(s, 6, (strlen(s) - 6 - 4)); // remove "demos/" prefix and ".dem" suffix
52  s = strdecolorize(s); // remove any pre-existing colors
53  if(subdir)
54  {
55  s = strreplace("/", "^7/", s); // clear colors at the forward slash
56  s = strcat("/", rgb_to_hexcolor(SKINCOLOR_DEMOLIST_SUBDIR), s); // add a forward slash for sorting, then color
57  bufstr_add(me.listDemo, s, true);
58  }
59  else { bufstr_add(me.listDemo, s, true); }
60  }
61  search_end(list);
62  }
63 
64  if (subdir)
65  getDemos_for_ext(me, ext, false);
66 }
void getDemos_for_ext(entity me, string ext, float subdir)
Definition: demolist.qc:31
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"))
ERASEABLE string rgb_to_hexcolor(vector rgb)
Definition: color.qh:183
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticDemoList()

entity makeXonoticDemoList ( )

Definition at line 5 of file demolist.qc.

References entity(), and NEW.

Referenced by XonoticDemoBrowserTab_fill().

6 {
7  entity me;
8  me = NEW(XonoticDemoList);
9  me.configureXonoticDemoList(me);
10  return me;
11 }
#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:

◆ XonoticDemoList_configureXonoticDemoList()

void XonoticDemoList_configureXonoticDemoList ( entity  me)

Definition at line 13 of file demolist.qc.

14 {
15  me.configureXonoticListBox(me);
16  me.nItems = 0;
17 }

◆ XonoticDemoList_demoName()

string XonoticDemoList_demoName ( entity  me,
float  i 
)

Definition at line 19 of file demolist.qc.

References strlen(), and substring().

20 {
21  string s;
22  s = bufstr_get(me.listDemo, i);
23 
24  if(substring(s, 0, 1) == "/")
25  s = substring(s, 1, strlen(s) - 1); // remove the first forward slash
26 
27  return s;
28 }
+ Here is the call graph for this function:

◆ XonoticDemoList_destroy()

void XonoticDemoList_destroy ( entity  me)

Definition at line 84 of file demolist.qc.

85 {
86  if(me.nItems > 0)
87  buf_del(me.listDemo);
88 }

◆ XonoticDemoList_doubleClickListBoxItem()

void XonoticDemoList_doubleClickListBoxItem ( entity  me,
float  i,
vector  where 
)

Definition at line 184 of file demolist.qc.

References DemoConfirm_ListClick_Check_Gamestatus().

185 {
187 }
void DemoConfirm_ListClick_Check_Gamestatus(entity me)
Definition: demolist.qc:167
+ Here is the call graph for this function:

◆ XonoticDemoList_drawListBoxItem()

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

Definition at line 105 of file demolist.qc.

References draw_Fill(), draw_Text(), draw_TextShortenToWidth(), draw_TextWidth(), eX, eY, and getFadedAlpha().

106 {
107  string s;
108  if(isSelected)
109  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
110  else if(isFocused)
111  {
112  me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
113  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
114  }
115 
116  s = me.demoName(me,i);
117  s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
118  draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 1);
119 }
const vector eY
Definition: vector.qh:45
const vector eX
Definition: vector.qh:44
+ Here is the call graph for this function:

◆ XonoticDemoList_getDemos()

void XonoticDemoList_getDemos ( entity  me)

Definition at line 68 of file demolist.qc.

References buf_create, and getDemos_for_ext().

69 {
70  if (me.listDemo >= 0)
71  buf_del(me.listDemo);
72  me.listDemo = buf_create();
73  if (me.listDemo < 0)
74  {
75  me.nItems = 0;
76  return;
77  }
78  getDemos_for_ext(me, ".dem", true);
79  me.nItems = buf_getsize(me.listDemo);
80  if(me.nItems > 0)
81  buf_sort(me.listDemo, 128, false);
82 }
void getDemos_for_ext(entity me, string ext, float subdir)
Definition: demolist.qc:31
#define buf_create
Definition: dpextensions.qh:63
+ Here is the call graph for this function:

◆ XonoticDemoList_keyDown()

float XonoticDemoList_keyDown ( entity  me,
float  scan,
float  ascii,
float  shift 
)

Definition at line 189 of file demolist.qc.

References DemoConfirm_ListClick_Check_Gamestatus(), K_ENTER, K_KP_ENTER, and SUPER.

190 {
191  if(scan == K_ENTER || scan == K_KP_ENTER)
192  {
194  return 1;
195  }
196  else
197  {
198  return SUPER(XonoticDemoList).keyDown(me, scan, ascii, shift);
199  }
200 }
float K_KP_ENTER
Definition: keycodes.qc:74
#define SUPER(cname)
Definition: oo.qh:219
float K_ENTER
Definition: keycodes.qc:8
void DemoConfirm_ListClick_Check_Gamestatus(entity me)
Definition: demolist.qc:167
+ Here is the call graph for this function:

◆ XonoticDemoList_resizeNotify()

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

Definition at line 90 of file demolist.qc.

References SUPER.

91 {
92  me.itemAbsSize = '0 0 0';
93  SUPER(XonoticDemoList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
94 
95  me.itemAbsSize.y = absSize.y * me.itemHeight;
96  me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
97  me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
98  me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
99  me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
100 
101  me.columnNameOrigin = me.realFontSize.x;
102  me.columnNameSize = 1 - 2 * me.realFontSize.x;
103 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticDemoList_showNotify()

void XonoticDemoList_showNotify ( entity  me)

Definition at line 121 of file demolist.qc.

122 {
123  me.getDemos(me);
124 }

◆ XonoticDemoList_startDemo()

void XonoticDemoList_startDemo ( entity  me)

Definition at line 149 of file demolist.qc.

References localcmd.

150 {
151  string s;
152  s = me.demoName(me, me.selectedItem);
153  s = strdecolorize(s);
154 
155  localcmd("playdemo \"demos/", s, ".dem\" \nwait \ntogglemenu\n");
156 }

◆ XonoticDemoList_timeDemo()

void XonoticDemoList_timeDemo ( entity  me)

Definition at line 158 of file demolist.qc.

References localcmd.

159 {
160  string s;
161  s = me.demoName(me, me.selectedItem);
162  s = strdecolorize(s);
163 
164  localcmd("timedemo \"demos/", s, ".dem\" \nwait \ntogglemenu\n");
165 }