mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:02:57 +08:00
Merge branch 'master' into health-adjustments
This commit is contained in:
commit
a864f2906f
@ -9,7 +9,7 @@ using osu.Framework.Android;
|
||||
|
||||
namespace osu.Android
|
||||
{
|
||||
[Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullSensor, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = false)]
|
||||
[Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullUser, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = false)]
|
||||
public class OsuGameActivity : AndroidGameActivity
|
||||
{
|
||||
protected override Framework.Game CreateGame() => new OsuGameAndroid();
|
||||
|
@ -12,6 +12,14 @@ namespace osu.Game.Tests.Editing
|
||||
[TestFixture]
|
||||
public class EditorChangeHandlerTest
|
||||
{
|
||||
private int stateChangedFired;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
stateChangedFired = 0;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSaveRestoreState()
|
||||
{
|
||||
@ -23,6 +31,8 @@ namespace osu.Game.Tests.Editing
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
@ -30,6 +40,8 @@ namespace osu.Game.Tests.Editing
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.True);
|
||||
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -45,6 +57,7 @@ namespace osu.Game.Tests.Editing
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
string hash = handler.CurrentStateHash;
|
||||
|
||||
@ -52,6 +65,7 @@ namespace osu.Game.Tests.Editing
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(hash, Is.EqualTo(handler.CurrentStateHash));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
handler.RestoreState(-1);
|
||||
|
||||
@ -60,6 +74,7 @@ namespace osu.Game.Tests.Editing
|
||||
// we should only be able to restore once even though we saved twice.
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.True);
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -71,6 +86,8 @@ namespace osu.Game.Tests.Editing
|
||||
|
||||
for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
|
||||
{
|
||||
Assert.That(stateChangedFired, Is.EqualTo(i));
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
}
|
||||
@ -114,7 +131,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var beatmap = new EditorBeatmap(new Beatmap());
|
||||
|
||||
return (new EditorChangeHandler(beatmap), beatmap);
|
||||
var changeHandler = new EditorChangeHandler(beatmap);
|
||||
|
||||
changeHandler.OnStateChange += () => stateChangedFired++;
|
||||
return (changeHandler, beatmap);
|
||||
}
|
||||
|
||||
private void addArbitraryChange(EditorBeatmap beatmap)
|
||||
|
@ -40,17 +40,28 @@ namespace osu.Game.Rulesets.Edit
|
||||
Playfield.DisplayJudgements.Value = false;
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private IEditorChangeHandler changeHandler { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
beatmap.HitObjectAdded += addHitObject;
|
||||
beatmap.HitObjectUpdated += updateReplay;
|
||||
beatmap.HitObjectRemoved += removeHitObject;
|
||||
|
||||
if (changeHandler != null)
|
||||
{
|
||||
// for now only regenerate replay on a finalised state change, not HitObjectUpdated.
|
||||
changeHandler.OnStateChange += updateReplay;
|
||||
}
|
||||
else
|
||||
{
|
||||
beatmap.HitObjectUpdated += _ => updateReplay();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReplay(HitObject obj = null) =>
|
||||
drawableRuleset.RegenerateAutoplay();
|
||||
private void updateReplay() => drawableRuleset.RegenerateAutoplay();
|
||||
|
||||
private void addHitObject(HitObject hitObject)
|
||||
{
|
||||
@ -58,8 +69,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
drawableRuleset.Playfield.Add(drawableObject);
|
||||
drawableRuleset.Playfield.PostProcess();
|
||||
|
||||
updateReplay();
|
||||
}
|
||||
|
||||
private void removeHitObject(HitObject hitObject)
|
||||
@ -68,8 +77,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
drawableRuleset.Playfield.Remove(drawableObject);
|
||||
drawableRuleset.Playfield.PostProcess();
|
||||
|
||||
drawableRuleset.RegenerateAutoplay();
|
||||
}
|
||||
|
||||
public override bool PropagatePositionalInputSubTree => false;
|
||||
|
@ -21,6 +21,8 @@ namespace osu.Game.Screens.Edit
|
||||
public readonly Bindable<bool> CanUndo = new Bindable<bool>();
|
||||
public readonly Bindable<bool> CanRedo = new Bindable<bool>();
|
||||
|
||||
public event Action OnStateChange;
|
||||
|
||||
private readonly LegacyEditorBeatmapPatcher patcher;
|
||||
private readonly List<byte[]> savedStates = new List<byte[]>();
|
||||
|
||||
@ -109,6 +111,8 @@ namespace osu.Game.Screens.Edit
|
||||
savedStates.Add(newState);
|
||||
|
||||
currentState = savedStates.Count - 1;
|
||||
|
||||
OnStateChange?.Invoke();
|
||||
updateBindables();
|
||||
}
|
||||
}
|
||||
@ -136,6 +140,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
isRestoring = false;
|
||||
|
||||
OnStateChange?.Invoke();
|
||||
updateBindables();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
@ -10,6 +11,11 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public interface IEditorChangeHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Fired whenever a state change occurs.
|
||||
/// </summary>
|
||||
event Action OnStateChange;
|
||||
|
||||
/// <summary>
|
||||
/// Begins a bulk state change event. <see cref="EndChange"/> should be invoked soon after.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user