Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
soundlist.qc
Go to the documentation of this file.
1#include "soundlist.qh"
2
3#include "inputbox.qh"
4#include "playlist.qh"
5
7{
9 me.configureXonoticSoundList(me);
10 return me;
11}
12
14{
15 me.configureXonoticListBox(me);
16 me.nItems = 0;
17}
18
20{
21 string s = search_getfilename(me.listSound, i);
22 s = substring(s, 15, strlen(s) - 15 - 4); // sound/cdtracks/, .ogg
23 return s;
24}
25
26
28{
29 string s;
30
31 if(me.filterString)
32 //subdirectory in filterString allowed
33 s = strcat("sound/cdtracks/*", me.filterString, "*.ogg");
34 else
35 s = "sound/cdtracks/*.ogg";
36
37 if(me.listSound >= 0)
38 search_end(me.listSound);
39
40 me.listSound = search_begin(s, false, true);
41
42 me.nItems = (me.listSound < 0) ? 0 : search_getsize(me.listSound);
43}
44
46{
47 if(me.listSound >= 0)
48 search_end(me.listSound);
49}
50
51void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
52{
53 me.itemAbsSize = '0 0 0';
54 SUPER(XonoticSoundList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
55
56 me.itemAbsSize.y = absSize.y * me.itemHeight;
57 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
58 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
59 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
60 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
61
62 me.columnNumberOrigin = 0;
63 me.columnNumberSize = me.realFontSize.x * 3;
64
65 me.columnNameOrigin = me.columnNumberSize;
66 me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x;
67}
68
69void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
70{
71 string s;
72 if(isSelected)
73 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
74 else if(isFocused)
75 {
76 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
77 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
78 }
79
80 s = me.soundName(me, i);
81 if(s == cvar_string("menu_cdtrack")) // current menu track
82 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
83 else if(s == cvar_defstring("menu_cdtrack")) // default menu track
84 draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[D]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
85
86 s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
87 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
88}
89
91{
92 me.getSounds(me);
93}
94
96{
97 cvar_set("menu_cdtrack", me.soundName(me, me.selectedItem));
98}
99
101{
102 cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
103}
104
106{
107 strfree(me.filterString);
108
109 if(box.text != "")
110 me.filterString = strzone(box.text);
111
112 me.getSounds(me);
113}
114
116{
117 me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
118}
119
121{
122 int i;
123 for(i = 0; i < me.nItems; ++i)
124 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
125}
126
128{
129 me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
130}
131
132float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
133{
134 if (scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE || ((shift & S_CTRL) && scan == K_MOUSE1)
135 || ascii == '+')
136 {
137 SoundList_Add(NULL, me);
138 return 1;
139 }
140 else
141 return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);
142}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define strlen
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_KP_ENTER
Definition keycodes.qc:74
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
void draw_CenterText(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:298
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
void cvar_set(string name, string value)
string substring(string s, float start, float length)
string search_getfilename(float handle, float num)
const string cvar_string(string name)
float search_getsize(float handle)
float search_begin(string pattern, float caseinsensitive, float quiet)
const string cvar_defstring(string name)
string strzone(string s)
void search_end(float handle)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
void SoundList_Add(entity box, entity me)
Definition soundlist.qc:115
string XonoticSoundList_soundName(entity me, int i)
Definition soundlist.qc:19
float XonoticSoundList_keyDown(entity me, float scan, float ascii, float shift)
Definition soundlist.qc:132
void XonoticSoundList_configureXonoticSoundList(entity me)
Definition soundlist.qc:13
void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
Definition soundlist.qc:69
void XonoticSoundList_doubleClickListBoxItem(entity me, int i, vector where)
Definition soundlist.qc:127
void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
Definition soundlist.qc:51
void XonoticSoundList_getSounds(entity me)
Definition soundlist.qc:27
void XonoticSoundList_destroy(entity me)
Definition soundlist.qc:45
void SoundList_Filter_Change(entity box, entity me)
Definition soundlist.qc:105
entity makeXonoticSoundList()
Definition soundlist.qc:6
void SoundList_Menu_Track_Reset(entity box, entity me)
Definition soundlist.qc:100
void SoundList_Menu_Track_Change(entity box, entity me)
Definition soundlist.qc:95
void XonoticSoundList_showNotify(entity me)
Definition soundlist.qc:90
void SoundList_Add_All(entity box, entity me)
Definition soundlist.qc:120
#define strfree(this)
Definition string.qh:59
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44