mirror of
https://github.com/ppy/osu
synced 2024-12-26 08:53:10 +00:00
Merge pull request #216 from peppy/general-fixes
Make toolbar buttons more independent logic-wise.
This commit is contained in:
commit
e218fda972
@ -1 +1 @@
|
||||
Subproject commit b5efbe6d53cb6895163731e2a934a1c6518d9d7d
|
||||
Subproject commit e611e186e3c8951d7e58a6c92c75e1b587e825a2
|
@ -47,7 +47,7 @@ namespace osu.Game
|
||||
|
||||
string[] args;
|
||||
|
||||
public OptionsOverlay Options;
|
||||
private OptionsOverlay options;
|
||||
|
||||
public OsuGame(string[] args = null)
|
||||
{
|
||||
@ -61,7 +61,7 @@ namespace osu.Game
|
||||
host.Size = new Vector2(Config.Get<int>(OsuConfig.Width), Config.Get<int>(OsuConfig.Height));
|
||||
}
|
||||
|
||||
public void ToggleOptions() => Options.ToggleVisibility();
|
||||
public void ToggleOptions() => options.ToggleVisibility();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
@ -118,15 +118,17 @@ namespace osu.Game
|
||||
|
||||
//overlay elements
|
||||
(chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add);
|
||||
(Options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add);
|
||||
(options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add);
|
||||
(musicController = new MusicController() { Depth = -3 }).Preload(this, overlayContent.Add);
|
||||
|
||||
Dependencies.Cache(options);
|
||||
Dependencies.Cache(musicController);
|
||||
|
||||
(Toolbar = new Toolbar
|
||||
{
|
||||
Depth = -2,
|
||||
OnHome = delegate { mainMenu?.MakeCurrent(); },
|
||||
OnSettings = Options.ToggleVisibility,
|
||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||
OnMusicController = musicController.ToggleVisibility
|
||||
}).Preload(this, t =>
|
||||
{
|
||||
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
|
||||
@ -134,9 +136,9 @@ namespace osu.Game
|
||||
overlayContent.Add(Toolbar);
|
||||
});
|
||||
|
||||
Options.StateChanged += delegate
|
||||
options.StateChanged += delegate
|
||||
{
|
||||
switch (Options.State)
|
||||
switch (options.State)
|
||||
{
|
||||
case Visibility.Hidden:
|
||||
intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||
@ -164,7 +166,7 @@ namespace osu.Game
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.O:
|
||||
Options.ToggleVisibility();
|
||||
options.ToggleVisibility();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -22,10 +21,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
private const float height = 50;
|
||||
|
||||
public Action OnSettings;
|
||||
public Action OnHome;
|
||||
public Action<PlayMode> OnPlayModeChange;
|
||||
public Action OnMusicController;
|
||||
|
||||
private ToolbarModeSelector modeSelector;
|
||||
private Box solidBackground;
|
||||
@ -87,18 +84,9 @@ namespace osu.Game.Overlays.Toolbar
|
||||
AutoSizeAxes = Axes.X,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ToolbarButton
|
||||
new ToolbarSettingsButton(),
|
||||
new ToolbarHomeButton()
|
||||
{
|
||||
Icon = FontAwesome.fa_gear,
|
||||
TooltipMain = "Settings",
|
||||
TooltipSub = "Change your settings",
|
||||
Action = () => OnSettings?.Invoke()
|
||||
},
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.fa_home,
|
||||
TooltipMain = "Home",
|
||||
TooltipSub = "Return to the main menu",
|
||||
Action = () => OnHome?.Invoke()
|
||||
},
|
||||
modeSelector = new ToolbarModeSelector
|
||||
@ -116,11 +104,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
AutoSizeAxes = Axes.X,
|
||||
Children = new []
|
||||
{
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.fa_music,
|
||||
Action = () => OnMusicController?.Invoke()
|
||||
},
|
||||
new ToolbarMusicButton(),
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.fa_search
|
||||
|
@ -133,7 +133,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
Action?.Invoke();
|
||||
HoverBackground.FlashColour(new Color4(255, 255, 255, 180), 800, EasingTypes.OutQuint);
|
||||
HoverBackground.FlashColour(new Color4(255, 255, 255, 100), 500, EasingTypes.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
19
osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs
Normal file
19
osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs
Normal file
@ -0,0 +1,19 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
class ToolbarHomeButton : ToolbarButton
|
||||
{
|
||||
public ToolbarHomeButton()
|
||||
{
|
||||
Icon = FontAwesome.fa_home;
|
||||
TooltipMain = "Home";
|
||||
TooltipSub = "Return to the main menu";
|
||||
}
|
||||
}
|
||||
}
|
23
osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs
Normal file
23
osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs
Normal file
@ -0,0 +1,23 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
class ToolbarMusicButton : ToolbarOverlayToggleButton
|
||||
{
|
||||
public ToolbarMusicButton()
|
||||
{
|
||||
Icon = FontAwesome.fa_music;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(MusicController music)
|
||||
{
|
||||
StateContainer = music;
|
||||
Action = music.ToggleVisibility;
|
||||
}
|
||||
}
|
||||
}
|
71
osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs
Normal file
71
osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs
Normal file
@ -0,0 +1,71 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online.API;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
class ToolbarOverlayToggleButton : ToolbarButton
|
||||
{
|
||||
private Box StateBackground;
|
||||
|
||||
private OverlayContainer stateContainer;
|
||||
|
||||
public OverlayContainer StateContainer
|
||||
{
|
||||
get { return stateContainer; }
|
||||
set
|
||||
{
|
||||
stateContainer = value;
|
||||
stateContainer.StateChanged += stateChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public ToolbarOverlayToggleButton()
|
||||
{
|
||||
Add(StateBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(150, 150, 150, 180),
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
Depth = 2,
|
||||
Alpha = 0,
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
if (stateContainer != null)
|
||||
stateContainer.StateChanged -= stateChanged;
|
||||
}
|
||||
|
||||
private void stateChanged(OverlayContainer c, Visibility state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case Visibility.Hidden:
|
||||
StateBackground.FadeOut(200);
|
||||
break;
|
||||
case Visibility.Visible:
|
||||
StateBackground.FadeIn(200);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs
Normal file
25
osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs
Normal file
@ -0,0 +1,25 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
class ToolbarSettingsButton : ToolbarOverlayToggleButton
|
||||
{
|
||||
public ToolbarSettingsButton()
|
||||
{
|
||||
Icon = FontAwesome.fa_gear;
|
||||
TooltipMain = "Settings";
|
||||
TooltipSub = "Change your settings";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OptionsOverlay options)
|
||||
{
|
||||
StateContainer = options;
|
||||
Action = options.ToggleVisibility;
|
||||
}
|
||||
}
|
||||
}
|
@ -92,6 +92,10 @@
|
||||
<Compile Include="Beatmaps\Timing\SampleChange.cs" />
|
||||
<Compile Include="Beatmaps\Timing\TimingChange.cs" />
|
||||
<Compile Include="Configuration\OsuConfigManager.cs" />
|
||||
<Compile Include="Overlays\Toolbar\ToolbarHomeButton.cs" />
|
||||
<Compile Include="Overlays\Toolbar\ToolbarMusicButton.cs" />
|
||||
<Compile Include="Overlays\Toolbar\ToolbarSettingsButton.cs" />
|
||||
<Compile Include="Overlays\Toolbar\ToolbarOverlayToggleButton.cs" />
|
||||
<Compile Include="Overlays\Toolbar\ToolbarUserButton.cs" />
|
||||
<Compile Include="Screens\BackgroundMode.cs" />
|
||||
<Compile Include="Screens\Backgrounds\BackgroundModeBeatmap.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user