@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 _lastVolume As Single = 1.0F
Private Shared _muted As Boolean = False Private Shared _muted As Boolean = False
Private Shared _paused As Boolean = False Private Shared _paused As Boolean = False
Public Shared ForceMusic As String = ""
Public Shared ReadOnly Property IsLooping As Boolean Public Shared ReadOnly Property IsLooping As Boolean
Get Get
If Playlist IsNot Nothing AndAlso Playlist.Count <= 1 Then If Playlist IsNot Nothing AndAlso Playlist.Count <= 1 Then

View File

@ -28,8 +28,24 @@
End If End If
End If End If
Case "forceplay" Case "forceplay"
MusicManager.ClearCurrentlyPlaying() Dim LoopSong As Boolean = True
MusicManager.Play(argument) 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" Case "setmusicloop"
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
Screen.Level.MusicLoop = argument Screen.Level.MusicLoop = argument

View File

@ -170,7 +170,10 @@ Namespace ScriptVersion2
Private Shared Sub DoMusic() Private Shared Sub DoMusic()
' Commands: ' 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", "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", "stop", "Stops the music playback."))
r(New ScriptCommand("music", "mute", "Silences the music playback.")) r(New ScriptCommand("music", "mute", "Silences the music playback."))

View File

@ -1060,6 +1060,7 @@ Public Class Level
Me._routeSign.Setup(MapName) Me._routeSign.Setup(MapName)
' Play the correct music track: ' Play the correct music track:
If MusicManager.ForceMusic = "" Then
If IsRadioOn = True AndAlso GameJolt.PokegearScreen.StationCanPlay(Me.SelectedRadioStation) = True Then If IsRadioOn = True AndAlso GameJolt.PokegearScreen.StationCanPlay(Me.SelectedRadioStation) = True Then
MusicManager.Play(SelectedRadioStation.Music, True) MusicManager.Play(SelectedRadioStation.Music, True)
Else Else
@ -1078,6 +1079,11 @@ Public Class Level
End If End If
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: ' Initialize the world with newly loaded environment variables:
World.Initialize(Screen.Level.EnvironmentType, Screen.Level.WeatherType) World.Initialize(Screen.Level.EnvironmentType, Screen.Level.WeatherType)