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

Make Options:IStateful.

This commit is contained in:
Huo Yaoyuan 2016-10-13 22:27:37 +08:00
parent acd54d1ebc
commit c93a440d3b
3 changed files with 18 additions and 17 deletions

View File

@ -14,6 +14,7 @@ using osu.Game.GameModes.Play;
using osu.Game.Graphics.Containers;
using OpenTK;
using osu.Framework;
using osu.Game.Overlays;
namespace osu.Game.GameModes.Menu
{
@ -48,7 +49,7 @@ namespace osu.Game.GameModes.Menu
OnTest = delegate { Push(new TestBrowser()); },
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
OnSettings = delegate {
osu.Options.PoppedOut = !osu.Options.PoppedOut;
osu.Options.State = osu.Options.State.Reverse();
},
}
}

View File

@ -96,7 +96,7 @@ namespace osu.Game
Toolbar = new Toolbar
{
OnHome = delegate { MainMenu?.MakeCurrent(); },
OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; },
OnSettings = delegate { Options.State = Options.State.Reverse(); },
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
Alpha = 0.001f,
},

View File

@ -13,7 +13,7 @@ using osu.Framework;
namespace osu.Game.Overlays
{
public class Options : Container
public class Options : Container, IStateful<Visibility>
{
const float width = 300;
@ -41,35 +41,35 @@ namespace osu.Game.Overlays
switch (args.Key)
{
case Key.Escape:
if (!poppedOut) return false;
if (State == Visibility.Hidden) return false;
PoppedOut = false;
State = Visibility.Hidden;
return true;
}
return base.OnKeyDown(state, args);
}
private bool poppedOut;
private Visibility state;
public bool PoppedOut
public Visibility State
{
get { return poppedOut; }
get { return state; }
set
{
if (value == poppedOut) return;
if (value == state) return;
poppedOut = value;
state = value;
if (poppedOut)
switch (state)
{
MoveTo(new Vector2(0, 0), 300, EasingTypes.Out);
case Visibility.Hidden:
MoveTo(new Vector2(-width, 0), 300, EasingTypes.Out);
break;
case Visibility.Visible:
MoveTo(new Vector2(0, 0), 300, EasingTypes.Out);
break;
}
else
{
MoveTo(new Vector2(-width, 0), 300, EasingTypes.Out);
}
}
}
}