Xonotic
dialog_multiplayer_media_screenshot_viewer.qc
Go to the documentation of this file.
2 
3 #include "screenshotlist.qh"
4 #include "inputbox.qh"
5 #include "button.qh"
6 
9 {
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
13  {
14  // pause music
15  if(cvar("music_playlist_index") != -1)
16  {
17  music_playlist_index_backup = cvar("music_playlist_index");
18  cvar_set("music_playlist_sampleposition0", "0");
19  cvar_set("music_playlist_index", "999");
20  }
21  else
22  localcmd("\ncd pause\n");
23  }
24 
25  if (me.currentScrPath == scrImage)
26  return;
27  strcpy(me.currentScrPath, scrImage);
28  me.screenshotImage.load(me.screenshotImage, me.currentScrPath);
29  me.frame.setText(me.frame, me.screenshotImage.screenshotTitle);
30 }
32 {
33  me.scrList.goScreenshot(me.scrList, -1);
34 }
36 {
37  me.scrList.goScreenshot(me.scrList, +1);
38 }
40 {
41  me.screenshotImage.setZoom(me.screenshotImage, -2, false);
42 }
44 {
45  me.screenshotImage.setZoom(me.screenshotImage, -1/2, false);
46 }
48 {
49  me.screenshotImage.setZoom(me.screenshotImage, 0, false);
50 }
52 {
53  if (me.slideShowButton.forcePressed)
54  {
55  me.scrList.stopSlideShow(me.scrList);
56  me.slideShowButton.forcePressed = 0;
57  }
58  else
59  {
60  me.scrList.startSlideShow(me.scrList);
61  me.slideShowButton.forcePressed = 1;
62  }
63 }
64 float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, float shift)
65 {
66  switch(key)
67  {
68  case K_KP_LEFTARROW:
69  case K_LEFTARROW:
70  me.scrList.goScreenshot(me.scrList, -1);
71  return 1;
72  case K_KP_RIGHTARROW:
73  case K_RIGHTARROW:
74  me.scrList.goScreenshot(me.scrList, +1);
75  return 1;
76  case K_KP_ENTER:
77  case K_ENTER:
78  case K_SPACE:
79  // we cannot use SPACE/ENTER directly, as in a dialog they are needed
80  // to press buttons while browsing with only the keyboard
81  if (shift & S_CTRL)
82  {
84  return 1;
85  }
86  return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
87  default:
88  if (key == K_MWHEELUP || ascii == '+')
89  {
90  me.screenshotImage.setZoom(me.screenshotImage, -2, (key == K_MWHEELUP));
91  return 1;
92  }
93  else if (key == K_MWHEELDOWN || ascii == '-')
94  {
95  me.screenshotImage.setZoom(me.screenshotImage, -1/2, (key == K_MWHEELDOWN));
96  return 1;
97  }
98  if (me.scrList.keyDown(me.scrList, key, ascii, shift))
99  {
100  // keyDown has already changed the selected item
101  me.scrList.goScreenshot(me.scrList, 0);
102  return 1;
103  }
104  return SUPER(XonoticScreenshotViewerDialog).keyDown(me, key, ascii, shift);
105  }
106 }
108 {
109  // resume music
110  if(!cvar("menu_screenshotviewer_enablemusic"))
111  if(cvar("music_playlist_index") == 999)
112  {
113  cvar_set("music_playlist_index", ftos(music_playlist_index_backup));
114  }
115  else
116  localcmd("\ncd resume\n");
117 
118  me.scrList.stopSlideShow(me.scrList);
119  me.slideShowButton.forcePressed = 0;
121 }
123 {
124  entity e;
125  me.TR(me);
126  me.TD(me, me.rows - 1, me.columns, e = makeXonoticScreenshotImage());
127  e.showTitle = 0; // dialog title is enough
128  me.screenshotImage = e;
129  me.gotoRC(me, me.rows - 1, 0);
130  me.TDempty(me, 1/20 * me.columns);
131  me.TD(me, 1, 1/20 * me.columns, e = makeXonoticButton("-", '0 0 0'));
132  e.onClick = decreaseZoom_Click;
133  e.onClickEntity = me;
134  me.TD(me, 1, 1/20 * me.columns, e = makeXonoticButton("+", '0 0 0'));
135  e.onClick = increaseZoom_Click;
136  e.onClickEntity = me;
137  me.TD(me, 1, 2/20 * me.columns, e = makeXonoticButton(_("Reset"), '0 0 0'));
138  e.onClick = resetZoom_Click;
139  e.onClickEntity = me;
140 
141  me.TDempty(me, 2/20 * me.columns);
142  me.TD(me, 1, 3/20 * me.columns, e = makeXonoticButton(_("Previous"), '0 0 0'));
143  e.onClick = prevScreenshot_Click;
144  e.onClickEntity = me;
145  me.TD(me, 1, 3/20 * me.columns, e = makeXonoticButton(_("Next"), '0 0 0'));
146  e.onClick = nextScreenshot_Click;
147  e.onClickEntity = me;
148 
149  me.TDempty(me, 2/20 * me.columns);
150  me.TD(me, 1, 4/20 * me.columns, e = makeXonoticButton(_("Slide show"), '0 0 0'));
151  e.onClick = toggleSlideShow_Click;
152  e.onClickEntity = me;
153  me.slideShowButton = e;
154 }
float K_KP_RIGHTARROW
Definition: keycodes.qc:60
void resetZoom_Click(entity btn, entity me)
entity() spawn
void XonoticScreenshotViewerDialog_close(entity me)
void increaseZoom_Click(entity btn, entity me)
float K_SPACE
Definition: keycodes.qc:10
float K_RIGHTARROW
Definition: keycodes.qc:18
float K_KP_ENTER
Definition: keycodes.qc:74
#define strcpy(this, s)
Definition: string.qh:49
float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, float shift)
#define SUPER(cname)
Definition: oo.qh:219
#define NULL
Definition: post.qh:17
entity makeXonoticScreenshotImage()
float K_MWHEELDOWN
Definition: keycodes.qc:133
void XonoticScreenshotViewerDialog_fill(entity me)
void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage)
float K_LEFTARROW
Definition: keycodes.qc:17
float K_ENTER
Definition: keycodes.qc:8
void prevScreenshot_Click(entity btn, entity me)
void nextScreenshot_Click(entity btn, entity me)
const int S_CTRL
Definition: hud.qh:128
float K_KP_LEFTARROW
Definition: keycodes.qc:57
float K_MWHEELUP
Definition: keycodes.qc:132
void decreaseZoom_Click(entity btn, entity me)
void toggleSlideShow_Click(entity btn, entity me)