From 4685121eeec5b24ea4b388805b1169d3ed3ee58e Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 3 Apr 2019 16:24:48 +0300 Subject: [PATCH] (3ffde5103) Disabled alpha premultiplication on a bunch of non-transparent textures (-> minor loading time reduction) --- .../BarotraumaClient/Source/GameSettings.cs | 19 +++++++++++++++++++ .../Source/Map/Lights/LightManager.cs | 10 +++++++--- .../Source/Map/Lights/LightSource.cs | 4 ++-- .../Source/Screens/GameScreen.cs | 4 ++-- .../Items/Components/Signal/LightComponent.cs | 4 ++++ .../BarotraumaShared/Source/Sprite/Sprite.cs | 4 ++-- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 874608100..91e698e09 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -701,6 +701,25 @@ namespace Barotrauma } }; + //spacing + new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); + + new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft), + TextManager.Get("Cancel"), style: "GUIButtonLarge") + { + IgnoreLayoutGroups = true, + OnClicked = (x, y) => + { + if (UnsavedSettings) + { + LoadPlayerConfig(); + } + if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null); + GUI.SettingsMenuOpen = false; + return true; + } + }; + applyButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomRight), TextManager.Get("ApplySettingsButton"), style: "GUIButtonLarge") { diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs index ca4b9c13f..a1fb2e137 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs @@ -78,9 +78,8 @@ namespace Barotrauma.Lights AmbientLight = new Color(20, 20, 20, 255); - visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png"); - - highlightRaster = Sprite.LoadTexture("Content/UI/HighlightRaster.png"); + visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png", preMultiplyAlpha: false); + highlightRaster = Sprite.LoadTexture("Content/UI/HighlightRaster.png", preMultiplyAlpha: false); CreateRenderTargets(graphics); GameMain.Instance.OnResolutionChanged += () => @@ -292,6 +291,11 @@ namespace Barotrauma.Lights spriteBatch.Draw(HighlightMap, Vector2.Zero, Color.White); spriteBatch.End(); } + GameMain.ParticleManager.Draw(spriteBatch, true, null, Particles.ParticleBlendState.Additive); + spriteBatch.End(); + + //draw a black rectangle on hulls to hide background lights behind subs + //--------------------------------------------------------------------------------------------------- //draw characters to obstruct the highlighted items/characters and light sprites //--------------------------------------------------------------------------------------------------- diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs index 9ff808757..946001c44 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs @@ -91,7 +91,7 @@ namespace Barotrauma.Lights } break; case "lighttexture": - OverrideLightTexture = new Sprite(subElement); + OverrideLightTexture = new Sprite(subElement, preMultiplyAlpha: false); break; } } @@ -211,7 +211,7 @@ namespace Barotrauma.Lights { if (lightTexture == null) { - lightTexture = TextureLoader.FromFile("Content/Lights/pointlight_bright.png"); + lightTexture = TextureLoader.FromFile("Content/Lights/pointlight_bright.png", preMultiplyAlpha: false); } return lightTexture; diff --git a/Barotrauma/BarotraumaClient/Source/Screens/GameScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/GameScreen.cs index a16eb2187..6d1e9ba04 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/GameScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/GameScreen.cs @@ -47,12 +47,12 @@ namespace Barotrauma postProcessEffect = content.Load("Effects/postprocess"); #endif - damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png"); + damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png", preMultiplyAlpha: false); damageEffect.Parameters["xStencil"].SetValue(damageStencil); damageEffect.Parameters["aMultiplier"].SetValue(50.0f); damageEffect.Parameters["cMultiplier"].SetValue(200.0f); - distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png"); + distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png", preMultiplyAlpha: false); postProcessEffect.Parameters["xDistortTexture"].SetValue(distortTexture); } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs index 7845f609c..eebf1146a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs @@ -26,6 +26,10 @@ namespace Barotrauma.Items.Components private float blinkTimer; + private bool itemLoaded; + + private float blinkTimer; + public PhysicsBody ParentBody; [Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)] diff --git a/Barotrauma/BarotraumaShared/Source/Sprite/Sprite.cs b/Barotrauma/BarotraumaShared/Source/Sprite/Sprite.cs index f5b89c237..d6141f6ad 100644 --- a/Barotrauma/BarotraumaShared/Source/Sprite/Sprite.cs +++ b/Barotrauma/BarotraumaShared/Source/Sprite/Sprite.cs @@ -99,7 +99,7 @@ namespace Barotrauma partial void LoadTexture(ref Vector4 sourceVector, ref bool shouldReturn, bool premultiplyAlpha = true); partial void CalculateSourceRect(); - public Sprite(XElement element, string path = "", string file = "") + public Sprite(XElement element, string path = "", string file = "", bool? preMultiplyAlpha = null) { SourceElement = element; if (file == "") @@ -124,7 +124,7 @@ namespace Barotrauma Name = SourceElement.GetAttributeString("name", null); Vector4 sourceVector = SourceElement.GetAttributeVector4("sourcerect", Vector4.Zero); bool shouldReturn = false; - LoadTexture(ref sourceVector, ref shouldReturn, SourceElement.GetAttributeBool("premultiplyalpha", true)); + LoadTexture(ref sourceVector, ref shouldReturn, preMultiplyAlpha ?? SourceElement.GetAttributeBool("premultiplyalpha", true)); if (shouldReturn) return; sourceRect = new Rectangle((int)sourceVector.X, (int)sourceVector.Y, (int)sourceVector.Z, (int)sourceVector.W); size = SourceElement.GetAttributeVector2("size", Vector2.One);