@Music.ForcePlay(song) & @Music.Unforce

@Music.ForcePlay(song)
Changes the currently playing music to a new one and prevents the music from being changed by warps or surfing/riding and such.

@Music.Unforce
Allows warps and surfing/riding etc. to change the music again.
This commit is contained in:
JappaWakka 2023-06-17 11:37:08 +02:00
parent 3c5f5ee889
commit 0e8170a449
5 changed files with 41 additions and 14 deletions

View File

@ -99,6 +99,8 @@ Public Class MusicManager
Private Shared _lastVolume As Single = 1.0F
Private Shared _muted As Boolean = False
Private Shared _paused As Boolean = False
Public Shared ForceMusic As String = ""
Public Shared ReadOnly Property IsLooping As Boolean
Get
If Playlist IsNot Nothing AndAlso Playlist.Count <= 1 Then

View File

@ -28,8 +28,24 @@
End If
End If
Case "forceplay"
MusicManager.ClearCurrentlyPlaying()
MusicManager.Play(argument)
Dim LoopSong As Boolean = True
If argument.Split(",").Length > 1 Then
LoopSong = CBool(argument.GetSplit(1, ","))
End If
MusicManager.ForceMusic = argument.GetSplit(0, ",")
MusicManager.Play(argument.GetSplit(0, ","), LoopSong, LoopSong)
If LoopSong = True Then
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
Screen.Level.MusicLoop = argument
End If
Else
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
Screen.Level.MusicLoop = "silence"
End If
End If
Case "unforce"
MusicManager.ForceMusic = ""
Case "setmusicloop"
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
Screen.Level.MusicLoop = argument

View File

@ -170,7 +170,10 @@ Namespace ScriptVersion2
Private Shared Sub DoMusic()
' Commands:
r(New ScriptCommand("music", "play", {New ScriptArgument("musicFile", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Changes the currently playing music to a new one."))
r(New ScriptCommand("music", "play", {New ScriptArgument("musicFile", ScriptArgument.ArgumentTypes.Str),
New ScriptArgument("loopSong", ScriptArgument.ArgumentTypes.Bool, True, "true")}.ToList(), "Changes the currently playing music to a new one."))
r(New ScriptCommand("music", "forceplay", {New ScriptArgument("musicFile", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Changes the currently playing music to a new one and prevents the music from being changed by warps or surfing/riding and such."))
r(New ScriptCommand("music", "unforce", "Allows warps and surfing/riding etc. to change the music again."))
r(New ScriptCommand("music", "setmusicloop", {New ScriptArgument("musicFile", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Sets the map musicloop to a new musicfile."))
r(New ScriptCommand("music", "stop", "Stops the music playback."))
r(New ScriptCommand("music", "mute", "Silences the music playback."))

View File

@ -1060,23 +1060,29 @@ Public Class Level
Me._routeSign.Setup(MapName)
' Play the correct music track:
If IsRadioOn = True AndAlso GameJolt.PokegearScreen.StationCanPlay(Me.SelectedRadioStation) = True Then
MusicManager.Play(SelectedRadioStation.Music, True)
Else
IsRadioOn = False
If Me.Surfing = True Then
MusicManager.Play("surf", True)
If MusicManager.ForceMusic = "" Then
If IsRadioOn = True AndAlso GameJolt.PokegearScreen.StationCanPlay(Me.SelectedRadioStation) = True Then
MusicManager.Play(SelectedRadioStation.Music, True)
Else
If Me.Riding = True Then
MusicManager.Play("ride", True)
IsRadioOn = False
If Me.Surfing = True Then
MusicManager.Play("surf", True)
Else
If MusicManager.GetSong(MusicLoop) IsNot Nothing Then
MusicManager.Play(MusicLoop, True)
If Me.Riding = True Then
MusicManager.Play("ride", True)
Else
MusicManager.Play("silence")
If MusicManager.GetSong(MusicLoop) IsNot Nothing Then
MusicManager.Play(MusicLoop, True)
Else
MusicManager.Play("silence")
End If
End If
End If
End If
Else
If MusicManager._currentSongName <> MusicManager.ForceMusic Then
MusicManager.Play(MusicManager.ForceMusic, True)
End If
End If
' Initialize the world with newly loaded environment variables: