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
|
|
|
|
|
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
2017-05-03 14:48:10 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
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
|
|
|
|
{
|
|
|
|
|
public class ModIcon : Container
|
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly TextAwesome modIcon;
|
|
|
|
|
private readonly TextAwesome background;
|
2017-02-17 04:05:03 +08:00
|
|
|
|
|
|
|
|
|
private float iconSize = 80;
|
|
|
|
|
public float IconSize
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return iconSize;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
iconSize = value;
|
|
|
|
|
reapplySize();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-06 16:21:18 +08:00
|
|
|
|
|
2017-03-06 17:14:41 +08:00
|
|
|
|
public new Color4 Colour
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-05-03 14:48:10 +08:00
|
|
|
|
get { return background?.Colour ?? Color4.Transparent; }
|
|
|
|
|
set { background.Colour = value; }
|
2017-02-17 04:05:03 +08:00
|
|
|
|
}
|
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; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ModIcon(Mod m)
|
|
|
|
|
{
|
|
|
|
|
if(m!= null)
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-05-03 14:48:10 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Icon = FontAwesome.fa_osu_mod_bg,
|
|
|
|
|
Colour = selectColour(m),
|
|
|
|
|
Shadow = true,
|
|
|
|
|
TextSize = 20
|
|
|
|
|
},
|
|
|
|
|
modIcon = new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Colour = OsuColour.Gray(84),
|
|
|
|
|
TextSize = 20,
|
|
|
|
|
Icon = m.Icon,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reapplySize();
|
2017-02-17 04:05:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void reapplySize()
|
|
|
|
|
{
|
|
|
|
|
background.TextSize = iconSize;
|
|
|
|
|
modIcon.TextSize = iconSize - 35;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-03 14:48:10 +08:00
|
|
|
|
private Color4 selectColour(Mod mod)
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-05-03 14:48:10 +08:00
|
|
|
|
switch (mod.Type)
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-05-03 14:48:10 +08:00
|
|
|
|
case ModType.DifficultyIncrease:
|
|
|
|
|
return OsuColour.FromHex(@"ffcc22");
|
|
|
|
|
case ModType.DifficultyReduction:
|
|
|
|
|
return OsuColour.FromHex(@"88b300");
|
|
|
|
|
case ModType.Special:
|
|
|
|
|
return OsuColour.FromHex(@"66ccff");
|
2017-02-17 04:05:03 +08:00
|
|
|
|
|
2017-05-03 14:48:10 +08:00
|
|
|
|
default: return Color4.White;
|
|
|
|
|
}
|
2017-02-17 04:05:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|