Move setting to user config

This commit is contained in:
Bartłomiej Dach 2024-11-11 09:57:17 +01:00
parent a6cdf6df07
commit 0cddb93dda
No known key found for this signature in database
7 changed files with 22 additions and 10 deletions

View File

@ -196,6 +196,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.EditorShowSpeedChanges, false); SetDefault(OsuSetting.EditorShowSpeedChanges, false);
SetDefault(OsuSetting.EditorScaleOrigin, EditorOrigin.GridCentre); SetDefault(OsuSetting.EditorScaleOrigin, EditorOrigin.GridCentre);
SetDefault(OsuSetting.EditorRotationOrigin, EditorOrigin.GridCentre); SetDefault(OsuSetting.EditorRotationOrigin, EditorOrigin.GridCentre);
SetDefault(OsuSetting.EditorAdjustExistingObjectsOnTimingChanges, true);
SetDefault(OsuSetting.HideCountryFlags, false); SetDefault(OsuSetting.HideCountryFlags, false);
@ -442,5 +443,6 @@ namespace osu.Game.Configuration
EditorScaleOrigin, EditorScaleOrigin,
EditorRotationOrigin, EditorRotationOrigin,
EditorTimelineShowBreaks, EditorTimelineShowBreaks,
EditorAdjustExistingObjectsOnTimingChanges,
} }
} }

View File

@ -40,9 +40,9 @@ namespace osu.Game.Localisation
public static LocalisableString SetPreviewPointToCurrent => new TranslatableString(getKey(@"set_preview_point_to_current"), @"Set preview point to current time"); public static LocalisableString SetPreviewPointToCurrent => new TranslatableString(getKey(@"set_preview_point_to_current"), @"Set preview point to current time");
/// <summary> /// <summary>
/// "Move already placed notes when changing the offset / BPM" /// "Move already placed objects when changing timing"
/// </summary> /// </summary>
public static LocalisableString AdjustNotesOnOffsetBPMChange => new TranslatableString(getKey(@"adjust_notes_on_offset_bpm_change"), @"Move already placed notes when changing the offset / BPM"); public static LocalisableString AdjustExistingObjectsOnTimingChanges => new TranslatableString(getKey(@"adjust_existing_objects_on_timing_changes"), @"Move already placed objects when changing timing");
/// <summary> /// <summary>
/// "For editing (.olz)" /// "For editing (.olz)"

View File

@ -422,9 +422,9 @@ namespace osu.Game.Screens.Edit
Items = new MenuItem[] Items = new MenuItem[]
{ {
new EditorMenuItem(EditorStrings.SetPreviewPointToCurrent, MenuItemType.Standard, SetPreviewPointToCurrentTime), new EditorMenuItem(EditorStrings.SetPreviewPointToCurrent, MenuItemType.Standard, SetPreviewPointToCurrentTime),
new ToggleMenuItem(EditorStrings.AdjustNotesOnOffsetBPMChange) new ToggleMenuItem(EditorStrings.AdjustExistingObjectsOnTimingChanges)
{ {
State = { BindTarget = editorBeatmap.AdjustNotesOnOffsetBPMChange }, State = { BindTarget = config.GetBindable<bool>(OsuSetting.EditorAdjustExistingObjectsOnTimingChanges) },
} }
} }
} }

View File

@ -89,8 +89,6 @@ namespace osu.Game.Screens.Edit
public BindableInt PreviewTime { get; } public BindableInt PreviewTime { get; }
public Bindable<bool> AdjustNotesOnOffsetBPMChange { get; } = new Bindable<bool>(false);
private readonly IBeatmapProcessor beatmapProcessor; private readonly IBeatmapProcessor beatmapProcessor;
private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>(); private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>();

View File

