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, columnNumberOrigin, float, 0)
19 ATTRIB(XonoticSoundList, columnNumberSize, float, 0)
20 ATTRIB(XonoticSoundList, realUpperMargin, float, 0)
21 ATTRIB(XonoticSoundList, origin, vector, '0 0 0')
22 ATTRIB(XonoticSoundList, itemAbsSize, vector, '0 0 0')
24 ATTRIB(XonoticSoundList, lastClickedSound, float, -1)
25 ATTRIB(XonoticSoundList, lastClickedTime, float, 0)
26 ATTRIB(XonoticSoundList, filterString, string, string_null)
27 ATTRIB(XonoticSoundList, playlist, entity, world)
28 ENDCLASS(XonoticSoundList)
30 entity makeXonoticSoundList();
31 void SoundList_Filter_Change(entity box, entity me);
32 void SoundList_Add(entity box, entity me);
33 void SoundList_Add_All(entity box, entity me);
34 void SoundList_Menu_Track_Change(entity box, entity me);
35 void SoundList_Menu_Track_Reset(entity box, entity me);
40 entity makeXonoticSoundList()
43 me = spawnXonoticSoundList();
44 me.configureXonoticSoundList(me);
48 void XonoticSoundList_configureXonoticSoundList(entity me)
50 me.configureXonoticListBox(me);
54 string XonoticSoundList_soundName(entity me, float i )
57 s = search_getfilename(me.listSound, i);
58 s = substring(s, 15, strlen(s) - 15 - 4); // sound/cdtracks/, .ogg
63 void XonoticSoundList_getSounds(entity me)
68 //subdirectory in filterString allowed
69 s = strcat("sound/cdtracks/*", me.filterString, "*.ogg");
71 s = "sound/cdtracks/*.ogg";
74 search_end(me.listSound);
76 me.listSound = search_begin(s, FALSE, TRUE);
81 me.nItems=search_getsize(me.listSound);
84 void XonoticSoundList_destroy(entity me)
87 search_end(me.listSound);
90 void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
92 me.itemAbsSize = '0 0 0';
93 SUPER(XonoticSoundList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
95 me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize_y * me.itemHeight));
96 me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth)));
97 me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
99 me.columnNumberOrigin = 0;
100 me.columnNumberSize = me.realFontSize_x * 3;
102 me.columnNameOrigin = me.columnNumberSize;
103 me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize_x;
106 void XonoticSoundList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
110 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
112 s = me.soundName(me,i);
113 if(s == cvar_string("menu_cdtrack")) // current menu track
114 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
115 else if(s == cvar_defstring("menu_cdtrack")) // default menu track
116 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[D]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
118 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
119 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
122 void XonoticSoundList_showNotify(entity me)
127 void SoundList_Menu_Track_Change(entity box, entity me)
129 cvar_set("menu_cdtrack", me.soundName(me,me.selectedItem));
132 void SoundList_Menu_Track_Reset(entity box, entity me)
134 cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
137 void SoundList_Filter_Change(entity box, entity me)
140 strunzone(me.filterString);
143 me.filterString = strzone(box.text);
145 me.filterString = string_null;
150 void SoundList_Add(entity box, entity me)
152 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
155 void SoundList_Add_All(entity box, entity me)
158 for(i = 0; i < me.nItems; ++i)
159 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
162 void XonoticSoundList_clickListBoxItem(entity me, float i, vector where)
164 if(i == me.lastClickedSound)
165 if(time < me.lastClickedTime + 0.3)
168 me.setSelected(me, i);
169 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
171 me.lastClickedSound = i;
172 me.lastClickedTime = time;
175 float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
177 if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE) {
178 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
182 return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);