mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Merge remote-tracking branch 'upstream/master' into general-fixes
# Conflicts: # osu.Game/Modes/UI/HitRenderer.cs
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Modes.Mods;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -22,10 +22,13 @@ namespace osu.Game.Modes.UI
|
||||
|
||||
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
|
||||
|
||||
/// <summary>
|
||||
/// A function to convert coordinates from gamefield to screen space.
|
||||
/// </summary>
|
||||
public abstract Func<Vector2, Vector2> MapPlayfieldToScreenSpace { get; }
|
||||
protected readonly KeyConversionInputManager KeyConversionInputManager;
|
||||
|
||||
protected HitRenderer()
|
||||
{
|
||||
KeyConversionInputManager = CreateKeyConversionInputManager();
|
||||
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether all the HitObjects have been judged.
|
||||
@ -39,51 +42,48 @@ namespace osu.Game.Modes.UI
|
||||
if (AllObjectsJudged)
|
||||
OnAllJudged?.Invoke();
|
||||
}
|
||||
|
||||
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
|
||||
}
|
||||
|
||||
public abstract class HitRenderer<TObject> : HitRenderer
|
||||
where TObject : HitObject
|
||||
{
|
||||
internal readonly KeyConversionInputManager KeyConversionInputManager;
|
||||
|
||||
public override Func<Vector2, Vector2> MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace;
|
||||
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
|
||||
public Beatmap<TObject> Beatmap;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
||||
|
||||
protected Playfield<TObject> Playfield;
|
||||
protected Beatmap<TObject> Beatmap;
|
||||
|
||||
private Container content;
|
||||
|
||||
protected HitRenderer(Beatmap beatmap)
|
||||
protected HitRenderer(WorkingBeatmap beatmap)
|
||||
{
|
||||
Beatmap = CreateBeatmapConverter().Convert(beatmap);
|
||||
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
|
||||
|
||||
applyMods(beatmap.Mods.Value);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
KeyConversionInputManager = CreateKeyConversionInputManager();
|
||||
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
|
||||
KeyConversionInputManager.Add(Playfield = CreatePlayfield());
|
||||
|
||||
InputManager.Add(content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
KeyConversionInputManager
|
||||
}
|
||||
Children = new[] { KeyConversionInputManager }
|
||||
});
|
||||
|
||||
AddInternal(InputManager);
|
||||
}
|
||||
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
loadObjects();
|
||||
|
||||
if (InputManager?.ReplayInputHandler != null)
|
||||
InputManager.ReplayInputHandler.ToScreenSpace = Playfield.ScaledContent.ToScreenSpace;
|
||||
}
|
||||
|
||||
private void loadObjects()
|
||||
@ -103,11 +103,19 @@ namespace osu.Game.Modes.UI
|
||||
Playfield.PostProcess();
|
||||
}
|
||||
|
||||
private void applyMods(IEnumerable<Mod> mods)
|
||||
{
|
||||
if (mods == null)
|
||||
return;
|
||||
|
||||
foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
|
||||
mod.Apply(this);
|
||||
}
|
||||
|
||||
private void onJudgement(DrawableHitObject<TObject> o, JudgementInfo j) => TriggerOnJudgement(j);
|
||||
|
||||
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
||||
protected abstract Playfield<TObject> CreatePlayfield();
|
||||
protected abstract IBeatmapConverter<TObject> CreateBeatmapConverter();
|
||||
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user