Merge branch 'master' into skin-editor-button-access

This commit is contained in:
Bartłomiej Dach
2021-07-22 22:49:44 +02:00
108 changed files with 2305 additions and 789 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Beatmaps.Formats;
using osu.Game.Extensions;
using osu.Game.IO;
using osu.Game.Screens.Play;
@ -136,10 +137,10 @@ namespace osu.Game.Skinning
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{
// todo: this code is pulled from LegacySkin and should not exist.
// will likely change based on how databased storage of skin configuration goes.
switch (lookup)
{
// todo: this code is pulled from LegacySkin and should not exist.
// will likely change based on how databased storage of skin configuration goes.
case GlobalSkinColours global:
switch (global)
{
@ -148,9 +149,15 @@ namespace osu.Game.Skinning
}
break;
case SkinComboColourLookup comboColour:
return SkinUtils.As<TValue>(new Bindable<Color4>(getComboColour(Configuration, comboColour.ColourIndex)));
}
return null;
}
private static Color4 getComboColour(IHasComboColours source, int colourIndex)
=> source.ComboColours[colourIndex % source.ComboColours.Count];
}
}

View File

@ -170,6 +170,8 @@ namespace osu.Game.Skinning.Editor
SelectionBox.CanRotate = true;
SelectionBox.CanScaleX = true;
SelectionBox.CanScaleY = true;
SelectionBox.CanFlipX = true;
SelectionBox.CanFlipY = true;
SelectionBox.CanReverse = false;
}

View File

@ -16,6 +16,7 @@ using osu.Framework.IO.Stores;
using osu.Game.Audio;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
@ -129,6 +130,9 @@ namespace osu.Game.Skinning
break;
case SkinComboColourLookup comboColour:
return SkinUtils.As<TValue>(GetComboColour(Configuration, comboColour.ColourIndex, comboColour.Combo));
case SkinCustomColourLookup customColour:
return SkinUtils.As<TValue>(getCustomColour(Configuration, customColour.Lookup.ToString()));
@ -286,6 +290,18 @@ namespace osu.Game.Skinning
return null;
}
/// <summary>
/// Retrieves the correct combo colour for a given colour index and information on the combo.
/// </summary>
/// <param name="source">The source to retrieve the combo colours from.</param>
/// <param name="colourIndex">The preferred index for retrieving the combo colour with.</param>
/// <param name="combo">Information on the combo whose using the returned colour.</param>
protected virtual IBindable<Color4> GetComboColour(IHasComboColours source, int colourIndex, IHasComboInformation combo)
{
var colour = source.ComboColours?[colourIndex % source.ComboColours.Count];
return colour.HasValue ? new Bindable<Color4>(colour.Value) : null;
}
private IBindable<Color4> getCustomColour(IHasCustomColours source, string lookup)
=> source.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;

View File

@ -0,0 +1,26 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Skinning
{
public class SkinComboColourLookup
{
/// <summary>
/// The index to use for deciding the combo colour.
/// </summary>
public readonly int ColourIndex;
/// <summary>
/// The combo information requesting the colour.
/// </summary>
public readonly IHasComboInformation Combo;
public SkinComboColourLookup(int colourIndex, IHasComboInformation combo)
{
ColourIndex = colourIndex;
Combo = combo;
}
}
}

View File

@ -272,6 +272,7 @@ namespace osu.Game.Skinning
switch (lookup)
{
case GlobalSkinColours _:
case SkinComboColourLookup _:
case SkinCustomColourLookup _:
if (provider.AllowColourLookup)
return skin.GetConfig<TLookup, TValue>(lookup);