mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 22:22:55 +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;
|
Composer.Alpha = 0;
|
||||||
|
|
||||||
var contextMenuContainer = new OsuContextMenuContainer
|
Add(new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -75,11 +75,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
Dependencies.Cache(contextMenuContainer);
|
|
||||||
|
|
||||||
Add(contextMenuContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
|
@ -8,6 +8,7 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.Cursor
|
namespace osu.Game.Graphics.Cursor
|
||||||
{
|
{
|
||||||
|
[Cached(typeof(OsuContextMenuContainer))]
|
||||||
public partial class OsuContextMenuContainer : ContextMenuContainer
|
public partial class OsuContextMenuContainer : ContextMenuContainer
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
|
@ -101,12 +101,6 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IDialogOverlay? dialogOverlay { get; set; }
|
private IDialogOverlay? dialogOverlay { get; set; }
|
||||||
|
|
||||||
[Cached]
|
|
||||||
public OsuContextMenuContainer ContextMenuContainer { get; private set; } = new OsuContextMenuContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
};
|
|
||||||
|
|
||||||
public SkinEditor()
|
public SkinEditor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -121,7 +115,10 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
ContextMenuContainer.Child = new GridContainer
|
AddInternal(new OsuContextMenuContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = new GridContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RowDimensions = new[]
|
RowDimensions = new[]
|
||||||
@ -222,9 +219,8 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
});
|
||||||
AddInternal(ContextMenuContainer);
|
|
||||||
|
|
||||||
clipboardContent = clipboard.Content.GetBoundCopy();
|
clipboardContent = clipboard.Content.GetBoundCopy();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
@ -76,12 +77,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public const float WAVEFORM_VISUAL_OFFSET = 20;
|
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 float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowBackButton => false;
|
||||||
@ -165,7 +160,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private string lastSavedHash;
|
private string lastSavedHash;
|
||||||
|
|
||||||
private Container<EditorScreen> screenContainer;
|
private ScreenContainer screenContainer;
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private readonly EditorLoader loader;
|
private readonly EditorLoader loader;
|
||||||
@ -325,14 +320,17 @@ namespace osu.Game.Screens.Edit
|
|||||||
editorTimelineShowTimingChanges = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
|
editorTimelineShowTimingChanges = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
|
||||||
editorTimelineShowTicks = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
|
editorTimelineShowTicks = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
|
||||||
|
|
||||||
ContextMenuContainer.AddRange(new Drawable[]
|
AddInternal(new OsuContextMenuContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
Name = "Screen container",
|
Name = "Screen container",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Top = 40, Bottom = 50 },
|
Padding = new MarginPadding { Top = 40, Bottom = 50 },
|
||||||
Child = screenContainer = new Container<EditorScreen>
|
Child = screenContainer = new ScreenContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
}
|
}
|
||||||
@ -423,10 +421,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
},
|
},
|
||||||
bottomBar = new BottomBar(),
|
bottomBar = new BottomBar(),
|
||||||
MutationTracker,
|
MutationTracker,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddInternal(ContextMenuContainer);
|
|
||||||
|
|
||||||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.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");
|
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentAsync(currentScreen, newScreen =>
|
screenContainer.LoadComponentAsync(currentScreen, newScreen =>
|
||||||
{
|
{
|
||||||
if (newScreen == currentScreen)
|
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