Fix incorrect layout calculations

This commit is contained in:
Royce551 2022-09-04 17:16:47 -05:00
parent fefbdce1e2
commit 6214b2ca1a
11 changed files with 28 additions and 28 deletions

View file

@ -52,13 +52,13 @@ namespace FrivoloCo.Screens.Menu
Layout = Water.Graphics.Layout.Fill,
HorizontalTextAlignment = HorizontalTextAlignment.Left,
VerticalTextAlignment = VerticalTextAlignment.Top,
Margin = 10
Margins = new(10)
};
tb.Text = File.ReadAllText("Assets/credits.txt");
var box = new Box()
{
Layout = Water.Graphics.Layout.Fill,
Margin = 10,
Margins = new(10),
Color = Color.White * 0.5f
};
co.AddChild(Game.AddObject(box));
@ -68,7 +68,7 @@ namespace FrivoloCo.Screens.Menu
{
Layout = Water.Graphics.Layout.AnchorBottomLeft,
RelativePosition = new(0, 0, 250, 100),
Margin = 10
Margins = new(10)
};
co.AddChild(Game.AddObject(button));
}

View file

@ -64,7 +64,7 @@ namespace FrivoloCo.Screens.Menu
{
RelativePosition = new(0, 0, 393, 225),
Layout = Water.Graphics.Layout.AnchorTop,
Margin = 50
Margins = new(50)
};
co.AddChild(Game.AddObject(logo));

View file

@ -53,14 +53,14 @@ namespace FrivoloCo.Screens.Menu
Layout = Water.Graphics.Layout.Fill,
HorizontalTextAlignment = HorizontalTextAlignment.Left,
VerticalTextAlignment = VerticalTextAlignment.Top,
Margin = 10
Margins = new(10)
};
tb.Text = "since we don't have a proper options UI yet, the config file should have been opened with your text editor.\n" +
"just edit that and your changes will be saved when you hit the back button :)";
var box = new Box()
{
Layout = Water.Graphics.Layout.Fill,
Margin = 10,
Margins = new(10),
Color = Color.White * 0.5f
};
co.AddChild(Game.AddObject(box));
@ -74,7 +74,7 @@ namespace FrivoloCo.Screens.Menu
{
Layout = Water.Graphics.Layout.AnchorBottomLeft,
RelativePosition = new(0, 0, 250, 100),
Margin = 10
Margins = new(10)
};
co.AddChild(Game.AddObject(button));

View file

@ -51,7 +51,7 @@ namespace FrivoloCo.Screens.Menu
Layout = Water.Graphics.Layout.Fill,
HorizontalTextAlignment = HorizontalTextAlignment.Left,
VerticalTextAlignment = VerticalTextAlignment.Top,
Margin = 10
Margins = new(10)
};
tb.Text =
"Customers will show up at the counter. Drag and drop the drinks they want to them.\n" +
@ -60,7 +60,7 @@ namespace FrivoloCo.Screens.Menu
var box = new Box()
{
Layout = Water.Graphics.Layout.Fill,
Margin = 10,
Margins = new(10),
Color = Color.White * 0.5f
};
co.AddChild(Game.AddObject(box));
@ -70,7 +70,7 @@ namespace FrivoloCo.Screens.Menu
{
Layout = Water.Graphics.Layout.AnchorBottomLeft,
RelativePosition = new(0, 0, 250, 100),
Margin = 10
Margins = new(10)
};
co.AddChild(Game.AddObject(button));
}

View file

@ -133,7 +133,7 @@ namespace FrivoloCo.Screens.Play
tb = new TextBlock(new(0, 0, 0, 0), Game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 25), "", Color.Black)
{
Layout = Layout.Fill,
Margin = 5
Margins = new(5)
};
AddChild(Game.AddObject(box));
box.AddChild(Game.AddObject(tb));

View file

@ -178,7 +178,7 @@ namespace FrivoloCo.Screens.Play
{
RelativePosition = new(0, 0, 250, 30),
Layout = Layout.AnchorTopRight,
Margin = 10,
Margins = new(10),
Color = Color.White
};
AddChild(Game.AddObject(moneyBox));
@ -187,7 +187,7 @@ namespace FrivoloCo.Screens.Play
Layout = Layout.Fill,
HorizontalTextAlignment = HorizontalTextAlignment.Left,
VerticalTextAlignment = VerticalTextAlignment.Center,
Margin = 2
Margins = new(2)
};
moneyBox.AddChild(Game.AddObject(moneyTb));
@ -195,7 +195,7 @@ namespace FrivoloCo.Screens.Play
{
RelativePosition = new(0, 0, 300, 30),
Layout = Layout.AnchorTopLeft,
Margin = 10,
Margins = new(10),
Color = Color.White
};
AddChild(Game.AddObject(statusBox));
@ -204,7 +204,7 @@ namespace FrivoloCo.Screens.Play
Layout = Layout.Fill,
HorizontalTextAlignment = HorizontalTextAlignment.Left,
VerticalTextAlignment = VerticalTextAlignment.Center,
Margin = 2
Margins = new(2)
};
statusBox.AddChild(Game.AddObject(statusTb));
}

