mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:32:55 +08:00
Fix ReplayLoader not being treated as having a replay loaded
Player checks for HasReplayLoaded in Player.load(), but the replay is attached in ReplayPlayer.LoadComplete(), which is too late.
This commit is contained in:
parent
da793d91ea
commit
2ebb3d6e0e
@ -13,6 +13,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
@ -45,9 +46,9 @@ namespace osu.Game.Rulesets.UI
|
||||
public PassThroughInputManager KeyBindingInputManager;
|
||||
|
||||
/// <summary>
|
||||
/// Whether we have a replay loaded currently.
|
||||
/// Whether a replay is currently loaded.
|
||||
/// </summary>
|
||||
public bool HasReplayLoaded => ReplayInputManager?.ReplayInputHandler != null;
|
||||
public readonly BindableBool HasReplayLoaded = new BindableBool();
|
||||
|
||||
public abstract IEnumerable<HitObject> Objects { get; }
|
||||
|
||||
@ -99,6 +100,8 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
Replay = replay;
|
||||
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
|
||||
|
||||
HasReplayLoaded.Value = ReplayInputManager.ReplayInputHandler != null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play
|
||||
public readonly ReplaySettingsOverlay ReplaySettingsOverlay;
|
||||
|
||||
private Bindable<bool> showHud;
|
||||
private bool replayLoaded;
|
||||
private readonly BindableBool replayLoaded = new BindableBool();
|
||||
|
||||
private static bool hasShownNotificationOnce;
|
||||
|
||||
@ -59,6 +59,24 @@ namespace osu.Game.Screens.Play
|
||||
ReplaySettingsOverlay = CreateReplaySettingsOverlay(),
|
||||
}
|
||||
});
|
||||
|
||||
replayLoaded.ValueChanged += replayLoadedValueChanged;
|
||||
}
|
||||
|
||||
private void replayLoadedValueChanged(bool loaded)
|
||||
{
|
||||
ReplaySettingsOverlay.ReplayLoaded = loaded;
|
||||
|
||||
if (loaded)
|
||||
{
|
||||
ReplaySettingsOverlay.Show();
|
||||
ModDisplay.FadeIn(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplaySettingsOverlay.Hide();
|
||||
ModDisplay.Delay(2000).FadeOut(200);
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
@ -95,16 +113,10 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
(rulesetContainer.KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(KeyCounter);
|
||||
|
||||
replayLoaded = rulesetContainer.HasReplayLoaded;
|
||||
replayLoaded.BindTo(rulesetContainer.HasReplayLoaded);
|
||||
replayLoaded.TriggerChange();
|
||||
|
||||
ReplaySettingsOverlay.ReplayLoaded = replayLoaded;
|
||||
|
||||
// in the case a replay isn't loaded, we want some elements to only appear briefly.
|
||||
if (!replayLoaded)
|
||||
{
|
||||
ReplaySettingsOverlay.Hide();
|
||||
ModDisplay.Delay(2000).FadeOut(200);
|
||||
}
|
||||
Progress.BindRulestContainer(rulesetContainer);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Screens.Play
|
||||
public int RestartCount;
|
||||
|
||||
public CursorContainer Cursor => RulesetContainer.Cursor;
|
||||
public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded;
|
||||
public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded.Value;
|
||||
|
||||
private IAdjustableClock adjustableSourceClock;
|
||||
private FramedOffsetClock offsetClock;
|
||||
@ -226,7 +226,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
hudOverlay.Progress.Objects = RulesetContainer.Objects;
|
||||
hudOverlay.Progress.AudioClock = decoupledClock;
|
||||
hudOverlay.Progress.AllowSeeking = RulesetContainer.HasReplayLoaded;
|
||||
hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos);
|
||||
|
||||
hudOverlay.ModDisplay.Current.BindTo(working.Mods);
|
||||
|
@ -9,9 +9,12 @@ using System.Collections.Generic;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using System.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class SongProgress : OverlayContainer
|
||||
@ -53,6 +56,8 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
private readonly BindableBool replayLoaded = new BindableBool();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
@ -92,6 +97,8 @@ namespace osu.Game.Screens.Play
|
||||
OnSeek = position => OnSeek?.Invoke(position),
|
||||
},
|
||||
};
|
||||
|
||||
replayLoaded.ValueChanged += v => AllowSeeking = v;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -99,6 +106,12 @@ namespace osu.Game.Screens.Play
|
||||
State = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void BindRulestContainer(RulesetContainer rulesetContainer)
|
||||
{
|
||||
replayLoaded.BindTo(rulesetContainer.HasReplayLoaded);
|
||||
replayLoaded.TriggerChange();
|
||||
}
|
||||
|
||||
private bool allowSeeking;
|
||||
|
||||
public bool AllowSeeking
|
||||
|
Loading…
Reference in New Issue
Block a user