2 CLASS(XonoticScreenshotViewerDialog) EXTENDS(XonoticDialog)
3 METHOD(XonoticScreenshotViewerDialog, fill, void(entity))
4 METHOD(XonoticScreenshotViewerDialog, keyDown, float(entity, float, float, float))
5 METHOD(XonoticScreenshotViewerDialog, loadScreenshot, void(entity, string))
6 METHOD(XonoticScreenshotViewerDialog, close, void(entity))
7 ATTRIB(XonoticScreenshotViewerDialog, title, string, "Screenshot Viewer")
8 ATTRIB(XonoticScreenshotViewerDialog, name, string, "ScreenshotViewer")
9 ATTRIB(XonoticScreenshotViewerDialog, intendedWidth, float, 1)
10 ATTRIB(XonoticScreenshotViewerDialog, rows, float, 25)
11 ATTRIB(XonoticScreenshotViewerDialog, columns, float, 4)
12 ATTRIB(XonoticScreenshotViewerDialog, color, vector, SKINCOLOR_DIALOG_SCREENSHOTVIEWER)
13 ATTRIB(XonoticScreenshotViewerDialog, scrList, entity, NULL)
14 ATTRIB(XonoticScreenshotViewerDialog, screenshotImage, entity, NULL)
15 ATTRIB(XonoticScreenshotViewerDialog, slideShowButton, entity, NULL)
16 ATTRIB(XonoticScreenshotViewerDialog, currentScrPath, string, string_null)
17 ENDCLASS(XonoticScreenshotViewerDialog)
21 void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage)
23 if (me.currentScrPath == scrImage)
25 if (me.currentScrPath)
26 strunzone(me.currentScrPath);
27 me.currentScrPath = strzone(scrImage);
28 me.screenshotImage.configureXonoticScreenshotImage(me.screenshotImage, me.currentScrPath);
30 void prevScreenshot_Click(entity btn, entity me)
32 me.scrList.goScreenshot(me.scrList, -1);
34 void nextScreenshot_Click(entity btn, entity me)
36 me.scrList.goScreenshot(me.scrList, +1);
38 void increaseZoom_Click(entity btn, entity me)
40 me.screenshotImage.setZoom(me.screenshotImage, 2);
42 void decreaseZoom_Click(entity btn, entity me)
44 me.screenshotImage.setZoom(me.screenshotImage, 1/2);
46 void resetZoom_Click(entity btn, entity me)
48 me.screenshotImage.setZoom(me.screenshotImage, 0);
50 void toggleSlideShow_Click(entity btn, entity me)
52 if (me.slideShowButton.forcePressed)
54 me.scrList.stopSlideShow(me.scrList);
55 me.slideShowButton.forcePressed = 0;
59 me.scrList.startSlideShow(me.scrList);
60 me.slideShowButton.forcePressed = 1;
63 float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, float shift)
69 me.scrList.goScreenshot(me.scrList, -1);
73 me.scrList.goScreenshot(me.scrList, +1);
78 // we cannot use SPACE/ENTER directly, as in a dialog they are needed
79 // to press buttons while browsing with only the keyboard
82 toggleSlideShow_Click(world, me);
85 return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
87 // mousewheel doesn't always reach the first/last screenshot
88 if (key == K_MWHEELUP)
90 else if (key == K_MWHEELDOWN)
92 if (me.scrList.keyDown(me.scrList, key, ascii, shift))
94 // keyDown has already changed the selected item
95 me.scrList.goScreenshot(me.scrList, 0);
98 return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
101 void XonoticScreenshotViewerDialog_close(entity me)
103 me.scrList.stopSlideShow(me.scrList);
104 me.slideShowButton.forcePressed = 0;
105 SUPER(XonoticScreenshotViewerDialog).close(me);
107 void XonoticScreenshotViewerDialog_fill(entity me)
111 me.TD(me, me.rows - 1, me.columns, e = makeXonoticScreenshotImage());
112 me.screenshotImage = e;
113 me.gotoRC(me, me.rows - 1, 0);
114 me.TDempty(me, 1/20 * me.columns);
115 me.TD(me, 1, 1/20 * me.columns, e = makeXonoticButton("-", '0 0 0'));
116 e.onClick = decreaseZoom_Click;
117 e.onClickEntity = me;
118 me.TD(me, 1, 1/20 * me.columns, e = makeXonoticButton("+", '0 0 0'));
119 e.onClick = increaseZoom_Click;
120 e.onClickEntity = me;
121 me.TD(me, 1, 2/20 * me.columns, e = makeXonoticButton("reset", '0 0 0'));
122 e.onClick = resetZoom_Click;
123 e.onClickEntity = me;
125 me.TDempty(me, 2/20 * me.columns);
126 me.TD(me, 1, 3/20 * me.columns, e = makeXonoticButton("Previous", '0 0 0'));
127 e.onClick = prevScreenshot_Click;
128 e.onClickEntity = me;
129 me.TD(me, 1, 3/20 * me.columns, e = makeXonoticButton("Next", '0 0 0'));
130 e.onClick = nextScreenshot_Click;
131 e.onClickEntity = me;
133 me.TDempty(me, 2/20 * me.columns);
134 me.TD(me, 1, 4/20 * me.columns, e = makeXonoticButton("Slide show", '0 0 0'));
135 e.onClick = toggleSlideShow_Click;
136 e.onClickEntity = me;
137 me.slideShowButton = e;