1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 10:43:04 +08:00

Merge pull request #24308 from peppy/tournament-ladder-improvements

General improvements to tournament client ladder editor
This commit is contained in:
Bartłomiej Dach 2023-07-20 21:40:57 +02:00 committed by GitHub
commit fedf830b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 25 deletions

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Input.States; using osu.Framework.Input.States;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Ladder; using osu.Game.Tournament.Screens.Ladder;
using osu.Game.Tournament.Screens.Ladder.Components; using osu.Game.Tournament.Screens.Ladder.Components;
@ -35,11 +36,9 @@ namespace osu.Game.Tournament.Screens.Editors
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Content.Add(new LadderEditorSettings AddInternal(new ControlPanel
{ {
Anchor = Anchor.TopRight, Child = new LadderEditorSettings(),
Origin = Anchor.TopRight,
Margin = new MarginPadding(5)
}); });
AddInternal(rightClickMessage = new WarningBox("Right click to place and link matches")); AddInternal(rightClickMessage = new WarningBox("Right click to place and link matches"));

View File

@ -213,7 +213,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
int instantWinAmount = Match.Round.Value.BestOf.Value / 2; int instantWinAmount = Match.Round.Value.BestOf.Value / 2;
Match.Completed.Value = Match.Round.Value.BestOf.Value > 0 Match.Completed.Value = Match.Round.Value.BestOf.Value > 0
&& (Match.Team1Score.Value + Match.Team2Score.Value >= Match.Round.Value.BestOf.Value || Match.Team1Score.Value > instantWinAmount || Match.Team2Score.Value > instantWinAmount); && (Match.Team1Score.Value + Match.Team2Score.Value >= Match.Round.Value.BestOf.Value || Match.Team1Score.Value > instantWinAmount
|| Match.Team2Score.Value > instantWinAmount);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -265,8 +266,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
protected override bool OnMouseDown(MouseDownEvent e) => e.Button == MouseButton.Left && editorInfo != null; protected override bool OnMouseDown(MouseDownEvent e) => e.Button == MouseButton.Left && editorInfo != null;
protected override bool OnDragStart(DragStartEvent e) => editorInfo != null;
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (Selected && editorInfo != null && e.Key == Key.Delete) if (Selected && editorInfo != null && e.Key == Key.Delete)
@ -287,17 +286,36 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
return true; return true;
} }
private Vector2 positionAtStartOfDrag;
protected override bool OnDragStart(DragStartEvent e)
{
if (editorInfo != null)
{
positionAtStartOfDrag = Position;
return true;
}
return false;
}
protected override void OnDrag(DragEvent e) protected override void OnDrag(DragEvent e)
{ {
base.OnDrag(e); base.OnDrag(e);
Selected = true; Selected = true;
this.MoveToOffset(e.Delta);
var pos = Position; this.MoveTo(snapToGrid(positionAtStartOfDrag + (e.MousePosition - e.MouseDownPosition)));
Match.Position.Value = new Point((int)pos.X, (int)pos.Y);
Match.Position.Value = new Point((int)Position.X, (int)Position.Y);
} }
private Vector2 snapToGrid(Vector2 pos) =>
new Vector2(
(int)(pos.X / 10) * 10,
(int)(pos.Y / 10) * 10
);
public void Remove() public void Remove()
{ {
Selected = false; Selected = false;

View File

@ -11,15 +11,17 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osuTK;
namespace osu.Game.Tournament.Screens.Ladder.Components namespace osu.Game.Tournament.Screens.Ladder.Components
{ {
public partial class LadderEditorSettings : PlayerSettingsGroup public partial class LadderEditorSettings : CompositeDrawable
{ {
private SettingsDropdown<TournamentRound> roundDropdown; private SettingsDropdown<TournamentRound> roundDropdown;
private PlayerCheckbox losersCheckbox; private PlayerCheckbox losersCheckbox;
@ -33,21 +35,26 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
[Resolved] [Resolved]
private LadderInfo ladderInfo { get; set; } private LadderInfo ladderInfo { get; set; }
public LadderEditorSettings()
: base("ladder")
{
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Children = new Drawable[] RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChild = new FillFlowContainer
{ {
team1Dropdown = new SettingsTeamDropdown(ladderInfo.Teams) { LabelText = "Team 1" }, RelativeSizeAxes = Axes.X,
team2Dropdown = new SettingsTeamDropdown(ladderInfo.Teams) { LabelText = "Team 2" }, AutoSizeAxes = Axes.Y,
roundDropdown = new SettingsRoundDropdown(ladderInfo.Rounds) { LabelText = "Round" }, Direction = FillDirection.Vertical,
losersCheckbox = new PlayerCheckbox { LabelText = "Losers Bracket" }, Spacing = new Vector2(5),
dateTimeBox = new DateTextBox { LabelText = "Match Time" }, Children = new Drawable[]
{
team1Dropdown = new SettingsTeamDropdown(ladderInfo.Teams) { LabelText = "Team 1" },
team2Dropdown = new SettingsTeamDropdown(ladderInfo.Teams) { LabelText = "Team 2" },
roundDropdown = new SettingsRoundDropdown(ladderInfo.Rounds) { LabelText = "Round" },
losersCheckbox = new PlayerCheckbox { LabelText = "Losers Bracket" },
dateTimeBox = new DateTextBox { LabelText = "Match Time" },
},
}; };
editorInfo.Selected.ValueChanged += selection => editorInfo.Selected.ValueChanged += selection =>

View File

@ -36,8 +36,8 @@ namespace osu.Game.Tournament.Screens.Ladder
{ {
float newScale = Math.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale); float newScale = Math.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale);
this.MoveTo(target -= e.MousePosition * (newScale - scale), 2000, Easing.OutQuint); this.MoveTo(target -= e.MousePosition * (newScale - scale), 1000, Easing.OutQuint);
this.ScaleTo(scale = newScale, 2000, Easing.OutQuint); this.ScaleTo(scale = newScale, 1000, Easing.OutQuint);
return true; return true;
} }

View File

@ -41,6 +41,7 @@ namespace osu.Game.Tournament.Screens.Ladder
InternalChild = Content = new Container InternalChild = Content = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[] Children = new Drawable[]
{ {
new TourneyVideo("ladder") new TourneyVideo("ladder")

View File

@ -38,7 +38,7 @@ namespace osu.Game.Tournament
private Container screens; private Container screens;
private TourneyVideo video; private TourneyVideo video;
public const float CONTROL_AREA_WIDTH = 160; public const float CONTROL_AREA_WIDTH = 200;
public const float STREAM_AREA_WIDTH = 1366; public const float STREAM_AREA_WIDTH = 1366;