]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Enhance slide show a bit:
authorterencehill <piuntn@gmail.com>
Fri, 4 Feb 2011 17:54:40 +0000 (18:54 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 4 Feb 2011 17:54:40 +0000 (18:54 +0100)
- it continues even if another image is manually selected (with mouse or keyboard)
- seamlessly restarts from the first image after the last image
- can be stopped only by pressing the Slide Show button (or by closing the viewer window)
- Slide Show button stays highlighted while the slide show is active

qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c
qcsrc/menu/xonotic/screenshotlist.c

index dec8881c16567639329c1c07f830a968162bdf6c..454667145eceef8783739b0bee995c102c5658f7 100644 (file)
@@ -12,6 +12,7 @@ CLASS(XonoticScreenshotViewerDialog) EXTENDS(XonoticDialog)
        ATTRIB(XonoticScreenshotViewerDialog, color, vector, SKINCOLOR_DIALOG_SCREENSHOTVIEWER)
        ATTRIB(XonoticScreenshotViewerDialog, scrList, entity, NULL)
        ATTRIB(XonoticScreenshotViewerDialog, screenshotImage, entity, NULL)
+       ATTRIB(XonoticScreenshotViewerDialog, slideShowButton, entity, NULL)
        ATTRIB(XonoticScreenshotViewerDialog, currentScrPath, string, string_null)
 ENDCLASS(XonoticScreenshotViewerDialog)
 #endif
@@ -34,9 +35,18 @@ void nextScreenshot_Click(entity btn, entity me)
 {
        me.scrList.goScreenshot(me.scrList, +1);
 }
-void startSlideShow_Click(entity btn, entity me)
+void toggleSlideShow_Click(entity btn, entity me)
 {
-       me.scrList.startSlideShow(me.scrList);
+       if (me.slideShowButton.forcePressed)
+       {
+               me.scrList.stopSlideShow(me.scrList);
+               me.slideShowButton.forcePressed = 0;
+       }
+       else
+       {
+               me.scrList.startSlideShow(me.scrList);
+               me.slideShowButton.forcePressed = 1;
+       }
 }
 float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, float shift)
 {
@@ -56,7 +66,7 @@ float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, f
                        // to press buttons while browsing with only the keyboard
                        if (shift & S_CTRL)
                        {
-                               me.scrList.startSlideShow(me.scrList);
+                               toggleSlideShow_Click(world, me);
                                return 1;
                        }
                        return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
@@ -78,6 +88,7 @@ float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, f
 void XonoticScreenshotViewerDialog_close(entity me)
 {
        me.scrList.stopSlideShow(me.scrList);
+       me.slideShowButton.forcePressed = 0;
        SUPER(XonoticScreenshotViewerDialog).close(me);
 }
 void XonoticScreenshotViewerDialog_fill(entity me)
@@ -92,9 +103,10 @@ void XonoticScreenshotViewerDialog_fill(entity me)
                        e.onClick = prevScreenshot_Click;
                        e.onClickEntity = me;
                me.TDempty(me, 1/4);
-               me.TD(me, 1, 1, e = makeXonoticButton("Start slide show", '0 0 0'));
-                       e.onClick = startSlideShow_Click;
+               me.TD(me, 1, 1, e = makeXonoticButton("Slide show", '0 0 0'));
+                       e.onClick = toggleSlideShow_Click;
                        e.onClickEntity = me;
+                       me.slideShowButton = e;
                me.TDempty(me, 1/4);
                me.TD(me, 1, 1, e = makeXonoticButton("Next", '0 0 0'));
                        e.onClick = nextScreenshot_Click;
index ffc5a2f375f4d93dac3d7980261175c57fd3836f..8419eb709ca4c082579aaa3931a38b9cd861c448 100644 (file)
@@ -134,7 +134,8 @@ void XonoticScreenshotList_resizeNotify(entity me, vector relOrigin, vector relS
 
 void XonoticScreenshotList_setSelected(entity me, float i)
 {
-       me.stopSlideShow(me);
+       if (me.newSlideShowScreenshotTime)
+               me.startSlideShow(me);
        me.prevSelectedItem = me.selectedItem;
        SUPER(XonoticScreenshotList).setSelected(me, i);
        if (me.pressed && me.selectedItem != me.prevSelectedItem)
@@ -211,9 +212,14 @@ void XonoticScreenshotList_draw(entity me)
        }
        else if (me.newSlideShowScreenshotTime && time > me.newSlideShowScreenshotTime)
        {
-               me.goScreenshot(me, +1);
-               if (me.selectedItem < me.nItems-1)
-                       me.startSlideShow(me);
+               if (me.selectedItem == me.nItems - 1) //last screenshot?
+               {
+                       // restart from the first screenshot
+                       me.setSelected(me, 0);
+                       me.goScreenshot(me, +0);
+               }
+               else
+                       me.goScreenshot(me, +1);
        }
        SUPER(XonoticScreenshotList).draw(me);
 }