Main Menu Crash Fix & Options Menu Cursor Fix

Fixed a crash when moving to the content pack button in the main menu options row while having no savegames.

Fixed the options pointer changing position when resizing the game window.
This commit is contained in:
JappaWakka 2021-09-29 14:32:05 +02:00
parent d3bad8913b
commit 106de657f0
2 changed files with 36 additions and 23 deletions

View File

@ -320,7 +320,7 @@ Public Class NewMainMenuScreen
Public Overrides Sub Update() Public Overrides Sub Update()
PreScreen.Update() PreScreen.Update()
If _loading = False Then If _loading = False Then
'Shift the top row horizontally 'Shift the Top row horizontally
_mainOffset.X = _screenOffset.X _mainOffset.X = _screenOffset.X
'Shift the main menu vertically 'Shift the main menu vertically
Select Case _menuIndex Select Case _menuIndex
@ -470,25 +470,27 @@ Public Class NewMainMenuScreen
End If End If
End Select End Select
End If End If
If _menuIndex = 0 Then
If _MainProfiles(_selectedProfile).IsGameJolt AndAlso _MainProfiles(_selectedProfile).Loaded Then If _MainProfiles(_selectedProfile).IsGameJolt AndAlso _MainProfiles(_selectedProfile).Loaded Then
If Controls.Down(True, True, False) Then If Controls.Down(True, True, False) Then
_GameJoltButtonIndex += 1 _GameJoltButtonIndex += 1
End If
If Controls.Up(True, True, False) Then
_GameJoltButtonIndex -= 1
End If
_GameJoltButtonIndex = Clamp(_GameJoltButtonIndex, 0, 3)
End If End If
If Controls.Up(True, True, False) Then
_GameJoltButtonIndex -= 1
End If
_GameJoltButtonIndex = Clamp(_GameJoltButtonIndex, 0, 3)
End If End If
Select Case _menuIndex Select Case _menuIndex
Case 0 Case 0
_selectedProfile = _selectedProfile.Clamp(0, _MainProfiles.Count - 1) _selectedProfile = _selectedProfile.Clamp(0, _MainProfiles.Count - 1)
Case 1 Case 1
_selectedProfile = _selectedProfile.Clamp(0, _GameJoltProfiles.Count - 1) _selectedProfile = _selectedProfile.Clamp(0, _GameJoltProfiles.Count - 1)
Case 2, 3 Case 2, 3
_selectedProfile = _selectedProfile.Clamp(0, _OptionsProfiles.Count - 1) _selectedProfile = _selectedProfile.Clamp(0, _OptionsProfiles.Count - 1)
End Select End Select
If _fadeInMain = 1.0F Then If _fadeInMain = 1.0F Then
If Controls.Accept(False, True, True) Then If Controls.Accept(False, True, True) Then
Select Case _GameJoltButtonIndex Select Case _GameJoltButtonIndex
@ -514,11 +516,12 @@ Public Class NewMainMenuScreen
' Try to load the GameJolt profile once the player has logged in. ' Try to load the GameJolt profile once the player has logged in.
_MainProfiles(0).LoadGameJolt() _MainProfiles(0).LoadGameJolt()
End If End If
If _menuIndex = 0 Then
If _MainProfiles(_selectedProfile).Loaded = False Then If _MainProfiles(_selectedProfile).Loaded = False Then
_closingDisplay = True _closingDisplay = True
Else Else
_closingDisplay = False _closingDisplay = False
End If
End If End If
_sliderTarget = GetSliderTarget(_selectedProfile) _sliderTarget = GetSliderTarget(_selectedProfile)

View File

@ -20,6 +20,8 @@
Dim GamePadEnabled As Boolean = True Dim GamePadEnabled As Boolean = True
Dim PreferMultiSampling As Boolean = True Dim PreferMultiSampling As Boolean = True
Private _subMenu As Integer = 0 Private _subMenu As Integer = 0
Private _screenSize As Size = New Size(CInt(ScreenSize.Width), CInt(ScreenSize.Height))
Private LastControl As Integer = 0
Private Languages As New List(Of String) Private Languages As New List(Of String)
Private LanguageNames As New List(Of String) Private LanguageNames As New List(Of String)
@ -320,6 +322,7 @@
For Each control As Control In ControlList For Each control As Control In ControlList
If control._position = _cursorDestPosition Then If control._position = _cursorDestPosition Then
LastControl = control.ID
currentControl = control currentControl = control
Exit For Exit For
End If End If
@ -655,9 +658,16 @@
'New stuff 'New stuff
If _opening Then If _opening Then
InitializeControls() InitializeControls()
LastControl = 0
_opening = False _opening = False
End If End If
'Refresh button positions
If ScreenSize.Width <> _screenSize.Width Or ScreenSize.Height <> _screenSize.Height Then
_screenSize = New Size(CInt(ScreenSize.Width), CInt(ScreenSize.Height))
InitializeControls()
End If
If _closing Then If _closing Then
' When the interface is closing, only update the closing animation ' When the interface is closing, only update the closing animation
' Once the interface is completely closed, set to the previous screen. ' Once the interface is completely closed, set to the previous screen.
@ -803,6 +813,7 @@
For Each control As Control In ControlList For Each control As Control In ControlList
If control._position = _cursorDestPosition Then If control._position = _cursorDestPosition Then
LastControl = control.ID
currentControl = control currentControl = control
Exit For Exit For
End If End If
@ -1020,8 +1031,7 @@
End Select End Select
If ScreenIndex <> 7 Then If ScreenIndex <> 7 Then
'_cursorPosition = ControlList(0)._position _cursorDestPosition = ControlList(LastControl)._position
_cursorDestPosition = ControlList(0)._position
Else Else
_cursorDestPosition = ControlList(4)._position _cursorDestPosition = ControlList(4)._position
End If End If