Skip to content

Commit

Permalink
Move IGameplaySettings override to compose screen to keep test mode…
Browse files Browse the repository at this point in the history
… unaffected
  • Loading branch information
frenzibyte committed Nov 16, 2022
1 parent ee6fffe commit 7a28a7f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 30 deletions.
2 changes: 1 addition & 1 deletion osu.Game/Configuration/IGameplaySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace osu.Game.Configuration
{
/// <summary>
/// A settings provider which generally sources from <see cref="OsuConfigManager"/> (global user settings)
/// but can allow overriding settings by caching more locally. For instance, in the editor.
/// but can allow overriding settings by caching more locally. For instance, in the editor compose screen.
/// </summary>
/// <remarks>
/// More settings can be moved into this interface as required.
Expand Down
13 changes: 12 additions & 1 deletion osu.Game/Screens/Edit/Compose/ComposeScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Extensions;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets;
Expand All @@ -19,14 +20,17 @@

namespace osu.Game.Screens.Edit.Compose
{
public class ComposeScreen : EditorScreenWithTimeline
public class ComposeScreen : EditorScreenWithTimeline, IGameplaySettings
{
[Resolved]
private GameHost host { get; set; }

[Resolved]
private EditorClock clock { get; set; }

[Resolved]
private IGameplaySettings globalGameplaySettings { get; set; }

private Bindable<string> clipboard { get; set; }

private HitObjectComposer composer;
Expand Down Expand Up @@ -157,5 +161,12 @@ private string formatSelectionAsString()
}

#endregion

// Combo colour normalisation should not be applied in the editor.
// Note this doesn't affect editor test mode.
IBindable<float> IGameplaySettings.ComboColourNormalisationAmount => new Bindable<float>();

// Arguable.
IBindable<float> IGameplaySettings.PositionalHitsoundsLevel => globalGameplaySettings.PositionalHitsoundsLevel;
}
}
12 changes: 1 addition & 11 deletions osu.Game/Screens/Edit/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ namespace osu.Game.Screens.Edit
{
[Cached(typeof(IBeatSnapProvider))]
[Cached]
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider, ISamplePlaybackDisabler, IBeatSyncProvider,
IGameplaySettings
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider, ISamplePlaybackDisabler, IBeatSyncProvider
{
public override float BackgroundParallaxAmount => 0.1f;

Expand Down Expand Up @@ -99,9 +98,6 @@ protected bool HasUnsavedChanges
[Resolved(canBeNull: true)]
private INotificationOverlay notifications { get; set; }

[Resolved]
private IGameplaySettings globalGameplaySettings { get; set; }

public readonly Bindable<EditorScreenMode> Mode = new Bindable<EditorScreenMode>();

public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
Expand Down Expand Up @@ -1045,11 +1041,5 @@ public BeatmapEditorToast(LocalisableString value, string beatmapDisplayName)
{
}
}

// Combo colour normalisation should not be applied in the editor.
IBindable<float> IGameplaySettings.ComboColourNormalisationAmount => new Bindable<float>();

// Arguable.
IBindable<float> IGameplaySettings.PositionalHitsoundsLevel => globalGameplaySettings.PositionalHitsoundsLevel;
}
}
18 changes: 1 addition & 17 deletions osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,28 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Overlays;
using osu.Game.Screens.Play;

namespace osu.Game.Screens.Edit.GameplayTest
{
public class EditorPlayer : Player, IGameplaySettings
public class EditorPlayer : Player
{
private readonly Editor editor;
private readonly EditorState editorState;

[Resolved]
private MusicController musicController { get; set; } = null!;

private OsuConfigManager config = null!;

public EditorPlayer(Editor editor)
: base(new PlayerConfiguration { ShowResults = false })
{
this.editor = editor;
editorState = editor.GetState();
}

protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
// needs to be populated before BDL to work correctly.
config = parent.Get<OsuConfigManager>();

return base.CreateChildDependencies(parent);
}

protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
{
var masterGameplayClockContainer = new MasterGameplayClockContainer(beatmap, gameplayStart);
Expand Down Expand Up @@ -84,9 +72,5 @@ public override bool OnExiting(ScreenExitEvent e)
editor.RestoreState(editorState);
return base.OnExiting(e);
}

// Editor overrides but we actually want to use game-wide settings here.
public IBindable<float> ComboColourNormalisationAmount => ((IGameplaySettings)config).ComboColourNormalisationAmount;
public IBindable<float> PositionalHitsoundsLevel => ((IGameplaySettings)config).PositionalHitsoundsLevel;
}
}

0 comments on commit 7a28a7f

Please sign in to comment.