From 78e41fbc1f5a5cd4dc8f7e84e8313046d451051c Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Tue, 17 Dec 2024 18:07:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E7=8E=A9=E7=95=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E6=AD=8C=E6=9B=B2=E6=98=BE=E7=A4=BA=E6=96=B0=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/TournamentBeatmapPanel.cs | 161 +++++++++++++----- .../Gameplay/Components/GameplaySongBar.cs | 67 ++++++-- 2 files changed, 170 insertions(+), 58 deletions(-) diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs index 386757b109cc..f5b1b6c56952 100644 --- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs +++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs @@ -84,15 +84,17 @@ public TournamentBeatmapPanel(RoundBeatmap beatmap, int? id = null, bool isMappo private readonly int? id; private readonly bool isMappool; + private readonly bool isGameplaySongBar; private readonly Colour4 textColor; private readonly Colour4 backgroundColor; private Container container = null!; - public TournamentBeatmapPanel(IBeatmapInfo? beatmap, string mod = "", float cornerRadius = 0, bool isMappool = false) + public TournamentBeatmapPanel(IBeatmapInfo? beatmap, string mod = "", float cornerRadius = 0, bool isMappool = false, bool isGameplaySongBar = false) { Beatmap = beatmap; this.mod = mod; this.isMappool = isMappool; + this.isGameplaySongBar = isGameplaySongBar; Width = mod == "TB" && id.HasValue ? 600 : 400; Height = HEIGHT; @@ -148,45 +150,7 @@ private void load(LadderInfo ladder) Origin = Anchor.CentreLeft, Padding = new MarginPadding(15), Direction = FillDirection.Vertical, - Children = new Drawable[] - { - new TournamentSpriteText - { - Text = Beatmap?.GetDisplayTitleRomanisable(false, false) ?? (LocalisableString)@"未知", - Font = OsuFont.Torus.With(weight: FontWeight.Bold), - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new Drawable[] - { - new TournamentSpriteText - { - Text = "谱师", - Padding = new MarginPadding { Right = 5 }, - Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14) - }, - new TournamentSpriteText - { - Text = Beatmap?.Metadata.Author.Username ?? "未知", - Padding = new MarginPadding { Right = 20 }, - Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14) - }, - new TournamentSpriteText - { - Text = "难度", - Padding = new MarginPadding { Right = 5 }, - Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14) - }, - new TournamentSpriteText - { - Text = Beatmap?.DifficultyName ?? "未知", - Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14) - }, - } - }, - }, + Children = createInformation() }, flash = new Box { @@ -274,6 +238,123 @@ private void matchChanged(ValueChangedEvent match) Scheduler.AddOnce(updateState); } + private Drawable[] createInformation() + { + if (isGameplaySongBar) + { + return new Drawable[] + { + new TournamentSpriteText + { + Text = Beatmap?.GetDisplayTitleRomanisable(false, false) ?? (LocalisableString)@"未知", + Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 20), + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + }, + new Container + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new TournamentSpriteText + { + Text = "|", + Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 15) + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreLeft, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + new TournamentSpriteText + { + Text = "谱师", + Padding = new MarginPadding { Right = 5 }, + Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 15) + }, + new TournamentSpriteText + { + Text = Beatmap?.Metadata.Author.Username ?? "未知", + Padding = new MarginPadding { Right = 5 }, + Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 15) + }, + } + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreRight, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + new TournamentSpriteText + { + Text = "难度", + Padding = new MarginPadding { Left = 5 }, + Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 15) + }, + new TournamentSpriteText + { + Text = Beatmap?.DifficultyName ?? "未知", + Padding = new MarginPadding { Left = 5 }, + Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 15) + }, + } + } + }, + }, + }; + } + else + { + return new Drawable[] + { + new TournamentSpriteText + { + Text = Beatmap?.GetDisplayTitleRomanisable(false, false) ?? (LocalisableString)@"未知", + Font = OsuFont.Torus.With(weight: FontWeight.Bold), + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + new TournamentSpriteText + { + Text = "谱师", + Padding = new MarginPadding { Right = 5 }, + Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14) + }, + new TournamentSpriteText + { + Text = Beatmap?.Metadata.Author.Username ?? "未知", + Padding = new MarginPadding { Right = 20 }, + Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14) + }, + new TournamentSpriteText + { + Text = "难度", + Padding = new MarginPadding { Right = 5 }, + Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14) + }, + new TournamentSpriteText + { + Text = Beatmap?.DifficultyName ?? "未知", + Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14) + }, + } + }, + }; + } + } + private void picksBansOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) => Scheduler.AddOnce(updateState); diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/GameplaySongBar.cs b/osu.Game.Tournament/Screens/Gameplay/Components/GameplaySongBar.cs index 1897f1a41cb7..91165fbb034c 100644 --- a/osu.Game.Tournament/Screens/Gameplay/Components/GameplaySongBar.cs +++ b/osu.Game.Tournament/Screens/Gameplay/Components/GameplaySongBar.cs @@ -33,6 +33,9 @@ public partial class GameplaySongBar : SongBar private SpriteIcon leftArrow = null!; private SpriteIcon rightArrow = null!; private bool expanded; + private Container modContainer = null!; + + private TeamColour? pickTeamColour; [Resolved] private LadderInfo ladder { get; set; } = null!; @@ -117,12 +120,20 @@ private void load() Colour = Colour4.Black, Alpha = 0.55f, }, + modContainer = new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = 17f } + }, leftData = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, Direction = FillDirection.Vertical, } }, @@ -131,7 +142,7 @@ private void load() { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Child = new TournamentBeatmapPanel(beatmap) + Child = new TournamentBeatmapPanel(beatmap, isGameplaySongBar: true) { Width = 500, CenterText = true @@ -154,8 +165,8 @@ private void load() { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, Direction = FillDirection.Vertical, } }, @@ -210,15 +221,29 @@ private void picksBansOnCollectionChanged(object? sender, NotifyCollectionChange private void updateState() { - BeatmapChoice? isChoice = currentMatch.Value?.PicksBans.FirstOrDefault(p => p.BeatmapID == beatmap?.OnlineID && p.Type == ChoiceType.Pick); + pickTeamColour = currentMatch.Value?.PicksBans.FirstOrDefault(p => p.BeatmapID == beatmap?.OnlineID && p.Type == ChoiceType.Pick)?.Team; + string? modString = currentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmap?.OnlineID)?.Mods; - if (isChoice == null) + modContainer.Clear(); + + if (!string.IsNullOrEmpty(modString)) + { + modContainer.Add(new TournamentModIcon(modString) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Width = 44f, + }); + } + + if (pickTeamColour == null) { arrowColor.Value = Color4.White; return; } - arrowColor.Value = getTeamColour(isChoice.Team); + arrowColor.Value = getTeamColour(pickTeamColour.Value); static ColourInfo getTeamColour(TeamColour teamColour) => teamColour == TeamColour.Red ? Color4Extensions.FromHex("#D43030") : Color4Extensions.FromHex("#2A82E4"); } @@ -260,17 +285,23 @@ protected override void PostUpdate() srAndModStats = srAndModStats.Append(("谱面位置", modPosition)).ToArray(); } + (string, string)[] bpmAndPickTeam = + { + ("选图方", pickTeamColour == null ? "无" : pickTeamColour.Value == TeamColour.Red ? "红队" : "蓝队"), + ("BPM", $"{bpm:0.#}") + }; + leftData.Children = new Drawable[] { - new DiffPiece(("BPM", $"{bpm:0.#}")) + new DiffPiece(bpmAndPickTeam) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreRight, }, new DiffPiece(("谱面长度", length.ToFormattedDuration().ToString())) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreRight, }, }; @@ -278,17 +309,17 @@ protected override void PostUpdate() { new DiffPiece(stats) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, }, new DiffPiece(srAndModStats) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, } }; - beatmapPanel.Child = new TournamentBeatmapPanel(beatmap) + beatmapPanel.Child = new TournamentBeatmapPanel(beatmap, isGameplaySongBar: true) { Width = 500, CenterText = true,