From 7deccd113606dceee3a3dbdce2db772d61bfa879 Mon Sep 17 00:00:00 2001 From: Nikita-str Date: Fri, 27 Dec 2024 04:44:24 +0300 Subject: [PATCH] Editor problem solved --- .../Edit/TaikoEditorPlayfield.cs | 17 +++++++++++++++++ .../Edit/TaikoSelectionHandler.cs | 7 ++++--- .../Objects/Drawables/DrawableHit.cs | 11 ++++++++++- .../Objects/Drawables/DrawableTaikoHitObject.cs | 2 +- osu.Game.Rulesets.Taiko/UI/HitPool.cs | 8 +++++++- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs b/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs index 760ed71662..c1b5e3c3ac 100644 --- a/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs @@ -3,6 +3,9 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Pooling; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.UI; using osu.Game.Skinning; @@ -20,6 +23,20 @@ namespace osu.Game.Rulesets.Taiko.Edit Anchor = Anchor.TopLeft, Origin = Anchor.TopRight, }); + + AddRangeInternal([poolHitEditorMode]); + } + + private readonly HitPool poolHitEditorMode = new HitPool(50, editorMode: true); + + protected override IDrawablePool? AdditionalPrepareDrawablePool(HitObject hitObject) + { + switch (hitObject) + { + // We should to return the editor pool, and suppress non-editor pools. + case Hit: return poolHitEditorMode; + default: return null; + } } } } diff --git a/osu.Game.Rulesets.Taiko/Edit/TaikoSelectionHandler.cs b/osu.Game.Rulesets.Taiko/Edit/TaikoSelectionHandler.cs index be2a5ac144..3c58b6e00d 100644 --- a/osu.Game.Rulesets.Taiko/Edit/TaikoSelectionHandler.cs +++ b/osu.Game.Rulesets.Taiko/Edit/TaikoSelectionHandler.cs @@ -71,14 +71,15 @@ namespace osu.Game.Rulesets.Taiko.Edit public void SetRimState(bool state) { - if (SelectedItems.OfType().All(h => h.Type == (state ? HitType.Rim : HitType.Centre))) + var expectedType = state ? HitType.Rim : HitType.Centre; + if (SelectedItems.OfType().All(h => h.Type == expectedType)) return; EditorBeatmap.PerformOnSelection(h => { - if (h is Hit taikoHit) + if (h is Hit taikoHit && taikoHit.Type != expectedType) { - taikoHit.Type = state ? HitType.Rim : HitType.Centre; + taikoHit.Type = expectedType; EditorBeatmap.Update(h); } }); diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs index b9522b9f67..2343919ff3 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs @@ -40,15 +40,18 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables private readonly Bindable type = new Bindable(); + private readonly bool editorMode = false; + public DrawableHit() : this(null) { } - public DrawableHit([CanBeNull] Hit hit) + public DrawableHit([CanBeNull] Hit hit, bool editorMode = false) : base(hit) { FillMode = FillMode.Fit; + this.editorMode = editorMode; } protected override void OnApply() @@ -62,6 +65,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables protected override void RestorePieceState() { + if (editorMode) + { + // We in Editor Mode so the performance is not critical and we can recreate piece. + if (MainPiece != null) Content.Remove(MainPiece, true); + Content.Add(MainPiece = OnLoadCreateMainPiece()); + } updateActionsFromType(); Size = new Vector2(HitObject.IsStrong ? TaikoStrongableHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE); } diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs index e5fd1838a1..b132a52ba2 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables /// /// Moves to the normal hitobject layer. - /// Does nothing is content is not currently proxied. + /// Does nothing if content is not currently proxied. /// protected void UnproxyContent() { diff --git a/osu.Game.Rulesets.Taiko/UI/HitPool.cs b/osu.Game.Rulesets.Taiko/UI/HitPool.cs index 5ccb1633f0..8e526ebb3a 100644 --- a/osu.Game.Rulesets.Taiko/UI/HitPool.cs +++ b/osu.Game.Rulesets.Taiko/UI/HitPool.cs @@ -12,6 +12,12 @@ namespace osu.Game.Rulesets.Taiko.UI { private readonly HitType hitType; private readonly bool isStrong; + private readonly bool editorMode = false; + + public HitPool(int initialSize, bool editorMode) : base(initialSize) + { + this.editorMode = editorMode; + } public HitPool(int initialSize, HitType hitType, bool isStrong) : base(initialSize) @@ -20,6 +26,6 @@ namespace osu.Game.Rulesets.Taiko.UI this.isStrong = isStrong; } - protected override DrawableHit CreateNewDrawable() => new DrawableHit(new Hit(hitType, isStrong)); + protected override DrawableHit CreateNewDrawable() => new DrawableHit(new Hit(hitType, isStrong), editorMode); } }