]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/playlist.c
Merge branch 'sev/luma' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / playlist.c
index ce670816b899f2e54fefede4d2b93a4f92d789f9..e918adacd391be7eb4a33744c7a78d4fae31663f 100644 (file)
@@ -7,8 +7,9 @@ CLASS(XonoticPlayList) EXTENDS(XonoticListBox)
        METHOD(XonoticPlayList, drawListBoxItem, void(entity, float, vector, float))
        METHOD(XonoticPlayList, stopSound, void(entity))
        METHOD(XonoticPlayList, startSound, void(entity, float))
+       METHOD(XonoticPlayList, resumeSound, void(entity))
        METHOD(XonoticPlayList, pauseSound, void(entity))
-       METHOD(XonoticPlayList, clickListBoxItem, void(entity, float, vector))
+       METHOD(XonoticPlayList, doubleClickListBoxItem, void(entity, float, vector))
        METHOD(XonoticPlayList, keyDown, float(entity, float, float, float))
        METHOD(XonoticPlayList, mouseDrag, float(entity, vector))
 
@@ -24,9 +25,6 @@ CLASS(XonoticPlayList) EXTENDS(XonoticListBox)
        ATTRIB(XonoticPlayList, realUpperMargin, float, 0)
        ATTRIB(XonoticPlayList, origin, vector, '0 0 0')
        ATTRIB(XonoticPlayList, itemAbsSize, vector, '0 0 0')
-
-       ATTRIB(XonoticPlayList, lastClickedSound, float, -1)
-       ATTRIB(XonoticPlayList, lastClickedTime, float, 0)
 ENDCLASS(XonoticPlayList)
 
 entity makeXonoticPlayList();
@@ -182,7 +180,7 @@ void XonoticPlayList_drawListBoxItem(entity me, float i, vector absSize, float i
        {
                float f = cvar("music_playlist_sampleposition0");
                if(f <= 0 || (((time * 2) & 1) && f > 0))
-                       draw_Text(me.realUpperMargin * eY + (me.columnNumberOrigin + me.columnNumberSize) * eX, chr(0xE000 + 141), me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+                       draw_Text(me.realUpperMargin * eY + (me.columnNumberOrigin + me.columnNumberSize) * eX, "\xE2\x96\xB6", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
        }
 
        s = ftos(i+1);
@@ -222,7 +220,18 @@ void XonoticPlayList_startSound(entity me, float offset)
                        return;
        }
        else
+       {
                f = me.selectedItem;
+               // if it was paused then resume
+               if(f == cvar("music_playlist_current0"))
+               if(cvar("music_playlist_index") == 999)
+               {
+                       me.resumeSound(me);
+                       return;
+               }
+               // if it was not paused then proceed with restart
+       }
+
        // START: list 0 is disabled by setting the index to 999
        // we set current0 to the selected track and sampleposition0 to 0 to forget the position that the engine saves in this frame (for this reason we need to wait a frame)
        // then we switch back to list 0
@@ -246,16 +255,20 @@ void NextSound_Click(entity btn, entity me)
        me.startSound(me, +1);
 }
 
+void XonoticPlayList_resumeSound(entity me)
+{
+       // RESUME: list 0 is enabled by setting the index to 0
+       // (we reset sampleposition0 to 0 to mark the track as in playing back state)
+       if(cvar("music_playlist_index") == 999)
+               localcmd("\nmusic_playlist_index 0; wait; music_playlist_sampleposition0 0\n");
+}
 void XonoticPlayList_pauseSound(entity me)
 {
        // PAUSE: list 0 is disabled by setting the index to 999
        // (we know the track is paused because the engine sets sampleposition0 to remember current position)
-       // RESUME: list 0 is enabled by setting the index to 0
-       // (we reset sampleposition0 to 0 to mark the track as in playing back state)
        if(cvar("music_playlist_index") == 0)
                localcmd("\nmusic_playlist_index 999\n");
-       else if(cvar("music_playlist_index") == 999)
-               localcmd("\nmusic_playlist_index 0; wait; music_playlist_sampleposition0 0\n");
+       else me.resumeSound(me);
 }
 
 void PauseSound_Click(entity btn, entity me)
@@ -263,17 +276,9 @@ void PauseSound_Click(entity btn, entity me)
        me.pauseSound(me);
 }
 
-void XonoticPlayList_clickListBoxItem(entity me, float i, vector where)
+void XonoticPlayList_doubleClickListBoxItem(entity me, float i, vector where)
 {
-       if(i == me.lastClickedSound)
-               if(time < me.lastClickedTime + 0.3)
-               {
-                       // DOUBLE CLICK!
-                       me.setSelected(me, i);
-                       me.startSound(me, 0);
-               }
-       me.lastClickedSound = i;
-       me.lastClickedTime = time;
+       me.startSound(me, 0);
 }
 
 float XonoticPlayList_keyDown(entity me, float scan, float ascii, float shift)