2 CLASS(XonoticSoundList) EXTENDS(XonoticListBox)
3 METHOD(XonoticSoundList, configureXonoticSoundList, void(entity))
4 ATTRIB(XonoticSoundList, rowsPerItem, float, 1)
5 METHOD(XonoticSoundList, resizeNotify, void(entity, vector, vector, vector, vector))
6 METHOD(XonoticSoundList, drawListBoxItem, void(entity, float, vector, float))
7 METHOD(XonoticSoundList, getSounds, void(entity))
8 METHOD(XonoticSoundList, soundName, string(entity, float))
9 METHOD(XonoticSoundList, clickListBoxItem, void(entity, float, vector))
10 METHOD(XonoticSoundList, keyDown, float(entity, float, float, float))
11 METHOD(XonoticSoundList, destroy, void(entity))
12 METHOD(XonoticSoundList, showNotify, void(entity))
14 ATTRIB(XonoticSoundList, listSound, float, -1)
15 ATTRIB(XonoticSoundList, realFontSize, vector, '0 0 0')
16 ATTRIB(XonoticSoundList, columnNameOrigin, float, 0)
17 ATTRIB(XonoticSoundList, columnNameSize, float, 0)
18 ATTRIB(XonoticSoundList, realUpperMargin, float, 0)
19 ATTRIB(XonoticSoundList, origin, vector, '0 0 0')
20 ATTRIB(XonoticSoundList, itemAbsSize, vector, '0 0 0')
22 ATTRIB(XonoticSoundList, lastClickedSound, float, -1)
23 ATTRIB(XonoticSoundList, lastClickedTime, float, 0)
24 ATTRIB(XonoticSoundList, filterString, string, string_null)
25 ATTRIB(XonoticSoundList, playlist, entity, world)
26 ENDCLASS(XonoticSoundList)
28 entity makeXonoticSoundList();
29 void SoundList_Filter_Change(entity box, entity me);
30 void SoundList_Menu_Track_Change(entity box, entity me);
31 void SoundList_Menu_Track_Reset(entity box, entity me);
36 entity makeXonoticSoundList()
39 me = spawnXonoticSoundList();
40 me.configureXonoticSoundList(me);
44 void XonoticSoundList_configureXonoticSoundList(entity me)
46 me.configureXonoticListBox(me);
50 string XonoticSoundList_soundName(entity me, float i )
53 s = search_getfilename(me.listSound, i);
54 s = substring(s, 15, strlen(s) - 15 - 4); // sound/cdtracks/, .ogg
59 void XonoticSoundList_getSounds(entity me)
65 //subdirectory in filterString allowed
66 s=strcat("sound/cdtracks/*", me.filterString, "*.ogg");
68 s="sound/cdtracks/*.ogg";
71 search_end(me.listSound);
73 me.listSound = search_begin(s, FALSE, TRUE);
78 me.nItems=search_getsize(me.listSound);
81 void XonoticSoundList_destroy(entity me)
83 search_end(me.listSound);
86 void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
88 me.itemAbsSize = '0 0 0';
89 SUPER(XonoticSoundList).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 XonoticSoundList_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.soundName(me,i);
106 if(s == cvar_defstring("menu_cdtrack"))
107 s = strcat(s, " [default menu track]");
108 else if(s == cvar_string("menu_cdtrack"))
109 s = strcat(s, " [current menu track]");
110 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
111 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
114 void XonoticSoundList_showNotify(entity me)
119 void SoundList_Menu_Track_Change(entity box, entity me)
121 cvar_set("menu_cdtrack", me.soundName(me,me.selectedItem));
124 void SoundList_Menu_Track_Reset(entity box, entity me)
126 cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
129 void SoundList_Filter_Change(entity box, entity me)
132 strunzone(me.filterString);
135 me.filterString = strzone(box.text);
137 me.filterString = string_null;
142 void XonoticSoundList_clickListBoxItem(entity me, float i, vector where)
144 if(i == me.lastClickedSound)
145 if(time < me.lastClickedTime + 0.3)
148 me.setSelected(me, i);
149 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
151 me.lastClickedSound = i;
152 me.lastClickedTime = time;
155 float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
157 if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE) {
158 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
161 else if(scan == K_DEL || scan == K_KP_DEL) {
162 me.playlist.removeFromPlayList(me.playlist, me.soundName(me, me.selectedItem));
166 return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);