]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Slide show in the viewer
authorterencehill <piuntn@gmail.com>
Sun, 22 Aug 2010 18:02:38 +0000 (20:02 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 22 Aug 2010 18:02:38 +0000 (20:02 +0200)
qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c
qcsrc/menu/xonotic/screenshotlist.c

index 2fde2d6c72b034fc852e57f2bf4275ba42dc1d51..2c69d5300fc012835f6dd0c9df8c2778fa0a7627 100644 (file)
@@ -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;
 }
index 97469227b49f7f96e40cad5896080b2820b14bcf..22d1eb2a2c6695dd00f4b0c42b7fc1442e1ec6b1 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,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)