1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:53:23 +08:00

Integrate HitObjectComposer into Compose

Also removes the other rulesets' HitObjectComposers for now.
This commit is contained in:
smoogipoo 2017-11-29 17:46:12 +09:00
parent f586cbac32
commit 309eb4edd7
12 changed files with 58 additions and 38 deletions

View File

@ -1,10 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Rulesets.Catch.Edit
{
public class HitObjectComposer : Rulesets.Edit.HitObjectComposer
{
}
}

View File

@ -48,7 +48,6 @@
<ItemGroup>
<Compile Include="Beatmaps\CatchBeatmapConverter.cs" />
<Compile Include="Beatmaps\CatchBeatmapProcessor.cs" />
<Compile Include="Edit\HitObjectComposer.cs" />
<Compile Include="CatchDifficultyCalculator.cs" />
<Compile Include="CatchInputManager.cs" />
<Compile Include="Objects\Drawable\DrawableCatchHitObject.cs" />

View File

@ -1,10 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Rulesets.Mania.Edit
{
public class HitObjectComposer : Rulesets.Edit.HitObjectComposer
{
}
}

View File

@ -53,7 +53,6 @@
<Compile Include="Beatmaps\Patterns\Legacy\PatternType.cs" />
<Compile Include="Beatmaps\ManiaBeatmapConverter.cs" />
<Compile Include="Beatmaps\Patterns\Pattern.cs" />
<Compile Include="Edit\HitObjectComposer.cs" />
<Compile Include="MathUtils\FastRandom.cs" />
<Compile Include="Judgements\HitWindows.cs" />
<Compile Include="Judgements\HoldNoteTailJudgement.cs" />

View File

@ -3,8 +3,11 @@
namespace osu.Game.Rulesets.Osu.Edit
{
public class HitObjectComposer : Rulesets.Edit.HitObjectComposer
public class OsuHitObjectComposer : Rulesets.Edit.HitObjectComposer
{
public OsuHitObjectComposer(Ruleset ruleset)
: base(ruleset)
{
}
}
}

View File

@ -14,6 +14,8 @@ using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Overlays.Settings;
using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Edit;
namespace osu.Game.Rulesets.Osu
{
@ -114,6 +116,8 @@ namespace osu.Game.Rulesets.Osu
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new OsuDifficultyCalculator(beatmap, mods);
public override HitObjectComposer CreateHitObjectComposer() => new OsuHitObjectComposer(this);
public override string Description => "osu!";
public override SettingsSubsection CreateSettings() => new OsuSettings();

View File

@ -49,7 +49,7 @@
<ItemGroup>
<Compile Include="Beatmaps\OsuBeatmapConverter.cs" />
<Compile Include="Beatmaps\OsuBeatmapProcessor.cs" />
<Compile Include="Edit\HitObjectComposer.cs" />
<Compile Include="Edit\OsuHitObjectComposer.cs" />
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
<Compile Include="Objects\Drawables\Connections\ConnectionRenderer.cs" />
<Compile Include="Objects\Drawables\Connections\FollowPointRenderer.cs" />

View File

@ -1,10 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Rulesets.Taiko.Edit
{
public class HitObjectComposer : Rulesets.Edit.HitObjectComposer
{
}
}

View File

@ -46,7 +46,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Beatmaps\TaikoBeatmapConverter.cs" />
<Compile Include="Edit\HitObjectComposer.cs" />
<Compile Include="Judgements\TaikoDrumRollTickJudgement.cs" />
<Compile Include="Judgements\TaikoStrongHitJudgement.cs" />
<Compile Include="Judgements\TaikoJudgement.cs" />

View File

@ -1,10 +1,31 @@
// Copyright (c) 2007-2017 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.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Rulesets.Edit
{
public class HitObjectComposer
public abstract class HitObjectComposer : CompositeDrawable
{
private readonly Ruleset ruleset;
public HitObjectComposer(Ruleset ruleset)
{
this.ruleset = ruleset;
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
{
try
{
InternalChild = ruleset.CreateRulesetContainerWith(osuGame.Beatmap.Value, true);
}
catch { }
}
}
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
@ -49,6 +50,8 @@ namespace osu.Game.Rulesets
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null);
public virtual HitObjectComposer CreateHitObjectComposer() => null;
public virtual Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_question_circle };
public abstract string Description { get; }

View File

@ -1,11 +1,14 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Screens.Edit.Screens.Compose.Timeline;
namespace osu.Game.Screens.Edit.Screens.Compose
@ -15,6 +18,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose
private const float vertical_margins = 10;
private const float horizontal_margins = 20;
private readonly Container composerContainer;
public Compose()
{
ScrollableTimeline timeline;
@ -58,7 +63,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose
},
new Drawable[]
{
new Container
composerContainer = new Container
{
Name = "Composer content",
RelativeSizeAxes = Axes.Both,
@ -71,6 +76,23 @@ namespace osu.Game.Screens.Edit.Screens.Compose
};
timeline.Beatmap.BindTo(Beatmap);
Beatmap.ValueChanged += beatmapChanged;
}
private void beatmapChanged(WorkingBeatmap newBeatmap)
{
var ruleset = newBeatmap.BeatmapInfo.Ruleset.CreateInstance();
var composer = ruleset.CreateHitObjectComposer();
if (composer == null)
{
// Todo: Handle this
//throw new InvalidOperationException($"Ruleset {ruleset.Description} doesn't support hitobject composition.");
return;
}
composerContainer.Add(composer);
composerContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)newBeatmap.Track ?? new StopwatchClock());
}
}
}