Invert the playfield by default to make calculations a bit simpler and clean up a lot of code.

This commit is contained in:
smoogipooo
2017-05-16 17:34:41 +09:00
parent 62139015fb
commit 7039205363
6 changed files with 57 additions and 61 deletions

View File

@ -27,18 +27,18 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
// This will be fixed when new designs are given or the current design is finalized. // This will be fixed when new designs are given or the current design is finalized.
bodyPiece = new BodyPiece bodyPiece = new BodyPiece
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.TopCentre,
}, },
headPiece = new NotePiece headPiece = new NotePiece
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre Origin = Anchor.TopCentre
}, },
tailPiece = new NotePiece tailPiece = new NotePiece
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre Origin = Anchor.BottomCentre
} }
}); });
} }

View File

@ -22,11 +22,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
{ {
HitObject = hitObject; HitObject = hitObject;
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
RelativePositionAxes = Axes.Y; RelativePositionAxes = Axes.Y;
Y = (float)-HitObject.StartTime; Y = (float)HitObject.StartTime;
Add(glowContainer = new Container Add(glowContainer = new Container
{ {

View File

@ -20,8 +20,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
Add(headPiece = new NotePiece Add(headPiece = new NotePiece
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre Origin = Anchor.TopCentre
}); });
} }

View File

@ -87,18 +87,13 @@ namespace osu.Game.Rulesets.Mania.Timing
{ {
this.timingChange = timingChange; this.timingChange = timingChange;
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
AddInternal(content = new AutoTimeRelativeContainer AddInternal(content = new AutoTimeRelativeContainer
{ {
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Y = -(float)timingChange.Time Y = (float)timingChange.Time
}); });
} }
@ -111,7 +106,7 @@ namespace osu.Game.Rulesets.Mania.Timing
RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan);
// Scroll the content // Scroll the content
content.Y = (float)(Time.Current - timingChange.Time); content.Y = (float)(timingChange.Time - Time.Current);
} }
public override void Add(Drawable drawable) public override void Add(Drawable drawable)
@ -120,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.Timing
// we need to offset it back by our position so that it becomes correctly relatively-positioned to us // we need to offset it back by our position so that it becomes correctly relatively-positioned to us
// This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section
// they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet
drawable.Y += (float)timingChange.Time; drawable.Y -= (float)timingChange.Time;
base.Add(drawable); base.Add(drawable);
} }
@ -130,7 +125,7 @@ namespace osu.Game.Rulesets.Mania.Timing
/// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity). /// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity).
/// </summary> /// </summary>
/// <param name="drawable">The drawable to check.</param> /// <param name="drawable">The drawable to check.</param>
public bool CanContain(Drawable drawable) => content.Y >= drawable.Y; public bool CanContain(Drawable drawable) => content.Y <= drawable.Y;
private class AutoTimeRelativeContainer : Container private class AutoTimeRelativeContainer : Container
{ {
@ -140,8 +135,7 @@ namespace osu.Game.Rulesets.Mania.Timing
foreach (Drawable child in Children) foreach (Drawable child in Children)
{ {
// Todo: This is wrong, it won't work for absolute-y-sized children float childEndPos = child.Y + child.Height;
float childEndPos = -child.Y + child.Height;
if (childEndPos > height) if (childEndPos > height)
height = childEndPos; height = childEndPos;
} }

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Judgements;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Rulesets.Mania.UI namespace osu.Game.Rulesets.Mania.UI
{ {
@ -56,51 +57,50 @@ namespace osu.Game.Rulesets.Mania.UI
}, },
new Container new Container
{ {
Name = "Hit target", Name = "Hit target + hit objects",
Anchor = Anchor.BottomCentre, RelativeSizeAxes = Axes.Both,
Origin = Anchor.BottomCentre, Padding = new MarginPadding { Top = ManiaPlayfield.HIT_TARGET_POSITION},
RelativeSizeAxes = Axes.X,
Height = hit_target_height,
Y = -ManiaPlayfield.HIT_TARGET_POSITION,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Container
{ {
Name = "Background", Name = "Hit target",
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black
},
hitTargetBar = new Container
{
Name = "Bar",
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = hit_target_bar_height, Height = hit_target_height,
Masking = true, Children = new Drawable[]
Children = new[]
{ {
new Box new Box
{ {
RelativeSizeAxes = Axes.Both Name = "Background",
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black
},
hitTargetBar = new Container
{
Name = "Bar",
RelativeSizeAxes = Axes.X,
Height = hit_target_bar_height,
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both
}
}
} }
} }
} },
TimingSectionContainer = new TimeRelativeContainer(timingChanges)
{
Name = "Hit objects",
RelativeSizeAxes = Axes.Both,
},
} }
}, },
TimingSectionContainer = new TimeRelativeContainer(timingChanges)
{
Name = "Hit objects",
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Y = -ManiaPlayfield.HIT_TARGET_POSITION
},
new Container new Container
{ {
Name = "Key", Name = "Key",
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = ManiaPlayfield.HIT_TARGET_POSITION, Height = ManiaPlayfield.HIT_TARGET_POSITION,
Children = new Drawable[] Children = new Drawable[]

View File

@ -74,8 +74,8 @@ namespace osu.Game.Rulesets.Mania.UI
{ {
new Container new Container
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Masking = true, Masking = true,
@ -95,13 +95,18 @@ namespace osu.Game.Rulesets.Mania.UI
Padding = new MarginPadding { Left = 1, Right = 1 }, Padding = new MarginPadding { Left = 1, Right = 1 },
Spacing = new Vector2(1, 0) Spacing = new Vector2(1, 0)
}, },
barlineContainer = new TimeRelativeContainer(timingChanges) new Container
{ {
Name = "Bar lines",
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Bottom = HIT_TARGET_POSITION } Padding = new MarginPadding { Top = HIT_TARGET_POSITION },
Children = new[]
{
barlineContainer = new TimeRelativeContainer(timingChanges)
{
Name = "Bar lines",
RelativeSizeAxes = Axes.Both,
}
}
} }
} }
} }