Xonotic
screenshotimage.qc
Go to the documentation of this file.
1 #include "screenshotimage.qh"
2 
4 {
5  entity me;
7  me.configureXonoticScreenshotImage(me);
8  return me;
9 }
10 
12 {
13  me.configureXonoticImage(me, string_null, -2);
14  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)
15  me.zoomSnapToTheBox = false; // disabled: it's cooler
16 }
17 
18 void XonoticScreenshotImage_load(entity me, string theImage)
19 {
20  me.screenshotTime = time;
21  me.src = theImage;
22  strcpy(me.screenshotTitle, substring(me.src, 13, strlen(theImage) - 13)); //strip "/screenshots/"
23 
24  me.initZoom(me); // this image may have a different size
25  me.setZoom(me, 0, 0);
26 }
27 
28 METHOD(XonoticScreenshotImage, mousePress, bool(XonoticScreenshotImage this, vector pos))
29 {
30  return this.drag_setStartPos(this, pos);
31 }
32 
34 {
35  return me.drag(me, coords);
36 }
37 
39 {
40  return me.drag_setStartPos(me, coords);
41 }
42 
44 {
45  if (me.src != "")
46  {
47  float theAlpha;
48  SUPER(XonoticScreenshotImage).draw(me);
49  if (me.showTitle && time < me.screenshotTime + 4) // 3 seconds at full alpha, 1 second fading out
50  {
51  theAlpha = (4 - (time - me.screenshotTime));
52  draw_CenterText('0.5 0 0', me.screenshotTitle, me.realFontSize, '1 1 1', theAlpha, false);
53  }
54  if (time < me.zoomTime + 2) // 1 seconds at full alpha, 1 second fading out
55  {
56  string zoomString;
57  float myzoom = me.zoomFactor * 100;
58  if (myzoom - floor(myzoom) == 0)
59  zoomString = sprintf("%d%%", myzoom);
60  else
61  zoomString = sprintf("%.2f%%", myzoom);
62  theAlpha = (2 - (time - me.zoomTime));
63  draw_Text('0.05 0.95 0', zoomString, me.realFontSize, '1 1 1', theAlpha, false);
64  }
65  }
66 }
67 
68 void XonoticScreenshotImage_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
69 {
70  SUPER(XonoticScreenshotImage).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
71  me.realFontSize_y = me.fontSize / absSize.y;
72  me.realFontSize_x = me.fontSize / absSize.x;
73 }
string string_null
Definition: nil.qh:9
#define NEW(cname,...)
Definition: oo.qh:105
void XonoticScreenshotImage_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void XonoticScreenshotImage_load(entity me, string theImage)
entity() spawn
void XonoticScreenshotImage_draw(entity me)
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
#define strcpy(this, s)
Definition: string.qh:49
float XonoticScreenshotImage_mouseDrag(entity me, vector coords)
#define SUPER(cname)
Definition: oo.qh:219
float XonoticScreenshotImage_mouseMove(entity me, vector coords)
entity makeXonoticScreenshotImage()
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void XonoticScreenshotImage_configureXonoticScreenshotImage(entity me)
float time
Definition: csprogsdefs.qc:16