2017-05-05 12:00:05 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using OpenTK;
|
2017-05-05 12:17:36 +08:00
|
|
|
|
using osu.Framework.Input;
|
2017-05-20 13:56:00 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-06-27 10:17:21 +08:00
|
|
|
|
using System.Linq;
|
2017-05-05 12:00:05 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
|
{
|
|
|
|
|
public class ModDisplay : Container, IHasCurrentValue<IEnumerable<Mod>>
|
|
|
|
|
{
|
2017-06-27 10:17:21 +08:00
|
|
|
|
private const int fade_duration = 1000;
|
|
|
|
|
|
2017-05-05 12:00:05 +08:00
|
|
|
|
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
|
|
|
|
|
|
|
|
|
|
public Bindable<IEnumerable<Mod>> Current => mods;
|
|
|
|
|
|
|
|
|
|
private readonly FillFlowContainer<ModIcon> iconsContainer;
|
2017-06-27 10:17:21 +08:00
|
|
|
|
private readonly OsuSpriteText unrankedText;
|
2017-05-05 12:00:05 +08:00
|
|
|
|
|
|
|
|
|
public ModDisplay()
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-20 13:56:00 +08:00
|
|
|
|
iconsContainer = new ReverseDepthFillFlowContainer<ModIcon>
|
2017-05-05 12:00:05 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Margin = new MarginPadding { Left = 10, Right = 10 },
|
|
|
|
|
},
|
2017-06-27 10:17:21 +08:00
|
|
|
|
unrankedText = new OsuSpriteText
|
2017-05-05 12:00:05 +08:00
|
|
|
|
{
|
2017-06-27 10:17:21 +08:00
|
|
|
|
AlwaysPresent = true,
|
2017-05-05 12:00:05 +08:00
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Text = @"/ UNRANKED /",
|
|
|
|
|
Font = @"Venera",
|
|
|
|
|
TextSize = 12,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
mods.ValueChanged += mods =>
|
|
|
|
|
{
|
|
|
|
|
iconsContainer.Clear();
|
|
|
|
|
foreach (Mod mod in mods)
|
|
|
|
|
{
|
|
|
|
|
iconsContainer.Add(new ModIcon(mod)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Scale = new Vector2(0.6f),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsLoaded)
|
|
|
|
|
appearTransform();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
appearTransform();
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-27 10:41:24 +08:00
|
|
|
|
private bool playIsRanked => !mods.Value.Any(m => !m.Ranked);
|
|
|
|
|
|
2017-05-05 12:00:05 +08:00
|
|
|
|
private void appearTransform()
|
|
|
|
|
{
|
2017-06-27 10:41:24 +08:00
|
|
|
|
if (!playIsRanked)
|
2017-06-27 10:17:21 +08:00
|
|
|
|
unrankedText.FadeInFromZero(fade_duration, EasingTypes.OutQuint);
|
|
|
|
|
else
|
|
|
|
|
unrankedText.FadeTo(0);
|
|
|
|
|
|
2017-05-05 12:00:05 +08:00
|
|
|
|
iconsContainer.Flush();
|
2017-06-27 10:17:21 +08:00
|
|
|
|
iconsContainer.FadeInFromZero(fade_duration, EasingTypes.OutQuint);
|
2017-05-05 12:17:36 +08:00
|
|
|
|
expand();
|
2017-05-05 12:00:05 +08:00
|
|
|
|
using (iconsContainer.BeginDelayedSequence(1200))
|
2017-05-05 12:17:36 +08:00
|
|
|
|
contract();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void expand() => iconsContainer.TransformSpacingTo(new Vector2(5, 0), 500, EasingTypes.OutQuint);
|
|
|
|
|
|
|
|
|
|
private void contract() => iconsContainer.TransformSpacingTo(new Vector2(-25, 0), 500, EasingTypes.OutQuint);
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
expand();
|
|
|
|
|
return base.OnHover(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
contract();
|
|
|
|
|
base.OnHoverLost(state);
|
2017-05-05 12:00:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|