1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Disable beatmap skinning when entering the skin editor

This commit is contained in:
Dean Herbert 2023-06-20 19:18:17 +09:00
parent c815f8cd23
commit d7b486e2ac

View File

@ -3,16 +3,19 @@
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components; using osu.Game.Screens.Edit.Components;
using osu.Game.Screens.Play;
using osuTK; using osuTK;
namespace osu.Game.Overlays.SkinEditor namespace osu.Game.Overlays.SkinEditor
@ -45,6 +48,12 @@ namespace osu.Game.Overlays.SkinEditor
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {
switch (e.Action) switch (e.Action)
@ -147,17 +156,24 @@ namespace osu.Game.Overlays.SkinEditor
/// </summary> /// </summary>
public void SetTarget(OsuScreen screen) public void SetTarget(OsuScreen screen)
{ {
lastTargetScreen = screen; try
{
lastTargetScreen = screen;
if (skinEditor == null) return; if (skinEditor == null) return;
skinEditor.Save(userTriggered: false); skinEditor.Save(userTriggered: false);
// ensure the toolbar is re-hidden even if a new screen decides to try and show it. // ensure the toolbar is re-hidden even if a new screen decides to try and show it.
updateComponentVisibility(); updateComponentVisibility();
// AddOnce with parameter will ensure the newest target is loaded if there is any overlap. // AddOnce with parameter will ensure the newest target is loaded if there is any overlap.
Scheduler.AddOnce(setTarget, screen); Scheduler.AddOnce(setTarget, screen);
}
finally
{
globallyReenableBeatmapSkinSetting();
}
} }
private void setTarget(OsuScreen? target) private void setTarget(OsuScreen? target)
@ -173,6 +189,9 @@ namespace osu.Game.Overlays.SkinEditor
return; return;
} }
if (target is Player)
globallyDisableBeatmapSkinSetting();
if (skinEditor.State.Value == Visibility.Visible) if (skinEditor.State.Value == Visibility.Visible)
skinEditor.UpdateTargetScreen(target); skinEditor.UpdateTargetScreen(target);
else else
@ -182,5 +201,30 @@ namespace osu.Game.Overlays.SkinEditor
skinEditor = null; skinEditor = null;
} }
} }
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
private bool beatmapSkinsOriginalState;
private void globallyDisableBeatmapSkinSetting()
{
if (beatmapSkins.Disabled)
return;
// The skin editor doesn't work well if beatmap skins are being applied to the player screen.
// To keep things simple, disable the setting game-wide while using the skin editor.
beatmapSkinsOriginalState = beatmapSkins.Value;
beatmapSkins.Value = false;
beatmapSkins.Disabled = true;
}
private void globallyReenableBeatmapSkinSetting()
{
if (!beatmapSkins.Disabled)
return;
beatmapSkins.Disabled = false;
beatmapSkins.Value = beatmapSkinsOriginalState;
}
} }
} }