1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-07 03:17:18 +08:00

104 lines
2.9 KiB
C#
Raw Normal View History

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