From ac6a103721723552957d052cba2d2021fe5b7a7e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2023 18:31:13 +0900 Subject: [PATCH 1/4] Add masking around ladder view --- osu.Game.Tournament/Screens/Ladder/LadderScreen.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs index 176c06c0e5..a74c9a9429 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs @@ -41,6 +41,7 @@ namespace osu.Game.Tournament.Screens.Ladder InternalChild = Content = new Container { RelativeSizeAxes = Axes.Both, + Masking = true, Children = new Drawable[] { new TourneyVideo("ladder") From ca14b4a35fec6f95e99e6dbb53e63575c2a63419 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2023 19:28:23 +0900 Subject: [PATCH 2/4] Move ladder editor controls to control panel --- .../Screens/Editors/LadderEditorScreen.cs | 7 ++--- .../Ladder/Components/LadderEditorSettings.cs | 31 ++++++++++++------- osu.Game.Tournament/TournamentSceneManager.cs | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs index 4ee3108034..e698e6e5b3 100644 --- a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs @@ -14,6 +14,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Framework.Input.States; using osu.Game.Graphics.UserInterface; +using osu.Game.Tournament.Components; using osu.Game.Tournament.Models; using osu.Game.Tournament.Screens.Ladder; using osu.Game.Tournament.Screens.Ladder.Components; @@ -35,11 +36,9 @@ namespace osu.Game.Tournament.Screens.Editors [BackgroundDependencyLoader] private void load() { - Content.Add(new LadderEditorSettings + AddInternal(new ControlPanel { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Margin = new MarginPadding(5) + Child = new LadderEditorSettings(), }); AddInternal(rightClickMessage = new WarningBox("Right click to place and link matches")); diff --git a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs index 5aea551c00..f5b6faaa3c 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs @@ -11,15 +11,17 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Game.Overlays.Settings; using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Tournament.Components; using osu.Game.Tournament.Models; +using osuTK; namespace osu.Game.Tournament.Screens.Ladder.Components { - public partial class LadderEditorSettings : PlayerSettingsGroup + public partial class LadderEditorSettings : CompositeDrawable { private SettingsDropdown roundDropdown; private PlayerCheckbox losersCheckbox; @@ -33,21 +35,26 @@ namespace osu.Game.Tournament.Screens.Ladder.Components [Resolved] private LadderInfo ladderInfo { get; set; } - public LadderEditorSettings() - : base("ladder") - { - } - [BackgroundDependencyLoader] private void load() { - Children = new Drawable[] + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChild = new FillFlowContainer { - 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" }, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(5), + 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 => diff --git a/osu.Game.Tournament/TournamentSceneManager.cs b/osu.Game.Tournament/TournamentSceneManager.cs index abfe69b97b..ae39d96d5d 100644 --- a/osu.Game.Tournament/TournamentSceneManager.cs +++ b/osu.Game.Tournament/TournamentSceneManager.cs @@ -38,7 +38,7 @@ namespace osu.Game.Tournament private Container screens; private TourneyVideo video; - public const float CONTROL_AREA_WIDTH = 160; + public const float CONTROL_AREA_WIDTH = 200; public const float STREAM_AREA_WIDTH = 1366; From fb4eaaeae990aab3cff3ff5d73c4cd30f28b5159 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2023 19:51:58 +0900 Subject: [PATCH 3/4] Add grid snapping to ladder editor --- .../Components/DrawableTournamentMatch.cs | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentMatch.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentMatch.cs index 33e383482f..2f59415d6e 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentMatch.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentMatch.cs @@ -213,7 +213,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components int instantWinAmount = Match.Round.Value.BestOf.Value / 2; 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() @@ -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 OnDragStart(DragStartEvent e) => editorInfo != null; - protected override bool OnKeyDown(KeyDownEvent e) { if (Selected && editorInfo != null && e.Key == Key.Delete) @@ -287,17 +286,36 @@ namespace osu.Game.Tournament.Screens.Ladder.Components 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) { base.OnDrag(e); Selected = true; - this.MoveToOffset(e.Delta); - var pos = Position; - Match.Position.Value = new Point((int)pos.X, (int)pos.Y); + this.MoveTo(snapToGrid(positionAtStartOfDrag + (e.MousePosition - e.MouseDownPosition))); + + 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() { Selected = false; From 97e572d4dad4f1e77ea1856f409cb770577f38e6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2023 19:56:24 +0900 Subject: [PATCH 4/4] Make dragging ladder more snappy --- osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs b/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs index 80b46007e7..3a2db4fc71 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderDragContainer.cs @@ -36,8 +36,8 @@ namespace osu.Game.Tournament.Screens.Ladder { 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.ScaleTo(scale = newScale, 2000, Easing.OutQuint); + this.MoveTo(target -= e.MousePosition * (newScale - scale), 1000, Easing.OutQuint); + this.ScaleTo(scale = newScale, 1000, Easing.OutQuint); return true; }