Commit 80524647 authored by NY00123's avatar NY00123
Browse files

duke3d: Add an option for using directories like "music", via mus_dirs

parent 9fffed9f
......@@ -10,6 +10,7 @@
#include "compat.h"
#include "grpscan.h"
#include "palette.h"
#include "sndcards.h"
#include "texcache.h"
#include "vfs.h"
......@@ -1023,27 +1024,32 @@ buildvfs_kfd S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic
if (fp != buildvfs_kfd_invalid)
goto success;
#ifndef USE_PHYSFS
// look in ./music/<file's parent GRP name>/
// ex: ./music/duke3d/grabbag.mid
// ex: ./music/nwinter/grabbag.mid
if (origparent != NULL)
#ifdef USE_PHYSFS
EDUKE32_UNREACHABLE_SECTION();
#else
if (ASS_MusicDirs)
{
char const * const parentextension = Bstrrchr(origparent, '.');
uint32_t const namelength = parentextension != NULL ? (unsigned)(parentextension - origparent) : parentlength;
// look in ./music/<file's parent GRP name>/
// ex: ./music/duke3d/grabbag.mid
// ex: ./music/nwinter/grabbag.mid
if (origparent != NULL)
{
char const * const parentextension = Bstrrchr(origparent, '.');
uint32_t const namelength = parentextension != NULL ? (unsigned)(parentextension - origparent) : parentlength;
Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn);
Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn);
fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp != buildvfs_kfd_invalid)
goto success;
}
// look in ./music/
// ex: ./music/grabbag.mid
Bsprintf(testfn, "music/%s", fn);
fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp != buildvfs_kfd_invalid)
goto success;
}
// look in ./music/
// ex: ./music/grabbag.mid
Bsprintf(testfn, "music/%s", fn);
fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic);
if (fp != buildvfs_kfd_invalid)
goto success;
#endif
Xfree(testfn);
......
......@@ -1253,7 +1253,7 @@ static int32_t alsadevice;
static std::vector<alsa_mididevinfo_t> alsadevices;
#endif
static int32_t soundrate, soundvoices, musicdevice, opl3stereo;
static int32_t soundrate, soundvoices, musicdevice, opl3stereo, musicdirs;
static char sf2bankfile[BMAX_PATH];
static MenuOption_t MEO_SOUND = MAKE_MENUOPTION( &MF_Redfont, &MEOS_OffOn, &ud.config.SoundToggle );
static MenuEntry_t ME_SOUND = MAKE_MENUENTRY( "Sound:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND, Option );
......@@ -1287,6 +1287,9 @@ static MenuEntry_t ME_SOUND_SAMPLINGRATE = MAKE_MENUENTRY( "Sample rate:", &MF_R
static MenuOption_t MEO_SOUND_OPL3STEREO = MAKE_MENUOPTION(&MF_Redfont, &MEOS_NoYes, &opl3stereo);
static MenuEntry_t ME_SOUND_OPL3STEREO = MAKE_MENUENTRY( "OPL3 stereo mode:", &MF_Redfont, &MEF_BigOptionsRtSections, &MEO_SOUND_OPL3STEREO, Option );
static MenuOption_t MEO_SOUND_MUSICDIRS = MAKE_MENUOPTION(&MF_Redfont, &MEOS_NoYes, &musicdirs);
static MenuEntry_t ME_SOUND_MUSICDIRS = MAKE_MENUENTRY( "Use music dirs:", &MF_Redfont, &MEF_BigOptionsRtSections, &MEO_SOUND_MUSICDIRS, Option );
static MenuRangeInt32_t MEO_SOUND_NUMVOICES = MAKE_MENURANGE( &soundvoices, &MF_Redfont, 16, 128, 0, 8, DisplayTypeInteger );
static MenuEntry_t ME_SOUND_NUMVOICES = MAKE_MENUENTRY( "Voices:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_NUMVOICES, RangeInt32 );
......@@ -1353,6 +1356,7 @@ static MenuEntry_t *MEL_SOUND_DEVSETUP[] = {
#endif
&ME_SOUND_OPL3STEREO,
&ME_SOUND_SF2,
&ME_SOUND_MUSICDIRS,
#endif
&ME_Space4_Redfont,
&ME_SOUND_RESTART,
......@@ -2494,6 +2498,7 @@ static void Menu_Pre(MenuID_t cm)
#endif
MenuEntry_DisableOnCondition(&ME_SOUND_OPL3STEREO, !ud.config.MusicToggle);
MenuEntry_DisableOnCondition(&ME_SOUND_SF2, !ud.config.MusicToggle);
MenuEntry_DisableOnCondition(&ME_SOUND_MUSICDIRS, !ud.config.MusicToggle);
MenuEntry_HideOnCondition(&ME_SOUND_OPL3STEREO, musicdevice != ASS_OPL3);
MenuEntry_HideOnCondition(&ME_SOUND_SF2, musicdevice != ASS_SF2);
......@@ -2501,6 +2506,7 @@ static void Menu_Pre(MenuID_t cm)
MenuEntry_DisableOnCondition(&ME_SOUND_RESTART, soundrate == ud.config.MixRate &&
soundvoices == ud.config.NumVoices &&
musicdevice == ud.config.MusicDevice &&
musicdirs == ASS_MusicDirs &&
opl3stereo == AL_Stereo &&
!Bstrcmp(sf2bankfile, SF2_BankFile)
#ifdef __linux__
......@@ -3597,6 +3603,7 @@ static void Menu_RefreshSoundProperties()
soundrate = ud.config.MixRate;
soundvoices = ud.config.NumVoices;
musicdevice = ud.config.MusicDevice;
musicdirs = ASS_MusicDirs;
opl3stereo = AL_Stereo;
}
......@@ -3789,13 +3796,17 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
if (ud.config.MusicToggle)
{
int const needsReInit = (ud.config.MusicDevice != musicdevice || (musicdevice == ASS_SF2 && Bstrcmp(SF2_BankFile, sf2bankfile))
int const musicdirsToggleUsed = (musicdirs != ASS_MusicDirs);
int const needsReInit =
(ud.config.MusicDevice != musicdevice || (musicdevice == ASS_SF2 && Bstrcmp(SF2_BankFile, sf2bankfile))
|| musicdirsToggleUsed
#ifdef __linux__
|| (musicdevice == ASS_ALSA && (size_t)alsadevice < alsadevices.size() &&
(ALSA_ClientID != alsadevices[alsadevice].clntid || ALSA_PortID != alsadevices[alsadevice].portid))
#endif
);
ASS_MusicDirs = musicdirs;
AL_Stereo = opl3stereo;
Bstrcpy(SF2_BankFile, sf2bankfile);
......@@ -3808,10 +3819,13 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
S_RestartMusic();
if (MusicIsWaveform)
MV_SetPosition(MusicVoice, (int)pos.tick);
else
MUSIC_SetSongPosition(pos.measure, pos.beat, pos.tick);
if (!musicdirsToggleUsed)
{
if (MusicIsWaveform)
MV_SetPosition(MusicVoice, (int)pos.tick);
else
MUSIC_SetSongPosition(pos.measure, pos.beat, pos.tick);
}
}
Menu_RefreshSoundProperties();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment