1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:02:55 +08:00

ModIcon refactor

This commit is contained in:
EVAST9919 2017-05-03 09:48:10 +03:00
parent 898d9495ff
commit e7a8619f01
7 changed files with 54 additions and 91 deletions

View File

@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
ButtonColour = colours.Blue;
SelectedColour = colours.BlueLight; SelectedColour = colours.BlueLight;
} }

View File

@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
ButtonColour = colours.Yellow;
SelectedColour = colours.YellowLight; SelectedColour = colours.YellowLight;
} }

View File

@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
ButtonColour = colours.Green;
SelectedColour = colours.GreenLight; SelectedColour = colours.GreenLight;
} }

View File

@ -71,10 +71,6 @@ namespace osu.Game.Overlays.Mods
{ {
if (value == buttonColour) return; if (value == buttonColour) return;
buttonColour = value; buttonColour = value;
foreach (ModIcon icon in iconsContainer.Children)
{
icon.Colour = value;
}
} }
} }
@ -180,41 +176,33 @@ namespace osu.Game.Overlays.Mods
{ {
iconsContainer.Add(new[] iconsContainer.Add(new[]
{ {
new ModIcon new ModIcon(Mods[0])
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Position = new Vector2(1.5f), Position = new Vector2(1.5f),
Colour = ButtonColour
}, },
foregroundIcon = new ModIcon foregroundIcon = new ModIcon(Mods[0])
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Position = new Vector2(-1.5f), Position = new Vector2(-1.5f),
Colour = ButtonColour
}, },
}); });
} }
else else
{ {
iconsContainer.Add(foregroundIcon = new ModIcon iconsContainer.Add(foregroundIcon = new ModIcon(Mod)
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Colour = ButtonColour
}); });
} }
}
protected override void LoadComplete() buttonColour = foregroundIcon.Colour;
{
base.LoadComplete();
foreach (ModIcon icon in iconsContainer.Children)
icon.Colour = ButtonColour;
} }
public ModButton(Mod m) public ModButton(Mod m)

View File

@ -50,7 +50,6 @@ namespace osu.Game.Overlays.Mods
foreach (ModButton button in value) foreach (ModButton button in value)
{ {
button.ButtonColour = ButtonColour;
button.SelectedColour = selectedColour; button.SelectedColour = selectedColour;
button.Action = Action; button.Action = Action;
} }
@ -59,25 +58,6 @@ namespace osu.Game.Overlays.Mods
} }
} }
private Color4 buttonsBolour = Color4.White;
public Color4 ButtonColour
{
get
{
return buttonsBolour;
}
set
{
if (value == buttonsBolour) return;
buttonsBolour = value;
foreach (ModButton button in buttons)
{
button.ButtonColour = value;
}
}
}
private Color4 selectedColour = Color4.White; private Color4 selectedColour = Color4.White;
public Color4 SelectedColour public Color4 SelectedColour
{ {

View File

@ -5,6 +5,7 @@ using OpenTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.UI namespace osu.Game.Rulesets.UI
{ {
@ -29,25 +30,42 @@ namespace osu.Game.Rulesets.UI
public new Color4 Colour public new Color4 Colour
{ {
get get { return background?.Colour ?? Color4.Transparent; }
{ set { background.Colour = value; }
return background.Colour;
}
set
{
background.Colour = value;
}
} }
public FontAwesome Icon public FontAwesome Icon
{ {
get get { return modIcon.Icon; }
{ set { modIcon.Icon = value; }
return modIcon.Icon;
} }
set
public ModIcon(Mod m)
{ {
modIcon.Icon = value; if(m!= null)
{
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();
} }
} }
@ -57,28 +75,19 @@ namespace osu.Game.Rulesets.UI
modIcon.TextSize = iconSize - 35; modIcon.TextSize = iconSize - 35;
} }
public ModIcon() private Color4 selectColour(Mod mod)
{ {
Children = new Drawable[] switch (mod.Type)
{ {
background = new TextAwesome case ModType.DifficultyIncrease:
{ return OsuColour.FromHex(@"ffcc22");
Origin = Anchor.Centre, case ModType.DifficultyReduction:
Anchor = Anchor.Centre, return OsuColour.FromHex(@"88b300");
Icon = FontAwesome.fa_osu_mod_bg, case ModType.Special:
Shadow = true, return OsuColour.FromHex(@"66ccff");
TextSize = 20
},
modIcon = new TextAwesome
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
TextSize = 20
},
};
reapplySize(); default: return Color4.White;
}
} }
} }
} }

View File

@ -16,9 +16,15 @@ namespace osu.Game.Screens.Play
{ {
private readonly FillFlowContainer<ModIcon> iconsContainer; private readonly FillFlowContainer<ModIcon> iconsContainer;
private bool showMods;
public bool ShowMods public bool ShowMods
{ {
set { if (!value) Hide(); } set
{
showMods = value;
if (!showMods) Hide();
}
get { return ShowMods; }
} }
public ModsContainer() public ModsContainer()
@ -46,28 +52,11 @@ namespace osu.Game.Screens.Play
public void Add(Mod mod) public void Add(Mod mod)
{ {
iconsContainer.Add(new ModIcon iconsContainer.Add(new ModIcon(mod)
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Icon = mod.Icon,
Colour = selectColour(mod),
Scale = new Vector2((float)0.7), Scale = new Vector2((float)0.7),
}); });
} }
private Color4 selectColour(Mod mod)
{
switch (mod.Type)
{
case ModType.DifficultyIncrease:
return OsuColour.FromHex(@"ffcc22");
case ModType.DifficultyReduction:
return OsuColour.FromHex(@"88b300");
case ModType.Special:
return OsuColour.FromHex(@"66ccff");
default: return Color4.White;
}
}
} }
} }