1 #include "screenshotimage.qh"
2 #ifndef SCREENSHOTIMAGE_H
3 #define SCREENSHOTIMAGE_H
5 CLASS(XonoticScreenshotImage, XonoticImage)
6 METHOD(XonoticScreenshotImage, configureXonoticScreenshotImage, void(entity));
7 METHOD(XonoticScreenshotImage, load, void(entity, string));
8 METHOD(XonoticScreenshotImage, draw, void(entity));
9 ATTRIB(XonoticScreenshotImage, focusable, float, 1) // mousePress and mouseDrag work only if focusable is set
10 METHOD(XonoticScreenshotImage, mousePress, float(entity, vector));
11 METHOD(XonoticScreenshotImage, mouseDrag, float(entity, vector));
12 METHOD(XonoticScreenshotImage, mouseMove, float(entity, vector));
13 METHOD(XonoticScreenshotImage, resizeNotify, void(entity, vector, vector, vector, vector));
14 ATTRIB(XonoticScreenshotImage, realFontSize, vector, '0 0 0')
15 ATTRIB(XonoticScreenshotImage, fontSize, float, SKINFONTSIZE_NORMAL)
16 ATTRIB(XonoticScreenshotImage, showTitle, float, 1)
17 ATTRIB(XonoticScreenshotImage, screenshotTime, float, 0)
18 ATTRIB(XonoticScreenshotImage, screenshotTitle, string, string_null)
19 ENDCLASS(XonoticScreenshotImage)
20 entity makeXonoticScreenshotImage();
24 entity makeXonoticScreenshotImage()
27 me = NEW(XonoticScreenshotImage);
28 me.configureXonoticScreenshotImage(me);
32 void XonoticScreenshotImage_configureXonoticScreenshotImage(entity me)
34 me.configureXonoticImage(me, string_null, -2);
35 me.zoomLimitedByTheBox = false; // enable this to forbid enlarging the image more than the containing box (if making use of draw_SetClip is a too bad thing)
36 me.zoomSnapToTheBox = false; // disabled: it's cooler
39 void XonoticScreenshotImage_load(entity me, string theImage)
41 me.screenshotTime = time;
43 if (me.screenshotTitle)
44 strunzone(me.screenshotTitle);
45 me.screenshotTitle = strzone(substring(me.src, 13, strlen(theImage) - 13)); //strip "/screenshots/"
47 me.initZoom(me); // this image may have a different size
51 float XonoticScreenshotImage_mousePress(entity me, vector coords)
53 return me.drag_setStartPos(me, coords);
56 float XonoticScreenshotImage_mouseDrag(entity me, vector coords)
58 return me.drag(me, coords);
61 float XonoticScreenshotImage_mouseMove(entity me, vector coords)
63 return me.drag_setStartPos(me, coords);
66 void XonoticScreenshotImage_draw(entity me)
71 SUPER(XonoticScreenshotImage).draw(me);
72 if (me.showTitle && time < me.screenshotTime + 4) // 3 seconds at full alpha, 1 second fading out
74 theAlpha = (4 - (time - me.screenshotTime));
75 draw_CenterText('0.5 0 0', me.screenshotTitle, me.realFontSize, '1 1 1', theAlpha, false);
77 if (time < me.zoomTime + 2) // 1 seconds at full alpha, 1 second fading out
81 z = me.zoomFactor * 100;
82 if (z - floor(z) == 0)
83 zoomString = sprintf("%d%%", z);
85 zoomString = sprintf("%.2f%%", z);
86 theAlpha = (2 - (time - me.zoomTime));
87 draw_Text('0.05 0.95 0', zoomString, me.realFontSize, '1 1 1', theAlpha, false);
92 void XonoticScreenshotImage_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
94 SUPER(XonoticScreenshotImage).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
95 me.realFontSize_y = me.fontSize / absSize.y;
96 me.realFontSize_x = me.fontSize / absSize.x;