2019-03-04 04:24:19 +00: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-10-13 15:40:33 +00:00
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2018-12-01 00:50:11 +00:00
|
|
|
using System;
|
2018-11-07 21:29:04 +00:00
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Linq;
|
2018-10-13 15:40:33 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-03-02 04:40:43 +00:00
|
|
|
using osu.Framework.Bindables;
|
2018-10-13 15:40:33 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
using osu.Game.Graphics;
|
2021-01-24 22:29:05 +00:00
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-22 01:25:30 +00:00
|
|
|
using osuTK.Graphics;
|
2018-10-13 15:40:33 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Components
|
|
|
|
{
|
|
|
|
public partial class TournamentBeatmapPanel : CompositeDrawable
|
|
|
|
{
|
2022-06-17 22:34:09 +00:00
|
|
|
public readonly TournamentBeatmap Beatmap;
|
2021-10-20 09:43:48 +00:00
|
|
|
|
2021-01-25 12:22:37 +00:00
|
|
|
private readonly string mod;
|
2018-11-07 21:29:04 +00:00
|
|
|
|
2018-11-03 22:12:07 +00:00
|
|
|
public const float HEIGHT = 50;
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
2018-11-11 01:48:57 +00:00
|
|
|
private Box flash;
|
2018-11-07 21:29:04 +00:00
|
|
|
|
2022-06-17 22:34:09 +00:00
|
|
|
public TournamentBeatmapPanel(TournamentBeatmap beatmap, string mod = null)
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
2022-12-22 20:27:59 +00:00
|
|
|
ArgumentNullException.ThrowIfNull(beatmap);
|
2018-12-01 00:50:11 +00:00
|
|
|
|
2021-10-27 09:25:23 +00:00
|
|
|
Beatmap = beatmap;
|
2021-01-25 12:24:43 +00:00
|
|
|
this.mod = mod;
|
2021-10-20 09:43:48 +00:00
|
|
|
|
2018-10-13 15:40:33 +00:00
|
|
|
Width = 400;
|
2018-11-03 22:12:07 +00:00
|
|
|
Height = HEIGHT;
|
2018-10-13 15:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 00:06:39 +00:00
|
|
|
private void load(LadderInfo ladder)
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
2018-11-07 21:29:04 +00:00
|
|
|
currentMatch.BindValueChanged(matchChanged);
|
|
|
|
currentMatch.BindTo(ladder.CurrentMatch);
|
|
|
|
|
2018-10-13 15:40:33 +00:00
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
},
|
2021-10-21 07:53:50 +00:00
|
|
|
new UpdateableOnlineBeatmapSetCover
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.Gray(0.5f),
|
2022-06-17 22:34:09 +00:00
|
|
|
OnlineInfo = Beatmap,
|
2018-10-13 15:40:33 +00:00
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2020-03-08 05:46:09 +00:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2020-03-09 06:08:24 +00:00
|
|
|
Padding = new MarginPadding(15),
|
2018-10-13 15:40:33 +00:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-03 10:14:44 +00:00
|
|
|
new TournamentSpriteText
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
2021-11-01 05:33:24 +00:00
|
|
|
Text = Beatmap.GetDisplayTitleRomanisable(false, false),
|
2020-03-03 10:14:44 +00:00
|
|
|
Font = OsuFont.Torus.With(weight: FontWeight.Bold),
|
2018-10-13 15:40:33 +00:00
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-03 10:14:44 +00:00
|
|
|
new TournamentSpriteText
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
|
|
|
Text = "mapper",
|
|
|
|
Padding = new MarginPadding { Right = 5 },
|
2020-03-03 10:14:44 +00:00
|
|
|
Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14)
|
2018-10-13 15:40:33 +00:00
|
|
|
},
|
2020-03-03 10:14:44 +00:00
|
|
|
new TournamentSpriteText
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
2021-11-04 09:22:21 +00:00
|
|
|
Text = Beatmap.Metadata.Author.Username,
|
2018-10-13 15:40:33 +00:00
|
|
|
Padding = new MarginPadding { Right = 20 },
|
2020-03-03 10:14:44 +00:00
|
|
|
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
2018-10-13 15:40:33 +00:00
|
|
|
},
|
2020-03-03 10:14:44 +00:00
|
|
|
new TournamentSpriteText
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
|
|
|
Text = "difficulty",
|
|
|
|
Padding = new MarginPadding { Right = 5 },
|
2020-03-03 10:14:44 +00:00
|
|
|
Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14)
|
2018-10-13 15:40:33 +00:00
|
|
|
},
|
2020-03-03 10:14:44 +00:00
|
|
|
new TournamentSpriteText
|
2018-10-13 15:40:33 +00:00
|
|
|
{
|
2021-10-27 09:25:23 +00:00
|
|
|
Text = Beatmap.DifficultyName,
|
2020-03-03 10:14:44 +00:00
|
|
|
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
2018-10-13 15:40:33 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2018-11-11 01:48:57 +00:00
|
|
|
flash = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Gray,
|
2019-08-21 04:29:50 +00:00
|
|
|
Blending = BlendingParameters.Additive,
|
2018-11-11 01:48:57 +00:00
|
|
|
Alpha = 0,
|
|
|
|
},
|
2018-10-13 15:40:33 +00:00
|
|
|
});
|
2018-11-17 07:00:12 +00:00
|
|
|
|
2021-01-25 12:22:37 +00:00
|
|
|
if (!string.IsNullOrEmpty(mod))
|
2019-11-11 11:53:22 +00:00
|
|
|
{
|
2021-01-26 10:15:19 +00:00
|
|
|
AddInternal(new TournamentModIcon(mod)
|
2018-11-17 07:00:12 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
2021-01-25 12:22:37 +00:00
|
|
|
Margin = new MarginPadding(10),
|
|
|
|
Width = 60,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2018-11-17 07:00:12 +00:00
|
|
|
});
|
2019-11-11 11:53:22 +00:00
|
|
|
}
|
2018-10-13 15:40:33 +00:00
|
|
|
}
|
2018-11-07 21:29:04 +00:00
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
|
2018-11-07 21:29:04 +00:00
|
|
|
{
|
2019-06-18 05:57:05 +00:00
|
|
|
if (match.OldValue != null)
|
|
|
|
match.OldValue.PicksBans.CollectionChanged -= picksBansOnCollectionChanged;
|
|
|
|
match.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged;
|
2018-11-07 21:29:04 +00:00
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
|
2019-05-20 05:47:46 +00:00
|
|
|
private void picksBansOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
=> updateState();
|
|
|
|
|
2018-11-11 01:48:57 +00:00
|
|
|
private BeatmapChoice choice;
|
|
|
|
|
2018-11-07 21:29:04 +00:00
|
|
|
private void updateState()
|
|
|
|
{
|
2021-10-27 09:25:23 +00:00
|
|
|
var found = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == Beatmap.OnlineID);
|
2018-11-07 21:29:04 +00:00
|
|
|
|
2018-11-11 01:48:57 +00:00
|
|
|
bool doFlash = found != choice;
|
|
|
|
choice = found;
|
|
|
|
|
2018-11-07 21:29:04 +00:00
|
|
|
if (found != null)
|
|
|
|
{
|
2018-11-11 01:48:57 +00:00
|
|
|
if (doFlash)
|
2018-11-11 16:25:31 +00:00
|
|
|
flash?.FadeOutFromOne(500).Loop(0, 10);
|
2018-11-11 01:48:57 +00:00
|
|
|
|
2018-11-07 21:47:42 +00:00
|
|
|
BorderThickness = 6;
|
|
|
|
|
2020-03-07 04:51:11 +00:00
|
|
|
BorderColour = TournamentGame.GetTeamColour(found.Team);
|
2018-11-07 21:47:42 +00:00
|
|
|
|
|
|
|
switch (found.Type)
|
|
|
|
{
|
|
|
|
case ChoiceType.Pick:
|
|
|
|
Colour = Color4.White;
|
|
|
|
Alpha = 1;
|
|
|
|
break;
|
2019-05-15 03:08:23 +00:00
|
|
|
|
2018-11-07 21:47:42 +00:00
|
|
|
case ChoiceType.Ban:
|
|
|
|
Colour = Color4.Gray;
|
|
|
|
Alpha = 0.5f;
|
2018-11-07 21:29:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Colour = Color4.White;
|
2018-11-07 21:47:42 +00:00
|
|
|
BorderThickness = 0;
|
|
|
|
Alpha = 1;
|
2018-11-07 21:29:04 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-13 15:40:33 +00:00
|
|
|
}
|
|
|
|
}
|