(cb10b53db) Fixed GUIImage.RecalculateScale throwing an exception if the sprite is not set, use relative scales in GUINumberInput to make the child elements scale dynamically with the parent

This commit is contained in:
Joonas Rikkonen
2019-04-06 17:50:40 +03:00
parent 7b3ccde624
commit c19899769e
5 changed files with 64 additions and 144 deletions
@@ -594,6 +594,26 @@ namespace Barotrauma
spawnPos.X = (minX + maxX) / 2 + subDockingPortOffset;
}
if (minX < 0.0f && maxX > Level.Loaded.Size.X)
{
//no walls found at either side, just use the initial spawnpos and hope for the best
}
else if (minX < 0)
{
//no wall found at the left side, spawn to the left from the right-side wall
spawnPos.X = maxX - minWidth - 100.0f + subDockingPortOffset;
}
else if (maxX > Level.Loaded.Size.X)
{
//no wall found at right side, spawn to the right from the left-side wall
spawnPos.X = minX + minWidth + 100.0f + subDockingPortOffset;
}
else
{
//walls found at both sides, use their midpoint
spawnPos.X = (minX + maxX) / 2 + subDockingPortOffset;
}
spawnPos.Y = Math.Min(spawnPos.Y, Level.Loaded.Size.Y - dockedBorders.Height / 2 - 10);
return spawnPos - diffFromDockedBorders;
}