2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-11-22 10:40:44 +00:00
|
|
|
|
using System;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-09-12 06:33:13 +00:00
|
|
|
|
using System.Diagnostics;
|
2020-09-11 10:54:20 +00:00
|
|
|
|
using System.Linq;
|
2021-09-05 14:59:28 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2020-04-22 08:41:24 +00:00
|
|
|
|
using osu.Framework.Input;
|
2019-06-30 10:31:31 +00:00
|
|
|
|
using osu.Framework.Input.Bindings;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2020-03-13 05:28:11 +00:00
|
|
|
|
using osu.Framework.Logging;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Framework.Screens;
|
2019-12-27 10:46:33 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-11-03 07:01:14 +00:00
|
|
|
|
using osu.Game.Configuration;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2019-11-07 13:51:49 +00:00
|
|
|
|
using osu.Game.Graphics.Cursor;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-06-30 10:31:31 +00:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2020-09-11 10:54:20 +00:00
|
|
|
|
using osu.Game.IO.Serialization;
|
2020-09-01 09:56:49 +00:00
|
|
|
|
using osu.Game.Online.API;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2020-01-23 05:39:56 +00:00
|
|
|
|
using osu.Game.Rulesets.Edit;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Game.Screens.Edit.Components;
|
|
|
|
|
using osu.Game.Screens.Edit.Components.Menus;
|
|
|
|
|
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
2019-10-09 07:04:58 +00:00
|
|
|
|
using osu.Game.Screens.Edit.Compose;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osu.Game.Screens.Edit.Design;
|
2019-10-08 05:23:13 +00:00
|
|
|
|
using osu.Game.Screens.Edit.Setup;
|
|
|
|
|
using osu.Game.Screens.Edit.Timing;
|
2021-03-28 15:36:22 +00:00
|
|
|
|
using osu.Game.Screens.Edit.Verify;
|
2019-12-12 04:04:32 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2019-04-12 20:54:35 +00:00
|
|
|
|
using osu.Game.Users;
|
2020-09-09 10:31:18 +00:00
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK.Input;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit
|
|
|
|
|
{
|
2020-01-23 05:39:56 +00:00
|
|
|
|
[Cached(typeof(IBeatSnapProvider))]
|
2020-10-27 05:31:56 +00:00
|
|
|
|
[Cached(typeof(ISamplePlaybackDisabler))]
|
2020-09-24 09:55:49 +00:00
|
|
|
|
[Cached]
|
2020-10-27 05:31:56 +00:00
|
|
|
|
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider, ISamplePlaybackDisabler
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-06 09:11:56 +00:00
|
|
|
|
public override float BackgroundParallaxAmount => 0.1f;
|
|
|
|
|
|
2019-06-25 07:55:49 +00:00
|
|
|
|
public override bool AllowBackButton => false;
|
|
|
|
|
|
2019-01-28 06:41:54 +00:00
|
|
|
|
public override bool HideOverlaysOnEnter => true;
|
2019-02-01 06:42:15 +00:00
|
|
|
|
|
|
|
|
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-07-29 07:39:26 +00:00
|
|
|
|
public override bool AllowTrackAdjustments => false;
|
2020-01-24 04:10:02 +00:00
|
|
|
|
|
2020-09-09 10:57:28 +00:00
|
|
|
|
protected bool HasUnsavedChanges => lastSavedHash != changeHandler.CurrentStateHash;
|
2020-09-09 10:42:03 +00:00
|
|
|
|
|
2020-01-10 10:57:34 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapManager beatmapManager { get; set; }
|
|
|
|
|
|
2020-09-09 10:31:18 +00:00
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private DialogOverlay dialogOverlay { get; set; }
|
|
|
|
|
|
2020-10-27 05:31:56 +00:00
|
|
|
|
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
|
|
|
|
|
|
|
|
|
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
|
|
|
|
|
2020-09-09 10:31:18 +00:00
|
|
|
|
private bool exitConfirmed;
|
|
|
|
|
|
2020-09-09 10:40:41 +00:00
|
|
|
|
private string lastSavedHash;
|
|
|
|
|
|
2020-09-24 08:03:54 +00:00
|
|
|
|
private Container<EditorScreen> screenContainer;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-09-05 14:59:28 +00:00
|
|
|
|
[CanBeNull]
|
|
|
|
|
private readonly EditorLoader loader;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private EditorScreen currentScreen;
|
|
|
|
|
|
|
|
|
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
|
|
|
|
private EditorClock clock;
|
|
|
|
|
|
2019-12-27 10:46:33 +00:00
|
|
|
|
private IBeatmap playableBeatmap;
|
|
|
|
|
private EditorBeatmap editorBeatmap;
|
2020-04-09 12:22:07 +00:00
|
|
|
|
private EditorChangeHandler changeHandler;
|
2019-12-27 10:46:33 +00:00
|
|
|
|
|
2020-09-22 06:55:25 +00:00
|
|
|
|
private EditorMenuBar menuBar;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private DependencyContainer dependencies;
|
|
|
|
|
|
2020-10-04 14:47:16 +00:00
|
|
|
|
private bool isNewBeatmap;
|
|
|
|
|
|
2019-06-12 07:33:15 +00:00
|
|
|
|
protected override UserActivity InitialActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo);
|
2019-04-12 20:54:35 +00:00
|
|
|
|
|
2018-07-11 08:07:14 +00:00
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
|
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-01 09:56:49 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private IAPIProvider api { get; set; }
|
|
|
|
|
|
2020-09-24 09:55:49 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private MusicController music { get; set; }
|
|
|
|
|
|
2021-09-05 14:59:28 +00:00
|
|
|
|
public Editor(EditorLoader loader = null)
|
|
|
|
|
{
|
|
|
|
|
this.loader = loader;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
2021-03-26 08:17:24 +00:00
|
|
|
|
private void load(OsuColour colours, OsuConfigManager config)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2021-03-17 06:52:24 +00:00
|
|
|
|
var loadableBeatmap = Beatmap.Value;
|
|
|
|
|
|
|
|
|
|
if (loadableBeatmap is DummyWorkingBeatmap)
|
2020-12-01 07:16:26 +00:00
|
|
|
|
{
|
|
|
|
|
isNewBeatmap = true;
|
2021-01-22 08:47:38 +00:00
|
|
|
|
|
2021-03-17 06:52:24 +00:00
|
|
|
|
loadableBeatmap = beatmapManager.CreateNew(Ruleset.Value, api.LocalUser.Value);
|
|
|
|
|
|
|
|
|
|
// required so we can get the track length in EditorClock.
|
|
|
|
|
// this is safe as nothing has yet got a reference to this new beatmap.
|
|
|
|
|
loadableBeatmap.LoadTrack();
|
2021-01-22 08:47:38 +00:00
|
|
|
|
|
|
|
|
|
// this is a bit haphazard, but guards against setting the lease Beatmap bindable if
|
|
|
|
|
// the editor has already been exited.
|
|
|
|
|
if (!ValidForPush)
|
|
|
|
|
return;
|
2020-12-01 07:16:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-13 05:28:11 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2021-03-17 06:52:24 +00:00
|
|
|
|
playableBeatmap = loadableBeatmap.GetPlayableBeatmap(loadableBeatmap.BeatmapInfo.Ruleset);
|
2021-01-25 09:29:00 +00:00
|
|
|
|
|
|
|
|
|
// clone these locally for now to avoid incurring overhead on GetPlayableBeatmap usages.
|
|
|
|
|
// eventually we will want to improve how/where this is done as there are issues with *not* cloning it in all cases.
|
2021-07-19 03:38:22 +00:00
|
|
|
|
playableBeatmap.ControlPointInfo = playableBeatmap.ControlPointInfo.DeepClone();
|
2020-03-13 05:28:11 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2020-03-16 02:29:28 +00:00
|
|
|
|
Logger.Error(e, "Could not load beatmap successfully!");
|
|
|
|
|
// couldn't load, hard abort!
|
2020-03-13 05:28:11 +00:00
|
|
|
|
this.Exit();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-03 09:43:47 +00:00
|
|
|
|
beatDivisor.Value = playableBeatmap.BeatmapInfo.BeatDivisor;
|
|
|
|
|
beatDivisor.BindValueChanged(divisor => playableBeatmap.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
|
|
|
|
|
|
|
|
|
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
|
|
|
|
clock = new EditorClock(playableBeatmap, beatDivisor) { IsCoupled = false };
|
2021-05-07 06:54:58 +00:00
|
|
|
|
clock.ChangeSource(loadableBeatmap.Track);
|
2021-04-03 09:43:47 +00:00
|
|
|
|
|
|
|
|
|
dependencies.CacheAs(clock);
|
|
|
|
|
AddInternal(clock);
|
|
|
|
|
|
|
|
|
|
clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());
|
|
|
|
|
|
|
|
|
|
// todo: remove caching of this and consume via editorBeatmap?
|
|
|
|
|
dependencies.Cache(beatDivisor);
|
|
|
|
|
|
2021-08-15 16:38:01 +00:00
|
|
|
|
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.GetSkin()));
|
2019-12-27 10:46:33 +00:00
|
|
|
|
dependencies.CacheAs(editorBeatmap);
|
2020-04-09 12:22:07 +00:00
|
|
|
|
changeHandler = new EditorChangeHandler(editorBeatmap);
|
|
|
|
|
dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
|
|
|
|
|
|
2020-09-09 10:40:41 +00:00
|
|
|
|
updateLastSavedHash();
|
|
|
|
|
|
2021-03-17 06:52:24 +00:00
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
// we need to avoid changing the beatmap from an asynchronous load thread. it can potentially cause weirdness including crashes.
|
|
|
|
|
// this assumes that nothing during the rest of this load() method is accessing Beatmap.Value (loadableBeatmap should be preferred).
|
|
|
|
|
// generally this is quite safe, as the actual load of editor content comes after menuBar.Mode.ValueChanged is fired in its own LoadComplete.
|
|
|
|
|
Beatmap.Value = loadableBeatmap;
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-16 04:25:08 +00:00
|
|
|
|
OsuMenuItem undoMenuItem;
|
|
|
|
|
OsuMenuItem redoMenuItem;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-11 10:54:20 +00:00
|
|
|
|
EditorMenuItem cutMenuItem;
|
|
|
|
|
EditorMenuItem copyMenuItem;
|
|
|
|
|
EditorMenuItem pasteMenuItem;
|
|
|
|
|
|
2020-02-05 08:16:15 +00:00
|
|
|
|
AddInternal(new OsuContextMenuContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
Name = "Screen container",
|
2018-04-13 09:19:50 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-11-07 13:51:49 +00:00
|
|
|
|
Padding = new MarginPadding { Top = 40, Bottom = 60 },
|
2020-09-24 08:03:54 +00:00
|
|
|
|
Child = screenContainer = new Container<EditorScreen>
|
2019-11-07 13:51:49 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
Name = "Top bar",
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 40,
|
|
|
|
|
Child = menuBar = new EditorMenuBar
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-08-24 10:38:05 +00:00
|
|
|
|
Mode = { Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose },
|
2019-11-07 13:51:49 +00:00
|
|
|
|
Items = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
new MenuItem("File")
|
|
|
|
|
{
|
2021-03-17 06:52:24 +00:00
|
|
|
|
Items = createFileMenuItems()
|
2020-04-09 12:22:07 +00:00
|
|
|
|
},
|
|
|
|
|
new MenuItem("Edit")
|
|
|
|
|
{
|
|
|
|
|
Items = new[]
|
|
|
|
|
{
|
2020-04-22 09:14:21 +00:00
|
|
|
|
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
|
2020-09-11 10:54:20 +00:00
|
|
|
|
redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, Redo),
|
|
|
|
|
new EditorMenuItemSpacer(),
|
|
|
|
|
cutMenuItem = new EditorMenuItem("Cut", MenuItemType.Standard, Cut),
|
|
|
|
|
copyMenuItem = new EditorMenuItem("Copy", MenuItemType.Standard, Copy),
|
|
|
|
|
pasteMenuItem = new EditorMenuItem("Paste", MenuItemType.Standard, Paste),
|
2020-04-09 12:22:07 +00:00
|
|
|
|
}
|
2020-11-03 07:01:14 +00:00
|
|
|
|
},
|
|
|
|
|
new MenuItem("View")
|
|
|
|
|
{
|
2021-04-21 09:05:40 +00:00
|
|
|
|
Items = new MenuItem[]
|
2020-11-03 07:01:14 +00:00
|
|
|
|
{
|
2021-04-21 09:05:26 +00:00
|
|
|
|
new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
|
2021-04-21 09:05:40 +00:00
|
|
|
|
new HitAnimationsMenuItem(config.GetBindable<bool>(OsuSetting.EditorHitAnimations))
|
2020-11-03 07:01:14 +00:00
|
|
|
|
}
|
2019-11-07 13:51:49 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-07 13:51:49 +00:00
|
|
|
|
},
|
|
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
Name = "Bottom bar",
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 60,
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2021-03-17 08:02:11 +00:00
|
|
|
|
new Box
|
2021-03-17 06:52:24 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = colours.Gray2
|
|
|
|
|
},
|
2019-11-07 13:51:49 +00:00
|
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-11-07 13:51:49 +00:00
|
|
|
|
Padding = new MarginPadding { Vertical = 5, Horizontal = 10 },
|
|
|
|
|
Child = new GridContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColumnDimensions = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
new Dimension(GridSizeMode.Absolute, 220),
|
|
|
|
|
new Dimension(),
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, 220)
|
|
|
|
|
},
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-07 13:51:49 +00:00
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Right = 10 },
|
|
|
|
|
Child = new TimeInfoContainer { RelativeSizeAxes = Axes.Both },
|
|
|
|
|
},
|
|
|
|
|
new SummaryTimeline
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = 10 },
|
|
|
|
|
Child = new PlaybackControl { RelativeSizeAxes = Axes.Both },
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
2019-11-07 13:51:49 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2019-11-07 13:51:49 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
2020-02-05 08:16:15 +00:00
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-16 04:25:08 +00:00
|
|
|
|
changeHandler.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
|
|
|
|
changeHandler.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
|
|
|
|
|
2020-09-11 13:53:03 +00:00
|
|
|
|
editorBeatmap.SelectedHitObjects.BindCollectionChanged((_, __) =>
|
2020-09-11 10:54:20 +00:00
|
|
|
|
{
|
|
|
|
|
var hasObjects = editorBeatmap.SelectedHitObjects.Count > 0;
|
|
|
|
|
|
|
|
|
|
cutMenuItem.Action.Disabled = !hasObjects;
|
|
|
|
|
copyMenuItem.Action.Disabled = !hasObjects;
|
2020-09-11 13:53:03 +00:00
|
|
|
|
}, true);
|
2020-09-11 10:54:20 +00:00
|
|
|
|
|
|
|
|
|
clipboard.BindValueChanged(content => pasteMenuItem.Action.Disabled = string.IsNullOrEmpty(content.NewValue));
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
menuBar.Mode.ValueChanged += onModeChanged;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-24 09:55:49 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// If the beatmap's track has changed, this method must be called to keep the editor in a valid state.
|
|
|
|
|
/// </summary>
|
2021-05-07 06:53:54 +00:00
|
|
|
|
public void UpdateClockSource() => clock.ChangeSource(Beatmap.Value.Track);
|
2020-09-24 09:55:49 +00:00
|
|
|
|
|
2020-09-09 10:57:28 +00:00
|
|
|
|
protected void Save()
|
|
|
|
|
{
|
2020-10-04 14:47:16 +00:00
|
|
|
|
// no longer new after first user-triggered save.
|
|
|
|
|
isNewBeatmap = false;
|
|
|
|
|
|
2020-09-09 10:57:28 +00:00
|
|
|
|
// apply any set-level metadata changes.
|
|
|
|
|
beatmapManager.Update(playableBeatmap.BeatmapInfo.BeatmapSet);
|
|
|
|
|
|
|
|
|
|
// save the loaded beatmap's data stream.
|
|
|
|
|
beatmapManager.Save(playableBeatmap.BeatmapInfo, editorBeatmap, editorBeatmap.BeatmapSkin);
|
|
|
|
|
|
|
|
|
|
updateLastSavedHash();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 09:21:53 +00:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
clock.ProcessFrame();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-22 08:41:24 +00:00
|
|
|
|
public bool OnPressed(PlatformAction action)
|
|
|
|
|
{
|
2021-07-20 05:23:34 +00:00
|
|
|
|
switch (action)
|
2020-04-22 08:41:24 +00:00
|
|
|
|
{
|
2021-07-20 05:23:34 +00:00
|
|
|
|
case PlatformAction.Cut:
|
2020-09-11 10:55:41 +00:00
|
|
|
|
Cut();
|
|
|
|
|
return true;
|
|
|
|
|
|
2021-07-20 05:23:34 +00:00
|
|
|
|
case PlatformAction.Copy:
|
2020-09-11 10:55:41 +00:00
|
|
|
|
Copy();
|
|
|
|
|
return true;
|
|
|
|
|
|
2021-07-20 05:23:34 +00:00
|
|
|
|
case PlatformAction.Paste:
|
2020-09-11 10:55:41 +00:00
|
|
|
|
Paste();
|
|
|
|
|
return true;
|
|
|
|
|
|
2021-07-20 05:23:34 +00:00
|
|
|
|
case PlatformAction.Undo:
|
2020-04-22 09:14:21 +00:00
|
|
|
|
Undo();
|
2020-04-22 08:41:24 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
2021-07-20 05:23:34 +00:00
|
|
|
|
case PlatformAction.Redo:
|
2020-04-22 09:14:21 +00:00
|
|
|
|
Redo();
|
2020-04-22 08:41:24 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
2021-07-20 05:23:34 +00:00
|
|
|
|
case PlatformAction.Save:
|
2020-09-09 10:57:28 +00:00
|
|
|
|
Save();
|
2020-04-22 08:41:24 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnReleased(PlatformAction action)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 05:57:25 +00:00
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-11-30 05:57:25 +00:00
|
|
|
|
switch (e.Key)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-11-30 05:57:25 +00:00
|
|
|
|
case Key.Left:
|
2018-11-30 06:47:55 +00:00
|
|
|
|
seek(e, -1);
|
2018-11-30 05:57:25 +00:00
|
|
|
|
return true;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-11-30 05:57:25 +00:00
|
|
|
|
case Key.Right:
|
2018-11-30 06:47:55 +00:00
|
|
|
|
seek(e, 1);
|
2018-11-30 05:57:25 +00:00
|
|
|
|
return true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 05:57:25 +00:00
|
|
|
|
return base.OnKeyDown(e);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-22 10:40:44 +00:00
|
|
|
|
private double scrollAccumulation;
|
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override bool OnScroll(ScrollEvent e)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-11-25 07:46:19 +00:00
|
|
|
|
if (e.ControlPressed || e.AltPressed || e.SuperPressed)
|
|
|
|
|
return false;
|
|
|
|
|
|
2020-07-17 07:03:13 +00:00
|
|
|
|
const double precision = 1;
|
2018-11-22 10:40:44 +00:00
|
|
|
|
|
2020-07-17 07:03:13 +00:00
|
|
|
|
double scrollComponent = e.ScrollDelta.X + e.ScrollDelta.Y;
|
2018-11-22 11:13:40 +00:00
|
|
|
|
|
2020-07-17 07:03:13 +00:00
|
|
|
|
double scrollDirection = Math.Sign(scrollComponent);
|
|
|
|
|
|
|
|
|
|
// this is a special case to handle the "pivot" scenario.
|
|
|
|
|
// if we are precise scrolling in one direction then change our mind and scroll backwards,
|
|
|
|
|
// the existing accumulation should be applied in the inverse direction to maintain responsiveness.
|
2020-08-31 09:01:16 +00:00
|
|
|
|
if (scrollAccumulation != 0 && Math.Sign(scrollAccumulation) != scrollDirection)
|
2020-07-17 07:03:13 +00:00
|
|
|
|
scrollAccumulation = scrollDirection * (precision - Math.Abs(scrollAccumulation));
|
|
|
|
|
|
|
|
|
|
scrollAccumulation += scrollComponent * (e.IsPrecise ? 0.1 : 1);
|
|
|
|
|
|
|
|
|
|
// because we are doing snapped seeking, we need to add up precise scrolls until they accumulate to an arbitrary cut-off.
|
|
|
|
|
while (Math.Abs(scrollAccumulation) >= precision)
|
2018-11-22 11:13:40 +00:00
|
|
|
|
{
|
|
|
|
|
if (scrollAccumulation > 0)
|
2018-11-30 06:47:55 +00:00
|
|
|
|
seek(e, -1);
|
2018-11-22 11:13:40 +00:00
|
|
|
|
else
|
2018-11-30 06:47:55 +00:00
|
|
|
|
seek(e, 1);
|
2018-11-22 11:13:40 +00:00
|
|
|
|
|
|
|
|
|
scrollAccumulation = scrollAccumulation < 0 ? Math.Min(0, scrollAccumulation + precision) : Math.Max(0, scrollAccumulation - precision);
|
|
|
|
|
}
|
2018-11-22 10:40:44 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-30 10:31:31 +00:00
|
|
|
|
public bool OnPressed(GlobalAction action)
|
|
|
|
|
{
|
2020-09-22 06:55:25 +00:00
|
|
|
|
switch (action)
|
2019-06-30 10:31:31 +00:00
|
|
|
|
{
|
2020-09-22 06:55:25 +00:00
|
|
|
|
case GlobalAction.Back:
|
|
|
|
|
// as we don't want to display the back button, manual handling of exit action is required.
|
|
|
|
|
this.Exit();
|
|
|
|
|
return true;
|
2019-06-30 10:31:31 +00:00
|
|
|
|
|
2020-09-22 06:55:25 +00:00
|
|
|
|
case GlobalAction.EditorComposeMode:
|
|
|
|
|
menuBar.Mode.Value = EditorScreenMode.Compose;
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case GlobalAction.EditorDesignMode:
|
|
|
|
|
menuBar.Mode.Value = EditorScreenMode.Design;
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case GlobalAction.EditorTimingMode:
|
|
|
|
|
menuBar.Mode.Value = EditorScreenMode.Timing;
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case GlobalAction.EditorSetupMode:
|
|
|
|
|
menuBar.Mode.Value = EditorScreenMode.SongSetup;
|
|
|
|
|
return true;
|
|
|
|
|
|
2021-03-28 15:36:22 +00:00
|
|
|
|
case GlobalAction.EditorVerifyMode:
|
|
|
|
|
menuBar.Mode.Value = EditorScreenMode.Verify;
|
|
|
|
|
return true;
|
|
|
|
|
|
2020-09-22 06:55:25 +00:00
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-06-30 10:31:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-22 04:22:34 +00:00
|
|
|
|
public void OnReleased(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-06-30 10:31:31 +00:00
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
public override void OnEntering(IScreen last)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
2019-07-10 15:22:40 +00:00
|
|
|
|
|
2021-01-04 09:32:23 +00:00
|
|
|
|
ApplyToBackground(b =>
|
|
|
|
|
{
|
|
|
|
|
// todo: temporary. we want to be applying dim using the UserDimContainer eventually.
|
|
|
|
|
b.FadeColour(Color4.DarkGray, 500);
|
2019-11-08 09:51:01 +00:00
|
|
|
|
|
2021-04-13 06:24:35 +00:00
|
|
|
|
b.IgnoreUserSettings.Value = true;
|
2021-01-04 09:32:23 +00:00
|
|
|
|
b.BlurAmount.Value = 0;
|
|
|
|
|
});
|
2019-12-12 04:04:32 +00:00
|
|
|
|
|
2019-11-08 09:51:01 +00:00
|
|
|
|
resetTrack(true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
public override bool OnExiting(IScreen next)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-10-04 14:57:28 +00:00
|
|
|
|
if (!exitConfirmed)
|
2020-09-09 10:31:18 +00:00
|
|
|
|
{
|
2021-05-19 07:28:25 +00:00
|
|
|
|
// dialog overlay may not be available in visual tests.
|
|
|
|
|
if (dialogOverlay == null)
|
2020-10-04 14:57:28 +00:00
|
|
|
|
{
|
|
|
|
|
confirmExit();
|
2021-05-19 07:28:25 +00:00
|
|
|
|
return true;
|
2020-10-04 14:57:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 07:28:25 +00:00
|
|
|
|
// if the dialog is already displayed, confirm exit with no save.
|
|
|
|
|
if (dialogOverlay.CurrentDialog is PromptForSaveDialog saveDialog)
|
2020-10-04 14:57:28 +00:00
|
|
|
|
{
|
2021-05-19 07:28:25 +00:00
|
|
|
|
saveDialog.PerformOkAction();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-10-28 04:32:39 +00:00
|
|
|
|
|
2021-05-19 07:28:25 +00:00
|
|
|
|
if (isNewBeatmap || HasUnsavedChanges)
|
|
|
|
|
{
|
2021-09-06 19:27:17 +00:00
|
|
|
|
dialogOverlay?.Push(new PromptForSaveDialog(confirmExit, confirmExitWithSave, cancelExit));
|
2020-10-04 14:57:28 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-09-09 10:31:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-04 09:32:23 +00:00
|
|
|
|
ApplyToBackground(b => b.FadeColour(Color4.White, 500));
|
2019-07-10 15:22:40 +00:00
|
|
|
|
resetTrack();
|
2019-07-10 08:43:02 +00:00
|
|
|
|
|
2021-05-20 06:39:29 +00:00
|
|
|
|
// To update the game-wide beatmap with any changes, perform a re-fetch on exit.
|
|
|
|
|
// This is required as the editor makes its local changes via EditorBeatmap
|
|
|
|
|
// (which are not propagated outwards to a potentially cached WorkingBeatmap).
|
2021-05-19 08:58:28 +00:00
|
|
|
|
var refetchedBeatmap = beatmapManager.GetWorkingBeatmap(Beatmap.Value.BeatmapInfo);
|
|
|
|
|
|
|
|
|
|
if (!(refetchedBeatmap is DummyWorkingBeatmap))
|
|
|
|
|
Beatmap.Value = refetchedBeatmap;
|
2021-01-04 07:37:49 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
2019-07-10 15:22:40 +00:00
|
|
|
|
|
2020-09-09 10:31:18 +00:00
|
|
|
|
private void confirmExitWithSave()
|
|
|
|
|
{
|
2020-09-09 10:57:28 +00:00
|
|
|
|
Save();
|
2021-05-19 07:28:25 +00:00
|
|
|
|
|
|
|
|
|
exitConfirmed = true;
|
|
|
|
|
this.Exit();
|
2020-09-09 10:31:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void confirmExit()
|
|
|
|
|
{
|
2020-10-09 04:11:44 +00:00
|
|
|
|
// stop the track if playing to allow the parent screen to choose a suitable playback mode.
|
|
|
|
|
Beatmap.Value.Track.Stop();
|
|
|
|
|
|
2020-10-04 14:47:16 +00:00
|
|
|
|
if (isNewBeatmap)
|
|
|
|
|
{
|
|
|
|
|
// confirming exit without save means we should delete the new beatmap completely.
|
|
|
|
|
beatmapManager.Delete(playableBeatmap.BeatmapInfo.BeatmapSet);
|
2020-10-09 04:11:44 +00:00
|
|
|
|
|
2020-11-07 19:31:44 +00:00
|
|
|
|
// eagerly clear contents before restoring default beatmap to prevent value change callbacks from firing.
|
|
|
|
|
ClearInternal();
|
|
|
|
|
|
2020-10-09 04:11:44 +00:00
|
|
|
|
// in theory this shouldn't be required but due to EF core not sharing instance states 100%
|
|
|
|
|
// MusicController is unaware of the changed DeletePending state.
|
|
|
|
|
Beatmap.SetDefault();
|
2020-10-04 14:47:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-09 10:31:18 +00:00
|
|
|
|
exitConfirmed = true;
|
2021-05-19 07:28:25 +00:00
|
|
|
|
this.Exit();
|
2020-09-09 10:31:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-11 10:54:20 +00:00
|
|
|
|
private readonly Bindable<string> clipboard = new Bindable<string>();
|
|
|
|
|
|
|
|
|
|
protected void Cut()
|
|
|
|
|
{
|
|
|
|
|
Copy();
|
2020-10-06 13:09:48 +00:00
|
|
|
|
editorBeatmap.RemoveRange(editorBeatmap.SelectedHitObjects.ToArray());
|
2020-09-11 10:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Copy()
|
|
|
|
|
{
|
2020-09-12 06:33:13 +00:00
|
|
|
|
if (editorBeatmap.SelectedHitObjects.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-09-11 10:54:20 +00:00
|
|
|
|
clipboard.Value = new ClipboardContent(editorBeatmap).Serialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Paste()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(clipboard.Value))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var objects = clipboard.Value.Deserialize<ClipboardContent>().HitObjects;
|
2020-09-12 06:33:13 +00:00
|
|
|
|
|
|
|
|
|
Debug.Assert(objects.Any());
|
|
|
|
|
|
2020-09-13 13:53:30 +00:00
|
|
|
|
double timeOffset = clock.CurrentTime - objects.Min(o => o.StartTime);
|
2020-09-11 10:54:20 +00:00
|
|
|
|
|
|
|
|
|
foreach (var h in objects)
|
|
|
|
|
h.StartTime += timeOffset;
|
|
|
|
|
|
2020-10-08 08:43:27 +00:00
|
|
|
|
editorBeatmap.BeginChange();
|
2020-09-14 05:45:49 +00:00
|
|
|
|
|
2020-09-11 14:02:23 +00:00
|
|
|
|
editorBeatmap.SelectedHitObjects.Clear();
|
|
|
|
|
|
2020-09-11 10:54:20 +00:00
|
|
|
|
editorBeatmap.AddRange(objects);
|
2020-09-11 14:02:23 +00:00
|
|
|
|
editorBeatmap.SelectedHitObjects.AddRange(objects);
|
2020-09-14 05:45:49 +00:00
|
|
|
|
|
2020-10-08 08:43:27 +00:00
|
|
|
|
editorBeatmap.EndChange();
|
2020-09-11 10:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-22 09:14:21 +00:00
|
|
|
|
protected void Undo() => changeHandler.RestoreState(-1);
|
2020-04-09 12:22:07 +00:00
|
|
|
|
|
2020-04-22 09:14:21 +00:00
|
|
|
|
protected void Redo() => changeHandler.RestoreState(1);
|
2020-04-09 12:22:07 +00:00
|
|
|
|
|
2019-11-08 09:51:01 +00:00
|
|
|
|
private void resetTrack(bool seekToStart = false)
|
2019-07-10 15:22:40 +00:00
|
|
|
|
{
|
2021-05-07 06:53:54 +00:00
|
|
|
|
Beatmap.Value.Track.Stop();
|
2019-11-08 09:51:01 +00:00
|
|
|
|
|
|
|
|
|
if (seekToStart)
|
|
|
|
|
{
|
|
|
|
|
double targetTime = 0;
|
|
|
|
|
|
|
|
|
|
if (Beatmap.Value.Beatmap.HitObjects.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
// seek to one beat length before the first hitobject
|
|
|
|
|
targetTime = Beatmap.Value.Beatmap.HitObjects[0].StartTime;
|
|
|
|
|
targetTime -= Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(targetTime).BeatLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clock.Seek(Math.Max(0, targetTime));
|
|
|
|
|
}
|
2019-07-10 15:22:40 +00:00
|
|
|
|
}
|
2018-11-30 05:57:25 +00:00
|
|
|
|
|
2019-02-21 09:56:34 +00:00
|
|
|
|
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
|
2018-11-30 05:57:25 +00:00
|
|
|
|
{
|
2020-09-24 08:03:54 +00:00
|
|
|
|
var lastScreen = currentScreen;
|
|
|
|
|
|
2021-08-25 13:58:06 +00:00
|
|
|
|
lastScreen?.Hide();
|
2020-09-24 08:03:54 +00:00
|
|
|
|
|
2020-10-27 05:31:56 +00:00
|
|
|
|
try
|
2020-09-24 08:03:54 +00:00
|
|
|
|
{
|
2020-10-27 05:31:56 +00:00
|
|
|
|
if ((currentScreen = screenContainer.SingleOrDefault(s => s.Type == e.NewValue)) != null)
|
|
|
|
|
{
|
|
|
|
|
screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
|
2021-08-25 13:58:06 +00:00
|
|
|
|
currentScreen.Show();
|
2020-10-27 05:31:56 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-11-30 05:57:25 +00:00
|
|
|
|
|
2020-10-27 05:31:56 +00:00
|
|
|
|
switch (e.NewValue)
|
|
|
|
|
{
|
|
|
|
|
case EditorScreenMode.SongSetup:
|
|
|
|
|
currentScreen = new SetupScreen();
|
|
|
|
|
break;
|
2019-10-08 05:23:13 +00:00
|
|
|
|
|
2020-10-27 05:31:56 +00:00
|
|
|
|
case EditorScreenMode.Compose:
|
|
|
|
|
currentScreen = new ComposeScreen();
|
|
|
|
|
break;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2020-10-27 05:31:56 +00:00
|
|
|
|
case EditorScreenMode.Design:
|
|
|
|
|
currentScreen = new DesignScreen();
|
|
|
|
|
break;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2020-10-27 05:31:56 +00:00
|
|
|
|
case EditorScreenMode.Timing:
|
|
|
|
|
currentScreen = new TimingScreen();
|
|
|
|
|
break;
|
2021-03-28 15:36:22 +00:00
|
|
|
|
|
|
|
|
|
case EditorScreenMode.Verify:
|
|
|
|
|
currentScreen = new VerifyScreen();
|
|
|
|
|
break;
|
2021-05-14 03:04:38 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode");
|
2020-10-27 05:31:56 +00:00
|
|
|
|
}
|
2018-11-30 05:57:25 +00:00
|
|
|
|
|
2020-10-27 05:31:56 +00:00
|
|
|
|
LoadComponentAsync(currentScreen, newScreen =>
|
|
|
|
|
{
|
|
|
|
|
if (newScreen == currentScreen)
|
2021-08-25 13:58:06 +00:00
|
|
|
|
{
|
2020-10-27 05:31:56 +00:00
|
|
|
|
screenContainer.Add(newScreen);
|
2021-08-25 13:58:06 +00:00
|
|
|
|
newScreen.Show();
|
|
|
|
|
}
|
2020-10-27 05:31:56 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
finally
|
2020-09-08 10:50:29 +00:00
|
|
|
|
{
|
2020-10-27 05:31:56 +00:00
|
|
|
|
updateSampleDisabledState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateSampleDisabledState()
|
|
|
|
|
{
|
|
|
|
|
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value || !(currentScreen is ComposeScreen);
|
2018-11-30 05:57:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 06:47:55 +00:00
|
|
|
|
private void seek(UIEvent e, int direction)
|
2018-11-30 05:57:25 +00:00
|
|
|
|
{
|
2020-10-06 08:47:22 +00:00
|
|
|
|
double amount = e.ShiftPressed ? 4 : 1;
|
2018-11-30 05:57:25 +00:00
|
|
|
|
|
2020-10-16 04:07:00 +00:00
|
|
|
|
bool trackPlaying = clock.IsRunning;
|
|
|
|
|
|
|
|
|
|
if (trackPlaying)
|
|
|
|
|
{
|
|
|
|
|
// generally users are not looking to perform tiny seeks when the track is playing,
|
|
|
|
|
// so seeks should always be by one full beat, bypassing the beatDivisor.
|
|
|
|
|
// this multiplication undoes the division that will be applied in the underlying seek operation.
|
|
|
|
|
amount *= beatDivisor.Value;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 05:57:25 +00:00
|
|
|
|
if (direction < 1)
|
2020-10-16 04:07:00 +00:00
|
|
|
|
clock.SeekBackward(!trackPlaying, amount);
|
2018-11-30 05:57:25 +00:00
|
|
|
|
else
|
2020-10-16 04:07:00 +00:00
|
|
|
|
clock.SeekForward(!trackPlaying, amount);
|
2018-11-30 05:57:25 +00:00
|
|
|
|
}
|
2020-01-14 10:05:52 +00:00
|
|
|
|
|
2020-01-15 04:48:28 +00:00
|
|
|
|
private void exportBeatmap()
|
|
|
|
|
{
|
2020-09-09 10:57:28 +00:00
|
|
|
|
Save();
|
2020-01-15 04:48:28 +00:00
|
|
|
|
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
|
|
|
|
|
}
|
2020-01-23 05:39:56 +00:00
|
|
|
|
|
2020-09-09 10:40:41 +00:00
|
|
|
|
private void updateLastSavedHash()
|
|
|
|
|
{
|
|
|
|
|
lastSavedHash = changeHandler.CurrentStateHash;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 06:52:24 +00:00
|
|
|
|
private List<MenuItem> createFileMenuItems()
|
|
|
|
|
{
|
|
|
|
|
var fileMenuItems = new List<MenuItem>
|
|
|
|
|
{
|
|
|
|
|
new EditorMenuItem("Save", MenuItemType.Standard, Save)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (RuntimeInfo.IsDesktop)
|
|
|
|
|
fileMenuItems.Add(new EditorMenuItem("Export package", MenuItemType.Standard, exportBeatmap));
|
|
|
|
|
|
2021-09-05 14:07:24 +00:00
|
|
|
|
fileMenuItems.Add(new EditorMenuItemSpacer());
|
|
|
|
|
|
|
|
|
|
var beatmapSet = beatmapManager.QueryBeatmapSet(bs => bs.ID == Beatmap.Value.BeatmapSetInfo.ID) ?? playableBeatmap.BeatmapInfo.BeatmapSet;
|
2021-09-05 19:00:19 +00:00
|
|
|
|
|
|
|
|
|
var difficultyItems = new List<MenuItem>();
|
|
|
|
|
|
|
|
|
|
foreach (var rulesetBeatmaps in beatmapSet.Beatmaps.GroupBy(b => b.RulesetID).OrderBy(group => group.Key))
|
|
|
|
|
{
|
|
|
|
|
if (difficultyItems.Count > 0)
|
|
|
|
|
difficultyItems.Add(new EditorMenuItemSpacer());
|
|
|
|
|
|
|
|
|
|
foreach (var beatmap in rulesetBeatmaps.OrderBy(b => b.StarDifficulty))
|
|
|
|
|
difficultyItems.Add(createDifficultyMenuItem(beatmap));
|
|
|
|
|
}
|
2021-09-05 14:07:24 +00:00
|
|
|
|
|
|
|
|
|
fileMenuItems.Add(new EditorMenuItem("Change difficulty") { Items = difficultyItems });
|
|
|
|
|
|
2021-03-17 06:52:24 +00:00
|
|
|
|
fileMenuItems.Add(new EditorMenuItemSpacer());
|
|
|
|
|
fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));
|
|
|
|
|
return fileMenuItems;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-05 15:26:09 +00:00
|
|
|
|
private DifficultyMenuItem createDifficultyMenuItem(BeatmapInfo beatmapInfo)
|
2021-09-05 14:28:32 +00:00
|
|
|
|
{
|
2021-09-05 15:26:09 +00:00
|
|
|
|
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmapInfo);
|
|
|
|
|
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, switchToDifficulty);
|
|
|
|
|
}
|
2021-09-05 14:28:32 +00:00
|
|
|
|
|
2021-09-05 15:26:09 +00:00
|
|
|
|
private void switchToDifficulty(BeatmapInfo beatmapInfo)
|
|
|
|
|
{
|
2021-09-05 15:53:57 +00:00
|
|
|
|
if (loader == null)
|
|
|
|
|
return;
|
2021-09-05 14:28:32 +00:00
|
|
|
|
|
2021-09-05 15:53:57 +00:00
|
|
|
|
loader.ValidForResume = true;
|
|
|
|
|
this.Exit();
|
2021-09-05 17:11:46 +00:00
|
|
|
|
loader.ScheduleDifficultySwitch(beatmapInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-06 19:27:17 +00:00
|
|
|
|
private void cancelExit()
|
2021-09-05 17:11:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (loader == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
loader.ValidForResume = false;
|
|
|
|
|
loader.CancelDifficultySwitch();
|
2021-09-05 14:28:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-28 03:48:24 +00:00
|
|
|
|
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
2020-01-23 05:39:56 +00:00
|
|
|
|
|
2020-01-23 06:31:56 +00:00
|
|
|
|
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
2020-01-23 05:39:56 +00:00
|
|
|
|
|
|
|
|
|
public int BeatDivisor => beatDivisor.Value;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|