1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Implement toolbox into HitObjectComposer

This commit is contained in:
smoogipoo 2017-11-30 16:58:14 +09:00
parent 73e41f9dde
commit 456bbe25f3
8 changed files with 126 additions and 3 deletions

View File

@ -1,6 +1,10 @@
// 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.Collections.Generic;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit
{
public class OsuHitObjectComposer : Rulesets.Edit.HitObjectComposer
@ -9,5 +13,12 @@ namespace osu.Game.Rulesets.Osu.Edit
: base(ruleset)
{
}
protected override IReadOnlyList<ICompositionTool> CompositionTools => new ICompositionTool[]
{
new HitObjectCompositionTool<HitCircle>(),
new HitObjectCompositionTool<Slider>(),
new HitObjectCompositionTool<Spinner>()
};
}
}

View File

@ -1,9 +1,20 @@
// 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 System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Framework.Timing;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons;
using osu.Game.Screens.Play.ReplaySettings;
namespace osu.Game.Rulesets.Edit
{
@ -21,11 +32,63 @@ namespace osu.Game.Rulesets.Edit
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
{
RulesetContainer rulesetContainer;
try
{
InternalChild = ruleset.CreateRulesetContainerWith(osuGame.Beatmap.Value, true);
}
catch { }
rulesetContainer = ruleset.CreateRulesetContainerWith(osuGame.Beatmap.Value, true);
}
catch (Exception e)
{
Logger.Log($"Could not load this beatmap sucessfully ({e})!", LoggingTarget.Runtime, LogLevel.Error);
return;
}
RadioButtonCollection toolboxCollection;
InternalChild = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Content = new[]
{
new Drawable[]
{
new FillFlowContainer
{
Name = "Sidebar",
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Right = 10 },
Children = new Drawable[]
{
new ToolboxGroup { Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X } }
}
},
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Child = rulesetContainer
}
},
},
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, 200),
}
};
rulesetContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)osuGame.Beatmap.Value.Track ?? new StopwatchClock());
toolboxCollection.Items =
new[] { new RadioButton("Select", () => setCompositionTool(new SelectionTool())) }
.Concat(
CompositionTools.Select(t => new RadioButton(t.Name, () => setCompositionTool(t)))
)
.ToList();
}
private void setCompositionTool(ICompositionTool tool)
{
}
protected abstract IReadOnlyList<ICompositionTool> CompositionTools { get; }
}
}

View File

@ -0,0 +1,19 @@
// 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.Graphics;
using osu.Game.Screens.Play.ReplaySettings;
namespace osu.Game.Rulesets.Edit
{
public class ToolboxGroup : ReplayGroup
{
protected override string Title => "toolbox";
public ToolboxGroup()
{
RelativeSizeAxes = Axes.X;
Width = 1;
}
}
}

View File

@ -0,0 +1,10 @@
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Edit.Tools
{
public class HitObjectCompositionTool<T> : ICompositionTool
where T : HitObject
{
public string Name => typeof(T).Name;
}
}

View File

@ -0,0 +1,10 @@
// 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.Edit.Tools
{
public interface ICompositionTool
{
string Name { get; }
}
}

View File

@ -0,0 +1,7 @@
namespace osu.Game.Rulesets.Edit.Tools
{
public class SelectionTool : ICompositionTool
{
public string Name => "Select";
}
}

View File

@ -94,7 +94,6 @@ namespace osu.Game.Screens.Edit.Screens.Compose
}
composerContainer.Child = composer;
composerContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)newBeatmap.Track ?? new StopwatchClock());
}
}
}

View File

@ -562,7 +562,11 @@
<Compile Include="Overlays\UserProfileOverlay.cs" />
<Compile Include="Overlays\WaveOverlayContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rulesets\Edit\Tools\HitObjectCompositionTool.cs" />
<Compile Include="Rulesets\Edit\Tools\ICompositionTool.cs" />
<Compile Include="Rulesets\Edit\Tools\SelectionTool.cs" />
<Compile Include="Rulesets\Edit\HitObjectComposer.cs" />
<Compile Include="Rulesets\Edit\ToolboxGroup.cs" />
<Compile Include="Rulesets\Judgements\DrawableJudgement.cs" />
<Compile Include="Rulesets\Judgements\Judgement.cs" />
<Compile Include="Rulesets\Mods\IApplicableToClock.cs" />