mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:07:52 +08:00
Merge pull request #2602 from AlFasGD/mania-mask-container
Initial implementation of osu!mania editor framework
This commit is contained in:
commit
e2253d38ad
32
osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs
Normal file
32
osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestCaseEditor : EditorTestCase
|
||||||
|
{
|
||||||
|
private readonly Bindable<ManiaScrollingDirection> direction = new Bindable<ManiaScrollingDirection>();
|
||||||
|
|
||||||
|
public TestCaseEditor()
|
||||||
|
: base(new ManiaRuleset())
|
||||||
|
{
|
||||||
|
AddStep("upwards scroll", () => direction.Value = ManiaScrollingDirection.Up);
|
||||||
|
AddStep("downwards scroll", () => direction.Value = ManiaScrollingDirection.Down);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(RulesetConfigCache configCache)
|
||||||
|
{
|
||||||
|
var config = (ManiaConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
|
||||||
|
config.BindWith(ManiaSetting.ScrollDirection, direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays
|
||||||
|
{
|
||||||
|
public class HoldNoteMask : HitObjectMask
|
||||||
|
{
|
||||||
|
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
|
||||||
|
|
||||||
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
|
private readonly BodyPiece body;
|
||||||
|
|
||||||
|
public HoldNoteMask(DrawableHoldNote hold)
|
||||||
|
: base(hold)
|
||||||
|
{
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new HoldNoteNoteMask(hold.Head),
|
||||||
|
new HoldNoteNoteMask(hold.Tail),
|
||||||
|
body = new BodyPiece
|
||||||
|
{
|
||||||
|
AccentColour = Color4.Transparent
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours, IScrollingInfo scrollingInfo)
|
||||||
|
{
|
||||||
|
body.BorderColour = colours.Yellow;
|
||||||
|
|
||||||
|
direction.BindTo(scrollingInfo.Direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight);
|
||||||
|
Position = Parent.ToLocalSpace(HitObject.ScreenSpaceDrawQuad.TopLeft);
|
||||||
|
|
||||||
|
// This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
|
||||||
|
// When scrolling upwards our origin is already at the top of the head note (which is the intended location),
|
||||||
|
// but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note)
|
||||||
|
if (direction.Value == ScrollingDirection.Down)
|
||||||
|
Y -= HitObject.Tail.DrawHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class HoldNoteNoteMask : NoteMask
|
||||||
|
{
|
||||||
|
public HoldNoteNoteMask(DrawableNote note)
|
||||||
|
: base(note)
|
||||||
|
{
|
||||||
|
Select();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Anchor = HitObject.Anchor;
|
||||||
|
Origin = HitObject.Origin;
|
||||||
|
|
||||||
|
Position = HitObject.DrawPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
|
||||||
|
public override bool HandleMouseInput => false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays
|
||||||
|
{
|
||||||
|
public class NoteMask : HitObjectMask
|
||||||
|
{
|
||||||
|
public NoteMask(DrawableNote note)
|
||||||
|
: base(note)
|
||||||
|
{
|
||||||
|
Scale = note.Scale;
|
||||||
|
|
||||||
|
CornerRadius = 5;
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
AddInternal(new NotePiece());
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
Colour = colours.Yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Size = HitObject.DrawSize;
|
||||||
|
Position = Parent.ToLocalSpace(HitObject.ScreenSpaceDrawQuad.TopLeft);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
osu.Game.Rulesets.Mania/Edit/ManiaEditPlayfield.cs
Normal file
17
osu.Game.Rulesets.Mania/Edit/ManiaEditPlayfield.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit
|
||||||
|
{
|
||||||
|
public class ManiaEditPlayfield : ManiaPlayfield
|
||||||
|
{
|
||||||
|
public ManiaEditPlayfield(List<StageDefinition> stages)
|
||||||
|
: base(stages)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
osu.Game.Rulesets.Mania/Edit/ManiaEditRulesetContainer.cs
Normal file
27
osu.Game.Rulesets.Mania/Edit/ManiaEditRulesetContainer.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using OpenTK;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit
|
||||||
|
{
|
||||||
|
public class ManiaEditRulesetContainer : ManiaRulesetContainer
|
||||||
|
{
|
||||||
|
public ManiaEditRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
|
: base(ruleset, beatmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Playfield CreatePlayfield() => new ManiaEditPlayfield(Beatmap.Stages)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override Vector2 PlayfieldArea => Vector2.One;
|
||||||
|
}
|
||||||
|
}
|
56
osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs
Normal file
56
osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
|
using osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit
|
||||||
|
{
|
||||||
|
public class ManiaHitObjectComposer : HitObjectComposer
|
||||||
|
{
|
||||||
|
protected new ManiaConfigManager Config => (ManiaConfigManager)base.Config;
|
||||||
|
|
||||||
|
public ManiaHitObjectComposer(Ruleset ruleset)
|
||||||
|
: base(ruleset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
dependencies.CacheAs<IScrollingInfo>(new ManiaScrollingInfo(Config));
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => new ManiaEditRulesetContainer(ruleset, beatmap);
|
||||||
|
|
||||||
|
protected override IReadOnlyList<ICompositionTool> CompositionTools => new ICompositionTool[]
|
||||||
|
{
|
||||||
|
new HitObjectCompositionTool<Note>("Note"),
|
||||||
|
new HitObjectCompositionTool<HoldNote>("Hold"),
|
||||||
|
};
|
||||||
|
|
||||||
|
public override HitObjectMask CreateMaskFor(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case DrawableNote note:
|
||||||
|
return new NoteMask(note);
|
||||||
|
case DrawableHoldNote holdNote:
|
||||||
|
return new HoldNoteMask(holdNote);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateMaskFor(hitObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,9 +19,11 @@ using osu.Game.Configuration;
|
|||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Configuration;
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
using osu.Game.Rulesets.Mania.Difficulty;
|
using osu.Game.Rulesets.Mania.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Mania.Edit;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania
|
namespace osu.Game.Rulesets.Mania
|
||||||
@ -32,6 +34,8 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
||||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, Score score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, Score score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||||
|
|
||||||
|
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
||||||
|
|
||||||
public override IEnumerable<Mod> ConvertLegacyMods(LegacyMods mods)
|
public override IEnumerable<Mod> ConvertLegacyMods(LegacyMods mods)
|
||||||
{
|
{
|
||||||
if (mods.HasFlag(LegacyMods.Nightcore))
|
if (mods.HasFlag(LegacyMods.Nightcore))
|
||||||
|
@ -21,8 +21,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
{
|
{
|
||||||
public override bool DisplayJudgement => false;
|
public override bool DisplayJudgement => false;
|
||||||
|
|
||||||
private readonly DrawableNote head;
|
public readonly DrawableNote Head;
|
||||||
private readonly DrawableNote tail;
|
public readonly DrawableNote Tail;
|
||||||
|
|
||||||
private readonly BodyPiece bodyPiece;
|
private readonly BodyPiece bodyPiece;
|
||||||
|
|
||||||
@ -57,12 +57,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
HoldStartTime = () => holdStartTime
|
HoldStartTime = () => holdStartTime
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
head = new DrawableHeadNote(this)
|
Head = new DrawableHeadNote(this)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre
|
Origin = Anchor.TopCentre
|
||||||
},
|
},
|
||||||
tail = new DrawableTailNote(this)
|
Tail = new DrawableTailNote(this)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre
|
Origin = Anchor.TopCentre
|
||||||
@ -72,8 +72,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
foreach (var tick in tickContainer)
|
foreach (var tick in tickContainer)
|
||||||
AddNested(tick);
|
AddNested(tick);
|
||||||
|
|
||||||
AddNested(head);
|
AddNested(Head);
|
||||||
AddNested(tail);
|
AddNested(Tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDirectionChanged(ScrollingDirection direction)
|
protected override void OnDirectionChanged(ScrollingDirection direction)
|
||||||
@ -91,15 +91,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
base.AccentColour = value;
|
base.AccentColour = value;
|
||||||
|
|
||||||
bodyPiece.AccentColour = value;
|
bodyPiece.AccentColour = value;
|
||||||
head.AccentColour = value;
|
Head.AccentColour = value;
|
||||||
tail.AccentColour = value;
|
Tail.AccentColour = value;
|
||||||
tickContainer.ForEach(t => t.AccentColour = value);
|
tickContainer.ForEach(t => t.AccentColour = value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||||
{
|
{
|
||||||
if (tail.AllJudged)
|
if (Tail.AllJudged)
|
||||||
AddJudgement(new HoldNoteJudgement { Result = HitResult.Perfect });
|
AddJudgement(new HoldNoteJudgement { Result = HitResult.Perfect });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +108,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
// Make the body piece not lie under the head note
|
// Make the body piece not lie under the head note
|
||||||
bodyPiece.Y = (Direction.Value == ScrollingDirection.Up ? 1 : -1) * head.Height / 2;
|
bodyPiece.Y = (Direction.Value == ScrollingDirection.Up ? 1 : -1) * Head.Height / 2;
|
||||||
bodyPiece.Height = DrawHeight - head.Height / 2 + tail.Height / 2;
|
bodyPiece.Height = DrawHeight - Head.Height / 2 + Tail.Height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnPressed(ManiaAction action)
|
public bool OnPressed(ManiaAction action)
|
||||||
@ -141,7 +141,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
holdStartTime = null;
|
holdStartTime = null;
|
||||||
|
|
||||||
// If the key has been released too early, the user should not receive full score for the release
|
// If the key has been released too early, the user should not receive full score for the release
|
||||||
if (!tail.IsHit)
|
if (!Tail.IsHit)
|
||||||
hasBroken = true;
|
hasBroken = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,7 +8,7 @@ using osu.Game.Rulesets.Objects.Drawables;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
internal class DrawableManiaJudgement : DrawableJudgement
|
public class DrawableManiaJudgement : DrawableJudgement
|
||||||
{
|
{
|
||||||
public DrawableManiaJudgement(Judgement judgement, DrawableHitObject judgedObject)
|
public DrawableManiaJudgement(Judgement judgement, DrawableHitObject judgedObject)
|
||||||
: base(judgement, judgedObject)
|
: base(judgement, judgedObject)
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using osu.Game.Rulesets.Mania.Configuration;
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
public class ManiaPlayfield : ManiaScrollingPlayfield
|
public class ManiaPlayfield : ManiaScrollingPlayfield
|
||||||
{
|
{
|
||||||
public List<Column> Columns => stages.SelectMany(x => x.Columns).ToList();
|
|
||||||
private readonly List<ManiaStage> stages = new List<ManiaStage>();
|
private readonly List<ManiaStage> stages = new List<ManiaStage>();
|
||||||
|
|
||||||
public ManiaPlayfield(List<StageDefinition> stageDefinitions)
|
public ManiaPlayfield(List<StageDefinition> stageDefinitions)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -35,8 +34,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
public IEnumerable<BarLine> BarLines;
|
public IEnumerable<BarLine> BarLines;
|
||||||
|
|
||||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
protected new ManiaConfigManager Config => (ManiaConfigManager)base.Config;
|
||||||
private ScrollingInfo scrollingInfo;
|
|
||||||
|
|
||||||
public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
@ -73,9 +71,6 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
BarLines.ForEach(Playfield.Add);
|
BarLines.ForEach(Playfield.Add);
|
||||||
|
|
||||||
((ManiaConfigManager)Config).BindWith(ManiaSetting.ScrollDirection, configDirection);
|
|
||||||
configDirection.BindValueChanged(d => scrollingInfo.Direction.Value = (ScrollingDirection)d, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
@ -83,11 +78,14 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
dependencies.CacheAs<IScrollingInfo>(scrollingInfo = new ScrollingInfo());
|
|
||||||
|
if (dependencies.Get<ManiaScrollingInfo>() == null)
|
||||||
|
dependencies.CacheAs<IScrollingInfo>(new ManiaScrollingInfo(Config));
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)
|
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -115,11 +113,5 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
protected override Vector2 PlayfieldArea => new Vector2(1, 0.8f);
|
protected override Vector2 PlayfieldArea => new Vector2(1, 0.8f);
|
||||||
|
|
||||||
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new ManiaFramedReplayInputHandler(replay);
|
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new ManiaFramedReplayInputHandler(replay);
|
||||||
|
|
||||||
private class ScrollingInfo : IScrollingInfo
|
|
||||||
{
|
|
||||||
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
|
||||||
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
osu.Game.Rulesets.Mania/UI/ManiaScrollingInfo.cs
Normal file
23
osu.Game.Rulesets.Mania/UI/ManiaScrollingInfo.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
|
{
|
||||||
|
public class ManiaScrollingInfo : IScrollingInfo
|
||||||
|
{
|
||||||
|
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||||
|
|
||||||
|
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
||||||
|
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
|
||||||
|
|
||||||
|
public ManiaScrollingInfo(ManiaConfigManager config)
|
||||||
|
{
|
||||||
|
config.BindWith(ManiaSetting.ScrollDirection, configDirection);
|
||||||
|
configDirection.BindValueChanged(v => Direction.Value = (ScrollingDirection)v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A collection of <see cref="Column"/>s.
|
/// A collection of <see cref="Column"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class ManiaStage : ManiaScrollingPlayfield
|
public class ManiaStage : ManiaScrollingPlayfield
|
||||||
{
|
{
|
||||||
public const float HIT_TARGET_POSITION = 50;
|
public const float HIT_TARGET_POSITION = 50;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Configuration;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -23,12 +24,15 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
private readonly Ruleset ruleset;
|
private readonly Ruleset ruleset;
|
||||||
|
|
||||||
|
public IEnumerable<DrawableHitObject> HitObjects => rulesetContainer.Playfield.AllHitObjects;
|
||||||
|
|
||||||
protected ICompositionTool CurrentTool { get; private set; }
|
protected ICompositionTool CurrentTool { get; private set; }
|
||||||
|
protected IRulesetConfigManager Config { get; private set; }
|
||||||
|
|
||||||
|
private readonly List<Container> layerContainers = new List<Container>();
|
||||||
|
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||||
|
|
||||||
private RulesetContainer rulesetContainer;
|
private RulesetContainer rulesetContainer;
|
||||||
private readonly List<Container> layerContainers = new List<Container>();
|
|
||||||
|
|
||||||
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
|
||||||
|
|
||||||
protected HitObjectComposer(Ruleset ruleset)
|
protected HitObjectComposer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
@ -60,7 +64,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
};
|
};
|
||||||
|
|
||||||
var layerAboveRuleset = CreateLayerContainer();
|
var layerAboveRuleset = CreateLayerContainer();
|
||||||
layerAboveRuleset.Child = new HitObjectMaskLayer(rulesetContainer.Playfield, this);
|
layerAboveRuleset.Child = new HitObjectMaskLayer();
|
||||||
|
|
||||||
layerContainers.Add(layerBelowRuleset);
|
layerContainers.Add(layerBelowRuleset);
|
||||||
layerContainers.Add(layerAboveRuleset);
|
layerContainers.Add(layerAboveRuleset);
|
||||||
@ -110,6 +114,16 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
toolboxCollection.Items[0].Select();
|
toolboxCollection.Items[0].Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
|
dependencies.CacheAs(this);
|
||||||
|
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(ruleset);
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -8,6 +8,16 @@ namespace osu.Game.Rulesets.Edit.Tools
|
|||||||
public class HitObjectCompositionTool<T> : ICompositionTool
|
public class HitObjectCompositionTool<T> : ICompositionTool
|
||||||
where T : HitObject
|
where T : HitObject
|
||||||
{
|
{
|
||||||
public string Name => typeof(T).Name;
|
public string Name { get; }
|
||||||
|
|
||||||
|
public HitObjectCompositionTool()
|
||||||
|
: this(typeof(T).Name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public HitObjectCompositionTool(string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
@ -12,15 +15,21 @@ namespace osu.Game.Rulesets.UI
|
|||||||
public abstract class Playfield : ScalableContainer
|
public abstract class Playfield : ScalableContainer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The HitObjects contained in this Playfield.
|
/// The <see cref="DrawableHitObject"/> contained in this Playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HitObjectContainer HitObjects { get; private set; }
|
public HitObjectContainer HitObjects { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All the <see cref="Playfield"/>s nested inside this playfield.
|
/// All the <see cref="DrawableHitObject"/>s contained in this <see cref="Playfield"/> and all <see cref="NestedPlayfields"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyList<Playfield> NestedPlayfields => nestedPlayfields;
|
public IEnumerable<DrawableHitObject> AllHitObjects => HitObjects?.Objects.Concat(NestedPlayfields.SelectMany(p => p.AllHitObjects)) ?? Enumerable.Empty<DrawableHitObject>();
|
||||||
private List<Playfield> nestedPlayfields;
|
|
||||||
|
/// <summary>
|
||||||
|
/// All <see cref="Playfield"/>s nested inside this <see cref="Playfield"/>.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<Playfield> NestedPlayfields => nestedPlayfields.IsValueCreated ? nestedPlayfields.Value : Enumerable.Empty<Playfield>();
|
||||||
|
|
||||||
|
private readonly Lazy<List<Playfield>> nestedPlayfields = new Lazy<List<Playfield>>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether judgements should be displayed by this and and all nested <see cref="Playfield"/>s.
|
/// Whether judgements should be displayed by this and and all nested <see cref="Playfield"/>s.
|
||||||
@ -54,7 +63,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield.
|
/// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void PostProcess() => nestedPlayfields?.ForEach(p => p.PostProcess());
|
public virtual void PostProcess() => NestedPlayfields.ForEach(p => p.PostProcess());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a DrawableHitObject to this Playfield.
|
/// Adds a DrawableHitObject to this Playfield.
|
||||||
@ -75,12 +84,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <param name="otherPlayfield">The <see cref="Playfield"/> to add.</param>
|
/// <param name="otherPlayfield">The <see cref="Playfield"/> to add.</param>
|
||||||
protected void AddNested(Playfield otherPlayfield)
|
protected void AddNested(Playfield otherPlayfield)
|
||||||
{
|
{
|
||||||
if (nestedPlayfields == null)
|
|
||||||
nestedPlayfields = new List<Playfield>();
|
|
||||||
|
|
||||||
nestedPlayfields.Add(otherPlayfield);
|
|
||||||
|
|
||||||
otherPlayfield.DisplayJudgements.BindTo(DisplayJudgements);
|
otherPlayfield.DisplayJudgements.BindTo(DisplayJudgements);
|
||||||
|
nestedPlayfields.Value.Add(otherPlayfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -9,30 +8,24 @@ using osu.Framework.Input.EventArgs;
|
|||||||
using osu.Framework.Input.States;
|
using osu.Framework.Input.States;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||||
{
|
{
|
||||||
public class HitObjectMaskLayer : CompositeDrawable
|
public class HitObjectMaskLayer : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly Playfield playfield;
|
|
||||||
private readonly HitObjectComposer composer;
|
|
||||||
|
|
||||||
private MaskContainer maskContainer;
|
private MaskContainer maskContainer;
|
||||||
|
private HitObjectComposer composer;
|
||||||
|
|
||||||
public HitObjectMaskLayer(Playfield playfield, HitObjectComposer composer)
|
public HitObjectMaskLayer()
|
||||||
{
|
{
|
||||||
// we need the playfield as HitObjects may not be initialised until its BDL.
|
|
||||||
this.playfield = playfield;
|
|
||||||
|
|
||||||
this.composer = composer;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(HitObjectComposer composer)
|
||||||
{
|
{
|
||||||
|
this.composer = composer;
|
||||||
|
|
||||||
maskContainer = new MaskContainer();
|
maskContainer = new MaskContainer();
|
||||||
|
|
||||||
var maskSelection = composer.CreateMaskSelection();
|
var maskSelection = composer.CreateMaskSelection();
|
||||||
@ -55,7 +48,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
|||||||
dragLayer.CreateProxy()
|
dragLayer.CreateProxy()
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var obj in playfield.HitObjects.Objects)
|
foreach (var obj in composer.HitObjects)
|
||||||
addMask(obj);
|
addMask(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,18 +70,5 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
|||||||
|
|
||||||
maskContainer.Add(mask);
|
maskContainer.Add(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Removes the mask for a <see cref="DrawableHitObject"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to remove the mask for.</param>
|
|
||||||
private void removeMask(DrawableHitObject hitObject)
|
|
||||||
{
|
|
||||||
var mask = maskContainer.FirstOrDefault(h => h.HitObject == hitObject);
|
|
||||||
if (mask == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
maskContainer.Remove(mask);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user