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

Add schedule screen

This commit is contained in:
Dean Herbert 2018-11-11 10:13:17 +09:00
parent 949cf98d1a
commit eabcef3e12
8 changed files with 221 additions and 17 deletions

View File

@ -0,0 +1,25 @@
// 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.Collections.Generic;
using osu.Framework.Allocation;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Screens.Schedule;
namespace osu.Game.Tournament.Tests
{
public class TestCaseSchedule : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ScheduleScreen)
};
[BackgroundDependencyLoader]
private void load()
{
Add(new ScheduleScreen());
}
}
}

View File

@ -18,7 +18,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
public class DrawableMatchPairing : CompositeDrawable
{
public readonly MatchPairing Pairing;
private readonly FillFlowContainer<DrawableMatchTeam> flow;
protected readonly FillFlowContainer<DrawableMatchTeam> Flow;
private readonly Drawable selectionBox;
private readonly Drawable currentMatchSelectionBox;
private Bindable<MatchPairing> globalSelection;
@ -62,7 +62,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
Colour = Color4.OrangeRed,
Child = new Box { RelativeSizeAxes = Axes.Both }
},
flow = new FillFlowContainer<DrawableMatchTeam>
Flow = new FillFlowContainer<DrawableMatchTeam>
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
@ -195,7 +195,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
if (Pairing.Team1.Value == null || Pairing.Team2.Value == null)
Pairing.CancelMatchStart();
flow.Children = new[]
Flow.Children = new[]
{
new DrawableMatchTeam(Pairing.Team1, Pairing, Pairing.Losers),
new DrawableMatchTeam(Pairing.Team2, Pairing, Pairing.Losers)

View File

@ -36,6 +36,19 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
private readonly Func<bool> isWinner;
private LadderManager manager;
[Resolved]
private LadderInfo ladderInfo { get; set; }
private void setCurrent()
{
//todo: tournamentgamebase?
if (ladderInfo.CurrentMatch.Value != null)
ladderInfo.CurrentMatch.Value.Current.Value = false;
ladderInfo.CurrentMatch.Value = pairing;
ladderInfo.CurrentMatch.Value.Current.Value = true;
}
[Resolved(CanBeNull = true)]
private LadderEditorInfo editorInfo { get; set; }
@ -132,7 +145,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
if (!pairing.Current.Value)
{
manager.SetCurrent(pairing);
setCurrent();
return true;
}
@ -182,7 +195,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
return new MenuItem[]
{
new OsuMenuItem("Set as current", MenuItemType.Standard, () => manager.SetCurrent(pairing)),
new OsuMenuItem("Set as current", MenuItemType.Standard, setCurrent),
new OsuMenuItem("Join with", MenuItemType.Standard, () => manager.RequestJoin(pairing, false)),
new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => manager.RequestJoin(pairing, true)),
new OsuMenuItem("Remove", MenuItemType.Destructive, () => manager.Remove(pairing)),

View File

@ -31,8 +31,8 @@ namespace osu.Game.Tournament.Screens.Ladder
private ScrollableContainer scrollContent;
[Cached]
private LadderEditorInfo editorInfo = new LadderEditorInfo();
[Resolved]
private LadderEditorInfo editorInfo { get; set;}
[Resolved]
private LadderInfo ladderInfo { get; set; }
@ -185,15 +185,6 @@ namespace osu.Game.Tournament.Screens.Ladder
public void Remove(MatchPairing pairing) => pairingsContainer.FirstOrDefault(p => p.Pairing == pairing)?.Remove();
public void SetCurrent(MatchPairing pairing)
{
if (ladderInfo.CurrentMatch.Value != null)
ladderInfo.CurrentMatch.Value.Current.Value = false;
ladderInfo.CurrentMatch.Value = pairing;
ladderInfo.CurrentMatch.Value.Current.Value = true;
}
private class JoinRequestHandler : CompositeDrawable
{
private readonly Container<DrawableMatchPairing> pairingsContainer;

View File

@ -0,0 +1,167 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Video;
using osu.Framework.Platform;
using osu.Game.Graphics.Sprites;
using osu.Game.Tournament.Screens.Ladder.Components;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Tournament.Screens.Schedule
{
public class ScheduleScreen : TournamentScreen, IProvideVideo
{
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
private Container mainContainer;
private LadderInfo ladder;
[BackgroundDependencyLoader]
private void load(LadderInfo ladder, Storage storage)
{
this.ladder = ladder;
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new VideoSprite(storage.GetStream(@"BG Side Logo - OWC.m4v"))
{
RelativeSizeAxes = Axes.Both,
Loop = true,
},
mainContainer = new Container
{
RelativeSizeAxes = Axes.Both,
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
}
private void matchChanged(MatchPairing pairing)
{
if (pairing == null)
{
mainContainer.Clear();
return;
}
mainContainer.Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Height = 0.65f,
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new ScheduleContainer("recent matches")
{
RelativeSizeAxes = Axes.Both,
Width = 0.4f,
ChildrenEnumerable = ladder.Pairings
.Where(p => p.Completed.Value)
.OrderByDescending(p => p.Date.Value)
.Take(8)
.Select(p => new SchedulePairing(p))
},
new ScheduleContainer("match overview")
{
RelativeSizeAxes = Axes.Both,
Width = 0.6f,
ChildrenEnumerable = ladder.Pairings
.Where(p => !p.Completed.Value)
.OrderBy(p => p.Date.Value)
.Take(8)
.Select(p => new SchedulePairing(p))
},
}
}
},
new ScheduleContainer("current match")
{
RelativeSizeAxes = Axes.Both,
Height = 0.25f,
Children = new Drawable[]
{
new OsuSpriteText
{
Margin = new MarginPadding { Left = -10, Bottom = 10, Top = -5 },
Spacing = new Vector2(10, 0),
Text = currentMatch.Value.Grouping.Value.Name.Value,
Colour = Color4.Black,
TextSize = 20
},
new SchedulePairing(currentMatch),
new OsuSpriteText
{
Text = "Start Time " + pairing.Date.Value.ToUniversalTime().ToString("HH:mm UTC"),
Colour = Color4.Black,
TextSize = 20
},
}
}
}
};
}
public class SchedulePairing : DrawableMatchPairing
{
public SchedulePairing(MatchPairing pairing)
: base(pairing)
{
Flow.Direction = FillDirection.Horizontal;
}
}
public class ScheduleContainer : Container
{
protected override Container<Drawable> Content => content;
private readonly FillFlowContainer content;
public ScheduleContainer(string title)
{
Padding = new MarginPadding { Left = 30, Top = 30 };
InternalChildren = new Drawable[]
{
new OsuSpriteText
{
X = 30,
Text = title,
Colour = Color4.Black,
Spacing = new Vector2(10, 0),
TextSize = 30
},
content = new FillFlowContainer
{
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding(40)
},
new Circle
{
Colour = new Color4(233, 187, 79, 255),
Width = 5,
RelativeSizeAxes = Axes.Y,
}
};
}
}
}
}

