Separated waypoint edit/update methods, fixed items/structures being immediately placed when selecting them in the editor, fixed GUIListBox children ovrlapping with the scrollbar
This commit is contained in:
@@ -103,15 +103,6 @@ namespace Barotrauma
|
|||||||
get { return scrollBarEnabled; }
|
get { return scrollBarEnabled; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
if (!scrollBarEnabled && scrollBarHidden) ShowScrollBar();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (scrollBarEnabled && !scrollBarHidden) HideScrollBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollBarEnabled = value;
|
scrollBarEnabled = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -337,14 +328,24 @@ namespace Barotrauma
|
|||||||
Math.Max(Math.Min((float)rect.Width / (float)totalSize, 1.0f), 5.0f / rect.Width) :
|
Math.Max(Math.Min((float)rect.Width / (float)totalSize, 1.0f), 5.0f / rect.Width) :
|
||||||
Math.Max(Math.Min((float)rect.Height / (float)totalSize, 1.0f), 5.0f / rect.Height);
|
Math.Max(Math.Min((float)rect.Height / (float)totalSize, 1.0f), 5.0f / rect.Height);
|
||||||
|
|
||||||
if (scrollBar.BarSize < 1.0f && scrollBarHidden) ShowScrollBar();
|
scrollBarHidden = scrollBar.BarSize >= 1.0f;
|
||||||
if (scrollBar.BarSize >= 1.0f && !scrollBarHidden) HideScrollBar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddChild(GUIComponent child)
|
public override void AddChild(GUIComponent child)
|
||||||
{
|
{
|
||||||
|
//temporarily reduce the size of the rect to prevent the child from expanding over the scrollbar
|
||||||
|
if (scrollBar.IsHorizontal)
|
||||||
|
rect.Height -= scrollBar.Rect.Height;
|
||||||
|
else
|
||||||
|
rect.Width -= scrollBar.Rect.Width;
|
||||||
|
|
||||||
base.AddChild(child);
|
base.AddChild(child);
|
||||||
|
|
||||||
|
if (scrollBar.IsHorizontal)
|
||||||
|
rect.Height += scrollBar.Rect.Height;
|
||||||
|
else
|
||||||
|
rect.Width += scrollBar.Rect.Width;
|
||||||
|
|
||||||
//float oldScroll = scrollBar.BarScroll;
|
//float oldScroll = scrollBar.BarScroll;
|
||||||
//float oldSize = scrollBar.BarSize;
|
//float oldSize = scrollBar.BarSize;
|
||||||
UpdateScrollBarSize();
|
UpdateScrollBarSize();
|
||||||
@@ -373,25 +374,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
UpdateScrollBarSize();
|
UpdateScrollBarSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowScrollBar()
|
|
||||||
{
|
|
||||||
if (scrollBarHidden && !scrollBar.IsHorizontal) Rect = new Rectangle(rect.X, rect.Y, rect.Width - scrollBar.Rect.Width, rect.Height);
|
|
||||||
scrollBarHidden = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HideScrollBar()
|
|
||||||
{
|
|
||||||
if (!scrollBarHidden && !scrollBar.IsHorizontal) Rect = new Rectangle(rect.X, rect.Y, rect.Width + scrollBar.Rect.Width, rect.Height);
|
|
||||||
scrollBarHidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Draw(SpriteBatch spriteBatch)
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
if (!Visible) return;
|
if (!Visible) return;
|
||||||
|
|
||||||
base.Draw(spriteBatch);
|
//base.Draw(spriteBatch);
|
||||||
|
|
||||||
frame.Draw(spriteBatch);
|
frame.Draw(spriteBatch);
|
||||||
//GUI.DrawRectangle(spriteBatch, rect, color*alpha, true);
|
//GUI.DrawRectangle(spriteBatch, rect, color*alpha, true);
|
||||||
|
|||||||
@@ -171,32 +171,37 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawEditing(SpriteBatch spriteBatch, Camera cam)
|
public override void UpdateEditing(Camera cam)
|
||||||
{
|
{
|
||||||
if (editingHUD == null || editingHUD.UserData != this)
|
if (editingHUD == null || editingHUD.UserData != this)
|
||||||
{
|
{
|
||||||
editingHUD = CreateEditingHUD();
|
editingHUD = CreateEditingHUD();
|
||||||
}
|
}
|
||||||
|
|
||||||
editingHUD.Update((float)Timing.Step);
|
editingHUD.Update((float)Timing.Step);
|
||||||
editingHUD.Draw(spriteBatch);
|
|
||||||
|
|
||||||
if (!PlayerInput.LeftButtonClicked()) return;
|
if (PlayerInput.LeftButtonClicked())
|
||||||
|
{
|
||||||
|
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
|
|
||||||
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
foreach (MapEntity e in mapEntityList)
|
||||||
|
{
|
||||||
|
if (e.GetType() != typeof(WayPoint)) continue;
|
||||||
|
if (e == this) continue;
|
||||||
|
|
||||||
foreach (MapEntity e in mapEntityList)
|
if (!Submarine.RectContains(e.Rect, position)) continue;
|
||||||
{
|
|
||||||
if (e.GetType()!=typeof(WayPoint)) continue;
|
|
||||||
if (e == this) continue;
|
|
||||||
|
|
||||||
if (!Submarine.RectContains(e.Rect, position)) continue;
|
linkedTo.Add(e);
|
||||||
|
e.linkedTo.Add(this);
|
||||||
linkedTo.Add(e);
|
}
|
||||||
e.linkedTo.Add(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void DrawEditing(SpriteBatch spriteBatch, Camera cam)
|
||||||
|
{
|
||||||
|
if (editingHUD != null) editingHUD.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
private bool ChangeSpawnType(GUIButton button, object obj)
|
private bool ChangeSpawnType(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
GUITextBlock spawnTypeText = button.Parent as GUITextBlock;
|
GUITextBlock spawnTypeText = button.Parent as GUITextBlock;
|
||||||
|
|||||||
@@ -835,6 +835,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||||
|
{
|
||||||
|
me.IsHighlighted = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (dummyCharacter.SelectedConstruction==null)
|
if (dummyCharacter.SelectedConstruction==null)
|
||||||
{
|
{
|
||||||
Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition);
|
Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition);
|
||||||
@@ -861,6 +866,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUIComponent.MouseOn = null;
|
GUIComponent.MouseOn = null;
|
||||||
|
|
||||||
|
if (!characterMode && !wiringMode)
|
||||||
|
{
|
||||||
|
if (MapEntityPrefab.Selected != null) MapEntityPrefab.Selected.UpdatePlacing(cam);
|
||||||
|
|
||||||
|
MapEntity.UpdateEditor(cam);
|
||||||
|
}
|
||||||
|
|
||||||
leftPanel.Update((float)deltaTime);
|
leftPanel.Update((float)deltaTime);
|
||||||
topPanel.Update((float)deltaTime);
|
topPanel.Update((float)deltaTime);
|
||||||
|
|
||||||
@@ -872,7 +884,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
wiringToolPanel.Update((float)deltaTime);
|
wiringToolPanel.Update((float)deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadFrame!=null)
|
if (loadFrame!=null)
|
||||||
{
|
{
|
||||||
loadFrame.Update((float)deltaTime);
|
loadFrame.Update((float)deltaTime);
|
||||||
@@ -888,20 +900,9 @@ namespace Barotrauma
|
|||||||
if (PlayerInput.RightButtonClicked()) selectedTab = -1;
|
if (PlayerInput.RightButtonClicked()) selectedTab = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!characterMode && !wiringMode)
|
|
||||||
{
|
|
||||||
if (MapEntityPrefab.Selected != null) MapEntityPrefab.Selected.UpdatePlacing(cam);
|
|
||||||
|
|
||||||
MapEntity.UpdateEditor(cam);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((characterMode || wiringMode) && dummyCharacter != null)
|
if ((characterMode || wiringMode) && dummyCharacter != null)
|
||||||
{
|
{
|
||||||
foreach (MapEntity me in MapEntity.mapEntityList)
|
|
||||||
{
|
|
||||||
me.IsHighlighted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dummyCharacter.AnimController.FindHull(dummyCharacter.CursorWorldPosition, false);
|
dummyCharacter.AnimController.FindHull(dummyCharacter.CursorWorldPosition, false);
|
||||||
|
|
||||||
foreach (Item item in dummyCharacter.SelectedItems)
|
foreach (Item item in dummyCharacter.SelectedItems)
|
||||||
|
|||||||
Reference in New Issue
Block a user