]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/soundlist.c
More fun stuff
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / soundlist.c
index e488e9e35d8e2eb4f18c8170c0ef36c95d028e1d..7d1515062ab5428aa09b0c272272aa4722a2f4c7 100644 (file)
@@ -6,7 +6,7 @@ CLASS(XonoticSoundList) EXTENDS(XonoticListBox)
        METHOD(XonoticSoundList, drawListBoxItem, void(entity, float, vector, float))
        METHOD(XonoticSoundList, getSounds, void(entity))
        METHOD(XonoticSoundList, soundName, string(entity, float))
-       METHOD(XonoticSoundList, clickListBoxItem, void(entity, float, vector))
+       METHOD(XonoticSoundList, doubleClickListBoxItem, void(entity, float, vector))
        METHOD(XonoticSoundList, keyDown, float(entity, float, float, float))
        METHOD(XonoticSoundList, destroy, void(entity))
        METHOD(XonoticSoundList, showNotify, void(entity))
@@ -15,18 +15,20 @@ CLASS(XonoticSoundList) EXTENDS(XonoticListBox)
        ATTRIB(XonoticSoundList, realFontSize, vector, '0 0 0')
        ATTRIB(XonoticSoundList, columnNameOrigin, float, 0)
        ATTRIB(XonoticSoundList, columnNameSize, float, 0)
+       ATTRIB(XonoticSoundList, columnNumberOrigin, float, 0)
+       ATTRIB(XonoticSoundList, columnNumberSize, float, 0)
        ATTRIB(XonoticSoundList, realUpperMargin, float, 0)
        ATTRIB(XonoticSoundList, origin, vector, '0 0 0')
        ATTRIB(XonoticSoundList, itemAbsSize, vector, '0 0 0')
 
-       ATTRIB(XonoticSoundList, lastClickedSound, float, -1)
-       ATTRIB(XonoticSoundList, lastClickedTime, float, 0)
        ATTRIB(XonoticSoundList, filterString, string, string_null)
        ATTRIB(XonoticSoundList, playlist, entity, world)
 ENDCLASS(XonoticSoundList)
 
 entity makeXonoticSoundList();
 void SoundList_Filter_Change(entity box, entity me);
+void SoundList_Add(entity box, entity me);
+void SoundList_Add_All(entity box, entity me);
 void SoundList_Menu_Track_Change(entity box, entity me);
 void SoundList_Menu_Track_Reset(entity box, entity me);
 #endif
@@ -59,13 +61,12 @@ string XonoticSoundList_soundName(entity me, float i )
 void XonoticSoundList_getSounds(entity me)
 {
        string s;
-       float i;
 
        if(me.filterString)
                //subdirectory in filterString allowed
-               s=strcat("sound/cdtracks/*", me.filterString, "*.ogg");
+               s = strcat("sound/cdtracks/*", me.filterString, "*.ogg");
        else
-               s="sound/cdtracks/*.ogg";
+               s = "sound/cdtracks/*.ogg";
 
        if(me.listSound >= 0)
                search_end(me.listSound);
@@ -80,7 +81,8 @@ void XonoticSoundList_getSounds(entity me)
 
 void XonoticSoundList_destroy(entity me)
 {
-       search_end(me.listSound);
+       if(me.listSound >= 0)
+               search_end(me.listSound);
 }
 
 void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
@@ -92,8 +94,11 @@ void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize,
        me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth)));
        me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
 
-       me.columnNameOrigin = me.realFontSize_x;
-       me.columnNameSize = 1 - 2 * me.realFontSize_x;
+       me.columnNumberOrigin = 0;
+       me.columnNumberSize = me.realFontSize_x * 3;
+
+       me.columnNameOrigin = me.columnNumberSize;
+       me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize_x;
 }
 
 void XonoticSoundList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
@@ -103,10 +108,11 @@ void XonoticSoundList_drawListBoxItem(entity me, float i, vector absSize, float
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
 
        s = me.soundName(me,i);
-       if(s == cvar_defstring("menu_cdtrack"))
-               s = strcat(s, " [default menu track]");
-       else if(s == cvar_string("menu_cdtrack"))
-               s = strcat(s, " [current menu track]");
+       if(s == cvar_string("menu_cdtrack")) // current menu track
+               draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+       else if(s == cvar_defstring("menu_cdtrack")) // default menu track
+               draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[D]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+
        s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
        draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
 }
@@ -139,17 +145,21 @@ void SoundList_Filter_Change(entity box, entity me)
        me.getSounds(me);
 }
 
-void XonoticSoundList_clickListBoxItem(entity me, float i, vector where)
+void SoundList_Add(entity box, entity me)
+{
+       me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
+}
+
+void SoundList_Add_All(entity box, entity me)
 {
-       if(i == me.lastClickedSound)
-               if(time < me.lastClickedTime + 0.3)
-               {
-                       // DOUBLE CLICK!
-                       me.setSelected(me, i);
-                       me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
-               }
-       me.lastClickedSound = i;
-       me.lastClickedTime = time;
+       float i;
+       for(i = 0; i < me.nItems; ++i)
+               me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
+}
+
+void XonoticSoundList_doubleClickListBoxItem(entity me, float i, vector where)
+{
+       me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
 }
 
 float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
@@ -158,10 +168,6 @@ float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
                me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
                return 1;
        }
-       else if(scan == K_DEL || scan == K_KP_DEL) {
-               me.playlist.removeFromPlayList(me.playlist, me.soundName(me, me.selectedItem));
-               return 1;
-       }
        else
                return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);
 }