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
{
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)
{
// 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);
void XonoticScreenshotViewerDialog_close(entity me)
{
me.scrList.stopSlideShow(me.scrList);
+ me.slideShowButton.forcePressed = 0;
SUPER(XonoticScreenshotViewerDialog).close(me);
}
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;
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)
}
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);
}