1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 22:22:54 +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]
private void load(OsuColour colours)
{
ButtonColour = colours.Blue;
SelectedColour = colours.BlueLight;
}

View File

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

View File

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

View File

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

View File

@ -50,7 +50,6 @@ namespace osu.Game.Overlays.Mods
foreach (ModButton button in value)
{
button.ButtonColour = ButtonColour;
button.SelectedColour = selectedColour;
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;
public Color4 SelectedColour
{

View File

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

View File

@ -16,9 +16,15 @@ namespace osu.Game.Screens.Play
{
private readonly FillFlowContainer<ModIcon> iconsContainer;
private bool showMods;
public bool ShowMods
{
set { if (!value) Hide(); }
set
{
showMods = value;
if (!showMods) Hide();
}
get { return ShowMods; }
}
public ModsContainer()
@ -46,28 +52,11 @@ namespace osu.Game.Screens.Play
public void Add(Mod mod)
{
iconsContainer.Add(new ModIcon
iconsContainer.Add(new ModIcon(mod)
{
AutoSizeAxes = Axes.Both,
Icon = mod.Icon,
Colour = selectColour(mod),
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;
}
}
}
}