From 39ddd63e0ccf4dfce998943aace010ef4ced0149 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 2 May 2017 23:39:09 +0300 Subject: [PATCH] Removed references to GameMain from GUIListBox & GUITextBlock (-> launcher works again) --- Launcher2/LauncherMain.cs | 29 ++++++++++++--------------- Subsurface/Source/GUI/GUIListBox.cs | 7 ++++--- Subsurface/Source/GUI/GUITextBlock.cs | 13 +++++++++--- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Launcher2/LauncherMain.cs b/Launcher2/LauncherMain.cs index 49ce2c989..fe6de4745 100644 --- a/Launcher2/LauncherMain.cs +++ b/Launcher2/LauncherMain.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Input; using Barotrauma; using System.Collections.Generic; using System.Reflection; -using System.Runtime.InteropServices; using System.Xml.Linq; using System.Linq; using System.Diagnostics; @@ -25,7 +24,7 @@ namespace Launcher2 string version = AssemblyName.GetAssemblyName("Barotrauma.exe").Version.ToString(); private const string configPath = "config.xml"; - private Barotrauma.GameSettings settings; + private GameSettings settings; private string latestVersionFileList, latestVersionFolder; @@ -38,28 +37,24 @@ namespace Launcher2 private GUIProgressBar progressBar; private GUIButton downloadButton; - GUIButton launchButton; - - //public bool FullScreenEnabled - //{ - // get { return settings.FullScreenEnabled; } - // set { settings.FullScreenEnabled = value; } - //} - + private GUIButton launchButton; + public bool AutoCheckUpdates { get { return settings.AutoCheckUpdates; } set { settings.AutoCheckUpdates = value; } } - Texture2D backgroundTexture, titleTexture; + private Texture2D backgroundTexture, titleTexture; - GraphicsDeviceManager graphics; - SpriteBatch spriteBatch; + private GraphicsDeviceManager graphics; + private SpriteBatch spriteBatch; - int graphicsWidth, graphicsHeight; + private RasterizerState scissorTestEnable; - GUIFrame guiRoot; + private int graphicsWidth, graphicsHeight; + + private GUIFrame guiRoot; public LauncherMain() : base() @@ -67,6 +62,8 @@ namespace Launcher2 graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 640; graphics.PreferredBackBufferHeight = 400; + + scissorTestEnable = new RasterizerState() { ScissorTestEnable = true }; IsMouseVisible = true; @@ -214,7 +211,7 @@ namespace Launcher2 { GraphicsDevice.Clear(Color.Black); - spriteBatch.Begin(); + spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, scissorTestEnable); spriteBatch.Draw(backgroundTexture, new Rectangle(0, 0, graphicsWidth, graphicsHeight), diff --git a/Subsurface/Source/GUI/GUIListBox.cs b/Subsurface/Source/GUI/GUIListBox.cs index 36a6e7b0c..bac788c7d 100644 --- a/Subsurface/Source/GUI/GUIListBox.cs +++ b/Subsurface/Source/GUI/GUIListBox.cs @@ -391,7 +391,8 @@ namespace Barotrauma if (!scrollBarHidden) scrollBar.Draw(spriteBatch); - GameMain.CurrGraphicsDevice.ScissorRectangle = frame.Rect; + Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle; + spriteBatch.GraphicsDevice.ScissorRectangle = frame.Rect; int lastVisible = 0; for (int i = 0; i < children.Count; i++) @@ -408,8 +409,8 @@ namespace Barotrauma lastVisible = i; child.Draw(spriteBatch); } - - GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight); + + spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect; } private bool IsChildVisible(GUIComponent child) diff --git a/Subsurface/Source/GUI/GUITextBlock.cs b/Subsurface/Source/GUI/GUITextBlock.cs index d4b5331b3..d16f4e5d6 100644 --- a/Subsurface/Source/GUI/GUITextBlock.cs +++ b/Subsurface/Source/GUI/GUITextBlock.cs @@ -278,8 +278,12 @@ namespace Barotrauma base.Draw(spriteBatch); if (TextGetter != null) text = TextGetter(); - - if (overflowClipActive) GameMain.CurrGraphicsDevice.ScissorRectangle = rect; + + Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle; + if (overflowClipActive) + { + spriteBatch.GraphicsDevice.ScissorRectangle = rect; + } if (!string.IsNullOrEmpty(text)) { @@ -291,7 +295,10 @@ namespace Barotrauma SpriteEffects.None, textDepth); } - if (overflowClipActive) GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight); + if (overflowClipActive) + { + spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect; + } DrawChildren(spriteBatch);