Xonotic
soundlist.qc File Reference
#include "soundlist.qh"
#include "inputbox.qh"
#include "playlist.qh"
+ Include dependency graph for soundlist.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

entity makeXonoticSoundList ()
 
void SoundList_Add (entity box, entity me)
 
void SoundList_Add_All (entity box, entity me)
 
void SoundList_Filter_Change (entity box, entity me)
 
void SoundList_Menu_Track_Change (entity box, entity me)
 
void SoundList_Menu_Track_Reset (entity box, entity me)
 
void XonoticSoundList_configureXonoticSoundList (entity me)
 
void XonoticSoundList_destroy (entity me)
 
void XonoticSoundList_doubleClickListBoxItem (entity me, int i, vector where)
 
void XonoticSoundList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
 
void XonoticSoundList_getSounds (entity me)
 
float XonoticSoundList_keyDown (entity me, float scan, float ascii, float shift)
 
void XonoticSoundList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
void XonoticSoundList_showNotify (entity me)
 
string XonoticSoundList_soundName (entity me, int i)
 

Function Documentation

◆ makeXonoticSoundList()

entity makeXonoticSoundList ( )

Definition at line 6 of file soundlist.qc.

References entity(), and NEW.

7 {
8  entity me;
9  me = NEW(XonoticSoundList);
10  me.configureXonoticSoundList(me);
11  return me;
12 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:

◆ SoundList_Add()

void SoundList_Add ( entity  box,
entity  me 
)

Definition at line 117 of file soundlist.qc.

118 {
119  me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
120 }

◆ SoundList_Add_All()

void SoundList_Add_All ( entity  box,
entity  me 
)

Definition at line 122 of file soundlist.qc.

123 {
124  int i;
125  for(i = 0; i < me.nItems; ++i)
126  me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
127 }

◆ SoundList_Filter_Change()

void SoundList_Filter_Change ( entity  box,
entity  me 
)

Definition at line 107 of file soundlist.qc.

References strfree, and strzone().

108 {
109  strfree(me.filterString);
110 
111  if(box.text != "")
112  me.filterString = strzone(box.text);
113 
114  me.getSounds(me);
115 }
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:

◆ SoundList_Menu_Track_Change()

void SoundList_Menu_Track_Change ( entity  box,
entity  me 
)

Definition at line 97 of file soundlist.qc.

References cvar_set().

98 {
99  cvar_set("menu_cdtrack", me.soundName(me, me.selectedItem));
100 }
+ Here is the call graph for this function:

◆ SoundList_Menu_Track_Reset()

void SoundList_Menu_Track_Reset ( entity  box,
entity  me 
)

Definition at line 102 of file soundlist.qc.

References cvar_defstring(), and cvar_set().

103 {
104  cvar_set("menu_cdtrack", cvar_defstring("menu_cdtrack"));
105 }
+ Here is the call graph for this function:

◆ XonoticSoundList_configureXonoticSoundList()

void XonoticSoundList_configureXonoticSoundList ( entity  me)

Definition at line 14 of file soundlist.qc.

15 {
16  me.configureXonoticListBox(me);
17  me.nItems = 0;
18 }

◆ XonoticSoundList_destroy()

void XonoticSoundList_destroy ( entity  me)

Definition at line 47 of file soundlist.qc.

References search_end().

48 {
49  if(me.listSound >= 0)
50  search_end(me.listSound);
51 }
+ Here is the call graph for this function:

◆ XonoticSoundList_doubleClickListBoxItem()

void XonoticSoundList_doubleClickListBoxItem ( entity  me,
int  i,
vector  where 
)

Definition at line 129 of file soundlist.qc.

130 {
131  me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
132 }

◆ XonoticSoundList_drawListBoxItem()

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

Definition at line 71 of file soundlist.qc.

References cvar_defstring(), cvar_string(), draw_CenterText(), draw_Fill(), draw_Text(), draw_TextShortenToWidth(), eX, eY, and getFadedAlpha().

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 }
const vector eY
Definition: vector.qh:45
const vector eX
Definition: vector.qh:44
+ Here is the call graph for this function:

◆ XonoticSoundList_getSounds()

void XonoticSoundList_getSounds ( entity  me)

Definition at line 29 of file soundlist.qc.

References search_begin(), search_end(), search_getsize(), and strcat().

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 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:

◆ XonoticSoundList_keyDown()

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

Definition at line 134 of file soundlist.qc.

References K_ENTER, K_KP_ENTER, K_SPACE, and SUPER.

135 {
136  if(scan == K_ENTER || scan == K_KP_ENTER || scan == K_SPACE) {
137  me.playlist.addToPlayList(me.playlist, me.soundName(me, me.selectedItem));
138  return 1;
139  }
140  else
141  return SUPER(XonoticSoundList).keyDown(me, scan, ascii, shift);
142 }
float K_SPACE
Definition: keycodes.qc:10
float K_KP_ENTER
Definition: keycodes.qc:74
#define SUPER(cname)
Definition: oo.qh:219
float K_ENTER
Definition: keycodes.qc:8

◆ XonoticSoundList_resizeNotify()

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

Definition at line 53 of file soundlist.qc.

References SUPER.

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 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticSoundList_showNotify()

void XonoticSoundList_showNotify ( entity  me)

Definition at line 92 of file soundlist.qc.

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

◆ XonoticSoundList_soundName()

string XonoticSoundList_soundName ( entity  me,
int  i 
)

Definition at line 20 of file soundlist.qc.

References search_getfilename(), strlen(), and substring().

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 }
+ Here is the call graph for this function: