mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Base class for overlays.
This commit is contained in:
@ -48,9 +48,7 @@ namespace osu.Game.GameModes.Menu
|
|||||||
OnMulti = delegate { Push(new Lobby()); },
|
OnMulti = delegate { Push(new Lobby()); },
|
||||||
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 = osu.Options.ReverseVisibility,
|
||||||
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.State = Options.State.Reverse(); },
|
OnSettings = Options.ReverseVisibility,
|
||||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||||
Alpha = 0.001f,
|
Alpha = 0.001f,
|
||||||
},
|
},
|
||||||
@ -134,7 +134,7 @@ namespace osu.Game
|
|||||||
switch (args.Key)
|
switch (args.Key)
|
||||||
{
|
{
|
||||||
case Key.F8:
|
case Key.F8:
|
||||||
Chat.State = Chat.State.Reverse();
|
Chat.ReverseVisibility();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using OpenTK;
|
||||||
using System.Threading.Tasks;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Drawables;
|
using osu.Framework.Graphics.Drawables;
|
||||||
@ -17,15 +17,10 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Online.Chat.Display;
|
using osu.Game.Online.Chat.Display;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using OpenTK.Input;
|
|
||||||
using osu.Framework;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class ChatConsole : Container, IStateful<Visibility>
|
public class ChatConsole : Overlay
|
||||||
{
|
{
|
||||||
private ChannelDisplay channelDisplay;
|
private ChannelDisplay channelDisplay;
|
||||||
|
|
||||||
@ -69,7 +64,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private long? lastMessageId;
|
private long? lastMessageId;
|
||||||
|
|
||||||
List<Channel> careChannels;
|
private List<Channel> careChannels;
|
||||||
|
|
||||||
private void initializeChannels()
|
private void initializeChannels()
|
||||||
{
|
{
|
||||||
@ -112,7 +107,7 @@ namespace osu.Game.Overlays
|
|||||||
careChannels.Add(channel);
|
careChannels.Add(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetMessagesRequest fetchReq;
|
private GetMessagesRequest fetchReq;
|
||||||
|
|
||||||
public void FetchNewMessages(APIAccess api)
|
public void FetchNewMessages(APIAccess api)
|
||||||
{
|
{
|
||||||
@ -140,30 +135,18 @@ namespace osu.Game.Overlays
|
|||||||
api.Queue(fetchReq);
|
api.Queue(fetchReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Visibility state;
|
private const int transition_length = 500;
|
||||||
|
|
||||||
public Visibility State
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
get { return state; }
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
state = value;
|
|
||||||
|
|
||||||
const int transition_length = 500;
|
|
||||||
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case Visibility.Hidden:
|
|
||||||
MoveToY(-Size.Y, transition_length, EasingTypes.InQuint);
|
|
||||||
FadeOut(transition_length, EasingTypes.InQuint);
|
|
||||||
break;
|
|
||||||
case Visibility.Visible:
|
|
||||||
MoveToY(0, transition_length, EasingTypes.OutQuint);
|
MoveToY(0, transition_length, EasingTypes.OutQuint);
|
||||||
FadeIn(transition_length, EasingTypes.OutQuint);
|
FadeIn(transition_length, EasingTypes.OutQuint);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
MoveToY(-Size.Y, transition_length, EasingTypes.InQuint);
|
||||||
|
FadeOut(transition_length, EasingTypes.InQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Drawables;
|
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Input;
|
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Drawables;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class Options : Container, IStateful<Visibility>
|
public class Options : Overlay
|
||||||
{
|
{
|
||||||
const float width = 300;
|
private const float width = 300;
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
public override void Load(BaseGame game)
|
||||||
{
|
{
|
||||||
@ -49,28 +48,14 @@ namespace osu.Game.Overlays
|
|||||||
return base.OnKeyDown(state, args);
|
return base.OnKeyDown(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Visibility state;
|
protected override void PopIn()
|
||||||
|
|
||||||
public Visibility State
|
|
||||||
{
|
{
|
||||||
get { return state; }
|
MoveToX(0, 300, EasingTypes.Out);
|
||||||
|
}
|
||||||
|
|
||||||
set
|
protected override void PopOut()
|
||||||
{
|
{
|
||||||
if (value == state) return;
|
MoveToX(-width, 300, EasingTypes.Out);
|
||||||
|
|
||||||
state = value;
|
|
||||||
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case Visibility.Hidden:
|
|
||||||
MoveTo(new Vector2(-width, 0), 300, EasingTypes.Out);
|
|
||||||
break;
|
|
||||||
case Visibility.Visible:
|
|
||||||
MoveTo(new Vector2(0, 0), 300, EasingTypes.Out);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
osu.Game/Overlays/Overlay.cs
Normal file
41
osu.Game/Overlays/Overlay.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays
|
||||||
|
{
|
||||||
|
public abstract class Overlay : Container, IStateful<Visibility>
|
||||||
|
{
|
||||||
|
private Visibility state;
|
||||||
|
public Visibility State
|
||||||
|
{
|
||||||
|
get { return state; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == state) return;
|
||||||
|
state = value;
|
||||||
|
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case Visibility.Hidden:
|
||||||
|
PopOut();
|
||||||
|
break;
|
||||||
|
case Visibility.Visible:
|
||||||
|
PopIn();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void PopIn();
|
||||||
|
|
||||||
|
protected abstract void PopOut();
|
||||||
|
|
||||||
|
public void ReverseVisibility()
|
||||||
|
=> State = (State == Visibility.Visible ? Visibility.Hidden : Visibility.Visible);
|
||||||
|
}
|
||||||
|
public enum Visibility
|
||||||
|
{
|
||||||
|
Hidden,
|
||||||
|
Visible
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,23 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Drawables;
|
using osu.Framework.Graphics.Drawables;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Configuration;
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Graphics.Transformations;
|
using osu.Framework.Graphics.Transformations;
|
||||||
using osu.Framework.Timing;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.GameModes.Play;
|
using osu.Game.GameModes.Play;
|
||||||
using osu.Framework;
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class Toolbar : Container, IStateful<Visibility>
|
public class Toolbar : Overlay
|
||||||
{
|
{
|
||||||
const float height = 50;
|
private const float height = 50;
|
||||||
|
|
||||||
public Action OnSettings;
|
public Action OnSettings;
|
||||||
public Action OnHome;
|
public Action OnHome;
|
||||||
@ -26,29 +25,18 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private ToolbarModeSelector modeSelector;
|
private ToolbarModeSelector modeSelector;
|
||||||
|
|
||||||
private Visibility state;
|
private const int transition_time = 200;
|
||||||
|
|
||||||
public Visibility State
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
get { return state; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
state = value;
|
|
||||||
|
|
||||||
const int transition_time = 200;
|
|
||||||
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case Visibility.Hidden:
|
|
||||||
MoveToY(-Size.Y, transition_time, EasingTypes.InQuint);
|
|
||||||
FadeOut(transition_time, EasingTypes.InQuint);
|
|
||||||
break;
|
|
||||||
case Visibility.Visible:
|
|
||||||
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
||||||
FadeIn(transition_time, EasingTypes.OutQuint);
|
FadeIn(transition_time, EasingTypes.OutQuint);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
MoveToY(-Size.Y, transition_time, EasingTypes.InQuint);
|
||||||
|
FadeOut(transition_time, EasingTypes.InQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
public override void Load(BaseGame game)
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
|
||||||
{
|
|
||||||
public enum Visibility
|
|
||||||
{
|
|
||||||
Hidden,
|
|
||||||
Visible
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class OverlayVisibilityHelper
|
|
||||||
{
|
|
||||||
public static Visibility Reverse(this Visibility input)
|
|
||||||
=> input == Visibility.Visible ? Visibility.Hidden : Visibility.Visible;
|
|
||||||
}
|
|
||||||
}
|
|
@ -156,11 +156,11 @@
|
|||||||
<Compile Include="OsuGameBase.cs" />
|
<Compile Include="OsuGameBase.cs" />
|
||||||
<Compile Include="Overlays\ChatConsole.cs" />
|
<Compile Include="Overlays\ChatConsole.cs" />
|
||||||
<Compile Include="Overlays\Options.cs" />
|
<Compile Include="Overlays\Options.cs" />
|
||||||
|
<Compile Include="Overlays\Overlay.cs" />
|
||||||
<Compile Include="Overlays\Toolbar.cs" />
|
<Compile Include="Overlays\Toolbar.cs" />
|
||||||
<Compile Include="Overlays\ToolbarButton.cs" />
|
<Compile Include="Overlays\ToolbarButton.cs" />
|
||||||
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
||||||
<Compile Include="Overlays\ToolbarModeSelector.cs" />
|
<Compile Include="Overlays\ToolbarModeSelector.cs" />
|
||||||
<Compile Include="Overlays\Visibility.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Users\User.cs" />
|
<Compile Include="Users\User.cs" />
|
||||||
<Compile Include="VolumeControl.cs" />
|
<Compile Include="VolumeControl.cs" />
|
||||||
|
Reference in New Issue
Block a user