Bunch of editor improvements/bugfixes: free node positioning when placing wires, options to hide hulls, gaps & links, hidden entities can't be selected, more accurate stair selecting, disabled UImessages, camera position fixes
This commit is contained in:
@@ -13,6 +13,8 @@ namespace Barotrauma
|
||||
{
|
||||
public static List<Gap> GapList = new List<Gap>();
|
||||
|
||||
public static bool ShowGaps = true;
|
||||
|
||||
public bool isHorizontal;
|
||||
|
||||
//private Sound waterSound;
|
||||
@@ -65,6 +67,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Gap(Rectangle rectangle)
|
||||
: this (rectangle, Submarine.Loaded)
|
||||
{ }
|
||||
|
||||
public Gap(Rectangle newRect, Submarine submarine)
|
||||
: this(newRect, newRect.Width < newRect.Height, submarine)
|
||||
{ }
|
||||
@@ -102,9 +108,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 position)
|
||||
public override bool IsMouseOn(Vector2 position)
|
||||
{
|
||||
return (Submarine.RectContains(WorldRect, position) &&
|
||||
return (ShowGaps && Submarine.RectContains(WorldRect, position) &&
|
||||
!Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -5), position));
|
||||
}
|
||||
|
||||
@@ -162,10 +168,11 @@ namespace Barotrauma
|
||||
|
||||
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + lerpedFlowForce / 10.0f + Vector2.One * 5.0f, Color.Orange);
|
||||
}
|
||||
|
||||
if (!editing) return;
|
||||
|
||||
if (!editing || !ShowGaps) return;
|
||||
|
||||
Color clr = (open == 0.0f) ? Color.Red : Color.Cyan;
|
||||
if (isHighlighted) clr = Color.Gold;
|
||||
|
||||
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y, rect.Width, rect.Height), clr * 0.5f, true);
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Barotrauma
|
||||
public static List<Hull> hullList = new List<Hull>();
|
||||
private static EntityGrid entityGrid;
|
||||
|
||||
public static bool ShowHulls = true;
|
||||
|
||||
public static bool EditWater, EditFire;
|
||||
|
||||
public static WaterRenderer renderer;
|
||||
@@ -186,8 +188,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 position)
|
||||
public override bool IsMouseOn(Vector2 position)
|
||||
{
|
||||
if (!GameMain.DebugDraw && !ShowHulls) return false;
|
||||
|
||||
return (Submarine.RectContains(WorldRect, position) &&
|
||||
!Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -8), position));
|
||||
}
|
||||
@@ -228,7 +232,7 @@ namespace Barotrauma
|
||||
|
||||
//renderer.Dispose();
|
||||
|
||||
entityGrid.RemoveEntity(this);
|
||||
if (entityGrid!=null) entityGrid.RemoveEntity(this);
|
||||
|
||||
hullList.Remove(this);
|
||||
}
|
||||
@@ -371,6 +375,8 @@ namespace Barotrauma
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
if (!ShowHulls && !GameMain.DebugDraw) return;
|
||||
|
||||
if (!editing && !GameMain.DebugDraw) return;
|
||||
|
||||
Rectangle drawRect =
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Barotrauma
|
||||
rect.Y += (int)amount.Y;
|
||||
}
|
||||
|
||||
public virtual bool Contains(Vector2 position)
|
||||
public virtual bool IsMouseOn(Vector2 position)
|
||||
{
|
||||
return (Submarine.RectContains(WorldRect, position));
|
||||
}
|
||||
@@ -268,7 +268,7 @@ namespace Barotrauma
|
||||
if (highLightedEntity == null || e.Sprite == null ||
|
||||
(highLightedEntity.Sprite!=null && e.Sprite.Depth < highLightedEntity.Sprite.Depth))
|
||||
{
|
||||
if (e.Contains(position)) highLightedEntity = e;
|
||||
if (e.IsMouseOn(position)) highLightedEntity = e;
|
||||
}
|
||||
e.isSelected = false;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ namespace Barotrauma
|
||||
//if clicking a selected entity, start moving it
|
||||
foreach (MapEntity e in selectedList)
|
||||
{
|
||||
if (e.Contains(position)) startMovingPos = position;
|
||||
if (e.IsMouseOn(position)) startMovingPos = position;
|
||||
}
|
||||
|
||||
selectionPos = position;
|
||||
@@ -415,6 +415,16 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (editingHUD == null) return;
|
||||
|
||||
foreach (GUIComponent component in editingHUD.children)
|
||||
{
|
||||
var textBox = component as GUITextBox;
|
||||
if (textBox == null) continue;
|
||||
|
||||
textBox.Deselect();
|
||||
}
|
||||
|
||||
editingHUD = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,13 @@ namespace Barotrauma
|
||||
|
||||
if (placePosition == Vector2.Zero)
|
||||
{
|
||||
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed)
|
||||
placePosition = Submarine.MouseToWorldGrid(cam);
|
||||
Vector2 position = Submarine.MouseToWorldGrid(cam);
|
||||
|
||||
GUI.DrawLine(spriteBatch, new Vector2(position.X-GameMain.GraphicsWidth, -position.Y), new Vector2(position.X+GameMain.GraphicsWidth, -position.Y), Color.White);
|
||||
|
||||
GUI.DrawLine(spriteBatch, new Vector2(position.X, position.Y - GameMain.GraphicsHeight), new Vector2(position.X, position.Y+GameMain.GraphicsHeight), Color.White);
|
||||
|
||||
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed) placePosition = position;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -268,6 +268,27 @@ namespace Barotrauma
|
||||
|
||||
InsertToList();
|
||||
}
|
||||
|
||||
public override bool IsMouseOn(Vector2 position)
|
||||
{
|
||||
if (StairDirection == Direction.None)
|
||||
{
|
||||
return base.IsMouseOn(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!base.IsMouseOn(position)) return false;
|
||||
|
||||
if (StairDirection == Direction.Left)
|
||||
{
|
||||
return MathUtils.LineToPointDistance(new Vector2(rect.X, rect.Y), new Vector2(rect.Right, rect.Y - rect.Height), position)< 40.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MathUtils.LineToPointDistance(new Vector2(rect.X,rect.Y-rect.Height), new Vector2(rect.Right, rect.Y), position) <40.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma
|
||||
{
|
||||
public static List<WayPoint> WayPointList = new List<WayPoint>();
|
||||
|
||||
public static bool ShowWayPoints, ShowSpawnPoints;
|
||||
public static bool ShowWayPoints = true, ShowSpawnPoints = true;
|
||||
|
||||
private SpawnType spawnType;
|
||||
|
||||
@@ -75,6 +75,10 @@ namespace Barotrauma
|
||||
ConnectedGap = gap;
|
||||
}
|
||||
|
||||
public WayPoint(Rectangle rectangle)
|
||||
: this (rectangle, Submarine.Loaded)
|
||||
{ }
|
||||
|
||||
public WayPoint(Rectangle newRect, Submarine submarine)
|
||||
: base (submarine)
|
||||
{
|
||||
@@ -88,18 +92,18 @@ namespace Barotrauma
|
||||
currentHull = Hull.FindHull(WorldPosition);
|
||||
}
|
||||
|
||||
public override bool IsMouseOn(Vector2 position)
|
||||
{
|
||||
if (IsHidden()) return false;
|
||||
|
||||
return base.IsMouseOn(position);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back=true)
|
||||
{
|
||||
if (!editing && !GameMain.DebugDraw) return;
|
||||
|
||||
if (spawnType == SpawnType.Path)
|
||||
{
|
||||
if (!GameMain.DebugDraw && !ShowWayPoints) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GameMain.DebugDraw && !ShowSpawnPoints) return;
|
||||
}
|
||||
if (IsHidden()) return;
|
||||
|
||||
Rectangle drawRect =
|
||||
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
||||
@@ -119,6 +123,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsHidden()
|
||||
{
|
||||
if (spawnType == SpawnType.Path)
|
||||
{
|
||||
return (!GameMain.DebugDraw && !ShowWayPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (!GameMain.DebugDraw && !ShowSpawnPoints);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawEditing(SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
if (editingHUD == null || editingHUD.UserData != this)
|
||||
@@ -247,6 +263,8 @@ namespace Barotrauma
|
||||
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
if (hull.Rect.Height < 150) continue;
|
||||
|
||||
WayPoint prevWaypoint = null;
|
||||
|
||||
if (hull.Rect.Width<minDist*3.0f)
|
||||
|
||||
Reference in New Issue
Block a user