Xonotic
screenshotlist.qc File Reference
+ Include dependency graph for screenshotlist.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void getScreenshots_for_ext (entity me, string ext, float subdir)
 
entity makeXonoticScreenshotList ()
 
void ScreenshotList_Filter_Change (entity box, entity me)
 
void ScreenshotList_Filter_Would_Change (entity box, entity me)
 
void ScreenshotList_Refresh_Click (entity btn, entity me)
 
void StartScreenshot_Click (entity btn, entity me)
 
void XonoticScreenshotList_configureXonoticScreenshotList (entity me)
 
void XonoticScreenshotList_destroy (entity me)
 
void XonoticScreenshotList_doubleClickListBoxItem (entity me, float i, vector where)
 
void XonoticScreenshotList_draw (entity me)
 
void XonoticScreenshotList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
 
void XonoticScreenshotList_getScreenshots (entity me)
 
void XonoticScreenshotList_goScreenshot (entity me, float d)
 
float XonoticScreenshotList_keyDown (entity me, float scan, float ascii, float shift)
 
void XonoticScreenshotList_previewScreenshot (entity me)
 
void XonoticScreenshotList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
string XonoticScreenshotList_screenshotName (entity me, float i)
 
void XonoticScreenshotList_setSelected (entity me, float i)
 
void XonoticScreenshotList_showNotify (entity me)
 
void XonoticScreenshotList_startScreenshot (entity me)
 
void XonoticScreenshotList_startSlideShow (entity me)
 
void XonoticScreenshotList_stopSlideShow (entity me)
 

Function Documentation

◆ getScreenshots_for_ext()

void getScreenshots_for_ext ( entity  me,
string  ext,
float  subdir 
)

Definition at line 34 of file screenshotlist.qc.

References rgb_to_hexcolor(), search_begin(), search_end(), search_getfilename(), search_getsize(), strcat(), strlen(), and substring().

Referenced by XonoticScreenshotList_getScreenshots().

