From 581a7d5d9f2ab799e4d8235a089674f585ef1c9a Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 31 Jul 2016 19:13:08 +0300 Subject: [PATCH] Highlighted items glow in the dark, health bars are hidden when health is full, usernames and health bars are drawn at full brightness --- Subsurface/Barotrauma.csproj | 3 +++ Subsurface/Source/Characters/Character.cs | 9 ++++++--- Subsurface/Source/GUI/GUI.cs | 8 ++++++-- Subsurface/Source/Map/Levels/Level.cs | 2 +- Subsurface/Source/Map/Lights/LightManager.cs | 7 +++++++ Subsurface/Source/Screens/GameScreen.cs | 6 +++--- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 0b99d6149..f29daa602 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -1281,6 +1281,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 83ad90d67..9edfe9614 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1165,10 +1165,13 @@ namespace Barotrauma if (isDead) return; - Vector2 healthBarPos = new Vector2(pos.X - 50, DrawPosition.Y + 100.0f); + if (health < maxHealth * 0.98f) + { + Vector2 healthBarPos = new Vector2(pos.X - 50, DrawPosition.Y + 100.0f); + + GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f); + } - GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f); - if (speechBubbleTimer > 0.0f) { GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 100.0f, diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs index eed1cbe28..d0b082ef6 100644 --- a/Subsurface/Source/GUI/GUI.cs +++ b/Subsurface/Source/GUI/GUI.cs @@ -21,7 +21,8 @@ namespace Barotrauma Message, RadioMessage, DeadMessage, - Click + Click, + Inventory, } public class GUI @@ -90,11 +91,14 @@ namespace Barotrauma if (loadSounds) { - sounds = new Sound[4]; + sounds = new Sound[Enum.GetValues(typeof(GUISoundType)).Length]; sounds[(int)GUISoundType.Message] = Sound.Load("Content/Sounds/UI/UImsg.ogg", false); sounds[(int)GUISoundType.RadioMessage] = Sound.Load("Content/Sounds/UI/radiomsg.ogg", false); sounds[(int)GUISoundType.DeadMessage] = Sound.Load("Content/Sounds/UI/deadmsg.ogg", false); sounds[(int)GUISoundType.Click] = Sound.Load("Content/Sounds/UI/beep-shinymetal.ogg", false); + + sounds[(int)GUISoundType.Inventory] = Sound.Load("Content/Sounds/pickItem.ogg", false); + } // create 1x1 texture for line drawing diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 5516f9ed2..5f30db6fc 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -181,7 +181,7 @@ namespace Barotrauma backgroundColor = new Color(backgroundColor, 1.0f); float avgValue = (backgroundColor.R + backgroundColor.G + backgroundColor.G) / 3; - GameMain.LightManager.AmbientLight = new Color(backgroundColor*(40.0f/avgValue), 1.0f); + GameMain.LightManager.AmbientLight = new Color(backgroundColor * (60.0f / avgValue), 1.0f); float minWidth = Submarine.MainSub == null ? 0.0f : Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height); minWidth = Math.Max(minWidth, 6500.0f); diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index 7281cf055..69b0d530f 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -111,6 +111,7 @@ namespace Barotrauma.Lights //where Alpha is 0, nothing will be written spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform); light.Draw(spriteBatch); + spriteBatch.End(); } @@ -122,6 +123,7 @@ namespace Barotrauma.Lights GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.Additive); + foreach (LightSource light in lights) { if (light.Color.A < 0.01f || light.Range < 1.0f || light.CastShadows) continue; @@ -130,6 +132,11 @@ namespace Barotrauma.Lights light.Draw(spriteBatch); } + if (Character.Controlled != null && Character.Controlled.ClosestItem != null) + { + Character.Controlled.ClosestItem.Draw(spriteBatch, false, true); + Character.Controlled.ClosestItem.IsHighlighted = true; + } spriteBatch.End(); //clear alpha, to avoid messing stuff up later diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 426992eeb..a38d05574 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -317,8 +317,6 @@ namespace Barotrauma null, null, null, cam.Transform); - foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch); - Submarine.DrawFront(spriteBatch); spriteBatch.End(); @@ -330,7 +328,9 @@ namespace Barotrauma null, null, null, cam.Transform); - if (Level.Loaded!=null) Level.Loaded.DrawFront(spriteBatch); + if (Level.Loaded != null) Level.Loaded.DrawFront(spriteBatch); + + foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch); spriteBatch.End();