Entities that are behind other entities can be selected using a listbox that appears when hovering the cursor over them, itemcomponent GUIFrames aren't added to GUIUpdateList in sub editor (unless in character mode)
This commit is contained in:
@@ -147,7 +147,8 @@ namespace Barotrauma
|
||||
scrollBar = new GUIScrollBar(
|
||||
new Rectangle(this.rect.Right - 20, this.rect.Y, 20, this.rect.Height), null, 1.0f, GUI.Style);
|
||||
}
|
||||
|
||||
|
||||
scrollBar.IsHorizontal = isHorizontal;
|
||||
|
||||
frame = new GUIFrame(Rectangle.Empty, style, this);
|
||||
if (style != null) style.Apply(frame, this);
|
||||
|
||||
@@ -25,6 +25,12 @@ namespace Barotrauma
|
||||
public bool IsHorizontal
|
||||
{
|
||||
get { return isHorizontal; }
|
||||
set
|
||||
{
|
||||
if (isHorizontal == value) return;
|
||||
isHorizontal = value;
|
||||
UpdateRect();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace Barotrauma.Items.Components
|
||||
Item targetItem;
|
||||
if ((targetStructure = (targetBody.UserData as Structure)) != null)
|
||||
{
|
||||
if (!fixableEntities.Contains(targetStructure.Name)) return;
|
||||
if (!fixableEntities.Contains("structure") && !fixableEntities.Contains(targetStructure.Name)) return;
|
||||
if (targetStructure.IsPlatform) return;
|
||||
|
||||
int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition));
|
||||
|
||||
@@ -1145,23 +1145,32 @@ namespace Barotrauma
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (condition <= 0.0f)
|
||||
{
|
||||
FixRequirement.AddToGUIUpdateList();
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasInGameEditableProperties)
|
||||
if (Screen.Selected is EditMapScreen)
|
||||
{
|
||||
if (editingHUD != null) editingHUD.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
else
|
||||
{
|
||||
ic.AddToGUIUpdateList();
|
||||
if (HasInGameEditableProperties)
|
||||
{
|
||||
if (editingHUD != null) editingHUD.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
|
||||
if (Screen.Selected is EditMapScreen && editingHUD != null) editingHUD.AddToGUIUpdateList();
|
||||
if (Character.Controlled!=null && Character.Controlled.SelectedConstruction == this)
|
||||
{
|
||||
|
||||
if (condition <= 0.0f)
|
||||
{
|
||||
FixRequirement.AddToGUIUpdateList();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
ic.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UpdateHUD(Camera cam, Character character)
|
||||
|
||||
@@ -80,6 +80,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Gap";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SelectableInEditor
|
||||
{
|
||||
get
|
||||
|
||||
@@ -26,7 +26,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
private static List<MapEntity> copiedList = new List<MapEntity>();
|
||||
|
||||
|
||||
private static List<MapEntity> highlightedList = new List<MapEntity>();
|
||||
|
||||
private static float highlightTimer;
|
||||
|
||||
private static GUIListBox highlightedListBox;
|
||||
public static GUIListBox HighlightedListBox
|
||||
{
|
||||
get { return highlightedListBox; }
|
||||
}
|
||||
|
||||
|
||||
protected static GUIComponent editingHUD;
|
||||
public static GUIComponent EditingHUD
|
||||
{
|
||||
@@ -371,7 +382,7 @@ namespace Barotrauma
|
||||
public virtual void Update(Camera cam, float deltaTime) { }
|
||||
|
||||
/// <summary>
|
||||
/// Update the selection logic in editmap-screen
|
||||
/// Update the selection logic in submarine editor
|
||||
/// </summary>
|
||||
public static void UpdateSelecting(Camera cam)
|
||||
{
|
||||
@@ -392,7 +403,15 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow) return;
|
||||
if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow)
|
||||
{
|
||||
if (highlightedListBox == null ||
|
||||
(GUIComponent.MouseOn != highlightedListBox && !highlightedListBox.IsParentOf(GUIComponent.MouseOn)))
|
||||
{
|
||||
UpdateHighlightedListBox(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (MapEntityPrefab.Selected != null)
|
||||
{
|
||||
@@ -445,19 +464,62 @@ namespace Barotrauma
|
||||
|
||||
if (startMovingPos == Vector2.Zero)
|
||||
{
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
List<MapEntity> highlightedEntities = new List<MapEntity>();
|
||||
if (highlightedListBox != null && highlightedListBox.IsParentOf(GUIComponent.MouseOn))
|
||||
{
|
||||
if (!e.SelectableInEditor) continue;
|
||||
|
||||
if (highLightedEntity == null || e.Sprite == null ||
|
||||
(highLightedEntity.Sprite != null && e.Sprite.Depth < highLightedEntity.Sprite.Depth))
|
||||
highLightedEntity = GUIComponent.MouseOn.UserData as MapEntity;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
if (e.IsMouseOn(position)) highLightedEntity = e;
|
||||
if (!e.SelectableInEditor) continue;
|
||||
|
||||
if (e.IsMouseOn(position))
|
||||
{
|
||||
int i = 0;
|
||||
while (i < highlightedEntities.Count &&
|
||||
e.Sprite != null &&
|
||||
(highlightedEntities[i].Sprite == null || highlightedEntities[i].Sprite.Depth < e.Sprite.Depth))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
highlightedEntities.Insert(i, e);
|
||||
|
||||
if (i == 0) highLightedEntity = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerInput.MouseSpeed.LengthSquared() > 10)
|
||||
{
|
||||
highlightTimer = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool mouseNearHighlightBox = false;
|
||||
|
||||
if (highlightedListBox != null)
|
||||
{
|
||||
Rectangle expandedRect = highlightedListBox.Rect;
|
||||
expandedRect.Inflate(20, 20);
|
||||
mouseNearHighlightBox = expandedRect.Contains(PlayerInput.MousePosition);
|
||||
if (!mouseNearHighlightBox) highlightedListBox = null;
|
||||
}
|
||||
|
||||
highlightTimer += (float)Timing.Step;
|
||||
if (highlightTimer > 1.0f)
|
||||
{
|
||||
if (!mouseNearHighlightBox)
|
||||
{
|
||||
UpdateHighlightedListBox(highlightedEntities);
|
||||
highlightTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (highLightedEntity != null) highLightedEntity.isHighlighted = true;
|
||||
|
||||
}
|
||||
|
||||
//started moving selected entities
|
||||
@@ -505,11 +567,6 @@ namespace Barotrauma
|
||||
if (highLightedEntity != null) newSelection.Add(highLightedEntity);
|
||||
}
|
||||
|
||||
foreach (MapEntity e in newSelection)
|
||||
{
|
||||
e.isHighlighted = true;
|
||||
}
|
||||
|
||||
if (PlayerInput.LeftButtonReleased())
|
||||
{
|
||||
if (PlayerInput.KeyDown(Keys.LeftControl) ||
|
||||
@@ -517,14 +574,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (MapEntity e in newSelection)
|
||||
{
|
||||
bool alreadySelected = false;
|
||||
|
||||
foreach (MapEntity e2 in selectedList)
|
||||
{
|
||||
if (e.ID == e2.ID) alreadySelected = true;
|
||||
}
|
||||
|
||||
if (alreadySelected)
|
||||
if (selectedList.Contains(e))
|
||||
selectedList.Remove(e);
|
||||
else
|
||||
selectedList.Add(e);
|
||||
@@ -562,7 +612,8 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
if (PlayerInput.LeftButtonHeld() &&
|
||||
PlayerInput.KeyUp(Keys.Space))
|
||||
PlayerInput.KeyUp(Keys.Space) &&
|
||||
(highlightedListBox == null || (GUIComponent.MouseOn != highlightedListBox && !highlightedListBox.IsParentOf(GUIComponent.MouseOn))))
|
||||
{
|
||||
//if clicking a selected entity, start moving it
|
||||
foreach (MapEntity e in selectedList)
|
||||
@@ -575,6 +626,57 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateHighlightedListBox(List<MapEntity> highlightedEntities)
|
||||
{
|
||||
if (highlightedEntities == null || highlightedEntities.Count < 2)
|
||||
{
|
||||
highlightedListBox = null;
|
||||
return;
|
||||
}
|
||||
if (highlightedListBox != null)
|
||||
{
|
||||
if (GUIComponent.MouseOn == highlightedListBox || highlightedListBox.IsParentOf(GUIComponent.MouseOn)) return;
|
||||
if (highlightedEntities.SequenceEqual(highlightedList)) return;
|
||||
}
|
||||
|
||||
highlightedList = highlightedEntities;
|
||||
|
||||
highlightedListBox = new GUIListBox(
|
||||
new Rectangle((int)PlayerInput.MousePosition.X+15, (int)PlayerInput.MousePosition.Y+15, 150, highlightedEntities.Count * 15),
|
||||
null, Alignment.TopLeft, GUI.Style, null, false);
|
||||
|
||||
highlightedListBox.Color = Color.Black * 0.6f;
|
||||
|
||||
foreach (MapEntity entity in highlightedEntities)
|
||||
{
|
||||
var textBlock = new GUITextBlock(
|
||||
new Rectangle(0,0,0,15),
|
||||
ToolBox.LimitString(entity.Name, GUI.SmallFont, 140), GUI.Style, highlightedListBox, GUI.SmallFont);
|
||||
|
||||
textBlock.UserData = entity;
|
||||
}
|
||||
|
||||
highlightedListBox.OnSelected = (GUIComponent component, object obj) =>
|
||||
{
|
||||
MapEntity entity = obj as MapEntity;
|
||||
|
||||
if (PlayerInput.KeyDown(Keys.LeftControl) ||
|
||||
PlayerInput.KeyDown(Keys.RightControl))
|
||||
{
|
||||
if (selectedList.Contains(entity))
|
||||
selectedList.Remove(entity);
|
||||
else
|
||||
selectedList.Add(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectEntity(entity);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Draw the "selection rectangle" and outlines of entities that are being dragged (if any)
|
||||
@@ -612,6 +714,8 @@ namespace Barotrauma
|
||||
|
||||
public static void UpdateEditor(Camera cam)
|
||||
{
|
||||
if (highlightedListBox != null) highlightedListBox.Update((float)Timing.Step);
|
||||
|
||||
if (selectedList.Count == 1)
|
||||
{
|
||||
selectedList[0].UpdateEditing(cam);
|
||||
@@ -621,19 +725,21 @@ namespace Barotrauma
|
||||
selectedList[0].UpdateResizing(cam);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (editingHUD != null)
|
||||
{
|
||||
if (editingHUD == null) return;
|
||||
|
||||
foreach (GUIComponent component in editingHUD.children)
|
||||
if (selectedList.Count == 0 || editingHUD.UserData != selectedList[0])
|
||||
{
|
||||
var textBox = component as GUITextBox;
|
||||
if (textBox == null) continue;
|
||||
foreach (GUIComponent component in editingHUD.children)
|
||||
{
|
||||
var textBox = component as GUITextBox;
|
||||
if (textBox == null) continue;
|
||||
|
||||
textBox.Deselect();
|
||||
textBox.Deselect();
|
||||
}
|
||||
|
||||
editingHUD = null;
|
||||
}
|
||||
|
||||
editingHUD = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,6 +754,11 @@ namespace Barotrauma
|
||||
selectedList[0].DrawResizing(spriteBatch, cam);
|
||||
}
|
||||
}
|
||||
|
||||
if (highlightedListBox != null)
|
||||
{
|
||||
highlightedListBox.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeselectAll()
|
||||
@@ -662,8 +773,7 @@ namespace Barotrauma
|
||||
|
||||
selectedList.Add(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// copies a list of entities to the "clipboard" (copiedList)
|
||||
/// </summary>
|
||||
@@ -697,7 +807,7 @@ namespace Barotrauma
|
||||
|
||||
public virtual void AddToGUIUpdateList()
|
||||
{
|
||||
if (editingHUD != null) editingHUD.AddToGUIUpdateList();
|
||||
if (editingHUD != null && editingHUD.UserData == this) editingHUD.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public virtual void UpdateEditing(Camera cam) { }
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Barotrauma
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "structure"; }
|
||||
get { return prefab.Name; }
|
||||
}
|
||||
|
||||
public bool HasBody
|
||||
|
||||
@@ -54,13 +54,13 @@ namespace Barotrauma
|
||||
set { spawnType = value; }
|
||||
}
|
||||
|
||||
//public override string Name
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return spawnType == SpawnType.Path ? "WayPoint" : "SpawnPoint";
|
||||
// }
|
||||
//}
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return spawnType == SpawnType.Path ? "WayPoint" : "SpawnPoint";
|
||||
}
|
||||
}
|
||||
|
||||
public string[] IdCardTags
|
||||
{
|
||||
|
||||
@@ -858,6 +858,10 @@ namespace Barotrauma
|
||||
{
|
||||
MapEntity.SelectedList[0].AddToGUIUpdateList();
|
||||
}
|
||||
if (MapEntity.HighlightedListBox != null)
|
||||
{
|
||||
MapEntity.HighlightedListBox.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
leftPanel.AddToGUIUpdateList();
|
||||
topPanel.AddToGUIUpdateList();
|
||||
@@ -899,10 +903,7 @@ namespace Barotrauma
|
||||
|
||||
hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull);
|
||||
|
||||
if (GUIComponent.MouseOn == null)
|
||||
{
|
||||
cam.MoveCamera((float)deltaTime);
|
||||
}
|
||||
cam.MoveCamera((float)deltaTime);
|
||||
|
||||
if (characterMode || wiringMode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user