View File

@ -13,6 +13,7 @@ using osu.Game.Tournament.Screens.Drawings;
using osu.Game.Tournament.Screens.Gameplay;
using osu.Game.Tournament.Screens.Ladder;
using osu.Game.Tournament.Screens.MapPool;
using osu.Game.Tournament.Screens.Schedule;
using osu.Game.Tournament.Screens.Showcase;
using osu.Game.Tournament.Screens.TeamIntro;
using OpenTK;
@ -22,6 +23,7 @@ namespace osu.Game.Tournament.Screens
{
public class TournamentSceneManager : OsuScreen
{
private ScheduleScreen schedule;
private LadderManager bracket;
private MapPoolScreen mapPool;
private GameplayScreen gameplay;
@ -56,6 +58,7 @@ namespace osu.Game.Tournament.Screens
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => setScreen(drawings) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => setScreen(showcase) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Schedule", Action = () => setScreen(schedule) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => setScreen(bracket) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => setScreen(teamIntro) },
@ -88,6 +91,7 @@ namespace osu.Game.Tournament.Screens
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
schedule = new ScheduleScreen(),
bracket = new LadderManager(),
showcase = new ShowcaseScreen(),
mapPool = new MapPoolScreen(),

View File

@ -19,6 +19,7 @@ using osu.Game.Online.API.Requests;
using osu.Game.Rulesets;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Screens.Ladder.Components;
namespace osu.Game.Tournament
{
@ -34,6 +35,9 @@ namespace osu.Game.Tournament
[Cached]
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
[Cached]
private LadderEditorInfo editorInfo = new LadderEditorInfo();
private Bindable<Size> windowSize;
private FileBasedIPC ipc;

View File

@ -297,7 +297,7 @@ namespace osu.Game
}
public override bool EnableDrag => true; // allow right-mouse dragging for absolute scroll in scroll containers.
public override bool EnableClick => false;
public override bool EnableClick => true;
public override bool ChangeFocusOnClick => false;
}
}