mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 11:22:55 +08:00
Add initial table display
This commit is contained in:
parent
937dbb7bf6
commit
de13320a2d
@ -1,12 +1,18 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -15,6 +21,9 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
{
|
{
|
||||||
public class TimingScreen : EditorScreenWithTimeline
|
public class TimingScreen : EditorScreenWithTimeline
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
|
private readonly Bindable<ControlPoint> controlPoint = new Bindable<ControlPoint>();
|
||||||
|
|
||||||
protected override Drawable CreateMainContent() => new GridContainer
|
protected override Drawable CreateMainContent() => new GridContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -53,37 +62,13 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
new OsuScrollContainer
|
new OsuScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = new FillFlowContainer
|
Child = new ControlPointTable
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
ControlPoints = Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints
|
||||||
Direction = FillDirection.Vertical,
|
}
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new ControlPointRow(),
|
|
||||||
new ControlPointRow(),
|
|
||||||
new ControlPointRow(),
|
|
||||||
new ControlPointRow(),
|
|
||||||
new ControlPointRow(),
|
|
||||||
new ControlPointRow(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ControlPointRow : CompositeDrawable
|
|
||||||
{
|
|
||||||
public ControlPointRow()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new OsuSpriteText { Text = "sample row" },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ControlPointSettings : CompositeDrawable
|
public class ControlPointSettings : CompositeDrawable
|
||||||
@ -101,4 +86,152 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ControlPointTable : TableContainer
|
||||||
|
{
|
||||||
|
private const float horizontal_inset = 20;
|
||||||
|
private const float row_height = 25;
|
||||||
|
private const int text_size = 14;
|
||||||
|
|
||||||
|
private readonly FillFlowContainer backgroundFlow;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Bindable<ControlPoint> controlPoint { get; set; }
|
||||||
|
|
||||||
|
public ControlPointTable()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
Padding = new MarginPadding { Horizontal = horizontal_inset };
|
||||||
|
RowSize = new Dimension(GridSizeMode.Absolute, row_height);
|
||||||
|
|
||||||
|
AddInternal(backgroundFlow = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Depth = 1f,
|
||||||
|
Padding = new MarginPadding { Horizontal = -horizontal_inset },
|
||||||
|
Margin = new MarginPadding { Top = row_height }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public IReadOnlyList<ControlPoint> ControlPoints
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Content = null;
|
||||||
|
backgroundFlow.Clear();
|
||||||
|
|
||||||
|
if (value?.Any() != true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < value.Count; i++)
|
||||||
|
{
|
||||||
|
var cp = value[i];
|
||||||
|
backgroundFlow.Add(new RowBackground { Action = () => controlPoint.Value = cp });
|
||||||
|
}
|
||||||
|
|
||||||
|
Columns = createHeaders();
|
||||||
|
Content = value.Select((s, i) => createContent(i, s)).ToArray().ToRectangular();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableColumn[] createHeaders()
|
||||||
|
{
|
||||||
|
var columns = new List<TableColumn>
|
||||||
|
{
|
||||||
|
new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
||||||
|
new TableColumn("offset", Anchor.Centre),
|
||||||
|
new TableColumn("BPM", Anchor.Centre),
|
||||||
|
new TableColumn("Meter", Anchor.Centre),
|
||||||
|
new TableColumn("Sample Set", Anchor.Centre),
|
||||||
|
new TableColumn("Volume", Anchor.Centre),
|
||||||
|
};
|
||||||
|
|
||||||
|
return columns.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable[] createContent(int index, ControlPoint controlPoint)
|
||||||
|
{
|
||||||
|
return new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = $"#{index + 1}",
|
||||||
|
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = $"{controlPoint.Time}",
|
||||||
|
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = $"{(controlPoint as TimingControlPoint)?.BeatLength.ToString(CultureInfo.InvariantCulture) ?? "-"}",
|
||||||
|
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = $"{(controlPoint as TimingControlPoint)?.TimeSignature.ToString() ?? "-"}",
|
||||||
|
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty);
|
||||||
|
|
||||||
|
private class HeaderText : OsuSpriteText
|
||||||
|
{
|
||||||
|
public HeaderText(string text)
|
||||||
|
{
|
||||||
|
Text = text.ToUpper();
|
||||||
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RowBackground : OsuClickableContainer
|
||||||
|
{
|
||||||
|
private const int fade_duration = 100;
|
||||||
|
|
||||||
|
private readonly Box hoveredBackground;
|
||||||
|
|
||||||
|
public RowBackground()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Height = 25;
|
||||||
|
|
||||||
|
AlwaysPresent = true;
|
||||||
|
|
||||||
|
CornerRadius = 3;
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
hoveredBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
hoveredBackground.Colour = colours.Blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
|
||||||
|
return base.OnHover(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user