View file

@ -56,7 +56,7 @@ namespace FrivoloCo.Screens.Play.Items
HorizontalTextAlignment = HorizontalTextAlignment.Center,
VerticalTextAlignment = VerticalTextAlignment.Center,
TextWrapping = TextWrapMode.LetterWrap,
Margin = 1
Margins = new(1)
};
labelBox.AddChild(Game.AddObject(tb));
AddChild(Game.AddObject(labelBox));

View file

@ -28,7 +28,7 @@ namespace TestGame.Screens
}
else if (e.Key == Microsoft.Xna.Framework.Input.Keys.E)
{
Game.Audio.SwitchToTrack("Assets/03. Dream Walker.mp3");
Game.Audio.SwitchToTrack("Assets/03. Dream Walker.mp3", false);
}
else if (e.Key == Microsoft.Xna.Framework.Input.Keys.R)
{

View file

@ -156,8 +156,8 @@ namespace Water.Graphics
(
parentPosition.X + child.Margins.Left,
parentPosition.Y + child.Margins.Top,
parentPosition.Width - ((child.Margins.Left + child.Margins.Right) * 2),
parentPosition.Height - ((child.Margins.Left + child.Margins.Right) * 2)
parentPosition.Width - (child.Margins.Right * 2),
parentPosition.Height - (child.Margins.Bottom * 2)
),
Layout.AspectRatioMaintainingFill => new
(
@ -173,13 +173,13 @@ namespace Water.Graphics
parentPosition.X + child.Margins.Left,
parentPosition.Y + child.Margins.Top,
child.RelativePosition.Width,
parentPosition.Height - ((child.Margins.Top + child.Margins.Bottom) * 2)
parentPosition.Height - (child.Margins.Bottom * 2)
),
Layout.DockTop => new
(
parentPosition.X + child.Margins.Left,
parentPosition.Y + child.Margins.Top,
parentPosition.Width - ((child.Margins.Left + child.Margins.Right) * 2),
parentPosition.Width - (child.Margins.Right * 2),
child.RelativePosition.Height
),
Layout.DockRight => new
@ -187,13 +187,13 @@ namespace Water.Graphics
parentPosition.Right - child.RelativePosition.Width - child.Margins.Right,
parentPosition.Y + child.Margins.Top,
child.RelativePosition.Width,
parentPosition.Height - ((child.Margins.Top + child.Margins.Bottom) * 2)
parentPosition.Height - (child.Margins.Bottom * 2)
),
Layout.DockBottom => new
(
parentPosition.X + child.Margins.Left,
parentPosition.Bottom - child.RelativePosition.Height - child.Margins.Top,
parentPosition.Width - ((child.Margins.Left + child.Margins.Right) * 2),
parentPosition.Width - (child.Margins.Right * 2),
child.RelativePosition.Height
),
Layout.Manual or _ => new

View file

@ -19,13 +19,13 @@ namespace Water.Graphics.Containers
{
if (Orientation == Orientation.Horizontal)
{
child.ActualPosition = new(offset + Margin, child.ActualPosition.Y + Margin, child.ActualPosition.Width, child.ActualPosition.Height);
offset += child.ActualPosition.X + Margin;
child.ActualPosition = new(offset + Margins.Top, child.ActualPosition.Y + Margins.Left, child.ActualPosition.Width, child.ActualPosition.Height);
offset += child.ActualPosition.X + Margins.Left;
}
else if (Orientation == Orientation.Vertical)
{
child.ActualPosition = new(child.ActualPosition.X + Margin, offset + Margin, child.ActualPosition.Width, child.ActualPosition.Height);
offset += child.ActualPosition.Y + Margin;
child.ActualPosition = new(child.ActualPosition.X + Margins.Top, offset + Margins.Left, child.ActualPosition.Width, child.ActualPosition.Height);
offset += child.ActualPosition.Y + Margins.Top;
}
child.CalculateChildrenPositions();
}

View file

@ -36,7 +36,7 @@ namespace Water.Screens
RelativePosition = new(0, 0, 100, 20),
Orientation = Orientation.Vertical,
Layout = Layout.AnchorTopRight,
Margin = 2
Margins = new(2)
};
box = new Box()
{