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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Screens;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components;
using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Overlays.SkinEditor
@ -45,6 +48,12 @@ namespace osu.Game.Overlays.SkinEditor
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
@ -146,6 +155,8 @@ namespace osu.Game.Overlays.SkinEditor
/// Set a new target screen which will be used to find skinnable components.
/// </summary>
public void SetTarget(OsuScreen screen)
{
try
{
lastTargetScreen = screen;
@ -159,6 +170,11 @@ namespace osu.Game.Overlays.SkinEditor
// AddOnce with parameter will ensure the newest target is loaded if there is any overlap.
Scheduler.AddOnce(setTarget, screen);
}
finally
{
globallyReenableBeatmapSkinSetting();
}
}
private void setTarget(OsuScreen? target)
{
@ -173,6 +189,9 @@ namespace osu.Game.Overlays.SkinEditor
return;
}
if (target is Player)
globallyDisableBeatmapSkinSetting();
if (skinEditor.State.Value == Visibility.Visible)
skinEditor.UpdateTargetScreen(target);
else
@ -182,5 +201,30 @@ namespace osu.Game.Overlays.SkinEditor
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;
}
}
}