mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Refactor BeatmapDetails to use GridContainer to keep a consistent layout
This commit is contained in:
@ -8,8 +8,8 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Framework.Threading;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Game.Screens.Select.Details;
|
using osu.Game.Screens.Select.Details;
|
||||||
@ -28,11 +28,8 @@ namespace osu.Game.Screens.Select
|
|||||||
private const float spacing = 10;
|
private const float spacing = 10;
|
||||||
private const float transition_duration = 250;
|
private const float transition_duration = 250;
|
||||||
|
|
||||||
private readonly FillFlowContainer top, statsFlow;
|
|
||||||
private readonly AdvancedStats advanced;
|
private readonly AdvancedStats advanced;
|
||||||
private readonly DetailBox ratingsContainer;
|
|
||||||
private readonly UserRatings ratings;
|
private readonly UserRatings ratings;
|
||||||
private readonly OsuScrollContainer metadataScroll;
|
|
||||||
private readonly MetadataSection description, source, tags;
|
private readonly MetadataSection description, source, tags;
|
||||||
private readonly Container failRetryContainer;
|
private readonly Container failRetryContainer;
|
||||||
private readonly FailRetryGraph failRetryGraph;
|
private readonly FailRetryGraph failRetryGraph;
|
||||||
@ -41,8 +38,6 @@ namespace osu.Game.Screens.Select
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
private ScheduledDelegate pendingBeatmapSwitch;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
@ -57,8 +52,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
beatmap = value;
|
beatmap = value;
|
||||||
|
|
||||||
pendingBeatmapSwitch?.Cancel();
|
Scheduler.AddOnce(updateStatistics);
|
||||||
pendingBeatmapSwitch = Schedule(updateStatistics);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,99 +69,115 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Horizontal = spacing },
|
Padding = new MarginPadding { Horizontal = spacing },
|
||||||
Children = new Drawable[]
|
Child = new GridContainer
|
||||||
{
|
{
|
||||||
top = new FillFlowContainer
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RowDimensions = new[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
AutoSizeAxes = Axes.Y,
|
new Dimension()
|
||||||
Direction = FillDirection.Horizontal,
|
},
|
||||||
Children = new Drawable[]
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
{
|
{
|
||||||
statsFlow = new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Width = 0.5f,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(spacing),
|
Children = new Drawable[]
|
||||||
Padding = new MarginPadding { Right = spacing / 2 },
|
|
||||||
Children = new[]
|
|
||||||
{
|
{
|
||||||
new DetailBox
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Child = advanced = new AdvancedStats
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Width = 0.5f,
|
||||||
|
Spacing = new Vector2(spacing),
|
||||||
|
Padding = new MarginPadding { Right = spacing / 2 },
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new DetailBox().WithChild(advanced = new AdvancedStats
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding { Horizontal = spacing, Top = spacing * 2, Bottom = spacing },
|
||||||
|
}),
|
||||||
|
new DetailBox().WithChild(new OnlineViewContainer(string.Empty)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 134,
|
||||||
|
Padding = new MarginPadding { Horizontal = spacing, Top = spacing },
|
||||||
|
Child = ratings = new UserRatings
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new OsuScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Width = 0.5f,
|
||||||
|
ScrollbarVisible = false,
|
||||||
|
Padding = new MarginPadding { Left = spacing / 2 },
|
||||||
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding { Horizontal = spacing, Top = spacing * 2, Bottom = spacing },
|
LayoutDuration = transition_duration,
|
||||||
|
LayoutEasing = Easing.OutQuad,
|
||||||
|
Spacing = new Vector2(spacing * 2),
|
||||||
|
Margin = new MarginPadding { Top = spacing * 2 },
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
description = new MetadataSection("Description"),
|
||||||
|
source = new MetadataSection("Source"),
|
||||||
|
tags = new MetadataSection("Tags"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ratingsContainer = new DetailBox
|
|
||||||
{
|
|
||||||
Child = ratings = new UserRatings
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = 134,
|
|
||||||
Padding = new MarginPadding { Horizontal = spacing, Top = spacing },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
metadataScroll = new OsuScrollContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Width = 0.5f,
|
|
||||||
ScrollbarVisible = false,
|
|
||||||
Padding = new MarginPadding { Left = spacing / 2 },
|
|
||||||
Child = new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
LayoutDuration = transition_duration,
|
|
||||||
LayoutEasing = Easing.OutQuad,
|
|
||||||
Spacing = new Vector2(spacing * 2),
|
|
||||||
Margin = new MarginPadding { Top = spacing * 2 },
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
description = new MetadataSection("Description"),
|
|
||||||
source = new MetadataSection("Source"),
|
|
||||||
tags = new MetadataSection("Tags"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
new Drawable[]
|
||||||
failRetryContainer = new OnlineViewContainer("Sign in to view more details")
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
failRetryContainer = new OnlineViewContainer("Sign in to view more details")
|
||||||
{
|
|
||||||
Text = "Points of Failure",
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14),
|
|
||||||
},
|
|
||||||
failRetryGraph = new FailRetryGraph
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Top = 14 + spacing / 2 },
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = "Points of Failure",
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14),
|
||||||
|
},
|
||||||
|
failRetryGraph = new FailRetryGraph
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Top = 14 + spacing / 2 },
|
||||||
|
},
|
||||||
|
loading = new LoadingLayer(true)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
loading = new LoadingLayer(true)
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
private IBindable<APIState> apiOnlineState;
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
metadataScroll.Height = statsFlow.DrawHeight;
|
protected override void LoadComplete()
|
||||||
failRetryContainer.Height = DrawHeight - Padding.TotalVertical - (top.DrawHeight + spacing / 2);
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
apiOnlineState = api.State.GetBoundCopy();
|
||||||
|
apiOnlineState.BindValueChanged(state =>
|
||||||
|
{
|
||||||
|
Scheduler.AddOnce(updateStatistics);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStatistics()
|
private void updateStatistics()
|
||||||
@ -185,7 +195,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for now, let's early abort if an OnlineBeatmapID is not present (should have been populated at import time).
|
// for now, let's early abort if an OnlineBeatmapID is not present (should have been populated at import time).
|
||||||
if (Beatmap?.OnlineBeatmapID == null)
|
if (Beatmap?.OnlineBeatmapID == null || apiOnlineState.Value != APIState.Online)
|
||||||
{
|
{
|
||||||
updateMetrics();
|
updateMetrics();
|
||||||
return;
|
return;
|
||||||
@ -237,17 +247,16 @@ namespace osu.Game.Screens.Select
|
|||||||
var hasRatings = beatmap?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false;
|
var hasRatings = beatmap?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false;
|
||||||
var hasRetriesFails = (beatmap?.Metrics?.Retries?.Any() ?? false) || (beatmap?.Metrics?.Fails?.Any() ?? false);
|
var hasRetriesFails = (beatmap?.Metrics?.Retries?.Any() ?? false) || (beatmap?.Metrics?.Fails?.Any() ?? false);
|
||||||
|
|
||||||
bool isOnline = api.State.Value == APIState.Online;
|
if (hasRatings)
|
||||||
|
|
||||||
if (hasRatings && isOnline)
|
|
||||||
{
|
{
|
||||||
ratings.Metrics = beatmap.BeatmapSet.Metrics;
|
ratings.Metrics = beatmap.BeatmapSet.Metrics;
|
||||||
ratingsContainer.FadeIn(transition_duration);
|
ratings.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// loading or just has no data server-side.
|
||||||
ratings.Metrics = new BeatmapSetMetrics { Ratings = new int[10] };
|
ratings.Metrics = new BeatmapSetMetrics { Ratings = new int[10] };
|
||||||
ratingsContainer.FadeTo(isOnline ? 0.25f : 0, transition_duration);
|
ratings.FadeTo(0.25f, transition_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasRetriesFails)
|
if (hasRetriesFails)
|
||||||
|
Reference in New Issue
Block a user