mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Add headings
This commit is contained in:
parent
1644775f7b
commit
c7c55f2139
@ -0,0 +1,39 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder
|
||||
{
|
||||
public class DrawableTournamentGrouping : CompositeDrawable
|
||||
{
|
||||
public DrawableTournamentGrouping(TournamentGrouping grouping)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = grouping.Description.ToUpper(),
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = grouping.Name.ToUpper(),
|
||||
Font = "Exo2.0-Bold",
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -12,7 +14,6 @@ using osu.Framework.Input.States;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||
using OpenTK;
|
||||
using SixLabors.Primitives;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder
|
||||
@ -30,6 +31,7 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
public readonly List<TournamentTeam> Teams;
|
||||
private readonly Container<DrawableMatchPairing> pairingsContainer;
|
||||
private readonly Container<Path> paths;
|
||||
private readonly Container headings;
|
||||
|
||||
[Cached]
|
||||
private readonly LadderEditorInfo editorInfo = new LadderEditorInfo();
|
||||
@ -52,6 +54,7 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
Children = new Drawable[]
|
||||
{
|
||||
paths = new Container<Path> { RelativeSizeAxes = Axes.Both },
|
||||
headings = new Container() { RelativeSizeAxes = Axes.Both },
|
||||
pairingsContainer = new Container<DrawableMatchPairing> { RelativeSizeAxes = Axes.Both },
|
||||
}
|
||||
},
|
||||
@ -81,6 +84,9 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
foreach (var group in info.Groupings)
|
||||
foreach (var id in group.Pairings)
|
||||
info.Pairings.Single(p => p.ID == id).Grouping.Value = group;
|
||||
|
||||
// todo: fix this
|
||||
Scheduler.AddDelayed(() => layout.Invalidate(), 100, true);
|
||||
}
|
||||
|
||||
public LadderInfo CreateInfo()
|
||||
@ -121,11 +127,20 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
}
|
||||
}
|
||||
|
||||
private Cached layout = new Cached();
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!layout.IsValid)
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
private void updateLayout()
|
||||
{
|
||||
paths.Clear();
|
||||
headings.Clear();
|
||||
|
||||
int id = 1;
|
||||
foreach (var pairing in pairingsContainer.OrderBy(d => d.Y).ThenBy(d => d.X))
|
||||
@ -143,6 +158,22 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
paths.Add(new ProgressionPath(pairing, dest));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var group in editorInfo.Groupings)
|
||||
{
|
||||
var topPairing = pairingsContainer.Where(p => p.Pairing.Grouping.Value == group).OrderBy(p => p.Y).FirstOrDefault();
|
||||
|
||||
if (topPairing == null) continue;
|
||||
|
||||
headings.Add(new DrawableTournamentGrouping(group)
|
||||
{
|
||||
Position = headings.ToLocalSpace((topPairing.ScreenSpaceDrawQuad.TopLeft + topPairing.ScreenSpaceDrawQuad.TopRight) / 2),
|
||||
Margin = new MarginPadding { Bottom = 10 },
|
||||
Origin = Anchor.BottomCentre,
|
||||
});
|
||||
}
|
||||
|
||||
layout.Validate();
|
||||
}
|
||||
|
||||
public void RequestJoin(MatchPairing pairing) => AddInternal(new JoinRequestHandler(pairingsContainer, pairing));
|
||||
@ -201,17 +232,4 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
|
||||
public void Remove(MatchPairing pairing) => pairingsContainer.FirstOrDefault(p => p.Pairing == pairing)?.Remove();
|
||||
}
|
||||
|
||||
public class ScrollableContainer : Container
|
||||
{
|
||||
protected override bool OnDragStart(InputState state) => true;
|
||||
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
Position += state.Mouse.Delta;
|
||||
return base.OnDrag(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
22
osu.Game.Tournament/Screens/Ladder/ScrollableContainer.cs
Normal file
22
osu.Game.Tournament/Screens/Ladder/ScrollableContainer.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// 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.Graphics.Containers;
|
||||
using osu.Framework.Input.States;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder
|
||||
{
|
||||
public class ScrollableContainer : Container
|
||||
{
|
||||
protected override bool OnDragStart(InputState state) => true;
|
||||
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
Position += state.Mouse.Delta;
|
||||
return base.OnDrag(state);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user