(e42047dc1) Tester's build, January 30th 2020
This commit is contained in:
@@ -37,11 +37,23 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool CrossFadeIn { get; private set; } = true;
|
||||
public bool CrossFadeOut { get; private set; } = true;
|
||||
|
||||
public TransitionMode TransitionMode { get; private set; }
|
||||
|
||||
public UISprite(XElement element)
|
||||
{
|
||||
Sprite = new Sprite(element);
|
||||
MaintainAspectRatio = element.GetAttributeBool("maintainaspectratio", false);
|
||||
Tile = element.GetAttributeBool("tile", true);
|
||||
CrossFadeIn = element.GetAttributeBool("crossfadein", CrossFadeIn);
|
||||
CrossFadeOut = element.GetAttributeBool("crossfadeout", CrossFadeOut);
|
||||
string transitionMode = element.GetAttributeString("transition", string.Empty);
|
||||
if (Enum.TryParse(transitionMode, ignoreCase: true, out TransitionMode transition))
|
||||
{
|
||||
TransitionMode = transition;
|
||||
}
|
||||
|
||||
Vector4 sliceVec = element.GetAttributeVector4("slice", Vector4.Zero);
|
||||
if (sliceVec != Vector4.Zero)
|
||||
@@ -86,43 +98,30 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 pos = new Vector2(rect.X, rect.Y);
|
||||
|
||||
int centerWidth = Math.Max(rect.Width - Slices[0].Width - Slices[2].Width, 0);
|
||||
int centerHeight = Math.Max(rect.Height - Slices[0].Height - Slices[8].Height, 0);
|
||||
|
||||
Vector2 scale = Vector2.One;
|
||||
if (centerHeight == 0)
|
||||
{
|
||||
scale.Y = MathHelper.Clamp((float)rect.Height / (Slices[0].Height + Slices[3].Height + Slices[6].Height), 0, 1);
|
||||
centerHeight = rect.Height - (int)((Slices[0].Height + Slices[6].Height) * scale.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
scale.Y = MathHelper.Clamp((float)rect.Height / (Slices[0].Height + Slices[6].Height), 0, 1);
|
||||
centerHeight = (int)(centerHeight * scale.Y);
|
||||
}
|
||||
if (centerWidth == 0)
|
||||
{
|
||||
scale.X = MathHelper.Clamp((float)rect.Height / (Slices[0].Width + Slices[1].Width + Slices[2].Width), 0, 1);
|
||||
centerWidth = rect.Width - (int)((Slices[0].Width + Slices[2].Width) * scale.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
scale.X = MathHelper.Clamp((float)rect.Width / (Slices[0].Width + Slices[2].Width), 0, 1);
|
||||
centerWidth = (int)(centerWidth * scale.X);
|
||||
}
|
||||
|
||||
scale.Y = MathHelper.Clamp((float)rect.Height / (Slices[0].Height + Slices[6].Height), 0, 1);
|
||||
|
||||
scale.X = MathHelper.Clamp((float)rect.Width / (Slices[0].Width + Slices[2].Width), 0, 1);
|
||||
|
||||
scale.X = scale.Y = Math.Min(scale.X, scale.Y);
|
||||
int centerHeight = rect.Height - (int)((Slices[0].Height + Slices[6].Height) * scale.Y);
|
||||
int centerWidth = rect.Width - (int)((Slices[0].Width + Slices[2].Width) * scale.X);
|
||||
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
float width = (x == 1 ? centerWidth : Slices[x].Width * scale.X);
|
||||
int width = (int)(x == 1 ? centerWidth : Slices[x].Width * scale.X);
|
||||
if (width <= 0) { continue; }
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
float height = (y == 1 ? centerHeight : Slices[x + y * 3].Height * scale.Y);
|
||||
int height = (int)(y == 1 ? centerHeight : Slices[x + y * 3].Height * scale.Y);
|
||||
if (height <= 0) { continue; }
|
||||
|
||||
spriteBatch.Draw(Sprite.Texture,
|
||||
new Rectangle((int)pos.X, (int)pos.Y, (int)width, (int)height),
|
||||
new Rectangle((int)pos.X, (int)pos.Y, width, height),
|
||||
Slices[x + y * 3],
|
||||
color);
|
||||
|
||||
|
||||
pos.Y += height;
|
||||
}
|
||||
pos.X += width;
|
||||
|
||||
Reference in New Issue
Block a user