mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-06-25 22:53:19 +00:00
music system now supports more tracks
This commit is contained in:
parent
40765e8808
commit
df5c36c2a6
22
sound.cpp
22
sound.cpp
|
@ -13,13 +13,19 @@ void playSound(cell *c, const string& fname, int vol = 100);
|
||||||
void resetmusic();
|
void resetmusic();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HDR
|
||||||
|
/** RogueViz may be used for situations where music does not correspond to lands, so we allow extra IDs */
|
||||||
|
static constexpr int MUSIC_MAX = 500;
|
||||||
|
#endif
|
||||||
|
|
||||||
EX const char *musicfile = "";
|
EX const char *musicfile = "";
|
||||||
EX bool audio;
|
EX bool audio;
|
||||||
EX string musiclicense;
|
EX string musiclicense;
|
||||||
EX string musfname[landtypes];
|
EX string musfname[MUSIC_MAX];
|
||||||
EX int musicvolume = 60;
|
EX int musicvolume = 60;
|
||||||
EX int effvolume = 60;
|
EX int effvolume = 60;
|
||||||
EX bool music_available;
|
EX bool music_available;
|
||||||
|
EX int musiclength[MUSIC_MAX];
|
||||||
|
|
||||||
EX eLand getCurrentLandForMusic() {
|
EX eLand getCurrentLandForMusic() {
|
||||||
eLand id = ((anims::center_music()) && centerover) ? centerover->land : cwt.at->land;
|
eLand id = ((anims::center_music()) && centerover) ? centerover->land : cwt.at->land;
|
||||||
|
@ -82,10 +88,10 @@ EX void playSeenSound(cell *c) {
|
||||||
|
|
||||||
#if CAP_SDLAUDIO
|
#if CAP_SDLAUDIO
|
||||||
|
|
||||||
bool loaded[landtypes];
|
bool loaded[MUSIC_MAX];
|
||||||
Mix_Music* music[landtypes];
|
Mix_Music* music[MUSIC_MAX];
|
||||||
EX int musicpos[landtypes];
|
EX int musicpos[MUSIC_MAX];
|
||||||
int musstart;
|
EX int musstart;
|
||||||
int musfadeval = 2000;
|
int musfadeval = 2000;
|
||||||
|
|
||||||
eLand cid = laNone;
|
eLand cid = laNone;
|
||||||
|
@ -162,9 +168,11 @@ EX bool loadMusicInfo(string dir) {
|
||||||
for(int i=0; buf[i]; i++) if(buf[i] == 10 || buf[i] == 13) buf[i] = 0;
|
for(int i=0; buf[i]; i++) if(buf[i] == 10 || buf[i] == 13) buf[i] = 0;
|
||||||
if(buf[0] == '[' && buf[3] == ']') {
|
if(buf[0] == '[' && buf[3] == ']') {
|
||||||
int id = (buf[1] - '0') * 10 + buf[2] - '0';
|
int id = (buf[1] - '0') * 10 + buf[2] - '0';
|
||||||
if(id >= 0 && id < landtypes) {
|
if(id >= 0 && id < MUSIC_MAX) {
|
||||||
if(buf[5] == '*' && buf[6] == '/') musfname[id] = dir2 + (buf+7);
|
if(buf[5] == 'L' && buf[6] == '=') musiclength[id] = atoi(buf+7);
|
||||||
|
else if(buf[5] == '*' && buf[6] == '/') musfname[id] = dir2 + (buf+7);
|
||||||
else musfname[id] = buf+5;
|
else musfname[id] = buf+5;
|
||||||
|
println(hlog, "set up for id=", id);
|
||||||
music_available = true;
|
music_available = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user