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:
Regalis
2016-01-15 23:04:34 +02:00
parent 203e7c4114
commit 8e491ae855
13 changed files with 184 additions and 65 deletions
+14 -2
View File
@@ -55,7 +55,19 @@ namespace Barotrauma.Items.Components
linkedGap = e as Gap; linkedGap = e as Gap;
if (linkedGap != null) return linkedGap; if (linkedGap != null) return linkedGap;
} }
linkedGap = new Gap(item.Rect, Item.Submarine); Rectangle rect = item.Rect;
if (isHorizontal)
{
rect.Y += 5;
rect.Height += 10;
}
else
{
rect.X -= 5;
rect.Width += 10;
}
linkedGap = new Gap(rect, Item.Submarine);
linkedGap.Submarine = item.Submarine; linkedGap.Submarine = item.Submarine;
linkedGap.Open = openState; linkedGap.Open = openState;
item.linkedTo.Add(linkedGap); item.linkedTo.Add(linkedGap);
@@ -341,7 +353,7 @@ namespace Barotrauma.Items.Components
doorSprite.Remove(); doorSprite.Remove();
convexHull.Remove(); if (convexHull!=null) convexHull.Remove();
if (convexHull2 != null) convexHull2.Remove(); if (convexHull2 != null) convexHull2.Remove();
} }
@@ -173,18 +173,19 @@ namespace Barotrauma.Items.Components
item.FindHull(); item.FindHull();
Vector2 position = item.Position; //Vector2 position = item.Position;
position.X = MathUtils.Round(item.Position.X, nodeDistance);
if (item.CurrentHull == null) //position.X = MathUtils.Round(item.Position.X, nodeDistance);
{ //if (item.CurrentHull == null)
position.Y = MathUtils.Round(item.Position.Y, nodeDistance); //{
} // position.Y = MathUtils.Round(item.Position.Y, nodeDistance);
else //}
{ //else
position.Y -= item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height; //{
position.Y = Math.Max(MathUtils.Round(position.Y, nodeDistance), heightFromFloor); // position.Y -= item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height;
position.Y += item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height; // position.Y = Math.Max(MathUtils.Round(position.Y, nodeDistance), heightFromFloor);
} // position.Y += item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height;
//}
newNodePos = RoundNode(item.Position, item.CurrentHull)-Submarine.HiddenSubPosition; newNodePos = RoundNode(item.Position, item.CurrentHull)-Submarine.HiddenSubPosition;
@@ -248,6 +249,15 @@ namespace Barotrauma.Items.Components
} }
private Vector2 RoundNode(Vector2 position, Hull hull) private Vector2 RoundNode(Vector2 position, Hull hull)
{
if (Screen.Selected == GameMain.EditMapScreen)
{
//position = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition) - Submarine.Loaded.Position;// Nodes[(int)selectedNodeIndex];
position.X = MathUtils.Round(position.X, Submarine.GridSize.X / 2.0f);
position.Y = MathUtils.Round(position.Y, Submarine.GridSize.Y / 2.0f);
}
else
{ {
position.X = MathUtils.Round(position.X, nodeDistance); position.X = MathUtils.Round(position.X, nodeDistance);
if (hull == null) if (hull == null)
@@ -260,6 +270,7 @@ namespace Barotrauma.Items.Components
position.Y = Math.Max(MathUtils.Round(position.Y, nodeDistance), heightFromFloor); position.Y = Math.Max(MathUtils.Round(position.Y, nodeDistance), heightFromFloor);
position.Y += hull.Rect.Y -hull.Rect.Height; position.Y += hull.Rect.Y -hull.Rect.Height;
} }
}
return position; return position;
} }
@@ -322,11 +333,13 @@ namespace Barotrauma.Items.Components
for (int i = 0; i < Nodes.Count; i++) for (int i = 0; i < Nodes.Count; i++)
{ {
Vector2 worldPos = Nodes[i]; Vector2 worldPos = Nodes[i];
if (item.Submarine != null) worldPos += item.Submarine.Position + Submarine.HiddenSubPosition; if (Submarine.Loaded != null) worldPos += Submarine.Loaded.Position + Submarine.HiddenSubPosition;
worldPos.Y = -worldPos.Y; worldPos.Y = -worldPos.Y;
GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-3, -3), new Vector2(6, 6), item.Color, true, 0.0f); GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-3, -3), new Vector2(6, 6), item.Color, true, 0.0f);
if (IsActive) continue;
if (GUIComponent.MouseOn != null || if (GUIComponent.MouseOn != null ||
Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), new Vector2(worldPos.X, -worldPos.Y)) > 10.0f) Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), new Vector2(worldPos.X, -worldPos.Y)) > 10.0f)
{ {
@@ -382,10 +395,10 @@ namespace Barotrauma.Items.Components
private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color) private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color)
{ {
if (item.Submarine!=null) if (Submarine.Loaded!=null)
{ {
start += item.Submarine.DrawPosition+Submarine.HiddenSubPosition; start += Submarine.Loaded.DrawPosition + Submarine.HiddenSubPosition;
end += item.Submarine.DrawPosition+Submarine.HiddenSubPosition; end += Submarine.Loaded.DrawPosition + Submarine.HiddenSubPosition;
} }
start.Y = -start.Y; start.Y = -start.Y;
+9 -6
View File
@@ -29,6 +29,8 @@ namespace Barotrauma
public static ItemSpawner Spawner = new ItemSpawner(); public static ItemSpawner Spawner = new ItemSpawner();
public static ItemRemover Remover = new ItemRemover(); public static ItemRemover Remover = new ItemRemover();
public static bool ShowLinks = true;
private List<string> tags; private List<string> tags;
public Hull CurrentHull; public Hull CurrentHull;
@@ -698,6 +700,8 @@ namespace Barotrauma
Color.Green); Color.Green);
} }
if (!ShowLinks) return;
foreach (MapEntity e in linkedTo) foreach (MapEntity e in linkedTo)
{ {
GUI.DrawLine(spriteBatch, GUI.DrawLine(spriteBatch,
@@ -727,7 +731,7 @@ namespace Barotrauma
{ {
if (entity == this || !entity.IsHighlighted) continue; if (entity == this || !entity.IsHighlighted) continue;
if (linkedTo.Contains(entity)) continue; if (linkedTo.Contains(entity)) continue;
if (!entity.Contains(position)) continue; if (!entity.IsMouseOn(position)) continue;
linkedTo.Add(entity); linkedTo.Add(entity);
if (entity.IsLinkable && entity.linkedTo != null) entity.linkedTo.Add(this); if (entity.IsLinkable && entity.linkedTo != null) entity.linkedTo.Add(this);
@@ -790,7 +794,7 @@ namespace Barotrauma
foreach (var objectProperty in editableProperties) foreach (var objectProperty in editableProperties)
{ {
new GUITextBlock(new Rectangle(0, y, 100, 20), objectProperty.Name, Color.Transparent, Color.White, Alignment.Left, null, editingHUD); new GUITextBlock(new Rectangle(0, y, 100, 20), objectProperty.Name, Color.Transparent, Color.White, Alignment.Left, GUI.Style, editingHUD);
int height = 20; int height = 20;
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault<Editable>(); var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault<Editable>();
@@ -905,11 +909,9 @@ namespace Barotrauma
transformedTrigger.Y - transformedTrigger.Height / 2.0f); transformedTrigger.Y - transformedTrigger.Height / 2.0f);
dist = MathHelper.Min(Math.Abs(triggerCenter.X - displayPos.X), Math.Abs(triggerCenter.Y-displayPos.Y)); dist = MathHelper.Min(Math.Abs(triggerCenter.X - displayPos.X), Math.Abs(triggerCenter.Y-displayPos.Y));
dist = ConvertUnits.ToSimUnits(dist);
if (dist > closestDist && closest!=null) continue; if (dist > closestDist && closest!=null) continue;
dist = MathHelper.Min(Math.Abs(triggerCenter.X - displayPickPos.X), Math.Abs(triggerCenter.Y - displayPickPos.Y)); dist = MathHelper.Min(Math.Abs(triggerCenter.X - displayPickPos.X), Math.Abs(triggerCenter.Y - displayPickPos.Y));
dist = ConvertUnits.ToSimUnits(dist);
if (closest == null || dist < closestDist) if (closest == null || dist < closestDist)
{ {
closest = item; closest = item;
@@ -993,7 +995,8 @@ namespace Barotrauma
if (tempRequiredSkill != null) requiredSkill = tempRequiredSkill; if (tempRequiredSkill != null) requiredSkill = tempRequiredSkill;
if (!ignoreRequiredItems && !ic.HasRequiredItems(picker, picker == Character.Controlled)) continue; bool showUiMsg = picker == Character.Controlled && Screen.Selected != GameMain.EditMapScreen;
if (!ignoreRequiredItems && !ic.HasRequiredItems(picker, showUiMsg)) continue;
if ((ic.CanBePicked && pickHit && ic.Pick(picker)) || if ((ic.CanBePicked && pickHit && ic.Pick(picker)) ||
(ic.CanBeSelected && selectHit && ic.Select(picker))) (ic.CanBeSelected && selectHit && ic.Select(picker)))
{ {
@@ -1133,7 +1136,7 @@ namespace Barotrauma
private bool EnterProperty(GUITextBox textBox, string text) private bool EnterProperty(GUITextBox textBox, string text)
{ {
textBox.Color = Color.White; textBox.Color = Color.DarkGreen;
var objectProperty = textBox.UserData as ObjectProperty; var objectProperty = textBox.UserData as ObjectProperty;
if (objectProperty == null) return false; if (objectProperty == null) return false;
+1 -1
View File
@@ -97,7 +97,7 @@ namespace Barotrauma
var item = new Item(new Rectangle((int)position.X, (int)position.Y, (int)sprite.size.X, (int)sprite.size.Y), this, Submarine.Loaded); var item = new Item(new Rectangle((int)position.X, (int)position.Y, (int)sprite.size.X, (int)sprite.size.Y), this, Submarine.Loaded);
//constructor.Invoke(lobject); //constructor.Invoke(lobject);
item.Submarine = Submarine.Loaded; item.Submarine = Submarine.Loaded;
item.SetTransform(ConvertUnits.ToSimUnits(item.Position - Submarine.Loaded.Position), 0.0f); item.SetTransform(ConvertUnits.ToSimUnits(Submarine.Loaded==null ? item.Position : item.Position - Submarine.Loaded.Position), 0.0f);
item.FindHull(); item.FindHull();
placePosition = Vector2.Zero; placePosition = Vector2.Zero;
+10 -3
View File
@@ -13,6 +13,8 @@ namespace Barotrauma
{ {
public static List<Gap> GapList = new List<Gap>(); public static List<Gap> GapList = new List<Gap>();
public static bool ShowGaps = true;
public bool isHorizontal; public bool isHorizontal;
//private Sound waterSound; //private Sound waterSound;
@@ -65,6 +67,10 @@ namespace Barotrauma
} }
} }
public Gap(Rectangle rectangle)
: this (rectangle, Submarine.Loaded)
{ }
public Gap(Rectangle newRect, Submarine submarine) public Gap(Rectangle newRect, Submarine submarine)
: this(newRect, newRect.Width < newRect.Height, 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)); !Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -5), position));
} }
@@ -163,9 +169,10 @@ namespace Barotrauma
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + lerpedFlowForce / 10.0f + Vector2.One * 5.0f, Color.Orange); 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; 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); GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y, rect.Width, rect.Height), clr * 0.5f, true);
+8 -2
View File
@@ -16,6 +16,8 @@ namespace Barotrauma
public static List<Hull> hullList = new List<Hull>(); public static List<Hull> hullList = new List<Hull>();
private static EntityGrid entityGrid; private static EntityGrid entityGrid;
public static bool ShowHulls = true;
public static bool EditWater, EditFire; public static bool EditWater, EditFire;
public static WaterRenderer renderer; 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) && return (Submarine.RectContains(WorldRect, position) &&
!Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -8), position)); !Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -8), position));
} }
@@ -228,7 +232,7 @@ namespace Barotrauma
//renderer.Dispose(); //renderer.Dispose();
entityGrid.RemoveEntity(this); if (entityGrid!=null) entityGrid.RemoveEntity(this);
hullList.Remove(this); hullList.Remove(this);
} }
@@ -371,6 +375,8 @@ namespace Barotrauma
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
{ {
if (!ShowHulls && !GameMain.DebugDraw) return;
if (!editing && !GameMain.DebugDraw) return; if (!editing && !GameMain.DebugDraw) return;
Rectangle drawRect = Rectangle drawRect =
+13 -3
View File
@@ -152,7 +152,7 @@ namespace Barotrauma
rect.Y += (int)amount.Y; rect.Y += (int)amount.Y;
} }
public virtual bool Contains(Vector2 position) public virtual bool IsMouseOn(Vector2 position)
{ {
return (Submarine.RectContains(WorldRect, position)); return (Submarine.RectContains(WorldRect, position));
} }
@@ -268,7 +268,7 @@ namespace Barotrauma
if (highLightedEntity == null || e.Sprite == null || if (highLightedEntity == null || e.Sprite == null ||
(highLightedEntity.Sprite!=null && e.Sprite.Depth < highLightedEntity.Sprite.Depth)) (highLightedEntity.Sprite!=null && e.Sprite.Depth < highLightedEntity.Sprite.Depth))
{ {
if (e.Contains(position)) highLightedEntity = e; if (e.IsMouseOn(position)) highLightedEntity = e;
} }
e.isSelected = false; e.isSelected = false;
} }
@@ -359,7 +359,7 @@ namespace Barotrauma
//if clicking a selected entity, start moving it //if clicking a selected entity, start moving it
foreach (MapEntity e in selectedList) foreach (MapEntity e in selectedList)
{ {
if (e.Contains(position)) startMovingPos = position; if (e.IsMouseOn(position)) startMovingPos = position;
} }
selectionPos = position; selectionPos = position;
@@ -415,6 +415,16 @@ namespace Barotrauma
} }
else else
{ {
if (editingHUD == null) return;
foreach (GUIComponent component in editingHUD.children)
{
var textBox = component as GUITextBox;
if (textBox == null) continue;
textBox.Deselect();
}
editingHUD = null; editingHUD = null;
} }
} }
+7 -2
View File
@@ -117,8 +117,13 @@ namespace Barotrauma
if (placePosition == Vector2.Zero) if (placePosition == Vector2.Zero)
{ {
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed) Vector2 position = Submarine.MouseToWorldGrid(cam);
placePosition = 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 else
{ {
+21
View File
@@ -269,6 +269,27 @@ namespace Barotrauma
InsertToList(); 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() public override void Remove()
{ {
base.Remove(); base.Remove();
+27 -9
View File
@@ -16,7 +16,7 @@ namespace Barotrauma
{ {
public static List<WayPoint> WayPointList = new List<WayPoint>(); public static List<WayPoint> WayPointList = new List<WayPoint>();
public static bool ShowWayPoints, ShowSpawnPoints; public static bool ShowWayPoints = true, ShowSpawnPoints = true;
private SpawnType spawnType; private SpawnType spawnType;
@@ -75,6 +75,10 @@ namespace Barotrauma
ConnectedGap = gap; ConnectedGap = gap;
} }
public WayPoint(Rectangle rectangle)
: this (rectangle, Submarine.Loaded)
{ }
public WayPoint(Rectangle newRect, Submarine submarine) public WayPoint(Rectangle newRect, Submarine submarine)
: base (submarine) : base (submarine)
{ {
@@ -88,18 +92,18 @@ namespace Barotrauma
currentHull = Hull.FindHull(WorldPosition); 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) public override void Draw(SpriteBatch spriteBatch, bool editing, bool back=true)
{ {
if (!editing && !GameMain.DebugDraw) return; if (!editing && !GameMain.DebugDraw) return;
if (spawnType == SpawnType.Path) if (IsHidden()) return;
{
if (!GameMain.DebugDraw && !ShowWayPoints) return;
}
else
{
if (!GameMain.DebugDraw && !ShowSpawnPoints) return;
}
Rectangle drawRect = Rectangle drawRect =
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height); 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) public override void DrawEditing(SpriteBatch spriteBatch, Camera cam)
{ {
if (editingHUD == null || editingHUD.UserData != this) if (editingHUD == null || editingHUD.UserData != this)
@@ -247,6 +263,8 @@ namespace Barotrauma
foreach (Hull hull in Hull.hullList) foreach (Hull hull in Hull.hullList)
{ {
if (hull.Rect.Height < 150) continue;
WayPoint prevWaypoint = null; WayPoint prevWaypoint = null;
if (hull.Rect.Width<minDist*3.0f) if (hull.Rect.Width<minDist*3.0f)
+31 -13
View File
@@ -33,10 +33,10 @@ namespace Barotrauma
get { return selectedTab; } get { return selectedTab; }
} }
//public string GetSubName() public string GetSubName()
//{ {
// return ((Submarine.Loaded == null) ? "" : Submarine.Loaded.Name); return ((Submarine.Loaded == null) ? "" : Submarine.Loaded.Name);
//} }
private string GetItemCount() private string GetItemCount()
{ {
@@ -57,7 +57,7 @@ namespace Barotrauma
public EditMapScreen() public EditMapScreen()
{ {
cam = new Camera(); cam = new Camera();
cam.Translate(new Vector2(-10.0f, 50.0f)); //cam.Translate(new Vector2(-10.0f, 50.0f));
selectedTab = -1; selectedTab = -1;
@@ -69,10 +69,10 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, 20, 0, 20), "Submarine:", GUI.Style, GUIpanel); var nameBlock =new GUITextBlock(new Rectangle(0, 20, 0, 20), "Submarine:", GUI.Style, GUIpanel);
nameBox = new GUITextBox(new Rectangle(0, 40, 0, 20), GUI.Style, GUIpanel); //nameBox = new GUITextBox(new Rectangle(0, 40, 0, 20), GUI.Style, GUIpanel);
nameBox.OnEnterPressed = ChangeSubName; //nameBox.OnEnterPressed = ChangeSubName;
//nameBlock.TextGetter = GetSubName; nameBlock.TextGetter = GetSubName;
GUIButton button = new GUIButton(new Rectangle(0,70,0,20), "Save", GUI.Style, GUIpanel); GUIButton button = new GUIButton(new Rectangle(0,70,0,20), "Save", GUI.Style, GUIpanel);
button.OnClicked = SaveSub; button.OnClicked = SaveSub;
@@ -162,10 +162,23 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", GUI.Style, GUIpanel); new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", GUI.Style, GUIpanel);
var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), "Waypoints", Alignment.TopLeft, GUIpanel); var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), "Waypoints", Alignment.TopLeft, GUIpanel);
tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return true; }; tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return true; };
tickBox = new GUITickBox(new Rectangle(0, y + 40, 20, 20), "Spawnpoints", Alignment.TopLeft, GUIpanel); tickBox.Selected = true;
tickBox = new GUITickBox(new Rectangle(0, y + 45, 20, 20), "Spawnpoints", Alignment.TopLeft, GUIpanel);
tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return true; }; tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return true; };
tickBox.Selected = true;
tickBox = new GUITickBox(new Rectangle(0, y + 70, 20, 20), "Links", Alignment.TopLeft, GUIpanel);
tickBox.OnSelected = (GUITickBox obj) => { Item.ShowLinks = !Item.ShowLinks; return true; };
tickBox.Selected = true;
tickBox = new GUITickBox(new Rectangle(0, y + 95, 20, 20), "Hulls", Alignment.TopLeft, GUIpanel);
tickBox.OnSelected = (GUITickBox obj) => { Hull.ShowHulls = !Hull.ShowHulls; return true; };
tickBox.Selected = true;
tickBox = new GUITickBox(new Rectangle(0, y + 120, 20, 20), "Gaps", Alignment.TopLeft, GUIpanel);
tickBox.OnSelected = (GUITickBox obj) => { Gap.ShowGaps = !Gap.ShowGaps; return true; };
tickBox.Selected = true;
} }
@@ -186,9 +199,14 @@ namespace Barotrauma
if (Submarine.Loaded != null) if (Submarine.Loaded != null)
{ {
cam.Position = Submarine.Loaded.Position + Submarine.HiddenSubPosition; cam.Position = Submarine.Loaded.Position + Submarine.HiddenSubPosition;
nameBox.Text = Submarine.Loaded.Name; //nameBox.Text = Submarine.Loaded.Name;
} }
//CreateDummyCharacter(); else
{
cam.Position = Submarine.HiddenSubPosition;
}
cam.UpdateTransform();
} }
public override void Deselect() public override void Deselect()
@@ -354,7 +372,7 @@ namespace Barotrauma
MapEntity.UpdateSelecting(cam); MapEntity.UpdateSelecting(cam);
} }
GUIComponent.MouseOn = null;
GUIpanel.Update((float)deltaTime); GUIpanel.Update((float)deltaTime);
if (selectedTab > -1) if (selectedTab > -1)
{ {
+6
View File
@@ -188,6 +188,12 @@ namespace Barotrauma
return (r >= 0 && r <= 1) && (s >= 0 && s <= 1); return (r >= 0 && r <= 1) && (s >= 0 && s <= 1);
} }
public static float LineToPointDistance(Vector2 lineA, Vector2 lineB, Vector2 point)
{
return (float)(Math.Abs((lineB.X-lineA.X)*(lineA.Y - point.Y) - (lineA.X - point.X)*(lineB.Y-lineA.Y)) /
Math.Sqrt(Math.Pow(lineB.X - lineA.X, 2) + Math.Pow(lineB.Y - lineA.Y, 2)));
}
public static bool CircleIntersectsRectangle(Vector2 circlePos, float radius, Rectangle rect) public static bool CircleIntersectsRectangle(Vector2 circlePos, float radius, Rectangle rect)
{ {
Vector2 circleDistance = new Vector2(Math.Abs(circlePos.X - rect.Center.X), Math.Abs(circlePos.Y -rect.Center.Y)); Vector2 circleDistance = new Vector2(Math.Abs(circlePos.X - rect.Center.X), Math.Abs(circlePos.Y -rect.Center.Y));
Binary file not shown.