mirror of
https://github.com/P3D-Legacy/P3D-Legacy.git
synced 2025-07-31 01:35:20 +02:00
* 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>
290 lines
12 KiB
VB.net
290 lines
12 KiB
VB.net
''' <summary>
|
|
''' A class to name Pokémon and other objects (namely the rival).
|
|
''' </summary>
|
|
''' <remarks>Inherits from screen.</remarks>
|
|
Public Class NameObjectScreen
|
|
|
|
Inherits Screen
|
|
|
|
Private _pokemon As Pokemon ' Temporarly stores the Pokémon to rename.
|
|
Private _currentText As String = "" ' The current Text in the textbox.
|
|
Private _mainTexture As Texture2D ' The temporary texture. Loads "GUI\Menus\Menu".
|
|
|
|
Private _index As Integer = 0 ' The button index (0 or 1).
|
|
Private _askedRename As Boolean = False ' If the question to rename is answered or not.
|
|
Private _renamePokemon As Boolean = False ' If a Pokémon is getting renamed.
|
|
|
|
Private _canChooseNo As Boolean = True ' If the player can choose to not rename the object.
|
|
Private _defaultName As String = "Name" ' The default name (that also gets mentioned in the question).
|
|
Private _delay As Single = 0.0F ' The delay until the question can be answered.
|
|
|
|
''' <summary>
|
|
''' Handles the NameAccept event which fires if the object gets renamed.
|
|
''' </summary>
|
|
''' <param name="Name">The new name of the object</param>
|
|
Public Delegate Sub DNameAcceptEventHandler(ByVal Name As String)
|
|
|
|
Private _acceptName As DNameAcceptEventHandler
|
|
|
|
''' <summary>
|
|
''' Creates a new instance of the NameObjectScreen class and sets its mode to "Rename Pokémon".
|
|
''' </summary>
|
|
''' <param name="CurrentScreen">The currently active screen.</param>
|
|
''' <param name="Pokemon">The Pokémon reference to rename.</param>
|
|
Public Sub New(ByVal CurrentScreen As Screen, ByVal Pokemon As Pokemon)
|
|
' Set default values:
|
|
Me.Identification = Identifications.NameObjectScreen
|
|
Me.PreScreen = CurrentScreen
|
|
Me.MouseVisible = True
|
|
Me.CanChat = False
|
|
Me.CanMuteMusic = False
|
|
Me.CanBePaused = False
|
|
|
|
Me._pokemon = Pokemon
|
|
Me._defaultName = Pokemon.GetDisplayName()
|
|
Me._renamePokemon = True
|
|
|
|
' Load texture:
|
|
Me._mainTexture = TextureManager.GetTexture("GUI\Menus\Menu")
|
|
|
|
' Show the Pokémon image:
|
|
Screen.PokemonImageView.Show(Pokemon, True)
|
|
End Sub
|
|
|
|
Public Sub New(ByVal CurrentScreen As Screen, ByVal Texture As Texture2D, ByVal canExit As Boolean, ByVal canChoose As Boolean, ByVal NameString As String, ByVal DefaultName As String, ByVal AcceptName As DNameAcceptEventHandler)
|
|
Me.Identification = Identifications.NameObjectScreen
|
|
Me.PreScreen = CurrentScreen
|
|
|
|
Me._mainTexture = TextureManager.GetTexture("GUI\Menus\Menu")
|
|
|
|
Me._acceptName = AcceptName
|
|
Me._canChooseNo = canExit
|
|
If canChoose = False Then
|
|
Me._delay = 5.0F
|
|
End If
|
|
Me._askedRename = Not canChoose
|
|
Me._defaultName = NameString
|
|
Me._currentText = DefaultName
|
|
|
|
Me._renamePokemon = False
|
|
Me.MouseVisible = True
|
|
Me.CanBePaused = True
|
|
Me.CanChat = False
|
|
Me.CanMuteMusic = False
|
|
|
|
Screen.PokemonImageView.Show(Texture)
|
|
End Sub
|
|
|
|
Public Overrides Sub Draw()
|
|
Me.PreScreen.Draw()
|
|
Canvas.DrawRectangle(Core.windowSize, New Color(0, 0, 0, 150))
|
|
|
|
Dim CanvasTexture As Texture2D
|
|
For i = 0 To 1
|
|
Dim Text As String = "Rename"
|
|
If _askedRename = True Then
|
|
Text = "OK"
|
|
End If
|
|
|
|
If i = 1 Then
|
|
Text = "Cancel"
|
|
End If
|
|
|
|
If i = _index Then
|
|
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 48, 48, 48), "")
|
|
Else
|
|
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "")
|
|
End If
|
|
|
|
If i = 1 And _canChooseNo = True Or i = 0 Then
|
|
Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.windowSize.Width / 2) - 182 + i * 192 + 22, Core.windowSize.Height - 128, 128, 64))
|
|
Core.SpriteBatch.DrawString(FontManager.InGameFont, Text, New Vector2(CInt(Core.windowSize.Width / 2) - 164 + i * 192 + 22, Core.windowSize.Height - 96), Color.Black)
|
|
End If
|
|
Next
|
|
|
|
If _askedRename = False Then
|
|
Dim genderString As String = ""
|
|
Dim genderUnicode As Integer = 0
|
|
If _renamePokemon = True Then
|
|
If _pokemon.Gender = Pokemon.Genders.Male Then
|
|
genderString = " "
|
|
genderUnicode = 156
|
|
ElseIf _pokemon.Gender = Pokemon.Genders.Female Then
|
|
genderString = " "
|
|
genderUnicode = 157
|
|
End If
|
|
End If
|
|
|
|
Core.SpriteBatch.DrawString(FontManager.InGameFont, "Rename " & Me._defaultName & genderString & "?", New Vector2(CInt(Core.windowSize.Width / 2) - 182 + 25, 93), Color.Black)
|
|
Core.SpriteBatch.DrawString(FontManager.InGameFont, "Rename " & Me._defaultName & genderString & "?", New Vector2(CInt(Core.windowSize.Width / 2) - 182 + 22, 90), Color.White)
|
|
|
|
If genderUnicode <> 0 Then
|
|
Core.SpriteBatch.DrawString(FontManager.TextFont, StringHelper.GetChar(genderUnicode), New Vector2(CInt(Core.windowSize.Width / 2) + FontManager.InGameFont.MeasureString("Rename " & Me._defaultName).X - 147, 93), Color.Black, 0.0F, Vector2.Zero, 2.0F, SpriteEffects.None, 0.0F)
|
|
Core.SpriteBatch.DrawString(FontManager.TextFont, StringHelper.GetChar(genderUnicode), New Vector2(CInt(Core.windowSize.Width / 2) + FontManager.InGameFont.MeasureString("Rename " & Me._defaultName).X - 150, 90), Color.White, 0.0F, Vector2.Zero, 2.0F, SpriteEffects.None, 0.0F)
|
|
End If
|
|
|
|
ChooseBox.Showing = False
|
|
Else
|
|
If _delay = 0.0F Then
|
|
Dim genderString As String = ""
|
|
Dim genderUnicode As Integer = 0
|
|
If _renamePokemon = True Then
|
|
If _pokemon.Gender = Pokemon.Genders.Male Then
|
|
genderString = " "
|
|
genderUnicode = 156
|
|
ElseIf _pokemon.Gender = Pokemon.Genders.Female Then
|
|
genderString = " "
|
|
genderUnicode = 157
|
|
End If
|
|
End If
|
|
|
|
Core.SpriteBatch.DrawString(FontManager.InGameFont, "Enter name for " & Me._defaultName & genderString & ":", New Vector2(CInt(Core.windowSize.Width / 2) - 182 + 25, 93), Color.Black)
|
|
Core.SpriteBatch.DrawString(FontManager.InGameFont, "Enter name for " & Me._defaultName & genderString & ":", New Vector2(CInt(Core.windowSize.Width / 2) - 182 + 22, 90), Color.White)
|
|
|
|
If genderUnicode <> 0 Then
|
|
Core.SpriteBatch.DrawString(FontManager.TextFont, StringHelper.GetChar(genderUnicode), New Vector2(CInt(Core.windowSize.Width / 2) + FontManager.InGameFont.MeasureString("Enter name for " & Me._defaultName).X - 150, 93), Color.Black, 0.0F, Vector2.Zero, 2.0F, SpriteEffects.None, 0.0F)
|
|
Core.SpriteBatch.DrawString(FontManager.TextFont, StringHelper.GetChar(genderUnicode), New Vector2(CInt(Core.windowSize.Width / 2) + FontManager.InGameFont.MeasureString("Enter name for " & Me._defaultName).X - 153, 90), Color.White, 0.0F, Vector2.Zero, 2.0F, SpriteEffects.None, 0.0F)
|
|
End If
|
|
|
|
Canvas.DrawRectangle(New Rectangle(CInt(Core.windowSize.Width / 2) - 89, 136, 208, 32), New Color(101, 142, 255))
|
|
DrawTextBox()
|
|
End If
|
|
End If
|
|
|
|
PokemonImageView.Draw()
|
|
End Sub
|
|
|
|
Private Function TextboxPosition() As Vector2
|
|
Return New Vector2(CInt(Core.windowSize.Width / 2) - 85, 140)
|
|
End Function
|
|
|
|
Private Sub DrawTextBox()
|
|
Canvas.DrawRectangle(New Rectangle(CInt(Core.windowSize.Width / 2) - 85, 140, 200, 24), Color.White)
|
|
|
|
Dim t As String = Me._currentText
|
|
If t.Length < 20 Then
|
|
t &= "_"
|
|
End If
|
|
Core.SpriteBatch.DrawString(FontManager.MiniFont, t, TextboxPosition(), Color.Black)
|
|
End Sub
|
|
|
|
Public Overrides Sub Update()
|
|
If CBool(GameModeManager.GetGameRuleValue("ForceRename", "0")) = True Then
|
|
Me._askedRename = True
|
|
Me._canChooseNo = False
|
|
End If
|
|
|
|
Dim mouseOver As Boolean = False
|
|
For i = 0 To 1
|
|
If New Rectangle(CInt(Core.windowSize.Width / 2) - 182 + i * 192, Core.windowSize.Height - 128, 128 + 32, 64 + 32).Contains(MouseHandler.MousePosition) = True Then
|
|
_index = i
|
|
mouseOver = True
|
|
End If
|
|
Next
|
|
|
|
If Controls.Accept(True, False, True) = True Or KeyBoardHandler.KeyPressed(KeyBindings.EnterKey1) = True Then
|
|
Select Case _index
|
|
Case 0
|
|
SoundManager.PlaySound("select")
|
|
ClickYes()
|
|
Case 1
|
|
If _canChooseNo = True Then
|
|
SoundManager.PlaySound("select")
|
|
ClickNo()
|
|
End If
|
|
End Select
|
|
End If
|
|
|
|
If _askedRename = True Then
|
|
If Controls.Right(True, True, True, False, True) = True Then
|
|
_index = 1
|
|
End If
|
|
If Controls.Left(True, True, True, False, True) = True Then
|
|
_index = 0
|
|
End If
|
|
|
|
If _delay > 0.0F Then
|
|
_delay -= 0.1F
|
|
|
|
If _delay <= 0.0F Then
|
|
_delay = 0.0F
|
|
End If
|
|
Else
|
|
KeyBindings.GetNameInput(Me._currentText, 20)
|
|
|
|
Me._currentText = Me.ReplaceInvalidChars(Me._currentText)
|
|
|
|
If Controls.Dismiss(True, False, True) = True And _canChooseNo = True Then
|
|
SoundManager.PlaySound("select")
|
|
ClickNo()
|
|
End If
|
|
End If
|
|
Else
|
|
If Controls.Right(True, True, True, True, True) = True Then
|
|
_index = 1
|
|
End If
|
|
If Controls.Left(True, True, True, True, True) = True Then
|
|
_index = 0
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' This function replaces characters in the string with nothing if the characters aren't allowed in the name.
|
|
''' </summary>
|
|
''' <param name="text">The name string.</param>
|
|
''' <remarks>Only numbers and alphabetic characters are allowed (0-9, a-z, A-Z)</remarks>
|
|
Private Function ReplaceInvalidChars(ByVal text As String) As String
|
|
' Creating the char array:
|
|
Dim chars() As Char = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()
|
|
|
|
' Create a new string to store the "purified" text in. YOU SHALL NOT PASS, EXTENDED LATIN.
|
|
Dim newText As String = ""
|
|
|
|
' Loop through all of the original text and only put in the allowed ones.
|
|
For i = 0 To text.Length - 1
|
|
If chars.Contains(text(i)) = True Then
|
|
newText &= text(i).ToString()
|
|
End If
|
|
Next
|
|
|
|
' Return the newly created string.
|
|
Return newText
|
|
End Function
|
|
|
|
Private Sub ClickYes()
|
|
If _askedRename = True Then
|
|
If _currentText <> "" Then
|
|
If _renamePokemon = True Then
|
|
If _pokemon.GetName() <> _currentText Then
|
|
_pokemon.NickName = _currentText
|
|
End If
|
|
Else
|
|
Me._acceptName(_currentText)
|
|
End If
|
|
|
|
PokemonImageView.Showing = False
|
|
Core.SetScreen(Me.PreScreen)
|
|
End If
|
|
Else
|
|
Me._askedRename = True
|
|
If ControllerHandler.IsConnected() = True Then
|
|
Core.SetScreen(New InputScreen(Me, Me._defaultName, InputScreen.InputModes.Name, Me._defaultName, 14, New List(Of Texture2D), AddressOf Me.GetControllerInput))
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ClickNo()
|
|
If Me._askedRename = True Then
|
|
Me._askedRename = False
|
|
Else
|
|
PokemonImageView.Showing = False
|
|
Core.SetScreen(Me.PreScreen)
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub GetControllerInput(ByVal input As String)
|
|
Me._currentText = input
|
|
End Sub
|
|
|
|
End Class |