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{
6 me.configureXonoticPlayList(me);
7 return me;
8}
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 221 of file playlist.qc.

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

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ PauseSound_Click()

void PauseSound_Click ( entity btn,
entity me )

Definition at line 242 of file playlist.qc.

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

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ PlayList_Remove()

void PlayList_Remove ( entity btn,
entity me )

Definition at line 91 of file playlist.qc.

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

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ PlayList_Remove_All()

void PlayList_Remove_All ( entity btn,
entity me )

Definition at line 96 of file playlist.qc.

97{
98 cvar_set("music_playlist_list0", "");
99 me.stopSound(me);
100 me.selectedItem = 0;
101}
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 216 of file playlist.qc.

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

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ StartSound_Click()

void StartSound_Click ( entity btn,
entity me )

Definition at line 211 of file playlist.qc.

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

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ StopSound_Click()

void StopSound_Click ( entity btn,
entity me )

Definition at line 173 of file playlist.qc.

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

References entity().

Referenced by XonoticMusicPlayerTab_fill().

◆ XonoticPlayList_addToPlayList()

void XonoticPlayList_addToPlayList ( entity me,
string track )

Definition at line 34 of file playlist.qc.

35{
36 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
37 if(me.nItems == 0)
38 {
39 cvar_set("music_playlist_list0", track);
40 return;
41 }
42 float i;
43 for(i = 0; i < me.nItems; ++i)
44 {
45 if(argv(i) == track)
46 return; // track is already in playlist
47 }
48 cvar_set("music_playlist_list0", strcat(cvar_string("music_playlist_list0"), " ", track));
49}
#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 10 of file playlist.qc.

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

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

◆ XonoticPlayList_doubleClickListBoxItem()

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

Definition at line 247 of file playlist.qc.

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

References entity(), and vector.

◆ XonoticPlayList_draw()

void XonoticPlayList_draw ( entity me)

Definition at line 125 of file playlist.qc.

126{
127 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
128 if(cvar("music_playlist_index") == 0 || cvar("music_playlist_index") == 999)
129 me.playingTrack = cvar("music_playlist_current0");
130 else
131 me.playingTrack = -1;
132 SUPER(XonoticPlayList).draw(me);
133}
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 135 of file playlist.qc.

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

253{
254 if (scan == K_ENTER || scan == K_KP_ENTER || ((shift & S_CTRL) && scan == K_MOUSE1))
255 {
256 me.startSound(me, 0);
257 return 1;
258 }
259 else if (scan == K_SPACE)
260 {
261 me.pauseSound(me);
262 return 1;
263 }
264 else if (scan == K_DEL || scan == K_KP_DEL || scan == K_BACKSPACE || scan == K_MOUSE3
265 || ascii == '-')
266 {
267 me.removeSelectedFromPlayList(me);
268 return 1;
269 }
270 else
271 return SUPER(XonoticPlayList).keyDown(me, scan, ascii, shift);
272}
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 103 of file playlist.qc.

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

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

◆ XonoticPlayList_pauseSound()

void XonoticPlayList_pauseSound ( entity me)

Definition at line 233 of file playlist.qc.

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

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

◆ XonoticPlayList_removeSelectedFromPlayList()

void XonoticPlayList_removeSelectedFromPlayList ( entity me)

Definition at line 51 of file playlist.qc.

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

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

References entity(), SUPER, and vector.

◆ XonoticPlayList_resumeSound()

void XonoticPlayList_resumeSound ( entity me)

Definition at line 226 of file playlist.qc.

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

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

◆ XonoticPlayList_startSound()

void XonoticPlayList_startSound ( entity me,
float offset )

Definition at line 178 of file playlist.qc.

179{
180 float f;
181 me.nItems = tokenize_console(cvar_string("music_playlist_list0"));
182 if(offset)
183 {
184 if(cvar("music_playlist_index") == -1)
185 return;
186 f = bound(0, cvar("music_playlist_current0") + offset, me.nItems - 1);
187 if(f == cvar("music_playlist_current0"))
188 return;
189 }
190 else
191 {
192 f = me.selectedItem;
193 // if it was paused then resume
194 if(f == cvar("music_playlist_current0"))
195 if(cvar("music_playlist_index") == 999)
196 {
197 me.resumeSound(me);
198 return;
199 }
200 // if it was not paused then proceed with restart
201 }
202
203 // START: list 0 is disabled by setting the index to 999
204 // 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)
205 // then we switch back to list 0
206 cvar_set("music_playlist_index", "999");
207 cvar_set("music_playlist_current0", ftos(f));
208 localcmd("\nwait; music_playlist_sampleposition0 0; wait; music_playlist_index 0\n");
209}
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 161 of file playlist.qc.

162{
163 // STOP: list 0 is disabled by setting the index to -1
164 // 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)
165 if(cvar("music_playlist_index") == 0 || cvar("music_playlist_index") == 999)
166 {
167 cvar_set("music_playlist_index", "-1");
168 localcmd("\nwait; music_playlist_sampleposition0 0\n");
169 localcmd("\ndefer 3 \"cd play $menu_cdtrack\"\n");
170 }
171}

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