From 5881808c8818792da5b84ce5b4aac5717734dea2 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 4 Feb 2011 18:54:40 +0100 Subject: [PATCH] Enhance slide show a bit: - 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 --- ..._multiplayer_screenshot_screenshotviewer.c | 22 ++++++++++++++----- qcsrc/menu/xonotic/screenshotlist.c | 14 ++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c index dec8881c1..454667145 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c @@ -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; diff --git a/qcsrc/menu/xonotic/screenshotlist.c b/qcsrc/menu/xonotic/screenshotlist.c index ffc5a2f37..8419eb709 100644 --- a/qcsrc/menu/xonotic/screenshotlist.c +++ b/qcsrc/menu/xonotic/screenshotlist.c @@ -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); } -- 2.39.2