Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
hudskinlist.qc File Reference
#include "hudskinlist.qh"
#include "inputbox.qh"
Include dependency graph for hudskinlist.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void getAllHUDSkins (entity me, int sortbuf)
void getHUDSkinFiles (entity me, int sortbuf, string subdir)
void HUDSkinList_Filter_Change (entity box, entity me)
void HUDSkinList_Refresh_Click (entity btn, entity me)
void HUDSkinList_SavedName_Change (entity box, entity me)
entity makeXonoticHUDSkinList ()
void SaveHUDSkin_Click (entity btn, entity me)
void SetHUDSkin_Click (entity btn, entity me)
void XonoticHUDSkinList_configureXonoticHUDSkinList (entity me)
void XonoticHUDSkinList_destroy (entity me)
void XonoticHUDSkinList_doubleClickListBoxItem (entity me, float i, vector where)
void XonoticHUDSkinList_draw (entity me)
void XonoticHUDSkinList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
void XonoticHUDSkinList_getHUDSkins (entity me)
string XonoticHUDSkinList_hudskinAuthor (entity me, float i)
string XonoticHUDSkinList_hudskinName (entity me, float i)
string XonoticHUDSkinList_hudskinPath (entity me, float i)
string XonoticHUDSkinList_hudskinTitle (entity me, float i)
float XonoticHUDSkinList_keyDown (entity me, float scan, float ascii, float shift)
void XonoticHUDSkinList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void XonoticHUDSkinList_setHUDSkin (entity me)
void XonoticHUDSkinList_showNotify (entity me)

Variables

const float HUDSKINPARM_AUTHOR = 3
const float HUDSKINPARM_COUNT = 4
const float HUDSKINPARM_NAME = 0
const float HUDSKINPARM_PATH = 1
const float HUDSKINPARM_TITLE = 2

Function Documentation

◆ getAllHUDSkins()

void getAllHUDSkins ( entity me,
int sortbuf )

Definition at line 82 of file hudskinlist.qc.

83{
84 int n = buf_getsize(sortbuf);
85 for(int i = 0; i < n; ++i)
86 {
87 string entry = bufstr_get(sortbuf, i);
88 int ofs = strstrofs(entry, "/", 0);
89 string s = "";
90 string filename = entry;
91 if(ofs >= 0)
92 {
93 s = substring(entry, ofs + 1, -1); // skip initial "/"
94 s = strcat(s, "/");
95 bufstr_set(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_PATH, s);
96 filename = strcat(s, substring(entry, 0, ofs));
97 }
98 else
99 ofs = strlen(entry);
100 s = substring(entry, 4, ofs - 4 - 4); // remove "hud_" prefix and ".cfg" suffix
101 bufstr_set(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_NAME, s);
102
103 int fh = fopen(filename, FILE_READ);
104 if(fh < 0)
105 continue;
106 while((s = fgets(fh)) && substring(s, 0, 2) == "//")
107 {
108 tokenize_console(substring(s, 2, -1));
109 if(argv(0) == "title")
110 bufstr_set(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_TITLE, argv(1));
111 else if(argv(0) == "author")
112 bufstr_set(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_AUTHOR, argv(1));
113 }
114 fclose(fh);
115 }
116}
const float FILE_READ
#define strstrofs
#define strlen
#define tokenize_console
const float HUDSKINPARM_TITLE
const float HUDSKINPARM_PATH
const float HUDSKINPARM_AUTHOR
const float HUDSKINPARM_NAME
const float HUDSKINPARM_COUNT
string fgets(float fhandle)
void fclose(float fhandle)
string substring(string s, float start, float length)
float fopen(string filename, float mode)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References argv(), entity(), fclose(), fgets(), FILE_READ, fopen(), HUDSKINPARM_AUTHOR, HUDSKINPARM_COUNT, HUDSKINPARM_NAME, HUDSKINPARM_PATH, HUDSKINPARM_TITLE, strcat(), strlen, strstrofs, substring(), and tokenize_console.

