From 278371638e3c706e931dd7a5adfa44078278cd52 Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 24 Jan 2016 21:28:27 +0200 Subject: [PATCH] - Fixed structure-gap links not being saved - Saving gap orientation - Waypoint generation works with small hulls and even if SubBody doesn't exist - Fixed charactermode when a editing mid-round - Fixed powercontainer charge progressbar position --- .../Source/Characters/AI/CrewCommander.cs | 2 +- Subsurface/Source/GUI/GUIListBox.cs | 2 +- Subsurface/Source/GameSession/CrewManager.cs | 3 +- .../Items/Components/Power/PowerContainer.cs | 4 +-- Subsurface/Source/Items/Item.cs | 3 ++ Subsurface/Source/Map/Gap.cs | 14 ++++++-- Subsurface/Source/Map/Hull.cs | 28 +++++++++++++++ Subsurface/Source/Map/MapEntityPrefab.cs | 5 +++ Subsurface/Source/Map/Structure.cs | 32 +++++++++++++++--- Subsurface/Source/Map/WayPoint.cs | 27 +++++++++++++-- Subsurface/Source/Screens/EditMapScreen.cs | 4 +-- Subsurface_Solution.v12.suo | Bin 835072 -> 835072 bytes 12 files changed, 107 insertions(+), 17 deletions(-) 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 3c7a7d00513bb2d2f4fbb684d97d73046cf4550c..d9f989b89062735acba1f02075058ccf497d0be8 100644 GIT binary patch delta 2355 zcmcgtX>3$g6rOYMebbq43@t6Cw4KMaU|EE=&;@APnSw1!r4_Xb5z`iwNR*j1Z(-`~ka@r&U;!D`S{A#88Gfx;yabC8($?F{ zTWSWF>|nB{{=rnnE}sz$InzYk4lrAx)~A7IDbODr7X1bPi!1C;SIorm(N^>wFx?3B zkTKU=K;IircqfPw9LwnTCXqBg_l{*n%!v1;P@j=~{(kzvc-B|qoQwz#95pVok;bl9 zl8k~O_TcoQL+&PTY4ju5&gI1CE+d}y2eEG~)f!d4nFI8xWEe+%sedjKyf{C#Ms7fVm?r^Bl~H0iVn(V3P(qK`tv`y1pB>>j5h! z9WnC(57yiX+gU3QAR>#u1h&?@6a} z$7+zS1?1srEY7Hmk5%8M(>N4W6AR_~$1~l~hoDHd43yJS=hf=!ZuagVe*;TkZ`fpF z11q9tIqw`_sSU*z`{nx$tVEPxBT{c<%h+Cd_Tg%yZTwl}go^8~YB z$`;uSZ_e)#H4Uuh%ET7YrNq`kzY>4SJWV&FiYKvNGW2vDBAoX`&}Qiy#R{djk5{>} z%d_WYjGh;JQV(x%_of_Ft$nOuNR+8L&OanS8az zu|O>-+RuIXZF0 zYb-}jNwmkS(g1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