Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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.

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}
ERASEABLE string rgb_to_hexcolor(vector rgb)
Definition color.qh:183
#define strlen
string substring(string s, float start, float length)
string search_getfilename(float handle, float num)
float search_getsize(float handle)
float search_begin(string pattern, float caseinsensitive, float quiet)
void search_end(float handle)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
void getScreenshots_for_ext(entity me, string ext, float subdir)

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

Referenced by getScreenshots_for_ext(), and XonoticScreenshotList_getScreenshots().

◆ makeXonoticScreenshotList()

entity makeXonoticScreenshotList ( )

Definition at line 8 of file screenshotlist.qc.

9{
10 entity me;
12 me.configureXonoticScreenshotList(me);
13 return me;
14}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

Referenced by XonoticScreenshotList::stopSlideShow(), and XonoticScreenshotBrowserTab_fill().

◆ ScreenshotList_Filter_Change()

void ScreenshotList_Filter_Change ( entity box,
entity me )

Definition at line 156 of file screenshotlist.qc.

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}
#define strstrofs
string strzone(string s)
#define NULL
Definition post.qh:14
void ScreenshotList_Refresh_Click(entity btn, entity me)
#define strfree(this)
Definition string.qh:59

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

Referenced by XonoticScreenshotList::stopSlideShow(), and XonoticScreenshotList_draw().

◆ ScreenshotList_Filter_Would_Change()

void ScreenshotList_Filter_Would_Change ( entity box,
entity me )

Definition at line 171 of file screenshotlist.qc.

172{
173 me.filterBox = box;
174 me.filterTime = time + 0.5;
175}
float time

References entity(), and time.

Referenced by XonoticScreenshotList::stopSlideShow(), and XonoticScreenshotBrowserTab_fill().

◆ ScreenshotList_Refresh_Click()

void ScreenshotList_Refresh_Click ( entity btn,
entity me )

Definition at line 150 of file screenshotlist.qc.

151{
152 me.getScreenshots(me);
153 me.setSelected(me, 0); //always select the first element after a list update
154}

References entity().

Referenced by ScreenshotList_Filter_Change(), XonoticScreenshotList::stopSlideShow(), and XonoticScreenshotBrowserTab_fill().

◆ StartScreenshot_Click()

void StartScreenshot_Click ( entity btn,
entity me )

Definition at line 238 of file screenshotlist.qc.

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

References entity().

Referenced by XonoticScreenshotList::stopSlideShow(), and XonoticScreenshotBrowserTab_fill().

◆ 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}

References entity().

◆ 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}

References entity().

◆ 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}

References entity(), and vector.

◆ XonoticScreenshotList_draw()

void XonoticScreenshotList_draw ( entity me)

Definition at line 177 of file screenshotlist.qc.

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 }
201}
#define SUPER(cname)
Definition oo.qh:231
void ScreenshotList_Filter_Change(entity box, entity me)

References entity(), ScreenshotList_Filter_Change(), SUPER, and time.

◆ XonoticScreenshotList_drawListBoxItem()

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

Definition at line 128 of file screenshotlist.qc.

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}
string draw_TextShortenToWidth(string theText, float maxWidth, float ICanHasKallerz, vector SizeThxBye)
Definition draw.qc:377
void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:282
float draw_TextWidth(string theText, float ICanHasKallerz, vector SizeThxBye)
Definition draw.qc:304
void draw_Fill(vector theOrigin, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:97
float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
Definition util.qc:816
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44

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

◆ XonoticScreenshotList_getScreenshots()

void XonoticScreenshotList_getScreenshots ( entity me)

Definition at line 71 of file screenshotlist.qc.

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

References buf_create, entity(), and getScreenshots_for_ext().

◆ XonoticScreenshotList_goScreenshot()

void XonoticScreenshotList_goScreenshot ( entity me,
float d )

Definition at line 213 of file screenshotlist.qc.

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}

References entity(), and strcat().

◆ XonoticScreenshotList_keyDown()

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

Definition at line 248 of file screenshotlist.qc.

249{
250 if (scan == K_ENTER || scan == K_KP_ENTER || scan == K_MOUSE2 || scan == K_SPACE || ((shift & S_CTRL) && scan == K_MOUSE1))
251 {
252 me.startScreenshot(me);
253 return 1;
254 }
255 return SUPER(XonoticScreenshotList).keyDown(me, scan, ascii, shift);
256}
const int S_CTRL
Definition hud.qh:130
float K_MOUSE1
Definition keycodes.qc:129
float K_SPACE
Definition keycodes.qc:10
float K_ENTER
Definition keycodes.qc:8
float K_MOUSE2
Definition keycodes.qc:130
float K_KP_ENTER
Definition keycodes.qc:74

References entity(), K_ENTER, K_KP_ENTER, K_MOUSE1, K_MOUSE2, K_SPACE, S_CTRL, and SUPER.

◆ XonoticScreenshotList_previewScreenshot()

void XonoticScreenshotList_previewScreenshot ( entity me)

Definition at line 228 of file screenshotlist.qc.

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}

References entity(), and strcat().

◆ XonoticScreenshotList_resizeNotify()

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

Definition at line 95 of file screenshotlist.qc.

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}

References entity(), SUPER, and vector.

◆ XonoticScreenshotList_screenshotName()

string XonoticScreenshotList_screenshotName ( entity me,
float i )

Definition at line 22 of file screenshotlist.qc.

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}

References entity(), strlen, and substring().

◆ XonoticScreenshotList_setSelected()

void XonoticScreenshotList_setSelected ( entity me,
float i )

Definition at line 110 of file screenshotlist.qc.

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}

References entity(), SUPER, and time.

◆ 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}

References entity().

◆ XonoticScreenshotList_startScreenshot()

void XonoticScreenshotList_startScreenshot ( entity me)

Definition at line 221 of file screenshotlist.qc.

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}
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)

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

◆ XonoticScreenshotList_startSlideShow()

void XonoticScreenshotList_startSlideShow ( entity me)

Definition at line 203 of file screenshotlist.qc.

204{
205 me.newSlideShowScreenshotTime = time + 3;
206}

References entity(), and time.

◆ XonoticScreenshotList_stopSlideShow()

void XonoticScreenshotList_stopSlideShow ( entity me)

Definition at line 208 of file screenshotlist.qc.

209{
210 me.newSlideShowScreenshotTime = 0;
211}

References entity().