1
0
Fork 0
mirror of https://github.com/ppy/osu-tools.git synced 2025-06-09 09:35:15 +09:00

Add beatmap card, remove bg from beatmap leaderboard screen

This commit is contained in:
StanR 2022-07-21 02:32:43 +03:00
parent bb9e6532ce
commit 2ce4e314b4
2 changed files with 132 additions and 51 deletions

View file

@ -0,0 +1,96 @@
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
namespace PerformanceCalculatorGUI.Components
{
internal class BeatmapCard : OsuClickableContainer
{
private readonly ProcessorWorkingBeatmap beatmap;
[Resolved(canBeNull: true)]
private OverlayColourProvider colourProvider { get; set; }
[Resolved]
private OsuColour colours { get; set; }
[Resolved]
private LargeTextureStore textures { get; set; }
public BeatmapCard(ProcessorWorkingBeatmap beatmap) : base(HoverSampleSet.Button)
{
this.beatmap = beatmap;
RelativeSizeAxes = Axes.X;
Height = 40;
CornerRadius = ExtendedLabelledTextBox.CORNER_RADIUS;
}
[BackgroundDependencyLoader]
private void load(GameHost host)
{
Masking = true;
BorderColour = colourProvider?.Light1 ?? colours.GreyVioletLighter;
AddRange(new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider?.Background5 ?? colours.Gray1
},
new BufferedContainer
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.3f,
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get($"https://assets.ppy.sh/beatmaps/{beatmap.BeatmapSetInfo.OnlineID}/covers/cover.jpg"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill
}
}
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold),
Shadow = false,
Text = beatmap.Metadata.GetDisplayTitle(),
Margin = new MarginPadding(10)
}
});
Action = () => { host.OpenUrlExternally($"https://osu.ppy.sh/beatmaps/{beatmap.BeatmapInfo.OnlineID}"); };
}
protected override bool OnHover(HoverEvent e)
{
BorderThickness = 2;
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
BorderThickness = 0;
base.OnHoverLost(e);
}
}
}

View file

@ -12,7 +12,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Logging;
using osu.Game.Graphics.Containers;
@ -26,7 +25,6 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Users;
using osu.Game.Utils;
using osuTK;
using PerformanceCalculatorGUI.Components;
using PerformanceCalculatorGUI.Configuration;
@ -38,9 +36,13 @@ namespace PerformanceCalculatorGUI.Screens
private StatefulButton calculationButton;
private VerboseLoadingLayer loadingLayer;
private GridContainer layout;
private OsuScrollContainer scrollContainer;
private ScoreTable scoreTable;
private BufferedContainer background;
private Box background;
private Container beatmapPanelContainer;
private BeatmapCard beatmapPanel;
private CancellationTokenSource calculationCancellatonToken;
@ -84,11 +86,11 @@ namespace PerformanceCalculatorGUI.Screens
{
InternalChildren = new Drawable[]
{
new GridContainer
layout = new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[] { new Dimension() },
RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, 40), new Dimension() },
RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, 40), new Dimension(GridSizeMode.Absolute), new Dimension() },
Content = new[]
{
new Drawable[]
@ -132,13 +134,29 @@ namespace PerformanceCalculatorGUI.Screens
},
new Drawable[]
{
new OsuScrollContainer
beatmapPanelContainer = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
},
new Drawable[]
{
scrollContainer = new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = scoreTable = new ScoreTable
Children = new Drawable[]
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5
},
scoreTable = new ScoreTable
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}
}
}
}
@ -180,7 +198,15 @@ namespace PerformanceCalculatorGUI.Screens
var working = ProcessorWorkingBeatmap.FromFileOrId(beatmapIdTextBox.Current.Value, cachePath: configManager.GetBindable<string>(Settings.CachePath).Value);
Schedule(() => loadBackground(working.BeatmapInfo?.BeatmapSet?.OnlineID.ToString()));
Schedule(() =>
{
if (beatmapPanel != null)
beatmapPanelContainer.Remove(beatmapPanel);
beatmapPanelContainer.Add(beatmapPanel = new BeatmapCard(working));
layout.RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, 40), new Dimension(GridSizeMode.AutoSize), new Dimension() };
});
var random = false;
@ -237,47 +263,6 @@ namespace PerformanceCalculatorGUI.Screens
}, token);
}
private void loadBackground(string beatmapId)
{
if (background is not null)
{
RemoveInternal(background);
}
if (!string.IsNullOrEmpty(beatmapId))
{
LoadComponentAsync(background = new BufferedContainer
{
RelativeSizeAxes = Axes.Both,
Depth = 99,
BlurSigma = new Vector2(6),
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get($"https://assets.ppy.sh/beatmaps/{beatmapId}/covers/cover.jpg"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background6,
Alpha = 0.9f
},
}
}).ContinueWith(_ =>
{
Schedule(() =>
{
AddInternal(background);
});
});
}
}
private List<SoloScoreInfo> generateRandomScores(ProcessorWorkingBeatmap working)
{
var scores = new List<SoloScoreInfo>();