From 39b342c7c41a540abd406c17f3ba6a4b1f70843f Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 9 Aug 2010 21:30:40 +0200 Subject: [PATCH] Add a screenshot preview below the screenshot list --- .../xonotic/dialog_multiplayer_screenshot.c | 27 ++++++++++++++++--- qcsrc/menu/xonotic/screenshotlist.c | 23 +++++++++++++--- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c index 0daf4bfdb..86fbaf89d 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c @@ -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 diff --git a/qcsrc/menu/xonotic/screenshotlist.c b/qcsrc/menu/xonotic/screenshotlist.c index 0d59a614c..e7b45c00f 100644 --- a/qcsrc/menu/xonotic/screenshotlist.c +++ b/qcsrc/menu/xonotic/screenshotlist.c @@ -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) -- 2.39.2