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

View File

@@ -55,7 +55,19 @@ namespace Barotrauma.Items.Components
linkedGap = e as Gap;
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.Open = openState;
item.linkedTo.Add(linkedGap);
@@ -341,7 +353,7 @@ namespace Barotrauma.Items.Components
doorSprite.Remove();
convexHull.Remove();
if (convexHull!=null) convexHull.Remove();
if (convexHull2 != null) convexHull2.Remove();
}

View File

@@ -173,18 +173,19 @@ namespace Barotrauma.Items.Components
item.FindHull();
Vector2 position = item.Position;
position.X = MathUtils.Round(item.Position.X, nodeDistance);
if (item.CurrentHull == null)
{
position.Y = MathUtils.Round(item.Position.Y, nodeDistance);
}
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;
}
//Vector2 position = item.Position;
//position.X = MathUtils.Round(item.Position.X, nodeDistance);
//if (item.CurrentHull == null)
//{
// position.Y = MathUtils.Round(item.Position.Y, nodeDistance);
//}
//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;
//}
newNodePos = RoundNode(item.Position, item.CurrentHull)-Submarine.HiddenSubPosition;
@@ -249,16 +250,26 @@ namespace Barotrauma.Items.Components
private Vector2 RoundNode(Vector2 position, Hull hull)
{
position.X = MathUtils.Round(position.X, nodeDistance);
if (hull == null)
if (Screen.Selected == GameMain.EditMapScreen)
{
position.Y = MathUtils.Round(position.Y, nodeDistance);
//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.Y -= hull.Rect.Y - hull.Rect.Height;
position.Y = Math.Max(MathUtils.Round(position.Y, nodeDistance), heightFromFloor);
position.Y += hull.Rect.Y -hull.Rect.Height;
position.X = MathUtils.Round(position.X, nodeDistance);
if (hull == null)
{
position.Y = MathUtils.Round(position.Y, nodeDistance);
}
else
{
position.Y -= hull.Rect.Y - hull.Rect.Height;
position.Y = Math.Max(MathUtils.Round(position.Y, nodeDistance), heightFromFloor);
position.Y += hull.Rect.Y -hull.Rect.Height;
}
}
return position;
@@ -322,11 +333,13 @@ namespace Barotrauma.Items.Components
for (int i = 0; i < Nodes.Count; 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;
GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-3, -3), new Vector2(6, 6), item.Color, true, 0.0f);
if (IsActive) continue;
if (GUIComponent.MouseOn != null ||
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)
{
if (item.Submarine!=null)
if (Submarine.Loaded!=null)
{
start += item.Submarine.DrawPosition+Submarine.HiddenSubPosition;
end += item.Submarine.DrawPosition+Submarine.HiddenSubPosition;
start += Submarine.Loaded.DrawPosition + Submarine.HiddenSubPosition;
end += Submarine.Loaded.DrawPosition + Submarine.HiddenSubPosition;
}
start.Y = -start.Y;

View File

@@ -29,6 +29,8 @@ namespace Barotrauma
public static ItemSpawner Spawner = new ItemSpawner();
public static ItemRemover Remover = new ItemRemover();
public static bool ShowLinks = true;
private List<string> tags;
public Hull CurrentHull;
@@ -698,6 +700,8 @@ namespace Barotrauma
Color.Green);
}
if (!ShowLinks) return;
foreach (MapEntity e in linkedTo)
{
GUI.DrawLine(spriteBatch,
@@ -727,7 +731,7 @@ namespace Barotrauma
{
if (entity == this || !entity.IsHighlighted) continue;
if (linkedTo.Contains(entity)) continue;
if (!entity.Contains(position)) continue;
if (!entity.IsMouseOn(position)) continue;
linkedTo.Add(entity);
if (entity.IsLinkable && entity.linkedTo != null) entity.linkedTo.Add(this);
@@ -790,7 +794,7 @@ namespace Barotrauma
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;
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault<Editable>();
@@ -905,11 +909,9 @@ namespace Barotrauma
transformedTrigger.Y - transformedTrigger.Height / 2.0f);
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;
dist = MathHelper.Min(Math.Abs(triggerCenter.X - displayPickPos.X), Math.Abs(triggerCenter.Y - displayPickPos.Y));
dist = ConvertUnits.ToSimUnits(dist);
if (closest == null || dist < closestDist)
{
closest = item;
@@ -993,7 +995,8 @@ namespace Barotrauma
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)) ||
(ic.CanBeSelected && selectHit && ic.Select(picker)))
{
@@ -1133,7 +1136,7 @@ namespace Barotrauma
private bool EnterProperty(GUITextBox textBox, string text)
{
textBox.Color = Color.White;
textBox.Color = Color.DarkGreen;
var objectProperty = textBox.UserData as ObjectProperty;
if (objectProperty == null) return false;

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);
//constructor.Invoke(lobject);
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();
placePosition = Vector2.Zero;