Added back gender switching and save reset buttons for GameJolt saves.

This commit is contained in:
CaptainSegis 2019-02-02 03:59:03 -05:00
parent d9f4173b0f
commit 3fb1cd0e89
2 changed files with 111 additions and 6 deletions

View File

@ -264,9 +264,11 @@ Public Class NewMainMenuScreen
Private _sliderTarget As Integer = 0
Private _menuTexture As Texture2D = Nothing
Private _oldMenuTexture As Texture2D
Private _profiles As New List(Of GameProfile)
Private _selectedProfile As Integer = 0
Private _yIndex As Integer = 0
Private _menuIndex As Integer = 1 '0 = New Game, 1 = Profiles
Private _messageBox As UI.MessageBox
@ -280,6 +282,7 @@ Public Class NewMainMenuScreen
CanChat = False
_menuTexture = TextureManager.GetTexture("GUI\Menus\MainMenu")
_oldMenuTexture = TextureManager.GetTexture("GUI\Menus\Menu")
_screenOffset.X = CSng(windowSize.Width / 2 - 80)
_screenOffsetTarget.X = _screenOffset.X
@ -316,8 +319,20 @@ Public Class NewMainMenuScreen
Exit For
End If
Next
If _profiles(_selectedProfile).IsGameJolt AndAlso _profiles(_selectedProfile).Loaded Then
' Click on gamejolt buttons
Dim _xOffset As Single = _screenOffset.X + (100 * (1 - _fadeIn))
Dim r As New Vector2(_xOffset + 400, _screenOffset.Y + 200)
If New Rectangle(CInt(r.X), CInt(r.Y), 32, 32).Contains(MouseHandler.MousePosition) Then
ButtonChangeMale()
ElseIf New Rectangle(CInt(r.X), CInt(r.Y) + 48, 32, 32).Contains(MouseHandler.MousePosition) Then
ButtonChangeFemale()
ElseIf New Rectangle(CInt(r.X), CInt(r.Y) + 48 + 48, 32, 32).Contains(MouseHandler.MousePosition) Then
ButtonResetSave()
End If
End If
End If
If Controls.Dismiss(True, False, False) Then
If Controls.Dismiss(True, False, False) Then
' Click on profiles.
For x = 0 To _profiles.Count - 1
Dim xOffset As Single = _screenOffset.X + x * 180 + ((x + 1) * 100 * (1 - _fadeIn))
@ -334,19 +349,41 @@ Public Class NewMainMenuScreen
If Controls.Right(True) And _selectedProfile < _profiles.Count - 1 Then
_selectedProfile += 1
_screenOffsetTarget.X -= 180
_yIndex = 0
End If
If Controls.Left(True) And _selectedProfile > 0 Then
_selectedProfile -= 1
_screenOffsetTarget.X += 180
_yIndex = 0
End If
If _profiles(_selectedProfile).IsGameJolt AndAlso _profiles(_selectedProfile).Loaded Then
If Controls.Down(True, True, False) Then
_yIndex += 1
End If
If Controls.Up(True, True, False) Then
_yIndex -= 1
End If
_yIndex = Clamp(_yIndex, 0, 3)
End If
_selectedProfile = _selectedProfile.Clamp(0, _profiles.Count - 1)
If _fadeIn = 1.0F Then
If Controls.Accept(False, True, True) Then
ClickedProfile()
Select Case _yIndex
Case 0
ClickedProfile()
Case 1
ButtonChangeMale()
Case 2
ButtonChangeFemale()
Case 3
ButtonResetSave()
End Select
End If
If Controls.Dismiss(False, True, True) Then
DismissProfile()
_yIndex = 0
End If
' Try to load the GameJolt profile once the player has logged in.
_profiles(0).LoadGameJolt()
@ -392,6 +429,31 @@ Public Class NewMainMenuScreen
End If
End Sub
Private Sub ButtonChangeMale()
If GameJoltSave.Gender = "0" Then
Exit Sub
End If
GameJoltSave.Gender = "0"
Core.Player.Skin = GameJolt.Emblem.GetPlayerSpriteFile(GameJolt.Emblem.GetPlayerLevel(GameJoltSave.Points), GameJoltSave.GameJoltID, GameJoltSave.Gender)
_profiles(_selectedProfile).Sprite = GameJolt.Emblem.GetPlayerSprite(GameJolt.Emblem.GetPlayerLevel(GameJoltSave.Points), GameJoltSave.GameJoltID, GameJoltSave.Gender)
End Sub
Private Sub ButtonChangeFemale()
If GameJoltSave.Gender = "1" Then
Exit Sub
End If
GameJoltSave.Gender = "1"
Core.Player.Skin = GameJolt.Emblem.GetPlayerSpriteFile(GameJolt.Emblem.GetPlayerLevel(GameJoltSave.Points), GameJoltSave.GameJoltID, GameJoltSave.Gender)
_profiles(_selectedProfile).Sprite = GameJolt.Emblem.GetPlayerSprite(GameJolt.Emblem.GetPlayerLevel(GameJoltSave.Points), GameJoltSave.GameJoltID, GameJoltSave.Gender)
End Sub
Private Sub ButtonResetSave()
GameJoltSave.ResetSave()
_profiles(_selectedProfile).Sprite = GameJolt.Emblem.GetPlayerSprite(GameJolt.Emblem.GetPlayerLevel(GameJoltSave.Points), GameJoltSave.GameJoltID, GameJoltSave.Gender)
_profiles(_selectedProfile).SetToDefault()
End Sub
Private Sub ClickedProfile()
If _selectedProfile = 0 And Security.FileValidation.IsValid(False) = False Then
_messageBox.Show("File validation failed!" & Environment.NewLine & "Redownload the game's files to solve this problem.")
@ -452,13 +514,42 @@ Public Class NewMainMenuScreen
End If
End If
End Sub
Public Sub DrawGameJoltButtons(ByVal offset As Vector2)
Dim r As New Rectangle(CInt(offset.X + 400), CInt(offset.Y + 200), 512, 128)
Dim y As Integer = 0
If ScaleScreenRec(New Rectangle(r.X, r.Y, 32, 32)).Contains(MouseHandler.MousePosition) = True And GameInstance.IsMouseVisible OrElse Not GameInstance.IsMouseVisible And _yIndex = 1 Then
y = 16
SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "Change to male.", New Vector2(r.X + 64 + 4, r.Y + 4), Color.White)
End If
SpriteBatch.DrawInterface(_oldMenuTexture, New Rectangle(r.X, r.Y, 32, 32), New Rectangle(144, 32 + y, 16, 16), Color.White)
y = 0
If ScaleScreenRec(New Rectangle(r.X, r.Y + 48, 32, 32)).Contains(MouseHandler.MousePosition) = True And GameInstance.IsMouseVisible OrElse Not GameInstance.IsMouseVisible And _yIndex = 2 Then
y = 16
SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "Change to female.", New Vector2(r.X + 64 + 4, r.Y + 4 + 48), Color.White)
End If
SpriteBatch.DrawInterface(_oldMenuTexture, New Rectangle(r.X, r.Y + 48, 32, 32), New Rectangle(160, 32 + y, 16, 16), Color.White)
y = 0
If ScaleScreenRec(New Rectangle(r.X, r.Y + 48 + 48, 32, 32)).Contains(MouseHandler.MousePosition) = True And GameInstance.IsMouseVisible OrElse Not GameInstance.IsMouseVisible And _yIndex = 3 Then
y = 16
SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "Reset save.", New Vector2(r.X + 64 + 4, r.Y + 4 + 48 + 48), Color.White)
End If
SpriteBatch.DrawInterface(_oldMenuTexture, New Rectangle(r.X, r.Y + 48 + 48, 32, 32), New Rectangle(176, 32 + y, 16, 16), Color.White)
End Sub
Private Sub DrawProfiles()
' Draw profiles.
For x = 0 To _profiles.Count - 1
Dim xOffset As Single = _screenOffset.X + x * 180 + ((x + 1) * 100 * (1 - _fadeIn))
_profiles(x).Draw(New Vector2(xOffset, _screenOffset.Y), CInt(_fadeIn * 255), (x = _selectedProfile), _menuTexture)
If _profiles(x).IsGameJolt AndAlso _profiles(x).Loaded AndAlso (x = _selectedProfile) Then
DrawGameJoltButtons(New Vector2(xOffset, _screenOffset.Y))
End If
Next
If _fadeIn = 1.0F Then
@ -592,6 +683,15 @@ Public Class NewMainMenuScreen
Private _logoBounce As Single = 0F
Private ReadOnly _spriteOrder As Integer() = {0, 1, 0, 2}
Public Property Sprite As Texture2D
Get
Return _sprite
End Get
Set(value As Texture2D)
_sprite = value
End Set
End Property
Public ReadOnly Property IsGameJolt As Boolean
Get
Return _isGameJolt
@ -670,6 +770,13 @@ Public Class NewMainMenuScreen
End Get
End Property
Public Sub SetToDefault()
_timePlayed = "00:00:00"
_location = "Your Room"
_pokemonTextures.Clear()
_badges = 0
End Sub
Public Sub New(ByVal path As String, ByVal isNewGameButton As Boolean)
If isNewGameButton Then
_isNewGameButton = True
@ -678,8 +785,6 @@ Public Class NewMainMenuScreen
If path = "" Then
_isGameJolt = True
_loaded = False
_sprite = TextureManager.GetTexture("Textures\UI\GameJolt\gameJoltIcon")
LoadGameJolt()
@ -694,13 +799,13 @@ Public Class NewMainMenuScreen
End If
End Sub
Private Sub LoadContent(ByVal data As String)
Private Sub LoadContent(ByVal pokedata As String)
If GameModeManager.GameModeExists(_gameMode) Then
_gameModeExists = True
GameModeManager.SetGameModePointer(_gameMode)
Dim pokemonData As String() = data.SplitAtNewline()
Dim pokemonData As String() = pokedata.SplitAtNewline()
For Each line As String In pokemonData
If line.StartsWith("{") Then
_pokemonTextures.Add(Pokemon.GetPokemonByData(line).GetMenuTexture(True))

Binary file not shown.