1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:12:54 +08:00

Use string lookups for combo colours

This commit is contained in:
Dean Herbert 2018-03-22 17:32:05 +09:00
parent ab9505652b
commit c4fe6a04c5
5 changed files with 23 additions and 10 deletions

View File

@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
base.SkinChanged(skin, allowFallback);
if (HitObject is IHasComboInformation combo)
AccentColour = skin.GetComboColour(combo) ?? Color4.White;
AccentColour = skin.GetColour($"Play/Combo/{combo.ComboIndex}") ?? Color4.White;
}
protected override void LoadComplete()

View File

@ -5,7 +5,6 @@ using System;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Objects.Types;
using OpenTK.Graphics;
namespace osu.Game.Skinning
@ -23,6 +22,6 @@ namespace osu.Game.Skinning
SampleChannel GetSample(string sampleName);
Color4? GetComboColour(IHasComboInformation comboObject);
Color4? GetColour(string colourName);
}
}

View File

@ -7,7 +7,6 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Objects.Types;
using OpenTK.Graphics;
namespace osu.Game.Skinning
@ -22,7 +21,7 @@ namespace osu.Game.Skinning
public SampleChannel GetSample(string sampleName) => source.GetSample(sampleName) ?? fallbackSource?.GetSample(sampleName);
public Color4? GetComboColour(IHasComboInformation comboObject) => source.GetComboColour(comboObject) ?? fallbackSource?.GetComboColour(comboObject);
public Color4? GetColour(string colourName) => source.GetColour(colourName) ?? fallbackSource?.GetColour(colourName);
private readonly ISkinSource source;
private ISkinSource fallbackSource;

View File

@ -5,7 +5,6 @@ using System;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Objects.Types;
using OpenTK.Graphics;
namespace osu.Game.Skinning
@ -24,8 +23,25 @@ namespace osu.Game.Skinning
public abstract Texture GetTexture(string componentName);
public virtual Color4? GetComboColour(IHasComboInformation comboObject) =>
Configuration.ComboColours.Count == 0 ? (Color4?)null : Configuration.ComboColours[comboObject.ComboIndex % Configuration.ComboColours.Count];
public virtual Color4? GetColour(string colourName)
{
var namespaces = colourName.Split('/');
switch (namespaces[0])
{
case "Play":
switch (namespaces[1])
{
case "Combo":
int index = int.Parse(namespaces[2]);
return Configuration.ComboColours.Count == 0 ? (Color4?)null : Configuration.ComboColours[index % Configuration.ComboColours.Count];
}
break;
}
return null;
}
protected Skin(SkinInfo skin)
{

View File

@ -14,7 +14,6 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.IO.Archives;
using osu.Game.Rulesets.Objects.Types;
using OpenTK.Graphics;
namespace osu.Game.Skinning
@ -124,6 +123,6 @@ namespace osu.Game.Skinning
public SampleChannel GetSample(string sampleName) => CurrentSkin.Value.GetSample(sampleName);
public Color4? GetComboColour(IHasComboInformation comboObject) => CurrentSkin.Value.GetComboColour(comboObject);
public Color4? GetColour(string colourName) => CurrentSkin.Value.GetColour(colourName);
}
}