P3D-Legacy/P3D/Core/MainGameFunctions.vb
JappaWakka fae7349356
Fix audio engine & contentpacks (#35)
* Replaced existing Gen 2 SFX with better sounding ones (no ugly reverb)
Replaced MediaPlayer with NAudio(and NAudio.Vorbis) for playing music in order to fix random stopping issues.
The game now directly loads .ogg files instead of the .wma/.xnb combination from before.
ContentPacks are now able to replace Music and SFX again (I haven't added a menu yet for choosing ContentPacks).
To make older GameModes work with current versions, you can add the GameMode property EnterType and set it to "1", this will make the game use the older 2D NewGameScreen.

* Delete GameController.vb

* Add gamecontroller.vb back

* Fix sfx missing

* Battleintro doodle now doesn't loop anymore (for no trainer)
Changed the shutter sound (aka Large Door sound) to something more large door-y
Made the enter sound slightly louder
The enter sound now plays when going through any warp to or from an indoor map (including falling through holes)
The flying sound effect is played earlier in the animation after selecting a location
Changed played sound effect when using the Escape Rope to "teleport" instead of "destroy"
The bump noise now also plays when bumping into something in first person
Fixed small gap between the end of the intro song and the start of the main song
Replaced some songs with better songs

* Fixed some more intro issues

* Forgot to change a thing

* Fixed an error where the main music would play, ignoring the muted musicmanager.

* fix indenting in musicmanager

* The music player will now only start playback on a new song if the music player is not muted, fixed the end time calculation of the intro of a song after muting, Music can't be unmuted now as long as a sound effect plays that stops the music.

* Fixed league restplace position, fixed sound effects sharing the volume slider of the music, sound effects are now also muted when pressing M, changed music on/off popup to audio on/off, removed bump delay in first person, added more control on whether played songs should be looping or not.

* Fixed some more scripts that turn on thirdperson mode but don't check if it was on before or set it back to what it was before afterwards, also fixed a small error in creditsscreen.vb.

* Fixed indenting error in musicmanager.vb, fixed an error of mine where the loopsong parameter would be seen as the playintro parameter.

* Added more music commands, added quite some menu select noises, will add more later

* More select sound effects!

* Fix music not resuming after soundeffect

* Trainer using item now plays the single_heal soundeffect

* Pokémon cries now sound louder

* Possibly fixing crash when playing Pokémon cry at volume higher than 0.71

* Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720.

* Sound effects now sound louder

* Revert "Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720."

This reverts commit 8c9296ed1a82144d17f303a52c3f2e9e65a5bfea.

* Fixed the cause of why the title screen music plays even when the game is muted

* Tabs to spaces

* Revert

Co-authored-by: darkfire006 <blazer257@live.com>
Co-authored-by: JappaWakkaP3D <66885565+JappaWakkaP3D@users.noreply.github.com>
Co-authored-by: JappaWakkaP3D <jasper.speelman@outlook.com>
Co-authored-by: Vitaly Mikhailov <personal@aragas.org>
2020-07-09 20:59:42 +03:00

160 lines
8.4 KiB
VB.net

Public Class MainGameFunctions
Public Shared Sub FunctionKeys()
If KeyBoardHandler.KeyPressed(KeyBindings.GUIControlKey) = True Then
Core.GameOptions.ShowGUI = Not Core.GameOptions.ShowGUI
Core.GameOptions.SaveOptions()
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.ScreenshotKey) AndAlso Core.CurrentScreen.CanTakeScreenshot Then
CaptureScreen()
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.DebugKey) Then
Core.GameOptions.ShowDebug += 1
If Core.GameOptions.ShowDebug >= 2 Then
Core.GameOptions.ShowDebug = 0
End If
Core.GameOptions.SaveOptions()
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.LightKey) Then
Core.GameOptions.LightingEnabled = Not Core.GameOptions.LightingEnabled
Core.GameOptions.SaveOptions()
If Core.GameOptions.LightingEnabled Then
Core.GameMessage.ShowMessage(Localization.GetString("game_message_lighting_on", "Lighting Enabled"), 12, FontManager.MainFont, Color.White)
Else
Core.GameMessage.ShowMessage(Localization.GetString("game_message_lighting_off", "Lighting Disabled"), 12, FontManager.MainFont, Color.White)
End If
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.FullScreenKey) AndAlso Core.CurrentScreen.CanGoFullscreen Then
ToggleFullScreen()
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.MuteAudioKey) AndAlso Core.CurrentScreen.CanMuteMusic Then
If MusicManager.Muted Then
MusicManager.Muted = False
SoundManager.Muted = False
Else
MusicManager.Muted = True
SoundManager.Muted = True
End If
Core.GameOptions.SaveOptions()
Core.CurrentScreen.ToggledMute()
End If
If KeyBoardHandler.KeyDown(KeyBindings.DebugKey) = True Then
If KeyBoardHandler.KeyPressed(Keys.F) Then
TextureManager.TextureList.Clear()
Core.GameMessage.ShowMessage(Localization.GetString("game_message_debug_texture_list_clear", "Texture list have cleared"), 12, FontManager.MainFont, Color.White)
ElseIf KeyBoardHandler.KeyPressed(Keys.S) Then
Core.SetWindowSize(New Vector2(1200, 680))
ElseIf KeyBoardHandler.KeyPressed(Keys.L) Then
Logger.DisplayLog = Not Logger.DisplayLog
ElseIf KeyBoardHandler.KeyPressed(Keys.B) Then
Entity.drawViewBox = Not Entity.drawViewBox
End If
End If
If ControllerHandler.ButtonPressed(Buttons.Back, True) = True Then
Core.GameOptions.GamePadEnabled = Not Core.GameOptions.GamePadEnabled
If Core.GameOptions.GamePadEnabled Then
Core.GameMessage.ShowMessage("Enabled XBOX 360 GamePad support.", 12, FontManager.MainFont, Color.White)
Else
Core.GameMessage.ShowMessage("Disabled XBOX 360 GamePad support.", 12, FontManager.MainFont, Color.White)
End If
Core.GameOptions.SaveOptions()
End If
End Sub
Private Shared Sub CaptureScreen()
Try
Core.GameMessage.HideMessage()
Dim fileName As String = ""
With My.Computer.Clock.LocalTime
Dim month As String = .Month.ToString()
If month.Length = 1 Then
month = "0" & month
End If
Dim day As String = .Day.ToString()
If day.Length = 1 Then
day = "0" & day
End If
Dim hour As String = .Hour.ToString()
If hour.Length = 1 Then
hour = "0" & hour
End If
Dim minute As String = .Minute.ToString()
If minute.Length = 1 Then
minute = "0" & minute
End If
Dim second As String = .Second.ToString()
If second.Length = 1 Then
second = "0" & second
End If
fileName = .Year & "-" & month & "-" & day & "_" & hour & "." & minute & "." & second & ".png"
End With
If Directory.Exists(GameController.GamePath & "\screenshots\") = False Then
Directory.CreateDirectory(GameController.GamePath & "\screenshots\")
End If
If Core.GraphicsManager.IsFullScreen = False Then
Dim b As New Drawing.Bitmap(Core.windowSize.Width, Core.windowSize.Height)
Using g As Drawing.Graphics = Drawing.Graphics.FromImage(b)
g.CopyFromScreen(Core.Window.ClientBounds.X, Core.Window.ClientBounds.Y, 0, 0, New Drawing.Size(b.Width, b.Height))
End Using
b.Save(GameController.GamePath & "\screenshots\" & fileName, Drawing.Imaging.ImageFormat.Png)
Else
Dim screenshot As New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
Core.GraphicsDevice.SetRenderTarget(screenshot)
Core.Draw()
Core.GraphicsDevice.SetRenderTarget(Nothing)
Dim stream As Stream = File.OpenWrite(GameController.GamePath & "\screenshots\" & fileName)
screenshot.SaveAsPng(stream, Core.windowSize.Width, Core.windowSize.Height)
stream.Dispose()
End If
Core.GameMessage.SetupText(Localization.GetString("game_message_screenshot") & fileName, FontManager.MainFont, Color.White)
Core.GameMessage.ShowMessage(12, Core.GraphicsDevice)
Catch ex As Exception
Logger.Log(Logger.LogTypes.ErrorMessage, "Basic.vb: " & Localization.GetString("game_message_screenshot_failed") & ". More information: " & ex.Message)
End Try
End Sub
Private Shared Sub ToggleFullScreen()
If Core.GraphicsManager.IsFullScreen = False Then
' MonoGame Bug > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width != System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
' MonoGame Bug > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height != System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
' Temp Fix just in case someone else face this as well.
If GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width <> Windows.Forms.Screen.PrimaryScreen.Bounds.Width OrElse
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height <> Windows.Forms.Screen.PrimaryScreen.Bounds.Height Then
Core.GraphicsManager.PreferredBackBufferWidth = Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Core.GraphicsManager.PreferredBackBufferHeight = Windows.Forms.Screen.PrimaryScreen.Bounds.Height
Core.windowSize = New Rectangle(0, 0, Windows.Forms.Screen.PrimaryScreen.Bounds.Width, Windows.Forms.Screen.PrimaryScreen.Bounds.Height)
Else
Core.GraphicsManager.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
Core.GraphicsManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
Core.windowSize = New Rectangle(0, 0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height)
End If
Windows.Forms.Application.VisualStyleState = Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled
Core.GraphicsManager.ToggleFullScreen()
Core.GameMessage.ShowMessage(Localization.GetString("game_message_fullscreen_on"), 12, FontManager.MainFont, Color.White)
Else
Core.GraphicsManager.PreferredBackBufferWidth = 1200
Core.GraphicsManager.PreferredBackBufferHeight = 680
Core.windowSize = New Rectangle(0, 0, 1200, 680)
Windows.Forms.Application.VisualStyleState = Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled
Core.GraphicsManager.ToggleFullScreen()
Core.GameMessage.ShowMessage(Localization.GetString("game_message_fullscreen_off"), 12, FontManager.MainFont, Color.White)
End If
Core.GraphicsManager.ApplyChanges()
NetworkPlayer.ScreenRegionChanged()
End Sub
End Class