Option to display lighting in sub editor

This commit is contained in:
Joonas Rikkonen
2018-01-09 12:27:42 +02:00
parent 55e96b315f
commit 6a3a4efba6
4 changed files with 44 additions and 15 deletions
@@ -286,7 +286,7 @@ namespace Barotrauma
ServerListScreen = new ServerListScreen();
SubEditorScreen = new SubEditorScreen();
SubEditorScreen = new SubEditorScreen(Content);
CharacterEditorScreen = new CharacterEditorScreen();
ParticleEditorScreen = new ParticleEditorScreen();
@@ -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<Effect>("blurshader_opengl");
#else
var blurEffect = content.Load<Effect>("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);
@@ -219,6 +219,7 @@
<GenerateWaypointsButton>Generate waypoints</GenerateWaypointsButton>
<GenerateWaypointsToolTip>AI controlled crew members require waypoints to navigate around the sub.</GenerateWaypointsToolTip>
<ShowEntitiesLabel>Show</ShowEntitiesLabel>
<ShowLighting>Lighting</ShowLighting>
<ShowWaypoints>Waypoints</ShowWaypoints>
<ShowSpawnpoints>Spawnpoints</ShowSpawnpoints>
<ShowLinks>Links</ShowLinks>
@@ -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)