Fix incorrect character list in rename screen

Also added space and a failsafe for if the name ends with a space
This commit is contained in:
JappaWakka 2023-02-02 15:59:26 +01:00
parent b27136d6bf
commit 72d653f65f
2 changed files with 24 additions and 5 deletions

View File

@ -8,6 +8,7 @@
Text = 0 Text = 0
Numbers = 1 Numbers = 1
Name = 2 Name = 2
Pokemon = 3
End Enum End Enum
Dim DefaultName As String = "" Dim DefaultName As String = ""
@ -63,7 +64,7 @@
Select Case Me.InputMode Select Case Me.InputMode
Case InputModes.Text Case InputModes.Text
Me.InitializeText() Me.InitializeText()
Case InputModes.Name Case InputModes.Name, InputModes.Pokemon
Me.InitializeName() Me.InitializeName()
Case InputModes.Numbers Case InputModes.Numbers
Me.InitializeNumbers() Me.InitializeNumbers()
@ -101,7 +102,13 @@
End Sub End Sub
Private Sub InitializeName() Private Sub InitializeName()
Dim chars() As String = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", " ", " ", " ", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", " ", "'", "-", "u", "v", "w", "x", "y", "z", " ", " ", " ", " ", "!", "?", "_"} Dim chars() As String
If InputMode = InputModes.Name Then
chars = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", " ", ".", ",", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", " ", "'", "-", "u", "v", "w", "x", "y", "z", " ", " ", " ", " ", "!", "?", "_"}
Else
chars = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", " ", " ", " ", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", " ", " ", " ", "u", "v", "w", "x", "y", "z", " ", " ", " ", " ", " ", " ", " "}
End If
Dim x As Integer = 0 Dim x As Integer = 0
Dim y As Integer = 0 Dim y As Integer = 0

View File

@ -222,7 +222,7 @@ Public Class NameObjectScreen
''' <remarks>Only numbers and alphabetic characters are allowed (0-9, a-z, A-Z)</remarks> ''' <remarks>Only numbers and alphabetic characters are allowed (0-9, a-z, A-Z)</remarks>
Private Function ReplaceInvalidChars(ByVal text As String) As String Private Function ReplaceInvalidChars(ByVal text As String) As String
' Creating the char array: ' Creating the char array:
Dim chars() As Char = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray() Dim chars() As Char = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ".ToCharArray()
' Create a new string to store the "purified" text in. YOU SHALL NOT PASS, EXTENDED LATIN. ' Create a new string to store the "purified" text in. YOU SHALL NOT PASS, EXTENDED LATIN.
Dim newText As String = "" Dim newText As String = ""
@ -243,9 +243,17 @@ Public Class NameObjectScreen
If _currentText <> "" Then If _currentText <> "" Then
If _renamePokemon = True Then If _renamePokemon = True Then
If _pokemon.GetName() <> _currentText Then If _pokemon.GetName() <> _currentText Then
' Remove spaces at the end
While _currentText.EndsWith(" ")
_currentText = _currentText.Remove(_currentText.Length - 1, 1)
End While
_pokemon.NickName = _currentText _pokemon.NickName = _currentText
End If End If
Else Else
' Remove spaces at the end
While _currentText.EndsWith(" ")
_currentText = _currentText.Remove(_currentText.Length - 1, 1)
End While
Me._acceptName(_currentText) Me._acceptName(_currentText)
End If End If
@ -255,7 +263,11 @@ Public Class NameObjectScreen
Else Else
Me._askedRename = True Me._askedRename = True
If ControllerHandler.IsConnected() = True Then 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)) If _pokemon IsNot Nothing Then
Core.SetScreen(New InputScreen(Me, Me._defaultName, InputScreen.InputModes.Pokemon, Me._defaultName, 14, New List(Of Texture2D), AddressOf Me.GetControllerInput))
Else
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 If
End If End If
End Sub End Sub
@ -270,7 +282,7 @@ Public Class NameObjectScreen
End Sub End Sub
Public Sub GetControllerInput(ByVal input As String) Public Sub GetControllerInput(ByVal input As String)
Me._currentText = input Me._currentText = ReplaceInvalidChars(input)
End Sub End Sub
End Class End Class