1 #include "soundlist.qh"
6 entity makeXonoticSoundList()
9 me = NEW(XonoticSoundList);
10 me.configureXonoticSoundList(me);
14 void XonoticSoundList_configureXonoticSoundList(entity me)
16 me.configureXonoticListBox(me);
20 string XonoticSoundList_soundName(entity me, int i)
23 s = search_getfilename(me.listSound, i);
24 s = substring(s, 15, strlen(s) - 15 - 4); // sound/cdtracks/, .ogg
29 void XonoticSoundList_getSounds(entity me)
34 //subdirectory in filterString allowed
35 s = strcat("sound/cdtracks/*", me.filterString, "*.ogg");
37 s = "sound/cdtracks/*.ogg";
40 search_end(me.listSound);
42 me.listSound = search_begin(s, false, true);
44 me.nItems = (me.listSound < 0) ? 0 : search_getsize(me.listSound);
47 void XonoticSoundList_destroy(entity me)
50 search_end(me.listSound);
53 void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
55 me.itemAbsSize = '0 0 0';
56 SUPER(XonoticSoundList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
58 me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize.y * me.itemHeight));
59 me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize.x * (1 - me.controlWidth)));
60 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
62 me.columnNumberOrigin = 0;
63 me.columnNumberSize = me.realFontSize.x * 3;
65 me.columnNameOrigin = me.columnNumberSize;
66 me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x;
69 void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
73 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
76 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
77 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
80 s = me.soundName(me, i);
81 if(s == cvar_string("menu_cdtrack")) // current menu track
82 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
83 else if(s == cvar_defstring("menu_cdtrack")) // default menu track
84 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[D]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
86 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
87 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
90 void XonoticSoundList_showNotify(entity me)
95 void SoundList_Menu_Track_Change(entity box, entity me)
97 cvar_set("menu_cdtrack", me.soundName(me, me.selectedItem));
100 void SoundList_Menu_Track_Reset(entity box, entity me)
102 cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
105 void SoundList_Filter_Change(entity box, entity me)
108 strunzone(me.filterString);
111 me.filterString = strzone(box.text);
113 me.filterString = string_null;
118 void SoundList_Add(entity box, entity me)
120 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
123 void SoundList_Add_All(entity box, entity me)
126 for(i = 0; i < me.nItems; ++i)
127 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
130 void XonoticSoundList_doubleClickListBoxItem(entity me, int i, vector where)
132 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
135 float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
137 if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE) {
138 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
142 return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);