Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions osu.Game/Localisation/EditorDialogsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ public static class EditorDialogsStrings
/// </summary>
public static LocalisableString SnapAllNotesConfirmationBody => new TranslatableString(getKey(@"snap_all_notes_confirmation_body"), @"Every hit object in this difficulty will move to the nearest tick for your current snap divisor. Slider and hold durations may change. You can undo this from the editor history.");

/// <summary>
/// "Sync to all difficulties?"
/// </summary>
public static LocalisableString SyncTimingConfirmationHeader => new TranslatableString(getKey(@"sync_timing_confirmation_header"), @"Sync to all difficulties?");

/// <summary>
/// "This overwrites the selected options on all other difficulties. This cannot be undone."
/// </summary>
public static LocalisableString SyncTimingConfirmationBody => new TranslatableString(getKey(@"sync_timing_confirmation_body"), @"This overwrites the selected options on all other difficulties. This cannot be undone.");

/// <summary>
/// "Bookmarks"
/// </summary>
public static LocalisableString SyncTimingOptionBookmarks => new TranslatableString(getKey(@"sync_timing_option_bookmarks"), @"Bookmarks");

/// <summary>
/// "Preview point"
/// </summary>
public static LocalisableString SyncTimingOptionPreviewPoint => new TranslatableString(getKey(@"sync_timing_option_preview_point"), @"Preview point");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
5 changes: 5 additions & 0 deletions osu.Game/Localisation/EditorStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ public static class EditorStrings
/// </summary>
public static LocalisableString SampleSet => new TranslatableString(getKey(@"sample_set"), @"Sample set");

/// <summary>
/// "Sync to all difficulties"
/// </summary>
public static LocalisableString SyncToAllDifficulties => new TranslatableString(getKey(@"sync_to_all_difficulties"), @"Sync to all difficulties");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
50 changes: 50 additions & 0 deletions osu.Game/Screens/Edit/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ private void load(OsuConfigManager config)
Items = new MenuItem[]
{
new EditorMenuItem(EditorStrings.SetPreviewPointToCurrent, MenuItemType.Standard, SetPreviewPointToCurrentTime),
new EditorMenuItem(EditorStrings.SyncToAllDifficulties, MenuItemType.Destructive, confirmSyncTimingToAllDifficulties)
{
Action = { Disabled = loadableBeatmap.BeatmapSetInfo.Beatmaps.Count < 2 }
},
new EditorMenuItem(EditorStrings.SnapAllNotesToCurrentSnapDivisor, MenuItemType.Destructive, confirmSnapAllHitObjectsToCurrentDivisor),
bookmarkController.Menu,
}
Expand Down Expand Up @@ -1037,6 +1041,52 @@ protected void SetPreviewPointToCurrentTime()
editorBeatmap.PreviewTime.Value = (int)clock.CurrentTime;
}

private void confirmSyncTimingToAllDifficulties()
{
dialogOverlay.Push(new SyncTimingConfirmationDialog(syncTimingToAllOtherDifficulties));
}

private void syncTimingToAllOtherDifficulties(bool syncBookmarks, bool syncPreviewPoint)
{
if (Beatmap.Value.BeatmapSetInfo.Beatmaps.Count <= 1)
return;

if (!syncBookmarks && !syncPreviewPoint)
return;

var set = Beatmap.Value.BeatmapSetInfo;
var current = editorBeatmap.BeatmapInfo;
int[] sourceBookmarks = editorBeatmap.Bookmarks.ToArray();
int sourcePreviewTime = editorBeatmap.BeatmapInfo.Metadata.PreviewTime;

foreach (var beatmapInfo in set.Beatmaps)
{
if (beatmapInfo.Equals(current))
continue;

try
{
var targetWorking = beatmapManager.GetWorkingBeatmap(beatmapInfo);
var playable = targetWorking.GetPlayableBeatmap(beatmapInfo.Ruleset);

if (syncBookmarks)
playable.Bookmarks = sourceBookmarks.ToArray();

if (syncPreviewPoint)
beatmapInfo.Metadata.PreviewTime = sourcePreviewTime;

beatmapManager.Save(beatmapInfo, playable, targetWorking.GetSkin(), targetWorking.Storyboard);
}
catch (Exception e)
{
Logger.Error(e, $@"Failed to sync bookmarks/preview to {beatmapInfo.GetDisplayTitle()}");
return;
}
}

SaveAndReload(withDialog: false);
}

private void confirmSnapAllHitObjectsToCurrentDivisor()
{
dialogOverlay.Push(new SnapAllNotesConfirmationDialog(SnapAllHitObjectsToCurrentDivisor));
Expand Down
52 changes: 52 additions & 0 deletions osu.Game/Screens/Edit/SyncTimingConfirmationDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays.Dialog;
using osuTK;

namespace osu.Game.Screens.Edit
{
public partial class SyncTimingConfirmationDialog : DangerousActionDialog
{
private readonly BindableBool syncBookmarks = new BindableBool(true);
private readonly BindableBool syncPreviewPoint = new BindableBool(true);

public SyncTimingConfirmationDialog(Action<bool, bool> syncAction)
{
HeaderText = EditorDialogsStrings.SyncTimingConfirmationHeader;
BodyText = EditorDialogsStrings.SyncTimingConfirmationBody;

DangerousAction = () => syncAction(syncBookmarks.Value, syncPreviewPoint.Value);

MainContent.Child = new FillFlowContainer
{
Margin = new MarginPadding { Top = 20 },
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 400,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5),
Children = new Drawable[]
{
new OsuCheckbox
{
LabelText = EditorDialogsStrings.SyncTimingOptionBookmarks,
Current = { BindTarget = syncBookmarks },
},
new OsuCheckbox
{
LabelText = EditorDialogsStrings.SyncTimingOptionPreviewPoint,
Current = { BindTarget = syncPreviewPoint },
},
}
};
}
}
}
Loading