mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 15:03:10 +08:00
Merge remote-tracking branch 'upstream/master' into beatmapset-genre-language
This commit is contained in:
commit
043034a6ce
@ -60,7 +60,7 @@
|
|||||||
<Reference Include="Java.Interop" />
|
<Reference Include="Java.Interop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.828.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.830.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
{
|
{
|
||||||
public class CatchRuleset : Ruleset
|
public class CatchRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableCatchRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableCatchRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
||||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
protected override bool UserScrollSpeedAdjustment => false;
|
protected override bool UserScrollSpeedAdjustment => false;
|
||||||
|
|
||||||
public DrawableCatchRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableCatchRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Down;
|
Direction.Value = ScrollingDirection.Down;
|
||||||
TimeRange.Value = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450);
|
TimeRange.Value = BeatmapDifficulty.DifficultyRange(beatmap.Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);
|
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
||||||
|
|
||||||
public DrawableManiaEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableManiaEditRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
[Cached(Type = typeof(IManiaHitObjectComposer))]
|
[Cached(Type = typeof(IManiaHitObjectComposer))]
|
||||||
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>, IManiaHitObjectComposer
|
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>, IManiaHitObjectComposer
|
||||||
{
|
{
|
||||||
protected new DrawableManiaEditRuleset DrawableRuleset { get; private set; }
|
private DrawableManiaEditRuleset drawableRuleset;
|
||||||
|
|
||||||
public ManiaHitObjectComposer(Ruleset ruleset)
|
public ManiaHitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
@ -33,23 +33,23 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="screenSpacePosition">The screen-space position.</param>
|
/// <param name="screenSpacePosition">The screen-space position.</param>
|
||||||
/// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns>
|
/// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns>
|
||||||
public Column ColumnAt(Vector2 screenSpacePosition) => DrawableRuleset.GetColumnByPosition(screenSpacePosition);
|
public Column ColumnAt(Vector2 screenSpacePosition) => drawableRuleset.GetColumnByPosition(screenSpacePosition);
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
public int TotalColumns => ((ManiaPlayfield)DrawableRuleset.Playfield).TotalColumns;
|
public int TotalColumns => ((ManiaPlayfield)drawableRuleset.Playfield).TotalColumns;
|
||||||
|
|
||||||
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
{
|
{
|
||||||
DrawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
||||||
|
|
||||||
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
|
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
|
||||||
dependencies.CacheAs(DrawableRuleset.ScrollingInfo);
|
dependencies.CacheAs(drawableRuleset.ScrollingInfo);
|
||||||
|
|
||||||
return DrawableRuleset;
|
return drawableRuleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
{
|
{
|
||||||
public class ManiaRuleset : Ruleset
|
public class ManiaRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableManiaRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableManiaRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
||||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||||
|
|
||||||
public DrawableManiaRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableManiaRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
// Generate the bar lines
|
// Generate the bar lines
|
||||||
|
BIN
osu.Game.Rulesets.Osu.Tests/Resources/default-skin/cursor@2x.png
Executable file
BIN
osu.Game.Rulesets.Osu.Tests/Resources/default-skin/cursor@2x.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/default-skin/cursormiddle@2x.png
Executable file
BIN
osu.Game.Rulesets.Osu.Tests/Resources/default-skin/cursormiddle@2x.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
@ -37,10 +37,21 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
public void SetContents(Func<Drawable> creationFunction)
|
public void SetContents(Func<Drawable> creationFunction)
|
||||||
{
|
{
|
||||||
Cell(0).Child = new LocalSkinOverrideContainer(null) { RelativeSizeAxes = Axes.Both }.WithChild(creationFunction());
|
Cell(0).Child = createProvider(null, creationFunction);
|
||||||
Cell(1).Child = new LocalSkinOverrideContainer(metricsSkin) { RelativeSizeAxes = Axes.Both }.WithChild(creationFunction());
|
Cell(1).Child = createProvider(metricsSkin, creationFunction);
|
||||||
Cell(2).Child = new LocalSkinOverrideContainer(defaultSkin) { RelativeSizeAxes = Axes.Both }.WithChild(creationFunction());
|
Cell(2).Child = createProvider(defaultSkin, creationFunction);
|
||||||
Cell(3).Child = new LocalSkinOverrideContainer(specialSkin) { RelativeSizeAxes = Axes.Both }.WithChild(creationFunction());
|
Cell(3).Child = createProvider(specialSkin, creationFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable createProvider(Skin skin, Func<Drawable> creationFunction)
|
||||||
|
{
|
||||||
|
var mainProvider = new SkinProvidingContainer(skin);
|
||||||
|
|
||||||
|
return mainProvider
|
||||||
|
.WithChild(new SkinProvidingContainer(Ruleset.Value.CreateInstance().CreateLegacySkinProvider(mainProvider))
|
||||||
|
{
|
||||||
|
Child = creationFunction()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestLegacySkin : LegacySkin
|
private class TestLegacySkin : LegacySkin
|
||||||
|
@ -6,29 +6,23 @@ using System.Collections.Generic;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Game.Graphics.Cursor;
|
|
||||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneGameplayCursor : OsuTestScene, IProvideCursor
|
public class TestSceneGameplayCursor : SkinnableTestScene
|
||||||
{
|
{
|
||||||
private GameplayCursorContainer cursorContainer;
|
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(CursorTrail) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(CursorTrail) };
|
||||||
|
|
||||||
public CursorContainer Cursor => cursorContainer;
|
|
||||||
|
|
||||||
public bool ProvidingUserCursor => true;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Add(cursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both });
|
SetContents(() => new OsuCursorContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
157
osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
Normal file
157
osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneSkinFallbacks : PlayerTestScene
|
||||||
|
{
|
||||||
|
private readonly TestSource testUserSkin;
|
||||||
|
private readonly TestSource testBeatmapSkin;
|
||||||
|
|
||||||
|
public TestSceneSkinFallbacks()
|
||||||
|
: base(new OsuRuleset())
|
||||||
|
{
|
||||||
|
testUserSkin = new TestSource("user");
|
||||||
|
testBeatmapSkin = new TestSource("beatmap");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBeatmapSkinDefault()
|
||||||
|
{
|
||||||
|
AddStep("enable user provider", () => testUserSkin.Enabled = true);
|
||||||
|
|
||||||
|
AddStep("enable beatmap skin", () => LocalConfig.Set<bool>(OsuSetting.BeatmapSkins, true));
|
||||||
|
checkNextHitObject("beatmap");
|
||||||
|
|
||||||
|
AddStep("disable beatmap skin", () => LocalConfig.Set<bool>(OsuSetting.BeatmapSkins, false));
|
||||||
|
checkNextHitObject("user");
|
||||||
|
|
||||||
|
AddStep("disable user provider", () => testUserSkin.Enabled = false);
|
||||||
|
checkNextHitObject(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNextHitObject(string skin) =>
|
||||||
|
AddUntilStep($"check skin from {skin}", () =>
|
||||||
|
{
|
||||||
|
var firstObject = ((TestPlayer)Player).DrawableRuleset.Playfield.HitObjectContainer.AliveObjects.OfType<DrawableHitCircle>().FirstOrDefault();
|
||||||
|
|
||||||
|
if (firstObject == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var skinnable = firstObject.ApproachCircle.Child as SkinnableDrawable;
|
||||||
|
|
||||||
|
if (skin == null && skinnable?.Drawable is Sprite)
|
||||||
|
// check for default skin provider
|
||||||
|
return true;
|
||||||
|
|
||||||
|
var text = skinnable?.Drawable as SpriteText;
|
||||||
|
|
||||||
|
return text?.Text == skin;
|
||||||
|
});
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private AudioManager audio { get; set; }
|
||||||
|
|
||||||
|
protected override Player CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(testUserSkin);
|
||||||
|
|
||||||
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) => new CustomSkinWorkingBeatmap(beatmap, Clock, audio, testBeatmapSkin);
|
||||||
|
|
||||||
|
public class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
||||||
|
{
|
||||||
|
private readonly ISkinSource skin;
|
||||||
|
|
||||||
|
public CustomSkinWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock frameBasedClock, AudioManager audio, ISkinSource skin)
|
||||||
|
: base(beatmap, frameBasedClock, audio)
|
||||||
|
{
|
||||||
|
this.skin = skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override ISkin GetSkin() => skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SkinProvidingPlayer : TestPlayer
|
||||||
|
{
|
||||||
|
private readonly TestSource userSkin;
|
||||||
|
|
||||||
|
public SkinProvidingPlayer(TestSource userSkin)
|
||||||
|
{
|
||||||
|
this.userSkin = userSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DependencyContainer dependencies;
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
|
dependencies.CacheAs<ISkinSource>(userSkin);
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestSource : ISkinSource
|
||||||
|
{
|
||||||
|
private readonly string identifier;
|
||||||
|
|
||||||
|
public TestSource(string identifier)
|
||||||
|
{
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable GetDrawableComponent(string componentName)
|
||||||
|
{
|
||||||
|
if (!enabled) return null;
|
||||||
|
|
||||||
|
return new SpriteText
|
||||||
|
{
|
||||||
|
Text = identifier,
|
||||||
|
Font = OsuFont.Default.With(size: 30),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture GetTexture(string componentName) => null;
|
||||||
|
|
||||||
|
public SampleChannel GetSample(ISampleInfo sampleInfo) => null;
|
||||||
|
|
||||||
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => default;
|
||||||
|
|
||||||
|
public event Action SourceChanged;
|
||||||
|
|
||||||
|
private bool enabled = true;
|
||||||
|
|
||||||
|
public bool Enabled
|
||||||
|
{
|
||||||
|
get => enabled;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
enabled = value;
|
||||||
|
SourceChanged?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
public class DrawableOsuEditRuleset : DrawableOsuRuleset
|
public class DrawableOsuEditRuleset : DrawableOsuRuleset
|
||||||
{
|
{
|
||||||
public DrawableOsuEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableOsuEditRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
=> new DrawableOsuEditRuleset(ruleset, beatmap, mods);
|
=> new DrawableOsuEditRuleset(ruleset, beatmap, mods);
|
||||||
|
|
||||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||||
|
@ -23,13 +23,15 @@ using osu.Game.Rulesets.Difficulty;
|
|||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Configuration;
|
using osu.Game.Rulesets.Osu.Configuration;
|
||||||
using osu.Game.Rulesets.Osu.Difficulty;
|
using osu.Game.Rulesets.Osu.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Osu.Skinning;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu
|
namespace osu.Game.Rulesets.Osu
|
||||||
{
|
{
|
||||||
public class OsuRuleset : Ruleset
|
public class OsuRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableOsuRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableOsuRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
||||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
||||||
|
|
||||||
@ -163,6 +165,8 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
|
|
||||||
public override RulesetSettingsSubsection CreateSettings() => new OsuSettingsSubsection(this);
|
public override RulesetSettingsSubsection CreateSettings() => new OsuSettingsSubsection(this);
|
||||||
|
|
||||||
|
public override ISkin CreateLegacySkinProvider(ISkinSource source) => new OsuLegacySkin(source);
|
||||||
|
|
||||||
public override int? LegacyID => 0;
|
public override int? LegacyID => 0;
|
||||||
|
|
||||||
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame();
|
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame();
|
||||||
|
42
osu.Game.Rulesets.Osu/Skinning/LegacyCursor.cs
Normal file
42
osu.Game.Rulesets.Osu/Skinning/LegacyCursor.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning
|
||||||
|
{
|
||||||
|
public class LegacyCursor : CompositeDrawable
|
||||||
|
{
|
||||||
|
public LegacyCursor()
|
||||||
|
{
|
||||||
|
Size = new Vector2(50);
|
||||||
|
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(ISkinSource skin)
|
||||||
|
{
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new NonPlayfieldSprite
|
||||||
|
{
|
||||||
|
Texture = skin.GetTexture("cursormiddle"),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
new NonPlayfieldSprite
|
||||||
|
{
|
||||||
|
Texture = skin.GetTexture("cursor"),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
Normal file
81
osu.Game.Rulesets.Osu/Skinning/LegacyMainCirclePiece.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// 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.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning
|
||||||
|
{
|
||||||
|
public class LegacyMainCirclePiece : CompositeDrawable
|
||||||
|
{
|
||||||
|
public LegacyMainCirclePiece()
|
||||||
|
{
|
||||||
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
|
||||||
|
|
||||||
|
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(DrawableHitObject drawableObject, ISkinSource skin)
|
||||||
|
{
|
||||||
|
Sprite hitCircleSprite;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
hitCircleSprite = new Sprite
|
||||||
|
{
|
||||||
|
Texture = skin.GetTexture("hitcircle"),
|
||||||
|
Colour = drawableObject.AccentColour.Value,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
new SkinnableSpriteText("Play/osu/number-text", _ => new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Numeric.With(size: 40),
|
||||||
|
UseFullGlyphHeight = false,
|
||||||
|
}, confineMode: ConfineMode.NoScaling)
|
||||||
|
{
|
||||||
|
Text = (((IHasComboInformation)drawableObject.HitObject).IndexInCurrentCombo + 1).ToString()
|
||||||
|
},
|
||||||
|
new Sprite
|
||||||
|
{
|
||||||
|
Texture = skin.GetTexture("hitcircleoverlay"),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
state.BindTo(drawableObject.State);
|
||||||
|
state.BindValueChanged(updateState, true);
|
||||||
|
|
||||||
|
accentColour.BindTo(drawableObject.AccentColour);
|
||||||
|
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState(ValueChangedEvent<ArmedState> state)
|
||||||
|
{
|
||||||
|
const double legacy_fade_duration = 240;
|
||||||
|
|
||||||
|
switch (state.NewValue)
|
||||||
|
{
|
||||||
|
case ArmedState.Hit:
|
||||||
|
this.FadeOut(legacy_fade_duration, Easing.Out);
|
||||||
|
this.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
Normal file
44
osu.Game.Rulesets.Osu/Skinning/LegacySliderBall.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// 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.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning
|
||||||
|
{
|
||||||
|
public class LegacySliderBall : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly Drawable animationContent;
|
||||||
|
|
||||||
|
public LegacySliderBall(Drawable animationContent)
|
||||||
|
{
|
||||||
|
this.animationContent = animationContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(ISkinSource skin, DrawableHitObject drawableObject)
|
||||||
|
{
|
||||||
|
animationContent.Colour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Color4.White;
|
||||||
|
|
||||||
|
InternalChildren = new[]
|
||||||
|
{
|
||||||
|
new Sprite
|
||||||
|
{
|
||||||
|
Texture = skin.GetTexture("sliderb-nd"),
|
||||||
|
Colour = new Color4(5, 5, 5, 255),
|
||||||
|
},
|
||||||
|
animationContent,
|
||||||
|
new Sprite
|
||||||
|
{
|
||||||
|
Texture = skin.GetTexture("sliderb-spec"),
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
osu.Game.Rulesets.Osu/Skinning/NonPlayfieldSprite.cs
Normal file
28
osu.Game.Rulesets.Osu/Skinning/NonPlayfieldSprite.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A sprite which is displayed within the playfield, but historically was not considered part of the playfield.
|
||||||
|
/// Performs scale adjustment to undo the scale applied by <see cref="PlayfieldAdjustmentContainer"/> (osu! ruleset specifically).
|
||||||
|
/// </summary>
|
||||||
|
public class NonPlayfieldSprite : Sprite
|
||||||
|
{
|
||||||
|
public override Texture Texture
|
||||||
|
{
|
||||||
|
get => base.Texture;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
// stable "magic ratio". see OsuPlayfieldAdjustmentContainer for full explanation.
|
||||||
|
value.ScaleAdjust *= 1.6f;
|
||||||
|
base.Texture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
122
osu.Game.Rulesets.Osu/Skinning/OsuLegacySkin.cs
Normal file
122
osu.Game.Rulesets.Osu/Skinning/OsuLegacySkin.cs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
// 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 osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Skinning
|
||||||
|
{
|
||||||
|
public class OsuLegacySkin : ISkin
|
||||||
|
{
|
||||||
|
private readonly ISkin source;
|
||||||
|
|
||||||
|
private Lazy<SkinConfiguration> configuration;
|
||||||
|
|
||||||
|
private Lazy<bool> hasHitCircle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// On osu-stable, hitcircles have 5 pixels of transparent padding on each side to allow for shadows etc.
|
||||||
|
/// Their hittable area is 128px, but the actual circle portion is 118px.
|
||||||
|
/// We must account for some gameplay elements such as slider bodies, where this padding is not present.
|
||||||
|
/// </summary>
|
||||||
|
private const float legacy_circle_radius = 64 - 5;
|
||||||
|
|
||||||
|
public OsuLegacySkin(ISkinSource source)
|
||||||
|
{
|
||||||
|
this.source = source;
|
||||||
|
|
||||||
|
source.SourceChanged += sourceChanged;
|
||||||
|
sourceChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sourceChanged()
|
||||||
|
{
|
||||||
|
// these need to be lazy in order to ensure they aren't called before the dependencies have been loaded into our source.
|
||||||
|
configuration = new Lazy<SkinConfiguration>(() =>
|
||||||
|
{
|
||||||
|
var config = new SkinConfiguration();
|
||||||
|
if (hasHitCircle.Value)
|
||||||
|
config.SliderPathRadius = legacy_circle_radius;
|
||||||
|
|
||||||
|
// defaults should only be applied for non-beatmap skins (which are parsed via this constructor).
|
||||||
|
config.CustomColours["SliderBall"] =
|
||||||
|
source.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.TryGetValue("SliderBall", out var val) ? val : (Color4?)null)
|
||||||
|
?? new Color4(2, 170, 255, 255);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
|
hasHitCircle = new Lazy<bool>(() => source.GetTexture("hitcircle") != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable GetDrawableComponent(string componentName)
|
||||||
|
{
|
||||||
|
switch (componentName)
|
||||||
|
{
|
||||||
|
case "Play/osu/sliderfollowcircle":
|
||||||
|
return this.GetAnimation(componentName, true, true);
|
||||||
|
|
||||||
|
case "Play/osu/sliderball":
|
||||||
|
var sliderBallContent = this.GetAnimation("sliderb", true, true, "");
|
||||||
|
|
||||||
|
if (sliderBallContent != null)
|
||||||
|
{
|
||||||
|
var size = sliderBallContent.Size;
|
||||||
|
|
||||||
|
sliderBallContent.RelativeSizeAxes = Axes.Both;
|
||||||
|
sliderBallContent.Size = Vector2.One;
|
||||||
|
|
||||||
|
return new LegacySliderBall(sliderBallContent)
|
||||||
|
{
|
||||||
|
Size = size
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
case "Play/osu/hitcircle":
|
||||||
|
if (hasHitCircle.Value)
|
||||||
|
return new LegacyMainCirclePiece();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
case "Play/osu/cursor":
|
||||||
|
if (source.GetTexture("cursor") != null)
|
||||||
|
return new LegacyCursor();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
case "Play/osu/number-text":
|
||||||
|
|
||||||
|
string font = GetValue<SkinConfiguration, string>(config => config.HitCircleFont);
|
||||||
|
var overlap = GetValue<SkinConfiguration, float>(config => config.HitCircleOverlap);
|
||||||
|
|
||||||
|
return !hasFont(font)
|
||||||
|
? null
|
||||||
|
: new LegacySpriteText(source, font)
|
||||||
|
{
|
||||||
|
// Spacing value was reverse-engineered from the ratio of the rendered sprite size in the visual inspector vs the actual texture size
|
||||||
|
Scale = new Vector2(0.96f),
|
||||||
|
Spacing = new Vector2(-overlap * 0.89f, 0)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||||
|
|
||||||
|
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
||||||
|
|
||||||
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration
|
||||||
|
=> configuration.Value is TConfiguration conf ? query.Invoke(conf) : source.GetValue(query);
|
||||||
|
|
||||||
|
private bool hasFont(string fontName) => source.GetTexture($"{fontName}-0") != null;
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
{
|
{
|
||||||
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
||||||
|
|
||||||
public DrawableOsuRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableOsuRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
},
|
},
|
||||||
// Todo: This should not exist, but currently helps to reduce LOH allocations due to unbinding skin source events on judgement disposal
|
// Todo: This should not exist, but currently helps to reduce LOH allocations due to unbinding skin source events on judgement disposal
|
||||||
// Todo: Remove when hitobjects are properly pooled
|
// Todo: Remove when hitobjects are properly pooled
|
||||||
new LocalSkinOverrideContainer(null)
|
new SkinProvidingContainer(null)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Child = HitObjectContainer,
|
Child = HitObjectContainer,
|
||||||
},
|
},
|
||||||
approachCircles = new ApproachCircleProxyContainer
|
approachCircles = new ApproachCircleProxyContainer
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
{
|
{
|
||||||
public class TaikoRuleset : Ruleset
|
public class TaikoRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableTaikoRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableTaikoRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
||||||
|
|
||||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
protected override bool UserScrollSpeedAdjustment => false;
|
protected override bool UserScrollSpeedAdjustment => false;
|
||||||
|
|
||||||
public DrawableTaikoRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableTaikoRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Left;
|
Direction.Value = ScrollingDirection.Left;
|
||||||
|
@ -16,15 +16,13 @@ using osu.Game.Rulesets.Osu.Edit;
|
|||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editor
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
[Cached(Type = typeof(IPlacementHandler))]
|
public class TestSceneHitObjectComposer : OsuTestScene
|
||||||
public class TestSceneHitObjectComposer : OsuTestScene, IPlacementHandler
|
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
@ -39,8 +37,6 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
typeof(HitCirclePlacementBlueprint),
|
typeof(HitCirclePlacementBlueprint),
|
||||||
};
|
};
|
||||||
|
|
||||||
private HitObjectComposer composer;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -67,15 +63,7 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
Dependencies.CacheAs<IAdjustableClock>(clock);
|
Dependencies.CacheAs<IAdjustableClock>(clock);
|
||||||
Dependencies.CacheAs<IFrameBasedClock>(clock);
|
Dependencies.CacheAs<IFrameBasedClock>(clock);
|
||||||
|
|
||||||
Child = composer = new OsuHitObjectComposer(new OsuRuleset());
|
Child = new OsuHitObjectComposer(new OsuRuleset());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginPlacement(HitObject hitObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EndPlacement(HitObject hitObject) => composer.Add(hitObject);
|
|
||||||
|
|
||||||
public void Delete(HitObject hitObject) => composer.Remove(hitObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
119
osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs
Normal file
119
osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
|
{
|
||||||
|
public class TestSceneBarHitErrorMeter : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(HitErrorMeter),
|
||||||
|
};
|
||||||
|
|
||||||
|
private HitErrorMeter meter;
|
||||||
|
private HitErrorMeter meter2;
|
||||||
|
private HitWindows hitWindows;
|
||||||
|
|
||||||
|
public TestSceneBarHitErrorMeter()
|
||||||
|
{
|
||||||
|
recreateDisplay(new OsuHitWindows(), 5);
|
||||||
|
|
||||||
|
AddRepeatStep("New random judgement", () => newJudgement(), 40);
|
||||||
|
|
||||||
|
AddRepeatStep("New max negative", () => newJudgement(-hitWindows.HalfWindowFor(HitResult.Meh)), 20);
|
||||||
|
AddRepeatStep("New max positive", () => newJudgement(hitWindows.HalfWindowFor(HitResult.Meh)), 20);
|
||||||
|
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOsu()
|
||||||
|
{
|
||||||
|
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
|
||||||
|
AddStep("OD 10", () => recreateDisplay(new OsuHitWindows(), 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTaiko()
|
||||||
|
{
|
||||||
|
AddStep("OD 1", () => recreateDisplay(new TaikoHitWindows(), 1));
|
||||||
|
AddStep("OD 10", () => recreateDisplay(new TaikoHitWindows(), 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMania()
|
||||||
|
{
|
||||||
|
AddStep("OD 1", () => recreateDisplay(new ManiaHitWindows(), 1));
|
||||||
|
AddStep("OD 10", () => recreateDisplay(new ManiaHitWindows(), 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCatch()
|
||||||
|
{
|
||||||
|
AddStep("OD 1", () => recreateDisplay(new CatchHitWindows(), 1));
|
||||||
|
AddStep("OD 10", () => recreateDisplay(new CatchHitWindows(), 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
|
||||||
|
{
|
||||||
|
this.hitWindows = hitWindows;
|
||||||
|
|
||||||
|
hitWindows?.SetDifficulty(overallDifficulty);
|
||||||
|
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
Add(new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new SpriteText { Text = $@"Great: {hitWindows?.Great}" },
|
||||||
|
new SpriteText { Text = $@"Good: {hitWindows?.Good}" },
|
||||||
|
new SpriteText { Text = $@"Meh: {hitWindows?.Meh}" },
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Add(meter = new BarHitErrorMeter(hitWindows, true)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
});
|
||||||
|
|
||||||
|
Add(meter2 = new BarHitErrorMeter(hitWindows, false)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void newJudgement(double offset = 0)
|
||||||
|
{
|
||||||
|
var judgement = new JudgementResult(new Judgement())
|
||||||
|
{
|
||||||
|
TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset,
|
||||||
|
Type = HitResult.Perfect,
|
||||||
|
};
|
||||||
|
|
||||||
|
meter.OnNewJudgement(judgement);
|
||||||
|
meter2.OnNewJudgement(judgement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -174,7 +174,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type) => throw new NotImplementedException();
|
public override IEnumerable<Mod> GetModsFor(ModType type) => throw new NotImplementedException();
|
||||||
|
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new TestDrawableScrollingRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new TestDrawableScrollingRuleset(this, beatmap, mods);
|
||||||
|
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TestBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TestBeatmapConverter(beatmap);
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
|
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
|
||||||
|
|
||||||
public TestDrawableScrollingRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public TestDrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
TimeRange.Value = time_range;
|
TimeRange.Value = time_range;
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddStep("setup layout larger source", () =>
|
AddStep("setup layout larger source", () =>
|
||||||
{
|
{
|
||||||
Child = new LocalSkinOverrideContainer(new SizedSource(50))
|
Child = new SkinProvidingContainer(new SizedSource(50))
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = fill = new FillFlowContainer<ExposedSkinnableDrawable>
|
Child = fill = new FillFlowContainer<ExposedSkinnableDrawable>
|
||||||
@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddStep("setup layout larger source", () =>
|
AddStep("setup layout larger source", () =>
|
||||||
{
|
{
|
||||||
Child = new LocalSkinOverrideContainer(new SizedSource(30))
|
Child = new SkinProvidingContainer(new SizedSource(30))
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = fill = new FillFlowContainer<ExposedSkinnableDrawable>
|
Child = fill = new FillFlowContainer<ExposedSkinnableDrawable>
|
||||||
@ -96,7 +96,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Child = new SkinSourceContainer
|
Child = new SkinSourceContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = new LocalSkinOverrideContainer(secondarySource)
|
Child = new SkinProvidingContainer(secondarySource)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)
|
Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)
|
||||||
@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Child = new SkinSourceContainer
|
Child = new SkinSourceContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = target = new LocalSkinOverrideContainer(secondarySource)
|
Child = target = new SkinProvidingContainer(secondarySource)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<PackageReference Include="DeepEqual" Version="2.0.0" />
|
<PackageReference Include="DeepEqual" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Beatmap containing converted HitObjects.
|
/// A Beatmap containing converted HitObjects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Beatmap<T> : IBeatmap
|
public class Beatmap<T> : IBeatmap<T>
|
||||||
where T : HitObject
|
where T : HitObject
|
||||||
{
|
{
|
||||||
public BeatmapInfo BeatmapInfo { get; set; } = new BeatmapInfo
|
public BeatmapInfo BeatmapInfo { get; set; } = new BeatmapInfo
|
||||||
@ -36,17 +36,13 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Total amount of break time in the beatmap.
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The HitObjects this Beatmap contains.
|
|
||||||
/// </summary>
|
|
||||||
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
||||||
public List<T> HitObjects = new List<T>();
|
public List<T> HitObjects { get; set; } = new List<T>();
|
||||||
|
|
||||||
|
IReadOnlyList<T> IBeatmap<T>.HitObjects => HitObjects;
|
||||||
|
|
||||||
IReadOnlyList<HitObject> IBeatmap.HitObjects => HitObjects;
|
IReadOnlyList<HitObject> IBeatmap.HitObjects => HitObjects;
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ namespace osu.Game.Beatmaps
|
|||||||
return storyboard;
|
return storyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Skin GetSkin()
|
protected override ISkin GetSkin()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||||
|
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -53,4 +53,13 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <returns>The shallow-cloned beatmap.</returns>
|
/// <returns>The shallow-cloned beatmap.</returns>
|
||||||
IBeatmap Clone();
|
IBeatmap Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IBeatmap<out T> : IBeatmap
|
||||||
|
where T : HitObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The hitobjects contained by this beatmap.
|
||||||
|
/// </summary>
|
||||||
|
new IReadOnlyList<T> HitObjects { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
61
osu.Game/Beatmaps/IWorkingBeatmap.cs
Normal file
61
osu.Game/Beatmaps/IWorkingBeatmap.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// 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 osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps
|
||||||
|
{
|
||||||
|
public interface IWorkingBeatmap
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the <see cref="IBeatmap"/> which this <see cref="WorkingBeatmap"/> represents.
|
||||||
|
/// </summary>
|
||||||
|
IBeatmap Beatmap { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the background for this <see cref="WorkingBeatmap"/>.
|
||||||
|
/// </summary>
|
||||||
|
Texture Background { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the audio track for this <see cref="WorkingBeatmap"/>.
|
||||||
|
/// </summary>
|
||||||
|
Track Track { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the <see cref="Waveform"/> for the <see cref="Track"/> of this <see cref="WorkingBeatmap"/>.
|
||||||
|
/// </summary>
|
||||||
|
Waveform Waveform { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the <see cref="Storyboard"/> which this <see cref="WorkingBeatmap"/> provides.
|
||||||
|
/// </summary>
|
||||||
|
Storyboard Storyboard { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the <see cref="Skin"/> which this <see cref="WorkingBeatmap"/> provides.
|
||||||
|
/// </summary>
|
||||||
|
ISkin Skin { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a playable <see cref="IBeatmap"/> from <see cref="Beatmap"/> using the applicable converters for a specific <see cref="RulesetInfo"/>.
|
||||||
|
/// <para>
|
||||||
|
/// The returned <see cref="IBeatmap"/> is in a playable state - all <see cref="HitObject"/> and <see cref="BeatmapDifficulty"/> <see cref="Mod"/>s
|
||||||
|
/// have been applied, and <see cref="HitObject"/>s have been fully constructed.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ruleset">The <see cref="RulesetInfo"/> to create a playable <see cref="IBeatmap"/> for.</param>
|
||||||
|
/// <param name="mods">The <see cref="Mod"/>s to apply to the <see cref="IBeatmap"/>.</param>
|
||||||
|
/// <returns>The converted <see cref="IBeatmap"/>.</returns>
|
||||||
|
/// <exception cref="BeatmapInvalidForRulesetException">If <see cref="Beatmap"/> could not be converted to <paramref name="ruleset"/>.</exception>
|
||||||
|
IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods);
|
||||||
|
}
|
||||||
|
}
|
@ -16,14 +16,13 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Statistics;
|
using osu.Framework.Statistics;
|
||||||
using osu.Game.IO.Serialization;
|
using osu.Game.IO.Serialization;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
public abstract class WorkingBeatmap : IDisposable
|
public abstract class WorkingBeatmap : IWorkingBeatmap, IDisposable
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo BeatmapInfo;
|
public readonly BeatmapInfo BeatmapInfo;
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ namespace osu.Game.Beatmaps
|
|||||||
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
|
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
|
||||||
waveform = new RecyclableLazy<Waveform>(GetWaveform);
|
waveform = new RecyclableLazy<Waveform>(GetWaveform);
|
||||||
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
|
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
|
||||||
skin = new RecyclableLazy<Skin>(GetSkin);
|
skin = new RecyclableLazy<ISkin>(GetSkin);
|
||||||
|
|
||||||
total_count.Value++;
|
total_count.Value++;
|
||||||
}
|
}
|
||||||
@ -97,17 +96,6 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <returns>The applicable <see cref="IBeatmapConverter"/>.</returns>
|
/// <returns>The applicable <see cref="IBeatmapConverter"/>.</returns>
|
||||||
protected virtual IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) => ruleset.CreateBeatmapConverter(beatmap);
|
protected virtual IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) => ruleset.CreateBeatmapConverter(beatmap);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs a playable <see cref="IBeatmap"/> from <see cref="Beatmap"/> using the applicable converters for a specific <see cref="RulesetInfo"/>.
|
|
||||||
/// <para>
|
|
||||||
/// The returned <see cref="IBeatmap"/> is in a playable state - all <see cref="HitObject"/> and <see cref="BeatmapDifficulty"/> <see cref="Mod"/>s
|
|
||||||
/// have been applied, and <see cref="HitObject"/>s have been fully constructed.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ruleset">The <see cref="RulesetInfo"/> to create a playable <see cref="IBeatmap"/> for.</param>
|
|
||||||
/// <param name="mods">The <see cref="Mod"/>s to apply to the <see cref="IBeatmap"/>.</param>
|
|
||||||
/// <returns>The converted <see cref="IBeatmap"/>.</returns>
|
|
||||||
/// <exception cref="BeatmapInvalidForRulesetException">If <see cref="Beatmap"/> could not be converted to <paramref name="ruleset"/>.</exception>
|
|
||||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
||||||
{
|
{
|
||||||
var rulesetInstance = ruleset.CreateInstance();
|
var rulesetInstance = ruleset.CreateInstance();
|
||||||
@ -214,10 +202,10 @@ namespace osu.Game.Beatmaps
|
|||||||
private readonly RecyclableLazy<Storyboard> storyboard;
|
private readonly RecyclableLazy<Storyboard> storyboard;
|
||||||
|
|
||||||
public bool SkinLoaded => skin.IsResultAvailable;
|
public bool SkinLoaded => skin.IsResultAvailable;
|
||||||
public Skin Skin => skin.Value;
|
public ISkin Skin => skin.Value;
|
||||||
|
|
||||||
protected virtual Skin GetSkin() => new DefaultSkin();
|
protected virtual ISkin GetSkin() => new DefaultSkin();
|
||||||
private readonly RecyclableLazy<Skin> skin;
|
private readonly RecyclableLazy<ISkin> skin;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transfer pieces of a beatmap to a new one, where possible, to save on loading.
|
/// Transfer pieces of a beatmap to a new one, where possible, to save on loading.
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Configuration
|
|||||||
{
|
{
|
||||||
// UI/selection defaults
|
// UI/selection defaults
|
||||||
Set(OsuSetting.Ruleset, 0, 0, int.MaxValue);
|
Set(OsuSetting.Ruleset, 0, 0, int.MaxValue);
|
||||||
Set(OsuSetting.Skin, 0, 0, int.MaxValue);
|
Set(OsuSetting.Skin, 0, -1, int.MaxValue);
|
||||||
|
|
||||||
Set(OsuSetting.BeatmapDetailTab, BeatmapDetailTab.Details);
|
Set(OsuSetting.BeatmapDetailTab, BeatmapDetailTab.Details);
|
||||||
|
|
||||||
@ -83,6 +83,7 @@ namespace osu.Game.Configuration
|
|||||||
Set(OsuSetting.ShowInterface, true);
|
Set(OsuSetting.ShowInterface, true);
|
||||||
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
|
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
|
||||||
Set(OsuSetting.KeyOverlay, false);
|
Set(OsuSetting.KeyOverlay, false);
|
||||||
|
Set(OsuSetting.ScoreMeter, ScoreMeterType.HitErrorBoth);
|
||||||
|
|
||||||
Set(OsuSetting.FloatingComments, false);
|
Set(OsuSetting.FloatingComments, false);
|
||||||
|
|
||||||
@ -136,6 +137,7 @@ namespace osu.Game.Configuration
|
|||||||
BlurLevel,
|
BlurLevel,
|
||||||
ShowStoryboard,
|
ShowStoryboard,
|
||||||
KeyOverlay,
|
KeyOverlay,
|
||||||
|
ScoreMeter,
|
||||||
FloatingComments,
|
FloatingComments,
|
||||||
ShowInterface,
|
ShowInterface,
|
||||||
ShowHealthDisplayWhenCantFail,
|
ShowHealthDisplayWhenCantFail,
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace osu.Game.Configuration
|
namespace osu.Game.Configuration
|
||||||
{
|
{
|
||||||
public enum ScoreMeterType
|
public enum ScoreMeterType
|
||||||
{
|
{
|
||||||
|
[Description("None")]
|
||||||
None,
|
None,
|
||||||
Colour,
|
|
||||||
Error
|
[Description("Hit Error (left)")]
|
||||||
|
HitErrorLeft,
|
||||||
|
|
||||||
|
[Description("Hit Error (right)")]
|
||||||
|
HitErrorRight,
|
||||||
|
|
||||||
|
[Description("Hit Error (both)")]
|
||||||
|
HitErrorBoth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,26 @@ namespace osu.Game
|
|||||||
// bind config int to database SkinInfo
|
// bind config int to database SkinInfo
|
||||||
configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin);
|
configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin);
|
||||||
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID;
|
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID;
|
||||||
configSkin.ValueChanged += skinId => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == skinId.NewValue) ?? SkinInfo.Default;
|
configSkin.ValueChanged += skinId =>
|
||||||
|
{
|
||||||
|
var skinInfo = SkinManager.Query(s => s.ID == skinId.NewValue);
|
||||||
|
|
||||||
|
if (skinInfo == null)
|
||||||
|
{
|
||||||
|
switch (skinId.NewValue)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
skinInfo = DefaultLegacySkin.Info;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
skinInfo = SkinInfo.Default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SkinManager.CurrentSkinInfo.Value = skinInfo;
|
||||||
|
};
|
||||||
configSkin.TriggerChange();
|
configSkin.TriggerChange();
|
||||||
|
|
||||||
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
||||||
|
@ -158,7 +158,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
runMigrations();
|
runMigrations();
|
||||||
|
|
||||||
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio));
|
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
||||||
dependencies.CacheAs<ISkinSource>(SkinManager);
|
dependencies.CacheAs<ISkinSource>(SkinManager);
|
||||||
|
|
||||||
API = new APIAccess(LocalConfig);
|
API = new APIAccess(LocalConfig);
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Chat.Selection
|
|||||||
private Color4 topicColour;
|
private Color4 topicColour;
|
||||||
private Color4 hoverColour;
|
private Color4 hoverColour;
|
||||||
|
|
||||||
public IEnumerable<string> FilterTerms => new[] { channel.Name };
|
public IEnumerable<string> FilterTerms => new[] { channel.Name, channel.Topic };
|
||||||
|
|
||||||
public bool MatchingFilter
|
public bool MatchingFilter
|
||||||
{
|
{
|
||||||
|
@ -296,7 +296,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
this.MoveTo(pos, 200, Easing.OutQuint);
|
this.MoveTo(pos, 200, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
instantMove |= !IsPresent;
|
||||||
|
this.FadeIn(200, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
LabelText = "Always show key overlay",
|
LabelText = "Always show key overlay",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
||||||
},
|
},
|
||||||
|
new SettingsEnumDropdown<ScoreMeterType>
|
||||||
|
{
|
||||||
|
LabelText = "Score meter type",
|
||||||
|
Bindable = config.GetBindable<ScoreMeterType>(OsuSetting.ScoreMeter)
|
||||||
|
},
|
||||||
new SettingsEnumDropdown<ScoringMode>
|
new SettingsEnumDropdown<ScoringMode>
|
||||||
{
|
{
|
||||||
LabelText = "Score display mode",
|
LabelText = "Score display mode",
|
||||||
|
@ -1,116 +0,0 @@
|
|||||||
// 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.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
|
||||||
{
|
|
||||||
public abstract class DrawableEditRuleset : CompositeDrawable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="Playfield"/> contained by this <see cref="DrawableEditRuleset"/>.
|
|
||||||
/// </summary>
|
|
||||||
public abstract Playfield Playfield { get; }
|
|
||||||
|
|
||||||
public abstract PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer();
|
|
||||||
|
|
||||||
internal DrawableEditRuleset()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmap"/> and displays a visual representation of it.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
|
||||||
/// <returns>The visual representation of <paramref name="hitObject"/>.</returns>
|
|
||||||
internal abstract DrawableHitObject Add(HitObject hitObject);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Removes a <see cref="HitObject"/> from the <see cref="Beatmap"/> and the display.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to remove.</param>
|
|
||||||
/// <returns>The visual representation of the removed <paramref name="hitObject"/>.</returns>
|
|
||||||
internal abstract DrawableHitObject Remove(HitObject hitObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DrawableEditRuleset<TObject> : DrawableEditRuleset
|
|
||||||
where TObject : HitObject
|
|
||||||
{
|
|
||||||
public override Playfield Playfield => drawableRuleset.Playfield;
|
|
||||||
|
|
||||||
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => drawableRuleset.CreatePlayfieldAdjustmentContainer();
|
|
||||||
|
|
||||||
private Ruleset ruleset => drawableRuleset.Ruleset;
|
|
||||||
private Beatmap<TObject> beatmap => drawableRuleset.Beatmap;
|
|
||||||
|
|
||||||
private readonly DrawableRuleset<TObject> drawableRuleset;
|
|
||||||
|
|
||||||
public DrawableEditRuleset(DrawableRuleset<TObject> drawableRuleset)
|
|
||||||
{
|
|
||||||
this.drawableRuleset = drawableRuleset;
|
|
||||||
|
|
||||||
InternalChild = drawableRuleset;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
drawableRuleset.FrameStablePlayback = false;
|
|
||||||
Playfield.DisplayJudgements.Value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override DrawableHitObject Add(HitObject hitObject)
|
|
||||||
{
|
|
||||||
var tObject = (TObject)hitObject;
|
|
||||||
|
|
||||||
// Add to beatmap, preserving sorting order
|
|
||||||
var insertionIndex = beatmap.HitObjects.FindLastIndex(h => h.StartTime <= hitObject.StartTime);
|
|
||||||
beatmap.HitObjects.Insert(insertionIndex + 1, tObject);
|
|
||||||
|
|
||||||
// Process object
|
|
||||||
var processor = ruleset.CreateBeatmapProcessor(beatmap);
|
|
||||||
|
|
||||||
processor?.PreProcess();
|
|
||||||
tObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
|
|
||||||
processor?.PostProcess();
|
|
||||||
|
|
||||||
// Add visual representation
|
|
||||||
var drawableObject = drawableRuleset.CreateDrawableRepresentation(tObject);
|
|
||||||
|
|
||||||
drawableRuleset.Playfield.Add(drawableObject);
|
|
||||||
drawableRuleset.Playfield.PostProcess();
|
|
||||||
|
|
||||||
return drawableObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override DrawableHitObject Remove(HitObject hitObject)
|
|
||||||
{
|
|
||||||
var tObject = (TObject)hitObject;
|
|
||||||
|
|
||||||
// Remove from beatmap
|
|
||||||
beatmap.HitObjects.Remove(tObject);
|
|
||||||
|
|
||||||
// Process the beatmap
|
|
||||||
var processor = ruleset.CreateBeatmapProcessor(beatmap);
|
|
||||||
|
|
||||||
processor?.PreProcess();
|
|
||||||
processor?.PostProcess();
|
|
||||||
|
|
||||||
// Remove visual representation
|
|
||||||
var drawableObject = Playfield.AllHitObjects.Single(d => d.HitObject == hitObject);
|
|
||||||
|
|
||||||
drawableRuleset.Playfield.Remove(drawableObject);
|
|
||||||
drawableRuleset.Playfield.PostProcess();
|
|
||||||
|
|
||||||
return drawableObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
80
osu.Game/Rulesets/Edit/DrawableEditRulesetWrapper.cs
Normal file
80
osu.Game/Rulesets/Edit/DrawableEditRulesetWrapper.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Edit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A wrapper for a <see cref="DrawableRuleset{TObject}"/>. Handles adding visual representations of <see cref="HitObject"/>s to the underlying <see cref="DrawableRuleset{TObject}"/>.
|
||||||
|
/// </summary>
|
||||||
|
internal class DrawableEditRulesetWrapper<TObject> : CompositeDrawable
|
||||||
|
where TObject : HitObject
|
||||||
|
{
|
||||||
|
public Playfield Playfield => drawableRuleset.Playfield;
|
||||||
|
|
||||||
|
private readonly DrawableRuleset<TObject> drawableRuleset;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IEditorBeatmap<TObject> beatmap { get; set; }
|
||||||
|
|
||||||
|
public DrawableEditRulesetWrapper(DrawableRuleset<TObject> drawableRuleset)
|
||||||
|
{
|
||||||
|
this.drawableRuleset = drawableRuleset;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChild = drawableRuleset;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
drawableRuleset.FrameStablePlayback = false;
|
||||||
|
Playfield.DisplayJudgements.Value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
beatmap.HitObjectAdded += addHitObject;
|
||||||
|
beatmap.HitObjectRemoved += removeHitObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
var drawableObject = drawableRuleset.CreateDrawableRepresentation((TObject)hitObject);
|
||||||
|
|
||||||
|
drawableRuleset.Playfield.Add(drawableObject);
|
||||||
|
drawableRuleset.Playfield.PostProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
var drawableObject = Playfield.AllHitObjects.Single(d => d.HitObject == hitObject);
|
||||||
|
|
||||||
|
drawableRuleset.Playfield.Remove(drawableObject);
|
||||||
|
drawableRuleset.Playfield.PostProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => drawableRuleset.CreatePlayfieldAdjustmentContainer();
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (beatmap != null)
|
||||||
|
{
|
||||||
|
beatmap.HitObjectAdded -= addHitObject;
|
||||||
|
beatmap.HitObjectRemoved -= removeHitObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,45 +18,47 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||||
|
using osu.Game.Screens.Edit.Compose;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
{
|
{
|
||||||
public abstract class HitObjectComposer : CompositeDrawable
|
[Cached(Type = typeof(IPlacementHandler))]
|
||||||
|
public abstract class HitObjectComposer<TObject> : HitObjectComposer, IPlacementHandler
|
||||||
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
public IEnumerable<DrawableHitObject> HitObjects => DrawableRuleset.Playfield.AllHitObjects;
|
protected IRulesetConfigManager Config { get; private set; }
|
||||||
|
|
||||||
protected readonly Ruleset Ruleset;
|
protected readonly Ruleset Ruleset;
|
||||||
|
|
||||||
protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
private IWorkingBeatmap workingBeatmap;
|
||||||
|
private Beatmap<TObject> playableBeatmap;
|
||||||
protected IRulesetConfigManager Config { get; private set; }
|
private EditorBeatmap<TObject> editorBeatmap;
|
||||||
|
private IBeatmapProcessor beatmapProcessor;
|
||||||
private readonly List<Container> layerContainers = new List<Container>();
|
|
||||||
|
|
||||||
protected DrawableEditRuleset DrawableRuleset { get; private set; }
|
|
||||||
|
|
||||||
|
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
|
||||||
private BlueprintContainer blueprintContainer;
|
private BlueprintContainer blueprintContainer;
|
||||||
|
private readonly List<Container> layerContainers = new List<Container>();
|
||||||
|
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
|
|
||||||
internal HitObjectComposer(Ruleset ruleset)
|
protected HitObjectComposer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Ruleset = ruleset;
|
Ruleset = ruleset;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IBindable<WorkingBeatmap> beatmap, IFrameBasedClock framedClock)
|
private void load(IFrameBasedClock framedClock)
|
||||||
{
|
{
|
||||||
Beatmap.BindTo(beatmap);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DrawableRuleset = CreateDrawableRuleset();
|
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, workingBeatmap, Array.Empty<Mod>()))
|
||||||
DrawableRuleset.Clock = framedClock;
|
{
|
||||||
|
Clock = framedClock
|
||||||
|
};
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -64,10 +66,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var layerBelowRuleset = DrawableRuleset.CreatePlayfieldAdjustmentContainer();
|
var layerBelowRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer();
|
||||||
layerBelowRuleset.Child = new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both };
|
layerBelowRuleset.Child = new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
var layerAboveRuleset = DrawableRuleset.CreatePlayfieldAdjustmentContainer();
|
var layerAboveRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer();
|
||||||
layerAboveRuleset.Child = blueprintContainer = new BlueprintContainer();
|
layerAboveRuleset.Child = blueprintContainer = new BlueprintContainer();
|
||||||
|
|
||||||
layerContainers.Add(layerBelowRuleset);
|
layerContainers.Add(layerBelowRuleset);
|
||||||
@ -98,7 +100,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
layerBelowRuleset,
|
layerBelowRuleset,
|
||||||
DrawableRuleset,
|
drawableRulesetWrapper,
|
||||||
layerAboveRuleset
|
layerAboveRuleset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,6 +120,28 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
toolboxCollection.Items[0].Select();
|
toolboxCollection.Items[0].Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
var parentWorkingBeatmap = parent.Get<IBindable<WorkingBeatmap>>().Value;
|
||||||
|
|
||||||
|
playableBeatmap = (Beatmap<TObject>)parentWorkingBeatmap.GetPlayableBeatmap(Ruleset.RulesetInfo, Array.Empty<Mod>());
|
||||||
|
workingBeatmap = new EditorWorkingBeatmap<TObject>(playableBeatmap, parentWorkingBeatmap);
|
||||||
|
|
||||||
|
beatmapProcessor = Ruleset.CreateBeatmapProcessor(playableBeatmap);
|
||||||
|
|
||||||
|
editorBeatmap = new EditorBeatmap<TObject>(playableBeatmap);
|
||||||
|
editorBeatmap.HitObjectAdded += addHitObject;
|
||||||
|
editorBeatmap.HitObjectRemoved += removeHitObject;
|
||||||
|
|
||||||
|
var dependencies = new DependencyContainer(parent);
|
||||||
|
dependencies.CacheAs<IEditorBeatmap>(editorBeatmap);
|
||||||
|
dependencies.CacheAs<IEditorBeatmap<TObject>>(editorBeatmap);
|
||||||
|
|
||||||
|
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
||||||
|
|
||||||
|
return base.CreateChildDependencies(dependencies);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -125,45 +149,76 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
inputManager = GetContainingInputManager();
|
inputManager = GetContainingInputManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
dependencies.CacheAs(this);
|
|
||||||
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
layerContainers.ForEach(l =>
|
layerContainers.ForEach(l =>
|
||||||
{
|
{
|
||||||
l.Anchor = DrawableRuleset.Playfield.Anchor;
|
l.Anchor = drawableRulesetWrapper.Playfield.Anchor;
|
||||||
l.Origin = DrawableRuleset.Playfield.Origin;
|
l.Origin = drawableRulesetWrapper.Playfield.Origin;
|
||||||
l.Position = DrawableRuleset.Playfield.Position;
|
l.Position = drawableRulesetWrapper.Playfield.Position;
|
||||||
l.Size = DrawableRuleset.Playfield.Size;
|
l.Size = drawableRulesetWrapper.Playfield.Size;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
beatmapProcessor?.PreProcess();
|
||||||
|
hitObject.ApplyDefaults(playableBeatmap.ControlPointInfo, playableBeatmap.BeatmapInfo.BaseDifficulty);
|
||||||
|
beatmapProcessor?.PostProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
beatmapProcessor?.PreProcess();
|
||||||
|
beatmapProcessor?.PostProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<DrawableHitObject> HitObjects => drawableRulesetWrapper.Playfield.AllHitObjects;
|
||||||
|
public override bool CursorInPlacementArea => drawableRulesetWrapper.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
||||||
|
|
||||||
|
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
||||||
|
|
||||||
|
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
||||||
|
|
||||||
|
public void BeginPlacement(HitObject hitObject)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EndPlacement(HitObject hitObject) => editorBeatmap.Add(hitObject);
|
||||||
|
|
||||||
|
public void Delete(HitObject hitObject) => editorBeatmap.Remove(hitObject);
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (editorBeatmap != null)
|
||||||
|
{
|
||||||
|
editorBeatmap.HitObjectAdded -= addHitObject;
|
||||||
|
editorBeatmap.HitObjectRemoved -= removeHitObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Cached(typeof(HitObjectComposer))]
|
||||||
|
public abstract class HitObjectComposer : CompositeDrawable
|
||||||
|
{
|
||||||
|
internal HitObjectComposer()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All the <see cref="DrawableHitObject"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public abstract IEnumerable<DrawableHitObject> HitObjects { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the user's cursor is currently in an area of the <see cref="HitObjectComposer"/> that is valid for placement.
|
/// Whether the user's cursor is currently in an area of the <see cref="HitObjectComposer"/> that is valid for placement.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CursorInPlacementArea => DrawableRuleset.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
public abstract bool CursorInPlacementArea { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
|
||||||
public void Add(HitObject hitObject) => blueprintContainer.AddBlueprintFor(DrawableRuleset.Add(hitObject));
|
|
||||||
|
|
||||||
public void Remove(HitObject hitObject) => blueprintContainer.RemoveBlueprintFor(DrawableRuleset.Remove(hitObject));
|
|
||||||
|
|
||||||
internal abstract DrawableEditRuleset CreateDrawableRuleset();
|
|
||||||
|
|
||||||
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="SelectionBlueprint"/> for a specific <see cref="DrawableHitObject"/>.
|
/// Creates a <see cref="SelectionBlueprint"/> for a specific <see cref="DrawableHitObject"/>.
|
||||||
@ -176,18 +231,4 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
public virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class HitObjectComposer<TObject> : HitObjectComposer
|
|
||||||
where TObject : HitObject
|
|
||||||
{
|
|
||||||
protected HitObjectComposer(Ruleset ruleset)
|
|
||||||
: base(ruleset)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override DrawableEditRuleset CreateDrawableRuleset()
|
|
||||||
=> new DrawableEditRuleset<TObject>(CreateDrawableRuleset(Ruleset, Beatmap.Value, Array.Empty<Mod>()));
|
|
||||||
|
|
||||||
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,19 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
return HitResult.None;
|
return HitResult.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves a mapping of <see cref="HitResult"/>s to their half window timing for all allowed <see cref="HitResult"/>s.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IEnumerable<(HitResult result, double length)> GetAllAvailableHalfWindows()
|
||||||
|
{
|
||||||
|
for (var result = HitResult.Meh; result <= HitResult.Perfect; ++result)
|
||||||
|
{
|
||||||
|
if (IsHitResultAllowed(result))
|
||||||
|
yield return (result, HalfWindowFor(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether it is possible to achieve the provided <see cref="HitResult"/>.
|
/// Check whether it is possible to achieve the provided <see cref="HitResult"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -18,6 +18,7 @@ using osu.Game.Configuration;
|
|||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets
|
namespace osu.Game.Rulesets
|
||||||
{
|
{
|
||||||
@ -44,6 +45,8 @@ namespace osu.Game.Rulesets
|
|||||||
|
|
||||||
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().First();
|
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().First();
|
||||||
|
|
||||||
|
public virtual ISkin CreateLegacySkinProvider(ISkinSource source) => null;
|
||||||
|
|
||||||
protected Ruleset(RulesetInfo rulesetInfo = null)
|
protected Ruleset(RulesetInfo rulesetInfo = null)
|
||||||
{
|
{
|
||||||
RulesetInfo = rulesetInfo ?? createRulesetInfo();
|
RulesetInfo = rulesetInfo ?? createRulesetInfo();
|
||||||
@ -56,7 +59,7 @@ namespace osu.Game.Rulesets
|
|||||||
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
||||||
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public abstract DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
public abstract DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
||||||
|
@ -113,7 +113,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <param name="ruleset">The ruleset being represented.</param>
|
/// <param name="ruleset">The ruleset being represented.</param>
|
||||||
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
||||||
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
||||||
protected DrawableRuleset(Ruleset ruleset, WorkingBeatmap workingBeatmap, IReadOnlyList<Mod> mods)
|
protected DrawableRuleset(Ruleset ruleset, IWorkingBeatmap workingBeatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
if (workingBeatmap == null)
|
if (workingBeatmap == null)
|
||||||
@ -215,10 +215,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
continueResume();
|
continueResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResumeOverlay ResumeOverlay { get; private set; }
|
|
||||||
|
|
||||||
protected virtual ResumeOverlay CreateResumeOverlay() => null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates and adds the visual representation of a <see cref="TObject"/> to this <see cref="DrawableRuleset{TObject}"/>.
|
/// Creates and adds the visual representation of a <see cref="TObject"/> to this <see cref="DrawableRuleset{TObject}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -389,6 +385,13 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract GameplayCursorContainer Cursor { get; }
|
public abstract GameplayCursorContainer Cursor { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An optional overlay used when resuming gameplay from a paused state.
|
||||||
|
/// </summary>
|
||||||
|
public ResumeOverlay ResumeOverlay { get; protected set; }
|
||||||
|
|
||||||
|
protected virtual ResumeOverlay CreateResumeOverlay() => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets a replay to be used, overriding local input.
|
/// Sets a replay to be used, overriding local input.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
[Cached(Type = typeof(IScrollingInfo))]
|
[Cached(Type = typeof(IScrollingInfo))]
|
||||||
private readonly LocalScrollingInfo scrollingInfo;
|
private readonly LocalScrollingInfo scrollingInfo;
|
||||||
|
|
||||||
protected DrawableScrollingRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
protected DrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
scrollingInfo = new LocalScrollingInfo();
|
scrollingInfo = new LocalScrollingInfo();
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
@ -35,5 +38,41 @@ namespace osu.Game.Screens.Edit
|
|||||||
protected override int DefaultMinValue => VALID_DIVISORS.First();
|
protected override int DefaultMinValue => VALID_DIVISORS.First();
|
||||||
protected override int DefaultMaxValue => VALID_DIVISORS.Last();
|
protected override int DefaultMaxValue => VALID_DIVISORS.Last();
|
||||||
protected override int DefaultPrecision => 1;
|
protected override int DefaultPrecision => 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the appropriate colour for a beat divisor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatDivisor">The beat divisor.</param>
|
||||||
|
/// <param name="colours">The set of colours.</param>
|
||||||
|
/// <returns>The applicable colour from <paramref name="colours"/> for <paramref name="beatDivisor"/>.</returns>
|
||||||
|
public static ColourInfo GetColourFor(int beatDivisor, OsuColour colours)
|
||||||
|
{
|
||||||
|
switch (beatDivisor)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
return colours.BlueLight;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
return colours.Blue;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
return colours.BlueDarker;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
return colours.PurpleDark;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
return colours.YellowLight;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
return colours.Yellow;
|
||||||
|
|
||||||
|
case 12:
|
||||||
|
return colours.YellowDarker;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Color4.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
private Marker marker;
|
private Marker marker;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private readonly BindableBeatDivisor beatDivisor;
|
private readonly BindableBeatDivisor beatDivisor;
|
||||||
private readonly int[] availableDivisors;
|
private readonly int[] availableDivisors;
|
||||||
|
|
||||||
@ -204,11 +207,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
foreach (var t in availableDivisors)
|
foreach (var t in availableDivisors)
|
||||||
{
|
{
|
||||||
AddInternal(new Tick(t)
|
AddInternal(new Tick
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
RelativePositionAxes = Axes.X,
|
RelativePositionAxes = Axes.X,
|
||||||
|
Colour = BindableBeatDivisor.GetColourFor(t, colours),
|
||||||
X = getMappedPosition(t)
|
X = getMappedPosition(t)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -284,11 +288,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private class Tick : CompositeDrawable
|
private class Tick : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly int divisor;
|
public Tick()
|
||||||
|
|
||||||
public Tick(int divisor)
|
|
||||||
{
|
{
|
||||||
this.divisor = divisor;
|
|
||||||
Size = new Vector2(2.5f, 10);
|
Size = new Vector2(2.5f, 10);
|
||||||
|
|
||||||
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
|
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
|
||||||
@ -296,42 +297,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
CornerRadius = 0.5f;
|
CornerRadius = 0.5f;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
Colour = getColourForDivisor(divisor, colours);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ColourInfo getColourForDivisor(int divisor, OsuColour colours)
|
|
||||||
{
|
|
||||||
switch (divisor)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
return colours.BlueLight;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
return colours.Blue;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
return colours.BlueDarker;
|
|
||||||
|
|
||||||
case 16:
|
|
||||||
return colours.PurpleDark;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
return colours.YellowLight;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
return colours.Yellow;
|
|
||||||
|
|
||||||
case 12:
|
|
||||||
return colours.YellowDarker;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return Color4.White;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Marker : CompositeDrawable
|
private class Marker : CompositeDrawable
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Framework.Input.States;
|
using osu.Framework.Input.States;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
@ -29,6 +30,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private HitObjectComposer composer { get; set; }
|
private HitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IEditorBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
public BlueprintContainer()
|
public BlueprintContainer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -53,7 +57,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
};
|
};
|
||||||
|
|
||||||
foreach (var obj in composer.HitObjects)
|
foreach (var obj in composer.HitObjects)
|
||||||
AddBlueprintFor(obj);
|
addBlueprintFor(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
beatmap.HitObjectAdded += addBlueprintFor;
|
||||||
|
beatmap.HitObjectRemoved += removeBlueprintFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HitObjectCompositionTool currentTool;
|
private HitObjectCompositionTool currentTool;
|
||||||
@ -75,11 +87,32 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void addBlueprintFor(HitObject hitObject)
|
||||||
/// Adds a blueprint for a <see cref="DrawableHitObject"/> which adds movement support.
|
{
|
||||||
/// </summary>
|
var drawable = composer.HitObjects.FirstOrDefault(d => d.HitObject == hitObject);
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create a blueprint for.</param>
|
if (drawable == null)
|
||||||
public void AddBlueprintFor(DrawableHitObject hitObject)
|
return;
|
||||||
|
|
||||||
|
addBlueprintFor(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeBlueprintFor(HitObject hitObject)
|
||||||
|
{
|
||||||
|
var blueprint = selectionBlueprints.Single(m => m.HitObject.HitObject == hitObject);
|
||||||
|
if (blueprint == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
blueprint.Deselect();
|
||||||
|
|
||||||
|
blueprint.Selected -= onBlueprintSelected;
|
||||||
|
blueprint.Deselected -= onBlueprintDeselected;
|
||||||
|
blueprint.SelectionRequested -= onSelectionRequested;
|
||||||
|
blueprint.DragRequested -= onDragRequested;
|
||||||
|
|
||||||
|
selectionBlueprints.Remove(blueprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addBlueprintFor(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
refreshTool();
|
refreshTool();
|
||||||
|
|
||||||
@ -95,25 +128,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
selectionBlueprints.Add(blueprint);
|
selectionBlueprints.Add(blueprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void removeBlueprintFor(DrawableHitObject hitObject) => removeBlueprintFor(hitObject.HitObject);
|
||||||
/// Removes a blueprint for a <see cref="DrawableHitObject"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> for which to remove the blueprint.</param>
|
|
||||||
public void RemoveBlueprintFor(DrawableHitObject hitObject)
|
|
||||||
{
|
|
||||||
var blueprint = selectionBlueprints.Single(m => m.HitObject == hitObject);
|
|
||||||
if (blueprint == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
blueprint.Deselect();
|
|
||||||
|
|
||||||
blueprint.Selected -= onBlueprintSelected;
|
|
||||||
blueprint.Deselected -= onBlueprintDeselected;
|
|
||||||
blueprint.SelectionRequested -= onSelectionRequested;
|
|
||||||
blueprint.DragRequested -= onDragRequested;
|
|
||||||
|
|
||||||
selectionBlueprints.Remove(blueprint);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
@ -183,6 +198,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent) => selectionHandler.HandleDrag(blueprint, dragEvent);
|
private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent) => selectionHandler.HandleDrag(blueprint, dragEvent);
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (beatmap != null)
|
||||||
|
{
|
||||||
|
beatmap.HitObjectAdded -= addBlueprintFor;
|
||||||
|
beatmap.HitObjectRemoved -= removeBlueprintFor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SelectionBlueprintContainer : Container<SelectionBlueprint>
|
private class SelectionBlueprintContainer : Container<SelectionBlueprint>
|
||||||
{
|
{
|
||||||
protected override int Compare(Drawable x, Drawable y)
|
protected override int Compare(Drawable x, Drawable y)
|
||||||
|
@ -9,15 +9,13 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose
|
namespace osu.Game.Screens.Edit.Compose
|
||||||
{
|
{
|
||||||
[Cached(Type = typeof(IPlacementHandler))]
|
public class ComposeScreen : EditorScreen
|
||||||
public class ComposeScreen : EditorScreen, IPlacementHandler
|
|
||||||
{
|
{
|
||||||
private const float vertical_margins = 10;
|
private const float vertical_margins = 10;
|
||||||
private const float horizontal_margins = 20;
|
private const float horizontal_margins = 20;
|
||||||
@ -119,13 +117,5 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
|
|
||||||
composerContainer.Child = composer;
|
composerContainer.Child = composer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginPlacement(HitObject hitObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EndPlacement(HitObject hitObject) => composer.Add(hitObject);
|
|
||||||
|
|
||||||
public void Delete(HitObject hitObject) => composer.Remove(hitObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
83
osu.Game/Screens/Edit/EditorBeatmap.cs
Normal file
83
osu.Game/Screens/Edit/EditorBeatmap.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// 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 osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit
|
||||||
|
{
|
||||||
|
public class EditorBeatmap<T> : IEditorBeatmap<T>
|
||||||
|
where T : HitObject
|
||||||
|
{
|
||||||
|
public event Action<HitObject> HitObjectAdded;
|
||||||
|
public event Action<HitObject> HitObjectRemoved;
|
||||||
|
|
||||||
|
private readonly Beatmap<T> beatmap;
|
||||||
|
|
||||||
|
public EditorBeatmap(Beatmap<T> beatmap)
|
||||||
|
{
|
||||||
|
this.beatmap = beatmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BeatmapInfo BeatmapInfo
|
||||||
|
{
|
||||||
|
get => beatmap.BeatmapInfo;
|
||||||
|
set => beatmap.BeatmapInfo = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BeatmapMetadata Metadata => beatmap.Metadata;
|
||||||
|
|
||||||
|
public ControlPointInfo ControlPointInfo => beatmap.ControlPointInfo;
|
||||||
|
|
||||||
|
public List<BreakPeriod> Breaks => beatmap.Breaks;
|
||||||
|
|
||||||
|
public double TotalBreakTime => beatmap.TotalBreakTime;
|
||||||
|
|
||||||
|
IReadOnlyList<T> IBeatmap<T>.HitObjects => beatmap.HitObjects;
|
||||||
|
|
||||||
|
IReadOnlyList<HitObject> IBeatmap.HitObjects => beatmap.HitObjects;
|
||||||
|
|
||||||
|
public IEnumerable<BeatmapStatistic> GetStatistics() => beatmap.GetStatistics();
|
||||||
|
|
||||||
|
public IBeatmap Clone() => (EditorBeatmap<T>)MemberwiseClone();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||||
|
public void Add(T hitObject)
|
||||||
|
{
|
||||||
|
// Preserve existing sorting order in the beatmap
|
||||||
|
var insertionIndex = beatmap.HitObjects.FindLastIndex(h => h.StartTime <= hitObject.StartTime);
|
||||||
|
beatmap.HitObjects.Insert(insertionIndex + 1, hitObject);
|
||||||
|
|
||||||
|
HitObjectAdded?.Invoke(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a <see cref="HitObject"/> from this <see cref="EditorBeatmap{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||||
|
public void Remove(T hitObject)
|
||||||
|
{
|
||||||
|
if (beatmap.HitObjects.Remove(hitObject))
|
||||||
|
HitObjectRemoved?.Invoke(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||||
|
public void Add(HitObject hitObject) => Add((T)hitObject);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a <see cref="HitObject"/> from this <see cref="EditorBeatmap{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||||
|
public void Remove(HitObject hitObject) => Remove((T)hitObject);
|
||||||
|
}
|
||||||
|
}
|
46
osu.Game/Screens/Edit/EditorWorkingBeatmap.cs
Normal file
46
osu.Game/Screens/Edit/EditorWorkingBeatmap.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// 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 osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Encapsulates a <see cref="WorkingBeatmap"/> while providing an overridden <see cref="Beatmap{TObject}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TObject"></typeparam>
|
||||||
|
public class EditorWorkingBeatmap<TObject> : IWorkingBeatmap
|
||||||
|
where TObject : HitObject
|
||||||
|
{
|
||||||
|
private readonly Beatmap<TObject> playableBeatmap;
|
||||||
|
private readonly WorkingBeatmap workingBeatmap;
|
||||||
|
|
||||||
|
public EditorWorkingBeatmap(Beatmap<TObject> playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||||
|
{
|
||||||
|
this.playableBeatmap = playableBeatmap;
|
||||||
|
this.workingBeatmap = workingBeatmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBeatmap Beatmap => workingBeatmap.Beatmap;
|
||||||
|
|
||||||
|
public Texture Background => workingBeatmap.Background;
|
||||||
|
|
||||||
|
public Track Track => workingBeatmap.Track;
|
||||||
|
|
||||||
|
public Waveform Waveform => workingBeatmap.Waveform;
|
||||||
|
|
||||||
|
public Storyboard Storyboard => workingBeatmap.Storyboard;
|
||||||
|
|
||||||
|
public ISkin Skin => workingBeatmap.Skin;
|
||||||
|
|
||||||
|
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods) => playableBeatmap;
|
||||||
|
}
|
||||||
|
}
|
36
osu.Game/Screens/Edit/IEditorBeatmap.cs
Normal file
36
osu.Game/Screens/Edit/IEditorBeatmap.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for the <see cref="IBeatmap"/> contained by the see <see cref="HitObjectComposer"/>.
|
||||||
|
/// Children of <see cref="HitObjectComposer"/> may resolve the beatmap via <see cref="IEditorBeatmap"/> or <see cref="IEditorBeatmap{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
public interface IEditorBeatmap : IBeatmap
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="IEditorBeatmap"/>.
|
||||||
|
/// </summary>
|
||||||
|
event Action<HitObject> HitObjectAdded;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="HitObject"/> is removed from this <see cref="IEditorBeatmap"/>.
|
||||||
|
/// </summary>
|
||||||
|
event Action<HitObject> HitObjectRemoved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for the <see cref="IBeatmap"/> contained by the see <see cref="HitObjectComposer"/>.
|
||||||
|
/// Children of <see cref="HitObjectComposer"/> may resolve the beatmap via <see cref="IEditorBeatmap"/> or <see cref="IEditorBeatmap{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
public interface IEditorBeatmap<out T> : IEditorBeatmap, IBeatmap<T>
|
||||||
|
where T : HitObject
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
Scheduler.AddDelayed(delegate
|
Scheduler.AddDelayed(delegate
|
||||||
{
|
{
|
||||||
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu.
|
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu.
|
||||||
if (menuMusic.Value)
|
if (menuMusic.Value)
|
||||||
{
|
{
|
||||||
track.Restart();
|
track.Restart();
|
||||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
private const float visualiser_rounds = 5;
|
private const float visualiser_rounds = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How much should each bar go down each milisecond (based on a full bar).
|
/// How much should each bar go down each millisecond (based on a full bar).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const float decay_per_milisecond = 0.0024f;
|
private const float decay_per_milisecond = 0.0024f;
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
private IShader shader;
|
private IShader shader;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
|
|
||||||
//Asuming the logo is a circle, we don't need a second dimension.
|
//Assuming the logo is a circle, we don't need a second dimension.
|
||||||
private float size;
|
private float size;
|
||||||
|
|
||||||
private Color4 colour;
|
private Color4 colour;
|
||||||
|
@ -229,7 +229,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Schedule a new extenral animation. Handled queueing and finishing previous animations in a sane way.
|
/// Schedule a new external animation. Handled queueing and finishing previous animations in a sane way.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="action">The animation to be performed</param>
|
/// <param name="action">The animation to be performed</param>
|
||||||
/// <param name="waitForPrevious">If true, the new animation is delayed until all previous transforms finish. If false, existing transformed are cleared.</param>
|
/// <param name="waitForPrevious">If true, the new animation is delayed until all previous transforms finish. If false, existing transformed are cleared.</param>
|
||||||
|
100
osu.Game/Screens/Play/HUD/HitErrorDisplay.cs
Normal file
100
osu.Game/Screens/Play/HUD/HitErrorDisplay.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// 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.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public class HitErrorDisplay : Container<HitErrorMeter>
|
||||||
|
{
|
||||||
|
private const int fade_duration = 200;
|
||||||
|
private const int margin = 10;
|
||||||
|
|
||||||
|
private readonly Bindable<ScoreMeterType> type = new Bindable<ScoreMeterType>();
|
||||||
|
|
||||||
|
private readonly HitWindows hitWindows;
|
||||||
|
|
||||||
|
private readonly ScoreProcessor processor;
|
||||||
|
|
||||||
|
public HitErrorDisplay(ScoreProcessor processor, HitWindows hitWindows)
|
||||||
|
{
|
||||||
|
this.processor = processor;
|
||||||
|
this.hitWindows = hitWindows;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
processor.NewJudgement += onNewJudgement;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
config.BindWith(OsuSetting.ScoreMeter, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
type.BindValueChanged(typeChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onNewJudgement(JudgementResult result)
|
||||||
|
{
|
||||||
|
foreach (var c in Children)
|
||||||
|
c.OnNewJudgement(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void typeChanged(ValueChangedEvent<ScoreMeterType> type)
|
||||||
|
{
|
||||||
|
Children.ForEach(c => c.FadeOut(fade_duration, Easing.OutQuint));
|
||||||
|
|
||||||
|
if (hitWindows == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (type.NewValue)
|
||||||
|
{
|
||||||
|
case ScoreMeterType.HitErrorBoth:
|
||||||
|
createBar(false);
|
||||||
|
createBar(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScoreMeterType.HitErrorLeft:
|
||||||
|
createBar(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScoreMeterType.HitErrorRight:
|
||||||
|
createBar(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createBar(bool rightAligned)
|
||||||
|
{
|
||||||
|
var display = new BarHitErrorMeter(hitWindows, rightAligned)
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding(margin),
|
||||||
|
Anchor = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
|
||||||
|
Origin = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
|
||||||
|
Alpha = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
Add(display);
|
||||||
|
display.FadeInFromZero(fade_duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
processor.NewJudgement -= onNewJudgement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
284
osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs
Normal file
284
osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||||
|
{
|
||||||
|
public class BarHitErrorMeter : HitErrorMeter
|
||||||
|
{
|
||||||
|
private readonly Anchor alignment;
|
||||||
|
|
||||||
|
private const int arrow_move_duration = 400;
|
||||||
|
|
||||||
|
private const int judgement_line_width = 6;
|
||||||
|
|
||||||
|
private const int bar_height = 200;
|
||||||
|
|
||||||
|
private const int bar_width = 2;
|
||||||
|
|
||||||
|
private const int spacing = 2;
|
||||||
|
|
||||||
|
private const float chevron_size = 8;
|
||||||
|
|
||||||
|
private SpriteIcon arrow;
|
||||||
|
|
||||||
|
private Container colourBarsEarly;
|
||||||
|
private Container colourBarsLate;
|
||||||
|
|
||||||
|
private Container judgementsContainer;
|
||||||
|
|
||||||
|
private double maxHitWindow;
|
||||||
|
|
||||||
|
public BarHitErrorMeter(HitWindows hitWindows, bool rightAligned = false)
|
||||||
|
: base(hitWindows)
|
||||||
|
{
|
||||||
|
alignment = rightAligned ? Anchor.x0 : Anchor.x2;
|
||||||
|
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
InternalChild = new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Height = bar_height,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(spacing, 0),
|
||||||
|
Margin = new MarginPadding(2),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
judgementsContainer = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.y1 | alignment,
|
||||||
|
Origin = Anchor.y1 | alignment,
|
||||||
|
Width = judgement_line_width,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
colourBars = new Container
|
||||||
|
{
|
||||||
|
Width = bar_width,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Anchor = Anchor.y1 | alignment,
|
||||||
|
Origin = Anchor.y1 | alignment,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
colourBarsEarly = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.y1 | alignment,
|
||||||
|
Origin = alignment,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 0.5f,
|
||||||
|
Scale = new Vector2(1, -1),
|
||||||
|
},
|
||||||
|
colourBarsLate = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.y1 | alignment,
|
||||||
|
Origin = alignment,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 0.5f,
|
||||||
|
},
|
||||||
|
new SpriteIcon
|
||||||
|
{
|
||||||
|
Y = -10,
|
||||||
|
Size = new Vector2(10),
|
||||||
|
Icon = FontAwesome.Solid.ShippingFast,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
},
|
||||||
|
new SpriteIcon
|
||||||
|
{
|
||||||
|
Y = 10,
|
||||||
|
Size = new Vector2(10),
|
||||||
|
Icon = FontAwesome.Solid.Bicycle,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.y1 | alignment,
|
||||||
|
Origin = Anchor.y1 | alignment,
|
||||||
|
Width = chevron_size,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Child = arrow = new SpriteIcon
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativePositionAxes = Axes.Y,
|
||||||
|
Y = 0.5f,
|
||||||
|
Icon = alignment == Anchor.x2 ? FontAwesome.Solid.ChevronRight : FontAwesome.Solid.ChevronLeft,
|
||||||
|
Size = new Vector2(chevron_size),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
createColourBars(colours);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
colourBars.Height = 0;
|
||||||
|
colourBars.ResizeHeightTo(1, 800, Easing.OutQuint);
|
||||||
|
|
||||||
|
arrow.Alpha = 0;
|
||||||
|
arrow.Delay(200).FadeInFromZero(600);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createColourBars(OsuColour colours)
|
||||||
|
{
|
||||||
|
var windows = HitWindows.GetAllAvailableHalfWindows().ToArray();
|
||||||
|
|
||||||
|
maxHitWindow = windows.First().length;
|
||||||
|
|
||||||
|
for (var i = 0; i < windows.Length; i++)
|
||||||
|
{
|
||||||
|
var (result, length) = windows[i];
|
||||||
|
|
||||||
|
colourBarsEarly.Add(createColourBar(result, (float)(length / maxHitWindow), i == 0));
|
||||||
|
colourBarsLate.Add(createColourBar(result, (float)(length / maxHitWindow), i == 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// a little nub to mark the centre point.
|
||||||
|
var centre = createColourBar(windows.Last().result, 0.01f);
|
||||||
|
centre.Anchor = centre.Origin = Anchor.y1 | (alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2);
|
||||||
|
centre.Width = 2.5f;
|
||||||
|
colourBars.Add(centre);
|
||||||
|
|
||||||
|
Color4 getColour(HitResult result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Meh:
|
||||||
|
return colours.Yellow;
|
||||||
|
|
||||||
|
case HitResult.Ok:
|
||||||
|
return colours.Green;
|
||||||
|
|
||||||
|
case HitResult.Good:
|
||||||
|
return colours.GreenLight;
|
||||||
|
|
||||||
|
case HitResult.Great:
|
||||||
|
return colours.Blue;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return colours.BlueLight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Drawable createColourBar(HitResult result, float height, bool first = false)
|
||||||
|
{
|
||||||
|
var colour = getColour(result);
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
// the first bar needs gradient rendering.
|
||||||
|
const float gradient_start = 0.8f;
|
||||||
|
|
||||||
|
return new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = getColour(result),
|
||||||
|
Height = height * gradient_start
|
||||||
|
},
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Colour = ColourInfo.GradientVertical(colour, colour.Opacity(0)),
|
||||||
|
Y = gradient_start,
|
||||||
|
Height = height * (1 - gradient_start)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colour,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double floatingAverage;
|
||||||
|
private Container colourBars;
|
||||||
|
|
||||||
|
public override void OnNewJudgement(JudgementResult judgement)
|
||||||
|
{
|
||||||
|
if (!judgement.IsHit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
judgementsContainer.Add(new JudgementLine
|
||||||
|
{
|
||||||
|
Y = getRelativeJudgementPosition(judgement.TimeOffset),
|
||||||
|
Anchor = alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2,
|
||||||
|
Origin = Anchor.y1 | (alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2),
|
||||||
|
});
|
||||||
|
|
||||||
|
arrow.MoveToY(
|
||||||
|
getRelativeJudgementPosition(floatingAverage = floatingAverage * 0.9 + judgement.TimeOffset * 0.1)
|
||||||
|
, arrow_move_duration, Easing.Out);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getRelativeJudgementPosition(double value) => (float)((value / maxHitWindow) + 1) / 2;
|
||||||
|
|
||||||
|
private class JudgementLine : CompositeDrawable
|
||||||
|
{
|
||||||
|
private const int judgement_fade_duration = 10000;
|
||||||
|
|
||||||
|
public JudgementLine()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
RelativePositionAxes = Axes.Y;
|
||||||
|
Height = 3;
|
||||||
|
|
||||||
|
InternalChild = new CircularContainer
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.White,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Width = 0;
|
||||||
|
|
||||||
|
this.ResizeWidthTo(1, 200, Easing.OutElasticHalf);
|
||||||
|
this.FadeTo(0.8f, 150).Then().FadeOut(judgement_fade_duration, Easing.OutQuint).Expire();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs
Normal file
21
osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||||
|
{
|
||||||
|
public abstract class HitErrorMeter : CompositeDrawable
|
||||||
|
{
|
||||||
|
protected readonly HitWindows HitWindows;
|
||||||
|
|
||||||
|
protected HitErrorMeter(HitWindows hitWindows)
|
||||||
|
{
|
||||||
|
HitWindows = hitWindows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void OnNewJudgement(JudgementResult judgement);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -33,6 +34,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public readonly HealthDisplay HealthDisplay;
|
public readonly HealthDisplay HealthDisplay;
|
||||||
public readonly SongProgress Progress;
|
public readonly SongProgress Progress;
|
||||||
public readonly ModDisplay ModDisplay;
|
public readonly ModDisplay ModDisplay;
|
||||||
|
public readonly HitErrorDisplay HitErrorDisplay;
|
||||||
public readonly HoldForMenuButton HoldToQuit;
|
public readonly HoldForMenuButton HoldToQuit;
|
||||||
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
||||||
|
|
||||||
@ -84,6 +86,7 @@ namespace osu.Game.Screens.Play
|
|||||||
HealthDisplay = CreateHealthDisplay(),
|
HealthDisplay = CreateHealthDisplay(),
|
||||||
Progress = CreateProgress(),
|
Progress = CreateProgress(),
|
||||||
ModDisplay = CreateModsContainer(),
|
ModDisplay = CreateModsContainer(),
|
||||||
|
HitErrorDisplay = CreateHitErrorDisplayOverlay(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
|
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
|
||||||
@ -256,6 +259,8 @@ namespace osu.Game.Screens.Play
|
|||||||
Margin = new MarginPadding { Top = 20, Right = 10 },
|
Margin = new MarginPadding { Top = 20, Right = 10 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected virtual HitErrorDisplay CreateHitErrorDisplayOverlay() => new HitErrorDisplay(scoreProcessor, drawableRuleset.Objects.FirstOrDefault()?.HitWindows);
|
||||||
|
|
||||||
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
||||||
|
|
||||||
protected virtual void BindProcessor(ScoreProcessor processor)
|
protected virtual void BindProcessor(ScoreProcessor processor)
|
||||||
|
@ -60,7 +60,9 @@ namespace osu.Game.Screens.Play
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private ScoreManager scoreManager { get; set; }
|
private ScoreManager scoreManager { get; set; }
|
||||||
|
|
||||||
private RulesetInfo ruleset;
|
private RulesetInfo rulesetInfo;
|
||||||
|
|
||||||
|
private Ruleset ruleset;
|
||||||
|
|
||||||
private IAPIProvider api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
@ -121,21 +123,53 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime);
|
InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||||
|
|
||||||
GameplayClockContainer.Children = new[]
|
addUnderlayComponents(GameplayClockContainer);
|
||||||
|
addGameplayComponents(GameplayClockContainer, working);
|
||||||
|
addOverlayComponents(GameplayClockContainer, working);
|
||||||
|
|
||||||
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true);
|
||||||
|
|
||||||
|
// bind clock into components that require it
|
||||||
|
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
||||||
|
|
||||||
|
// Bind ScoreProcessor to ourselves
|
||||||
|
ScoreProcessor.AllJudged += onCompletion;
|
||||||
|
ScoreProcessor.Failed += onFail;
|
||||||
|
|
||||||
|
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||||
|
mod.ApplyToScoreProcessor(ScoreProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addUnderlayComponents(Container target)
|
||||||
{
|
{
|
||||||
DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both },
|
target.Add(DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both });
|
||||||
new ScalingContainer(ScalingMode.Gameplay)
|
}
|
||||||
|
|
||||||
|
private void addGameplayComponents(Container target, WorkingBeatmap working)
|
||||||
{
|
{
|
||||||
Child = new LocalSkinOverrideContainer(working.Skin)
|
var beatmapSkinProvider = new BeatmapSkinProvidingContainer(working.Skin);
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
// the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
|
||||||
Children = new Drawable[]
|
// full access to all skin sources.
|
||||||
|
var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider));
|
||||||
|
|
||||||
|
// load the skinning hierarchy first.
|
||||||
|
// this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
|
||||||
|
target.Add(new ScalingContainer(ScalingMode.Gameplay)
|
||||||
|
.WithChild(beatmapSkinProvider
|
||||||
|
.WithChild(target = rulesetSkinProvider)));
|
||||||
|
|
||||||
|
target.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
DrawableRuleset,
|
DrawableRuleset,
|
||||||
new ComboEffects(ScoreProcessor)
|
new ComboEffects(ScoreProcessor)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
private void addOverlayComponents(Container target, WorkingBeatmap working)
|
||||||
|
{
|
||||||
|
target.AddRange(new[]
|
||||||
|
{
|
||||||
breakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
breakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -144,6 +178,7 @@ namespace osu.Game.Screens.Play
|
|||||||
},
|
},
|
||||||
// display the cursor above some HUD elements.
|
// display the cursor above some HUD elements.
|
||||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||||
|
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
||||||
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value)
|
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value)
|
||||||
{
|
{
|
||||||
HoldToQuit =
|
HoldToQuit =
|
||||||
@ -194,19 +229,7 @@ namespace osu.Game.Screens.Play
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
|
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
|
||||||
};
|
});
|
||||||
|
|
||||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true);
|
|
||||||
|
|
||||||
// bind clock into components that require it
|
|
||||||
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
|
||||||
|
|
||||||
// Bind ScoreProcessor to ourselves
|
|
||||||
ScoreProcessor.AllJudged += onCompletion;
|
|
||||||
ScoreProcessor.Failed += onFail;
|
|
||||||
|
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
|
||||||
mod.ApplyToScoreProcessor(ScoreProcessor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorkingBeatmap loadBeatmap()
|
private WorkingBeatmap loadBeatmap()
|
||||||
@ -222,20 +245,20 @@ namespace osu.Game.Screens.Play
|
|||||||
if (beatmap == null)
|
if (beatmap == null)
|
||||||
throw new InvalidOperationException("Beatmap was not loaded");
|
throw new InvalidOperationException("Beatmap was not loaded");
|
||||||
|
|
||||||
ruleset = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
rulesetInfo = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
||||||
var rulesetInstance = ruleset.CreateInstance();
|
ruleset = rulesetInfo.CreateInstance();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(working, Mods.Value);
|
DrawableRuleset = ruleset.CreateDrawableRulesetWith(working, Mods.Value);
|
||||||
}
|
}
|
||||||
catch (BeatmapInvalidForRulesetException)
|
catch (BeatmapInvalidForRulesetException)
|
||||||
{
|
{
|
||||||
// we may fail to create a DrawableRuleset if the beatmap cannot be loaded with the user's preferred ruleset
|
// we may fail to create a DrawableRuleset if the beatmap cannot be loaded with the user's preferred ruleset
|
||||||
// let's try again forcing the beatmap's ruleset.
|
// let's try again forcing the beatmap's ruleset.
|
||||||
ruleset = beatmap.BeatmapInfo.Ruleset;
|
rulesetInfo = beatmap.BeatmapInfo.Ruleset;
|
||||||
rulesetInstance = ruleset.CreateInstance();
|
ruleset = rulesetInfo.CreateInstance();
|
||||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(Beatmap.Value, Mods.Value);
|
DrawableRuleset = ruleset.CreateDrawableRulesetWith(Beatmap.Value, Mods.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DrawableRuleset.Objects.Any())
|
if (!DrawableRuleset.Objects.Any())
|
||||||
@ -313,7 +336,7 @@ namespace osu.Game.Screens.Play
|
|||||||
var score = DrawableRuleset.ReplayScore?.ScoreInfo ?? new ScoreInfo
|
var score = DrawableRuleset.ReplayScore?.ScoreInfo ?? new ScoreInfo
|
||||||
{
|
{
|
||||||
Beatmap = Beatmap.Value.BeatmapInfo,
|
Beatmap = Beatmap.Value.BeatmapInfo,
|
||||||
Ruleset = ruleset,
|
Ruleset = rulesetInfo,
|
||||||
Mods = Mods.Value.ToArray(),
|
Mods = Mods.Value.ToArray(),
|
||||||
User = api.LocalUser.Value,
|
User = api.LocalUser.Value,
|
||||||
};
|
};
|
||||||
|
39
osu.Game/Skinning/BeatmapSkinProvidingContainer.cs
Normal file
39
osu.Game/Skinning/BeatmapSkinProvidingContainer.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// 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.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A container which overrides existing skin options with beatmap-local values.
|
||||||
|
/// </summary>
|
||||||
|
public class BeatmapSkinProvidingContainer : SkinProvidingContainer
|
||||||
|
{
|
||||||
|
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
|
||||||
|
private readonly Bindable<bool> beatmapHitsounds = new Bindable<bool>();
|
||||||
|
|
||||||
|
protected override bool AllowConfigurationLookup => beatmapSkins.Value;
|
||||||
|
protected override bool AllowDrawableLookup(string componentName) => beatmapSkins.Value;
|
||||||
|
protected override bool AllowTextureLookup(string componentName) => beatmapSkins.Value;
|
||||||
|
protected override bool AllowSampleLookup(ISampleInfo componentName) => beatmapHitsounds.Value;
|
||||||
|
|
||||||
|
public BeatmapSkinProvidingContainer(ISkin skin)
|
||||||
|
: base(skin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
|
||||||
|
config.BindWith(OsuSetting.BeatmapHitsounds, beatmapHitsounds);
|
||||||
|
|
||||||
|
beatmapSkins.BindValueChanged(_ => TriggerSourceChanged());
|
||||||
|
beatmapHitsounds.BindValueChanged(_ => TriggerSourceChanged());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
osu.Game/Skinning/DefaultLegacySkin.cs
Normal file
23
osu.Game/Skinning/DefaultLegacySkin.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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.Framework.Audio;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
public class DefaultLegacySkin : LegacySkin
|
||||||
|
{
|
||||||
|
public DefaultLegacySkin(IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||||
|
: base(Info, storage, audioManager, string.Empty)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinInfo Info { get; } = new SkinInfo
|
||||||
|
{
|
||||||
|
ID = -1, // this is temporary until database storage is decided upon.
|
||||||
|
Name = "osu!classic",
|
||||||
|
Creator = "team osu!"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ namespace osu.Game.Skinning
|
|||||||
public DefaultSkin()
|
public DefaultSkin()
|
||||||
: base(SkinInfo.Default)
|
: base(SkinInfo.Default)
|
||||||
{
|
{
|
||||||
Configuration = new SkinConfiguration();
|
Configuration = new DefaultSkinConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(string componentName) => null;
|
public override Drawable GetDrawableComponent(string componentName) => null;
|
||||||
|
28
osu.Game/Skinning/DefaultSkinConfiguration.cs
Normal file
28
osu.Game/Skinning/DefaultSkinConfiguration.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A skin configuration pre-populated with sane defaults.
|
||||||
|
/// </summary>
|
||||||
|
public class DefaultSkinConfiguration : SkinConfiguration
|
||||||
|
{
|
||||||
|
public DefaultSkinConfiguration()
|
||||||
|
{
|
||||||
|
HitCircleFont = "default";
|
||||||
|
|
||||||
|
ComboColours.AddRange(new[]
|
||||||
|
{
|
||||||
|
new Color4(17, 136, 170, 255),
|
||||||
|
new Color4(102, 136, 0, 255),
|
||||||
|
new Color4(204, 102, 0, 255),
|
||||||
|
new Color4(121, 9, 13, 255)
|
||||||
|
});
|
||||||
|
|
||||||
|
CursorExpand = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +1,14 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Animations;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Text;
|
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
@ -35,13 +19,6 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected IResourceStore<SampleChannel> Samples;
|
protected IResourceStore<SampleChannel> Samples;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// On osu-stable, hitcircles have 5 pixels of transparent padding on each side to allow for shadows etc.
|
|
||||||
/// Their hittable area is 128px, but the actual circle portion is 118px.
|
|
||||||
/// We must account for some gameplay elements such as slider bodies, where this padding is not present.
|
|
||||||
/// </summary>
|
|
||||||
private const float legacy_circle_radius = 64 - 5;
|
|
||||||
|
|
||||||
public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager)
|
public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||||
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, storage), audioManager, "skin.ini")
|
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, storage), audioManager, "skin.ini")
|
||||||
{
|
{
|
||||||
@ -49,8 +26,6 @@ namespace osu.Game.Skinning
|
|||||||
if (!Configuration.CustomColours.ContainsKey("SliderBall")) Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
if (!Configuration.CustomColours.ContainsKey("SliderBall")) Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly bool hasHitCircle;
|
|
||||||
|
|
||||||
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, string filename)
|
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, string filename)
|
||||||
: base(skin)
|
: base(skin)
|
||||||
{
|
{
|
||||||
@ -59,18 +34,10 @@ namespace osu.Game.Skinning
|
|||||||
using (StreamReader reader = new StreamReader(stream))
|
using (StreamReader reader = new StreamReader(stream))
|
||||||
Configuration = new LegacySkinDecoder().Decode(reader);
|
Configuration = new LegacySkinDecoder().Decode(reader);
|
||||||
else
|
else
|
||||||
Configuration = new SkinConfiguration();
|
Configuration = new DefaultSkinConfiguration();
|
||||||
|
|
||||||
Samples = audioManager.GetSampleStore(storage);
|
Samples = audioManager.GetSampleStore(storage);
|
||||||
Textures = new TextureStore(new TextureLoaderStore(storage));
|
Textures = new TextureStore(new TextureLoaderStore(storage));
|
||||||
|
|
||||||
using (var testStream = storage.GetStream("hitcircle@2x") ?? storage.GetStream("hitcircle"))
|
|
||||||
hasHitCircle |= testStream != null;
|
|
||||||
|
|
||||||
if (hasHitCircle)
|
|
||||||
{
|
|
||||||
Configuration.SliderPathRadius = legacy_circle_radius;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -80,8 +47,6 @@ namespace osu.Game.Skinning
|
|||||||
Samples?.Dispose();
|
Samples?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private const double default_frame_time = 1000 / 60d;
|
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(string componentName)
|
public override Drawable GetDrawableComponent(string componentName)
|
||||||
{
|
{
|
||||||
bool animatable = false;
|
bool animatable = false;
|
||||||
@ -89,40 +54,6 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
switch (componentName)
|
switch (componentName)
|
||||||
{
|
{
|
||||||
case "Play/osu/cursor":
|
|
||||||
if (GetTexture("cursor") != null)
|
|
||||||
return new LegacyCursor();
|
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
case "Play/osu/sliderball":
|
|
||||||
var sliderBallContent = getAnimation("sliderb", true, true, "");
|
|
||||||
|
|
||||||
if (sliderBallContent != null)
|
|
||||||
{
|
|
||||||
var size = sliderBallContent.Size;
|
|
||||||
|
|
||||||
sliderBallContent.RelativeSizeAxes = Axes.Both;
|
|
||||||
sliderBallContent.Size = Vector2.One;
|
|
||||||
|
|
||||||
return new LegacySliderBall(sliderBallContent)
|
|
||||||
{
|
|
||||||
Size = size
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
case "Play/osu/hitcircle":
|
|
||||||
if (hasHitCircle)
|
|
||||||
return new LegacyMainCirclePiece();
|
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
case "Play/osu/sliderfollowcircle":
|
|
||||||
animatable = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Play/Miss":
|
case "Play/Miss":
|
||||||
componentName = "hit0";
|
componentName = "hit0";
|
||||||
animatable = true;
|
animatable = true;
|
||||||
@ -146,19 +77,9 @@ namespace osu.Game.Skinning
|
|||||||
animatable = true;
|
animatable = true;
|
||||||
looping = false;
|
looping = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Play/osu/number-text":
|
|
||||||
return !hasFont(Configuration.HitCircleFont)
|
|
||||||
? null
|
|
||||||
: new LegacySpriteText(this, Configuration.HitCircleFont)
|
|
||||||
{
|
|
||||||
Scale = new Vector2(0.96f),
|
|
||||||
// Spacing value was reverse-engineered from the ratio of the rendered sprite size in the visual inspector vs the actual texture size
|
|
||||||
Spacing = new Vector2(-Configuration.HitCircleOverlap * 0.89f, 0)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return getAnimation(componentName, animatable, looping);
|
return this.GetAnimation(componentName, animatable, looping);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Texture GetTexture(string componentName)
|
public override Texture GetTexture(string componentName)
|
||||||
@ -197,295 +118,10 @@ namespace osu.Game.Skinning
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool hasFont(string fontName) => GetTexture($"{fontName}-0") != null;
|
|
||||||
|
|
||||||
private string getFallbackName(string componentName)
|
private string getFallbackName(string componentName)
|
||||||
{
|
{
|
||||||
string lastPiece = componentName.Split('/').Last();
|
string lastPiece = componentName.Split('/').Last();
|
||||||
return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
|
return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getAnimation(string componentName, bool animatable, bool looping, string animationSeparator = "-")
|
|
||||||
{
|
|
||||||
Texture texture;
|
|
||||||
|
|
||||||
Texture getFrameTexture(int frame) => GetTexture($"{componentName}{animationSeparator}{frame}");
|
|
||||||
|
|
||||||
TextureAnimation animation = null;
|
|
||||||
|
|
||||||
if (animatable)
|
|
||||||
{
|
|
||||||
for (int i = 0;; i++)
|
|
||||||
{
|
|
||||||
if ((texture = getFrameTexture(i)) == null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (animation == null)
|
|
||||||
animation = new TextureAnimation
|
|
||||||
{
|
|
||||||
DefaultFrameLength = default_frame_time,
|
|
||||||
Repeat = looping
|
|
||||||
};
|
|
||||||
|
|
||||||
animation.AddFrame(texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animation != null)
|
|
||||||
return animation;
|
|
||||||
|
|
||||||
if ((texture = GetTexture(componentName)) != null)
|
|
||||||
return new Sprite { Texture = texture };
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected class LegacySkinResourceStore<T> : IResourceStore<byte[]>
|
|
||||||
where T : INamedFileInfo
|
|
||||||
{
|
|
||||||
private readonly IHasFiles<T> source;
|
|
||||||
private readonly IResourceStore<byte[]> underlyingStore;
|
|
||||||
|
|
||||||
private string getPathForFile(string filename)
|
|
||||||
{
|
|
||||||
bool hasExtension = filename.Contains('.');
|
|
||||||
|
|
||||||
var file = source.Files.Find(f =>
|
|
||||||
string.Equals(hasExtension ? f.Filename : Path.ChangeExtension(f.Filename, null), filename, StringComparison.InvariantCultureIgnoreCase));
|
|
||||||
return file?.FileInfo.StoragePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LegacySkinResourceStore(IHasFiles<T> source, IResourceStore<byte[]> underlyingStore)
|
|
||||||
{
|
|
||||||
this.source = source;
|
|
||||||
this.underlyingStore = underlyingStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stream GetStream(string name)
|
|
||||||
{
|
|
||||||
string path = getPathForFile(name);
|
|
||||||
return path == null ? null : underlyingStore.GetStream(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<string> GetAvailableResources() => source.Files.Select(f => f.Filename);
|
|
||||||
|
|
||||||
byte[] IResourceStore<byte[]>.Get(string name) => GetAsync(name).Result;
|
|
||||||
|
|
||||||
public Task<byte[]> GetAsync(string name)
|
|
||||||
{
|
|
||||||
string path = getPathForFile(name);
|
|
||||||
return path == null ? Task.FromResult<byte[]>(null) : underlyingStore.GetAsync(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Support
|
|
||||||
|
|
||||||
private bool isDisposed;
|
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (!isDisposed)
|
|
||||||
{
|
|
||||||
isDisposed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~LegacySkinResourceStore()
|
|
||||||
{
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LegacySpriteText : OsuSpriteText
|
|
||||||
{
|
|
||||||
private readonly LegacyGlyphStore glyphStore;
|
|
||||||
|
|
||||||
public LegacySpriteText(ISkin skin, string font)
|
|
||||||
{
|
|
||||||
Shadow = false;
|
|
||||||
UseFullGlyphHeight = false;
|
|
||||||
|
|
||||||
Font = new FontUsage(font, OsuFont.DEFAULT_FONT_SIZE);
|
|
||||||
glyphStore = new LegacyGlyphStore(skin);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore);
|
|
||||||
|
|
||||||
private class LegacyGlyphStore : ITexturedGlyphLookupStore
|
|
||||||
{
|
|
||||||
private readonly ISkin skin;
|
|
||||||
|
|
||||||
public LegacyGlyphStore(ISkin skin)
|
|
||||||
{
|
|
||||||
this.skin = skin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITexturedCharacterGlyph Get(string fontName, char character)
|
|
||||||
{
|
|
||||||
var texture = skin.GetTexture($"{fontName}-{character}");
|
|
||||||
|
|
||||||
if (texture != null)
|
|
||||||
// Approximate value that brings character sizing roughly in-line with stable
|
|
||||||
texture.ScaleAdjust *= 18;
|
|
||||||
|
|
||||||
if (texture == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, null), texture, 1f / texture.ScaleAdjust);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<ITexturedCharacterGlyph> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LegacyCursor : CompositeDrawable
|
|
||||||
{
|
|
||||||
public LegacyCursor()
|
|
||||||
{
|
|
||||||
Size = new Vector2(50);
|
|
||||||
|
|
||||||
Anchor = Anchor.Centre;
|
|
||||||
Origin = Anchor.Centre;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(ISkinSource skin)
|
|
||||||
{
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new NonPlayfieldSprite
|
|
||||||
{
|
|
||||||
Texture = skin.GetTexture("cursormiddle"),
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
},
|
|
||||||
new NonPlayfieldSprite
|
|
||||||
{
|
|
||||||
Texture = skin.GetTexture("cursor"),
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LegacySliderBall : CompositeDrawable
|
|
||||||
{
|
|
||||||
private readonly Drawable animationContent;
|
|
||||||
|
|
||||||
public LegacySliderBall(Drawable animationContent)
|
|
||||||
{
|
|
||||||
this.animationContent = animationContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(ISkinSource skin, DrawableHitObject drawableObject)
|
|
||||||
{
|
|
||||||
animationContent.Colour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Color4.White;
|
|
||||||
|
|
||||||
InternalChildren = new[]
|
|
||||||
{
|
|
||||||
new Sprite
|
|
||||||
{
|
|
||||||
Texture = skin.GetTexture("sliderb-nd"),
|
|
||||||
Colour = new Color4(5, 5, 5, 255),
|
|
||||||
},
|
|
||||||
animationContent,
|
|
||||||
new Sprite
|
|
||||||
{
|
|
||||||
Texture = skin.GetTexture("sliderb-spec"),
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LegacyMainCirclePiece : CompositeDrawable
|
|
||||||
{
|
|
||||||
public LegacyMainCirclePiece()
|
|
||||||
{
|
|
||||||
Size = new Vector2(128);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
|
|
||||||
|
|
||||||
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(DrawableHitObject drawableObject, ISkinSource skin)
|
|
||||||
{
|
|
||||||
Sprite hitCircleSprite;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
hitCircleSprite = new Sprite
|
|
||||||
{
|
|
||||||
Texture = skin.GetTexture("hitcircle"),
|
|
||||||
Colour = drawableObject.AccentColour.Value,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
},
|
|
||||||
new SkinnableSpriteText("Play/osu/number-text", _ => new OsuSpriteText
|
|
||||||
{
|
|
||||||
Font = OsuFont.Numeric.With(size: 40),
|
|
||||||
UseFullGlyphHeight = false,
|
|
||||||
}, confineMode: ConfineMode.NoScaling)
|
|
||||||
{
|
|
||||||
Text = (((IHasComboInformation)drawableObject.HitObject).IndexInCurrentCombo + 1).ToString()
|
|
||||||
},
|
|
||||||
new Sprite
|
|
||||||
{
|
|
||||||
Texture = skin.GetTexture("hitcircleoverlay"),
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
state.BindTo(drawableObject.State);
|
|
||||||
state.BindValueChanged(updateState, true);
|
|
||||||
|
|
||||||
accentColour.BindTo(drawableObject.AccentColour);
|
|
||||||
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateState(ValueChangedEvent<ArmedState> state)
|
|
||||||
{
|
|
||||||
const double legacy_fade_duration = 240;
|
|
||||||
|
|
||||||
switch (state.NewValue)
|
|
||||||
{
|
|
||||||
case ArmedState.Hit:
|
|
||||||
this.FadeOut(legacy_fade_duration, Easing.Out);
|
|
||||||
this.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A sprite which is displayed within the playfield, but historically was not considered part of the playfield.
|
|
||||||
/// Performs scale adjustment to undo the scale applied by <see cref="PlayfieldAdjustmentContainer"/> (osu! ruleset specifically).
|
|
||||||
/// </summary>
|
|
||||||
private class NonPlayfieldSprite : Sprite
|
|
||||||
{
|
|
||||||
public override Texture Texture
|
|
||||||
{
|
|
||||||
get => base.Texture;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value != null)
|
|
||||||
// stable "magic ratio". see OsuPlayfieldAdjustmentContainer for full explanation.
|
|
||||||
value.ScaleAdjust *= 1.6f;
|
|
||||||
base.Texture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ using osu.Game.Beatmaps.Formats;
|
|||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
public class LegacySkinDecoder : LegacyDecoder<SkinConfiguration>
|
public class LegacySkinDecoder : LegacyDecoder<DefaultSkinConfiguration>
|
||||||
{
|
{
|
||||||
public LegacySkinDecoder()
|
public LegacySkinDecoder()
|
||||||
: base(1)
|
: base(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
|
protected override void ParseLine(DefaultSkinConfiguration skin, Section section, string line)
|
||||||
{
|
{
|
||||||
line = StripComments(line);
|
line = StripComments(line);
|
||||||
|
|
||||||
|
53
osu.Game/Skinning/LegacySkinExtensions.cs
Normal file
53
osu.Game/Skinning/LegacySkinExtensions.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// 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.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Animations;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
public static class LegacySkinExtensions
|
||||||
|
{
|
||||||
|
public static Drawable GetAnimation(this ISkin source, string componentName, bool animatable, bool looping, string animationSeparator = "-")
|
||||||
|
{
|
||||||
|
const double default_frame_time = 1000 / 60d;
|
||||||
|
|
||||||
|
Texture texture;
|
||||||
|
|
||||||
|
Texture getFrameTexture(int frame) => source.GetTexture($"{componentName}{animationSeparator}{frame}");
|
||||||
|
|
||||||
|
TextureAnimation animation = null;
|
||||||
|
|
||||||
|
if (animatable)
|
||||||
|
{
|
||||||
|
for (int i = 0;; i++)
|
||||||
|
{
|
||||||
|
if ((texture = getFrameTexture(i)) == null)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (animation == null)
|
||||||
|
animation = new TextureAnimation
|
||||||
|
{
|
||||||
|
DefaultFrameLength = default_frame_time,
|
||||||
|
Repeat = looping
|
||||||
|
};
|
||||||
|
|
||||||
|
animation.AddFrame(texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (animation != null)
|
||||||
|
return animation;
|
||||||
|
|
||||||
|
if ((texture = source.GetTexture(componentName)) != null)
|
||||||
|
return new Sprite
|
||||||
|
{
|
||||||
|
Texture = texture
|
||||||
|
};
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
79
osu.Game/Skinning/LegacySkinResourceStore.cs
Normal file
79
osu.Game/Skinning/LegacySkinResourceStore.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// 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 System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
public class LegacySkinResourceStore<T> : IResourceStore<byte[]>
|
||||||
|
where T : INamedFileInfo
|
||||||
|
{
|
||||||
|
private readonly IHasFiles<T> source;
|
||||||
|
private readonly IResourceStore<byte[]> underlyingStore;
|
||||||
|
|
||||||
|
private string getPathForFile(string filename)
|
||||||
|
{
|
||||||
|
if (source.Files == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
bool hasExtension = filename.Contains('.');
|
||||||
|
|
||||||
|
var file = source.Files.Find(f =>
|
||||||
|
string.Equals(hasExtension ? f.Filename : Path.ChangeExtension(f.Filename, null), filename, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
return file?.FileInfo.StoragePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LegacySkinResourceStore(IHasFiles<T> source, IResourceStore<byte[]> underlyingStore)
|
||||||
|
{
|
||||||
|
this.source = source;
|
||||||
|
this.underlyingStore = underlyingStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stream GetStream(string name)
|
||||||
|
{
|
||||||
|
string path = getPathForFile(name);
|
||||||
|
return path == null ? null : underlyingStore.GetStream(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAvailableResources() => source.Files.Select(f => f.Filename);
|
||||||
|
|
||||||
|
byte[] IResourceStore<byte[]>.Get(string name) => GetAsync(name).Result;
|
||||||
|
|
||||||
|
public Task<byte[]> GetAsync(string name)
|
||||||
|
{
|
||||||
|
string path = getPathForFile(name);
|
||||||
|
return path == null ? Task.FromResult<byte[]>(null) : underlyingStore.GetAsync(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Support
|
||||||
|
|
||||||
|
private bool isDisposed;
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!isDisposed)
|
||||||
|
{
|
||||||
|
isDisposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~LegacySkinResourceStore()
|
||||||
|
{
|
||||||
|
Dispose(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
53
osu.Game/Skinning/LegacySpriteText.cs
Normal file
53
osu.Game/Skinning/LegacySpriteText.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// 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.Threading.Tasks;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Text;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
public class LegacySpriteText : OsuSpriteText
|
||||||
|
{
|
||||||
|
private readonly LegacyGlyphStore glyphStore;
|
||||||
|
|
||||||
|
public LegacySpriteText(ISkin skin, string font)
|
||||||
|
{
|
||||||
|
Shadow = false;
|
||||||
|
UseFullGlyphHeight = false;
|
||||||
|
|
||||||
|
Font = new FontUsage(font, OsuFont.DEFAULT_FONT_SIZE);
|
||||||
|
glyphStore = new LegacyGlyphStore(skin);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore);
|
||||||
|
|
||||||
|
private class LegacyGlyphStore : ITexturedGlyphLookupStore
|
||||||
|
{
|
||||||
|
private readonly ISkin skin;
|
||||||
|
|
||||||
|
public LegacyGlyphStore(ISkin skin)
|
||||||
|
{
|
||||||
|
this.skin = skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITexturedCharacterGlyph Get(string fontName, char character)
|
||||||
|
{
|
||||||
|
var texture = skin.GetTexture($"{fontName}-{character}");
|
||||||
|
|
||||||
|
if (texture != null)
|
||||||
|
// Approximate value that brings character sizing roughly in-line with stable
|
||||||
|
texture.ScaleAdjust *= 18;
|
||||||
|
|
||||||
|
if (texture == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, null), texture, 1f / texture.ScaleAdjust);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<ITexturedCharacterGlyph> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,21 +7,18 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An empty skin configuration.
|
||||||
|
/// </summary>
|
||||||
public class SkinConfiguration : IHasComboColours, IHasCustomColours
|
public class SkinConfiguration : IHasComboColours, IHasCustomColours
|
||||||
{
|
{
|
||||||
public readonly SkinInfo SkinInfo = new SkinInfo();
|
public readonly SkinInfo SkinInfo = new SkinInfo();
|
||||||
|
|
||||||
public List<Color4> ComboColours { get; set; } = new List<Color4>
|
public List<Color4> ComboColours { get; set; } = new List<Color4>();
|
||||||
{
|
|
||||||
new Color4(17, 136, 170, 255),
|
|
||||||
new Color4(102, 136, 0, 255),
|
|
||||||
new Color4(204, 102, 0, 255),
|
|
||||||
new Color4(121, 9, 13, 255)
|
|
||||||
};
|
|
||||||
|
|
||||||
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
|
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
|
||||||
|
|
||||||
public string HitCircleFont { get; set; } = "default";
|
public string HitCircleFont { get; set; }
|
||||||
|
|
||||||
public int HitCircleOverlap { get; set; }
|
public int HitCircleOverlap { get; set; }
|
||||||
|
|
||||||
@ -29,6 +26,6 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public float? SliderPathRadius { get; set; }
|
public float? SliderPathRadius { get; set; }
|
||||||
|
|
||||||
public bool? CursorExpand { get; set; } = true;
|
public bool? CursorExpand { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,11 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public string FullName => $"\"{Name}\" by {Creator}";
|
public string FullName => $"\"{Name}\" by {Creator}";
|
||||||
|
|
||||||
public static SkinInfo Default { get; } = new SkinInfo { Name = "osu!lazer", Creator = "team osu!" };
|
public static SkinInfo Default { get; } = new SkinInfo
|
||||||
|
{
|
||||||
|
Name = "osu!lazer",
|
||||||
|
Creator = "team osu!"
|
||||||
|
};
|
||||||
|
|
||||||
public bool Equals(SkinInfo other) => other != null && ID == other.ID;
|
public bool Equals(SkinInfo other) => other != null && ID == other.ID;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Audio.Sample;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
@ -25,6 +26,8 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
private readonly AudioManager audio;
|
private readonly AudioManager audio;
|
||||||
|
|
||||||
|
private readonly IResourceStore<byte[]> legacyDefaultResources;
|
||||||
|
|
||||||
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>(new DefaultSkin());
|
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>(new DefaultSkin());
|
||||||
public readonly Bindable<SkinInfo> CurrentSkinInfo = new Bindable<SkinInfo>(SkinInfo.Default) { Default = SkinInfo.Default };
|
public readonly Bindable<SkinInfo> CurrentSkinInfo = new Bindable<SkinInfo>(SkinInfo.Default) { Default = SkinInfo.Default };
|
||||||
|
|
||||||
@ -34,10 +37,11 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected override string ImportFromStablePath => "Skins";
|
protected override string ImportFromStablePath => "Skins";
|
||||||
|
|
||||||
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio)
|
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio, IResourceStore<byte[]> legacyDefaultResources)
|
||||||
: base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
|
: base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
|
||||||
{
|
{
|
||||||
this.audio = audio;
|
this.audio = audio;
|
||||||
|
this.legacyDefaultResources = legacyDefaultResources;
|
||||||
|
|
||||||
ItemRemoved += removedInfo =>
|
ItemRemoved += removedInfo =>
|
||||||
{
|
{
|
||||||
@ -66,6 +70,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
var userSkins = GetAllUserSkins();
|
var userSkins = GetAllUserSkins();
|
||||||
userSkins.Insert(0, SkinInfo.Default);
|
userSkins.Insert(0, SkinInfo.Default);
|
||||||
|
userSkins.Insert(1, DefaultLegacySkin.Info);
|
||||||
return userSkins;
|
return userSkins;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +96,7 @@ namespace osu.Game.Skinning
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.Name = model.Name.Replace(".osk", "");
|
model.Name = model.Name.Replace(".osk", "");
|
||||||
model.Creator = "Unknown";
|
model.Creator = model.Creator ?? "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +110,9 @@ namespace osu.Game.Skinning
|
|||||||
if (skinInfo == SkinInfo.Default)
|
if (skinInfo == SkinInfo.Default)
|
||||||
return new DefaultSkin();
|
return new DefaultSkin();
|
||||||
|
|
||||||
|
if (skinInfo == DefaultLegacySkin.Info)
|
||||||
|
return new DefaultLegacySkin(legacyDefaultResources, audio);
|
||||||
|
|
||||||
return new LegacySkin(skinInfo, Files.Store, audio);
|
return new LegacySkin(skinInfo, Files.Store, audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,38 +4,43 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Configuration;
|
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A container which overrides existing skin options with beatmap-local values.
|
/// A container which adds a local <see cref="ISkinSource"/> to the hierarchy.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LocalSkinOverrideContainer : Container, ISkinSource
|
public class SkinProvidingContainer : Container, ISkinSource
|
||||||
{
|
{
|
||||||
public event Action SourceChanged;
|
public event Action SourceChanged;
|
||||||
|
|
||||||
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
|
|
||||||
private readonly Bindable<bool> beatmapHitsounds = new Bindable<bool>();
|
|
||||||
|
|
||||||
private readonly ISkin skin;
|
private readonly ISkin skin;
|
||||||
|
|
||||||
private ISkinSource fallbackSource;
|
private ISkinSource fallbackSource;
|
||||||
|
|
||||||
public LocalSkinOverrideContainer(ISkin skin)
|
protected virtual bool AllowDrawableLookup(string componentName) => true;
|
||||||
|
|
||||||
|
protected virtual bool AllowTextureLookup(string componentName) => true;
|
||||||
|
|
||||||
|
protected virtual bool AllowSampleLookup(ISampleInfo componentName) => true;
|
||||||
|
|
||||||
|
protected virtual bool AllowConfigurationLookup => true;
|
||||||
|
|
||||||
|
public SkinProvidingContainer(ISkin skin)
|
||||||
{
|
{
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(string componentName)
|
public Drawable GetDrawableComponent(string componentName)
|
||||||
{
|
{
|
||||||
Drawable sourceDrawable;
|
Drawable sourceDrawable;
|
||||||
if (beatmapSkins.Value && (sourceDrawable = skin?.GetDrawableComponent(componentName)) != null)
|
if (AllowDrawableLookup(componentName) && (sourceDrawable = skin?.GetDrawableComponent(componentName)) != null)
|
||||||
return sourceDrawable;
|
return sourceDrawable;
|
||||||
|
|
||||||
return fallbackSource?.GetDrawableComponent(componentName);
|
return fallbackSource?.GetDrawableComponent(componentName);
|
||||||
@ -44,7 +49,7 @@ namespace osu.Game.Skinning
|
|||||||
public Texture GetTexture(string componentName)
|
public Texture GetTexture(string componentName)
|
||||||
{
|
{
|
||||||
Texture sourceTexture;
|
Texture sourceTexture;
|
||||||
if (beatmapSkins.Value && (sourceTexture = skin?.GetTexture(componentName)) != null)
|
if (AllowTextureLookup(componentName) && (sourceTexture = skin?.GetTexture(componentName)) != null)
|
||||||
return sourceTexture;
|
return sourceTexture;
|
||||||
|
|
||||||
return fallbackSource.GetTexture(componentName);
|
return fallbackSource.GetTexture(componentName);
|
||||||
@ -53,7 +58,7 @@ namespace osu.Game.Skinning
|
|||||||
public SampleChannel GetSample(ISampleInfo sampleInfo)
|
public SampleChannel GetSample(ISampleInfo sampleInfo)
|
||||||
{
|
{
|
||||||
SampleChannel sourceChannel;
|
SampleChannel sourceChannel;
|
||||||
if (beatmapHitsounds.Value && (sourceChannel = skin?.GetSample(sampleInfo)) != null)
|
if (AllowSampleLookup(sampleInfo) && (sourceChannel = skin?.GetSample(sampleInfo)) != null)
|
||||||
return sourceChannel;
|
return sourceChannel;
|
||||||
|
|
||||||
return fallbackSource?.GetSample(sampleInfo);
|
return fallbackSource?.GetSample(sampleInfo);
|
||||||
@ -62,14 +67,13 @@ namespace osu.Game.Skinning
|
|||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration
|
||||||
{
|
{
|
||||||
TValue val;
|
TValue val;
|
||||||
if ((skin as Skin)?.Configuration is TConfiguration conf)
|
if (AllowConfigurationLookup && skin != null && (val = skin.GetValue(query)) != null)
|
||||||
if (beatmapSkins.Value && (val = query.Invoke(conf)) != null)
|
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
return fallbackSource == null ? default : fallbackSource.GetValue(query);
|
return fallbackSource == null ? default : fallbackSource.GetValue(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSourceChanged() => SourceChanged?.Invoke();
|
protected virtual void TriggerSourceChanged() => SourceChanged?.Invoke();
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
@ -77,18 +81,10 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
fallbackSource = dependencies.Get<ISkinSource>();
|
fallbackSource = dependencies.Get<ISkinSource>();
|
||||||
if (fallbackSource != null)
|
if (fallbackSource != null)
|
||||||
fallbackSource.SourceChanged += onSourceChanged;
|
fallbackSource.SourceChanged += TriggerSourceChanged;
|
||||||
|
|
||||||
dependencies.CacheAs<ISkinSource>(this);
|
dependencies.CacheAs<ISkinSource>(this);
|
||||||
|
|
||||||
var config = dependencies.Get<OsuConfigManager>();
|
|
||||||
|
|
||||||
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
|
|
||||||
config.BindWith(OsuSetting.BeatmapHitsounds, beatmapHitsounds);
|
|
||||||
|
|
||||||
beatmapSkins.BindValueChanged(_ => onSourceChanged());
|
|
||||||
beatmapHitsounds.BindValueChanged(_ => onSourceChanged());
|
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +96,7 @@ namespace osu.Game.Skinning
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (fallbackSource != null)
|
if (fallbackSource != null)
|
||||||
fallbackSource.SourceChanged -= onSourceChanged;
|
fallbackSource.SourceChanged -= TriggerSourceChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ namespace osu.Game.Skinning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The displayed component.
|
/// The displayed component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Drawable Drawable { get; private set; }
|
public Drawable Drawable { get; private set; }
|
||||||
|
|
||||||
private readonly string componentName;
|
private readonly string componentName;
|
||||||
|
|
||||||
|
@ -22,12 +22,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
this.ruleset = ruleset;
|
this.ruleset = ruleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected OsuConfigManager LocalConfig;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
OsuConfigManager manager;
|
Dependencies.Cache(LocalConfig = new OsuConfigManager(LocalStorage));
|
||||||
Dependencies.Cache(manager = new OsuConfigManager(LocalStorage));
|
LocalConfig.GetBindable<double>(OsuSetting.DimLevel).Value = 1.0;
|
||||||
manager.GetBindable<double>(OsuSetting.DimLevel).Value = 1.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
@ -9,6 +10,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
protected override bool PauseOnFocusLost => false;
|
protected override bool PauseOnFocusLost => false;
|
||||||
|
|
||||||
|
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
|
||||||
|
|
||||||
public TestPlayer(bool allowPause = true, bool showResults = true)
|
public TestPlayer(bool allowPause = true, bool showResults = true)
|
||||||
: base(allowPause, showResults)
|
: base(allowPause, showResults)
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2019.828.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2019.830.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
@ -117,9 +117,9 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2019.828.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2019.830.1" />
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.828.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.830.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.11.0" />
|
<PackageReference Include="NUnit" Version="3.11.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user