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

Go to the source code of this file.

Functions

entity makeXonoticPlayList ()
void NextSound_Click (entity btn, entity me)
void PauseSound_Click (entity btn, entity me)
void PlayList_Remove (entity btn, entity me)
void PlayList_Remove_All (entity btn, entity me)
void PrevSound_Click (entity btn, entity me)
void StartSound_Click (entity btn, entity me)
void StopSound_Click (entity btn, entity me)
void XonoticPlayList_addToPlayList (entity me, string track)
void XonoticPlayList_configureXonoticPlayList (entity me)
void XonoticPlayList_doubleClickListBoxItem (entity me, float i, vector where)
void XonoticPlayList_draw (entity me)
void XonoticPlayList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
float XonoticPlayList_keyDown (entity me, float scan, float ascii, float shift)
float XonoticPlayList_mouseDrag (entity me, vector pos)
void XonoticPlayList_pauseSound (entity me)
void XonoticPlayList_removeSelectedFromPlayList (entity me)
void XonoticPlayList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void XonoticPlayList_resumeSound (entity me)
void XonoticPlayList_startSound (entity me, float offset)
void XonoticPlayList_stopSound (entity me)

Function Documentation

◆ makeXonoticPlayList()

entity makeXonoticPlayList ( )

Definition at line 3 of file playlist.qc.

4{
5 entity me;
7 me.configureXonoticPlayList(me);
8 return me;
9}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

Referenced by XonoticMusicPlayerTab_fill().

◆ NextSound_Click()

void NextSound_Click ( entity btn,
entity me )

Definition at line 222 of file playlist.qc.

223{
224 me.startSound(me, +1);
225}

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ PauseSound_Click()

void PauseSound_Click ( entity btn,
entity me )

Definition at line 243 of file playlist.qc.

244{
245 me.pauseSound(me);
246}

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ PlayList_Remove()

void PlayList_Remove ( entity btn,
entity me )

Definition at line 92 of file playlist.qc.

93{
94 me.removeSelectedFromPlayList(me);
95}

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ PlayList_Remove_All()

void PlayList_Remove_All ( entity btn,
entity me )

Definition at line 97 of file playlist.qc.

98{
99 cvar_set("music_playlist_list0", "");
100 me.stopSound(me);
101 me.selectedItem = 0;
102}
void cvar_set(string name, string value)

References cvar_set(), and entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ PrevSound_Click()

void PrevSound_Click ( entity btn,
entity me )

Definition at line 217 of file playlist.qc.

218{
219 me.startSound(me, -1);
220}

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ StartSound_Click()

void StartSound_Click ( entity btn,
entity me )

Definition at line 212 of file playlist.qc.

213{
214 me.startSound(me, 0);
215}

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ StopSound_Click()

void StopSound_Click ( entity btn,
entity me )

Definition at line 174 of file playlist.qc.

175{
176 me.stopSound(me);
177}

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ XonoticPlayList_addToPlayList()

void XonoticPlayList_addToPlayList ( entity me,
string track )

Definition at line 35 of file playlist.qc.

36{
37 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
38 if(me.nItems == 0)
39 {
40 cvar_set("music_playlist_list0", track);
41 return;
42 }
43 float i;
44 for(i = 0; i < me.nItems; ++i)
45 {
46 if(argv(i) == track)
47 return; // track is already in playlist
48 }
49 cvar_set("music_playlist_list0", strcat(cvar_string("music_playlist_list0"), " ", track));
50}
#define tokenize_console
const string cvar_string(string name)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References argv(), cvar_set(), cvar_string(), entity(), strcat(), and tokenize_console.

◆ XonoticPlayList_configureXonoticPlayList()

void XonoticPlayList_configureXonoticPlayList ( entity me)

Definition at line 11 of file playlist.qc.

12{
13 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
14 me.configureXonoticListBox(me);
15}

References cvar_string(), entity(), and tokenize_console.

◆ XonoticPlayList_doubleClickListBoxItem()

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

Definition at line 248 of file playlist.qc.

249{
250 me.startSound(me, 0);
251}

References entity(), and vector.

◆ XonoticPlayList_draw()

void XonoticPlayList_draw ( entity me)

Definition at line 126 of file playlist.qc.

127{
128 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
129 if(cvar("music_playlist_index") == 0 || cvar("music_playlist_index") == 999)
130 me.playingTrack = cvar("music_playlist_current0");
131 else
132 me.playingTrack = -1;
133 SUPER(XonoticPlayList).draw(me);
134}
float cvar(string name)
#define SUPER(cname)
Definition oo.qh:231

