- 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
This commit is contained in:
Regalis
2016-01-24 21:28:27 +02:00
parent 28af6fa1f4
commit 278371638e
12 changed files with 107 additions and 17 deletions

View File

@@ -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();

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -1023,6 +1023,9 @@ namespace Barotrauma
{
picked = true;
ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
GUIComponent.MouseOn = null;
if (ic.CanBeSelected) selected = true;
}
}

View File

@@ -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<ushort>();

View File

@@ -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);

View File

@@ -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 };

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)
{

Binary file not shown.