1 #include "dialog_multiplayer_media_screenshot_viewer.qh"
3 #include "screenshotlist.qh"
7 float music_playlist_index_backup;
8 void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage)
10 // disable music as it can lag depending on image loading time
11 if(!cvar("menu_screenshotviewer_enablemusic"))
12 if(cvar("music_playlist_index") != 999) // if the playlist isn't paused
15 if(cvar("music_playlist_index") != -1)
17 music_playlist_index_backup = cvar("music_playlist_index");
18 cvar_set("music_playlist_sampleposition0", "0");
19 cvar_set("music_playlist_index", "999");
22 localcmd("\ncd pause\n");
25 if (me.currentScrPath == scrImage)
27 if (me.currentScrPath)
28 strunzone(me.currentScrPath);
29 me.currentScrPath = strzone(scrImage);
30 me.screenshotImage.load(me.screenshotImage, me.currentScrPath);
31 me.frame.setText(me.frame, me.screenshotImage.screenshotTitle);
33 void prevScreenshot_Click(entity btn, entity me)
35 me.scrList.goScreenshot(me.scrList, -1);
37 void nextScreenshot_Click(entity btn, entity me)
39 me.scrList.goScreenshot(me.scrList, +1);
41 void increaseZoom_Click(entity btn, entity me)
43 me.screenshotImage.setZoom(me.screenshotImage, -2, false);
45 void decreaseZoom_Click(entity btn, entity me)
47 me.screenshotImage.setZoom(me.screenshotImage, -1/2, false);
49 void resetZoom_Click(entity btn, entity me)
51 me.screenshotImage.setZoom(me.screenshotImage, 0, false);
53 void toggleSlideShow_Click(entity btn, entity me)
55 if (me.slideShowButton.forcePressed)
57 me.scrList.stopSlideShow(me.scrList);
58 me.slideShowButton.forcePressed = 0;
62 me.scrList.startSlideShow(me.scrList);
63 me.slideShowButton.forcePressed = 1;
66 float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, float shift)
72 me.scrList.goScreenshot(me.scrList, -1);
76 me.scrList.goScreenshot(me.scrList, +1);
81 // we cannot use SPACE/ENTER directly, as in a dialog they are needed
82 // to press buttons while browsing with only the keyboard
85 toggleSlideShow_Click(NULL, me);
88 return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
90 if (key == K_MWHEELUP || ascii == '+')
92 me.screenshotImage.setZoom(me.screenshotImage, -2, (key == K_MWHEELUP));
95 else if (key == K_MWHEELDOWN || ascii == '-')
97 me.screenshotImage.setZoom(me.screenshotImage, -1/2, (key == K_MWHEELDOWN));
100 if (me.scrList.keyDown(me.scrList, key, ascii, shift))
102 // keyDown has already changed the selected item
103 me.scrList.goScreenshot(me.scrList, 0);
106 return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
109 void XonoticScreenshotViewerDialog_close(entity me)
112 if(!cvar("menu_screenshotviewer_enablemusic"))
113 if(cvar("music_playlist_index") == 999)
115 cvar_set("music_playlist_index", ftos(music_playlist_index_backup));
118 localcmd("\ncd resume\n");
120 me.scrList.stopSlideShow(me.scrList);
121 me.slideShowButton.forcePressed = 0;
122 SUPER(XonoticScreenshotViewerDialog).close(me);
124 void XonoticScreenshotViewerDialog_fill(entity me)
128 me.TD(me, me.rows - 1, me.columns, e = makeXonoticScreenshotImage());
129 e.showTitle = 0; // dialog title is enough
130 me.screenshotImage = e;
131 me.gotoRC(me, me.rows - 1, 0);
132 me.TDempty(me, 1/20 * me.columns);
133 me.TD(me, 1, 1/20 * me.columns, e = makeXonoticButton("-", '0 0 0'));
134 e.onClick = decreaseZoom_Click;
135 e.onClickEntity = me;
136 me.TD(me, 1, 1/20 * me.columns, e = makeXonoticButton("+", '0 0 0'));
137 e.onClick = increaseZoom_Click;
138 e.onClickEntity = me;
139 me.TD(me, 1, 2/20 * me.columns, e = makeXonoticButton(_("Reset"), '0 0 0'));
140 e.onClick = resetZoom_Click;
141 e.onClickEntity = me;
143 me.TDempty(me, 2/20 * me.columns);
144 me.TD(me, 1, 3/20 * me.columns, e = makeXonoticButton(_("Previous"), '0 0 0'));
145 e.onClick = prevScreenshot_Click;
146 e.onClickEntity = me;
147 me.TD(me, 1, 3/20 * me.columns, e = makeXonoticButton(_("Next"), '0 0 0'));
148 e.onClick = nextScreenshot_Click;
149 e.onClickEntity = me;
151 me.TDempty(me, 2/20 * me.columns);
152 me.TD(me, 1, 4/20 * me.columns, e = makeXonoticButton(_("Slide show"), '0 0 0'));
153 e.onClick = toggleSlideShow_Click;
154 e.onClickEntity = me;
155 me.slideShowButton = e;