Skip to content

Commit

Permalink
修改GameplayScreen的SongBar
Browse files Browse the repository at this point in the history
  • Loading branch information
cdwcgt committed Jan 19, 2025
1 parent f1800ef commit a362124
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 20 deletions.
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Components/SongBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private void refreshContent()
}
}
},
new TournamentBeatmapPanel(beatmap)
new SongBarBeatmapPanel(beatmap)
{
RelativeSizeAxes = Axes.X,
Width = 0.5f,
Expand Down
37 changes: 37 additions & 0 deletions osu.Game.Tournament/Components/SongBarBeatmapPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics;
using osu.Game.Beatmaps;

namespace osu.Game.Tournament.Components
{
public partial class SongBarBeatmapPanel : TournamentBeatmapPanel
{
protected override bool TranslucentProtectedAfterPick => false;

public SongBarBeatmapPanel(IBeatmapInfo? beatmap)
: base(beatmap)
{
}

protected override void LoadComplete()
{
base.LoadComplete();

ModIconContainer.With(d =>
{
d.Anchor = Anchor.CentreRight;
d.Origin = Anchor.CentreRight;
d.Margin = new MarginPadding { Right = 20 };
});

PadLockContainer.With(d =>
{
d.Anchor = Anchor.CentreRight;
d.Origin = Anchor.CentreRight;
d.Margin = new MarginPadding { Right = 100 };
});
}
}
}
50 changes: 34 additions & 16 deletions osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,27 @@ public partial class TournamentBeatmapPanel : CompositeDrawable
{
public readonly IBeatmapInfo? Beatmap;

private readonly string? mod;
private string? mod;

public const float HEIGHT = 50;

private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();

private Box flash = null!;

protected Container PadLockContainer = null!;
private PadLock padLock = null!;
private readonly bool isMappool;

public TournamentBeatmapPanel(IBeatmapInfo? beatmap, string mod = "", bool isMappool = false)
protected Container ModIconContainer = null!;

[Resolved]
private LadderInfo ladderInfo { get; set; } = null!;

protected virtual bool TranslucentProtectedAfterPick => true;

public TournamentBeatmapPanel(IBeatmapInfo? beatmap)
{
Beatmap = beatmap;
this.mod = mod;
this.isMappool = isMappool;

Width = 400;
Height = HEIGHT;
Expand All @@ -53,6 +59,8 @@ private void load(LadderInfo ladder)

Masking = true;

mod = ladderInfo.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.Beatmap?.OnlineID == Beatmap?.OnlineID)?.Mods;

AddRangeInternal(new Drawable[]
{
new Box
Expand Down Expand Up @@ -113,11 +121,25 @@ private void load(LadderInfo ladder)
}
},
},
padLock = new PadLock
PadLockContainer = new Container
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Alpha = 0f,
AutoSizeAxes = Axes.Both,
Child = padLock = new PadLock
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Alpha = 0f,
},
},
ModIconContainer = new Container
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding(10),
Width = 60,
RelativeSizeAxes = Axes.Y,
},
flash = new Box
{
Expand All @@ -130,13 +152,9 @@ private void load(LadderInfo ladder)

if (!string.IsNullOrEmpty(mod))
{
AddInternal(new TournamentModIcon(mod)
ModIconContainer.Add(new TournamentModIcon(mod)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding(10),
Width = 60,
RelativeSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.Both,
});
}
}
Expand Down Expand Up @@ -164,17 +182,17 @@ private void updateState()
}

var found = currentMatch.Value.PicksBans.Where(p => p.BeatmapID == Beatmap?.OnlineID).ToList();
var foundProtected = isMappool ? found.FirstOrDefault(s => s.Type == ChoiceType.Protected) : null;
var foundProtected = found.FirstOrDefault(s => s.Type == ChoiceType.Protected);
var lastFound = found.LastOrDefault();

bool shouldFlash = lastFound != choice;

if (foundProtected != null && isMappool)
if (foundProtected != null)
{
padLock.Team = foundProtected.Team;
padLock.Show();

if (currentMatch.Value.PicksBans.Any(p => p.Type == ChoiceType.Pick))
if (currentMatch.Value.PicksBans.Any(p => p.Type == ChoiceType.Pick) && TranslucentProtectedAfterPick)
{
padLock.FadeTo(0.5f);
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void updatePanel() => Schedule(() =>

if (Model.Beatmap != null)
{
drawableContainer.Child = new TournamentBeatmapPanel(Model.Beatmap, Model.Mods)
drawableContainer.Child = new TournamentBeatmapPanel(Model.Beatmap)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private void updatePanel()

if (Model.Beatmap != null)
{
drawableContainer.Child = new TournamentBeatmapPanel(Model.Beatmap, result.Mod.Value)
drawableContainer.Child = new TournamentBeatmapPanel(Model.Beatmap)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private void updateDisplay()
flowCount = 1;
}

currentFlow.Add(new TournamentBeatmapPanel(b.Beatmap, b.Mods, true)
currentFlow.Add(new TournamentBeatmapPanel(b.Beatmap)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Expand Down

0 comments on commit a362124

Please sign in to comment.