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.itemAbsSize.y = absSize.y * me.itemHeight;
59 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
60 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
61 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
62 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
64 me.columnNumberOrigin = 0;
65 me.columnNumberSize = me.realFontSize.x * 3;
67 me.columnNameOrigin = me.columnNumberSize;
68 me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x;
71 void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
75 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
78 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
79 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
82 s = me.soundName(me, i);
83 if(s == cvar_string("menu_cdtrack")) // current menu track
84 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
85 else if(s == cvar_defstring("menu_cdtrack")) // default menu track
86 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[D]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
88 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
89 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
92 void XonoticSoundList_showNotify(entity me)
97 void SoundList_Menu_Track_Change(entity box, entity me)
99 cvar_set("menu_cdtrack", me.soundName(me, me.selectedItem));
102 void SoundList_Menu_Track_Reset(entity box, entity me)
104 cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
107 void SoundList_Filter_Change(entity box, entity me)
109 strfree(me.filterString);
112 me.filterString = strzone(box.text);
117 void SoundList_Add(entity box, entity me)
119 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
122 void SoundList_Add_All(entity box, entity me)
125 for(i = 0; i < me.nItems; ++i)
126 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
129 void XonoticSoundList_doubleClickListBoxItem(entity me, int i, vector where)
131 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
134 float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
136 if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE) {
137 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
141 return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);