From: terencehill Date: Sun, 5 Feb 2012 19:09:38 +0000 (+0100) Subject: Code improvements to make possible to keep the zoom state while browsing the images... X-Git-Tag: xonotic-v0.8.0~139^2~1^2~155^2~15 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8421b635baee482a93ace1d68fda05ad27757bd4;p=xonotic%2Fxonotic-data.pk3dir.git Code improvements to make possible to keep the zoom state while browsing the images (not applied to the screenshot viewer but it'd be handy in the player model selector hehe) --- diff --git a/qcsrc/menu/item/image.c b/qcsrc/menu/item/image.c index 68b9ad93f..c7d1ae894 100644 --- a/qcsrc/menu/item/image.c +++ b/qcsrc/menu/item/image.c @@ -5,6 +5,7 @@ CLASS(Image) EXTENDS(Item) METHOD(Image, toString, string(entity)) METHOD(Image, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(Image, updateAspect, void(entity)) + METHOD(Image, initZoom, void(entity)) METHOD(Image, setZoom, void(entity, float, float)) METHOD(Image, drag_setStartPos, float(entity, vector)) METHOD(Image, drag, float(entity, vector)) @@ -32,6 +33,9 @@ string Image_toString(entity me) void Image_configureImage(entity me, string path) { me.src = path; +} +void Image_initZoom(entity me) +{ me.zoomOffset = '0.5 0.5 0'; me.zoomFactor = 1; if (me.forcedAspect == -2) @@ -39,6 +43,7 @@ void Image_configureImage(entity me, string path) if (me.zoomLimitedByTheBox) me.zoomMax = -1; // calculate zoomMax at the first updateAspect call } + void Image_draw(entity me) { if(me.imgSize_x > 1 || me.imgSize_y > 1) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c index 94e7d6548..94b9f5552 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c @@ -29,7 +29,7 @@ void XonoticScreenshotBrowserTab_loadPreviewScreenshot(entity me, string scrImag if (me.currentScrPath) strunzone(me.currentScrPath); me.currentScrPath = strzone(scrImage); - me.screenshotImage.configureXonoticScreenshotImage(me.screenshotImage, me.currentScrPath); + me.screenshotImage.load(me.screenshotImage, me.currentScrPath); } void XonoticScreenshotBrowserTab_fill(entity me) { diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c index 1ff4c340a..1a123c891 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c @@ -25,7 +25,7 @@ void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage) if (me.currentScrPath) strunzone(me.currentScrPath); me.currentScrPath = strzone(scrImage); - me.screenshotImage.configureXonoticScreenshotImage(me.screenshotImage, me.currentScrPath); + me.screenshotImage.load(me.screenshotImage, me.currentScrPath); me.frame.setText(me.frame, me.screenshotImage.screenshotTitle); } void prevScreenshot_Click(entity btn, entity me) diff --git a/qcsrc/menu/xonotic/screenshotimage.c b/qcsrc/menu/xonotic/screenshotimage.c index fa6be93f2..adde95b87 100644 --- a/qcsrc/menu/xonotic/screenshotimage.c +++ b/qcsrc/menu/xonotic/screenshotimage.c @@ -1,6 +1,7 @@ #ifdef INTERFACE -CLASS(XonoticScreenshotImage) EXTENDS(Image) - METHOD(XonoticScreenshotImage, configureXonoticScreenshotImage, void(entity, string)) +CLASS(XonoticScreenshotImage) EXTENDS(XonoticImage) + METHOD(XonoticScreenshotImage, configureXonoticScreenshotImage, void(entity)) + METHOD(XonoticScreenshotImage, load, void(entity, string)) METHOD(XonoticScreenshotImage, draw, void(entity)) ATTRIB(XonoticScreenshotImage, focusable, float, 1) // mousePress and mouseDrag work only if focusable is set METHOD(XonoticScreenshotImage, mousePress, float(entity, vector)) @@ -21,20 +22,26 @@ entity makeXonoticScreenshotImage() { entity me; me = spawnXonoticScreenshotImage(); - me.configureXonoticScreenshotImage(me, string_null); + me.configureXonoticScreenshotImage(me); return me; } -void XonoticScreenshotImage_configureXonoticScreenshotImage(entity me, string theImage) +void XonoticScreenshotImage_configureXonoticScreenshotImage(entity me) +{ + me.configureXonoticImage(me, string_null, -2); +} + +void XonoticScreenshotImage_load(entity me, string theImage) { - me.configureImage(me, theImage); - me.forcedAspect = -2; //me.zoomLimitedByTheBox = 1; me.screenshotTime = time; - me.updateAspect(me); + me.src = theImage; if (me.screenshotTitle) strunzone(me.screenshotTitle); me.screenshotTitle = strzone(substring(me.src, 13, strlen(theImage) - 13)); //strip "/screenshots/" + + me.initZoom(me); // this image may have a different size + me.setZoom(me, 0, 0); } float XonoticScreenshotImage_mousePress(entity me, vector coords)