2 CLASS(XonoticDemoList) EXTENDS(XonoticListBox)
3 METHOD(XonoticDemoList, configureXonoticDemoList, void(entity))
4 ATTRIB(XonoticDemoList, rowsPerItem, float, 1)
5 METHOD(XonoticDemoList, resizeNotify, void(entity, vector, vector, vector, vector))
6 METHOD(XonoticDemoList, drawListBoxItem, void(entity, float, vector, float))
7 METHOD(XonoticDemoList, getDemos, void(entity))
8 METHOD(XonoticDemoList, startDemo, void(entity))
9 METHOD(XonoticDemoList, demoName, string(entity, float))
10 METHOD(XonoticDemoList, clickListBoxItem, void(entity, float, vector))
11 METHOD(XonoticDemoList, keyDown, float(entity, float, float, float))
12 METHOD(XonoticDemoList, destroy, void(entity))
13 METHOD(XonoticDemoList, showNotify, void(entity))
14 ATTRIB(XonoticDemoList, listDemo, float, -1)
15 ATTRIB(XonoticDemoList, realFontSize, vector, '0 0 0')
16 ATTRIB(XonoticDemoList, columnNameOrigin, float, 0)
17 ATTRIB(XonoticDemoList, columnNameSize, float, 0)
18 ATTRIB(XonoticDemoList, realUpperMargin, float, 0)
19 ATTRIB(XonoticDemoList, origin, vector, '0 0 0')
20 ATTRIB(XonoticDemoList, itemAbsSize, vector, '0 0 0')
21 ATTRIB(XonoticDemoList, lastClickedDemo, float, -1)
22 ATTRIB(XonoticDemoList, lastClickedTime, float, 0)
23 ATTRIB(XonoticDemoList, filterString, string, string_null)
24 ENDCLASS(XonoticDemoList)
26 entity makeXonoticDemoList();
27 void StartDemo_Click(entity btn, entity me);
28 void TimeDemo_Click(entity btn, entity me);
29 void DemoList_Filter_Change(entity box, entity me);
34 entity makeXonoticDemoList()
37 me = spawnXonoticDemoList();
38 me.configureXonoticDemoList(me);
42 void XonoticDemoList_configureXonoticDemoList(entity me)
44 me.configureXonoticListBox(me);
48 string XonoticDemoList_demoName(entity me, float i )
51 s = search_getfilename(me.listDemo, i);
52 s = substring(s, 6, strlen(s) - 6 - 4); // demos/, .dem
57 void XonoticDemoList_getDemos(entity me)
62 //subdirectory in filterString allowed
63 s=strcat("demos/*", me.filterString, "*.dem");
67 //dprint("Search demos with the pattern ", s, "\n");
69 search_end(me.listDemo);
70 me.listDemo = search_begin(s, FALSE, TRUE);
74 me.nItems=search_getsize(me.listDemo);
77 void XonoticDemoList_destroy(entity me)
79 search_end(me.listDemo);
82 void XonoticDemoList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
84 me.itemAbsSize = '0 0 0';
85 SUPER(XonoticDemoList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
87 me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize_y * me.itemHeight));
88 me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth)));
89 me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
91 me.columnNameOrigin = me.realFontSize_x;
92 me.columnNameSize = 1 - 2 * me.realFontSize_x;
95 void XonoticDemoList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
99 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
101 s = me.demoName(me,i);
102 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
103 draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
106 void XonoticDemoList_showNotify(entity me)
111 void DemoList_Filter_Change(entity box, entity me)
114 strunzone(me.filterString);
117 me.filterString = strzone(box.text);
119 me.filterString = string_null;
124 void XonoticDemoList_startDemo(entity me)
127 s = me.demoName(me,me.selectedItem);
128 localcmd("playdemo demos/", s, ".dem\nwait\ntogglemenu\n");
131 void StartDemo_Click(entity btn, entity me)
136 void TimeDemo_Click(entity btn, entity me)
139 s = me.demoName(me,me.selectedItem);
140 localcmd("timedemo demos/", s, ".dem\nwait\ntogglemenu\n");
143 void XonoticDemoList_clickListBoxItem(entity me, float i, vector where)
145 if(i == me.lastClickedDemo)
146 if(time < me.lastClickedTime + 0.3)
149 me.setSelected(me, i);
152 me.lastClickedDemo = i;
153 me.lastClickedTime = time;
156 float XonoticDemoList_keyDown(entity me, float scan, float ascii, float shift)
158 if(scan == K_ENTER) {
163 return SUPER(XonoticDemoList).keyDown(me, scan, ascii, shift);