Referenced by XonoticHUDSkinList_getHUDSkins().

◆ getHUDSkinFiles()

void getHUDSkinFiles ( entity me,
int sortbuf,
string subdir )

Definition at line 41 of file hudskinlist.qc.

42{
43 string s;
44 if(me.filterString)
45 s = me.filterString;
46 else
47 s = "*";
48 s = strcat(subdir, "hud_", s, ".cfg");
49
50 int list = search_begin(s, false, true);
51 if(list >= 0)
52 {
53 int n = search_getsize(list);
54 for(int i = 0; i < n; ++i)
55 {
56 string s = search_getfilename(list, i);
57 int subdir_ofs = strstrofs(s, "/", 0);
58 if(subdir_ofs >= 0)
59 {
60 int ofs = subdir_ofs;
61 while(ofs != -1)
62 {
63 subdir_ofs = ofs;
64 ofs = strstrofs(s, "/", subdir_ofs + 1);
65 }
66 }
67
68 if(subdir_ofs == -1)
69 bufstr_add(sortbuf, s, true);
70 else
71 {
72 subdir = substring(s, 0, subdir_ofs);
73 string filename = substring(s, subdir_ofs + 1, -1);
74 // invert path and filename position so we can sort sortbuf by filename
75 bufstr_add(sortbuf, strcat(filename, "/", subdir), true);
76 }
77 }
78 search_end(list);
79 }
80}
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)

References entity(), search_begin(), search_end(), search_getfilename(), search_getsize(), strcat(), strstrofs, and substring().

Referenced by XonoticHUDSkinList_getHUDSkins().

◆ HUDSkinList_Filter_Change()

void HUDSkinList_Filter_Change ( entity box,
entity me )

Definition at line 198 of file hudskinlist.qc.

199{
200 strfree(me.filterString);
201
202 if(box.text != "")
203 {
204 if (strstrofs(box.text, "*", 0) >= 0 || strstrofs(box.text, "?", 0) >= 0)
205 me.filterString = strzone(box.text);
206 else
207 me.filterString = strzone(strcat("*", box.text, "*"));
208 }
209
210 me.getHUDSkins(me);
211}
string strzone(string s)
#define strfree(this)
Definition string.qh:59

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

Referenced by XonoticHUDExitDialog_fill().

◆ HUDSkinList_Refresh_Click()

void HUDSkinList_Refresh_Click ( entity btn,
entity me )

Definition at line 184 of file hudskinlist.qc.

185{
186 me.getHUDSkins(me);
187 me.setSelected(me, 0); //always select the first element after a list update
188}

References entity().

Referenced by XonoticHUDExitDialog_fill(), and XonoticHUDSkinList_draw().

◆ HUDSkinList_SavedName_Change()

void HUDSkinList_SavedName_Change ( entity box,
entity me )

Definition at line 190 of file hudskinlist.qc.

191{
192 strfree(me.savedName);
193
194 if(box.text != "")
195 me.savedName = strzone(box.text);
196}

References entity(), strfree, and strzone().

Referenced by XonoticHUDExitDialog_fill().

◆ makeXonoticHUDSkinList()

entity makeXonoticHUDSkinList ( )

Definition at line 5 of file hudskinlist.qc.

6{
8 me.configureXonoticHUDSkinList(me);
9 return me;
10}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

Referenced by XonoticHUDExitDialog_fill(), and XonoticSkinResetDialog_fill().

◆ SaveHUDSkin_Click()

void SaveHUDSkin_Click ( entity btn,
entity me )

Definition at line 213 of file hudskinlist.qc.

214{
215 string s = me.savedName;
216 if(s == "")
217 s = "myconfig";
218 localcmd(sprintf("hud save \"%s\"\n", s));
219 me.delayedRefreshTime = time + 1;
220}
float time
void localcmd(string command,...)

References entity(), localcmd(), and time.

