1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

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>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -9,13 +10,13 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
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;
public TestCaseGroupingManager()
public GroupingsEditorScreen()
{
Add(new FillFlowContainer
{
@ -37,29 +38,37 @@ namespace osu.Game.Tournament.Tests
},
}
});
}
[BackgroundDependencyLoader]
private void load()
{
foreach (var g in Ladder.Groupings)
items.Add(new GroupingRow(g));
foreach (var g in LadderInfo.Groupings)
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.Dispose(isDisposing);
base.LoadComplete();
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 readonly TournamentGrouping Grouping;
public GroupingRow(TournamentGrouping grouping)
public GroupingRow(TournamentGrouping grouping, Action onDelete)
{
Grouping = grouping;
InternalChildren = new Drawable[]
@ -77,7 +86,11 @@ namespace osu.Game.Tournament.Tests
{
Width = 0.1f,
Text = "Delete",
Action = () => Expire()
Action = () =>
{
Expire();
onDelete();
}
},
}
}

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
@ -115,5 +116,15 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
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;
[Resolved]
protected LadderInfo LadderInfo { get; private set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{

View File

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

View File

@ -1,6 +1,7 @@
// 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.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Screens;
@ -8,6 +9,9 @@ namespace osu.Game.Tournament.Screens
{
public class TournamentScreen : OsuScreen
{
[Resolved]
protected LadderInfo LadderInfo { get; private set; }
public override void Hide()
{
this.FadeOut(200);