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
_preScreenTarget = New RenderTarget2D(GraphicsDevice, windowSize.Width, windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8) If windowSize.Width > 0 AndAlso windowSize.Height > 0 Then
_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,27 +66,38 @@
Private _blur As Resources.Blur.BlurHandler Private _blur As Resources.Blur.BlurHandler
Private Sub DrawPrescreen() Private Sub DrawPrescreen()
If _preScreenTexture Is Nothing OrElse _preScreenTexture.IsContentLost Then If windowSize.Width > 0 And windowSize.Height > 0 Then
SpriteBatch.EndBatch() 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
SpriteBatch.EndBatch()
Dim target As RenderTarget2D = _preScreenTarget Dim target As RenderTarget2D = _preScreenTarget
GraphicsDevice.SetRenderTarget(target) GraphicsDevice.SetRenderTarget(target)
GraphicsDevice.Clear(BackgroundColor) GraphicsDevice.Clear(BackgroundColor)
SpriteBatch.BeginBatch() SpriteBatch.BeginBatch()
PreScreen.Draw() PreScreen.Draw()
SpriteBatch.EndBatch() SpriteBatch.EndBatch()
GraphicsDevice.SetRenderTarget(Nothing) GraphicsDevice.SetRenderTarget(Nothing)
SpriteBatch.BeginBatch() SpriteBatch.BeginBatch()
_preScreenTexture = target _preScreenTexture = target
End If
If _preScreenTexture IsNot Nothing Then
If _preScreenTexture.Width > 0 And _preScreenTexture.Height > 0 Then
SpriteBatch.Draw(_blur.Perform(_preScreenTexture), windowSize, Color.White)
End If
End If
End If End If
SpriteBatch.Draw(_blur.Perform(_preScreenTexture), windowSize, Color.White)
End Sub End Sub
Public Overrides Sub Draw() Public Overrides Sub Draw()