- PlayMusic script function.

This commit is contained in:
Christoph Oelckers 2021-05-23 16:21:04 +02:00
parent d98a567597
commit b2545f8042
3 changed files with 15 additions and 5 deletions

View file

@ -1014,6 +1014,20 @@ DEFINE_ACTION_FUNCTION_NATIVE(_System, StopAllSounds, StopAllSounds)
return 0; return 0;
} }
static int PlayMusic(const FString& musname, int order, int looped)
{
return S_ChangeMusic(musname, order, !!looped, true);
}
DEFINE_ACTION_FUNCTION_NATIVE(_System, PlayMusic, PlayMusic)
{
PARAM_PROLOGUE;
PARAM_STRING(name);
PARAM_INT(order);
PARAM_BOOL(looped);
ACTION_RETURN_BOOL(PlayMusic(name, order, looped));
}
static void Mus_Stop() static void Mus_Stop()
{ {
S_StopMusic(true); S_StopMusic(true);

View file

@ -190,14 +190,9 @@ static FString LookupMusicCB(const char* musicname, int& order)
} }
static FString lastMusic;
int Mus_Play(const char *fn, bool loop) int Mus_Play(const char *fn, bool loop)
{ {
if (mus_blocked) return 1; // Caller should believe it succeeded. if (mus_blocked) return 1; // Caller should believe it succeeded.
if (*fn == '/') fn++;
// Store the requested names for resuming.
lastMusic = fn;
return S_ChangeMusic(fn, 0, loop, true); return S_ChangeMusic(fn, 0, loop, true);
} }

View file

@ -188,6 +188,7 @@ struct _ native // These are the global variables, the struct is only here to av
struct System native struct System native
{ {
native static void PlayMusic(String mus, int order = 0, bool looped = true);
native static void StopMusic(); native static void StopMusic();
native static void StopAllSounds(); native static void StopAllSounds();
native static bool SoundEnabled(); native static bool SoundEnabled();