Fix for menu screen crash

This commit is contained in:
JappaWakka 2022-06-04 16:12:03 +02:00
parent 537226be76
commit bc37be1374
1 changed files with 28 additions and 15 deletions

View File

@ -27,7 +27,10 @@
IsDrawingGradients = 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")
ConstructMenu()
@ -36,7 +39,6 @@
SetCursorPosition(_menuIndex)
_cursorPosition = _cursorDestPosition
_blur = New Resources.Blur.BlurHandler(windowSize.Width, windowSize.Height)
End Sub
Private Sub ConstructMenu()
@ -64,27 +66,38 @@
Private _blur As Resources.Blur.BlurHandler
Private Sub DrawPrescreen()
If _preScreenTexture Is Nothing OrElse _preScreenTexture.IsContentLost Then
SpriteBatch.EndBatch()
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
SpriteBatch.EndBatch()
Dim target As RenderTarget2D = _preScreenTarget
GraphicsDevice.SetRenderTarget(target)
GraphicsDevice.Clear(BackgroundColor)
Dim target As RenderTarget2D = _preScreenTarget
GraphicsDevice.SetRenderTarget(target)
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
SpriteBatch.Draw(_blur.Perform(_preScreenTexture), windowSize, Color.White)
End Sub
Public Overrides Sub Draw()