Referenced by XonoticHUDExitDialog_fill().

◆ SetHUDSkin_Click()

void SetHUDSkin_Click ( entity btn,
entity me )

Definition at line 238 of file hudskinlist.qc.

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

References entity().

Referenced by XonoticSkinResetDialog_fill().

◆ XonoticHUDSkinList_configureXonoticHUDSkinList()

void XonoticHUDSkinList_configureXonoticHUDSkinList ( entity me)

Definition at line 12 of file hudskinlist.qc.

13{
14 me.configureXonoticListBox(me);
15 me.nItems = 0;
16}

References entity().

◆ XonoticHUDSkinList_destroy()

void XonoticHUDSkinList_destroy ( entity me)

Definition at line 137 of file hudskinlist.qc.

138{
139 if(me.nItems > 0)
140 buf_del(me.listHUDSkin);
141}

References entity().

◆ XonoticHUDSkinList_doubleClickListBoxItem()

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

Definition at line 243 of file hudskinlist.qc.

244{
246 me.setHUDSkin(me);
247}
void m_play_click_sound(string soundfile)
Definition menu.qc:1111
const string MENU_SOUND_EXECUTE
Definition menu.qh:51

References entity(), m_play_click_sound(), MENU_SOUND_EXECUTE, and vector.

◆ XonoticHUDSkinList_draw()

void XonoticHUDSkinList_draw ( entity me)

Definition at line 222 of file hudskinlist.qc.

223{
224 if(me.delayedRefreshTime > 0 && me.delayedRefreshTime < time)
225 {
227 me.delayedRefreshTime = 0;
228 }
229 SUPER(XonoticHUDSkinList).draw(me);
230}
void HUDSkinList_Refresh_Click(entity btn, entity me)
#define SUPER(cname)
Definition oo.qh:231
#define NULL
Definition post.qh:14

References entity(), HUDSkinList_Refresh_Click(), NULL, SUPER, and time.

◆ XonoticHUDSkinList_drawListBoxItem()

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

Definition at line 158 of file hudskinlist.qc.

159{
160 string s, s2;
161 if(isSelected)
162 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
163 else if(isFocused)
164 {
165 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
166 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
167 }
168
169 s = me.hudskinTitle(me, i);
170 if(s == "")
171 s = me.hudskinName(me, i);
172 s2 = me.hudskinAuthor(me, i);
173 if(s2 != "")
174 s = strcat(s, " (", s2, ")");
175 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
176 draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 1);
177}
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
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1points s1 s2
Definition all.inc:471
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(), s2, strcat(), and vector.

◆ XonoticHUDSkinList_getHUDSkins()

void XonoticHUDSkinList_getHUDSkins ( entity me)

Definition at line 118 of file hudskinlist.qc.

119{
120 if (me.listHUDSkin >= 0)
121 buf_del(me.listHUDSkin);
122 me.listHUDSkin = buf_create();
123 if (me.listHUDSkin < 0)
124 {
125 me.nItems = 0;
126 return;
127 }
128 int sortbuf = buf_create();
129 getHUDSkinFiles(me, sortbuf, "");
130 getHUDSkinFiles(me, sortbuf, "data/");
131 buf_sort(sortbuf, 128, 0);
132 getAllHUDSkins(me, sortbuf);
133 buf_del(sortbuf);
134 me.nItems = buf_getsize(me.listHUDSkin) / HUDSKINPARM_COUNT;
135}
#define buf_create
void getHUDSkinFiles(entity me, int sortbuf, string subdir)
void getAllHUDSkins(entity me, int sortbuf)

References buf_create, entity(), getAllHUDSkins(), getHUDSkinFiles(), and HUDSKINPARM_COUNT.

◆ XonoticHUDSkinList_hudskinAuthor()

string XonoticHUDSkinList_hudskinAuthor ( entity me,
float i )

Definition at line 35 of file hudskinlist.qc.

