]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Show title on top of the screenshot and add support for left/right keys to load ...
authorterencehill <piuntn@gmail.com>
Fri, 6 Aug 2010 12:55:12 +0000 (14:55 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 6 Aug 2010 12:55:12 +0000 (14:55 +0200)
qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c

index 4c7ead45626443de4698b01492a970b6e4786d20..d067db741da3b852908b78054d2bef0e63ed0236 100644 (file)
@@ -1,6 +1,7 @@
 #ifdef INTERFACE
 CLASS(XonoticScreenshotViewerDialog) EXTENDS(XonoticRootDialog)
        METHOD(XonoticScreenshotViewerDialog, fill, void(entity))
+       METHOD(XonoticScreenshotViewerDialog, keyDown, float(entity, float, float, float))
        METHOD(XonoticScreenshotViewerDialog, loadScreenshot, void(entity, string))
        ATTRIB(XonoticScreenshotViewerDialog, title, string, "Screenshot Viewer")
        ATTRIB(XonoticScreenshotViewerDialog, intendedWidth, float, 1)
@@ -8,16 +9,26 @@ CLASS(XonoticScreenshotViewerDialog) EXTENDS(XonoticRootDialog)
        ATTRIB(XonoticScreenshotViewerDialog, columns, float, 6.5)
        ATTRIB(XonoticScreenshotViewerDialog, screenshotImage, entity, NULL)
        ATTRIB(XonoticScreenshotViewerDialog, scrList, entity, NULL)
+       ATTRIB(XonoticScreenshotViewerDialog, titleLabel, entity, NULL)
+       
+       ATTRIB(XonoticScreenshotViewerDialog, currentScrName, string, string_null)
+       ATTRIB(XonoticScreenshotViewerDialog, currentScrPath, string, string_null)
 ENDCLASS(XonoticScreenshotViewerDialog)
 #endif
 
 #ifdef IMPLEMENTATION
 void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage)
 {
-       if (me.screenshotImage.src)
-               strunzone(me.screenshotImage.src);
-       me.screenshotImage.src = strzone(scrImage);
+       if (me.currentScrPath)
+               strunzone(me.currentScrPath);
+       me.currentScrPath = strzone(scrImage);
+       me.screenshotImage.configureImage(me.screenshotImage, me.currentScrPath);
        me.screenshotImage.updateAspect(me.screenshotImage);
+
+       if (me.currentScrName)
+               strunzone(me.currentScrName);
+       me.currentScrName = strzone(substring(scrImage, 13, strlen(scrImage) - 13));
+       me.titleLabel.setText(me.titleLabel, me.currentScrName);
 }
 void prevScreenshot_Click(entity btn, entity me)
 {
@@ -27,6 +38,23 @@ void nextScreenshot_Click(entity btn, entity me)
 {
        me.scrList.goScreenshot(me.scrList, +1);
 }
+
+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;
+               case K_KP_RIGHTARROW:
+               case K_RIGHTARROW:
+                       me.scrList.goScreenshot(me.scrList, +1);
+                       return 1;
+               default:
+                       return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
+       }
+}
 void XonoticScreenshotViewerDialog_fill(entity me)
 {
        entity e;
@@ -34,8 +62,10 @@ void XonoticScreenshotViewerDialog_fill(entity me)
        me.TR(me);
                me.TD(me, me.rows - 1, me.columns, e = makeXonoticImage(string_null, -1));
                me.screenshotImage = e;
+               me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
+               me.titleLabel = e;
        me.gotoRC(me, me.rows - 1, 0);
-               me.TD(me, 1, me.columns/2, e = makeXonoticButton("Prev", '0 0 0'));
+               me.TD(me, 1, me.columns/2, 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'));