4 CLASS(XonoticSoundList, XonoticListBox)
5 METHOD(XonoticSoundList, configureXonoticSoundList, void(entity));
6 ATTRIB(XonoticSoundList, rowsPerItem, float, 1)
7 METHOD(XonoticSoundList, resizeNotify, void(entity, vector, vector, vector, vector));
8 METHOD(XonoticSoundList, drawListBoxItem, void(entity, int, vector, bool, bool));
9 METHOD(XonoticSoundList, getSounds, void(entity));
10 METHOD(XonoticSoundList, soundName, string(entity, int));
11 METHOD(XonoticSoundList, doubleClickListBoxItem, void(entity, int, vector));
12 METHOD(XonoticSoundList, keyDown, float(entity, float, float, float));
13 METHOD(XonoticSoundList, destroy, void(entity));
14 METHOD(XonoticSoundList, showNotify, void(entity));
16 ATTRIB(XonoticSoundList, listSound, int, -1)
17 ATTRIB(XonoticSoundList, realFontSize, vector, '0 0 0')
18 ATTRIB(XonoticSoundList, columnNameOrigin, float, 0)
19 ATTRIB(XonoticSoundList, columnNameSize, float, 0)
20 ATTRIB(XonoticSoundList, columnNumberOrigin, float, 0)
21 ATTRIB(XonoticSoundList, columnNumberSize, float, 0)
22 ATTRIB(XonoticSoundList, realUpperMargin, float, 0)
23 ATTRIB(XonoticSoundList, origin, vector, '0 0 0')
24 ATTRIB(XonoticSoundList, itemAbsSize, vector, '0 0 0')
26 ATTRIB(XonoticSoundList, filterString, string, string_null)
27 ATTRIB(XonoticSoundList, playlist, entity, NULL)
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 = NEW(XonoticSoundList);
44 me.configureXonoticSoundList(me);
48 void XonoticSoundList_configureXonoticSoundList(entity me)
50 me.configureXonoticListBox(me);
54 string XonoticSoundList_soundName(entity me, int 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);
78 me.nItems = (me.listSound < 0) ? 0 : search_getsize(me.listSound);
81 void XonoticSoundList_destroy(entity me)
84 search_end(me.listSound);
87 void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
89 me.itemAbsSize = '0 0 0';
90 SUPER(XonoticSoundList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
92 me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize.y * me.itemHeight));
93 me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize.x * (1 - me.controlWidth)));
94 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
96 me.columnNumberOrigin = 0;
97 me.columnNumberSize = me.realFontSize.x * 3;
99 me.columnNameOrigin = me.columnNumberSize;
100 me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x;
103 void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
107 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
110 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
111 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
114 s = me.soundName(me, i);
115 if(s == cvar_string("menu_cdtrack")) // current menu track
116 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
117 else if(s == cvar_defstring("menu_cdtrack")) // default menu track
118 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[D]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
120 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
121 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
124 void XonoticSoundList_showNotify(entity me)
129 void SoundList_Menu_Track_Change(entity box, entity me)
131 cvar_set("menu_cdtrack", me.soundName(me, me.selectedItem));
134 void SoundList_Menu_Track_Reset(entity box, entity me)
136 cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
139 void SoundList_Filter_Change(entity box, entity me)
142 strunzone(me.filterString);
145 me.filterString = strzone(box.text);
147 me.filterString = string_null;
152 void SoundList_Add(entity box, entity me)
154 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
157 void SoundList_Add_All(entity box, entity me)
160 for(i = 0; i < me.nItems; ++i)
161 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
164 void XonoticSoundList_doubleClickListBoxItem(entity me, int i, vector where)
166 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
169 float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
171 if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE) {
172 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
176 return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);