3 CLASS(XonoticSoundList, XonoticListBox)
4 METHOD(XonoticSoundList, configureXonoticSoundList, void(entity))
5 ATTRIB(XonoticSoundList, rowsPerItem, float, 1)
6 METHOD(XonoticSoundList, resizeNotify, void(entity, vector, vector, vector, vector))
7 METHOD(XonoticSoundList, drawListBoxItem, void(entity, float, vector, float))
8 METHOD(XonoticSoundList, getSounds, void(entity))
9 METHOD(XonoticSoundList, soundName, string(entity, float))
10 METHOD(XonoticSoundList, doubleClickListBoxItem, void(entity, float, vector))
11 METHOD(XonoticSoundList, keyDown, float(entity, float, float, float))
12 METHOD(XonoticSoundList, destroy, void(entity))
13 METHOD(XonoticSoundList, showNotify, void(entity))
15 ATTRIB(XonoticSoundList, listSound, float, -1)
16 ATTRIB(XonoticSoundList, realFontSize, vector, '0 0 0')
17 ATTRIB(XonoticSoundList, columnNameOrigin, float, 0)
18 ATTRIB(XonoticSoundList, columnNameSize, float, 0)
19 ATTRIB(XonoticSoundList, columnNumberOrigin, float, 0)
20 ATTRIB(XonoticSoundList, columnNumberSize, float, 0)
21 ATTRIB(XonoticSoundList, realUpperMargin, float, 0)
22 ATTRIB(XonoticSoundList, origin, vector, '0 0 0')
23 ATTRIB(XonoticSoundList, itemAbsSize, vector, '0 0 0')
25 ATTRIB(XonoticSoundList, filterString, string, string_null)
26 ATTRIB(XonoticSoundList, playlist, entity, world)
27 ENDCLASS(XonoticSoundList)
29 entity makeXonoticSoundList();
30 void SoundList_Filter_Change(entity box, entity me);
31 void SoundList_Add(entity box, entity me);
32 void SoundList_Add_All(entity box, entity me);
33 void SoundList_Menu_Track_Change(entity box, entity me);
34 void SoundList_Menu_Track_Reset(entity box, entity me);
39 entity makeXonoticSoundList()
42 me = NEW(XonoticSoundList);
43 me.configureXonoticSoundList(me);
47 void XonoticSoundList_configureXonoticSoundList(entity me)
49 me.configureXonoticListBox(me);
53 string XonoticSoundList_soundName(entity me, float i )
56 s = search_getfilename(me.listSound, i);
57 s = substring(s, 15, strlen(s) - 15 - 4); // sound/cdtracks/, .ogg
62 void XonoticSoundList_getSounds(entity me)
67 //subdirectory in filterString allowed
68 s = strcat("sound/cdtracks/*", me.filterString, "*.ogg");
70 s = "sound/cdtracks/*.ogg";
73 search_end(me.listSound);
75 me.listSound = search_begin(s, false, true);
80 me.nItems=search_getsize(me.listSound);
83 void XonoticSoundList_destroy(entity me)
86 search_end(me.listSound);
89 void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
91 me.itemAbsSize = '0 0 0';
92 SUPER(XonoticSoundList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
94 me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize.y * me.itemHeight));
95 me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize.x * (1 - me.controlWidth)));
96 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
98 me.columnNumberOrigin = 0;
99 me.columnNumberSize = me.realFontSize.x * 3;
101 me.columnNameOrigin = me.columnNumberSize;
102 me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x;
105 void XonoticSoundList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
109 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
111 s = me.soundName(me,i);
112 if(s == cvar_string("menu_cdtrack")) // current menu track
113 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
114 else if(s == cvar_defstring("menu_cdtrack")) // default menu track
115 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[D]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
117 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
118 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
121 void XonoticSoundList_showNotify(entity me)
126 void SoundList_Menu_Track_Change(entity box, entity me)
128 cvar_set("menu_cdtrack", me.soundName(me,me.selectedItem));
131 void SoundList_Menu_Track_Reset(entity box, entity me)
133 cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
136 void SoundList_Filter_Change(entity box, entity me)
139 strunzone(me.filterString);
142 me.filterString = strzone(box.text);
144 me.filterString = string_null;
149 void SoundList_Add(entity box, entity me)
151 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
154 void SoundList_Add_All(entity box, entity me)
157 for(i = 0; i < me.nItems; ++i)
158 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
161 void XonoticSoundList_doubleClickListBoxItem(entity me, float i, vector where)
163 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
166 float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
168 if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE) {
169 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
173 return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);