]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Call previewScreenshot only on selection change (not at every frame...)
authorterencehill <piuntn@gmail.com>
Thu, 12 Aug 2010 21:03:17 +0000 (23:03 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 12 Aug 2010 21:03:17 +0000 (23:03 +0200)
Also add 2 checks

qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c
qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c
qcsrc/menu/xonotic/screenshotlist.c

index 56aacdf302d75c414ec0d004380632169c3e8d99..b0eebeda1a864128be72041c1abe6b7725c6b5ef 100644 (file)
@@ -24,6 +24,8 @@ entity makeXonoticScreenshotBrowserTab()
 }
 void XonoticScreenshotBrowserTab_loadPreviewScreenshot(entity me, string scrImage)
 {
+       if (me.currentScrPath == scrImage)
+               return;
        if (me.currentScrPath)
                strunzone(me.currentScrPath);
        me.currentScrPath = strzone(scrImage);
index f0cd2ecc60ba374183a536bb6efd81f7c3efdfc5..2fde2d6c72b034fc852e57f2bf4275ba42dc1d51 100644 (file)
@@ -18,6 +18,8 @@ ENDCLASS(XonoticScreenshotViewerDialog)
 #ifdef IMPLEMENTATION
 void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage)
 {
+       if (me.currentScrPath == scrImage)
+               return;
        if (me.currentScrPath)
                strunzone(me.currentScrPath);
        me.currentScrPath = strzone(scrImage);
index a60c3f8ca9c2990cb436b33ab8b2a2072449ba1a..1fa901d9a3d5470d09e489b3196fbddced9ce9f9 100644 (file)
@@ -3,6 +3,7 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox)
        METHOD(XonoticScreenshotList, configureXonoticScreenshotList, void(entity))
        ATTRIB(XonoticScreenshotList, rowsPerItem, float, 1)
        METHOD(XonoticScreenshotList, resizeNotify, void(entity, vector, vector, vector, vector))
+       METHOD(XonoticScreenshotList, setSelected, void(entity, float))
        METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, float, vector, float))
        METHOD(XonoticScreenshotList, getScreenshots, void(entity))
        METHOD(XonoticScreenshotList, previewScreenshot, void(entity))
@@ -121,14 +122,17 @@ void XonoticScreenshotList_resizeNotify(entity me, vector relOrigin, vector relS
        me.columnNameSize = 1 - 2 * me.realFontSize_x;
 }
 
+void XonoticScreenshotList_setSelected(entity me, float i)
+{
+       SUPER(XonoticScreenshotList).setSelected(me, i);
+       me.previewScreenshot(me); // load the preview on selection change
+}
+
 void XonoticScreenshotList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
 {
        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);
@@ -138,15 +142,13 @@ void XonoticScreenshotList_drawListBoxItem(entity me, float i, vector absSize, f
 void XonoticScreenshotList_showNotify(entity me)
 {
        me.getScreenshots(me);
+       me.previewScreenshot(me);
 }
 
 void ScreenshotList_Refresh_Click(entity btn, entity me)
 {
        me.getScreenshots(me);
-       if (me.nItems <= 0)
-               me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, "");
-       else
-               me.setSelected(me, 0); //always select the first element after a list update
+       me.setSelected(me, 0); //always select the first element after a list update
 }
 
 void ScreenshotList_Filter_Change(entity box, entity me)
@@ -186,7 +188,10 @@ void XonoticScreenshotList_previewScreenshot(entity me)
 {
        if(!me.screenshotBrowserDialog)
                return;
-       me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, strcat("/screenshots/", me.screenshotName(me,me.selectedItem)));
+       if (me.nItems <= 0)
+               me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, "");
+       else
+               me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, strcat("/screenshots/", me.screenshotName(me,me.selectedItem)));
 }
 
 void StartScreenshot_Click(entity btn, entity me)