]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a screenshot preview below the screenshot list
authorterencehill <piuntn@gmail.com>
Mon, 9 Aug 2010 19:30:40 +0000 (21:30 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 9 Aug 2010 19:30:40 +0000 (21:30 +0200)
qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c
qcsrc/menu/xonotic/screenshotlist.c

index 0daf4bfdbb12f51fd5434b37019b6bb510808cd4..86fbaf89dc7b0b81d7eaf98f081a329e9a458b90 100644 (file)
@@ -5,8 +5,12 @@ CLASS(XonoticScreenshotBrowserTab) EXTENDS(XonoticTab)
        ATTRIB(XonoticScreenshotBrowserTab, intendedWidth, float, 0.9)
        ATTRIB(XonoticScreenshotBrowserTab, rows, float, 22)
        ATTRIB(XonoticScreenshotBrowserTab, columns, float, 6.5)
-       ATTRIB(XonoticScreenshotBrowserTab, screenshotImage, entity, NULL)
        ATTRIB(XonoticScreenshotBrowserTab, name, string, "ScreenshotBrowser")
+       
+       METHOD(XonoticScreenshotBrowserTab, loadPreviewScreenshot, void(entity, string))
+       ATTRIB(XonoticScreenshotBrowserTab, screenshotImage, entity, NULL)
+       ATTRIB(XonoticScreenshotBrowserTab, currentScrName, string, string_null)
+       ATTRIB(XonoticScreenshotBrowserTab, currentScrPath, string, string_null)
 ENDCLASS(XonoticScreenshotBrowserTab)
 entity makeXonoticScreenshotBrowserTab();
 #endif
@@ -19,6 +23,18 @@ entity makeXonoticScreenshotBrowserTab()
        me.configureDialog(me);
        return me;
 }
+void XonoticScreenshotBrowserTab_loadPreviewScreenshot(entity me, string 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));
+}
 void XonoticScreenshotBrowserTab_fill(entity me)
 {
        entity e, btn, slist;
@@ -36,10 +52,15 @@ void XonoticScreenshotBrowserTab_fill(entity me)
                        slist.screenshotViewerDialog = main.screenshotViewerDialog;
                        main.screenshotViewerDialog.scrList = slist;
        me.TR(me);
-               me.TD(me, me.rows - 4, me.columns, slist);
-       me.gotoRC(me, me.rows - 1, 0);
+               me.TD(me, me.rows - 4 - 11, me.columns, slist);
+       me.gotoRC(me, me.rows - 2 - 11, 0);
                me.TD(me, 1, me.columns, e = makeXonoticButton("View", '0 0 0'));
                        e.onClick = StartScreenshot_Click;
                        e.onClickEntity = slist;
+       me.gotoRC(me, me.rows - 1 - 11, 0);
+               me.TD(me, 12, me.columns, e = makeXonoticImage(string_null, -1));
+                       me.screenshotImage = e;
+                       slist.screenshotPreview = e;
+                       slist.screenshotBrowserDialog = me;
 }
 #endif
index 0d59a614cba1a18657e04d09b909636b8308921f..e7b45c00f441a09022151e66a70a46f4c49bac63 100644 (file)
@@ -5,6 +5,7 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox)
        METHOD(XonoticScreenshotList, resizeNotify, void(entity, vector, vector, vector, vector))
        METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, float, vector, float))
        METHOD(XonoticScreenshotList, getScreenshots, void(entity))
+       METHOD(XonoticScreenshotList, previewScreenshot, void(entity))
        METHOD(XonoticScreenshotList, startScreenshot, void(entity))
        METHOD(XonoticScreenshotList, screenshotName, string(entity, float))
        METHOD(XonoticScreenshotList, clickListBoxItem, void(entity, float, vector))
@@ -21,6 +22,9 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox)
        ATTRIB(XonoticScreenshotList, lastClickedScreenshot, float, -1)
        ATTRIB(XonoticScreenshotList, lastClickedTime, float, 0)
        ATTRIB(XonoticScreenshotList, filterString, string, string_null)
+
+       ATTRIB(XonoticScreenshotList, screenshotBrowserDialog, entity, NULL)
+       ATTRIB(XonoticScreenshotList, screenshotPreview, entity, NULL)
        ATTRIB(XonoticScreenshotList, screenshotViewerDialog, entity, NULL)
        METHOD(XonoticScreenshotList, goScreenshot, void(entity, float))
 ENDCLASS(XonoticScreenshotList)
@@ -120,7 +124,10 @@ void XonoticScreenshotList_drawListBoxItem(entity me, float i, vector absSize, f
 {
        string s;
        if(isSelected)
+       {
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+               me.previewScreenshot(me);
+       }
 
        s = me.screenshotName(me,i);
        s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
@@ -133,7 +140,7 @@ void XonoticScreenshotList_showNotify(entity me)
 }
 
 void ScreenshotList_Filter_Change(entity box, entity me)
-{      
+{
        if(me.filterString)
                strunzone(me.filterString);
 
@@ -148,6 +155,7 @@ void ScreenshotList_Filter_Change(entity box, entity me)
                me.filterString = string_null;
 
        me.getScreenshots(me);
+       me.setSelected(me, 0); //alway select the first element after a new search
 }
 
 void XonoticScreenshotList_goScreenshot(entity me, float d)
@@ -155,14 +163,21 @@ void XonoticScreenshotList_goScreenshot(entity me, float d)
        if(!me.screenshotViewerDialog)
                return;
        me.setSelected(me, me.selectedItem + d);
-       main.screenshotViewerDialog.loadScreenshot(main.screenshotViewerDialog, strcat("/screenshots/", me.screenshotName(me,me.selectedItem)));
+       me.screenshotViewerDialog.loadScreenshot(me.screenshotViewerDialog, strcat("/screenshots/", me.screenshotName(me,me.selectedItem)));
 }
 
 void XonoticScreenshotList_startScreenshot(entity me)
 {
-       main.screenshotViewerDialog.loadScreenshot(main.screenshotViewerDialog, strcat("/screenshots/", me.screenshotName(me,me.selectedItem)));
+       me.screenshotViewerDialog.loadScreenshot(me.screenshotViewerDialog, strcat("/screenshots/", me.screenshotName(me,me.selectedItem)));
        // pop up screenshot
-       DialogOpenButton_Click_withCoords(NULL, main.screenshotViewerDialog, me.origin + eX * (me.columnNameOrigin * me.size_x) + eY * ((me.itemHeight * me.selectedItem - me.scrollPos) * me.size_y), eY * me.itemAbsSize_y + eX * (me.itemAbsSize_x * me.columnNameSize));
+       DialogOpenButton_Click_withCoords(NULL, me.screenshotViewerDialog, me.origin + eX * (me.columnNameOrigin * me.size_x) + eY * ((me.itemHeight * me.selectedItem - me.scrollPos) * me.size_y), eY * me.itemAbsSize_y + eX * (me.itemAbsSize_x * me.columnNameSize));
+}
+
+void XonoticScreenshotList_previewScreenshot(entity me)
+{
+       if(!me.screenshotBrowserDialog)
+               return;
+       me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, strcat("/screenshots/", me.screenshotName(me,me.selectedItem)));
 }
 
 void StartScreenshot_Click(entity btn, entity me)