36{
37 return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_AUTHOR);
38}

References entity(), HUDSKINPARM_AUTHOR, and HUDSKINPARM_COUNT.

◆ XonoticHUDSkinList_hudskinName()

string XonoticHUDSkinList_hudskinName ( entity me,
float i )

Definition at line 23 of file hudskinlist.qc.

24{
25 return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_NAME);
26}

References entity(), HUDSKINPARM_COUNT, and HUDSKINPARM_NAME.

◆ XonoticHUDSkinList_hudskinPath()

string XonoticHUDSkinList_hudskinPath ( entity me,
float i )

Definition at line 27 of file hudskinlist.qc.

28{
29 return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_PATH);
30}

References entity(), HUDSKINPARM_COUNT, and HUDSKINPARM_PATH.

◆ XonoticHUDSkinList_hudskinTitle()

string XonoticHUDSkinList_hudskinTitle ( entity me,
float i )

Definition at line 31 of file hudskinlist.qc.

32{
33 return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_TITLE);
34}

References entity(), HUDSKINPARM_COUNT, and HUDSKINPARM_TITLE.

◆ XonoticHUDSkinList_keyDown()

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

Definition at line 249 of file hudskinlist.qc.

250{
251 if(scan == K_ENTER || scan == K_KP_ENTER)
252 {
253 me.setHUDSkin(me);
254 return 1;
255 }
256 else
257 {
258 return SUPER(XonoticHUDSkinList).keyDown(me, scan, ascii, shift);
259 }
260}
float K_ENTER
Definition keycodes.qc:8
float K_KP_ENTER
Definition keycodes.qc:74

References entity(), K_ENTER, K_KP_ENTER, and SUPER.

◆ XonoticHUDSkinList_resizeNotify()

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

Definition at line 143 of file hudskinlist.qc.

144{
145 me.itemAbsSize = '0 0 0';
146 SUPER(XonoticHUDSkinList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
147
148 me.itemAbsSize.y = absSize.y * me.itemHeight;
149 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
150 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
151 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
152 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
153
154 me.columnNameOrigin = me.realFontSize.x;
155 me.columnNameSize = 1 - 2 * me.realFontSize.x;
156}

References entity(), SUPER, and vector.

◆ XonoticHUDSkinList_setHUDSkin()

void XonoticHUDSkinList_setHUDSkin ( entity me)

Definition at line 232 of file hudskinlist.qc.

233{
234 string cfg = strcat(me.hudskinPath(me, me.selectedItem), "hud_", me.hudskinName(me, me.selectedItem), ".cfg");
235 localcmd("exec \"", cfg, "\"\n");
236}

References entity(), localcmd(), and strcat().

◆ XonoticHUDSkinList_showNotify()

void XonoticHUDSkinList_showNotify ( entity me)

Definition at line 179 of file hudskinlist.qc.

180{
181 me.getHUDSkins(me);
182}

References entity().

Variable Documentation

◆ HUDSKINPARM_AUTHOR

const float HUDSKINPARM_AUTHOR = 3

Definition at line 21 of file hudskinlist.qc.

Referenced by getAllHUDSkins(), and XonoticHUDSkinList_hudskinAuthor().

◆ HUDSKINPARM_COUNT

◆ HUDSKINPARM_NAME

const float HUDSKINPARM_NAME = 0

Definition at line 18 of file hudskinlist.qc.

Referenced by getAllHUDSkins(), and XonoticHUDSkinList_hudskinName().

◆ HUDSKINPARM_PATH

const float HUDSKINPARM_PATH = 1

Definition at line 19 of file hudskinlist.qc.

Referenced by getAllHUDSkins(), and XonoticHUDSkinList_hudskinPath().

◆ HUDSKINPARM_TITLE

const float HUDSKINPARM_TITLE = 2

Definition at line 20 of file hudskinlist.qc.

Referenced by getAllHUDSkins(), and XonoticHUDSkinList_hudskinTitle().