mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 05:36:05 +08:00
let editor dim different from gameplay dim
This commit is contained in:
parent
f9c6190426
commit
6991195d69
@ -7,10 +7,12 @@ using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@ -21,7 +23,6 @@ using osu.Game.Screens.Edit.GameplayTest;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
@ -40,6 +41,14 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
private BeatmapSetInfo importedBeatmapSet;
|
||||
|
||||
private Bindable<float> editorDim;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
editorDim = config.GetBindable<float>(OsuSetting.EditorDim);
|
||||
}
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
AddStep("import test beatmap", () => importedBeatmapSet = BeatmapImportHelper.LoadOszIntoOsu(game).GetResultSafely());
|
||||
@ -77,7 +86,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
// this test cares about checking the background belonging to the editor specifically, so check that using reference equality
|
||||
// (as `.Equals()` cannot discern between the two, as they technically share the same database GUID).
|
||||
var background = this.ChildrenOfType<BackgroundScreenBeatmap>().Single(b => ReferenceEquals(b.Beatmap.BeatmapInfo, EditorBeatmap.BeatmapInfo));
|
||||
return background.Colour == Color4.DarkGray && background.BlurAmount.Value == 0;
|
||||
return background.DimAmount.Value == editorDim.Value && background.BlurAmount.Value == 0;
|
||||
});
|
||||
AddAssert("no mods selected", () => SelectedMods.Value.Count == 0);
|
||||
}
|
||||
@ -110,7 +119,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
// this test cares about checking the background belonging to the editor specifically, so check that using reference equality
|
||||
// (as `.Equals()` cannot discern between the two, as they technically share the same database GUID).
|
||||
var background = this.ChildrenOfType<BackgroundScreenBeatmap>().Single(b => ReferenceEquals(b.Beatmap.BeatmapInfo, EditorBeatmap.BeatmapInfo));
|
||||
return background.Colour == Color4.DarkGray && background.BlurAmount.Value == 0;
|
||||
return background.DimAmount.Value == editorDim.Value && background.BlurAmount.Value == 0;
|
||||
});
|
||||
|
||||
AddStep("start track", () => EditorClock.Start());
|
||||
|
@ -122,7 +122,7 @@ namespace osu.Game.Configuration
|
||||
SetDefault(OsuSetting.PositionalHitsoundsLevel, 0.2f, 0, 1);
|
||||
SetDefault(OsuSetting.DimLevel, 0.7, 0, 1, 0.01);
|
||||
SetDefault(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
||||
SetDefault(OsuSetting.EditorUseDim, false);
|
||||
SetDefault(OsuSetting.EditorDim, 0.25f);
|
||||
SetDefault(OsuSetting.LightenDuringBreaks, true);
|
||||
|
||||
SetDefault(OsuSetting.HitLighting, true);
|
||||
@ -293,7 +293,7 @@ namespace osu.Game.Configuration
|
||||
GameplayCursorDuringTouch,
|
||||
DimLevel,
|
||||
BlurLevel,
|
||||
EditorUseDim,
|
||||
EditorDim,
|
||||
LightenDuringBreaks,
|
||||
ShowStoryboard,
|
||||
KeyOverlay,
|
||||
|
46
osu.Game/Screens/Edit/BackgroundDimMenuItem.cs
Normal file
46
osu.Game/Screens/Edit/BackgroundDimMenuItem.cs
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
internal class BackgroundDimMenuItem : MenuItem
|
||||
{
|
||||
private readonly Bindable<float> backgroudDim;
|
||||
|
||||
private readonly Dictionary<float, TernaryStateRadioMenuItem> menuItemLookup = new Dictionary<float, TernaryStateRadioMenuItem>();
|
||||
|
||||
public BackgroundDimMenuItem(Bindable<float> backgroudDim)
|
||||
: base("Background dim")
|
||||
{
|
||||
Items = new[]
|
||||
{
|
||||
createMenuItem(0f),
|
||||
createMenuItem(0.25f),
|
||||
createMenuItem(0.5f),
|
||||
createMenuItem(0.75f),
|
||||
createMenuItem(1f),
|
||||
};
|
||||
|
||||
this.backgroudDim = backgroudDim;
|
||||
backgroudDim.BindValueChanged(dim =>
|
||||
{
|
||||
foreach (var kvp in menuItemLookup)
|
||||
kvp.Value.State.Value = kvp.Key == dim.NewValue ? TernaryState.True : TernaryState.False;
|
||||
}, true);
|
||||
}
|
||||
|
||||
private TernaryStateRadioMenuItem createMenuItem(float dim)
|
||||
{
|
||||
var item = new TernaryStateRadioMenuItem($"{dim * 100}%", MenuItemType.Standard, _ => updateOpacity(dim));
|
||||
menuItemLookup[dim] = item;
|
||||
return item;
|
||||
}
|
||||
|
||||
private void updateOpacity(float dim) => backgroudDim.Value = dim;
|
||||
}
|
||||
}
|
@ -51,7 +51,6 @@ using osu.Game.Screens.Edit.Timing;
|
||||
using osu.Game.Screens.Edit.Verify;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
using CommonStrings = osu.Game.Resources.Localisation.Web.CommonStrings;
|
||||
|
||||
@ -176,7 +175,7 @@ namespace osu.Game.Screens.Edit
|
||||
[Resolved(canBeNull: true)]
|
||||
private OnScreenDisplay onScreenDisplay { get; set; }
|
||||
|
||||
private Bindable<bool> useUserDim;
|
||||
private Bindable<float> editorDim;
|
||||
|
||||
public Editor(EditorLoader loader = null)
|
||||
{
|
||||
@ -262,8 +261,7 @@ namespace osu.Game.Screens.Edit
|
||||
OsuMenuItem undoMenuItem;
|
||||
OsuMenuItem redoMenuItem;
|
||||
|
||||
TernaryStateRadioMenuItem backgroundDim;
|
||||
useUserDim = config.GetBindable<bool>(OsuSetting.EditorUseDim);
|
||||
editorDim = config.GetBindable<float>(OsuSetting.EditorDim);
|
||||
|
||||
AddInternal(new OsuContextMenuContainer
|
||||
{
|
||||
@ -316,7 +314,7 @@ namespace osu.Game.Screens.Edit
|
||||
Items = new MenuItem[]
|
||||
{
|
||||
new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
|
||||
backgroundDim = new TernaryStateRadioMenuItem("Background Dim", MenuItemType.Standard, _ => useUserDim.Value = !useUserDim.Value),
|
||||
new BackgroundDimMenuItem(editorDim),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -337,12 +335,7 @@ namespace osu.Game.Screens.Edit
|
||||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||
|
||||
useUserDim.BindValueChanged(s =>
|
||||
{
|
||||
dimBackground();
|
||||
backgroundDim.State.Value = s.NewValue ? TernaryState.True : TernaryState.False;
|
||||
});
|
||||
backgroundDim.State.Value = useUserDim.Value ? TernaryState.True : TernaryState.False;
|
||||
editorDim.BindValueChanged(_ => dimBackground());
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
@ -638,10 +631,8 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
ApplyToBackground(b =>
|
||||
{
|
||||
// todo: temporary. we want to be applying dim using the UserDimContainer eventually.
|
||||
if (!useUserDim.Value) b.FadeColour(Color4.DarkGray, 500);
|
||||
|
||||
b.IgnoreUserSettings.Value = !useUserDim.Value;
|
||||
b.IgnoreUserSettings.Value = true;
|
||||
b.DimAmount.Value = editorDim.Value;
|
||||
b.BlurAmount.Value = 0;
|
||||
});
|
||||
}
|
||||
@ -671,8 +662,8 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
ApplyToBackground(b =>
|
||||
{
|
||||
b.FadeColour(Color4.White, 500);
|
||||
b.IgnoreUserSettings.Value = true;
|
||||
//b.DimAmount.UnbindAll();
|
||||
b.DimAmount.Value = 0;
|
||||
});
|
||||
resetTrack();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user