2017-03-08 14:50:52 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-17 04:05:03 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-05-05 11:16:41 +08:00
|
|
|
|
using System;
|
2017-02-17 04:05:03 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2017-05-08 10:33:22 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-02-17 04:05:03 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-10-13 18:14:43 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2017-02-17 04:05:03 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-05-03 14:48:10 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2017-08-03 13:36:21 +08:00
|
|
|
|
using OpenTK;
|
2017-02-17 04:05:03 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.UI
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-10-13 18:14:43 +08:00
|
|
|
|
public class ModIcon : Container, IHasTooltip
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
|
private readonly SpriteIcon modIcon;
|
|
|
|
|
private readonly SpriteIcon background;
|
2017-02-17 04:05:03 +08:00
|
|
|
|
|
2017-08-14 01:54:07 +08:00
|
|
|
|
private const float background_size = 80;
|
2017-04-06 16:21:18 +08:00
|
|
|
|
|
2017-02-17 04:05:03 +08:00
|
|
|
|
public FontAwesome Icon
|
|
|
|
|
{
|
2017-05-03 14:48:10 +08:00
|
|
|
|
get { return modIcon.Icon; }
|
|
|
|
|
set { modIcon.Icon = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 10:47:06 +08:00
|
|
|
|
private readonly ModType type;
|
2017-05-08 10:33:22 +08:00
|
|
|
|
|
2017-10-13 18:14:43 +08:00
|
|
|
|
public string TooltipText { get; }
|
|
|
|
|
|
2017-05-04 22:29:52 +08:00
|
|
|
|
public ModIcon(Mod mod)
|
2017-05-03 14:48:10 +08:00
|
|
|
|
{
|
2017-05-05 11:16:41 +08:00
|
|
|
|
if (mod == null) throw new ArgumentNullException(nameof(mod));
|
|
|
|
|
|
2017-05-08 10:33:22 +08:00
|
|
|
|
type = mod.Type;
|
|
|
|
|
|
2017-10-13 18:14:43 +08:00
|
|
|
|
TooltipText = mod.Name;
|
|
|
|
|
|
2017-05-03 18:53:45 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
|
background = new SpriteIcon
|
2017-05-03 14:48:10 +08:00
|
|
|
|
{
|
2017-05-03 18:53:45 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
2017-08-14 01:54:07 +08:00
|
|
|
|
Size = new Vector2(background_size),
|
2017-05-03 18:53:45 +08:00
|
|
|
|
Icon = FontAwesome.fa_osu_mod_bg,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
2017-08-03 13:36:21 +08:00
|
|
|
|
modIcon = new SpriteIcon
|
2017-05-03 18:53:45 +08:00
|
|
|
|
{
|
2017-08-05 10:09:44 +08:00
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-05-03 18:53:45 +08:00
|
|
|
|
Colour = OsuColour.Gray(84),
|
2017-08-14 01:54:07 +08:00
|
|
|
|
Size = new Vector2(background_size - 35),
|
2017-08-05 10:09:44 +08:00
|
|
|
|
Y = 25,
|
2017-05-05 11:16:41 +08:00
|
|
|
|
Icon = mod.Icon
|
2017-05-03 18:53:45 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
2017-02-17 04:05:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 10:33:22 +08:00
|
|
|
|
private Color4 backgroundColour;
|
|
|
|
|
private Color4 highlightedColour;
|
2017-02-17 04:05:03 +08:00
|
|
|
|
|
2017-05-08 10:33:22 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-05-08 10:33:22 +08:00
|
|
|
|
switch (type)
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-05-08 10:33:22 +08:00
|
|
|
|
default:
|
2017-05-03 14:48:10 +08:00
|
|
|
|
case ModType.DifficultyIncrease:
|
2017-05-08 10:33:22 +08:00
|
|
|
|
backgroundColour = colours.Yellow;
|
|
|
|
|
highlightedColour = colours.YellowLight;
|
|
|
|
|
break;
|
2017-05-03 14:48:10 +08:00
|
|
|
|
case ModType.DifficultyReduction:
|
2017-05-08 10:33:22 +08:00
|
|
|
|
backgroundColour = colours.Green;
|
|
|
|
|
highlightedColour = colours.GreenLight;
|
|
|
|
|
break;
|
2017-05-03 14:48:10 +08:00
|
|
|
|
case ModType.Special:
|
2017-05-08 10:33:22 +08:00
|
|
|
|
backgroundColour = colours.Blue;
|
|
|
|
|
highlightedColour = colours.BlueLight;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
applyStyle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool highlighted;
|
|
|
|
|
|
|
|
|
|
public bool Highlighted
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return highlighted;
|
|
|
|
|
}
|
2017-02-17 04:05:03 +08:00
|
|
|
|
|
2017-05-08 10:33:22 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
highlighted = value;
|
|
|
|
|
applyStyle();
|
2017-05-03 14:48:10 +08:00
|
|
|
|
}
|
2017-02-17 04:05:03 +08:00
|
|
|
|
}
|
2017-05-08 10:33:22 +08:00
|
|
|
|
|
|
|
|
|
private void applyStyle()
|
|
|
|
|
{
|
|
|
|
|
background.Colour = highlighted ? highlightedColour : backgroundColour;
|
|
|
|
|
}
|
2017-02-17 04:05:03 +08:00
|
|
|
|
}
|
2017-05-05 11:16:41 +08:00
|
|
|
|
}
|