mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 06:42:54 +08:00
Add more checks and remove direct cast
This commit is contained in:
parent
a7e6efd34f
commit
c9f90efb8a
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The input manager for this RulesetContainer.
|
/// The input manager for this RulesetContainer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal IHasReplayHandler ReplayInputManager => (IHasReplayHandler)KeyBindingInputManager;
|
internal IHasReplayHandler ReplayInputManager => KeyBindingInputManager as IHasReplayHandler;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The key conversion input manager for this RulesetContainer.
|
/// The key conversion input manager for this RulesetContainer.
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether we have a replay loaded currently.
|
/// Whether we have a replay loaded currently.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasReplayLoaded => ReplayInputManager.ReplayInputHandler != null;
|
public bool HasReplayLoaded => ReplayInputManager?.ReplayInputHandler != null;
|
||||||
|
|
||||||
public abstract IEnumerable<HitObject> Objects { get; }
|
public abstract IEnumerable<HitObject> Objects { get; }
|
||||||
|
|
||||||
@ -107,6 +107,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <param name="replay">The replay, null for local input.</param>
|
/// <param name="replay">The replay, null for local input.</param>
|
||||||
public virtual void SetReplay(Replay replay)
|
public virtual void SetReplay(Replay replay)
|
||||||
{
|
{
|
||||||
|
if (ReplayInputManager == null)
|
||||||
|
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports replay loading is not available");
|
||||||
|
|
||||||
Replay = replay;
|
Replay = replay;
|
||||||
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
|
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user