References cvar(), cvar_string(), entity(), SUPER, and tokenize_console.

◆ XonoticPlayList_drawListBoxItem()

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

Definition at line 136 of file playlist.qc.

137{
138 string s;
139 if(isSelected)
140 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
141 else if(isFocused)
142 {
143 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
144 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
145 }
146
147 if(i == me.playingTrack)
148 {
149 float f = cvar("music_playlist_sampleposition0");
150 // display Play symbol: Unicode char U+25B6: Black Right-Pointing Triangle
151 if(f <= 0 || (((time * 2) & 1) && f > 0))
152 draw_Text(me.realUpperMargin * eY + (me.columnNumberOrigin + me.columnNumberSize) * eX, "\xE2\x96\xB6", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
153 }
154
155 s = ftos(i+1);
156 draw_CenterText(me.realUpperMargin * eY + (me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
157
158 s = draw_TextShortenToWidth(argv(i), me.columnNameSize, 0, me.realFontSize);
159 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
160}
float time
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
string ftos(float f)
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44

References argv(), cvar(), draw_CenterText(), draw_Fill(), draw_Text(), draw_TextShortenToWidth(), entity(), eX, eY, ftos(), getFadedAlpha(), time, and vector.

◆ XonoticPlayList_keyDown()

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

Definition at line 253 of file playlist.qc.

254{
255 if (scan == K_ENTER || scan == K_KP_ENTER || ((shift & S_CTRL) && scan == K_MOUSE1))
256 {
257 me.startSound(me, 0);
258 return 1;
259 }
260 else if (scan == K_SPACE)
261 {
262 me.pauseSound(me);
263 return 1;
264 }
265 else if (scan == K_DEL || scan == K_KP_DEL || scan == K_BACKSPACE || scan == K_MOUSE3
266 || ascii == '-')
267 {
268 me.removeSelectedFromPlayList(me);
269 return 1;
270 }
271 else
272 return SUPER(XonoticPlayList).keyDown(me, scan, ascii, shift);
273}
const int S_CTRL
Definition hud.qh:130
float K_BACKSPACE
Definition keycodes.qc:14
float K_MOUSE1
Definition keycodes.qc:129
float K_DEL
Definition keycodes.qc:38
float K_MOUSE3
Definition keycodes.qc:131
float K_SPACE
Definition keycodes.qc:10
float K_ENTER
Definition keycodes.qc:8
float K_KP_DEL
Definition keycodes.qc:68
float K_KP_ENTER
Definition keycodes.qc:74

References entity(), K_BACKSPACE, K_DEL, K_ENTER, K_KP_DEL, K_KP_ENTER, K_MOUSE1, K_MOUSE3, K_SPACE, S_CTRL, and SUPER.

◆ XonoticPlayList_mouseDrag()

float XonoticPlayList_mouseDrag ( entity me,
vector pos )

Definition at line 104 of file playlist.qc.

105{
106 float f, i;
107 i = me.selectedItem;
108 f = SUPER(XonoticPlayList).mouseDrag(me, pos);
109
110 if(me.pressed != 1) // don't change priority if the person is just scrolling
111 {
112 if(me.selectedItem != i)
113 {
114 cvar_set("music_playlist_list0", swapInPriorityList(cvar_string("music_playlist_list0"), me.selectedItem, i));
115 float c = cvar("music_playlist_current0");
116 if(c == i)
117 cvar_set("music_playlist_current0", ftos(me.selectedItem));
118 else if(c == me.selectedItem)
119 cvar_set("music_playlist_current0", ftos(i));
120 }
121 }
122
123 return f;
124}
string swapInPriorityList(string order, float i, float j)
Definition util.qc:655

References cvar(), cvar_set(), cvar_string(), entity(), ftos(), SUPER, swapInPriorityList(), and vector.

◆ XonoticPlayList_pauseSound()

void XonoticPlayList_pauseSound ( entity me)

Definition at line 234 of file playlist.qc.

235{
236 // PAUSE: list 0 is disabled by setting the index to 999
237 // (we know the track is paused because the engine sets sampleposition0 to remember current position)
238 if(cvar("music_playlist_index") == 0)
239 localcmd("\nmusic_playlist_index 999\n");
240 else me.resumeSound(me);
241}
void localcmd(string command,...)

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

◆ XonoticPlayList_removeSelectedFromPlayList()

void XonoticPlayList_removeSelectedFromPlayList ( entity me)

Definition at line 52 of file playlist.qc.

53{
54 float i, cpt = false;
55 string s = "";
56 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
57 if(me.nItems == 0)
58 return;
59 for(i = 0; i < me.nItems; ++i)
60 {
61 if(i == me.selectedItem)
62 {
63 if(i == me.nItems - 1)
64 me.setSelected(me, me.selectedItem - 1);
65 if(cvar("music_playlist_index") == 0 || cvar("music_playlist_index") == 999)
66 {
67 if(cvar("music_playlist_current0") == i)
68 cpt = true; // current playing track (we can't start next track here because startSound calls tokenize_console)
69 else if(cvar("music_playlist_current0") > i)
70 cvar_set("music_playlist_current0", ftos(cvar("music_playlist_current0") - 1));
71 }
72 continue;
73 }
74 s = strcat(s, " ", argv(i));
75 }
76 // we must stop the current playing track if it has been removed
77 // otherwise pause/play button will resume from another track
78 if(s == "")
79 {
80 cvar_set("music_playlist_list0", "");
81 if(cpt)
82 me.stopSound(me);
83 }
84 else
85 {
86 cvar_set("music_playlist_list0", substring(s, 1, strlen(s))); // remove initial space
87 if(cpt)
88 me.startSound(me, 0);
89 }
90}
#define strlen
string substring(string s, float start, float length)

References argv(), cvar(), cvar_set(), cvar_string(), entity(), ftos(), strcat(), strlen, substring(), and tokenize_console.

◆ XonoticPlayList_resizeNotify()

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

Definition at line 17 of file playlist.qc.

18{
19 me.itemAbsSize = '0 0 0';
20 SUPER(XonoticPlayList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
21
22 me.itemAbsSize.y = absSize.y * me.itemHeight;
23 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
24 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
25 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
26 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
27
28 me.columnNumberOrigin = 0;
29 me.columnNumberSize = 3 * me.realFontSize.x;
30
31 me.columnNameOrigin = me.columnNumberSize + me.realFontSize.x;
32 me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x;
33}

References entity(), SUPER, and vector.

◆ XonoticPlayList_resumeSound()

void XonoticPlayList_resumeSound ( entity me)

Definition at line 227 of file playlist.qc.

228{
229 // RESUME: list 0 is enabled by setting the index to 0
230 // (we reset sampleposition0 to 0 to mark the track as in playing back state)
231 if(cvar("music_playlist_index") == 999)
232 localcmd("\nmusic_playlist_index 0; wait; music_playlist_sampleposition0 0\n");
233}

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

◆ XonoticPlayList_startSound()

void XonoticPlayList_startSound ( entity me,
float offset )

Definition at line 179 of file playlist.qc.

180{
181 float f;
182 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
183 if(offset)
184 {
185 if(cvar("music_playlist_index") == -1)
186 return;
187 f = bound(0, cvar("music_playlist_current0") + offset, me.nItems - 1);
188 if(f == cvar("music_playlist_current0"))
189 return;
190 }
191 else
192 {
193 f = me.selectedItem;
194 // if it was paused then resume
195 if(f == cvar("music_playlist_current0"))
196 if(cvar("music_playlist_index") == 999)
197 {
198 me.resumeSound(me);
199 return;
200 }
201 // if it was not paused then proceed with restart
202 }
203
204 // START: list 0 is disabled by setting the index to 999
205 // we set current0 to the selected track and sampleposition0 to 0 to forget the position that the engine saves in this frame (for this reason we need to wait a frame)
206 // then we switch back to list 0
207 cvar_set("music_playlist_index", "999");
208 cvar_set("music_playlist_current0", ftos(f));
209 localcmd("\nwait; music_playlist_sampleposition0 0; wait; music_playlist_index 0\n");
210}
float bound(float min, float value, float max)

References bound(), cvar(), cvar_set(), cvar_string(), entity(), ftos(), localcmd(), and tokenize_console.

◆ XonoticPlayList_stopSound()

void XonoticPlayList_stopSound ( entity me)

Definition at line 162 of file playlist.qc.

163{
164 // STOP: list 0 is disabled by setting the index to -1
165 // we set sampleposition0 to 0 to forget the position that the engine saves in this frame (for this reason we need to wait a frame)
166 if(cvar("music_playlist_index") == 0 || cvar("music_playlist_index") == 999)
167 {
168 cvar_set("music_playlist_index", "-1");
169 localcmd("\nwait; music_playlist_sampleposition0 0\n");
170 localcmd("\ndefer 3 \"cd play $menu_cdtrack\"\n");
171 }
172}

References cvar(), cvar_set(), entity(), and localcmd().