tabulation

This commit is contained in:
aragas 2020-11-06 15:07:19 +03:00 committed by Vitaly Mikhailov
parent e8d980b34a
commit b10415ccf0
2 changed files with 224 additions and 224 deletions

View File

@ -54,12 +54,12 @@
End Function End Function
Public Overrides Sub ClickFunction() Public Overrides Sub ClickFunction()
If Me.TriggerID = 1 Or Me.TriggerID = 2 Then If Me.TriggerID = 1 Or Me.TriggerID = 2 Then
ActionScript.TempInputDirection = -1 ActionScript.TempInputDirection = -1
Me.clickedToActivate = True Me.clickedToActivate = True
TriggerScript(False) TriggerScript(False)
End If End If
End Sub End Sub
Public Overrides Sub Update() Public Overrides Sub Update()
If Me.ActivateScript = True And Screen.Camera.Position.X = Me.Position.X And Screen.Camera.Position.Z = Me.Position.Z And CInt(Screen.Camera.Position.Y) = CInt(Me.Position.Y) Then If Me.ActivateScript = True And Screen.Camera.Position.X = Me.Position.X And Screen.Camera.Position.Z = Me.Position.Z And CInt(Screen.Camera.Position.Y) = CInt(Me.Position.Y) Then
@ -81,13 +81,13 @@
Me.clickedToActivate = False Me.clickedToActivate = False
SoundManager.PlaySound("select") SoundManager.PlaySound("select")
End If End If
If Me.TriggerID = 2 Then If Me.TriggerID = 2 Then
oS.ActionScript.StartScript(Me.AdditionalValue, GetActivationID()) oS.ActionScript.StartScript(Me.AdditionalValue, GetActivationID())
Else Else
oS.ActionScript.StartScript(Me._scriptID, GetActivationID()) oS.ActionScript.StartScript(Me._scriptID, GetActivationID())
ActionScript.TempSpin = True ActionScript.TempSpin = True
End If End If
End If End If
End If End If
End If End If
TriggeredScriptBlock = False TriggeredScriptBlock = False

View File

