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