mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 20:22:58 +08:00
Merge branch 'master' into fix-taiko-scroller-time-control
This commit is contained in:
commit
46608615b0
@ -7,6 +7,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
@ -49,6 +50,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
if (e.Button != MouseButton.Left)
|
||||
return;
|
||||
|
||||
base.OnMouseUp(e);
|
||||
EndPlacement(true);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
@ -46,6 +47,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (e.Button != MouseButton.Left)
|
||||
return false;
|
||||
|
||||
if (Column == null)
|
||||
return base.OnMouseDown(e);
|
||||
|
||||
|
@ -5,6 +5,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
@ -30,6 +31,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (e.Button != MouseButton.Left)
|
||||
return false;
|
||||
|
||||
base.OnMouseDown(e);
|
||||
|
||||
// Place the note immediately.
|
||||
|
@ -152,11 +152,12 @@ namespace osu.Game.Tests.Skins
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetBeatmapVersionNoFallback()
|
||||
public void TestSetBeatmapVersionFallsBackToUserSkin()
|
||||
{
|
||||
// completely ignoring beatmap versions for simplicity.
|
||||
AddStep("Set user skin version 2.3", () => userSource.Configuration.LegacyVersion = 2.3m);
|
||||
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = 1.7m);
|
||||
AddAssert("Check legacy version lookup", () => requester.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value == 1.7m);
|
||||
AddAssert("Check legacy version lookup", () => requester.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value == 2.3m);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -172,7 +173,6 @@ namespace osu.Game.Tests.Skins
|
||||
public void TestIniWithNoVersionFallsBackTo1()
|
||||
{
|
||||
AddStep("Parse skin with no version", () => userSource.Configuration = new LegacySkinDecoder().Decode(new LineBufferedReader(new MemoryStream())));
|
||||
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = null);
|
||||
AddAssert("Check legacy version lookup", () => requester.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value == 1.0m);
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@ using Newtonsoft.Json.Linq;
|
||||
namespace osu.Game.IO.Serialization.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// A type of <see cref="JsonConverter"/> that serializes a <see cref="List{T}"/> alongside
|
||||
/// A type of <see cref="JsonConverter"/> that serializes an <see cref="IReadOnlyList{T}"/> alongside
|
||||
/// a lookup table for the types contained. The lookup table is used in deserialization to
|
||||
/// reconstruct the objects with their original types.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of objects contained in the <see cref="List{T}"/> this attribute is attached to.</typeparam>
|
||||
public class TypedListConverter<T> : JsonConverter
|
||||
/// <typeparam name="T">The type of objects contained in the <see cref="IReadOnlyList{T}"/> this attribute is attached to.</typeparam>
|
||||
public class TypedListConverter<T> : JsonConverter<IReadOnlyList<T>>
|
||||
{
|
||||
private readonly bool requiresTypeVersion;
|
||||
|
||||
@ -36,9 +36,7 @@ namespace osu.Game.IO.Serialization.Converters
|
||||
this.requiresTypeVersion = requiresTypeVersion;
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(List<T>);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
public override IReadOnlyList<T> ReadJson(JsonReader reader, Type objectType, IReadOnlyList<T> existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
var list = new List<T>();
|
||||
|
||||
@ -59,14 +57,12 @@ namespace osu.Game.IO.Serialization.Converters
|
||||
return list;
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public override void WriteJson(JsonWriter writer, IReadOnlyList<T> value, JsonSerializer serializer)
|
||||
{
|
||||
var list = (IEnumerable<T>)value;
|
||||
|
||||
var lookupTable = new List<string>();
|
||||
var objects = new List<JObject>();
|
||||
|
||||
foreach (var item in list)
|
||||
foreach (var item in value)
|
||||
{
|
||||
var type = item.GetType();
|
||||
var assemblyName = type.Assembly.GetName();
|
||||
|
@ -11,26 +11,22 @@ namespace osu.Game.IO.Serialization.Converters
|
||||
/// <summary>
|
||||
/// A type of <see cref="JsonConverter"/> that serializes only the X and Y coordinates of a <see cref="Vector2"/>.
|
||||
/// </summary>
|
||||
public class Vector2Converter : JsonConverter
|
||||
public class Vector2Converter : JsonConverter<Vector2>
|
||||
{
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(Vector2);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
public override Vector2 ReadJson(JsonReader reader, Type objectType, Vector2 existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
var obj = JObject.Load(reader);
|
||||
return new Vector2((float)obj["x"], (float)obj["y"]);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public override void WriteJson(JsonWriter writer, Vector2 value, JsonSerializer serializer)
|
||||
{
|
||||
var vector = (Vector2)value;
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("x");
|
||||
writer.WriteValue(vector.X);
|
||||
writer.WriteValue(value.X);
|
||||
writer.WritePropertyName("y");
|
||||
writer.WriteValue(vector.Y);
|
||||
writer.WriteValue(value.Y);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace osu.Game
|
||||
|
||||
protected BackButton BackButton;
|
||||
|
||||
protected SettingsPanel Settings;
|
||||
protected SettingsOverlay Settings;
|
||||
|
||||
private VolumeOverlay volume;
|
||||
private OsuLogo osuLogo;
|
||||
@ -767,13 +767,20 @@ namespace osu.Game
|
||||
|
||||
private Task asyncLoadStream;
|
||||
|
||||
private T loadComponentSingleFile<T>(T d, Action<T> add, bool cache = false)
|
||||
/// <summary>
|
||||
/// Queues loading the provided component in sequential fashion.
|
||||
/// This operation is limited to a single thread to avoid saturating all cores.
|
||||
/// </summary>
|
||||
/// <param name="component">The component to load.</param>
|
||||
/// <param name="loadCompleteAction">An action to invoke on load completion (generally to add the component to the hierarchy).</param>
|
||||
/// <param name="cache">Whether to cache the component as type <typeparamref name="T"/> into the game dependencies before any scheduling.</param>
|
||||
private T loadComponentSingleFile<T>(T component, Action<T> loadCompleteAction, bool cache = false)
|
||||
where T : Drawable
|
||||
{
|
||||
if (cache)
|
||||
dependencies.Cache(d);
|
||||
dependencies.CacheAs(component);
|
||||
|
||||
if (d is OverlayContainer overlay)
|
||||
if (component is OverlayContainer overlay)
|
||||
overlays.Add(overlay);
|
||||
|
||||
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
|
||||
@ -791,12 +798,12 @@ namespace osu.Game
|
||||
|
||||
try
|
||||
{
|
||||
Logger.Log($"Loading {d}...", level: LogLevel.Debug);
|
||||
Logger.Log($"Loading {component}...", level: LogLevel.Debug);
|
||||
|
||||
// Since this is running in a separate thread, it is possible for OsuGame to be disposed after LoadComponentAsync has been called
|
||||
// throwing an exception. To avoid this, the call is scheduled on the update thread, which does not run if IsDisposed = true
|
||||
Task task = null;
|
||||
var del = new ScheduledDelegate(() => task = LoadComponentAsync(d, add));
|
||||
var del = new ScheduledDelegate(() => task = LoadComponentAsync(component, loadCompleteAction));
|
||||
Scheduler.Add(del);
|
||||
|
||||
// The delegate won't complete if OsuGame has been disposed in the meantime
|
||||
@ -811,7 +818,7 @@ namespace osu.Game
|
||||
|
||||
await task;
|
||||
|
||||
Logger.Log($"Loaded {d}!", level: LogLevel.Debug);
|
||||
Logger.Log($"Loaded {component}!", level: LogLevel.Debug);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@ -819,7 +826,7 @@ namespace osu.Game
|
||||
});
|
||||
});
|
||||
|
||||
return d;
|
||||
return component;
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
|
@ -86,7 +86,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
api.Unregister(this);
|
||||
api?.Unregister(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,11 @@ namespace osu.Game.Skinning
|
||||
switch (lookup)
|
||||
{
|
||||
case LegacySkinConfiguration.LegacySetting s when s == LegacySkinConfiguration.LegacySetting.Version:
|
||||
if (Configuration.LegacyVersion is decimal version)
|
||||
return SkinUtils.As<TValue>(new Bindable<decimal>(version));
|
||||
// For lookup simplicity, ignore beatmap-level versioning completely.
|
||||
|
||||
// If it is decided that we need this due to beatmaps somehow using it, the default (1.0 specified in LegacySkinDecoder.CreateTemplateObject)
|
||||
// needs to be removed else it will cause incorrect skin behaviours. This is due to the config lookup having no context of which skin
|
||||
// it should be returning the version for.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user