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))
15 ATTRIB(XonoticDemoList, listDemo, float, -1)
16 ATTRIB(XonoticDemoList, realFontSize, vector, '0 0 0')
17 ATTRIB(XonoticDemoList, columnNameOrigin, float, 0)
18 ATTRIB(XonoticDemoList, columnNameSize, float, 0)
19 ATTRIB(XonoticDemoList, realUpperMargin, float, 0)
20 ATTRIB(XonoticDemoList, origin, vector, '0 0 0')
21 ATTRIB(XonoticDemoList, itemAbsSize, vector, '0 0 0')
23 ATTRIB(XonoticDemoList, lastClickedDemo, float, -1)
24 ATTRIB(XonoticDemoList, lastClickedTime, float, 0)
25 ATTRIB(XonoticDemoList, filterString, string, string_null)
26 ENDCLASS(XonoticDemoList)
28 entity makeXonoticDemoList();
29 void StartDemo_Click(entity btn, entity me);
30 void TimeDemo_Click(entity btn, entity me);
31 void DemoList_Filter_Change(entity box, entity me);
36 entity makeXonoticDemoList()
39 me = spawnXonoticDemoList();
40 me.configureXonoticDemoList(me);
44 void XonoticDemoList_configureXonoticDemoList(entity me)
46 me.configureXonoticListBox(me);
50 string XonoticDemoList_demoName(entity me, float i )
53 s = search_getfilename(me.listDemo, i);
54 s = substring(s, 6, strlen(s) - 6 - 4); // demos/, .dem
59 void XonoticDemoList_getDemos(entity me)
64 //subdirectory in filterString allowed
65 s=strcat("demos/*", me.filterString, "*.dem");
69 //dprint("Search demos with the pattern ", s, "\n");
71 search_end(me.listDemo);
73 me.listDemo = search_begin(s, FALSE, TRUE);
78 me.nItems=search_getsize(me.listDemo);
81 void XonoticDemoList_destroy(entity me)
83 search_end(me.listDemo);
86 void XonoticDemoList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
88 me.itemAbsSize = '0 0 0';
89 SUPER(XonoticDemoList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
91 me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize_y * me.itemHeight));
92 me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth)));
93 me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
95 me.columnNameOrigin = me.realFontSize_x;
96 me.columnNameSize = 1 - 2 * me.realFontSize_x;
99 void XonoticDemoList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
103 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
105 s = me.demoName(me,i);
106 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
107 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);
110 void XonoticDemoList_showNotify(entity me)
115 void DemoList_Filter_Change(entity box, entity me)
118 strunzone(me.filterString);
121 me.filterString = strzone(box.text);
123 me.filterString = string_null;
128 void XonoticDemoList_startDemo(entity me)
131 s = me.demoName(me,me.selectedItem);
132 localcmd("playdemo \"demos/", s, ".dem\" \nwait \ntogglemenu\n");
135 void StartDemo_Click(entity btn, entity me)
140 void TimeDemo_Click(entity btn, entity me)
143 s = me.demoName(me,me.selectedItem);
144 localcmd("timedemo \"demos/", s, ".dem\" \nwait \ntogglemenu\n");
147 void XonoticDemoList_clickListBoxItem(entity me, float i, vector where)
149 if(i == me.lastClickedDemo)
150 if(time < me.lastClickedTime + 0.3)
153 me.setSelected(me, i);
156 me.lastClickedDemo = i;
157 me.lastClickedTime = time;
160 float XonoticDemoList_keyDown(entity me, float scan, float ascii, float shift)
162 if(scan == K_ENTER || scan == K_KP_ENTER) {
167 return SUPER(XonoticDemoList).keyDown(me, scan, ascii, shift);