From 7b1ef53f36fc60877bfacbe729ef72e71942a316 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 2 Oct 2017 09:24:25 +0900 Subject: [PATCH] Expose a mode change event from EditorMenuBar --- osu.Game/Screens/Edit/Menus/EditorMenuBar.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Menus/EditorMenuBar.cs b/osu.Game/Screens/Edit/Menus/EditorMenuBar.cs index 616cabbab2..4c9b3c84b3 100644 --- a/osu.Game/Screens/Edit/Menus/EditorMenuBar.cs +++ b/osu.Game/Screens/Edit/Menus/EditorMenuBar.cs @@ -11,11 +11,19 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; +using System; namespace osu.Game.Screens.Edit.Menus { public class EditorMenuBar : OsuMenu { + /// + /// Invaoked when the selected mode has changed. + /// + public event Action ModeChanged; + + private readonly ScreenSelectionTabControl tabControl; + public EditorMenuBar() : base(Direction.Horizontal, true) { @@ -26,13 +34,21 @@ namespace osu.Game.Screens.Edit.Menus AddRangeInternal(new Drawable[] { - new ScreenSelectionTabControl + tabControl = new ScreenSelectionTabControl { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, X = -15 } }); + + tabControl.Current.ValueChanged += v => ModeChanged?.Invoke(v); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + tabControl.Current.TriggerChange(); } protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();