1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 01:33:20 +08:00

Merge branch 'master' into placement-blueprint-movement

This commit is contained in:
Dean Herbert 2019-10-06 13:52:22 +08:00 committed by GitHub
commit 2e20380d07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 23 deletions

View File

@ -591,5 +591,27 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.Throws<IOException>(() => Decoder.GetDecoder<Beatmap>(stream));
}
}
[Test]
public void TestAllowFallbackDecoderOverwrite()
{
Decoder<Beatmap> decoder = null;
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
using (var stream = new LineBufferedReader(resStream))
{
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
}
Assert.DoesNotThrow(LegacyDifficultyCalculatorBeatmapDecoder.Register);
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
using (var stream = new LineBufferedReader(resStream))
{
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
Assert.IsInstanceOf<LegacyDifficultyCalculatorBeatmapDecoder>(decoder);
}
}
}
}

View File

@ -18,8 +18,8 @@ namespace osu.Game.Tests.Visual.SongSelect
overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, Color4.Purple, null, Key.Number1);
overlay.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, Color4.Purple, null, Key.Number2);
overlay.AddButton(@"Edit", @"Beatmap", FontAwesome.Solid.PencilAlt, Color4.Yellow, null, Key.Number3);
overlay.AddButton(@"Delete", @"Beatmap", FontAwesome.Solid.Trash, Color4.Pink, null, Key.Number4, float.MaxValue);
overlay.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, Color4.Pink, null, Key.Number3);
overlay.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, Color4.Yellow, null, Key.Number4);
Add(overlay);

View File

@ -93,14 +93,12 @@ namespace osu.Game.Beatmaps.Formats
/// <summary>
/// Registers a fallback decoder instantiation function.
/// The fallback will be returned if the first non-empty line of the decoded stream does not match any known magic.
/// Calling this method will overwrite any existing global fallback registration for type <see cref="T"/> - use with caution.
/// </summary>
/// <typeparam name="T">Type of object being decoded.</typeparam>
/// <param name="constructor">A function that constructs the fallback<see cref="Decoder"/>.</param>
protected static void SetFallbackDecoder<T>(Func<Decoder> constructor)
{
if (fallback_decoders.ContainsKey(typeof(T)))
throw new InvalidOperationException($"A fallback decoder was already added for type {typeof(T)}.");
fallback_decoders[typeof(T)] = constructor;
}
}

View File

@ -89,11 +89,7 @@ namespace osu.Game.Screens.Select.Options
/// <param name="icon">Icon of the button.</param>
/// <param name="hotkey">Hotkey of the button.</param>
/// <param name="action">Binding the button does.</param>
/// <param name="depth">
/// <para>Lower depth to be put on the left, and higher to be put on the right.</para>
/// <para>Notice this is different to <see cref="Footer"/>!</para>
/// </param>
public void AddButton(string firstLine, string secondLine, IconUsage icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
public void AddButton(string firstLine, string secondLine, IconUsage icon, Color4 colour, Action action, Key? hotkey = null)
{
var button = new BeatmapOptionsButton
{
@ -101,7 +97,6 @@ namespace osu.Game.Screens.Select.Options
SecondLineText = secondLine,
Icon = icon,
ButtonColour = colour,
Depth = depth,
Action = () =>
{
Hide();
@ -110,7 +105,7 @@ namespace osu.Game.Screens.Select.Options
HotKey = hotkey
};
buttonsContainer.Insert((int)depth, button);
buttonsContainer.Add(button);
}
}
}

View File

@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select
{
ValidForResume = false;
Edit();
}, Key.Number3);
}, Key.Number4);
}
public override void OnResuming(IScreen last)

View File

@ -230,9 +230,9 @@ namespace osu.Game.Screens.Select
Footer.AddButton(new FooterButtonRandom { Action = triggerRandom });
Footer.AddButton(new FooterButtonOptions(), BeatmapOptions);
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo), Key.Number2);
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number3);
}
if (this.beatmaps == null)
@ -413,7 +413,7 @@ namespace osu.Game.Screens.Select
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, previous);
if (this.IsCurrentScreen() && Beatmap.Value?.Track != previous?.Track)
ensurePlayingSelected();
ensurePlayingSelected(true);
if (beatmap != null)
{
@ -585,18 +585,14 @@ namespace osu.Game.Screens.Select
{
Track track = Beatmap.Value.Track;
if (!track.IsRunning || restart)
if (!track.IsRunning)
{
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
if (music != null)
{
// use the global music controller (when available) to cancel a potential local user paused state.
music.SeekTo(track.RestartPoint);
music.Play();
}
else
if (restart)
track.Restart();
else
track.Start();
}
}