2019-03-04 12:24:19 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-11-06 15:15:03 +08:00
|
|
|
|
2018-11-08 05:29:04 +08:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-02 12:40:43 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-11-06 13:49:09 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-11-08 05:29:04 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2018-11-18 08:29:18 +08:00
|
|
|
using osu.Framework.Threading;
|
2018-11-08 05:29:04 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-11-06 13:49:09 +08:00
|
|
|
using osu.Game.Tournament.Components;
|
2018-11-08 05:36:36 +08:00
|
|
|
using osu.Game.Tournament.IPC;
|
2019-06-18 13:51:48 +08:00
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-18 08:29:18 +08:00
|
|
|
using osu.Game.Tournament.Screens.Gameplay;
|
2018-11-15 20:28:42 +08:00
|
|
|
using osu.Game.Tournament.Screens.Gameplay.Components;
|
2018-11-22 09:25:30 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
using osuTK.Input;
|
2018-11-06 13:49:09 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.MapPool
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class MapPoolScreen : TournamentMatchScreen
|
2018-11-06 13:49:09 +08:00
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
private FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows = null!;
|
2018-11-08 05:29:04 +08:00
|
|
|
|
2023-07-30 00:57:44 +08:00
|
|
|
[Resolved]
|
2023-07-25 19:50:55 +08:00
|
|
|
private TournamentSceneManager? sceneManager { get; set; }
|
2019-06-14 16:20:15 +08:00
|
|
|
|
2018-11-08 05:36:36 +08:00
|
|
|
private TeamColour pickColour;
|
|
|
|
private ChoiceType pickType;
|
|
|
|
|
2023-07-25 19:50:55 +08:00
|
|
|
private OsuButton buttonRedBan = null!;
|
|
|
|
private OsuButton buttonBlueBan = null!;
|
|
|
|
private OsuButton buttonRedPick = null!;
|
|
|
|
private OsuButton buttonBluePick = null!;
|
2018-11-08 05:36:36 +08:00
|
|
|
|
2023-07-25 19:50:55 +08:00
|
|
|
private ScheduledDelegate? scheduledScreenChange;
|
2023-07-25 16:18:13 +08:00
|
|
|
|
2023-06-14 15:01:01 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(MatchIPCInfo ipc)
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
2018-11-06 13:49:09 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2020-05-15 03:51:39 +08:00
|
|
|
new TourneyVideo("mappool")
|
2020-03-07 12:51:11 +08:00
|
|
|
{
|
|
|
|
Loop = true,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2022-09-02 17:20:23 +08:00
|
|
|
new MatchHeader
|
|
|
|
{
|
|
|
|
ShowScores = true,
|
|
|
|
},
|
2018-11-17 15:06:43 +08:00
|
|
|
mapFlows = new FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>>
|
2018-11-06 13:49:09 +08:00
|
|
|
{
|
2020-03-13 13:09:09 +08:00
|
|
|
Y = 160,
|
2019-07-27 18:46:46 +08:00
|
|
|
Spacing = new Vector2(10, 10),
|
2018-11-17 15:06:43 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
2020-03-07 13:28:10 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-11-08 05:29:04 +08:00
|
|
|
},
|
|
|
|
new ControlPanel
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
new TournamentSpriteText
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
|
|
|
Text = "Current Mode"
|
|
|
|
},
|
2019-11-08 16:00:47 +08:00
|
|
|
buttonRedBan = new TourneyButton
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Red Ban",
|
|
|
|
Action = () => setMode(TeamColour.Red, ChoiceType.Ban)
|
|
|
|
},
|
2019-11-08 16:00:47 +08:00
|
|
|
buttonBlueBan = new TourneyButton
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Blue Ban",
|
|
|
|
Action = () => setMode(TeamColour.Blue, ChoiceType.Ban)
|
|
|
|
},
|
2019-11-08 16:00:47 +08:00
|
|
|
buttonRedPick = new TourneyButton
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Red Pick",
|
|
|
|
Action = () => setMode(TeamColour.Red, ChoiceType.Pick)
|
|
|
|
},
|
2019-11-08 16:00:47 +08:00
|
|
|
buttonBluePick = new TourneyButton
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Blue Pick",
|
|
|
|
Action = () => setMode(TeamColour.Blue, ChoiceType.Pick)
|
2018-11-08 05:47:42 +08:00
|
|
|
},
|
|
|
|
new ControlPanel.Spacer(),
|
2019-11-08 16:00:47 +08:00
|
|
|
new TourneyButton
|
2018-11-08 05:47:42 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Reset",
|
|
|
|
Action = reset
|
|
|
|
},
|
2020-03-07 13:28:10 +08:00
|
|
|
new ControlPanel.Spacer(),
|
2023-06-14 15:01:01 +08:00
|
|
|
new OsuCheckbox
|
2023-06-11 21:43:06 +08:00
|
|
|
{
|
2023-06-14 15:01:01 +08:00
|
|
|
LabelText = "Split display by mods",
|
|
|
|
Current = LadderInfo.SplitMapPoolByMods,
|
2023-06-11 21:43:06 +08:00
|
|
|
},
|
2021-07-16 22:34:28 +08:00
|
|
|
},
|
2018-11-06 13:49:09 +08:00
|
|
|
}
|
|
|
|
};
|
2023-06-14 15:01:01 +08:00
|
|
|
|
|
|
|
ipc.Beatmap.BindValueChanged(beatmapChanged);
|
2018-11-08 05:29:04 +08:00
|
|
|
}
|
|
|
|
|
2023-07-25 19:50:55 +08:00
|
|
|
private Bindable<bool>? splitMapPoolByMods;
|
2023-06-14 15:01:01 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
2018-11-08 05:36:36 +08:00
|
|
|
{
|
2023-06-14 15:01:01 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
splitMapPoolByMods = LadderInfo.SplitMapPoolByMods.GetBoundCopy();
|
|
|
|
splitMapPoolByMods.BindValueChanged(_ => updateDisplay());
|
2018-11-08 05:36:36 +08:00
|
|
|
}
|
|
|
|
|
2023-08-09 18:11:51 +08:00
|
|
|
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap?> beatmap)
|
2018-11-08 05:36:36 +08:00
|
|
|
{
|
2021-07-16 22:34:28 +08:00
|
|
|
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
|
2018-11-10 23:48:22 +08:00
|
|
|
return;
|
|
|
|
|
2019-06-14 15:23:38 +08:00
|
|
|
// if bans have already been placed, beatmap changes result in a selection being made autoamtically
|
2023-08-09 18:11:51 +08:00
|
|
|
if (beatmap.NewValue?.OnlineID > 0)
|
2021-10-27 16:22:23 +08:00
|
|
|
addForBeatmap(beatmap.NewValue.OnlineID);
|
2018-11-08 05:36:36 +08:00
|
|
|
}
|
2018-11-08 05:29:04 +08:00
|
|
|
|
|
|
|
private void setMode(TeamColour colour, ChoiceType choiceType)
|
|
|
|
{
|
|
|
|
pickColour = colour;
|
|
|
|
pickType = choiceType;
|
|
|
|
|
2019-11-12 18:37:20 +08:00
|
|
|
static Color4 setColour(bool active) => active ? Color4.White : Color4.Gray;
|
2018-11-08 05:29:04 +08:00
|
|
|
|
2018-11-08 05:47:42 +08:00
|
|
|
buttonRedBan.Colour = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Ban);
|
|
|
|
buttonBlueBan.Colour = setColour(pickColour == TeamColour.Blue && pickType == ChoiceType.Ban);
|
|
|
|
buttonRedPick.Colour = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Pick);
|
|
|
|
buttonBluePick.Colour = setColour(pickColour == TeamColour.Blue && pickType == ChoiceType.Pick);
|
2018-11-08 05:29:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setNextMode()
|
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
if (CurrentMatch.Value == null)
|
|
|
|
return;
|
|
|
|
|
2018-11-08 05:29:04 +08:00
|
|
|
const TeamColour roll_winner = TeamColour.Red; //todo: draw from match
|
|
|
|
|
2021-07-16 22:34:28 +08:00
|
|
|
var nextColour = (CurrentMatch.Value.PicksBans.LastOrDefault()?.Team ?? roll_winner) == TeamColour.Red ? TeamColour.Blue : TeamColour.Red;
|
2018-11-08 05:29:04 +08:00
|
|
|
|
2021-07-16 22:34:28 +08:00
|
|
|
if (pickType == ChoiceType.Ban && CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2)
|
2018-11-10 23:48:22 +08:00
|
|
|
setMode(pickColour, ChoiceType.Pick);
|
|
|
|
else
|
2021-07-16 22:34:28 +08:00
|
|
|
setMode(nextColour, CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2 ? ChoiceType.Pick : ChoiceType.Ban);
|
2018-11-08 05:29:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
|
|
|
{
|
2018-11-17 15:06:43 +08:00
|
|
|
var maps = mapFlows.Select(f => f.FirstOrDefault(m => m.ReceivePositionalInputAt(e.ScreenSpaceMousePosition)));
|
|
|
|
var map = maps.FirstOrDefault(m => m != null);
|
|
|
|
|
2018-11-08 05:29:04 +08:00
|
|
|
if (map != null)
|
|
|
|
{
|
2023-07-27 16:41:27 +08:00
|
|
|
if (e.Button == MouseButton.Left && map.Beatmap?.OnlineID > 0)
|
2021-10-27 17:25:23 +08:00
|
|
|
addForBeatmap(map.Beatmap.OnlineID);
|
2018-11-08 05:29:04 +08:00
|
|
|
else
|
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
var existing = CurrentMatch.Value?.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap?.OnlineID);
|
2019-05-15 11:08:23 +08:00
|
|
|
|
2018-11-08 05:29:04 +08:00
|
|
|
if (existing != null)
|
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
CurrentMatch.Value?.PicksBans.Remove(existing);
|
2018-11-08 05:29:04 +08:00
|
|
|
setNextMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.OnMouseDown(e);
|
|
|
|
}
|
2018-11-08 05:47:42 +08:00
|
|
|
|
|
|
|
private void reset()
|
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
CurrentMatch.Value?.PicksBans.Clear();
|
2018-11-08 05:47:42 +08:00
|
|
|
setNextMode();
|
|
|
|
}
|
2018-11-06 13:49:09 +08:00
|
|
|
|
2018-11-08 05:36:36 +08:00
|
|
|
private void addForBeatmap(int beatmapId)
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
if (CurrentMatch.Value?.Round.Value == null)
|
2018-11-08 12:08:59 +08:00
|
|
|
return;
|
|
|
|
|
2023-07-28 04:10:41 +08:00
|
|
|
if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.Beatmap?.OnlineID != beatmapId))
|
2018-11-08 05:36:36 +08:00
|
|
|
// don't attempt to add if the beatmap isn't in our pool
|
|
|
|
return;
|
|
|
|
|
2021-07-16 22:34:28 +08:00
|
|
|
if (CurrentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
|
2018-11-08 05:36:36 +08:00
|
|
|
// don't attempt to add if already exists.
|
|
|
|
return;
|
|
|
|
|
2021-07-16 22:34:28 +08:00
|
|
|
CurrentMatch.Value.PicksBans.Add(new BeatmapChoice
|
2018-11-08 05:36:36 +08:00
|
|
|
{
|
|
|
|
Team = pickColour,
|
|
|
|
Type = pickType,
|
|
|
|
BeatmapID = beatmapId
|
|
|
|
});
|
|
|
|
|
|
|
|
setNextMode();
|
2018-11-18 08:29:18 +08:00
|
|
|
|
2022-08-31 12:44:06 +08:00
|
|
|
if (LadderInfo.AutoProgressScreens.Value)
|
2018-11-18 08:29:18 +08:00
|
|
|
{
|
2022-08-31 12:44:06 +08:00
|
|
|
if (pickType == ChoiceType.Pick && CurrentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
|
|
|
|
{
|
2023-07-25 16:18:13 +08:00
|
|
|
scheduledScreenChange?.Cancel();
|
|
|
|
scheduledScreenChange = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(GameplayScreen)); }, 10000);
|
2022-08-31 12:44:06 +08:00
|
|
|
}
|
2018-11-18 08:29:18 +08:00
|
|
|
}
|
2023-07-23 06:08:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Hide()
|
|
|
|
{
|
2023-07-25 16:18:13 +08:00
|
|
|
scheduledScreenChange?.Cancel();
|
2023-07-23 06:08:20 +08:00
|
|
|
base.Hide();
|
2018-11-08 05:29:04 +08:00
|
|
|
}
|
|
|
|
|
2023-07-25 19:50:55 +08:00
|
|
|
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?> match)
|
2018-11-08 05:29:04 +08:00
|
|
|
{
|
2021-07-16 22:34:28 +08:00
|
|
|
base.CurrentMatchChanged(match);
|
2023-06-14 15:01:01 +08:00
|
|
|
updateDisplay();
|
2023-06-11 21:43:06 +08:00
|
|
|
}
|
2021-07-16 22:34:28 +08:00
|
|
|
|
2023-06-14 15:01:01 +08:00
|
|
|
private void updateDisplay()
|
2023-06-11 21:43:06 +08:00
|
|
|
{
|
2018-11-17 15:06:43 +08:00
|
|
|
mapFlows.Clear();
|
2018-11-08 19:14:50 +08:00
|
|
|
|
2023-06-14 15:01:01 +08:00
|
|
|
if (CurrentMatch.Value == null)
|
2021-07-16 22:34:28 +08:00
|
|
|
return;
|
2023-06-14 15:01:01 +08:00
|
|
|
|
2020-03-07 13:28:10 +08:00
|
|
|
int totalRows = 0;
|
|
|
|
|
2023-06-14 15:01:01 +08:00
|
|
|
if (CurrentMatch.Value.Round.Value != null)
|
2018-11-08 19:14:50 +08:00
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
FillFlowContainer<TournamentBeatmapPanel>? currentFlow = null;
|
|
|
|
string? currentMods = null;
|
2020-03-07 13:28:10 +08:00
|
|
|
int flowCount = 0;
|
|
|
|
|
2023-06-14 15:01:01 +08:00
|
|
|
foreach (var b in CurrentMatch.Value.Round.Value.Beatmaps)
|
2018-11-17 15:06:43 +08:00
|
|
|
{
|
2023-06-14 15:01:01 +08:00
|
|
|
if (currentFlow == null || (LadderInfo.SplitMapPoolByMods.Value && currentMods != b.Mods))
|
2018-11-17 15:06:43 +08:00
|
|
|
{
|
2023-06-14 15:01:01 +08:00
|
|
|
mapFlows.Add(currentFlow = new FillFlowContainer<TournamentBeatmapPanel>
|
2018-11-17 15:06:43 +08:00
|
|
|
{
|
2023-06-14 15:01:01 +08:00
|
|
|
Spacing = new Vector2(10, 5),
|
|
|
|
Direction = FillDirection.Full,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y
|
|
|
|
});
|
|
|
|
|
|
|
|
currentMods = b.Mods;
|
|
|
|
|
|
|
|
totalRows++;
|
|
|
|
flowCount = 0;
|
2020-03-07 13:28:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (++flowCount > 2)
|
|
|
|
{
|
|
|
|
totalRows++;
|
2020-03-11 14:34:52 +08:00
|
|
|
flowCount = 1;
|
2018-11-17 15:06:43 +08:00
|
|
|
}
|
|
|
|
|
2021-10-27 17:25:23 +08:00
|
|
|
currentFlow.Add(new TournamentBeatmapPanel(b.Beatmap, b.Mods)
|
2018-11-08 19:14:50 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2020-03-12 13:26:39 +08:00
|
|
|
Height = 42,
|
2018-11-08 19:14:50 +08:00
|
|
|
});
|
2018-11-17 15:06:43 +08:00
|
|
|
}
|
2018-11-08 19:14:50 +08:00
|
|
|
}
|
2020-03-07 13:28:10 +08:00
|
|
|
|
2020-03-13 13:25:25 +08:00
|
|
|
mapFlows.Padding = new MarginPadding(5)
|
|
|
|
{
|
2020-03-07 13:28:10 +08:00
|
|
|
// remove horizontal padding to increase flow width to 3 panels
|
2020-03-13 13:25:25 +08:00
|
|
|
Horizontal = totalRows > 9 ? 0 : 100
|
|
|
|
};
|
2018-11-06 13:49:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|