2019-01-24 08:43:03 +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-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-03-27 10:29:27 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2019-08-07 05:46:27 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.UI
|
|
|
|
|
{
|
|
|
|
|
public class ModIcon : Container, IHasTooltip
|
|
|
|
|
{
|
2019-08-07 05:46:27 +00:00
|
|
|
|
public readonly BindableBool Highlighted = new BindableBool();
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private readonly SpriteIcon modIcon;
|
|
|
|
|
private readonly SpriteIcon background;
|
|
|
|
|
|
|
|
|
|
private const float size = 80;
|
|
|
|
|
|
2019-03-27 10:29:27 +00:00
|
|
|
|
public IconUsage Icon
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-02-28 04:58:19 +00:00
|
|
|
|
get => modIcon.Icon;
|
|
|
|
|
set => modIcon.Icon = value;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly ModType type;
|
|
|
|
|
|
|
|
|
|
public virtual string TooltipText { get; }
|
|
|
|
|
|
|
|
|
|
public ModIcon(Mod mod)
|
|
|
|
|
{
|
|
|
|
|
if (mod == null) throw new ArgumentNullException(nameof(mod));
|
|
|
|
|
|
|
|
|
|
type = mod.Type;
|
|
|
|
|
|
|
|
|
|
TooltipText = mod.Name;
|
|
|
|
|
|
|
|
|
|
Size = new Vector2(size);
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(size),
|
2019-03-27 10:29:27 +00:00
|
|
|
|
Icon = OsuIcon.ModBg,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
|
|
|
|
modIcon = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Colour = OsuColour.Gray(84),
|
|
|
|
|
Size = new Vector2(size - 35),
|
|
|
|
|
Icon = mod.Icon
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Color4 backgroundColour;
|
|
|
|
|
private Color4 highlightedColour;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case ModType.DifficultyIncrease:
|
|
|
|
|
backgroundColour = colours.Yellow;
|
|
|
|
|
highlightedColour = colours.YellowLight;
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case ModType.DifficultyReduction:
|
|
|
|
|
backgroundColour = colours.Green;
|
|
|
|
|
highlightedColour = colours.GreenLight;
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-07-31 09:00:42 +00:00
|
|
|
|
case ModType.Automation:
|
2018-04-13 09:19:50 +00:00
|
|
|
|
backgroundColour = colours.Blue;
|
|
|
|
|
highlightedColour = colours.BlueLight;
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-07-31 09:00:42 +00:00
|
|
|
|
case ModType.Conversion:
|
|
|
|
|
backgroundColour = colours.Purple;
|
|
|
|
|
highlightedColour = colours.PurpleLight;
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-07-31 09:00:42 +00:00
|
|
|
|
case ModType.Fun:
|
|
|
|
|
backgroundColour = colours.Pink;
|
|
|
|
|
highlightedColour = colours.PinkLight;
|
|
|
|
|
break;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-07 05:46:27 +00:00
|
|
|
|
protected override void LoadComplete()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-08-07 05:46:27 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|