2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2018-11-22 18:40:44 +08:00
|
|
|
|
using System;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-06-19 19:19:52 +08:00
|
|
|
|
using osu.Framework.Platform;
|
2020-08-21 15:58:45 +08:00
|
|
|
|
using osu.Framework.Timing;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Screens.Edit.Components;
|
2018-11-06 17:28:22 +08:00
|
|
|
|
using osu.Game.Screens.Edit.Components.Menus;
|
2018-11-07 12:04:17 +08:00
|
|
|
|
using osu.Game.Screens.Edit.Design;
|
2018-11-30 13:57:25 +08:00
|
|
|
|
using osuTK.Input;
|
2020-02-25 17:59:16 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Framework;
|
2020-04-22 16:41:24 +08:00
|
|
|
|
using osu.Framework.Input;
|
2019-06-30 18:31:31 +08:00
|
|
|
|
using osu.Framework.Input.Bindings;
|
2020-03-13 13:28:11 +08:00
|
|
|
|
using osu.Framework.Logging;
|
2019-12-27 18:46:33 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2019-11-07 21:51:49 +08:00
|
|
|
|
using osu.Game.Graphics.Cursor;
|
2019-06-30 18:31:31 +08:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2020-01-23 13:39:56 +08:00
|
|
|
|
using osu.Game.Rulesets.Edit;
|
2019-10-09 15:04:58 +08:00
|
|
|
|
using osu.Game.Screens.Edit.Compose;
|
2019-10-08 13:23:13 +08:00
|
|
|
|
using osu.Game.Screens.Edit.Setup;
|
|
|
|
|
using osu.Game.Screens.Edit.Timing;
|
2019-12-12 12:04:32 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
2019-04-13 04:54:35 +08:00
|
|
|
|
using osu.Game.Users;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit
|
|
|
|
|
{
|
2020-01-23 13:39:56 +08:00
|
|
|
|
[Cached(typeof(IBeatSnapProvider))]
|
2020-04-22 16:41:24 +08:00
|
|
|
|
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-06 17:11:56 +08:00
|
|
|
|
public override float BackgroundParallaxAmount => 0.1f;
|
|
|
|
|
|
2019-06-25 15:55:49 +08:00
|
|
|
|
public override bool AllowBackButton => false;
|
|
|
|
|
|
2019-01-28 14:41:54 +08:00
|
|
|
|
public override bool HideOverlaysOnEnter => true;
|
2019-02-01 14:42:15 +08:00
|
|
|
|
|
|
|
|
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-01-24 12:10:02 +08:00
|
|
|
|
public override bool AllowRateAdjustments => false;
|
|
|
|
|
|
2020-01-10 18:57:34 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapManager beatmapManager { get; set; }
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private Box bottomBackground;
|
|
|
|
|
private Container screenContainer;
|
|
|
|
|
|
|
|
|
|
private EditorScreen currentScreen;
|
|
|
|
|
|
|
|
|
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
|
|
|
|
private EditorClock clock;
|
|
|
|
|
|
2019-12-27 18:46:33 +08:00
|
|
|
|
private IBeatmap playableBeatmap;
|
|
|
|
|
private EditorBeatmap editorBeatmap;
|
2020-04-09 20:22:07 +08:00
|
|
|
|
private EditorChangeHandler changeHandler;
|
2019-12-27 18:46:33 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private DependencyContainer dependencies;
|
|
|
|
|
|
2019-06-12 15:33:15 +08:00
|
|
|
|
protected override UserActivity InitialActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo);
|
2019-04-13 04:54:35 +08:00
|
|
|
|
|
2018-07-11 16:07:14 +08:00
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
|
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-06-19 19:19:52 +08:00
|
|
|
|
private void load(OsuColour colours, GameHost host)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-08 16:12:47 +08:00
|
|
|
|
beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
|
|
|
|
|
beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
|
|
|
|
|
|
|
|
|
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
2020-08-21 15:58:45 +08:00
|
|
|
|
var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();
|
2020-08-11 23:48:38 +08:00
|
|
|
|
clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false };
|
2020-08-21 15:58:45 +08:00
|
|
|
|
clock.ChangeSource(sourceClock);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-05-22 15:37:28 +08:00
|
|
|
|
dependencies.CacheAs(clock);
|
2020-05-22 15:40:52 +08:00
|
|
|
|
AddInternal(clock);
|
2020-01-23 13:39:56 +08:00
|
|
|
|
|
|
|
|
|
// todo: remove caching of this and consume via editorBeatmap?
|
2018-04-13 17:19:50 +08:00
|
|
|
|
dependencies.Cache(beatDivisor);
|
2020-01-23 13:39:56 +08:00
|
|
|
|
|
2020-03-13 13:28:11 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2020-03-16 10:29:28 +08:00
|
|
|
|
Logger.Error(e, "Could not load beatmap successfully!");
|
|
|
|
|
// couldn't load, hard abort!
|
2020-03-13 13:28:11 +08:00
|
|
|
|
this.Exit();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-05 16:32:33 +08:00
|
|
|
|
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap));
|
2019-12-27 18:46:33 +08:00
|
|
|
|
dependencies.CacheAs(editorBeatmap);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-09 20:22:07 +08:00
|
|
|
|
changeHandler = new EditorChangeHandler(editorBeatmap);
|
|
|
|
|
dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
EditorMenuBar menuBar;
|
2020-04-16 12:25:08 +08:00
|
|
|
|
OsuMenuItem undoMenuItem;
|
|
|
|
|
OsuMenuItem redoMenuItem;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-25 19:52:33 +08:00
|
|
|
|
var fileMenuItems = new List<MenuItem>
|
|
|
|
|
{
|
|
|
|
|
new EditorMenuItem("Save", MenuItemType.Standard, saveBeatmap)
|
|
|
|
|
};
|
2020-02-25 17:59:16 +08:00
|
|
|
|
|
|
|
|
|
if (RuntimeInfo.IsDesktop)
|
|
|
|
|
fileMenuItems.Add(new EditorMenuItem("Export package", MenuItemType.Standard, exportBeatmap));
|
|
|
|
|
|
|
|
|
|
fileMenuItems.Add(new EditorMenuItemSpacer());
|
|
|
|
|
fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));
|
|
|
|
|
|
2020-02-05 16:16:15 +08:00
|
|
|
|
AddInternal(new OsuContextMenuContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
Name = "Screen container",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-11-07 21:51:49 +08:00
|
|
|
|
Padding = new MarginPadding { Top = 40, Bottom = 60 },
|
|
|
|
|
Child = screenContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
Name = "Top bar",
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 40,
|
|
|
|
|
Child = menuBar = new EditorMenuBar
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Items = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
new MenuItem("File")
|
|
|
|
|
{
|
2020-02-25 17:59:16 +08:00
|
|
|
|
Items = fileMenuItems
|
2020-04-09 20:22:07 +08:00
|
|
|
|
},
|
|
|
|
|
new MenuItem("Edit")
|
|
|
|
|
{
|
|
|
|
|
Items = new[]
|
|
|
|
|
{
|
2020-04-22 17:14:21 +08:00
|
|
|
|
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
|
|
|
|
|
redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, Redo)
|
2020-04-09 20:22:07 +08:00
|
|
|
|
}
|
2019-11-07 21:51:49 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-07 21:51:49 +08:00
|
|
|
|
},
|
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
Name = "Bottom bar",
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 60,
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
bottomBackground = new Box { RelativeSizeAxes = Axes.Both },
|
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-11-07 21:51:49 +08:00
|
|
|
|
Padding = new MarginPadding { Vertical = 5, Horizontal = 10 },
|
|
|
|
|
Child = new GridContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColumnDimensions = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08:00
|
|
|
|
new Dimension(GridSizeMode.Absolute, 220),
|
|
|
|
|
new Dimension(),
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, 220)
|
|
|
|
|
},
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-07 21:51:49 +08: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 17:19:50 +08:00
|
|
|
|
},
|
2019-11-07 21:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-11-07 21:51:49 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2020-02-05 16:16:15 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-16 12:25:08 +08:00
|
|
|
|
changeHandler.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
|
|
|
|
changeHandler.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
menuBar.Mode.ValueChanged += onModeChanged;
|
|
|
|
|
|
|
|
|
|
bottomBackground.Colour = colours.Gray2;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 17:21:53 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
clock.ProcessFrame();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-22 16:41:24 +08:00
|
|
|
|
public bool OnPressed(PlatformAction action)
|
|
|
|
|
{
|
|
|
|
|
switch (action.ActionType)
|
|
|
|
|
{
|
|
|
|
|
case PlatformActionType.Undo:
|
2020-04-22 17:14:21 +08:00
|
|
|
|
Undo();
|
2020-04-22 16:41:24 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case PlatformActionType.Redo:
|
2020-04-22 17:14:21 +08:00
|
|
|
|
Redo();
|
2020-04-22 16:41:24 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case PlatformActionType.Save:
|
|
|
|
|
saveBeatmap();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnReleased(PlatformAction action)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 13:57:25 +08:00
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-11-30 13:57:25 +08:00
|
|
|
|
switch (e.Key)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-11-30 13:57:25 +08:00
|
|
|
|
case Key.Left:
|
2018-11-30 14:47:55 +08:00
|
|
|
|
seek(e, -1);
|
2018-11-30 13:57:25 +08:00
|
|
|
|
return true;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-11-30 13:57:25 +08:00
|
|
|
|
case Key.Right:
|
2018-11-30 14:47:55 +08:00
|
|
|
|
seek(e, 1);
|
2018-11-30 13:57:25 +08:00
|
|
|
|
return true;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 13:57:25 +08:00
|
|
|
|
return base.OnKeyDown(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-22 18:40:44 +08:00
|
|
|
|
private double scrollAccumulation;
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnScroll(ScrollEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-07-17 15:03:13 +08:00
|
|
|
|
const double precision = 1;
|
2018-11-22 18:40:44 +08:00
|
|
|
|
|
2020-07-17 15:03:13 +08:00
|
|
|
|
double scrollComponent = e.ScrollDelta.X + e.ScrollDelta.Y;
|
2018-11-22 19:13:40 +08:00
|
|
|
|
|
2020-07-17 15:03:13 +08: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.
|
|
|
|
|
if (Math.Sign(scrollAccumulation) != scrollDirection)
|
|
|
|
|
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 19:13:40 +08:00
|
|
|
|
{
|
|
|
|
|
if (scrollAccumulation > 0)
|
2018-11-30 14:47:55 +08:00
|
|
|
|
seek(e, -1);
|
2018-11-22 19:13:40 +08:00
|
|
|
|
else
|
2018-11-30 14:47:55 +08:00
|
|
|
|
seek(e, 1);
|
2018-11-22 19:13:40 +08:00
|
|
|
|
|
|
|
|
|
scrollAccumulation = scrollAccumulation < 0 ? Math.Min(0, scrollAccumulation + precision) : Math.Max(0, scrollAccumulation - precision);
|
|
|
|
|
}
|
2018-11-22 18:40:44 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-30 18:31:31 +08:00
|
|
|
|
public bool OnPressed(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
if (action == GlobalAction.Back)
|
|
|
|
|
{
|
2019-06-30 19:46:51 +08:00
|
|
|
|
// as we don't want to display the back button, manual handling of exit action is required.
|
2019-06-30 18:31:31 +08:00
|
|
|
|
this.Exit();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-22 12:22:34 +08:00
|
|
|
|
public void OnReleased(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-06-30 18:31:31 +08:00
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override void OnEntering(IScreen last)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
2019-07-10 23:22:40 +08:00
|
|
|
|
|
2019-12-12 12:04:32 +08:00
|
|
|
|
// todo: temporary. we want to be applying dim using the UserDimContainer eventually.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Background.FadeColour(Color4.DarkGray, 500);
|
2019-11-08 17:51:01 +08:00
|
|
|
|
|
2019-12-12 12:04:32 +08:00
|
|
|
|
Background.EnableUserDim.Value = false;
|
|
|
|
|
Background.BlurAmount.Value = 0;
|
|
|
|
|
|
2019-11-08 17:51:01 +08:00
|
|
|
|
resetTrack(true);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override bool OnExiting(IScreen next)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Background.FadeColour(Color4.White, 500);
|
2019-07-10 23:22:40 +08:00
|
|
|
|
resetTrack();
|
2019-07-10 16:43:02 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
2019-07-10 23:22:40 +08:00
|
|
|
|
|
2020-04-22 17:14:21 +08:00
|
|
|
|
protected void Undo() => changeHandler.RestoreState(-1);
|
2020-04-09 20:22:07 +08:00
|
|
|
|
|
2020-04-22 17:14:21 +08:00
|
|
|
|
protected void Redo() => changeHandler.RestoreState(1);
|
2020-04-09 20:22:07 +08:00
|
|
|
|
|
2019-11-08 17:51:01 +08:00
|
|
|
|
private void resetTrack(bool seekToStart = false)
|
2019-07-10 23:22:40 +08:00
|
|
|
|
{
|
2020-08-21 15:58:45 +08:00
|
|
|
|
Beatmap.Value.Track?.Stop();
|
2019-11-08 17:51:01 +08: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 23:22:40 +08:00
|
|
|
|
}
|
2018-11-30 13:57:25 +08:00
|
|
|
|
|
2019-02-21 17:56:34 +08:00
|
|
|
|
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
|
2018-11-30 13:57:25 +08:00
|
|
|
|
{
|
|
|
|
|
currentScreen?.Exit();
|
|
|
|
|
|
2019-02-21 17:56:34 +08:00
|
|
|
|
switch (e.NewValue)
|
2018-11-30 13:57:25 +08:00
|
|
|
|
{
|
2019-10-08 13:23:13 +08:00
|
|
|
|
case EditorScreenMode.SongSetup:
|
|
|
|
|
currentScreen = new SetupScreen();
|
|
|
|
|
break;
|
|
|
|
|
|
2018-11-30 13:57:25 +08:00
|
|
|
|
case EditorScreenMode.Compose:
|
|
|
|
|
currentScreen = new ComposeScreen();
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-11-30 13:57:25 +08:00
|
|
|
|
case EditorScreenMode.Design:
|
|
|
|
|
currentScreen = new DesignScreen();
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2019-10-08 13:23:13 +08:00
|
|
|
|
case EditorScreenMode.Timing:
|
|
|
|
|
currentScreen = new TimingScreen();
|
|
|
|
|
break;
|
2018-11-30 13:57:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LoadComponentAsync(currentScreen, screenContainer.Add);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 14:47:55 +08:00
|
|
|
|
private void seek(UIEvent e, int direction)
|
2018-11-30 13:57:25 +08:00
|
|
|
|
{
|
2018-11-30 14:47:55 +08:00
|
|
|
|
double amount = e.ShiftPressed ? 2 : 1;
|
2018-11-30 13:57:25 +08:00
|
|
|
|
|
|
|
|
|
if (direction < 1)
|
|
|
|
|
clock.SeekBackward(!clock.IsRunning, amount);
|
|
|
|
|
else
|
|
|
|
|
clock.SeekForward(!clock.IsRunning, amount);
|
|
|
|
|
}
|
2020-01-14 18:05:52 +08:00
|
|
|
|
|
|
|
|
|
private void saveBeatmap() => beatmapManager.Save(playableBeatmap.BeatmapInfo, editorBeatmap);
|
2020-01-15 12:48:28 +08:00
|
|
|
|
|
|
|
|
|
private void exportBeatmap()
|
|
|
|
|
{
|
|
|
|
|
saveBeatmap();
|
|
|
|
|
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
|
|
|
|
|
}
|
2020-01-23 13:39:56 +08:00
|
|
|
|
|
2020-01-28 11:48:24 +08:00
|
|
|
|
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
2020-01-23 13:39:56 +08:00
|
|
|
|
|
2020-01-23 14:31:56 +08:00
|
|
|
|
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
2020-01-23 13:39:56 +08:00
|
|
|
|
|
|
|
|
|
public int BeatDivisor => beatDivisor.Value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|