From 4e23c9f9daf3acb6c07650f075c8a639457ee97a Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sat, 5 Aug 2023 15:14:38 +0200 Subject: [PATCH] Fix background & splash scaling --- P3D/Screens/MainMenu/PressStartScreen.vb | 14 ++++++++++++-- P3D/Screens/PC/MailSystemScreen.vb | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/P3D/Screens/MainMenu/PressStartScreen.vb b/P3D/Screens/MainMenu/PressStartScreen.vb index 38a420508..6ed332654 100644 --- a/P3D/Screens/MainMenu/PressStartScreen.vb +++ b/P3D/Screens/MainMenu/PressStartScreen.vb @@ -826,8 +826,13 @@ Public Class NewMainMenuScreen backSize.Height = windowSize.Height backSize.Width = CInt(windowSize.Height / origSize.Height * origSize.Width) End If + Dim xOffset As Integer = 0 + If windowSize.Width < backSize.Width Then + Dim xAspectRatio As Single = CSng(origSize.Width / backSize.Width) + xOffset = CInt(Math.Floor((backSize.Width - windowSize.Width) * xAspectRatio) / 2) + End If - Core.SpriteBatch.Draw(GameModeSplash, New Rectangle(0, 0, backSize.Width, backSize.Height), Color.White) + Core.SpriteBatch.Draw(GameModeSplash, New Rectangle(0, 0, backSize.Width, backSize.Height), New Rectangle(xOffset, 0, origSize.Width, origSize.Height), Color.White) End Sub Public Sub DrawGameJoltButtons(ByVal offset As Vector2) Dim r As New Rectangle(CInt(offset.X + 400), CInt(offset.Y + 200), 512, 128) @@ -1661,8 +1666,13 @@ Public Class GameModeSelectionScreen backSize.Height = windowSize.Height backSize.Width = CInt(windowSize.Height / origSize.Height * origSize.Width) End If + Dim xOffset As Integer = 0 + If windowSize.Width < backSize.Width Then + Dim xAspectRatio As Single = CSng(origSize.Width / backSize.Width) + xOffset = CInt(Math.Floor((backSize.Width - windowSize.Width) * xAspectRatio) / 2) + End If - Core.SpriteBatch.Draw(GameModeSplash, New Rectangle(0, 0, backSize.Width, backSize.Height), Color.White) + Core.SpriteBatch.Draw(GameModeSplash, New Rectangle(0, 0, backSize.Width, backSize.Height), New Rectangle(xOffset, 0, origSize.Width, origSize.Height), Color.White) End Sub Public Overrides Sub Update() diff --git a/P3D/Screens/PC/MailSystemScreen.vb b/P3D/Screens/PC/MailSystemScreen.vb index 20766debd..7fec36409 100644 --- a/P3D/Screens/PC/MailSystemScreen.vb +++ b/P3D/Screens/PC/MailSystemScreen.vb @@ -78,7 +78,13 @@ Dim background As Texture2D = TextureManager.GetTexture("GUI\Menus\MailboxBackground") - Core.SpriteBatch.Draw(background, New Rectangle(0, 0, backSize.Width, backSize.Height), Color.White) + Dim xOffset As Integer = 0 + If windowSize.Width < backSize.Width Then + Dim xAspectRatio As Single = CSng(origSize.Width / backSize.Width) + xOffset = CInt(Math.Floor((backSize.Width - windowSize.Width) * xAspectRatio) / 2) + End If + + Core.SpriteBatch.Draw(background, New Rectangle(0, 0, backSize.Width, backSize.Height), New Rectangle(xOffset, 0, origSize.Width, origSize.Height), Color.White) Canvas.DrawRectangle(New Rectangle(32, 16, 240, 48), New Color(255, 255, 255, 224)) Canvas.DrawRectangle(New Rectangle(48, 64 - 2, 208, 2), Color.DarkGray)