1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Merge branch 'master' into mania-hitexplosion-skinning

This commit is contained in:
Dean Herbert 2020-04-02 23:57:03 +09:00 committed by GitHub
commit f919a2f267
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 6 deletions

View File

@ -46,6 +46,9 @@ namespace osu.Game.Rulesets.Mania.Skinning
new LegacyManiaSkinConfigurationLookup(Stage?.Columns.Count ?? 4, LegacyManiaSkinConfigurationLookups.LightPosition))?.Value
?? 0;
Color4 lineColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLineColour)?.Value
?? Color4.White;
InternalChildren = new Drawable[]
{
new Box
@ -57,6 +60,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
{
RelativeSizeAxes = Axes.Y,
Width = leftLineWidth,
Colour = lineColour,
Alpha = hasLeftLine ? 1 : 0
},
new Box
@ -65,6 +69,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = rightLineWidth,
Colour = lineColour,
Alpha = hasRightLine ? 1 : 0
},
lightContainer = new Container

View File

@ -0,0 +1,3 @@
[Mania]
Keys: 4
ColourBarline: 50,50,50,50

View File

@ -5,6 +5,7 @@ using NUnit.Framework;
using osu.Game.IO;
using osu.Game.Skinning;
using osu.Game.Tests.Resources;
using osuTK.Graphics;
namespace osu.Game.Tests.Skins
{
@ -83,5 +84,20 @@ namespace osu.Game.Tests.Skins
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
}
}
[Test]
public void TestParseColours()
{
var decoder = new LegacyManiaSkinDecoder();
using (var resStream = TestResources.OpenResource("mania-skin-colours.ini"))
using (var stream = new LineBufferedReader(resStream))
{
var configs = decoder.Decode(stream);
Assert.That(configs.Count, Is.EqualTo(1));
Assert.That(configs[0].CustomColours, Contains.Key("ColourBarline").And.ContainValue(new Color4(50, 50, 50, 50)));
}
}
}
}

View File

@ -73,7 +73,7 @@ namespace osu.Game.Beatmaps.Formats
switch (section)
{
case Section.Colours:
handleColours(output, line);
HandleColours(output, line);
return;
}
}
@ -87,7 +87,7 @@ namespace osu.Game.Beatmaps.Formats
return line;
}
private void handleColours(T output, string line)
protected void HandleColours<TModel>(TModel output, string line)
{
var pair = SplitKeyVal(line);

View File

@ -2,10 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Game.Beatmaps.Formats;
using osuTK.Graphics;
namespace osu.Game.Skinning
{
public class LegacyManiaSkinConfiguration
public class LegacyManiaSkinConfiguration : IHasCustomColours
{
/// <summary>
/// Conversion factor from converting legacy positioning values (based in x480 dimensions) to x768.
@ -19,6 +22,8 @@ namespace osu.Game.Skinning
public readonly int Keys;
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
public readonly float[] ColumnLineWidth;
public readonly float[] ColumnSpacing;
public readonly float[] ColumnWidth;

View File

@ -36,5 +36,6 @@ namespace osu.Game.Skinning
HoldNoteBodyImage,
ExplosionImage,
ExplosionScale
ColumnLineColour
}
}

View File

@ -71,6 +71,12 @@ namespace osu.Game.Skinning
{
var pair = SplitKeyVal(line);
if (pair.Key.StartsWith("Colour"))
{
HandleColours(currentConfig, line);
continue;
}
switch (pair.Key)
{
case "ColumnLineWidth":

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Game.Audio;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
using osu.Game.Rulesets.Scoring;
using osuTK.Graphics;
@ -112,7 +113,7 @@ namespace osu.Game.Skinning
break;
default:
return SkinUtils.As<TValue>(getCustomColour(colour.ToString()));
return SkinUtils.As<TValue>(getCustomColour(Configuration, colour.ToString()));
}
break;
@ -130,7 +131,7 @@ namespace osu.Game.Skinning
break;
case SkinCustomColourLookup customColour:
return SkinUtils.As<TValue>(getCustomColour(customColour.Lookup.ToString()));
return SkinUtils.As<TValue>(getCustomColour(Configuration, customColour.Lookup.ToString()));
case LegacyManiaSkinConfigurationLookup maniaLookup:
if (!AllowManiaSkin)
@ -203,12 +204,16 @@ namespace osu.Game.Skinning
return SkinUtils.As<TValue>(new Bindable<float>(existing.ExplosionWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE));
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value] / LegacyManiaSkinConfiguration.DEFAULT_COLUMN_SIZE));
case LegacyManiaSkinConfigurationLookups.ColumnLineColour:
return SkinUtils.As<TValue>(getCustomColour(existing, "ColourColumnLine"));
}
return null;
}
private IBindable<Color4> getCustomColour(string lookup) => Configuration.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;
private IBindable<Color4> getCustomColour(IHasCustomColours source, string lookup)
=> source.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;
public override Drawable GetDrawableComponent(ISkinComponent component)
{