1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Merge pull request #154 from peppy/sidebar-toolbar-coexistence

Make options overlay coexist with toolbar.
This commit is contained in:
Dean Herbert 2016-11-11 13:34:08 +09:00 committed by GitHub
commit ff67b77c5b
8 changed files with 52 additions and 21 deletions

View File

@ -26,6 +26,8 @@ namespace osu.Game.GameModes.Menu
private AudioSample welcome;
private AudioTrack bgm;
internal override bool ShowToolbar => (ParentGameMode as OsuGameMode)?.ShowToolbar ?? false;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
public Intro()

View File

@ -25,6 +25,8 @@ namespace osu.Game.GameModes.Menu
private ButtonSystem buttons;
public override string Name => @"Main Menu";
internal override bool ShowToolbar => true;
private BackgroundMode background;
protected override BackgroundMode CreateBackground() => background;

View File

@ -27,6 +27,12 @@ namespace osu.Game.GameModes
/// </summary>
protected virtual BackgroundMode CreateBackground() => null;
internal virtual bool ShowToolbar => true;
protected new OsuGame Game => base.Game as OsuGame;
protected float ToolbarPadding => ShowToolbar ? Game.Toolbar.DrawHeight : 0;
private bool boundToBeatmap;
private Bindable<WorkingBeatmap> beatmap;

View File

@ -133,7 +133,7 @@ namespace osu.Game.GameModes.Play
playMode = osuGame.PlayMode;
playMode.ValueChanged += playMode_ValueChanged;
// Temporary:
scrollContainer.Padding = new MarginPadding { Top = osuGame.Toolbar.Height };
scrollContainer.Padding = new MarginPadding { Top = ToolbarPadding };
}
if (database == null)

View File

@ -22,6 +22,8 @@ namespace osu.Game.GameModes.Play
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
internal override bool ShowToolbar => false;
public BeatmapInfo BeatmapInfo;
public PlayMode PreferredPlayMode;

View File

@ -18,6 +18,7 @@ using osu.Framework.Input;
using osu.Game.Input;
using OpenTK.Input;
using osu.Framework.Logging;
using osu.Game.GameModes;
using osu.Game.Graphics.UserInterface.Volume;
namespace osu.Game
@ -25,10 +26,15 @@ namespace osu.Game
public class OsuGame : OsuGameBase
{
public Toolbar Toolbar;
public ChatConsole Chat;
public MusicController MusicController;
public MainMenu MainMenu => intro?.ChildGameMode as MainMenu;
private Intro intro;
private ChatConsole chat;
private MusicController musicController;
private MainMenu mainMenu => modeStack?.ChildGameMode as MainMenu;
private Intro intro => modeStack as Intro;
private OsuGameMode modeStack;
private VolumeControl volume;
@ -86,40 +92,41 @@ namespace osu.Game
VolumeSample = Audio.VolumeSample,
VolumeTrack = Audio.VolumeTrack
},
overlayContent = new Container{ RelativeSizeAxes = Axes.Both },
new GlobalHotkeys //exists because UserInputManager is at a level below us.
{
Handler = globalHotkeyPressed
}
});
(Options = new OptionsOverlay { Depth = float.MaxValue / 2 }).Preload(game, Add);
(intro = new Intro
(modeStack = new Intro
{
Beatmap = Beatmap
}).Preload(game, d =>
{
mainContent.Add(d);
intro.ModePushed += modeAdded;
intro.Exited += modeRemoved;
intro.DisplayAsRoot();
modeStack.ModePushed += modeAdded;
modeStack.Exited += modeRemoved;
modeStack.DisplayAsRoot();
});
(Chat = new ChatConsole(API)).Preload(game, Add);
(MusicController = new MusicController()).Preload(game, Add);
//overlay elements
(chat = new ChatConsole(API) { Depth = 0 }).Preload(game, overlayContent.Add);
(musicController = new MusicController()).Preload(game, overlayContent.Add);
(Options = new OptionsOverlay { Depth = 1 }).Preload(game, overlayContent.Add);
(Toolbar = new Toolbar
{
OnHome = delegate { MainMenu?.MakeCurrent(); },
Depth = 2,
OnHome = delegate { mainMenu?.MakeCurrent(); },
OnSettings = Options.ToggleVisibility,
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
OnMusicController = MusicController.ToggleVisibility
OnMusicController = musicController.ToggleVisibility
}).Preload(game, t =>
{
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
PlayMode.TriggerChange();
Add(Toolbar);
overlayContent.Add(Toolbar);
});
Cursor.Alpha = 0;
@ -130,7 +137,7 @@ namespace osu.Game
switch (args.Key)
{
case Key.F8:
Chat.ToggleVisibility();
chat.ToggleVisibility();
return true;
}
@ -151,6 +158,8 @@ namespace osu.Game
private Container mainContent;
private Container overlayContent;
private void modeChanged(GameMode newMode)
{
// - Ability to change window size
@ -158,10 +167,10 @@ namespace osu.Game
// - Frame limiter changes
//central game mode change logic.
if (newMode is Player || newMode is Intro)
if ((newMode as OsuGameMode)?.ShowToolbar != true)
{
Toolbar.State = Visibility.Hidden;
Chat.State = Visibility.Hidden;
chat.State = Visibility.Hidden;
}
else
{

View File

@ -6,6 +6,7 @@ using System.Linq;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
@ -73,6 +74,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FlowDirection.VerticalOnly,
Children = new Drawable[]
{
new SpriteText
@ -114,6 +116,13 @@ namespace osu.Game.Overlays
};
}
protected override void Load(BaseGame game)
{
base.Load(game);
scrollContainer.Padding = new MarginPadding { Top = (game as OsuGame)?.Toolbar.DrawHeight ?? 0 };
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)

View File

@ -105,10 +105,11 @@ namespace osu.Game.Overlays
tooltip1 = new SpriteText
{
TextSize = 22,
Font = @"Exo2.0-Bold",
},
tooltip2 = new SpriteText
{
TextSize = 15
TextSize = 16
}
}
}