mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 16:02:58 +08:00
Reorder class
This commit is contained in:
parent
5f288650bf
commit
c186629b8a
@ -58,22 +58,40 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Place to put drawables above hit objects but below UI.
|
/// Place to put drawables above hit objects but below UI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Container Overlays { get; protected set; }
|
public Container Overlays { get; private set; }
|
||||||
|
|
||||||
public override CursorContainer Cursor => Playfield.Cursor;
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="JudgementResult"/> has been applied by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<JudgementResult> OnNewResult;
|
||||||
|
|
||||||
public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value;
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="JudgementResult"/> is being reverted by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<JudgementResult> OnRevertResult;
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
|
/// <summary>
|
||||||
|
/// The beatmap.
|
||||||
|
/// </summary>
|
||||||
|
public Beatmap<TObject> Beatmap;
|
||||||
|
|
||||||
|
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
||||||
|
|
||||||
protected IRulesetConfigManager Config { get; private set; }
|
protected IRulesetConfigManager Config { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The mods which are to be applied.
|
||||||
|
/// </summary>
|
||||||
|
private readonly IEnumerable<Mod> mods;
|
||||||
|
|
||||||
|
private FrameStabilityContainer frameStabilityContainer;
|
||||||
|
|
||||||
private OnScreenDisplay onScreenDisplay;
|
private OnScreenDisplay onScreenDisplay;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a ruleset visualisation for the provided ruleset and beatmap.
|
/// Creates a ruleset visualisation for the provided ruleset and beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ruleset">The ruleset being repesented.</param>
|
/// <param name="ruleset">The ruleset being represented.</param>
|
||||||
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
||||||
protected DrawableRuleset(Ruleset ruleset, WorkingBeatmap workingBeatmap)
|
protected DrawableRuleset(Ruleset ruleset, WorkingBeatmap workingBeatmap)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
@ -99,20 +117,42 @@ namespace osu.Game.Rulesets.UI
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetReplayScore(Score replayScore)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
if (!(KeyBindingInputManager is IHasReplayHandler replayInputManager))
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports replay loading is not available");
|
|
||||||
|
|
||||||
var handler = (ReplayScore = replayScore) != null ? CreateReplayInputHandler(replayScore.Replay) : null;
|
onScreenDisplay = dependencies.Get<OnScreenDisplay>();
|
||||||
|
|
||||||
replayInputManager.ReplayInputHandler = handler;
|
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
||||||
frameStabilityContainer.ReplayInputHandler = handler;
|
if (Config != null)
|
||||||
|
{
|
||||||
|
dependencies.Cache(Config);
|
||||||
|
onScreenDisplay?.BeginTracking(this, Config);
|
||||||
|
}
|
||||||
|
|
||||||
HasReplayLoaded.Value = replayInputManager.ReplayInputHandler != null;
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
if (replayInputManager.ReplayInputHandler != null)
|
[BackgroundDependencyLoader]
|
||||||
replayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace;
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
KeyBindingInputManager.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
Playfield
|
||||||
|
});
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
frameStabilityContainer = new FrameStabilityContainer
|
||||||
|
{
|
||||||
|
Child = KeyBindingInputManager,
|
||||||
|
},
|
||||||
|
Overlays = new Container { RelativeSizeAxes = Axes.Both }
|
||||||
|
};
|
||||||
|
|
||||||
|
applyRulesetMods(mods, config);
|
||||||
|
|
||||||
|
loadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -146,6 +186,22 @@ namespace osu.Game.Rulesets.UI
|
|||||||
Playfield.Add(drawableObject);
|
Playfield.Add(drawableObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetReplayScore(Score replayScore)
|
||||||
|
{
|
||||||
|
if (!(KeyBindingInputManager is IHasReplayHandler replayInputManager))
|
||||||
|
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports replay loading is not available");
|
||||||
|
|
||||||
|
var handler = (ReplayScore = replayScore) != null ? CreateReplayInputHandler(replayScore.Replay) : null;
|
||||||
|
|
||||||
|
replayInputManager.ReplayInputHandler = handler;
|
||||||
|
frameStabilityContainer.ReplayInputHandler = handler;
|
||||||
|
|
||||||
|
HasReplayLoaded.Value = replayInputManager.ReplayInputHandler != null;
|
||||||
|
|
||||||
|
if (replayInputManager.ReplayInputHandler != null)
|
||||||
|
replayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a DrawableHitObject from a HitObject.
|
/// Creates a DrawableHitObject from a HitObject.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -156,22 +212,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
public void Attach(KeyCounterCollection keyCounter) =>
|
public void Attach(KeyCounterCollection keyCounter) =>
|
||||||
(KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(keyCounter);
|
(KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(keyCounter);
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
onScreenDisplay = dependencies.Get<OnScreenDisplay>();
|
|
||||||
|
|
||||||
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
|
||||||
if (Config != null)
|
|
||||||
{
|
|
||||||
dependencies.Cache(Config);
|
|
||||||
onScreenDisplay?.BeginTracking(this, Config);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a key conversion input manager. An exception will be thrown if a valid <see cref="RulesetInputManager{T}"/> is not returned.
|
/// Creates a key conversion input manager. An exception will be thrown if a valid <see cref="RulesetInputManager{T}"/> is not returned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -180,61 +220,14 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
protected virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
|
protected virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
|
||||||
|
|
||||||
private FrameStabilityContainer frameStabilityContainer;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a Playfield.
|
/// Creates a Playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The Playfield.</returns>
|
/// <returns>The Playfield.</returns>
|
||||||
protected abstract Playfield CreatePlayfield();
|
protected abstract Playfield CreatePlayfield();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when a <see cref="JudgementResult"/> has been applied by a <see cref="DrawableHitObject"/>.
|
|
||||||
/// </summary>
|
|
||||||
public event Action<JudgementResult> OnNewResult;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when a <see cref="JudgementResult"/> is being reverted by a <see cref="DrawableHitObject"/>.
|
|
||||||
/// </summary>
|
|
||||||
public event Action<JudgementResult> OnRevertResult;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The beatmap.
|
|
||||||
/// </summary>
|
|
||||||
public Beatmap<TObject> Beatmap;
|
|
||||||
|
|
||||||
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The mods which are to be applied.
|
|
||||||
/// </summary>
|
|
||||||
private readonly IEnumerable<Mod> mods;
|
|
||||||
|
|
||||||
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
|
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
|
||||||
KeyBindingInputManager.AddRange(new Drawable[]
|
|
||||||
{
|
|
||||||
Playfield
|
|
||||||
});
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
frameStabilityContainer = new FrameStabilityContainer
|
|
||||||
{
|
|
||||||
Child = KeyBindingInputManager,
|
|
||||||
},
|
|
||||||
Overlays = new Container { RelativeSizeAxes = Axes.Both }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Apply mods
|
|
||||||
applyRulesetMods(mods, config);
|
|
||||||
|
|
||||||
loadObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies the active mods to the Beatmap.
|
/// Applies the active mods to the Beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -264,6 +257,16 @@ namespace osu.Game.Rulesets.UI
|
|||||||
mod.ReadFromConfig(config);
|
mod.ReadFromConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region IProvideCursor
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
|
||||||
|
|
||||||
|
public override CursorContainer Cursor => Playfield.Cursor;
|
||||||
|
|
||||||
|
public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
Loading…
Reference in New Issue
Block a user