Skip to content

Commit

Permalink
游玩界面的歌曲显示新设计
Browse files Browse the repository at this point in the history
  • Loading branch information
cdwcgt committed Dec 17, 2024
1 parent 8a449c8 commit 78e41fb
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 58 deletions.
161 changes: 121 additions & 40 deletions osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -274,6 +238,123 @@ private void matchChanged(ValueChangedEvent<TournamentMatch?> 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);

Expand Down
67 changes: 49 additions & 18 deletions osu.Game.Tournament/Screens/Gameplay/Components/GameplaySongBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down Expand Up @@ -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,
}
},
Expand All @@ -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
Expand All @@ -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,
}
},
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -260,35 +285,41 @@ 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,
},
};

rightData.Children = new Drawable[]
{
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,
Expand Down

0 comments on commit 78e41fb

Please sign in to comment.