mirror of
https://github.com/ppy/osu
synced 2024-12-16 20:05:41 +00:00
Merge branch 'master' into localisation-settings
This commit is contained in:
commit
8c3eb91059
@ -169,7 +169,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
protected override ISkin GetSkin() => throw new NotImplementedException();
|
||||
protected internal override ISkin GetSkin() => throw new NotImplementedException();
|
||||
|
||||
public override Stream GetStream(string storagePath) => throw new NotImplementedException();
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
protected override ISkin GetSkin() => new TestSkin("test-sample", resources);
|
||||
protected internal override ISkin GetSkin() => new TestSkin("test-sample", resources);
|
||||
}
|
||||
|
||||
private class TestDrawableStoryboardSample : DrawableStoryboardSample
|
||||
|
@ -133,11 +133,12 @@ namespace osu.Game.Tests.Skins
|
||||
[Test]
|
||||
public void TestEmptyComboColoursNoFallback()
|
||||
{
|
||||
AddStep("Add custom combo colours to user skin", () => userSource.Configuration.AddComboColours(
|
||||
AddStep("Add custom combo colours to user skin", () => userSource.Configuration.CustomComboColours = new List<Color4>
|
||||
{
|
||||
new Color4(100, 150, 200, 255),
|
||||
new Color4(55, 110, 166, 255),
|
||||
new Color4(75, 125, 175, 255)
|
||||
));
|
||||
});
|
||||
|
||||
AddStep("Disallow default colours fallback in beatmap skin", () => beatmapSource.Configuration.AllowDefaultComboColoursFallback = false);
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
this.beatmapSkin = beatmapSkin;
|
||||
}
|
||||
|
||||
protected override ISkin GetSkin() => beatmapSkin;
|
||||
protected internal override ISkin GetSkin() => beatmapSkin;
|
||||
}
|
||||
|
||||
private class TestOsuRuleset : OsuRuleset
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests
|
||||
|
||||
protected override Waveform GetWaveform() => new Waveform(trackStore.GetStream(firstAudioFile));
|
||||
|
||||
protected override ISkin GetSkin() => null;
|
||||
protected internal override ISkin GetSkin() => null;
|
||||
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
|
||||
|
@ -534,7 +534,7 @@ namespace osu.Game.Beatmaps
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
protected override Texture GetBackground() => null;
|
||||
protected override Track GetBeatmapTrack() => null;
|
||||
protected override ISkin GetSkin() => null;
|
||||
protected internal override ISkin GetSkin() => null;
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ namespace osu.Game.Beatmaps
|
||||
return storyboard;
|
||||
}
|
||||
|
||||
protected override ISkin GetSkin()
|
||||
protected internal override ISkin GetSkin()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
protected override Track GetBeatmapTrack() => GetVirtualTrack();
|
||||
|
||||
protected override ISkin GetSkin() => null;
|
||||
protected internal override ISkin GetSkin() => null;
|
||||
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -13,9 +14,17 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// </summary>
|
||||
IReadOnlyList<Color4> ComboColours { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of custom combo colours.
|
||||
/// If non-empty, <see cref="ComboColours"/> will return these colours;
|
||||
/// if empty, <see cref="ComboColours"/> will fall back to default combo colours.
|
||||
/// </summary>
|
||||
List<Color4> CustomComboColours { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds combo colours to the list.
|
||||
/// </summary>
|
||||
[Obsolete("Use CustomComboColours directly.")] // can be removed 20220215
|
||||
void AddComboColours(params Color4[] colours);
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
if (!(output is IHasComboColours tHasComboColours)) return;
|
||||
|
||||
tHasComboColours.AddComboColours(colour);
|
||||
tHasComboColours.CustomComboColours.Add(colour);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -327,7 +327,15 @@ namespace osu.Game.Beatmaps
|
||||
public bool SkinLoaded => skin.IsResultAvailable;
|
||||
public ISkin Skin => skin.Value;
|
||||
|
||||
protected abstract ISkin GetSkin();
|
||||
/// <summary>
|
||||
/// Creates a new skin instance for this beatmap.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should only be called externally in scenarios where it is explicitly desired to get a new instance of a skin
|
||||
/// (e.g. for editing purposes, to avoid state pollution).
|
||||
/// For standard reading purposes, <see cref="Skin"/> should always be used directly.
|
||||
/// </remarks>
|
||||
protected internal abstract ISkin GetSkin();
|
||||
|
||||
private readonly RecyclableLazy<ISkin> skin;
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace osu.Game.Configuration
|
||||
SetDefault(OsuSetting.HitLighting, true);
|
||||
|
||||
SetDefault(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Always);
|
||||
SetDefault(OsuSetting.ShowDifficultyGraph, true);
|
||||
SetDefault(OsuSetting.ShowProgressGraph, true);
|
||||
SetDefault(OsuSetting.ShowHealthDisplayWhenCantFail, true);
|
||||
SetDefault(OsuSetting.FadePlayfieldWhenHealthLow, true);
|
||||
SetDefault(OsuSetting.KeyOverlay, false);
|
||||
@ -201,6 +201,8 @@ namespace osu.Game.Configuration
|
||||
public Func<GlobalAction, string> LookupKeyBindings { get; set; }
|
||||
}
|
||||
|
||||
// IMPORTANT: These are used in user configuration files.
|
||||
// The naming of these keys should not be changed once they are deployed in a release, unless migration logic is also added.
|
||||
public enum OsuSetting
|
||||
{
|
||||
Ruleset,
|
||||
@ -217,7 +219,7 @@ namespace osu.Game.Configuration
|
||||
AlwaysPlayFirstComboBreak,
|
||||
FloatingComments,
|
||||
HUDVisibilityMode,
|
||||
ShowDifficultyGraph,
|
||||
ShowProgressGraph,
|
||||
ShowHealthDisplayWhenCantFail,
|
||||
FadePlayfieldWhenHealthLow,
|
||||
MouseDisableButtons,
|
||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = GameplaySettingsStrings.ShowDifficultyGraph,
|
||||
Current = config.GetBindable<bool>(OsuSetting.ShowDifficultyGraph)
|
||||
Current = config.GetBindable<bool>(OsuSetting.ShowProgressGraph)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
|
@ -15,7 +15,6 @@ using osu.Game.Extensions;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose
|
||||
{
|
||||
@ -73,7 +72,7 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
{
|
||||
Debug.Assert(ruleset != null);
|
||||
|
||||
return new RulesetSkinProvidingContainer(ruleset, EditorBeatmap.PlayableBeatmap, beatmap.Value.Skin).WithChild(content);
|
||||
return new EditorSkinProvidingContainer(EditorBeatmap).WithChild(content);
|
||||
}
|
||||
|
||||
#region Input Handling
|
||||
|
@ -153,7 +153,7 @@ namespace osu.Game.Screens.Edit
|
||||
// todo: remove caching of this and consume via editorBeatmap?
|
||||
dependencies.Cache(beatDivisor);
|
||||
|
||||
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.Skin));
|
||||
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.GetSkin()));
|
||||
dependencies.CacheAs(editorBeatmap);
|
||||
changeHandler = new EditorChangeHandler(editorBeatmap);
|
||||
dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
|
||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Screens.Edit
|
||||
private readonly Bindable<bool> hasTiming = new Bindable<bool>();
|
||||
|
||||
[CanBeNull]
|
||||
public readonly ISkin BeatmapSkin;
|
||||
public readonly EditorBeatmapSkin BeatmapSkin;
|
||||
|
||||
[Resolved]
|
||||
private BindableBeatDivisor beatDivisor { get; set; }
|
||||
@ -69,7 +69,8 @@ namespace osu.Game.Screens.Edit
|
||||
public EditorBeatmap(IBeatmap playableBeatmap, ISkin beatmapSkin = null)
|
||||
{
|
||||
PlayableBeatmap = playableBeatmap;
|
||||
BeatmapSkin = beatmapSkin;
|
||||
if (beatmapSkin is Skin skin)
|
||||
BeatmapSkin = new EditorBeatmapSkin(skin);
|
||||
|
||||
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);
|
||||
|
||||
|
59
osu.Game/Screens/Edit/EditorBeatmapSkin.cs
Normal file
59
osu.Game/Screens/Edit/EditorBeatmapSkin.cs
Normal file
@ -0,0 +1,59 @@
|
||||
// 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 System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.OpenGL.Textures;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
/// <summary>
|
||||
/// A beatmap skin which is being edited.
|
||||
/// </summary>
|
||||
public class EditorBeatmapSkin : ISkin
|
||||
{
|
||||
public event Action BeatmapSkinChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The combo colours of this skin.
|
||||
/// If empty, the default combo colours will be used.
|
||||
/// </summary>
|
||||
public readonly BindableList<Colour4> ComboColours;
|
||||
|
||||
private readonly Skin skin;
|
||||
|
||||
public EditorBeatmapSkin(Skin skin)
|
||||
{
|
||||
this.skin = skin;
|
||||
|
||||
ComboColours = new BindableList<Colour4>();
|
||||
if (skin.Configuration.ComboColours != null)
|
||||
ComboColours.AddRange(skin.Configuration.ComboColours.Select(c => (Colour4)c));
|
||||
ComboColours.BindCollectionChanged((_, __) => updateColours());
|
||||
}
|
||||
|
||||
private void invokeSkinChanged() => BeatmapSkinChanged?.Invoke();
|
||||
|
||||
private void updateColours()
|
||||
{
|
||||
skin.Configuration.CustomComboColours = ComboColours.Select(c => (Color4)c).ToList();
|
||||
invokeSkinChanged();
|
||||
}
|
||||
|
||||
#region Delegated ISkin implementation
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component);
|
||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT);
|
||||
public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo);
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => skin.GetConfig<TLookup, TValue>(lookup);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
40
osu.Game/Screens/Edit/EditorSkinProvidingContainer.cs
Normal file
40
osu.Game/Screens/Edit/EditorSkinProvidingContainer.cs
Normal file
@ -0,0 +1,40 @@
|
||||
// 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.Skinning;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="SkinProvidingContainer"/> that fires <see cref="ISkinSource.SourceChanged"/> when users have made a change to the beatmap skin
|
||||
/// of the map being edited.
|
||||
/// </summary>
|
||||
public class EditorSkinProvidingContainer : RulesetSkinProvidingContainer
|
||||
{
|
||||
private readonly EditorBeatmapSkin? beatmapSkin;
|
||||
|
||||
public EditorSkinProvidingContainer(EditorBeatmap editorBeatmap)
|
||||
: base(editorBeatmap.PlayableBeatmap.BeatmapInfo.Ruleset.CreateInstance(), editorBeatmap, editorBeatmap.BeatmapSkin)
|
||||
{
|
||||
beatmapSkin = editorBeatmap.BeatmapSkin;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (beatmapSkin != null)
|
||||
beatmapSkin.BeatmapSkinChanged += TriggerSourceChanged;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (beatmapSkin != null)
|
||||
beatmapSkin.BeatmapSkinChanged -= TriggerSourceChanged;
|
||||
}
|
||||
}
|
||||
}
|
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
protected override ISkin GetSkin() => throw new NotImplementedException();
|
||||
protected internal override ISkin GetSkin() => throw new NotImplementedException();
|
||||
|
||||
public override Stream GetStream(string storagePath) => throw new NotImplementedException();
|
||||
}
|
||||
|
@ -1,14 +1,10 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
@ -31,9 +27,8 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
}
|
||||
};
|
||||
|
||||
var colours = Beatmap.BeatmapSkin?.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
|
||||
if (colours != null)
|
||||
comboColours.Colours.AddRange(colours.Select(c => (Colour4)c));
|
||||
if (Beatmap.BeatmapSkin != null)
|
||||
comboColours.Colours.BindTo(Beatmap.BeatmapSkin.ComboColours);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ namespace osu.Game.Screens.Play
|
||||
Objects = drawableRuleset.Objects;
|
||||
}
|
||||
|
||||
config.BindWith(OsuSetting.ShowDifficultyGraph, ShowGraph);
|
||||
config.BindWith(OsuSetting.ShowProgressGraph, ShowGraph);
|
||||
|
||||
graph.FillColour = bar.FillColour = colours.BlueLighter;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Extensions;
|
||||
@ -21,12 +22,13 @@ namespace osu.Game.Skinning
|
||||
: base(skin, new NamespacedResourceStore<byte[]>(resources.Resources, "Skins/Legacy"), resources, string.Empty)
|
||||
{
|
||||
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
||||
Configuration.AddComboColours(
|
||||
Configuration.CustomComboColours = new List<Color4>
|
||||
{
|
||||
new Color4(255, 192, 0, 255),
|
||||
new Color4(0, 202, 0, 255),
|
||||
new Color4(18, 124, 255, 255),
|
||||
new Color4(242, 24, 57, 255)
|
||||
);
|
||||
};
|
||||
|
||||
Configuration.LegacyVersion = 2.7m;
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ namespace osu.Game.Skinning
|
||||
new Color4(242, 24, 57, 255),
|
||||
};
|
||||
|
||||
private readonly List<Color4> comboColours = new List<Color4>();
|
||||
public List<Color4> CustomComboColours { get; set; } = new List<Color4>();
|
||||
|
||||
public IReadOnlyList<Color4> ComboColours
|
||||
{
|
||||
get
|
||||
{
|
||||
if (comboColours.Count > 0)
|
||||
return comboColours;
|
||||
if (CustomComboColours.Count > 0)
|
||||
return CustomComboColours;
|
||||
|
||||
if (AllowDefaultComboColoursFallback)
|
||||
return DefaultComboColours;
|
||||
@ -43,7 +43,7 @@ namespace osu.Game.Skinning
|
||||
}
|
||||
}
|
||||
|
||||
public void AddComboColours(params Color4[] colours) => comboColours.AddRange(colours);
|
||||
void IHasComboColours.AddComboColours(params Color4[] colours) => CustomComboColours.AddRange(colours);
|
||||
|
||||
public Dictionary<string, Color4> CustomColours { get; } = new Dictionary<string, Color4>();
|
||||
|
||||
|
@ -217,7 +217,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
protected override ISkin GetSkin() => throw new NotImplementedException();
|
||||
protected internal override ISkin GetSkin() => throw new NotImplementedException();
|
||||
|
||||
public override Stream GetStream(string storagePath) => throw new NotImplementedException();
|
||||
|
||||
|
@ -211,7 +211,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
protected override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, resources);
|
||||
protected internal override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, resources);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
HasColours = hasColours;
|
||||
}
|
||||
|
||||
protected override ISkin GetSkin() => new TestBeatmapSkin(BeatmapInfo, HasColours);
|
||||
protected internal override ISkin GetSkin() => new TestBeatmapSkin(BeatmapInfo, HasColours);
|
||||
}
|
||||
|
||||
protected class TestBeatmapSkin : LegacyBeatmapSkin
|
||||
@ -116,7 +116,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
if (hasColours)
|
||||
{
|
||||
Configuration.AddComboColours(Colours);
|
||||
Configuration.CustomComboColours = Colours.ToList();
|
||||
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
||||
@ -145,7 +145,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
if (hasCustomColours)
|
||||
{
|
||||
Configuration.AddComboColours(Colours);
|
||||
Configuration.CustomComboColours = Colours.ToList();
|
||||
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
protected override Storyboard GetStoryboard() => storyboard ?? base.GetStoryboard();
|
||||
|
||||
protected override ISkin GetSkin() => null;
|
||||
protected internal override ISkin GetSkin() => null;
|
||||
|
||||
public override Stream GetStream(string storagePath) => null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user