diff --git a/Subsurface/Source/Characters/AI/CrewCommander.cs b/Subsurface/Source/Characters/AI/CrewCommander.cs index 89b172e15..995f1ebe0 100644 --- a/Subsurface/Source/Characters/AI/CrewCommander.cs +++ b/Subsurface/Source/Characters/AI/CrewCommander.cs @@ -57,7 +57,7 @@ namespace Barotrauma frame = new GUIFrame(Rectangle.Empty, Color.Black * 0.6f); frame.Padding = new Vector4(200.0f, 100.0f, 200.0f, 100.0f); - GUIButton closeButton = new GUIButton(new Rectangle(0, 50, 100, 20), "Close", GUI.Style, frame); + GUIButton closeButton = new GUIButton(new Rectangle(0, 50, 100, 20), "Close", Alignment.BottomCenter, GUI.Style, frame); closeButton.OnClicked = (GUIButton button, object userData) => { ToggleGUIFrame(); diff --git a/Subsurface/Source/GUI/GUIListBox.cs b/Subsurface/Source/GUI/GUIListBox.cs index d269010a5..c3717b7e5 100644 --- a/Subsurface/Source/GUI/GUIListBox.cs +++ b/Subsurface/Source/GUI/GUIListBox.cs @@ -177,7 +177,7 @@ namespace Barotrauma base.Update(deltaTime); - scrollBar.Update(deltaTime); + if (scrollBarEnabled && !scrollBarHidden) scrollBar.Update(deltaTime); if ((MouseOn == this || MouseOn == scrollBar || IsParentOf(MouseOn)) && PlayerInput.ScrollWheelSpeed != 0) { diff --git a/Subsurface/Source/GameSession/CrewManager.cs b/Subsurface/Source/GameSession/CrewManager.cs index 439e7e921..fe3ec51d4 100644 --- a/Subsurface/Source/GameSession/CrewManager.cs +++ b/Subsurface/Source/GameSession/CrewManager.cs @@ -98,7 +98,8 @@ namespace Barotrauma img.Scale = 30.0f / img.SourceRect.Width; img.Color = order.Color; img.CanBeFocused = false; - img.ToolTip ="Order: "+ order.Name; + + orderListBox.children[characterIndex].ToolTip = "Order: " + order.Name; } public bool SelectCharacterOrder(GUIComponent component, object selection) diff --git a/Subsurface/Source/Items/Components/Power/PowerContainer.cs b/Subsurface/Source/Items/Components/Power/PowerContainer.cs index cb330400c..858f51e74 100644 --- a/Subsurface/Source/Items/Components/Power/PowerContainer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerContainer.cs @@ -186,12 +186,12 @@ namespace Barotrauma.Items.Components base.Draw(spriteBatch); GUI.DrawRectangle(spriteBatch, - new Vector2(item.Rect.X + item.Rect.Width / 2 - 4, -item.Rect.Y + 9), + new Vector2(item.DrawPosition.X- 4, -item.DrawPosition.Y), new Vector2(8, 22), Color.Black); if (charge > 0) GUI.DrawRectangle(spriteBatch, - new Vector2(item.Rect.X + item.Rect.Width / 2 - 3, -item.Rect.Y + 10 + (20.0f * (1.0f - charge / capacity))), + new Vector2(item.DrawPosition.X - 3, -item.DrawPosition.Y + 1 + (20.0f * (1.0f - charge / capacity))), new Vector2(6, 20 * (charge / capacity)), Color.Green, true); } diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index d9ef618a6..727ae9e50 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -1023,6 +1023,9 @@ namespace Barotrauma { picked = true; ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker); + + GUIComponent.MouseOn = null; + if (ic.CanBeSelected) selected = true; } } diff --git a/Subsurface/Source/Map/Gap.cs b/Subsurface/Source/Map/Gap.cs index 10f0f933b..210a25cb7 100644 --- a/Subsurface/Source/Map/Gap.cs +++ b/Subsurface/Source/Map/Gap.cs @@ -560,7 +560,9 @@ namespace Barotrauma { XElement element = new XElement("Gap"); - element.Add(new XAttribute("ID", ID)); + element.Add( + new XAttribute("ID", ID), + new XAttribute("horizontal", isHorizontal ? "true" : "false")); element.Add(new XAttribute("rect", (int)(rect.X - Submarine.HiddenSubPosition.X) + "," + @@ -608,7 +610,15 @@ namespace Barotrauma int.Parse(element.Attribute("height").Value)); } - Gap g = new Gap(rect, submarine); + bool isHorizontal = rect.Height > rect.Width; + + var horizontalAttribute = element.Attribute("horizontal"); + if (horizontalAttribute!=null) + { + isHorizontal = horizontalAttribute.Value.ToString() == "true"; + } + + Gap g = new Gap(rect, isHorizontal, submarine); g.ID = (ushort)int.Parse(element.Attribute("ID").Value); g.linkedToID = new List(); diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index 574a5355d..ff9e078ba 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -178,6 +178,34 @@ namespace Barotrauma InsertToList(); } + public static Rectangle GetBorders() + { + if (!hullList.Any()) return Rectangle.Empty; + + Rectangle rect = hullList[0].rect; + + foreach (Hull hull in hullList) + { + if (hull.Rect.X < rect.X) + { + rect.Width += rect.X - hull.rect.X; + rect.X = hull.rect.X; + + } + if (hull.rect.Right > rect.Right) rect.Width = hull.rect.Right - rect.X; + + if (hull.rect.Y > rect.Y) + { + rect.Height += hull.rect.Y - rect.Y; + + rect.Y = hull.rect.Y; + } + if (hull.rect.Y - hull.rect.Height < rect.Y - rect.Height) rect.Height = rect.Y - (hull.rect.Y - hull.rect.Height); + } + + return rect; + } + public static void GenerateEntityGrid() { entityGrid = new EntityGrid(Submarine.Borders, 200.0f); diff --git a/Subsurface/Source/Map/MapEntityPrefab.cs b/Subsurface/Source/Map/MapEntityPrefab.cs index 8f981c5ff..c026f2eda 100644 --- a/Subsurface/Source/Map/MapEntityPrefab.cs +++ b/Subsurface/Source/Map/MapEntityPrefab.cs @@ -147,6 +147,11 @@ namespace Barotrauma newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X); newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y); + if (Submarine.Loaded != null) + { + newRect.Location -= Submarine.Loaded.Position.ToPoint(); + } + if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released) { object[] lobject = new object[] { this, newRect }; diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index ec56edaf5..ece4518c4 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -21,6 +21,8 @@ namespace Barotrauma public float damage; public Gap gap; + public int GapIndex; + public float lastSentDamage; public bool isHighLighted; @@ -613,9 +615,17 @@ namespace Barotrauma { if (sections[i].damage == 0.0f) continue; - element.Add(new XElement("section", - new XAttribute("i", i), - new XAttribute("damage", sections[i].damage))); + var sectionElement = + new XElement("section", + new XAttribute("i", i), + new XAttribute("damage", sections[i].damage)); + + if (sections[i].gap!=null) + { + sectionElement.Add(new XAttribute("gap", sections[i].gap.ID)); + } + + element.Add(sectionElement); } doc.Root.Add(element); @@ -660,15 +670,27 @@ namespace Barotrauma switch (subElement.Name.ToString()) { case "section": - if (subElement.Attribute("i") == null) continue; + int index = ToolBox.GetAttributeInt(subElement, "i", -1); + if (index == -1) continue; - s.sections[int.Parse(subElement.Attribute("i").Value)].damage = + s.sections[index].damage = ToolBox.GetAttributeFloat(subElement, "damage", 0.0f); + s.sections[index].GapIndex = ToolBox.GetAttributeInt(subElement, "gap", -1); + break; } } + } + public override void OnMapLoaded() + { + foreach (WallSection s in sections) + { + if (s.GapIndex == -1) continue; + + s.gap = FindEntityByID((ushort)s.GapIndex) as Gap; + } } public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data) diff --git a/Subsurface/Source/Map/WayPoint.cs b/Subsurface/Source/Map/WayPoint.cs index 58b28cadf..716676b6f 100644 --- a/Subsurface/Source/Map/WayPoint.cs +++ b/Subsurface/Source/Map/WayPoint.cs @@ -328,10 +328,31 @@ namespace Barotrauma float outSideWaypointInterval = 200.0f; int outsideWaypointDist = 100; - Rectangle borders = new Rectangle(Submarine.Borders.X - outsideWaypointDist, Submarine.Borders.Y + outsideWaypointDist, - Submarine.Borders.Width + outsideWaypointDist*2, Submarine.Borders.Height+outsideWaypointDist*2); + Rectangle borders = Hull.GetBorders(); + borders.X -= outsideWaypointDist; + borders.Y += outsideWaypointDist; + + borders.Width += outsideWaypointDist * 2; + borders.Height += outsideWaypointDist * 2; + + borders.Location -= Submarine.HiddenSubPosition.ToPoint(); + + if (borders.Width <= outSideWaypointInterval*2) + { + borders.Inflate(outSideWaypointInterval*2 - borders.Width, 0); + } + + if (borders.Height <= outSideWaypointInterval * 2) + { + int inflateAmount = (int)(outSideWaypointInterval * 2) - borders.Height; + borders.Y += inflateAmount / 2; + + borders.Height += inflateAmount; + } + WayPoint[,] cornerWaypoint = new WayPoint[2,2]; + for (int i = 0; i<2; i++) { for (float x = borders.X + outSideWaypointInterval; x < borders.Right - outSideWaypointInterval; x += outSideWaypointInterval) @@ -351,7 +372,7 @@ namespace Barotrauma cornerWaypoint[i, 1] = WayPoint.WayPointList[WayPointList.Count - 1]; } - + for (int i = 0; i < 2; i++) { WayPoint wayPoint = null; diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index 2eae21d93..cd1212b51 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -409,7 +409,7 @@ namespace Barotrauma if (dummyCharacter.SelectedConstruction==null) { - Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(cam.ScreenToWorld(PlayerInput.MousePosition)); + Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition); foreach (Limb limb in dummyCharacter.AnimController.Limbs) { limb.body.SetTransform(mouseSimPos, 0.0f); @@ -473,7 +473,7 @@ namespace Barotrauma { if (dummyCharacter != null) { - dummyCharacter.AnimController.FindHull(); + dummyCharacter.AnimController.FindHull(dummyCharacter.CursorWorldPosition, false); foreach (Item item in dummyCharacter.SelectedItems) { diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 3c7a7d005..d9f989b89 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