Expose groupings editor

This commit is contained in:
Dean Herbert 2018-11-16 20:30:12 +09:00
parent 67bb428aef
commit cf0976955b
6 changed files with 59 additions and 15 deletions

View File

@ -0,0 +1,15 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Tournament.Screens.Groupings;
namespace osu.Game.Tournament.Tests
{
public class TestCaseGroupingsEditorScreen : LadderTestCase
{
public TestCaseGroupingsEditorScreen()
{
Add(new GroupingsEditorScreen());
}
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -9,13 +10,13 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Screens.Ladder.Components; using osu.Game.Tournament.Screens.Ladder.Components;
namespace osu.Game.Tournament.Tests namespace osu.Game.Tournament.Screens.Groupings
{ {
public class TestCaseGroupingManager : LadderTestCase public class GroupingsEditorScreen : TournamentScreen, IProvideVideo
{ {
private readonly FillFlowContainer<GroupingRow> items; private readonly FillFlowContainer<GroupingRow> items;
public TestCaseGroupingManager() public GroupingsEditorScreen()
{ {
Add(new FillFlowContainer Add(new FillFlowContainer
{ {
@ -37,29 +38,37 @@ namespace osu.Game.Tournament.Tests
}, },
} }
}); });
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
foreach (var g in Ladder.Groupings) foreach (var g in LadderInfo.Groupings)
items.Add(new GroupingRow(g)); items.Add(new GroupingRow(g, updateGroupings));
} }
protected override void Dispose(bool isDisposing) protected override void LoadComplete()
{ {
Ladder.Groupings = items.Children.Select(c => c.Grouping).ToList(); base.LoadComplete();
base.Dispose(isDisposing); Scheduler.AddDelayed(() => LadderInfo.Groupings = items.Children.Select(c => c.Grouping).ToList(), 500, true);
} }
private void addNew() => items.Add(new GroupingRow(new TournamentGrouping())); private void addNew()
{
items.Add(new GroupingRow(new TournamentGrouping(), updateGroupings));
updateGroupings();
}
private void updateGroupings()
{
LadderInfo.Groupings = items.Children.Select(c => c.Grouping).ToList();
}
public class GroupingRow : CompositeDrawable public class GroupingRow : CompositeDrawable
{ {
public readonly TournamentGrouping Grouping; public readonly TournamentGrouping Grouping;
public GroupingRow(TournamentGrouping grouping) public GroupingRow(TournamentGrouping grouping, Action onDelete)
{ {
Grouping = grouping; Grouping = grouping;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
@ -77,7 +86,11 @@ namespace osu.Game.Tournament.Tests
{ {
Width = 0.1f, Width = 0.1f,
Text = "Delete", Text = "Delete",
Action = () => Expire() Action = () =>
{
Expire();
onDelete();
}
}, },
} }
} }

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
@ -115,5 +116,15 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
editorInfo.Selected.Value.Losers.Value = losers; editorInfo.Selected.Value.Losers.Value = losers;
}; };
} }
protected override bool OnHover(HoverEvent e)
{
return false;
}
protected override void OnHoverLost(HoverLostEvent e)
{
}
} }
} }

View File

@ -22,9 +22,6 @@ namespace osu.Game.Tournament.Screens.Ladder
protected ScrollableContainer ScrollContent; protected ScrollableContainer ScrollContent;
[Resolved]
protected LadderInfo LadderInfo { get; private set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {

View File

@ -11,6 +11,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Tournament.Screens.Drawings; using osu.Game.Tournament.Screens.Drawings;
using osu.Game.Tournament.Screens.Gameplay; using osu.Game.Tournament.Screens.Gameplay;
using osu.Game.Tournament.Screens.Groupings;
using osu.Game.Tournament.Screens.Ladder; using osu.Game.Tournament.Screens.Ladder;
using osu.Game.Tournament.Screens.MapPool; using osu.Game.Tournament.Screens.MapPool;
using osu.Game.Tournament.Screens.Schedule; using osu.Game.Tournament.Screens.Schedule;
@ -27,6 +28,7 @@ namespace osu.Game.Tournament.Screens
private ScheduleScreen schedule; private ScheduleScreen schedule;
private LadderScreen bracket; private LadderScreen bracket;
private LadderEditorScreen bracketEditor; private LadderEditorScreen bracketEditor;
private GroupingsEditorScreen groupingsEditor;
private MapPoolScreen mapPool; private MapPoolScreen mapPool;
private GameplayScreen gameplay; private GameplayScreen gameplay;
private TeamWinScreen winner; private TeamWinScreen winner;
@ -59,6 +61,7 @@ namespace osu.Game.Tournament.Screens
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => setScreen(bracketEditor) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => setScreen(bracketEditor) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Groupings Editor", Action = () => setScreen(groupingsEditor) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 }, new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => setScreen(drawings) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => setScreen(drawings) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => setScreen(showcase) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => setScreen(showcase) },
@ -101,6 +104,7 @@ namespace osu.Game.Tournament.Screens
schedule = new ScheduleScreen(), schedule = new ScheduleScreen(),
bracket = new LadderScreen(), bracket = new LadderScreen(),
bracketEditor = new LadderEditorScreen(), bracketEditor = new LadderEditorScreen(),
groupingsEditor = new GroupingsEditorScreen(),
showcase = new ShowcaseScreen(), showcase = new ShowcaseScreen(),
mapPool = new MapPoolScreen(), mapPool = new MapPoolScreen(),
teamIntro = new TeamIntroScreen(), teamIntro = new TeamIntroScreen(),

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Screens; using osu.Game.Screens;
@ -8,6 +9,9 @@ namespace osu.Game.Tournament.Screens
{ {
public class TournamentScreen : OsuScreen public class TournamentScreen : OsuScreen
{ {
[Resolved]
protected LadderInfo LadderInfo { get; private set; }
public override void Hide() public override void Hide()
{ {
this.FadeOut(200); this.FadeOut(200);