mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 17:02:55 +08:00
Move editor mode selector out of EditorMenuBar
to allow for better reuse
This commit is contained in:
parent
09a74cdfc6
commit
f15b8781bb
@ -4,11 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Testing;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.Menus;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editing
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
{
|
{
|
||||||
@ -22,7 +20,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("switch between all screens at once", () =>
|
AddStep("switch between all screens at once", () =>
|
||||||
{
|
{
|
||||||
foreach (var screen in Enum.GetValues(typeof(EditorScreenMode)).Cast<EditorScreenMode>())
|
foreach (var screen in Enum.GetValues(typeof(EditorScreenMode)).Cast<EditorScreenMode>())
|
||||||
Editor.ChildrenOfType<EditorMenuBar>().Single().Mode.Value = screen;
|
Editor.Mode.Value = screen;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -18,8 +17,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
|||||||
{
|
{
|
||||||
public class EditorMenuBar : OsuMenu
|
public class EditorMenuBar : OsuMenu
|
||||||
{
|
{
|
||||||
public readonly Bindable<EditorScreenMode> Mode = new Bindable<EditorScreenMode>();
|
|
||||||
|
|
||||||
public EditorMenuBar()
|
public EditorMenuBar()
|
||||||
: base(Direction.Horizontal, true)
|
: base(Direction.Horizontal, true)
|
||||||
{
|
{
|
||||||
@ -28,25 +25,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
|||||||
MaskingContainer.CornerRadius = 0;
|
MaskingContainer.CornerRadius = 0;
|
||||||
ItemsContainer.Padding = new MarginPadding { Left = 100 };
|
ItemsContainer.Padding = new MarginPadding { Left = 100 };
|
||||||
BackgroundColour = Color4Extensions.FromHex("111");
|
BackgroundColour = Color4Extensions.FromHex("111");
|
||||||
|
|
||||||
ScreenSelectionTabControl tabControl;
|
|
||||||
AddRangeInternal(new Drawable[]
|
|
||||||
{
|
|
||||||
tabControl = new ScreenSelectionTabControl
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomRight,
|
|
||||||
Origin = Anchor.BottomRight,
|
|
||||||
X = -15
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Mode.BindTo(tabControl.Current);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
Mode.TriggerChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
||||||
|
@ -89,6 +89,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private NotificationOverlay notifications { get; set; }
|
private NotificationOverlay notifications { get; set; }
|
||||||
|
|
||||||
|
public readonly Bindable<EditorScreenMode> Mode = new Bindable<EditorScreenMode>();
|
||||||
|
|
||||||
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
||||||
|
|
||||||
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
||||||
@ -115,8 +117,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
[CanBeNull] // Should be non-null once it can support custom rulesets.
|
[CanBeNull] // Should be non-null once it can support custom rulesets.
|
||||||
private EditorChangeHandler changeHandler;
|
private EditorChangeHandler changeHandler;
|
||||||
|
|
||||||
private EditorMenuBar menuBar;
|
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
|
|
||||||
private TestGameplayButton testGameplayButton;
|
private TestGameplayButton testGameplayButton;
|
||||||
@ -239,40 +239,49 @@ namespace osu.Game.Screens.Edit
|
|||||||
Name = "Top bar",
|
Name = "Top bar",
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 40,
|
Height = 40,
|
||||||
Child = menuBar = new EditorMenuBar
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
new EditorMenuBar
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Mode = { Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose },
|
|
||||||
Items = new[]
|
|
||||||
{
|
{
|
||||||
new MenuItem("File")
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Items = new[]
|
||||||
{
|
{
|
||||||
Items = createFileMenuItems()
|
new MenuItem("File")
|
||||||
},
|
|
||||||
new MenuItem("Edit")
|
|
||||||
{
|
|
||||||
Items = new[]
|
|
||||||
{
|
{
|
||||||
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
|
Items = createFileMenuItems()
|
||||||
redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, Redo),
|
},
|
||||||
new EditorMenuItemSpacer(),
|
new MenuItem("Edit")
|
||||||
cutMenuItem = new EditorMenuItem("Cut", MenuItemType.Standard, Cut),
|
|
||||||
copyMenuItem = new EditorMenuItem("Copy", MenuItemType.Standard, Copy),
|
|
||||||
pasteMenuItem = new EditorMenuItem("Paste", MenuItemType.Standard, Paste),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new MenuItem("View")
|
|
||||||
{
|
|
||||||
Items = new MenuItem[]
|
|
||||||
{
|
{
|
||||||
new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
|
Items = new[]
|
||||||
new HitAnimationsMenuItem(config.GetBindable<bool>(OsuSetting.EditorHitAnimations))
|
{
|
||||||
|
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new MenuItem("View")
|
||||||
|
{
|
||||||
|
Items = new MenuItem[]
|
||||||
|
{
|
||||||
|
new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
|
||||||
|
new HitAnimationsMenuItem(config.GetBindable<bool>(OsuSetting.EditorHitAnimations))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
new ScreenSelectionTabControl
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
X = -15,
|
||||||
|
Current = Mode,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -340,14 +349,15 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
|
|
||||||
menuBar.Mode.ValueChanged += onModeChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
setUpClipboardActionAvailability();
|
setUpClipboardActionAvailability();
|
||||||
|
|
||||||
|
Mode.Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose;
|
||||||
|
Mode.BindValueChanged(onModeChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -517,23 +527,23 @@ namespace osu.Game.Screens.Edit
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorComposeMode:
|
case GlobalAction.EditorComposeMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Compose;
|
Mode.Value = EditorScreenMode.Compose;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorDesignMode:
|
case GlobalAction.EditorDesignMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Design;
|
Mode.Value = EditorScreenMode.Design;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorTimingMode:
|
case GlobalAction.EditorTimingMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Timing;
|
Mode.Value = EditorScreenMode.Timing;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorSetupMode:
|
case GlobalAction.EditorSetupMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.SongSetup;
|
Mode.Value = EditorScreenMode.SongSetup;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorVerifyMode:
|
case GlobalAction.EditorVerifyMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Verify;
|
Mode.Value = EditorScreenMode.Verify;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorTestGameplay:
|
case GlobalAction.EditorTestGameplay:
|
||||||
|
Loading…
Reference in New Issue
Block a user