diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index 45fe0b4f7..82405f913 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -286,7 +286,7 @@ namespace Barotrauma ServerListScreen = new ServerListScreen(); - SubEditorScreen = new SubEditorScreen(); + SubEditorScreen = new SubEditorScreen(Content); CharacterEditorScreen = new CharacterEditorScreen(); ParticleEditorScreen = new ParticleEditorScreen(); diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index d92be993e..5e87310c0 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -1,5 +1,6 @@ using Barotrauma.Items.Components; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -13,6 +14,9 @@ namespace Barotrauma class SubEditorScreen : Screen { private Camera cam; + private BlurEffect lightBlur; + + private bool lightingEnabled; public GUIComponent topPanel, leftPanel; @@ -117,10 +121,15 @@ namespace Barotrauma } - public SubEditorScreen() + public SubEditorScreen(ContentManager content) { - cam = new Camera(); - //cam.Translate(new Vector2(-10.0f, 50.0f)); + cam = new Camera(); +#if LINUX + var blurEffect = content.Load("blurshader_opengl"); +#else + var blurEffect = content.Load("blurshader"); +#endif + lightBlur = new BlurEffect(blurEffect, 0.001f, 0.001f); selectedTab = -1; @@ -258,24 +267,26 @@ namespace Barotrauma y += 30; new GUITextBlock(new Rectangle(0, y, 0, 20), TextManager.Get("ShowEntitiesLabel"), "", leftPanel); - - var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), TextManager.Get("ShowWaypoints"), Alignment.TopLeft, leftPanel); + + var tickBox = new GUITickBox(new Rectangle(0, y + 20, 20, 20), TextManager.Get("ShowLighting"), Alignment.TopLeft, leftPanel); + tickBox.OnSelected = (GUITickBox obj) => { lightingEnabled = !lightingEnabled; return true; }; + tickBox = new GUITickBox(new Rectangle(0, y + 45, 20, 20), TextManager.Get("ShowWaypoints"), Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return true; }; tickBox.Selected = true; - tickBox = new GUITickBox(new Rectangle(0, y + 45, 20, 20), TextManager.Get("ShowSpawnpoints"), Alignment.TopLeft, leftPanel); + tickBox = new GUITickBox(new Rectangle(0, y + 70, 20, 20), TextManager.Get("ShowSpawnpoints"), Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return true; }; tickBox.Selected = true; - tickBox = new GUITickBox(new Rectangle(0, y + 70, 20, 20), TextManager.Get("ShowLinks"), Alignment.TopLeft, leftPanel); + tickBox = new GUITickBox(new Rectangle(0, y + 95, 20, 20), TextManager.Get("ShowLinks"), Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { Item.ShowLinks = !Item.ShowLinks; return true; }; tickBox.Selected = true; - tickBox = new GUITickBox(new Rectangle(0, y + 95, 20, 20), TextManager.Get("ShowHulls"), Alignment.TopLeft, leftPanel); + tickBox = new GUITickBox(new Rectangle(0, y + 120, 20, 20), TextManager.Get("ShowHulls"), Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { Hull.ShowHulls = !Hull.ShowHulls; return true; }; tickBox.Selected = true; - tickBox = new GUITickBox(new Rectangle(0, y + 120, 20, 20), TextManager.Get("ShowGaps"), Alignment.TopLeft, leftPanel); + tickBox = new GUITickBox(new Rectangle(0, y + 145, 20, 20), TextManager.Get("ShowGaps"), Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { Gap.ShowGaps = !Gap.ShowGaps; return true; }; tickBox.Selected = true; - y+=150; + y += 170; if (y < GameMain.GraphicsHeight - 100) { @@ -1382,6 +1393,10 @@ namespace Barotrauma public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) { cam.UpdateTransform(); + if (lightingEnabled) + { + GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam, lightBlur.Effect); + } spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, @@ -1400,13 +1415,17 @@ namespace Barotrauma if (!characterMode && !wiringMode) { if (MapEntityPrefab.Selected != null) MapEntityPrefab.Selected.DrawPlacing(spriteBatch,cam); - MapEntity.DrawSelecting(spriteBatch, cam); } - - spriteBatch.End(); + if (GameMain.LightManager.LightingEnabled && lightingEnabled) + { + spriteBatch.Begin(SpriteSortMode.Deferred, Lights.CustomBlendStates.Multiplicative, null, DepthStencilState.None, null, null, null); + spriteBatch.Draw(GameMain.LightManager.lightMap, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White); + spriteBatch.End(); + } + //-------------------- HUD ----------------------------- spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable); diff --git a/Barotrauma/BarotraumaShared/Content/Texts.xml b/Barotrauma/BarotraumaShared/Content/Texts.xml index c1140f639..c1a2be692 100644 --- a/Barotrauma/BarotraumaShared/Content/Texts.xml +++ b/Barotrauma/BarotraumaShared/Content/Texts.xml @@ -219,6 +219,7 @@ Generate waypoints AI controlled crew members require waypoints to navigate around the sub. Show + Lighting Waypoints Spawnpoints Links diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs index 99797afd9..8a0168313 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs @@ -28,6 +28,9 @@ namespace Barotrauma.Items.Components set { range = MathHelper.Clamp(value, 0.0f, 2048.0f); +#if CLIENT + if (light != null) light.Range = range; +#endif } } @@ -72,7 +75,13 @@ namespace Barotrauma.Items.Components public Color LightColor { get { return lightColor; } - set { lightColor = value; } + set + { + lightColor = value; +#if CLIENT + if (light != null) light.Color = lightColor; +#endif + } } public override void Move(Vector2 amount)