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 32 of file screenshotlist.qc.

33{
34 string s;
35 if (subdir)
36 s="screenshots/*/";
37 else
38 s="screenshots/";
39 if(me.filterString)
40 s=strcat(s, me.filterString, ext);
41 else
42 s=strcat(s, "*", ext);
43
44 float list, i, n;
45 list = search_begin(s, false, true);
46 if(list >= 0)
47 {
48 n = search_getsize(list);
49 for(i = 0; i < n; ++i)
50 {
51 s = search_getfilename(list, i); // get initial full file name
52 s = substring(s, 12, (strlen(s) - 12 - 4)); // remove "screenshots/" prefix and ".<ext>" suffix
53 s = strdecolorize(s); // remove any pre-existing colors
54 if(subdir)
55 {
56 s = strreplace("/", "^7/", s); // clear colors at the forward slash
57 s = strcat("/", rgb_to_hexcolor(SKINCOLOR_SCREENSHOTLIST_SUBDIR), s); // add a forward slash for sorting, then color
58 bufstr_add(me.listScreenshot, s, true);
59 }
60 else { bufstr_add(me.listScreenshot, s, true); }
61 }
62 search_end(list);
63 }
64
65 if (subdir)
66 getScreenshots_for_ext(me, ext, false);
67}
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{
11 me.configureXonoticScreenshotList(me);
12 return me;
13}
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 154 of file screenshotlist.qc.

155{
156 strfree(me.filterString);
157
158 if(box.text != "")
159 {
160 if (strstrofs(box.text, "*", 0) >= 0 || strstrofs(box.text, "?", 0) >= 0)
161 me.filterString = strzone(box.text);
162 else
163 me.filterString = strzone(strcat("*", box.text, "*"));
164 }
165
167}
#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 169 of file screenshotlist.qc.

170{
171 me.filterBox = box;
172 me.filterTime = time + 0.5;
173}
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 148 of file screenshotlist.qc.

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

References entity().

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

◆ StartScreenshot_Click()

void StartScreenshot_Click ( entity btn,
entity me )

Definition at line 236 of file screenshotlist.qc.

237{
238 me.startScreenshot(me);
239}

References entity().

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

◆ XonoticScreenshotList_configureXonoticScreenshotList()

void XonoticScreenshotList_configureXonoticScreenshotList ( entity me)

Definition at line 15 of file screenshotlist.qc.

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

References entity().

◆ XonoticScreenshotList_destroy()

void XonoticScreenshotList_destroy ( entity me)

Definition at line 87 of file screenshotlist.qc.

88{
89 if(me.nItems > 0)
90 buf_del(me.listScreenshot);
91}

References entity().

◆ XonoticScreenshotList_doubleClickListBoxItem()

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

Definition at line 241 of file screenshotlist.qc.

242{
243 me.startScreenshot(me);
244}

References entity(), and vector.

◆ XonoticScreenshotList_draw()

void XonoticScreenshotList_draw ( entity me)

Definition at line 175 of file screenshotlist.qc.

176{
177 if (me.filterTime && time > me.filterTime)
178 {
179 ScreenshotList_Filter_Change(me.filterBox, me);
180 me.filterTime = 0;
181 }
182 if (me.newScreenshotTime && time > me.newScreenshotTime)
183 {
184 me.previewScreenshot(me);
185 me.newScreenshotTime = 0;
186 }
187 else if (me.newSlideShowScreenshotTime && time > me.newSlideShowScreenshotTime)
188 {
189 if (me.selectedItem == me.nItems - 1) //last screenshot?
190 {
191 // restart from the first screenshot
192 me.setSelected(me, 0);
193 me.goScreenshot(me, +0);
194 }
195 else
196 me.goScreenshot(me, +1);
197 }
199}
#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 126 of file screenshotlist.qc.

127{
128 string s;
129 if(isSelected)
130 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
131 else if(isFocused)
132 {
133 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
134 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
135 }
136
137 s = me.screenshotName(me,i);
138 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
139 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);
140}
string draw_TextShortenToWidth(string theText, float maxWidth, float ICanHasKallerz, vector SizeThxBye)
Definition draw.qc:378
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 69 of file screenshotlist.qc.

70{
71 if (me.listScreenshot >= 0)
72 buf_del(me.listScreenshot);
73 me.listScreenshot = buf_create();
74 if (me.listScreenshot < 0)
75 {
76 me.nItems = 0;
77 return;
78 }
79 getScreenshots_for_ext(me, ".jpg", true);
80 getScreenshots_for_ext(me, ".tga", true);
81 getScreenshots_for_ext(me, ".png", true);
82 me.nItems = buf_getsize(me.listScreenshot);
83 if(me.nItems > 0)
84 buf_sort(me.listScreenshot, 128, false);
85}
#define buf_create

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