@ -51,7 +51,7 @@ Public Class LoopStream
End If End If
totalBytesRead += bytesRead totalBytesRead += bytesRead
End While End While
Return totalBytesRead Return totalBytesRead
End Function End Function
End Class End Class
@ -94,248 +94,248 @@ Public Class MusicManager
Private Shared _isFadingIn As Boolean = False Private Shared _isFadingIn As Boolean = False
' NAudio properties ' NAudio properties
Public Shared outputDevice As WaveOutEvent Public Shared outputDevice As WaveOutEvent
Public Shared audioFile As VorbisWaveReader Public Shared audioFile As VorbisWaveReader
Public Shared _stream As WaveChannel32 Public Shared _stream As WaveChannel32
Public Shared Property MasterVolume As Single = 1.0F Public Shared Property MasterVolume As Single = 1.0F
Public Shared ReadOnly Property CurrentSong As SongContainer Public Shared ReadOnly Property CurrentSong As SongContainer
Get Get
Return _currentSong Return _currentSong
End Get End Get
End Property End Property
Public Shared Property Muted As Boolean Public Shared Property Muted As Boolean
Get Get
Return _muted Return _muted
End Get End Get
Set(value As Boolean) Set(value As Boolean)
If _muted <> value Then If _muted <> value Then
_muted = value _muted = value
If _muted = True Then If _muted = True Then
If outputDevice IsNot Nothing Then If outputDevice IsNot Nothing Then
Volume = 0.0F Volume = 0.0F
Core.GameMessage.ShowMessage(Localization.GetString("game_message_audio_off"), 12, FontManager.MainFont, Color.White) Core.GameMessage.ShowMessage(Localization.GetString("game_message_audio_off"), 12, FontManager.MainFont, Color.White)
End If End If
Else Else
If outputDevice IsNot Nothing Then If outputDevice IsNot Nothing Then
If _isPausedForSound = True Then If _isPausedForSound = True Then
_muted = True _muted = True
Volume = 0.0F Volume = 0.0F
Else Else
Volume = 1.0F Volume = 1.0F
Core.GameMessage.ShowMessage(Localization.GetString("game_message_audio_on"), 12, FontManager.MainFont, Color.White) Core.GameMessage.ShowMessage(Localization.GetString("game_message_audio_on"), 12, FontManager.MainFont, Color.White)
End If End If
End If End If
End If End If
End If End If
End Set End Set
End Property End Property
Public Shared Property Paused As Boolean Public Shared Property Paused As Boolean
Get Get
Return _paused Return _paused
End Get End Get
Set(value As Boolean) Set(value As Boolean)
If _paused <> value Then If _paused <> value Then
_paused = value _paused = value
If _paused = True Then If _paused = True Then
If outputDevice IsNot Nothing Then If outputDevice IsNot Nothing Then
outputDevice.Pause() outputDevice.Pause()
_introMuteTime = Date.Now _introMuteTime = Date.Now
End If End If
Else Else
ResumePlayback() ResumePlayback()
End If End If
End If End If
End Set End Set
End Property End Property
Public Shared Sub Setup() Public Shared Sub Setup()
MasterVolume = 1.0F MasterVolume = 1.0F
If Muted = True Then If Muted = True Then
Volume = 0.0F Volume = 0.0F
Else Else
Volume = 1.0F Volume = 1.0F
End If End If
_nextSong = "" _nextSong = ""
_fadeSpeed = DEFAULT_FADE_SPEED _fadeSpeed = DEFAULT_FADE_SPEED
_isFadingOut = False _isFadingOut = False
_isFadingIn = False _isFadingIn = False
_isLooping = True _isLooping = True
End Sub End Sub
Public Shared Sub Clear() Public Shared Sub Clear()
_songs.Clear() _songs.Clear()
LoadMusic(False) LoadMusic(False)
End Sub End Sub
Public Shared Sub ClearCurrentlyPlaying() Public Shared Sub ClearCurrentlyPlaying()
' cleans all remains of currently playing songs ' cleans all remains of currently playing songs
_currentSongExists = False _currentSongExists = False
_currentSong = Nothing _currentSong = Nothing
_currentSongName = NO_MUSIC _currentSongName = NO_MUSIC
_isIntroStarted = False _isIntroStarted = False
End Sub End Sub
Public Shared Sub PlayNoMusic() Public Shared Sub PlayNoMusic()
' fades out current track and sets to NO_MUSIC ' fades out current track and sets to NO_MUSIC
Play(NO_MUSIC) Play(NO_MUSIC)
End Sub End Sub
Public Shared Sub Update() Public Shared Sub Update()
If _isPausedForSound Then If _isPausedForSound Then
If Date.Now >= _pausedUntil Then If Date.Now >= _pausedUntil Then
If MusicManager.Paused = True Then If MusicManager.Paused = True Then
_isPausedForSound = False _isPausedForSound = False
Paused = False Paused = False
End If End If
End If End If
Else Else
' fading ' fading
If _isFadingOut Then If _isFadingOut Then
Volume -= _fadeSpeed Volume -= _fadeSpeed
If Volume <= 0F Then If Volume <= 0F Then
Volume = 0F Volume = 0F
_isFadingOut = False _isFadingOut = False
_isFadingIn = True _isFadingIn = True
Dim song = GetSong(_nextSong) Dim song = GetSong(_nextSong)
If Not song Is Nothing Then If Not song Is Nothing Then
Play(song) Play(song)
_nextSong = "" _nextSong = ""
If _fadeIntoIntro Then If _fadeIntoIntro Then
_fadeIntoIntro = False _fadeIntoIntro = False
_introEndTime = Date.Now + song.Duration _introEndTime = Date.Now + song.Duration
_isIntroStarted = True _isIntroStarted = True
Else Else
_isLooping = True _isLooping = True
End If End If
Else Else
' no song found, do not fade into anything ' no song found, do not fade into anything
_fadeIntoIntro = False _fadeIntoIntro = False
ClearCurrentlyPlaying() ClearCurrentlyPlaying()
_isFadingIn = False _isFadingIn = False
If Muted = True Then If Muted = True Then
Volume = 0.0F Volume = 0.0F
Else Else
Volume = 1.0F Volume = 1.0F
End If End If
If _nextSong = NO_MUSIC Then If _nextSong = NO_MUSIC Then
_nextSong = "" _nextSong = ""
MusicManager.Stop() MusicManager.Stop()
End If End If
End If End If
End If End If
ElseIf _isFadingIn Then ElseIf _isFadingIn Then
If Muted = True Then If Muted = True Then
Volume = 0.0F Volume = 0.0F
_isFadingIn = False _isFadingIn = False
Else Else
Volume += _fadeSpeed Volume += _fadeSpeed
If Volume >= 1.0F Then If Volume >= 1.0F Then
Volume = 1.0F Volume = 1.0F
_isFadingIn = False _isFadingIn = False
End If End If
End If End If
End If End If
' intro ' intro
If _isIntroStarted Then If _isIntroStarted Then
If Paused = False Then If Paused = False Then
If Date.Now >= _introEndTime Then If Date.Now >= _introEndTime Then
Dim song = GetSong(_introContinueSong) Dim song = GetSong(_introContinueSong)
_isLooping = True _isLooping = True
_isIntroStarted = False _isIntroStarted = False
Play(song) Play(song)
End If End If
End If End If
End If End If
End If End If
If Core.GameInstance.IsActive AndAlso _lastVolume <> (Volume * MasterVolume) Then If Core.GameInstance.IsActive AndAlso _lastVolume <> (Volume * MasterVolume) Then
UpdateVolume() UpdateVolume()
End If End If
End Sub End Sub
Public Shared Sub UpdateVolume() Public Shared Sub UpdateVolume()
_lastVolume = Volume * MasterVolume _lastVolume = Volume * MasterVolume
If Not _stream Is Nothing Then If Not _stream Is Nothing Then
_stream.Volume = Volume * MasterVolume _stream.Volume = Volume * MasterVolume
End If End If
End Sub End Sub
Public Shared Sub PauseForSound(ByVal sound As SoundEffect) Public Shared Sub PauseForSound(ByVal sound As SoundEffect)
_isPausedForSound = True _isPausedForSound = True
_pausedUntil = Date.Now + sound.Duration _pausedUntil = Date.Now + sound.Duration
MusicManager.Pause() MusicManager.Pause()
End Sub End Sub
Public Shared Sub Pause() Public Shared Sub Pause()
MusicManager.Paused = True MusicManager.Paused = True
End Sub End Sub
Public Shared Sub [Stop]() Public Shared Sub [Stop]()
If Not outputDevice Is Nothing Then If Not outputDevice Is Nothing Then
outputDevice.Stop() outputDevice.Stop()
outputDevice.Dispose() outputDevice.Dispose()
End If End If
_isIntroStarted = False _isIntroStarted = False
End Sub End Sub
Public Shared Sub ResumePlayback() Public Shared Sub ResumePlayback()
If Not _currentSong Is Nothing Then If Not _currentSong Is Nothing Then
If outputDevice IsNot Nothing Then If outputDevice IsNot Nothing Then
' if an intro was playing while the music player was paused, calculate its end time ' if an intro was playing while the music player was paused, calculate its end time
If outputDevice.PlaybackState = PlaybackState.Paused AndAlso _isIntroStarted Then If outputDevice.PlaybackState = PlaybackState.Paused AndAlso _isIntroStarted Then
Dim pauseTime As TimeSpan = Date.Now.Subtract(_introMuteTime) Dim pauseTime As TimeSpan = Date.Now.Subtract(_introMuteTime)
_introEndTime = _introEndTime + pauseTime _introEndTime = _introEndTime + pauseTime
End If End If
outputDevice.Play() outputDevice.Play()
End If End If
End If End If
End Sub End Sub
Private Shared Sub Play(song As SongContainer) Private Shared Sub Play(song As SongContainer)
If Not song Is Nothing Then If Not song Is Nothing Then
Logger.Debug($"Play song [{song.Name}]") Logger.Debug($"Play song [{song.Name}]")
If Not outputDevice Is Nothing Then If Not outputDevice Is Nothing Then
outputDevice.Dispose() outputDevice.Dispose()
End If End If
outputDevice = New WaveOutEvent() outputDevice = New WaveOutEvent()
audioFile = New VorbisWaveReader(song.Song) audioFile = New VorbisWaveReader(song.Song)
_stream = New NAudio.Wave.WaveChannel32(New LoopStream(audioFile, _isLooping)) _stream = New NAudio.Wave.WaveChannel32(New LoopStream(audioFile, _isLooping))
outputDevice.Init(_stream) outputDevice.Init(_stream)
If Paused = False Then If Paused = False Then
outputDevice.Play() outputDevice.Play()
End If End If
_stream.Volume = Volume * MasterVolume _stream.Volume = Volume * MasterVolume
_currentSongExists = True _currentSongExists = True
_currentSongName = song.Name _currentSongName = song.Name
_currentSong = song _currentSong = song
Else Else
_currentSongExists = False _currentSongExists = False
_currentSongName = NO_MUSIC _currentSongName = NO_MUSIC
_currentSong = Nothing _currentSong = Nothing
End If End If
End Sub End Sub
Private Shared Sub FadeInto(song As SongContainer, fadeSpeed As Single) Private Shared Sub FadeInto(song As SongContainer, fadeSpeed As Single)
_isFadingOut = True _isFadingOut = True
If Not song Is Nothing Then If Not song Is Nothing Then
_nextSong = song.Name _nextSong = song.Name
@ -415,10 +415,10 @@ Public Class MusicManager
playedSong = nextSong playedSong = nextSong
End If
End If End If
End If
Return playedSong Return playedSong
End Function End Function