]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/screenshotlist.c
Fix minor issues with mouse wheel up/down keys
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / screenshotlist.c
index 97469227b49f7f96e40cad5896080b2820b14bcf..ffc5a2f375f4d93dac3d7980261175c57fd3836f 100644 (file)
@@ -28,12 +28,15 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox)
        ATTRIB(XonoticScreenshotList, filterTime, float, 0)
 
        ATTRIB(XonoticScreenshotList, newScreenshotTime, float, 0)
+       ATTRIB(XonoticScreenshotList, newSlideShowScreenshotTime, float, 0)
        ATTRIB(XonoticScreenshotList, prevSelectedItem, float, 0)
 
        ATTRIB(XonoticScreenshotList, screenshotBrowserDialog, entity, NULL)
        ATTRIB(XonoticScreenshotList, screenshotPreview, entity, NULL)
        ATTRIB(XonoticScreenshotList, screenshotViewerDialog, entity, NULL)
        METHOD(XonoticScreenshotList, goScreenshot, void(entity, float))
+       METHOD(XonoticScreenshotList, startSlideShow, void(entity))
+       METHOD(XonoticScreenshotList, stopSlideShow, void(entity))
 ENDCLASS(XonoticScreenshotList)
 
 entity makeXonoticScreenshotList();
@@ -131,13 +134,14 @@ void XonoticScreenshotList_resizeNotify(entity me, vector relOrigin, vector relS
 
 void XonoticScreenshotList_setSelected(entity me, float i)
 {
+       me.stopSlideShow(me);
        me.prevSelectedItem = me.selectedItem;
        SUPER(XonoticScreenshotList).setSelected(me, i);
        if (me.pressed && me.selectedItem != me.prevSelectedItem)
        {
                // while dragging the scrollbar (or an item)
                // for a smooth mouse movement do not load immediately the new selected images
-               me.newScreenshotTime = time + 0.2;
+               me.newScreenshotTime = time + 0.22; // dragging an item we need a delay > 0.2 (from listbox: me.dragScrollTimer = time + 0.2;)
        }
        else if (time > me.newScreenshotTime)
        {
@@ -205,9 +209,25 @@ void XonoticScreenshotList_draw(entity me)
                me.previewScreenshot(me);
                me.newScreenshotTime = 0;
        }
+       else if (me.newSlideShowScreenshotTime && time > me.newSlideShowScreenshotTime)
+       {
+               me.goScreenshot(me, +1);
+               if (me.selectedItem < me.nItems-1)
+                       me.startSlideShow(me);
+       }
        SUPER(XonoticScreenshotList).draw(me);
 }
 
+void XonoticScreenshotList_startSlideShow(entity me)
+{
+       me.newSlideShowScreenshotTime = time + 3;
+}
+
+void XonoticScreenshotList_stopSlideShow(entity me)
+{
+       me.newSlideShowScreenshotTime = 0;
+}
+
 void XonoticScreenshotList_goScreenshot(entity me, float d)
 {
        if(!me.screenshotViewerDialog)