Skip to content

Commit

Permalink
对Seeding界面进行更改
Browse files Browse the repository at this point in the history
  • Loading branch information
cdwcgt committed Dec 30, 2024
1 parent e81755b commit 2d39f2b
Showing 1 changed file with 50 additions and 33 deletions.
83 changes: 50 additions & 33 deletions osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Ladder.Components;
using osuTK;

namespace osu.Game.Tournament.Screens.TeamIntro
{
public partial class SeedingScreen : TournamentMatchScreen
public partial class SeedingScreen : TournamentScreen
{
private Container mainContainer = null!;

private readonly Bindable<TournamentTeam?> currentTeam = new Bindable<TournamentTeam?>();

private TourneyButton showFirstTeamButton = null!;
private TourneyButton showSecondTeamButton = null!;

[BackgroundDependencyLoader]
private void load()
{
Expand All @@ -47,21 +43,21 @@ private void load()
{
Children = new Drawable[]
{
showFirstTeamButton = new TourneyButton
new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Show first team",
Action = () => currentTeam.Value = CurrentMatch.Value?.Team1.Value,
Text = "上一个队伍",
Action = () => switchTeam(Direction.Previous)
},
showSecondTeamButton = new TourneyButton
new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Show second team",
Action = () => currentTeam.Value = CurrentMatch.Value?.Team2.Value,
Text = "下一个队伍",
Action = () => switchTeam(Direction.Next)
},
new SettingsTeamDropdown(LadderInfo.Teams)
{
LabelText = "Show specific team",
LabelText = "指定队伍",
Current = currentTeam,
}
}
Expand All @@ -71,32 +67,53 @@ private void load()
currentTeam.BindValueChanged(teamChanged, true);
}

private void teamChanged(ValueChangedEvent<TournamentTeam?> team) => updateTeamDisplay();

public override void Show()
private enum Direction
{
base.Show();

// Changes could have been made on editor screen.
// Rather than trying to track all the possibilities (teams / players / scores) just force a full refresh.
updateTeamDisplay();
Previous,
Next
}

protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
private void switchTeam(Direction direction)
{
base.CurrentMatchChanged(match);
int index = 0;

if (match.NewValue == null)
if (currentTeam.Value != null)
{
showFirstTeamButton.Enabled.Value = false;
showSecondTeamButton.Enabled.Value = false;
return;
index = LadderInfo.Teams.IndexOf(currentTeam.Value);
}

showFirstTeamButton.Enabled.Value = true;
showSecondTeamButton.Enabled.Value = true;
switch (direction)
{
case Direction.Previous:
index--;
break;

currentTeam.Value = match.NewValue.Team1.Value;
case Direction.Next:
index++;
break;
}

if (index < 0)
{
index = LadderInfo.Teams.Count - 1;
}
else if (index >= LadderInfo.Teams.Count)
{
index = 0;
}

currentTeam.Value = LadderInfo.Teams[index];
}

private void teamChanged(ValueChangedEvent<TournamentTeam?> team) => updateTeamDisplay();

public override void Show()
{
base.Show();

// Changes could have been made on editor screen.
// Rather than trying to track all the possibilities (teams / players / scores) just force a full refresh.
updateTeamDisplay();
}

private void updateTeamDisplay() => Scheduler.AddOnce(() =>
Expand Down Expand Up @@ -243,7 +260,7 @@ private void load(TextureStore textures)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = seeding.ToString("#,0"),
Text = $"#{seeding:#,0}",
Colour = TournamentGame.ELEMENT_FOREGROUND_COLOUR
},
}
Expand Down Expand Up @@ -271,9 +288,9 @@ public LeftInfo(TournamentTeam? team)
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new TeamDisplay(team) { Margin = new MarginPadding { Bottom = 30 } },
new RowDisplay("Average Rank:", $"#{team.AverageRank:#,0}"),
new RowDisplay("Seed:", team.Seed.Value),
new TeamDisplay(team) { Margin = new MarginPadding { Bottom = 30 }, },
new RowDisplay("平均排名:", $"#{team.AverageRank:#,0}"),
new RowDisplay("种子:", $"#{team.Seed.Value}"),
new Container { Margin = new MarginPadding { Bottom = 30 } },
}
},
Expand Down

0 comments on commit 2d39f2b

Please sign in to comment.