From: terencehill Date: Sun, 22 Aug 2010 18:02:38 +0000 (+0200) Subject: Slide show in the viewer X-Git-Tag: xonotic-v0.8.0~139^2~1^2~155^2~52 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cef38c0d117821354cb3887599dc69e01e630568;p=xonotic%2Fxonotic-data.pk3dir.git Slide show in the viewer --- diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c index 2fde2d6c7..2c69d5300 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c @@ -3,11 +3,12 @@ CLASS(XonoticScreenshotViewerDialog) EXTENDS(XonoticDialog) METHOD(XonoticScreenshotViewerDialog, fill, void(entity)) METHOD(XonoticScreenshotViewerDialog, keyDown, float(entity, float, float, float)) METHOD(XonoticScreenshotViewerDialog, loadScreenshot, void(entity, string)) + METHOD(XonoticScreenshotViewerDialog, close, void(entity)) ATTRIB(XonoticScreenshotViewerDialog, title, string, "Screenshot Viewer") ATTRIB(XonoticScreenshotViewerDialog, name, string, "ScreenshotViewer") ATTRIB(XonoticScreenshotViewerDialog, intendedWidth, float, 1) ATTRIB(XonoticScreenshotViewerDialog, rows, float, 25) - ATTRIB(XonoticScreenshotViewerDialog, columns, float, 6.5) + ATTRIB(XonoticScreenshotViewerDialog, columns, float, 4) ATTRIB(XonoticScreenshotViewerDialog, color, vector, SKINCOLOR_DIALOG_SCREENSHOTVIEWER) ATTRIB(XonoticScreenshotViewerDialog, scrList, entity, NULL) ATTRIB(XonoticScreenshotViewerDialog, screenshotImage, entity, NULL) @@ -33,11 +34,14 @@ void nextScreenshot_Click(entity btn, entity me) { me.scrList.goScreenshot(me.scrList, +1); } +void startSlideShow_Click(entity btn, entity me) +{ + me.scrList.startSlideShow(me.scrList); +} float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, float shift) { switch(key) { - case K_KP_LEFTARROW: case K_LEFTARROW: me.scrList.goScreenshot(me.scrList, -1); return 1; @@ -45,6 +49,17 @@ float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, f case K_RIGHTARROW: me.scrList.goScreenshot(me.scrList, +1); return 1; + case K_KP_ENTER: + case K_ENTER: + case K_SPACE: + // we cannot use SPACE/ENTER directly, as in a dialog they are needed + // to press buttons while browsing with only the keyboard + if (shift & S_CTRL) + { + me.scrList.startSlideShow(me.scrList); + return 1; + } + return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift); default: if (me.scrList.keyDown(me.scrList, key, ascii, shift)) { @@ -55,6 +70,11 @@ float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, f return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift); } } +void XonoticScreenshotViewerDialog_close(entity me) +{ + me.scrList.stopSlideShow(me.scrList); + SUPER(XonoticScreenshotViewerDialog).close(me); +} void XonoticScreenshotViewerDialog_fill(entity me) { entity e; @@ -62,10 +82,16 @@ void XonoticScreenshotViewerDialog_fill(entity me) me.TD(me, me.rows - 1, me.columns, e = makeXonoticScreenshotImage()); me.screenshotImage = e; me.gotoRC(me, me.rows - 1, 0); - me.TD(me, 1, me.columns/2, e = makeXonoticButton("Previous", '0 0 0')); + me.TDempty(me, 1/4); + me.TD(me, 1, 1, e = makeXonoticButton("Previous", '0 0 0')); e.onClick = prevScreenshot_Click; e.onClickEntity = me; - me.TD(me, 1, me.columns/2, e = makeXonoticButton("Next", '0 0 0')); + me.TDempty(me, 1/4); + me.TD(me, 1, 1, e = makeXonoticButton("Start slide show", '0 0 0')); + e.onClick = startSlideShow_Click; + e.onClickEntity = me; + me.TDempty(me, 1/4); + me.TD(me, 1, 1, e = makeXonoticButton("Next", '0 0 0')); e.onClick = nextScreenshot_Click; e.onClickEntity = me; } diff --git a/qcsrc/menu/xonotic/screenshotlist.c b/qcsrc/menu/xonotic/screenshotlist.c index 97469227b..22d1eb2a2 100644 --- a/qcsrc/menu/xonotic/screenshotlist.c +++ b/qcsrc/menu/xonotic/screenshotlist.c @@ -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,6 +134,7 @@ 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) @@ -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)