mirror of
https://github.com/ppy/osu.git
synced 2025-02-07 20:52:56 +08:00
Simplify caching
This commit is contained in:
parent
b91461e661
commit
c574551ee0
@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
Composer.Alpha = 0;
|
||||
|
||||
var contextMenuContainer = new OsuContextMenuContainer
|
||||
Add(new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
@ -75,11 +75,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Dependencies.Cache(contextMenuContainer);
|
||||
|
||||
Add(contextMenuContainer);
|
||||
});
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
|
@ -8,6 +8,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
[Cached(typeof(OsuContextMenuContainer))]
|
||||
public partial class OsuContextMenuContainer : ContextMenuContainer
|
||||
{
|
||||
[Cached]
|
||||
|
@ -101,12 +101,6 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
[Resolved]
|
||||
private IDialogOverlay? dialogOverlay { get; set; }
|
||||
|
||||
[Cached]
|
||||
public OsuContextMenuContainer ContextMenuContainer { get; private set; } = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
|
||||
public SkinEditor()
|
||||
{
|
||||
}
|
||||
@ -121,7 +115,10 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
ContextMenuContainer.Child = new GridContainer
|
||||
AddInternal(new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
@ -222,9 +219,8 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
AddInternal(ContextMenuContainer);
|
||||
}
|
||||
});
|
||||
|
||||
clipboardContent = clipboard.Content.GetBoundCopy();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework;
|
||||
@ -76,12 +77,6 @@ namespace osu.Game.Screens.Edit
|
||||
/// </remarks>
|
||||
public const float WAVEFORM_VISUAL_OFFSET = 20;
|
||||
|
||||
[Cached]
|
||||
public OsuContextMenuContainer ContextMenuContainer { get; private set; } = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
|
||||
public override float BackgroundParallaxAmount => 0.1f;
|
||||
|
||||
public override bool AllowBackButton => false;
|
||||
@ -165,7 +160,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
private string lastSavedHash;
|
||||
|
||||
private Container<EditorScreen> screenContainer;
|
||||
private ScreenContainer screenContainer;
|
||||
|
||||
[CanBeNull]
|
||||
private readonly EditorLoader loader;
|
||||
@ -325,14 +320,17 @@ namespace osu.Game.Screens.Edit
|
||||
editorTimelineShowTimingChanges = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
|
||||
editorTimelineShowTicks = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
|
||||
|
||||
ContextMenuContainer.AddRange(new Drawable[]
|
||||
AddInternal(new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Name = "Screen container",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = 40, Bottom = 50 },
|
||||
Child = screenContainer = new Container<EditorScreen>
|
||||
Child = screenContainer = new ScreenContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
@ -423,10 +421,9 @@ namespace osu.Game.Screens.Edit
|
||||
},
|
||||
bottomBar = new BottomBar(),
|
||||
MutationTracker,
|
||||
}
|
||||
});
|
||||
|
||||
AddInternal(ContextMenuContainer);
|
||||
|
||||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||
|
||||
@ -1012,7 +1009,7 @@ namespace osu.Game.Screens.Edit
|
||||
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode");
|
||||
}
|
||||
|
||||
LoadComponentAsync(currentScreen, newScreen =>
|
||||
screenContainer.LoadComponentAsync(currentScreen, newScreen =>
|
||||
{
|
||||
if (newScreen == currentScreen)
|
||||
{
|
||||
@ -1390,5 +1387,12 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private partial class ScreenContainer : Container<EditorScreen>
|
||||
{
|
||||
public new Task LoadComponentAsync<TLoadable>([NotNull] TLoadable component, Action<TLoadable> onLoaded = null, CancellationToken cancellation = default, Scheduler scheduler = null)
|
||||
where TLoadable : Drawable
|
||||
=> base.LoadComponentAsync(component, onLoaded, cancellation, scheduler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user