From 8c30fd490c373492e219bead97d5ae9fc7e57bf9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Nov 2017 16:22:11 +0900 Subject: [PATCH 01/27] Add HitObjectComposer class --- osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs | 10 ++++++++++ osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj | 1 + osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs | 10 ++++++++++ osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 1 + osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs | 10 ++++++++++ osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj | 1 + osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs | 10 ++++++++++ osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj | 1 + osu.Game/Rulesets/Edit/HitObjectComposer.cs | 10 ++++++++++ osu.Game/osu.Game.csproj | 1 + 10 files changed, 55 insertions(+) create mode 100644 osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs create mode 100644 osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs create mode 100644 osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs create mode 100644 osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs create mode 100644 osu.Game/Rulesets/Edit/HitObjectComposer.cs diff --git a/osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs new file mode 100644 index 0000000000..01351fd00c --- /dev/null +++ b/osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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 + { + + } +} diff --git a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj index bf60bc01bb..30c088ac85 100644 --- a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj +++ b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj @@ -48,6 +48,7 @@ + diff --git a/osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs new file mode 100644 index 0000000000..aa0d43dc75 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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 + { + + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 6f45a64d92..1470ee57b1 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -53,6 +53,7 @@ + diff --git a/osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs new file mode 100644 index 0000000000..921fb72fdf --- /dev/null +++ b/osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Osu.Edit +{ + public class HitObjectComposer : Rulesets.Edit.HitObjectComposer + { + + } +} diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 3c90749777..32a0a34ff2 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -49,6 +49,7 @@ + diff --git a/osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs new file mode 100644 index 0000000000..e524b4cdc7 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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 + { + + } +} diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index bf627d205a..41881fc250 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -46,6 +46,7 @@ + diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs new file mode 100644 index 0000000000..2724334ed4 --- /dev/null +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Edit +{ + public class HitObjectComposer + { + + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ce9e8eff9c..b707a3382e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -559,6 +559,7 @@ + From 2ec24f58c8e5c30e9c3cd681f55869f971b4f80e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Nov 2017 16:30:59 +0900 Subject: [PATCH 02/27] Add testcase for editor compose --- .../Visual/TestCaseEditorCompose.cs | 47 +++++++++++++++++++ osu.Game.Tests/osu.Game.Tests.csproj | 1 + 2 files changed, 48 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseEditorCompose.cs diff --git a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs new file mode 100644 index 0000000000..9f060a9ec4 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs @@ -0,0 +1,47 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Screens.Edit.Screens.Compose; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseEditorCompose : OsuTestCase + { + private readonly Random random; + private readonly Compose compose; + + public TestCaseEditorCompose() + { + random = new Random(1337); + + Add(compose = new Compose()); + AddStep("Next beatmap", nextBeatmap); + } + + private OsuGameBase osuGame; + private BeatmapManager beatmaps; + + [BackgroundDependencyLoader] + private void load(OsuGameBase osuGame, BeatmapManager beatmaps) + { + this.osuGame = osuGame; + this.beatmaps = beatmaps; + + compose.Beatmap.BindTo(osuGame.Beatmap); + nextBeatmap(); + } + + private void nextBeatmap() + { + var sets = beatmaps.GetAllUsableBeatmapSets(); + if (sets.Count == 0) + return; + + var b = sets[random.Next(0, sets.Count)].Beatmaps[0]; + osuGame.Beatmap.Value = beatmaps.GetWorkingBeatmap(b); + } + } +} diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 312a564f71..34f79987c5 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -105,6 +105,7 @@ + From f586cbac3285e2b2a8e8586276bd660e9736ddb0 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Nov 2017 16:47:36 +0900 Subject: [PATCH 03/27] Restructure Compose to use grids and eventually support HitObjectContainer --- .../Screens/Edit/Screens/Compose/Compose.cs | 66 ++++++++++++------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index 2349c261cf..67e66eecdf 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -12,40 +12,62 @@ namespace osu.Game.Screens.Edit.Screens.Compose { public class Compose : EditorScreen { + private const float vertical_margins = 10; + private const float horizontal_margins = 20; + public Compose() { ScrollableTimeline timeline; - Children = new[] + Children = new Drawable[] { - new Container + new GridContainer { - Name = "Timeline", - RelativeSizeAxes = Axes.X, - Height = 110, - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + Content = new[] { - new Box + new Drawable[] { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.5f) - }, - new Container - { - Name = "Content", - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = 17, Vertical = 10 }, - Children = new Drawable[] + new Container { - new Container + Name = "Timeline", + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Right = 115 }, - Child = timeline = new ScrollableTimeline { RelativeSizeAxes = Axes.Both } + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f) + }, + new Container + { + Name = "Timeline content", + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = horizontal_margins, Vertical = vertical_margins }, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Right = 115 }, + Child = timeline = new ScrollableTimeline { RelativeSizeAxes = Axes.Both } + } + } + } } } + }, + new Drawable[] + { + new Container + { + Name = "Composer content", + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = horizontal_margins, Vertical = vertical_margins }, + } } - } - } + }, + RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, 110) } + }, }; timeline.Beatmap.BindTo(Beatmap); From 309eb4edd752b95d108770f2df55f6efdcd6ac2c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Nov 2017 17:46:12 +0900 Subject: [PATCH 04/27] Integrate HitObjectComposer into Compose Also removes the other rulesets' HitObjectComposers for now. --- .../Edit/HitObjectComposer.cs | 10 -------- .../osu.Game.Rulesets.Catch.csproj | 1 - .../Edit/HitObjectComposer.cs | 10 -------- .../osu.Game.Rulesets.Mania.csproj | 1 - ...ectComposer.cs => OsuHitObjectComposer.cs} | 7 ++++-- osu.Game.Rulesets.Osu/OsuRuleset.cs | 4 ++++ .../osu.Game.Rulesets.Osu.csproj | 2 +- .../Edit/HitObjectComposer.cs | 10 -------- .../osu.Game.Rulesets.Taiko.csproj | 1 - osu.Game/Rulesets/Edit/HitObjectComposer.cs | 23 +++++++++++++++++- osu.Game/Rulesets/Ruleset.cs | 3 +++ .../Screens/Edit/Screens/Compose/Compose.cs | 24 ++++++++++++++++++- 12 files changed, 58 insertions(+), 38 deletions(-) delete mode 100644 osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs delete mode 100644 osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs rename osu.Game.Rulesets.Osu/Edit/{HitObjectComposer.cs => OsuHitObjectComposer.cs} (52%) delete mode 100644 osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs diff --git a/osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs deleted file mode 100644 index 01351fd00c..0000000000 --- a/osu.Game.Rulesets.Catch/Edit/HitObjectComposer.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// 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 - { - - } -} diff --git a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj index 30c088ac85..bf60bc01bb 100644 --- a/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj +++ b/osu.Game.Rulesets.Catch/osu.Game.Rulesets.Catch.csproj @@ -48,7 +48,6 @@ - diff --git a/osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs deleted file mode 100644 index aa0d43dc75..0000000000 --- a/osu.Game.Rulesets.Mania/Edit/HitObjectComposer.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// 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 - { - - } -} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 1470ee57b1..6f45a64d92 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -53,7 +53,6 @@ - diff --git a/osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs similarity index 52% rename from osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs rename to osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 921fb72fdf..18dfbb6711 100644 --- a/osu.Game.Rulesets.Osu/Edit/HitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -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) + { + } } } diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index c87328d87c..64e76d6022 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -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(); diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 32a0a34ff2..34f9bdf972 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -49,7 +49,7 @@ - + diff --git a/osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs b/osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs deleted file mode 100644 index e524b4cdc7..0000000000 --- a/osu.Game.Rulesets.Taiko/Edit/HitObjectComposer.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// 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 - { - - } -} diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index 41881fc250..bf627d205a 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -46,7 +46,6 @@ - diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 2724334ed4..da31f6ba66 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -1,10 +1,31 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // 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 { } + } } } diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index ed2fdf4157..dfa9ea5125 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -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; } diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index 67e66eecdf..8cfb04da06 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -1,11 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // 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()); } } } From ee35422efc0396ec7800933ae4e2e51abfb45140 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Nov 2017 18:38:12 +0900 Subject: [PATCH 05/27] Handle rulesets that don't support composition a bit better --- osu.Game/Screens/Edit/Editor.cs | 1 + osu.Game/Screens/Edit/Screens/Compose/Compose.cs | 10 +++++----- osu.Game/Screens/Edit/Screens/EditorScreen.cs | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 607ff792d8..bc86c683c7 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -154,6 +154,7 @@ namespace osu.Game.Screens.Edit } currentScreen.Beatmap.BindTo(Beatmap); + currentScreen.ExitRequested = Exit; screenContainer.Add(currentScreen); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index 8cfb04da06..6954995340 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -7,6 +7,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Logging; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Screens.Edit.Screens.Compose.Timeline; @@ -76,18 +77,17 @@ 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(); + 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."); + Logger.Log($"Ruleset {ruleset.Description} doesn't support hitobject composition."); + ExitRequested?.Invoke(); return; } diff --git a/osu.Game/Screens/Edit/Screens/EditorScreen.cs b/osu.Game/Screens/Edit/Screens/EditorScreen.cs index ac248930d8..9a158d20f1 100644 --- a/osu.Game/Screens/Edit/Screens/EditorScreen.cs +++ b/osu.Game/Screens/Edit/Screens/EditorScreen.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -10,6 +11,8 @@ namespace osu.Game.Screens.Edit.Screens { public class EditorScreen : Container { + public Action ExitRequested; + public readonly Bindable Beatmap = new Bindable(); protected override Container Content => content; From a7a9569aee3c4f8e9adfdfb754d39f2a47aa656b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 13:53:57 +0900 Subject: [PATCH 06/27] Don't exit when we don't have composer for now --- osu.Game/Screens/Edit/Screens/Compose/Compose.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index 6954995340..fea439bfb8 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -87,7 +87,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose if (composer == null) { Logger.Log($"Ruleset {ruleset.Description} doesn't support hitobject composition."); - ExitRequested?.Invoke(); + // ExitRequested?.Invoke(); return; } From abd61256911a9ff7e52cc5390895ec3c9e226fd1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 14:00:17 +0900 Subject: [PATCH 07/27] Make sure that composerContainer is cleared for testing purposes --- osu.Game/Screens/Edit/Screens/Compose/Compose.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index fea439bfb8..7e4ce74c5c 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -82,6 +82,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose private void beatmapChanged(WorkingBeatmap newBeatmap) { + composerContainer.Clear(); + var ruleset = newBeatmap.BeatmapInfo.Ruleset?.CreateInstance(); var composer = ruleset?.CreateHitObjectComposer(); if (composer == null) @@ -91,7 +93,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose return; } - composerContainer.Add(composer); + composerContainer.Child = composer; composerContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)newBeatmap.Track ?? new StopwatchClock()); } } From ead745697875d10bb96fd786c72cbf2e074bac41 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 15:43:19 +0900 Subject: [PATCH 08/27] Add compose radio buttons + testcase --- .../TestCaseEditorComposeRadioButtons.cs | 34 ++++++ osu.Game.Tests/osu.Game.Tests.csproj | 1 + .../RadioButtons/DrawableRadioButton.cs | 107 ++++++++++++++++++ .../Compose/RadioButtons/RadioButton.cs | 20 ++++ .../RadioButtons/RadioButtonCollection.cs | 48 ++++++++ osu.Game/osu.Game.csproj | 5 +- 6 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs create mode 100644 osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs create mode 100644 osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs create mode 100644 osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs diff --git a/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs new file mode 100644 index 0000000000..55ceac6fd8 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs @@ -0,0 +1,34 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseEditorComposeRadioButtons : OsuTestCase + { + public override IReadOnlyList RequiredTypes => new[] { typeof(DrawableRadioButton) }; + + public TestCaseEditorComposeRadioButtons() + { + Add(new RadioButtonCollection + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 150, + Items = new[] + { + new RadioButton { Text = "Item 1", Action = () => { } }, + new RadioButton { Text = "Item 2", Action = () => { } }, + new RadioButton { Text = "Item 3", Action = () => { } }, + new RadioButton { Text = "Item 4", Action = () => { } }, + new RadioButton { Text = "Item 5", Action = () => { } } + } + }); + } + } +} diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 34f79987c5..ae88fb004f 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -106,6 +106,7 @@ + diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs new file mode 100644 index 0000000000..4ac36cc07e --- /dev/null +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs @@ -0,0 +1,107 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons +{ + public class DrawableRadioButton : TriangleButton + { + private static readonly Color4 DefaultBackgroundColour = OsuColour.FromHex("333"); + private static readonly Color4 DefaultBubbleColour = DefaultBackgroundColour.Darken(0.5f); + private static readonly Color4 SelectedBackgroundColour = OsuColour.FromHex("1188aa"); + private static readonly Color4 SelectedBubbleColour = SelectedBackgroundColour.Lighten(0.5f); + + /// + /// Invoked when this has been selected. + /// + public Action Selected; + + private Drawable bubble; + + public DrawableRadioButton(RadioButton button) + { + Text = button.Text; + Action = button.Action; + + RelativeSizeAxes = Axes.X; + } + + [BackgroundDependencyLoader] + private void load() + { + Triangles.Alpha = 0; + BackgroundColour = DefaultBackgroundColour; + + Add(bubble = new CircularContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fit, + Scale = new Vector2(0.5f), + X = 10, + Masking = true, + Colour = DefaultBubbleColour, + Blending = BlendingMode.Additive, + Child = new Box { RelativeSizeAxes = Axes.Both } + }); + } + + private bool isSelected; + + public void Deselect() + { + if (!isSelected) + return; + isSelected = false; + + BackgroundColour = DefaultBackgroundColour; + bubble.Colour = DefaultBubbleColour; + } + + public void Select() + { + if (isSelected) + return; + isSelected = true; + Selected?.Invoke(this); + + BackgroundColour = SelectedBackgroundColour; + bubble.Colour = SelectedBubbleColour; + } + + protected override bool OnClick(InputState state) + { + if (isSelected) + return true; + + if (!Enabled) + return true; + + Select(); + + return base.OnClick(state); + } + + protected override SpriteText CreateText() => new OsuSpriteText + { + Depth = -1, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + X = 40f + }; + } +} diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs new file mode 100644 index 0000000000..3ef89d2a2b --- /dev/null +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs @@ -0,0 +1,20 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; + +namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons +{ + public class RadioButton + { + /// + /// The text that should be displayed in this button. + /// + public string Text; + + /// + /// The that should be invoked when this button is selected. + /// + public Action Action; + } +} diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs new file mode 100644 index 0000000000..557e8e1ee8 --- /dev/null +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs @@ -0,0 +1,48 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons +{ + public class RadioButtonCollection : CompositeDrawable + { + public IReadOnlyList Items + { + set + { + buttonContainer.Clear(); + value.ForEach(addButton); + } + } + + private readonly FlowContainer buttonContainer; + + public RadioButtonCollection() + { + AutoSizeAxes = Axes.Y; + + InternalChild = buttonContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 5) + }; + } + + private void addButton(RadioButton button) => buttonContainer.Add(new DrawableRadioButton(button) { Selected = buttonSelected }); + + private DrawableRadioButton currentlySelected; + private void buttonSelected(DrawableRadioButton drawableButton) + { + currentlySelected?.Deselect(); + currentlySelected = drawableButton; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b4ab8a4cf2..1064665a0e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -306,7 +306,6 @@ - @@ -316,6 +315,10 @@ + + + + From 73e41f9dded5128bb4df51efc5ffc74e107828fe Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 16:57:30 +0900 Subject: [PATCH 09/27] Add constructors to RadioButton --- .../Visual/TestCaseEditorComposeRadioButtons.cs | 10 +++++----- .../Screens/Compose/RadioButtons/RadioButton.cs | 14 +++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs index 55ceac6fd8..c259ca666e 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs @@ -22,11 +22,11 @@ namespace osu.Game.Tests.Visual Width = 150, Items = new[] { - new RadioButton { Text = "Item 1", Action = () => { } }, - new RadioButton { Text = "Item 2", Action = () => { } }, - new RadioButton { Text = "Item 3", Action = () => { } }, - new RadioButton { Text = "Item 4", Action = () => { } }, - new RadioButton { Text = "Item 5", Action = () => { } } + new RadioButton("Item 1", () => { }), + new RadioButton("Item 2", () => { }), + new RadioButton("Item 3", () => { }), + new RadioButton("Item 4", () => { }), + new RadioButton("Item 5", () => { }) } }); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs index 3ef89d2a2b..bec2d1903d 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs @@ -5,7 +5,7 @@ using System; namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons { - public class RadioButton + public struct RadioButton { /// /// The text that should be displayed in this button. @@ -16,5 +16,17 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons /// The that should be invoked when this button is selected. /// public Action Action; + + public RadioButton(string text) + { + Text = text; + Action = null; + } + + public RadioButton(string text, Action action) + { + Text = text; + Action = action; + } } } From 456bbe25f38e34253cf77b9057e20022add7e9e5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 16:58:14 +0900 Subject: [PATCH 10/27] Implement toolbox into HitObjectComposer --- .../Edit/OsuHitObjectComposer.cs | 11 +++ osu.Game/Rulesets/Edit/HitObjectComposer.cs | 67 ++++++++++++++++++- osu.Game/Rulesets/Edit/ToolboxGroup.cs | 19 ++++++ .../Edit/Tools/HitObjectCompositionTool.cs | 10 +++ .../Rulesets/Edit/Tools/ICompositionTool.cs | 10 +++ osu.Game/Rulesets/Edit/Tools/SelectionTool.cs | 7 ++ .../Screens/Edit/Screens/Compose/Compose.cs | 1 - osu.Game/osu.Game.csproj | 4 ++ 8 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Rulesets/Edit/ToolboxGroup.cs create mode 100644 osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs create mode 100644 osu.Game/Rulesets/Edit/Tools/ICompositionTool.cs create mode 100644 osu.Game/Rulesets/Edit/Tools/SelectionTool.cs diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 18dfbb6711..851e572163 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -1,6 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // 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 CompositionTools => new ICompositionTool[] + { + new HitObjectCompositionTool(), + new HitObjectCompositionTool(), + new HitObjectCompositionTool() + }; } } diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index da31f6ba66..8c4969cec5 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -1,9 +1,20 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // 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); + rulesetContainer = ruleset.CreateRulesetContainerWith(osuGame.Beatmap.Value, true); } - catch { } + 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 CompositionTools { get; } } } diff --git a/osu.Game/Rulesets/Edit/ToolboxGroup.cs b/osu.Game/Rulesets/Edit/ToolboxGroup.cs new file mode 100644 index 0000000000..70e4d3a0c5 --- /dev/null +++ b/osu.Game/Rulesets/Edit/ToolboxGroup.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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; + } + } +} diff --git a/osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs b/osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs new file mode 100644 index 0000000000..914cbd11ca --- /dev/null +++ b/osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs @@ -0,0 +1,10 @@ +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Edit.Tools +{ + public class HitObjectCompositionTool : ICompositionTool + where T : HitObject + { + public string Name => typeof(T).Name; + } +} diff --git a/osu.Game/Rulesets/Edit/Tools/ICompositionTool.cs b/osu.Game/Rulesets/Edit/Tools/ICompositionTool.cs new file mode 100644 index 0000000000..eba873f0cf --- /dev/null +++ b/osu.Game/Rulesets/Edit/Tools/ICompositionTool.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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; } + } +} diff --git a/osu.Game/Rulesets/Edit/Tools/SelectionTool.cs b/osu.Game/Rulesets/Edit/Tools/SelectionTool.cs new file mode 100644 index 0000000000..9f3ef78a02 --- /dev/null +++ b/osu.Game/Rulesets/Edit/Tools/SelectionTool.cs @@ -0,0 +1,7 @@ +namespace osu.Game.Rulesets.Edit.Tools +{ + public class SelectionTool : ICompositionTool + { + public string Name => "Select"; + } +} diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index 7e4ce74c5c..5eeaf3205d 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -94,7 +94,6 @@ namespace osu.Game.Screens.Edit.Screens.Compose } composerContainer.Child = composer; - composerContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)newBeatmap.Track ?? new StopwatchClock()); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1064665a0e..886d3313c6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -562,7 +562,11 @@ + + + + From e5353bb53e2a898a523c542854b6911ed30687ea Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 17:38:55 +0900 Subject: [PATCH 11/27] Add border to playfield, add shadow to toolbox buttons --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 15 ++++++++++++++- .../Compose/RadioButtons/DrawableRadioButton.cs | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 8c4969cec5..ed057dbb03 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -4,10 +4,12 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Logging; using osu.Framework.Timing; using osu.Game.Rulesets.Edit.Tools; @@ -65,7 +67,18 @@ namespace osu.Game.Rulesets.Edit { RelativeSizeAxes = Axes.Both, Masking = true, - Child = rulesetContainer + BorderColour = Color4.White, + BorderThickness = 2, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true, + }, + rulesetContainer + } } }, }, diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs index 4ac36cc07e..690a50bb11 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs @@ -45,6 +45,14 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons Triangles.Alpha = 0; BackgroundColour = DefaultBackgroundColour; + Content.EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Radius = 2, + Offset = new Vector2(0, 1), + Colour = Color4.Black.Opacity(0.5f) + }; + Add(bubble = new CircularContainer { Anchor = Anchor.CentreLeft, From 33adf569a4d825ac3ffd90d251785ada52ec4b5c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 17:39:06 +0900 Subject: [PATCH 12/27] Don't select a new beatmap in load() --- osu.Game.Tests/Visual/TestCaseEditorCompose.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs index 9f060a9ec4..d52f27f4ab 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs @@ -31,7 +31,6 @@ namespace osu.Game.Tests.Visual this.beatmaps = beatmaps; compose.Beatmap.BindTo(osuGame.Beatmap); - nextBeatmap(); } private void nextBeatmap() From efa39f38ca1fbd03ad880f010670111f6a7f52f2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 18:48:00 +0900 Subject: [PATCH 13/27] CI fixes --- .../Edit/OsuHitObjectComposer.cs | 3 ++- .../TestCaseEditorComposeRadioButtons.cs | 1 - osu.Game/Rulesets/Edit/HitObjectComposer.cs | 5 +---- .../Screens/Edit/Screens/Compose/Compose.cs | 11 +++++++--- .../RadioButtons/DrawableRadioButton.cs | 20 +++++++++---------- .../RadioButtons/RadioButtonCollection.cs | 1 - 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 851e572163..8a919e0178 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -2,12 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Osu.Objects; namespace osu.Game.Rulesets.Osu.Edit { - public class OsuHitObjectComposer : Rulesets.Edit.HitObjectComposer + public class OsuHitObjectComposer : HitObjectComposer { public OsuHitObjectComposer(Ruleset ruleset) : base(ruleset) diff --git a/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs index c259ca666e..8c2a07b536 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; -using osu.Framework.Graphics.UserInterface; using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; namespace osu.Game.Tests.Visual diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index ed057dbb03..9297c82ba4 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -6,17 +6,14 @@ using System.Collections.Generic; using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; 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 { @@ -24,7 +21,7 @@ namespace osu.Game.Rulesets.Edit { private readonly Ruleset ruleset; - public HitObjectComposer(Ruleset ruleset) + protected HitObjectComposer(Ruleset ruleset) { this.ruleset = ruleset; diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index 5eeaf3205d..6bc7356f26 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -1,14 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // 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.Logging; -using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Screens.Edit.Screens.Compose.Timeline; @@ -85,7 +83,14 @@ namespace osu.Game.Screens.Edit.Screens.Compose composerContainer.Clear(); var ruleset = newBeatmap.BeatmapInfo.Ruleset?.CreateInstance(); - var composer = ruleset?.CreateHitObjectComposer(); + if (ruleset == null) + { + Logger.Log("Beatmap doesn't have a ruleset assigned."); + // ExitRequested?.Invoke(); + return; + } + + var composer = ruleset.CreateHitObjectComposer(); if (composer == null) { Logger.Log($"Ruleset {ruleset.Description} doesn't support hitobject composition."); diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs index 690a50bb11..b3c9983db9 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs @@ -19,10 +19,10 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons { public class DrawableRadioButton : TriangleButton { - private static readonly Color4 DefaultBackgroundColour = OsuColour.FromHex("333"); - private static readonly Color4 DefaultBubbleColour = DefaultBackgroundColour.Darken(0.5f); - private static readonly Color4 SelectedBackgroundColour = OsuColour.FromHex("1188aa"); - private static readonly Color4 SelectedBubbleColour = SelectedBackgroundColour.Lighten(0.5f); + private static readonly Color4 default_background_colour = OsuColour.FromHex("333"); + private static readonly Color4 default_bubble_colour = default_background_colour.Darken(0.5f); + private static readonly Color4 selected_background_colour = OsuColour.FromHex("1188aa"); + private static readonly Color4 selected_bubble_colour = selected_background_colour.Lighten(0.5f); /// /// Invoked when this has been selected. @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons private void load() { Triangles.Alpha = 0; - BackgroundColour = DefaultBackgroundColour; + BackgroundColour = default_background_colour; Content.EdgeEffect = new EdgeEffectParameters { @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons Scale = new Vector2(0.5f), X = 10, Masking = true, - Colour = DefaultBubbleColour, + Colour = default_bubble_colour, Blending = BlendingMode.Additive, Child = new Box { RelativeSizeAxes = Axes.Both } }); @@ -76,8 +76,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons return; isSelected = false; - BackgroundColour = DefaultBackgroundColour; - bubble.Colour = DefaultBubbleColour; + BackgroundColour = default_background_colour; + bubble.Colour = default_bubble_colour; } public void Select() @@ -87,8 +87,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons isSelected = true; Selected?.Invoke(this); - BackgroundColour = SelectedBackgroundColour; - bubble.Colour = SelectedBubbleColour; + BackgroundColour = selected_background_colour; + bubble.Colour = selected_bubble_colour; } protected override bool OnClick(InputState state) diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs index 557e8e1ee8..8a3194b72e 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using System.Linq; using OpenTK; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; From 677f3653eb04ed29b7c99f7c21079691ccc6ce67 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 19:19:34 +0900 Subject: [PATCH 14/27] Hide osu! playfield cursor --- .../Edit/OsuEditPlayfield.cs | 13 +++++++++++++ .../Edit/OsuEditRulesetContainer.cs | 19 +++++++++++++++++++ .../Edit/OsuHitObjectComposer.cs | 4 ++++ osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 8 +++++++- .../osu.Game.Rulesets.Osu.csproj | 2 ++ osu.Game/Rulesets/Edit/HitObjectComposer.cs | 5 ++++- 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs create mode 100644 osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs diff --git a/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs b/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs new file mode 100644 index 0000000000..d5fc1b606b --- /dev/null +++ b/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Cursor; +using osu.Game.Rulesets.Osu.UI; + +namespace osu.Game.Rulesets.Osu.Edit +{ + public class OsuEditPlayfield : OsuPlayfield + { + protected override CursorContainer CreateCursor() => null; + } +} diff --git a/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs new file mode 100644 index 0000000000..1e9e4b4686 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Osu.UI; +using osu.Game.Rulesets.UI; + +namespace osu.Game.Rulesets.Osu.Edit +{ + public class OsuEditRulesetContainer : OsuRulesetContainer + { + public OsuEditRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset) + : base(ruleset, beatmap, isForCurrentRuleset) + { + } + + protected override Playfield CreatePlayfield() => new OsuEditPlayfield(); + } +} diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 8a919e0178..ec3aa4661c 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -2,9 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.Edit { @@ -15,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Edit { } + protected override RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => new OsuEditRulesetContainer(ruleset, beatmap, true); + protected override IReadOnlyList CompositionTools => new ICompositionTool[] { new HitObjectCompositionTool(), diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 89f6a4e255..387a098a5a 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -13,6 +13,7 @@ using System.Linq; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.UI.Cursor; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Rulesets.Osu.UI { @@ -65,7 +66,10 @@ namespace osu.Game.Rulesets.Osu.UI protected override void LoadComplete() { base.LoadComplete(); - AddInternal(new GameplayCursor()); + + var cursor = CreateCursor(); + if (cursor != null) + AddInternal(cursor); } public override void Add(DrawableHitObject h) @@ -102,5 +106,7 @@ namespace osu.Game.Rulesets.Osu.UI judgementLayer.Add(explosion); } + + protected virtual CursorContainer CreateCursor() => new GameplayCursor(); } } diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index c527265c40..bc343ece05 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -49,6 +49,8 @@ + + diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 9297c82ba4..1e47ea4e63 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Logging; using osu.Framework.Timing; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.UI; using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; @@ -34,7 +35,7 @@ namespace osu.Game.Rulesets.Edit RulesetContainer rulesetContainer; try { - rulesetContainer = ruleset.CreateRulesetContainerWith(osuGame.Beatmap.Value, true); + rulesetContainer = CreateRulesetContainer(ruleset, osuGame.Beatmap.Value); } catch (Exception e) { @@ -99,6 +100,8 @@ namespace osu.Game.Rulesets.Edit { } + protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true); + protected abstract IReadOnlyList CompositionTools { get; } } } From e9cbef88f17021032a5cce26d6a616b4648c5a6b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 19:49:55 +0900 Subject: [PATCH 15/27] Improve selection/deselection behaviour of RadioButtonCollections --- .../TestCaseEditorComposeRadioButtons.cs | 10 ++- .../RadioButtons/DrawableRadioButton.cs | 72 ++++++++++--------- .../Compose/RadioButtons/RadioButton.cs | 31 ++++++-- .../RadioButtons/RadioButtonCollection.cs | 26 +++++-- 4 files changed, 93 insertions(+), 46 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs index 8c2a07b536..f8669cde4b 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorComposeRadioButtons.cs @@ -14,7 +14,8 @@ namespace osu.Game.Tests.Visual public TestCaseEditorComposeRadioButtons() { - Add(new RadioButtonCollection + RadioButtonCollection collection; + Add(collection = new RadioButtonCollection { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -28,6 +29,13 @@ namespace osu.Game.Tests.Visual new RadioButton("Item 5", () => { }) } }); + + for (int i = 0; i < collection.Items.Count; i++) + { + int l = i; + AddStep($"Select item {l + 1}", () => collection.Items[l].Select()); + AddStep($"Deselect item {l + 1}", () => collection.Items[l].Deselect()); + } } } } diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs index b3c9983db9..a6c0f48f1f 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs @@ -27,16 +27,34 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons /// /// Invoked when this has been selected. /// - public Action Selected; + public Action Selected; private Drawable bubble; + private readonly RadioButton button; + public DrawableRadioButton(RadioButton button) { + this.button = button; + Text = button.Text; Action = button.Action; RelativeSizeAxes = Axes.X; + + bubble = new CircularContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fit, + Scale = new Vector2(0.5f), + X = 10, + Masking = true, + Colour = default_bubble_colour, + Blending = BlendingMode.Additive, + Child = new Box { RelativeSizeAxes = Axes.Both } + }; } [BackgroundDependencyLoader] @@ -53,53 +71,41 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons Colour = Color4.Black.Opacity(0.5f) }; - Add(bubble = new CircularContainer + Add(bubble); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + button.Selected.ValueChanged += v => { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fit, - Scale = new Vector2(0.5f), - X = 10, - Masking = true, - Colour = default_bubble_colour, - Blending = BlendingMode.Additive, - Child = new Box { RelativeSizeAxes = Axes.Both } - }); + updateSelectionState(); + if (v) + Selected?.Invoke(button); + }; + + updateSelectionState(); } - private bool isSelected; - - public void Deselect() + private void updateSelectionState() { - if (!isSelected) + if (!IsLoaded) return; - isSelected = false; - BackgroundColour = default_background_colour; - bubble.Colour = default_bubble_colour; - } - - public void Select() - { - if (isSelected) - return; - isSelected = true; - Selected?.Invoke(this); - - BackgroundColour = selected_background_colour; - bubble.Colour = selected_bubble_colour; + BackgroundColour = button.Selected ? selected_background_colour : default_background_colour; + bubble.Colour = button.Selected ? selected_bubble_colour : default_bubble_colour; } protected override bool OnClick(InputState state) { - if (isSelected) + if (button.Selected) return true; if (!Enabled) return true; - Select(); + button.Selected.Value = true; return base.OnClick(state); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs index bec2d1903d..055362d9e1 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButton.cs @@ -2,11 +2,18 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Configuration; namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons { - public struct RadioButton + public class RadioButton { + /// + /// Whether this is selected. + /// + /// + public readonly BindableBool Selected; + /// /// The text that should be displayed in this button. /// @@ -17,16 +24,28 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons /// public Action Action; + public RadioButton(string text, Action action) + { + Text = text; + Action = action; + Selected = new BindableBool(); + } + public RadioButton(string text) + : this(text, null) { Text = text; Action = null; } - public RadioButton(string text, Action action) - { - Text = text; - Action = action; - } + /// + /// Selects this . + /// + public void Select() => Selected.Value = true; + + /// + /// Deselects this . + /// + public void Deselect() => Selected.Value = false; } } diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs index 8a3194b72e..ad24a1da52 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs @@ -11,10 +11,16 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons { public class RadioButtonCollection : CompositeDrawable { + private IReadOnlyList items; public IReadOnlyList Items { + get { return items; } set { + if (items == value) + return; + items = value; + buttonContainer.Clear(); value.ForEach(addButton); } @@ -35,13 +41,21 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons }; } - private void addButton(RadioButton button) => buttonContainer.Add(new DrawableRadioButton(button) { Selected = buttonSelected }); - - private DrawableRadioButton currentlySelected; - private void buttonSelected(DrawableRadioButton drawableButton) + private RadioButton currentlySelected; + private void addButton(RadioButton button) { - currentlySelected?.Deselect(); - currentlySelected = drawableButton; + button.Selected.ValueChanged += v => + { + if (v) + { + currentlySelected?.Deselect(); + currentlySelected = button; + } + else + currentlySelected = null; + }; + + buttonContainer.Add(new DrawableRadioButton(button)); } } } From 7e34b0f08dcc504b81833487530111117eada6c9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 19:53:52 +0900 Subject: [PATCH 16/27] Remove SelectionTool, make Select the default tool --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 4 +++- osu.Game/Rulesets/Edit/Tools/SelectionTool.cs | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 osu.Game/Rulesets/Edit/Tools/SelectionTool.cs diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 1e47ea4e63..b06af84ec8 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -89,11 +89,13 @@ namespace osu.Game.Rulesets.Edit rulesetContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)osuGame.Beatmap.Value.Track ?? new StopwatchClock()); toolboxCollection.Items = - new[] { new RadioButton("Select", () => setCompositionTool(new SelectionTool())) } + new[] { new RadioButton("Select", () => setCompositionTool(null)) } .Concat( CompositionTools.Select(t => new RadioButton(t.Name, () => setCompositionTool(t))) ) .ToList(); + + toolboxCollection.Items[0].Select(); } private void setCompositionTool(ICompositionTool tool) diff --git a/osu.Game/Rulesets/Edit/Tools/SelectionTool.cs b/osu.Game/Rulesets/Edit/Tools/SelectionTool.cs deleted file mode 100644 index 9f3ef78a02..0000000000 --- a/osu.Game/Rulesets/Edit/Tools/SelectionTool.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace osu.Game.Rulesets.Edit.Tools -{ - public class SelectionTool : ICompositionTool - { - public string Name => "Select"; - } -} From 89772f4efd889836f60480ba3de93cd73598caf9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 19:54:58 +0900 Subject: [PATCH 17/27] A few resharper fixes --- .../Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs | 3 +-- .../Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs | 2 +- osu.Game/osu.Game.csproj | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs index a6c0f48f1f..48cc7f3379 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs @@ -29,8 +29,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons /// public Action Selected; - private Drawable bubble; - + private readonly Drawable bubble; private readonly RadioButton button; public DrawableRadioButton(RadioButton button) diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs index ad24a1da52..08473eaeba 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs @@ -17,7 +17,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons get { return items; } set { - if (items == value) + if (ReferenceEquals(items, value)) return; items = value; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 886d3313c6..e1425ff8b8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -564,7 +564,6 @@ - From e8cbde3ae18746e0b96f17e6ddea0114590085b0 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 21:56:12 +0900 Subject: [PATCH 18/27] Add overlay/underlay --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 14 ++++++++---- osu.Game/Rulesets/Edit/PlayfieldOverlay.cs | 24 +++++++++++++++++++++ osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs | 21 ++++++++++++++++++ osu.Game/Rulesets/UI/RulesetContainer.cs | 10 ++++----- osu.Game/osu.Game.csproj | 2 ++ 5 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 osu.Game/Rulesets/Edit/PlayfieldOverlay.cs create mode 100644 osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index b06af84ec8..3aa633115b 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -22,6 +22,8 @@ namespace osu.Game.Rulesets.Edit { private readonly Ruleset ruleset; + protected ICompositionTool CurrentTool { get; private set; } + protected HitObjectComposer(Ruleset ruleset) { this.ruleset = ruleset; @@ -75,7 +77,9 @@ namespace osu.Game.Rulesets.Edit Alpha = 0, AlwaysPresent = true, }, - rulesetContainer + CreateUnderlay(rulesetContainer.Playfield), + rulesetContainer, + CreateOverlay(rulesetContainer.Playfield) } } }, @@ -98,12 +102,14 @@ namespace osu.Game.Rulesets.Edit toolboxCollection.Items[0].Select(); } - private void setCompositionTool(ICompositionTool tool) - { - } + private void setCompositionTool(ICompositionTool tool) => CurrentTool = tool; protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true); + protected virtual PlayfieldUnderlay CreateUnderlay(Playfield playfield) => new PlayfieldUnderlay(playfield); + + protected virtual PlayfieldOverlay CreateOverlay(Playfield playfield) => new PlayfieldOverlay(playfield); + protected abstract IReadOnlyList CompositionTools { get; } } } diff --git a/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs b/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs new file mode 100644 index 0000000000..2138079784 --- /dev/null +++ b/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs @@ -0,0 +1,24 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.UI; + +namespace osu.Game.Rulesets.Edit +{ + public class PlayfieldOverlay : CompositeDrawable + { + + private Playfield playfield; + + public PlayfieldOverlay(Playfield playfield) + { + this.playfield = playfield; + + RelativeSizeAxes = Axes.Both; + + } + + } +} diff --git a/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs b/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs new file mode 100644 index 0000000000..7a18c59613 --- /dev/null +++ b/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.UI; + +namespace osu.Game.Rulesets.Edit +{ + public class PlayfieldUnderlay : CompositeDrawable + { + private readonly Playfield playfield; + + public PlayfieldUnderlay(Playfield playfield) + { + this.playfield = playfield; + + RelativeSizeAxes = Axes.Both; + } + } +} diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index ec26f6f310..69bf6bba29 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -55,6 +55,11 @@ namespace osu.Game.Rulesets.UI public abstract IEnumerable Objects { get; } + /// + /// The playfield. + /// + public Playfield Playfield { get; protected set; } + protected readonly Ruleset Ruleset; /// @@ -135,11 +140,6 @@ namespace osu.Game.Rulesets.UI public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(this); - /// - /// The playfield. - /// - public Playfield Playfield { get; private set; } - protected override Container Content => content; private Container content; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index e1425ff8b8..ad1370890f 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -302,6 +302,8 @@ + + From c0c051aa32166fc378e7d13051ecfd932cc04cc7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 21:58:41 +0900 Subject: [PATCH 19/27] Remove unused parameter for now --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 4 ++-- osu.Game/Rulesets/Edit/PlayfieldOverlay.cs | 9 ++------- osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs | 7 +------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 3aa633115b..f55b7b0531 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -106,9 +106,9 @@ namespace osu.Game.Rulesets.Edit protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true); - protected virtual PlayfieldUnderlay CreateUnderlay(Playfield playfield) => new PlayfieldUnderlay(playfield); + protected virtual PlayfieldUnderlay CreateUnderlay(Playfield playfield) => new PlayfieldUnderlay(); - protected virtual PlayfieldOverlay CreateOverlay(Playfield playfield) => new PlayfieldOverlay(playfield); + protected virtual PlayfieldOverlay CreateOverlay(Playfield playfield) => new PlayfieldOverlay(); protected abstract IReadOnlyList CompositionTools { get; } } diff --git a/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs b/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs index 2138079784..4f5658e39c 100644 --- a/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs +++ b/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs @@ -3,22 +3,17 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Edit { public class PlayfieldOverlay : CompositeDrawable { - - private Playfield playfield; - - public PlayfieldOverlay(Playfield playfield) + public PlayfieldOverlay() { - this.playfield = playfield; - RelativeSizeAxes = Axes.Both; } + } } diff --git a/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs b/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs index 7a18c59613..e9198c71c6 100644 --- a/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs +++ b/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs @@ -3,18 +3,13 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Edit { public class PlayfieldUnderlay : CompositeDrawable { - private readonly Playfield playfield; - - public PlayfieldUnderlay(Playfield playfield) + public PlayfieldUnderlay() { - this.playfield = playfield; - RelativeSizeAxes = Axes.Both; } } From 52ba68e25dd1fb873608d548507b7f4cd7945445 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Nov 2017 22:21:02 +0900 Subject: [PATCH 20/27] Add/fix up license headers --- osu.Game/Rulesets/Edit/PlayfieldOverlay.cs | 2 +- osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs | 2 +- osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs b/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs index 4f5658e39c..58b15e3de2 100644 --- a/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs +++ b/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs b/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs index e9198c71c6..bace5258f8 100644 --- a/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs +++ b/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs b/osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs index 914cbd11ca..dd182dcbdb 100644 --- a/osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs +++ b/osu.Game/Rulesets/Edit/Tools/HitObjectCompositionTool.cs @@ -1,3 +1,6 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Edit.Tools From 5a7c4772bd57453466f9cc2f3599f54b7882ce22 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 2 Dec 2017 19:53:11 +0900 Subject: [PATCH 21/27] Remove PlayfieldUnderlay for now --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 3 --- osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs | 16 ---------------- osu.Game/osu.Game.csproj | 1 - 3 files changed, 20 deletions(-) delete mode 100644 osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index f55b7b0531..767e8ade46 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -77,7 +77,6 @@ namespace osu.Game.Rulesets.Edit Alpha = 0, AlwaysPresent = true, }, - CreateUnderlay(rulesetContainer.Playfield), rulesetContainer, CreateOverlay(rulesetContainer.Playfield) } @@ -106,8 +105,6 @@ namespace osu.Game.Rulesets.Edit protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true); - protected virtual PlayfieldUnderlay CreateUnderlay(Playfield playfield) => new PlayfieldUnderlay(); - protected virtual PlayfieldOverlay CreateOverlay(Playfield playfield) => new PlayfieldOverlay(); protected abstract IReadOnlyList CompositionTools { get; } diff --git a/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs b/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs deleted file mode 100644 index bace5258f8..0000000000 --- a/osu.Game/Rulesets/Edit/PlayfieldUnderlay.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Rulesets.Edit -{ - public class PlayfieldUnderlay : CompositeDrawable - { - public PlayfieldUnderlay() - { - RelativeSizeAxes = Axes.Both; - } - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ad1370890f..ee5834890f 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -303,7 +303,6 @@ - From a80059032cdc94a37a83b78fd86b4466be095c61 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 2 Dec 2017 20:24:10 +0900 Subject: [PATCH 22/27] Remove PlayfieldOverlay --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 5 +---- osu.Game/Rulesets/Edit/PlayfieldOverlay.cs | 19 ------------------- osu.Game/osu.Game.csproj | 1 - 3 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 osu.Game/Rulesets/Edit/PlayfieldOverlay.cs diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 767e8ade46..3184b84e98 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -77,8 +77,7 @@ namespace osu.Game.Rulesets.Edit Alpha = 0, AlwaysPresent = true, }, - rulesetContainer, - CreateOverlay(rulesetContainer.Playfield) + rulesetContainer } } }, @@ -105,8 +104,6 @@ namespace osu.Game.Rulesets.Edit protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true); - protected virtual PlayfieldOverlay CreateOverlay(Playfield playfield) => new PlayfieldOverlay(); - protected abstract IReadOnlyList CompositionTools { get; } } } diff --git a/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs b/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs deleted file mode 100644 index 58b15e3de2..0000000000 --- a/osu.Game/Rulesets/Edit/PlayfieldOverlay.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Rulesets.Edit -{ - public class PlayfieldOverlay : CompositeDrawable - { - public PlayfieldOverlay() - { - RelativeSizeAxes = Axes.Both; - - } - - - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ee5834890f..e1425ff8b8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -302,7 +302,6 @@ - From c14d68e685143e00f8d37a2c1bc3d4f9d883378e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 2 Dec 2017 20:30:18 +0900 Subject: [PATCH 23/27] Use OsuColour for radio buttons --- .../RadioButtons/DrawableRadioButton.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs index 48cc7f3379..10b6c07f3d 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/DrawableRadioButton.cs @@ -19,16 +19,16 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons { public class DrawableRadioButton : TriangleButton { - private static readonly Color4 default_background_colour = OsuColour.FromHex("333"); - private static readonly Color4 default_bubble_colour = default_background_colour.Darken(0.5f); - private static readonly Color4 selected_background_colour = OsuColour.FromHex("1188aa"); - private static readonly Color4 selected_bubble_colour = selected_background_colour.Lighten(0.5f); - /// /// Invoked when this has been selected. /// public Action Selected; + private Color4 defaultBackgroundColour; + private Color4 defaultBubbleColour; + private Color4 selectedBackgroundColour; + private Color4 selectedBubbleColour; + private readonly Drawable bubble; private readonly RadioButton button; @@ -50,17 +50,20 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons Scale = new Vector2(0.5f), X = 10, Masking = true, - Colour = default_bubble_colour, Blending = BlendingMode.Additive, Child = new Box { RelativeSizeAxes = Axes.Both } }; } [BackgroundDependencyLoader] - private void load() + private void load(OsuColour colours) { + defaultBackgroundColour = colours.Gray3; + defaultBubbleColour = defaultBackgroundColour.Darken(0.5f); + selectedBackgroundColour = colours.BlueDark; + selectedBubbleColour = selectedBackgroundColour.Lighten(0.5f); + Triangles.Alpha = 0; - BackgroundColour = default_background_colour; Content.EdgeEffect = new EdgeEffectParameters { @@ -92,8 +95,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons if (!IsLoaded) return; - BackgroundColour = button.Selected ? selected_background_colour : default_background_colour; - bubble.Colour = button.Selected ? selected_bubble_colour : default_bubble_colour; + BackgroundColour = button.Selected ? selectedBackgroundColour : defaultBackgroundColour; + bubble.Colour = button.Selected ? selectedBubbleColour : defaultBubbleColour; } protected override bool OnClick(InputState state) From cd20d6df160b1b4617b4f8035dc31ee52063588f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 2 Dec 2017 20:31:10 +0900 Subject: [PATCH 24/27] Apply suggested changes --- osu.Game/Screens/Edit/Editor.cs | 1 - .../Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs | 2 +- osu.Game/Screens/Edit/Screens/EditorScreen.cs | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index bc86c683c7..607ff792d8 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -154,7 +154,6 @@ namespace osu.Game.Screens.Edit } currentScreen.Beatmap.BindTo(Beatmap); - currentScreen.ExitRequested = Exit; screenContainer.Add(currentScreen); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs index 08473eaeba..5f1def4a2e 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/RadioButtons/RadioButtonCollection.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons items = value; buttonContainer.Clear(); - value.ForEach(addButton); + items.ForEach(addButton); } } diff --git a/osu.Game/Screens/Edit/Screens/EditorScreen.cs b/osu.Game/Screens/Edit/Screens/EditorScreen.cs index 9a158d20f1..773975d493 100644 --- a/osu.Game/Screens/Edit/Screens/EditorScreen.cs +++ b/osu.Game/Screens/Edit/Screens/EditorScreen.cs @@ -11,8 +11,6 @@ namespace osu.Game.Screens.Edit.Screens { public class EditorScreen : Container { - public Action ExitRequested; - public readonly Bindable Beatmap = new Bindable(); protected override Container Content => content; From 2852337b04c0160a6b52e5376acdf73e09af4fd8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 2 Dec 2017 20:35:47 +0900 Subject: [PATCH 25/27] Remove unused using --- osu.Game/Screens/Edit/Screens/EditorScreen.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Screens/EditorScreen.cs b/osu.Game/Screens/Edit/Screens/EditorScreen.cs index 773975d493..ac248930d8 100644 --- a/osu.Game/Screens/Edit/Screens/EditorScreen.cs +++ b/osu.Game/Screens/Edit/Screens/EditorScreen.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From 5f9de399e40d6748a14657fa97da77aa3f916323 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 4 Dec 2017 11:30:25 +0900 Subject: [PATCH 26/27] Add keydown override --- osu.Game/Screens/OsuScreen.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 76ee4a607e..4a27c7f1ea 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -13,6 +13,8 @@ using osu.Framework.Audio; using osu.Framework.Graphics; using osu.Game.Rulesets; using osu.Game.Screens.Menu; +using osu.Framework.Input; +using OpenTK.Input; namespace osu.Game.Screens { @@ -73,6 +75,20 @@ namespace osu.Game.Screens sampleExit = audio.Sample.Get(@"UI/screen-back"); } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Repeat || !IsCurrentScreen) return false; + + switch (args.Key) + { + case Key.Escape: + Exit(); + return true; + } + + return base.OnKeyDown(state, args); + } + protected override void OnResuming(Screen last) { base.OnResuming(last); From 7cfe694a3fd63ac1dd54caddcb87bce80f09e8cb Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 4 Dec 2017 11:37:19 +0900 Subject: [PATCH 27/27] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index cc013fc406..8c16e6244d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cc013fc4063dda0843f38c1c73568a413abcf229 +Subproject commit 8c16e6244d8ca884a743a0d5a1f1ee485f18655c