@ -7,6 +7,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osuTK; using osuTK;
@ -25,6 +26,9 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved] [Resolved]
protected EditorBeatmap Beatmap { get; private set; } = null!; protected EditorBeatmap Beatmap { get; private set; } = null!;
[Resolved]
private OsuConfigManager configManager { get; set; } = null!;
[Resolved] [Resolved]
private EditorClock clock { get; set; } = null!; private EditorClock clock { get; set; } = null!;
@ -112,7 +116,7 @@ namespace osu.Game.Screens.Edit.Timing
foreach (var cp in currentGroupItems) foreach (var cp in currentGroupItems)
{ {
// Only adjust hit object offsets if the group contains a timing control point // Only adjust hit object offsets if the group contains a timing control point
if (Beatmap.AdjustNotesOnOffsetBPMChange.Value && cp is TimingControlPoint tp) if (cp is TimingControlPoint tp && configManager.Get<bool>(OsuSetting.EditorAdjustExistingObjectsOnTimingChanges))
{ {
TimingSectionAdjustments.AdjustHitObjectOffset(Beatmap, tp, time - SelectedGroup.Value.Time); TimingSectionAdjustments.AdjustHitObjectOffset(Beatmap, tp, time - SelectedGroup.Value.Time);
Beatmap.UpdateAllHitObjects(); Beatmap.UpdateAllHitObjects();

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
@ -26,6 +27,9 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved] [Resolved]
private EditorBeatmap beatmap { get; set; } = null!; private EditorBeatmap beatmap { get; set; } = null!;
[Resolved]
private OsuConfigManager configManager { get; set; } = null!;
[Resolved] [Resolved]
private Bindable<ControlPointGroup> selectedGroup { get; set; } = null!; private Bindable<ControlPointGroup> selectedGroup { get; set; } = null!;
@ -209,7 +213,7 @@ namespace osu.Game.Screens.Edit.Timing
foreach (var cp in currentGroupItems) foreach (var cp in currentGroupItems)
{ {
if (beatmap.AdjustNotesOnOffsetBPMChange.Value && cp is TimingControlPoint tp) if (cp is TimingControlPoint tp)
{ {
TimingSectionAdjustments.AdjustHitObjectOffset(beatmap, tp, adjust); TimingSectionAdjustments.AdjustHitObjectOffset(beatmap, tp, adjust);
beatmap.UpdateAllHitObjects(); beatmap.UpdateAllHitObjects();
@ -236,7 +240,7 @@ namespace osu.Game.Screens.Edit.Timing
double oldBeatLength = timing.BeatLength; double oldBeatLength = timing.BeatLength;
timing.BeatLength = 60000 / (timing.BPM + adjust); timing.BeatLength = 60000 / (timing.BPM + adjust);
if (beatmap.AdjustNotesOnOffsetBPMChange.Value) if (configManager.Get<bool>(OsuSetting.EditorAdjustExistingObjectsOnTimingChanges))
{ {
beatmap.BeginChange(); beatmap.BeginChange();
TimingSectionAdjustments.SetHitObjectBPM(beatmap, timing, oldBeatLength); TimingSectionAdjustments.SetHitObjectBPM(beatmap, timing, oldBeatLength);

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
namespace osu.Game.Screens.Edit.Timing namespace osu.Game.Screens.Edit.Timing
@ -16,6 +17,9 @@ namespace osu.Game.Screens.Edit.Timing
private LabelledSwitchButton omitBarLine = null!; private LabelledSwitchButton omitBarLine = null!;
private BPMTextBox bpmTextEntry = null!; private BPMTextBox bpmTextEntry = null!;
[Resolved]
private OsuConfigManager configManager { get; set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
@ -46,7 +50,7 @@ namespace osu.Game.Screens.Edit.Timing
bpmTextEntry.OnCommit = (oldBeatLength, _) => bpmTextEntry.OnCommit = (oldBeatLength, _) =>
{ {
if (!Beatmap.AdjustNotesOnOffsetBPMChange.Value || ControlPoint.Value == null) if (!configManager.Get<bool>(OsuSetting.EditorAdjustExistingObjectsOnTimingChanges) || ControlPoint.Value == null)
return; return;
Beatmap.BeginChange(); Beatmap.BeginChange();