1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 14:43:22 +08:00

Editor problem solved

This commit is contained in:
Nikita-str 2024-12-27 04:44:24 +03:00
parent c145cff5a0
commit 7deccd1136
5 changed files with 39 additions and 6 deletions

View File

@ -3,6 +3,9 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; 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.Rulesets.Taiko.UI;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -20,6 +23,20 @@ namespace osu.Game.Rulesets.Taiko.Edit
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
Origin = Anchor.TopRight, 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;
}
} }
} }
} }

View File

@ -71,14 +71,15 @@ namespace osu.Game.Rulesets.Taiko.Edit
public void SetRimState(bool state) public void SetRimState(bool state)
{ {
if (SelectedItems.OfType<Hit>().All(h => h.Type == (state ? HitType.Rim : HitType.Centre))) var expectedType = state ? HitType.Rim : HitType.Centre;
if (SelectedItems.OfType<Hit>().All(h => h.Type == expectedType))
return; return;
EditorBeatmap.PerformOnSelection(h => 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); EditorBeatmap.Update(h);
} }
}); });

View File

@ -40,15 +40,18 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private readonly Bindable<HitType> type = new Bindable<HitType>(); private readonly Bindable<HitType> type = new Bindable<HitType>();
private readonly bool editorMode = false;
public DrawableHit() public DrawableHit()
: this(null) : this(null)
{ {
} }
public DrawableHit([CanBeNull] Hit hit) public DrawableHit([CanBeNull] Hit hit, bool editorMode = false)
: base(hit) : base(hit)
{ {
FillMode = FillMode.Fit; FillMode = FillMode.Fit;
this.editorMode = editorMode;
} }
protected override void OnApply() protected override void OnApply()
@ -62,6 +65,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
protected override void RestorePieceState() 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(); updateActionsFromType();
Size = new Vector2(HitObject.IsStrong ? TaikoStrongableHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE); Size = new Vector2(HitObject.IsStrong ? TaikoStrongableHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE);
} }

View File

@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// <summary> /// <summary>
/// Moves <see cref="Content"/> to the normal hitobject layer. /// Moves <see cref="Content"/> to the normal hitobject layer.
/// Does nothing is content is not currently proxied. /// Does nothing if content is not currently proxied.
/// </summary> /// </summary>
protected void UnproxyContent() protected void UnproxyContent()
{ {

View File

@ -12,6 +12,12 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
private readonly HitType hitType; private readonly HitType hitType;
private readonly bool isStrong; 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) public HitPool(int initialSize, HitType hitType, bool isStrong)
: base(initialSize) : base(initialSize)
@ -20,6 +26,6 @@ namespace osu.Game.Rulesets.Taiko.UI
this.isStrong = isStrong; this.isStrong = isStrong;
} }
protected override DrawableHit CreateNewDrawable() => new DrawableHit(new Hit(hitType, isStrong)); protected override DrawableHit CreateNewDrawable() => new DrawableHit(new Hit(hitType, isStrong), editorMode);
} }
} }