Fix for menu screen crash

This commit is contained in:
JappaWakka 2022-06-04 16:12:03 +02:00
parent 537226be76
commit bc37be1374

View File

@ -27,7 +27,10 @@
IsDrawingGradients = True IsDrawingGradients = True
MouseVisible = True MouseVisible = True
If windowSize.Width > 0 AndAlso windowSize.Height > 0 Then
_preScreenTarget = New RenderTarget2D(GraphicsDevice, windowSize.Width, windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8) _preScreenTarget = New RenderTarget2D(GraphicsDevice, windowSize.Width, windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
_blur = New Resources.Blur.BlurHandler(windowSize.Width, windowSize.Height)
End If
_texture = TextureManager.GetTexture("GUI\Menus\General") _texture = TextureManager.GetTexture("GUI\Menus\General")
ConstructMenu() ConstructMenu()
@ -36,7 +39,6 @@
SetCursorPosition(_menuIndex) SetCursorPosition(_menuIndex)
_cursorPosition = _cursorDestPosition _cursorPosition = _cursorDestPosition
_blur = New Resources.Blur.BlurHandler(windowSize.Width, windowSize.Height)
End Sub End Sub
Private Sub ConstructMenu() Private Sub ConstructMenu()
@ -64,6 +66,13 @@
Private _blur As Resources.Blur.BlurHandler Private _blur As Resources.Blur.BlurHandler
Private Sub DrawPrescreen() Private Sub DrawPrescreen()
If windowSize.Width > 0 And windowSize.Height > 0 Then
If _preScreenTarget Is Nothing Then
_preScreenTarget = New RenderTarget2D(GraphicsDevice, windowSize.Width, windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
End If
If _blur Is Nothing Then
_blur = New Resources.Blur.BlurHandler(windowSize.Width, windowSize.Height)
End If
If _preScreenTexture Is Nothing OrElse _preScreenTexture.IsContentLost Then If _preScreenTexture Is Nothing OrElse _preScreenTexture.IsContentLost Then
SpriteBatch.EndBatch() SpriteBatch.EndBatch()
@ -83,8 +92,12 @@
_preScreenTexture = target _preScreenTexture = target
End If End If
If _preScreenTexture IsNot Nothing Then
If _preScreenTexture.Width > 0 And _preScreenTexture.Height > 0 Then
SpriteBatch.Draw(_blur.Perform(_preScreenTexture), windowSize, Color.White) SpriteBatch.Draw(_blur.Perform(_preScreenTexture), windowSize, Color.White)
End If
End If
End If
End Sub End Sub
Public Overrides Sub Draw() Public Overrides Sub Draw()