mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 09:02:55 +08:00
Merge branch 'master' into fix-editor-bindable-crash
This commit is contained in:
commit
351acce698
@ -43,8 +43,9 @@ using osuTK.Input;
|
|||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
[Cached(typeof(IBeatSnapProvider))]
|
[Cached(typeof(IBeatSnapProvider))]
|
||||||
|
[Cached(typeof(ISamplePlaybackDisabler))]
|
||||||
[Cached]
|
[Cached]
|
||||||
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider
|
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider, ISamplePlaybackDisabler
|
||||||
{
|
{
|
||||||
public override float BackgroundParallaxAmount => 0.1f;
|
public override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
@ -64,6 +65,10 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private DialogOverlay dialogOverlay { get; set; }
|
private DialogOverlay dialogOverlay { get; set; }
|
||||||
|
|
||||||
|
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
||||||
|
|
||||||
|
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
||||||
|
|
||||||
private bool exitConfirmed;
|
private bool exitConfirmed;
|
||||||
|
|
||||||
private string lastSavedHash;
|
private string lastSavedHash;
|
||||||
@ -109,9 +114,10 @@ namespace osu.Game.Screens.Edit
|
|||||||
UpdateClockSource();
|
UpdateClockSource();
|
||||||
|
|
||||||
dependencies.CacheAs(clock);
|
dependencies.CacheAs(clock);
|
||||||
dependencies.CacheAs<ISamplePlaybackDisabler>(clock);
|
|
||||||
AddInternal(clock);
|
AddInternal(clock);
|
||||||
|
|
||||||
|
clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());
|
||||||
|
|
||||||
// todo: remove caching of this and consume via editorBeatmap?
|
// todo: remove caching of this and consume via editorBeatmap?
|
||||||
dependencies.Cache(beatDivisor);
|
dependencies.Cache(beatDivisor);
|
||||||
|
|
||||||
@ -564,40 +570,52 @@ namespace osu.Game.Screens.Edit
|
|||||||
.ScaleTo(0.98f, 200, Easing.OutQuint)
|
.ScaleTo(0.98f, 200, Easing.OutQuint)
|
||||||
.FadeOut(200, Easing.OutQuint);
|
.FadeOut(200, Easing.OutQuint);
|
||||||
|
|
||||||
if ((currentScreen = screenContainer.SingleOrDefault(s => s.Type == e.NewValue)) != null)
|
try
|
||||||
{
|
{
|
||||||
screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
|
if ((currentScreen = screenContainer.SingleOrDefault(s => s.Type == e.NewValue)) != null)
|
||||||
|
{
|
||||||
|
screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
|
||||||
|
|
||||||
currentScreen
|
currentScreen
|
||||||
.ScaleTo(1, 200, Easing.OutQuint)
|
.ScaleTo(1, 200, Easing.OutQuint)
|
||||||
.FadeIn(200, Easing.OutQuint);
|
.FadeIn(200, Easing.OutQuint);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (e.NewValue)
|
||||||
|
{
|
||||||
|
case EditorScreenMode.SongSetup:
|
||||||
|
currentScreen = new SetupScreen();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EditorScreenMode.Compose:
|
||||||
|
currentScreen = new ComposeScreen();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EditorScreenMode.Design:
|
||||||
|
currentScreen = new DesignScreen();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EditorScreenMode.Timing:
|
||||||
|
currentScreen = new TimingScreen();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadComponentAsync(currentScreen, newScreen =>
|
||||||
|
{
|
||||||
|
if (newScreen == currentScreen)
|
||||||
|
screenContainer.Add(newScreen);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
switch (e.NewValue)
|
|
||||||
{
|
{
|
||||||
case EditorScreenMode.SongSetup:
|
updateSampleDisabledState();
|
||||||
currentScreen = new SetupScreen();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EditorScreenMode.Compose:
|
|
||||||
currentScreen = new ComposeScreen();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EditorScreenMode.Design:
|
|
||||||
currentScreen = new DesignScreen();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EditorScreenMode.Timing:
|
|
||||||
currentScreen = new TimingScreen();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LoadComponentAsync(currentScreen, newScreen =>
|
private void updateSampleDisabledState()
|
||||||
{
|
{
|
||||||
if (newScreen == currentScreen)
|
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value || !(currentScreen is ComposeScreen);
|
||||||
screenContainer.Add(newScreen);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seek(UIEvent e, int direction)
|
private void seek(UIEvent e, int direction)
|
||||||
|
@ -11,14 +11,13 @@ using osu.Framework.Timing;
|
|||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
|
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock, ISamplePlaybackDisabler
|
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
||||||
{
|
{
|
||||||
public IBindable<Track> Track => track;
|
public IBindable<Track> Track => track;
|
||||||
|
|
||||||
@ -32,9 +31,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private readonly DecoupleableInterpolatingFramedClock underlyingClock;
|
private readonly DecoupleableInterpolatingFramedClock underlyingClock;
|
||||||
|
|
||||||
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
public IBindable<bool> SeekingOrStopped => seekingOrStopped;
|
||||||
|
|
||||||
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
private readonly Bindable<bool> seekingOrStopped = new Bindable<bool>(true);
|
||||||
|
|
||||||
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
||||||
: this(beatmap.Beatmap.ControlPointInfo, beatmap.Track.Length, beatDivisor)
|
: this(beatmap.Beatmap.ControlPointInfo, beatmap.Track.Length, beatDivisor)
|
||||||
@ -171,13 +170,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.Value = true;
|
seekingOrStopped.Value = true;
|
||||||
underlyingClock.Stop();
|
underlyingClock.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Seek(double position)
|
public bool Seek(double position)
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.Value = true;
|
seekingOrStopped.Value = true;
|
||||||
|
|
||||||
ClearTransforms();
|
ClearTransforms();
|
||||||
return underlyingClock.Seek(position);
|
return underlyingClock.Seek(position);
|
||||||
@ -228,7 +227,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private void updateSeekingState()
|
private void updateSeekingState()
|
||||||
{
|
{
|
||||||
if (samplePlaybackDisabled.Value)
|
if (seekingOrStopped.Value)
|
||||||
{
|
{
|
||||||
if (track.Value?.IsRunning != true)
|
if (track.Value?.IsRunning != true)
|
||||||
{
|
{
|
||||||
@ -240,13 +239,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
// we are either running a seek tween or doing an immediate seek.
|
// we are either running a seek tween or doing an immediate seek.
|
||||||
// in the case of an immediate seek the seeking bool will be set to false after one update.
|
// in the case of an immediate seek the seeking bool will be set to false after one update.
|
||||||
// this allows for silencing hit sounds and the likes.
|
// this allows for silencing hit sounds and the likes.
|
||||||
samplePlaybackDisabled.Value = Transforms.Any();
|
seekingOrStopped.Value = Transforms.Any();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SeekTo(double seekDestination)
|
public void SeekTo(double seekDestination)
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.Value = true;
|
seekingOrStopped.Value = true;
|
||||||
|
|
||||||
if (IsRunning)
|
if (IsRunning)
|
||||||
Seek(seekDestination);
|
Seek(seekDestination);
|
||||||
|
Loading…
Reference in New Issue
Block a user