◆ XonoticScreenshotList_goScreenshot()

void XonoticScreenshotList_goScreenshot ( entity me,
float d )

Definition at line 211 of file screenshotlist.qc.

212{
213 if(!me.screenshotViewerDialog)
214 return;
215 me.setSelected(me, me.selectedItem + d);
216 me.screenshotViewerDialog.loadScreenshot(me.screenshotViewerDialog, strcat("/screenshots/", strdecolorize(me.screenshotName(me,me.selectedItem))));
217}

References entity(), and strcat().

◆ XonoticScreenshotList_keyDown()

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

Definition at line 246 of file screenshotlist.qc.

247{
248 if (scan == K_ENTER || scan == K_KP_ENTER || scan == K_MOUSE2 || scan == K_SPACE || ((shift & S_CTRL) && scan == K_MOUSE1))
249 {
250 me.startScreenshot(me);
251 return 1;
252 }
253 return SUPER(XonoticScreenshotList).keyDown(me, scan, ascii, shift);
254}
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 226 of file screenshotlist.qc.

227{
228 if(!me.screenshotBrowserDialog)
229 return;
230 if (me.nItems <= 0)
231 me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, "");
232 else
233 me.screenshotBrowserDialog.loadPreviewScreenshot(me.screenshotBrowserDialog, strcat("/screenshots/", strdecolorize(me.screenshotName(me,me.selectedItem))));
234}

References entity(), and strcat().

◆ XonoticScreenshotList_resizeNotify()

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

Definition at line 93 of file screenshotlist.qc.

94{
95 me.itemAbsSize = '0 0 0';
96 SUPER(XonoticScreenshotList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
97
98 me.itemAbsSize.y = absSize.y * me.itemHeight;
99 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
100 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
101 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
102 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
103
104 me.columnNameOrigin = me.realFontSize.x;
105 me.columnNameSize = 1 - 2 * me.realFontSize.x;
106}

References entity(), SUPER, and vector.

◆ XonoticScreenshotList_screenshotName()

string XonoticScreenshotList_screenshotName ( entity me,
float i )

Definition at line 21 of file screenshotlist.qc.

22{
23 string s = bufstr_get(me.listScreenshot, i);
24
25 if(substring(s, 0, 1) == "/")
26 s = substring(s, 1, strlen(s) - 1); // remove the first forward slash
27
28 return s;
29}

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

◆ XonoticScreenshotList_setSelected()

void XonoticScreenshotList_setSelected ( entity me,
float i )

Definition at line 108 of file screenshotlist.qc.

109{
110 if (me.newSlideShowScreenshotTime)
111 me.startSlideShow(me);
112 float selectedItem_save = me.selectedItem;
113 SUPER(XonoticScreenshotList).setSelected(me, i);
114 if (me.pressed && me.selectedItem != selectedItem_save)
115 {
116 // avoid immediate image loading on quick repeated selection changes
117 me.newScreenshotTime = time + 0.22;
118 }
119 else if (time > me.newScreenshotTime)
120 {
121 me.newScreenshotTime = 0;
122 me.previewScreenshot(me); // load the preview on selection change
123 }
124}

References entity(), SUPER, and time.

◆ XonoticScreenshotList_showNotify()

void XonoticScreenshotList_showNotify ( entity me)

Definition at line 142 of file screenshotlist.qc.

143{
144 me.getScreenshots(me);
145 me.previewScreenshot(me);
146}

References entity().

◆ XonoticScreenshotList_startScreenshot()

void XonoticScreenshotList_startScreenshot ( entity me)

Definition at line 219 of file screenshotlist.qc.

220{
221 me.screenshotViewerDialog.loadScreenshot(me.screenshotViewerDialog, strcat("/screenshots/", strdecolorize(me.screenshotName(me,me.selectedItem))));
222 // pop up screenshot
223 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));
224}
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 201 of file screenshotlist.qc.

202{
203 me.newSlideShowScreenshotTime = time + 3;
204}

References entity(), and time.

◆ XonoticScreenshotList_stopSlideShow()

void XonoticScreenshotList_stopSlideShow ( entity me)

Definition at line 206 of file screenshotlist.qc.

207{
208 me.newSlideShowScreenshotTime = 0;
209}

References entity().