35 {
36  string s;
37  if (subdir)
38  s="screenshots/*/";
39  else
40  s="screenshots/";
41  if(me.filterString)
42  s=strcat(s, me.filterString, ext);
43  else
44  s=strcat(s, "*", ext);
45 
46  float list, i, n;
47  list = search_begin(s, false, true);
48  if(list >= 0)
49  {
50  n = search_getsize(list);
51  for(i = 0; i < n; ++i)
52  {
53  s = search_getfilename(list, i); // get initial full file name
54  s = substring(s, 12, (strlen(s) - 12 - 4)); // remove "screenshots/" prefix and ".<ext>" suffix
55  s = strdecolorize(s); // remove any pre-existing colors
56  if(subdir)
57  {
58  s = strreplace("/", "^7/", s); // clear colors at the forward slash
59  s = strcat("/", rgb_to_hexcolor(SKINCOLOR_SCREENSHOTLIST_SUBDIR), s); // add a forward slash for sorting, then color
60  bufstr_add(me.listScreenshot, s, true);
61  }
62  else { bufstr_add(me.listScreenshot, s, true); }
63  }
64  search_end(list);
65  }
66 
67  if (subdir)
68  getScreenshots_for_ext(me, ext, false);
69 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
ERASEABLE string rgb_to_hexcolor(vector rgb)
Definition: color.qh:183
void getScreenshots_for_ext(entity me, string ext, float subdir)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticScreenshotList()

entity makeXonoticScreenshotList ( )

Definition at line 8 of file screenshotlist.qc.

References entity(), and NEW.

Referenced by XonoticScreenshotBrowserTab_fill().

9 {
10  entity me;
12  me.configureXonoticScreenshotList(me);
13  return me;
14 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ScreenshotList_Filter_Change()

void ScreenshotList_Filter_Change ( entity  box,
entity  me 
)

Definition at line 156 of file screenshotlist.qc.

References NULL, ScreenshotList_Refresh_Click(), strcat(), strfree, strstrofs, and strzone().

Referenced by XonoticScreenshotList_draw().

157 {
158  strfree(me.filterString);
159 
160  if(box.text != "")
161  {
162  if (strstrofs(box.text, "*", 0) >= 0 || strstrofs(box.text, "?", 0) >= 0)
163  me.filterString = strzone(box.text);
164  else
165  me.filterString = strzone(strcat("*", box.text, "*"));
166  }
167 
169 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
#define strstrofs
Definition: dpextensions.qh:42
void ScreenshotList_Refresh_Click(entity btn, entity me)
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ScreenshotList_Filter_Would_Change()

void ScreenshotList_Filter_Would_Change ( entity  box,
entity  me 
)

Definition at line 171 of file screenshotlist.qc.

References time.

172 {
173  me.filterBox = box;
174  me.filterTime = time + 0.5;
175 }
float time
Definition: csprogsdefs.qc:16

◆ ScreenshotList_Refresh_Click()

void ScreenshotList_Refresh_Click ( entity  btn,
entity  me 
)

Definition at line 150 of file screenshotlist.qc.

Referenced by ScreenshotList_Filter_Change().

151 {
152  me.getScreenshots(me);
153  me.setSelected(me, 0); //always select the first element after a list update
154 }
+ Here is the caller graph for this function:

◆ StartScreenshot_Click()

void StartScreenshot_Click ( entity  btn,
entity  me 
)

Definition at line 238 of file screenshotlist.qc.

239 {
240  me.startScreenshot(me);
241 }

◆ XonoticScreenshotList_configureXonoticScreenshotList()

void XonoticScreenshotList_configureXonoticScreenshotList ( entity  me)

Definition at line 16 of file screenshotlist.qc.

17 {
18  me.configureXonoticListBox(me);
19  me.nItems = 0;
20 }

◆ XonoticScreenshotList_destroy()

void XonoticScreenshotList_destroy ( entity  me)

Definition at line 89 of file screenshotlist.qc.

90 {
91  if(me.nItems > 0)
92  buf_del(me.listScreenshot);
93 }

◆ XonoticScreenshotList_doubleClickListBoxItem()

void XonoticScreenshotList_doubleClickListBoxItem ( entity  me,
float  i,
vector  where 
)

Definition at line 243 of file screenshotlist.qc.

244 {
245  me.startScreenshot(me);
246 }

◆ XonoticScreenshotList_draw()

void XonoticScreenshotList_draw ( entity  me)

Definition at line 177 of file screenshotlist.qc.

References ScreenshotList_Filter_Change(), SUPER, and time.

178 {
179  if (me.filterTime && time > me.filterTime)
180  {
181  ScreenshotList_Filter_Change(me.filterBox, me);
182  me.filterTime = 0;
183  }
184  if (me.newScreenshotTime && time > me.newScreenshotTime)
185  {
186  me.previewScreenshot(me);
187  me.newScreenshotTime = 0;
188  }
189  else if (me.newSlideShowScreenshotTime && time > me.newSlideShowScreenshotTime)
190  {
191  if (me.selectedItem == me.nItems - 1) //last screenshot?
192  {
193  // restart from the first screenshot
194  me.setSelected(me, 0);
195  me.goScreenshot(me, +0);
196  }
197  else
198  me.goScreenshot(me, +1);
199  }
200  SUPER(XonoticScreenshotList).draw(me);
201 }
void ScreenshotList_Filter_Change(entity box, entity me)
#define SUPER(cname)
Definition: oo.qh:219
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ XonoticScreenshotList_drawListBoxItem()

void XonoticScreenshotList_drawListBoxItem ( entity  me,
int  i,
vector  absSize,
bool  isSelected,
bool  isFocused 
)

Definition at line 128 of file screenshotlist.qc.

References draw_Fill(), draw_Text(), draw_TextShortenToWidth(), draw_TextWidth(), eX, eY, and getFadedAlpha().

129 {
130  string s;
131  if(isSelected)
132  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
133  else if(isFocused)
134  {
135  me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
136  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
137  }
138 
139  s = me.screenshotName(me,i);
140  s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
141  draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 1);
142 }
const vector eY
Definition: vector.qh:45
const vector eX
Definition: vector.qh:44
+ Here is the call graph for this function:

◆ XonoticScreenshotList_getScreenshots()

void XonoticScreenshotList_getScreenshots ( entity  me)

Definition at line 71 of file screenshotlist.qc.

References buf_create, and getScreenshots_for_ext().

72 {
73  if (me.listScreenshot >= 0)
74  buf_del(me.listScreenshot);
75  me.listScreenshot = buf_create();
76  if (me.listScreenshot < 0)
77  {
78  me.nItems = 0;
79  return;
80  }
81  getScreenshots_for_ext(me, ".jpg", true);
82  getScreenshots_for_ext(me, ".tga", true);
83  getScreenshots_for_ext(me, ".png", true);
84  me.nItems = buf_getsize(me.listScreenshot);
85  if(me.nItems > 0)
86  buf_sort(me.listScreenshot, 128, false);
87 }
#define buf_create
Definition: dpextensions.qh:63
void getScreenshots_for_ext(entity me, string ext, float subdir)
+ Here is the call graph for this function:

◆ XonoticScreenshotList_goScreenshot()

void XonoticScreenshotList_goScreenshot ( entity  me,
float  d 
)

Definition at line 213 of file screenshotlist.qc.

References strcat().

214 {
215  if(!me.screenshotViewerDialog)
216  return;
217  me.setSelected(me, me.selectedItem + d);
218  me.screenshotViewerDialog.loadScreenshot(me.screenshotViewerDialog, strcat("/screenshots/", strdecolorize(me.screenshotName(me,me.selectedItem))));
219 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:

◆ XonoticScreenshotList_keyDown()

float XonoticScreenshotList_keyDown ( entity  me,
float  scan,
float  ascii,
float  shift 
)

Definition at line 248 of file screenshotlist.qc.

References K_ENTER, K_KP_ENTER, K_MOUSE2, K_SPACE, and SUPER.

249 {
250  if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_MOUSE2 || scan == K_SPACE) {
251  me.startScreenshot(me);
252  return 1;
253  }
254  return SUPER(XonoticScreenshotList).keyDown(me, scan, ascii, shift);
255 }
float K_SPACE
Definition: keycodes.qc:10
float K_KP_ENTER
Definition: keycodes.qc:74
#define SUPER(cname)
Definition: oo.qh:219
float K_MOUSE2
Definition: keycodes.qc:130
float K_ENTER
Definition: keycodes.qc:8

◆ XonoticScreenshotList_previewScreenshot()

void XonoticScreenshotList_previewScreenshot ( entity  me)

Definition at line 228 of file screenshotlist.qc.

References strcat().

229 {
230  if(!me.screenshotBrowserDialog)
231  return;
232  if (me.nItems <= 0)
233  me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, "");
234  else
235  me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, strcat("/screenshots/", strdecolorize(me.screenshotName(me,me.selectedItem))));
236 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:

◆ XonoticScreenshotList_resizeNotify()

void XonoticScreenshotList_resizeNotify ( entity  me,
vector  relOrigin,
vector  relSize,
vector  absOrigin,
vector  absSize 
)

Definition at line 95 of file screenshotlist.qc.

References SUPER.

96 {
97  me.itemAbsSize = '0 0 0';
98  SUPER(XonoticScreenshotList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
99 
100  me.itemAbsSize.y = absSize.y * me.itemHeight;
101  me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
102  me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
103  me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
104  me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
105 
106  me.columnNameOrigin = me.realFontSize.x;
107  me.columnNameSize = 1 - 2 * me.realFontSize.x;
108 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticScreenshotList_screenshotName()

string XonoticScreenshotList_screenshotName ( entity  me,
float  i 
)

Definition at line 22 of file screenshotlist.qc.

References strlen(), and substring().

23 {
24  string s;
25  s = bufstr_get(me.listScreenshot, i);
26 
27  if(substring(s, 0, 1) == "/")
28  s = substring(s, 1, strlen(s) - 1); // remove the first forward slash
29 
30  return s;
31 }
+ Here is the call graph for this function:

◆ XonoticScreenshotList_setSelected()

void XonoticScreenshotList_setSelected ( entity  me,
float  i 
)

Definition at line 110 of file screenshotlist.qc.

References SUPER, and time.

111 {
112  if (me.newSlideShowScreenshotTime)
113  me.startSlideShow(me);
114  float selectedItem_save = me.selectedItem;
115  SUPER(XonoticScreenshotList).setSelected(me, i);
116  if (me.pressed && me.selectedItem != selectedItem_save)
117  {
118  // avoid immediate image loading on quick repeated selection changes
119  me.newScreenshotTime = time + 0.22;
120  }
121  else if (time > me.newScreenshotTime)
122  {
123  me.newScreenshotTime = 0;
124  me.previewScreenshot(me); // load the preview on selection change
125  }
126 }
#define SUPER(cname)
Definition: oo.qh:219
float time
Definition: csprogsdefs.qc:16

◆ XonoticScreenshotList_showNotify()

void XonoticScreenshotList_showNotify ( entity  me)

Definition at line 144 of file screenshotlist.qc.

145 {
146  me.getScreenshots(me);
147  me.previewScreenshot(me);
148 }

◆ XonoticScreenshotList_startScreenshot()

void XonoticScreenshotList_startScreenshot ( entity  me)

Definition at line 221 of file screenshotlist.qc.

References DialogOpenButton_Click_withCoords(), eX, eY, NULL, and strcat().

222 {
223  me.screenshotViewerDialog.loadScreenshot(me.screenshotViewerDialog, strcat("/screenshots/", strdecolorize(me.screenshotName(me,me.selectedItem))));
224  // pop up screenshot
225  DialogOpenButton_Click_withCoords(NULL, me.screenshotViewerDialog, me.origin + eX * (me.columnNameOrigin * me.size.x) + eY * ((me.itemHeight * me.selectedItem - me.scrollPos) * me.size.y), eY * me.itemAbsSize.y + eX * (me.itemAbsSize.x * me.columnNameSize));
226 }
const vector eY
Definition: vector.qh:45
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
const vector eX
Definition: vector.qh:44
+ Here is the call graph for this function:

◆ XonoticScreenshotList_startSlideShow()

void XonoticScreenshotList_startSlideShow ( entity  me)

Definition at line 203 of file screenshotlist.qc.

References time.

204 {
205  me.newSlideShowScreenshotTime = time + 3;
206 }
float time
Definition: csprogsdefs.qc:16

◆ XonoticScreenshotList_stopSlideShow()

void XonoticScreenshotList_stopSlideShow ( entity  me)

Definition at line 208 of file screenshotlist.qc.

209 {
210  me.newSlideShowScreenshotTime = 0;
211 }