mirror of
https://github.com/osukey/osukey.git
synced 2025-05-02 20:27:27 +09:00
Make Options:IStateful.
This commit is contained in:
parent
acd54d1ebc
commit
c93a440d3b
@ -14,6 +14,7 @@ using osu.Game.GameModes.Play;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Menu
|
namespace osu.Game.GameModes.Menu
|
||||||
{
|
{
|
||||||
@ -48,7 +49,7 @@ namespace osu.Game.GameModes.Menu
|
|||||||
OnTest = delegate { Push(new TestBrowser()); },
|
OnTest = delegate { Push(new TestBrowser()); },
|
||||||
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
|
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
|
||||||
OnSettings = delegate {
|
OnSettings = delegate {
|
||||||
osu.Options.PoppedOut = !osu.Options.PoppedOut;
|
osu.Options.State = osu.Options.State.Reverse();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ namespace osu.Game
|
|||||||
Toolbar = new Toolbar
|
Toolbar = new Toolbar
|
||||||
{
|
{
|
||||||
OnHome = delegate { MainMenu?.MakeCurrent(); },
|
OnHome = delegate { MainMenu?.MakeCurrent(); },
|
||||||
OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; },
|
OnSettings = delegate { Options.State = Options.State.Reverse(); },
|
||||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||||
Alpha = 0.001f,
|
Alpha = 0.001f,
|
||||||
},
|
},
|
||||||
|
@ -13,7 +13,7 @@ using osu.Framework;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class Options : Container
|
public class Options : Container, IStateful<Visibility>
|
||||||
{
|
{
|
||||||
const float width = 300;
|
const float width = 300;
|
||||||
|
|
||||||
@ -41,35 +41,35 @@ namespace osu.Game.Overlays
|
|||||||
switch (args.Key)
|
switch (args.Key)
|
||||||
{
|
{
|
||||||
case Key.Escape:
|
case Key.Escape:
|
||||||
if (!poppedOut) return false;
|
if (State == Visibility.Hidden) return false;
|
||||||
|
|
||||||
PoppedOut = false;
|
State = Visibility.Hidden;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return base.OnKeyDown(state, args);
|
return base.OnKeyDown(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool poppedOut;
|
private Visibility state;
|
||||||
|
|
||||||
public bool PoppedOut
|
public Visibility State
|
||||||
{
|
{
|
||||||
get { return poppedOut; }
|
get { return state; }
|
||||||
|
|
||||||
set
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user