mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
commit
3c01f59e00
@ -1 +1 @@
|
||||
Subproject commit 4d78fdfbe01e3ecb213c19a3f3243c80a71bb668
|
||||
Subproject commit 7c15499b5ef49bed580b2ee851952826b9c5d39a
|
@ -2,6 +2,7 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Game.GameModes.Play;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Configuration
|
||||
@ -17,6 +18,8 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.Username, string.Empty);
|
||||
Set(OsuConfig.Password, string.Empty);
|
||||
Set(OsuConfig.Token, string.Empty);
|
||||
|
||||
Set(OsuConfig.PlayMode, PlayMode.Osu);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +30,7 @@ namespace osu.Game.Configuration
|
||||
MouseSensitivity,
|
||||
Username,
|
||||
Password,
|
||||
Token
|
||||
Token,
|
||||
PlayMode
|
||||
}
|
||||
}
|
||||
|
@ -701,6 +701,4 @@ namespace osu.Game.GameModes.Menu
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.GameModes.Menu
|
||||
{
|
||||
internal class MainMenu : GameMode
|
||||
public class MainMenu : GameMode
|
||||
{
|
||||
private ButtonSystem buttons;
|
||||
public override string Name => @"Main Menu";
|
||||
|
20
osu.Game/GameModes/Play/PlayMode.cs
Normal file
20
osu.Game/GameModes/Play/PlayMode.cs
Normal file
@ -0,0 +1,20 @@
|
||||
//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.ComponentModel;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public enum PlayMode
|
||||
{
|
||||
[Description(@"osu!")]
|
||||
Osu = 0,
|
||||
[Description(@"osu!taiko")]
|
||||
Taiko = 1,
|
||||
[Description(@"osu!catch")]
|
||||
Catch = 2,
|
||||
[Description(@"osu!mania")]
|
||||
Mania = 3
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
//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.Configuration;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.GameModes.Menu;
|
||||
using OpenTK;
|
||||
@ -17,6 +18,9 @@ namespace osu.Game
|
||||
public class OsuGame : OsuGameBase
|
||||
{
|
||||
public Toolbar Toolbar;
|
||||
public MainMenu MainMenu;
|
||||
|
||||
public Bindable<PlayMode> PlayMode;
|
||||
|
||||
public override void SetHost(BasicGameHost host)
|
||||
{
|
||||
@ -29,8 +33,6 @@ namespace osu.Game
|
||||
{
|
||||
base.Load();
|
||||
|
||||
ShowPerformanceOverlay = true;
|
||||
|
||||
Add(new Drawable[] {
|
||||
new ParallaxContainer
|
||||
{
|
||||
@ -38,9 +40,18 @@ namespace osu.Game
|
||||
new Background()
|
||||
}
|
||||
},
|
||||
new MainMenu(),
|
||||
Toolbar = new Toolbar(),
|
||||
MainMenu = new MainMenu(),
|
||||
Toolbar = new Toolbar
|
||||
{
|
||||
OnHome = delegate { MainMenu.MakeCurrent(); },
|
||||
OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; },
|
||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||
},
|
||||
});
|
||||
|
||||
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
|
||||
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
|
||||
PlayMode.TriggerChange();
|
||||
}
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
|
@ -1,16 +1,15 @@
|
||||
//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.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using System;
|
||||
using osu.Game.GameModes.Play;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -18,6 +17,12 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
const float height = 50;
|
||||
|
||||
public Action OnSettings;
|
||||
public Action OnHome;
|
||||
public Action<PlayMode> OnPlayModeChange;
|
||||
|
||||
private ToolbarModeSelector modeSelector;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
@ -30,9 +35,60 @@ namespace osu.Game.Overlays
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(0.1f, 0.1f, 0.1f, 0.9f)
|
||||
Colour = new Color4(0.1f, 0.1f, 0.1f, 0.4f)
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.gear,
|
||||
Action = OnSettings,
|
||||
TooltipMain = "Settings",
|
||||
TooltipSub = "Change your settings",
|
||||
},
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.home,
|
||||
TooltipMain = "Home",
|
||||
TooltipSub = "Return to the main menu",
|
||||
Action = OnHome
|
||||
},
|
||||
modeSelector = new ToolbarModeSelector
|
||||
{
|
||||
OnPlayModeChange = OnPlayModeChange
|
||||
}
|
||||
}
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new []
|
||||
{
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.search
|
||||
},
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.user,
|
||||
Text = ((OsuGame)Game).Config.Get<string>(OsuConfig.Username)
|
||||
},
|
||||
new ToolbarButton
|
||||
{
|
||||
Icon = FontAwesome.bars
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
||||
}
|
||||
}
|
||||
|
176
osu.Game/Overlays/ToolbarButton.cs
Normal file
176
osu.Game/Overlays/ToolbarButton.cs
Normal file
@ -0,0 +1,176 @@
|
||||
//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 osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class ToolbarButton : Container
|
||||
{
|
||||
public const float WIDTH = 60;
|
||||
|
||||
public FontAwesome Icon
|
||||
{
|
||||
get { return DrawableIcon.Icon; }
|
||||
set { DrawableIcon.Icon = value; }
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return DrawableText.Text; }
|
||||
set
|
||||
{
|
||||
DrawableText.Text = value;
|
||||
paddingIcon.Alpha = string.IsNullOrEmpty(value) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
public string TooltipMain
|
||||
{
|
||||
get { return tooltip1.Text; }
|
||||
set
|
||||
{
|
||||
tooltip1.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string TooltipSub
|
||||
{
|
||||
get { return tooltip2.Text; }
|
||||
set
|
||||
{
|
||||
tooltip2.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Action Action;
|
||||
protected TextAwesome DrawableIcon;
|
||||
protected SpriteText DrawableText;
|
||||
protected Box HoverBackground;
|
||||
private Drawable paddingLeft;
|
||||
private Drawable paddingRight;
|
||||
private Drawable paddingIcon;
|
||||
private FlowContainer tooltipContainer;
|
||||
private SpriteText tooltip1;
|
||||
private SpriteText tooltip2;
|
||||
|
||||
public new float Padding
|
||||
{
|
||||
get { return paddingLeft.Size.X; }
|
||||
set
|
||||
{
|
||||
paddingLeft.Size = new Vector2(value, 1);
|
||||
paddingRight.Size = new Vector2(value, 1);
|
||||
tooltipContainer.Position = new Vector2(value, tooltipContainer.Position.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public ToolbarButton()
|
||||
{
|
||||
HoverBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Additive = true,
|
||||
Colour = new Color4(60, 60, 60, 255),
|
||||
Alpha = 0,
|
||||
};
|
||||
|
||||
DrawableIcon = new TextAwesome
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
};
|
||||
|
||||
DrawableText = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
};
|
||||
|
||||
tooltipContainer = new FlowContainer
|
||||
{
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Position = new Vector2(0, -5),
|
||||
Alpha = 0,
|
||||
Children = new[]
|
||||
{
|
||||
tooltip1 = new SpriteText()
|
||||
{
|
||||
TextSize = 22,
|
||||
},
|
||||
tooltip2 = new SpriteText
|
||||
{
|
||||
TextSize = 15
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
paddingLeft = new Container { RelativeSizeAxes = Axes.Y };
|
||||
paddingRight = new Container { RelativeSizeAxes = Axes.Y };
|
||||
paddingIcon = new Container
|
||||
{
|
||||
Size = new Vector2(5, 0),
|
||||
Alpha = 0
|
||||
};
|
||||
|
||||
Padding = 10;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Size = new Vector2(WIDTH, 1);
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
HoverBackground,
|
||||
new FlowContainer
|
||||
{
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
paddingLeft,
|
||||
DrawableIcon,
|
||||
paddingIcon,
|
||||
DrawableText,
|
||||
paddingRight
|
||||
},
|
||||
},
|
||||
tooltipContainer
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
Action?.Invoke();
|
||||
HoverBackground.FlashColour(Color4.White, 400);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
HoverBackground.FadeTo(0.4f, 200);
|
||||
tooltipContainer.FadeIn(100);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
HoverBackground.FadeTo(0, 200);
|
||||
tooltipContainer.FadeOut(100);
|
||||
}
|
||||
}
|
||||
}
|
51
osu.Game/Overlays/ToolbarModeButton.cs
Normal file
51
osu.Game/Overlays/ToolbarModeButton.cs
Normal file
@ -0,0 +1,51 @@
|
||||
//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.Extensions;
|
||||
using osu.Game.GameModes.Play;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class ToolbarModeButton : ToolbarButton
|
||||
{
|
||||
private PlayMode mode;
|
||||
public PlayMode Mode
|
||||
{
|
||||
get { return mode; }
|
||||
set
|
||||
{
|
||||
mode = value;
|
||||
TooltipMain = mode.GetDescription();
|
||||
TooltipSub = $"Play some {mode.GetDescription()}";
|
||||
Icon = getModeIcon(mode);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Active
|
||||
{
|
||||
set
|
||||
{
|
||||
//Background.Colour = value ? new Color4(100, 100, 100, 255) : new Color4(20, 20, 20, 255);
|
||||
}
|
||||
}
|
||||
|
||||
private FontAwesome getModeIcon(PlayMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
default: return FontAwesome.fa_osu_osu_o;
|
||||
case PlayMode.Taiko: return FontAwesome.fa_osu_taiko_o;
|
||||
case PlayMode.Catch: return FontAwesome.fa_osu_fruits_o;
|
||||
case PlayMode.Mania: return FontAwesome.fa_osu_mania_o;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
DrawableIcon.TextSize *= 1.4f;
|
||||
}
|
||||
}
|
||||
}
|
101
osu.Game/Overlays/ToolbarModeSelector.cs
Normal file
101
osu.Game/Overlays/ToolbarModeSelector.cs
Normal file
@ -0,0 +1,101 @@
|
||||
//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.Linq;
|
||||
using osu.Framework.Cached;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.GameModes.Play;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
class ToolbarModeSelector : Container
|
||||
{
|
||||
const float padding = 10;
|
||||
|
||||
private FlowContainer modeButtons;
|
||||
private Box modeButtonLine;
|
||||
private ToolbarModeButton activeButton;
|
||||
|
||||
public Action<PlayMode> OnPlayModeChange;
|
||||
|
||||
public ToolbarModeSelector()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(20, 20, 20, 255)
|
||||
},
|
||||
modeButtons = new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
},
|
||||
modeButtonLine = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Size = new Vector2(0.3f, 3),
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopCentre,
|
||||
Colour = Color4.White
|
||||
}
|
||||
};
|
||||
|
||||
foreach (PlayMode m in Enum.GetValues(typeof(PlayMode)))
|
||||
{
|
||||
var localMode = m;
|
||||
modeButtons.Add(new ToolbarModeButton
|
||||
{
|
||||
Mode = m,
|
||||
Action = delegate
|
||||
{
|
||||
SetGameMode(localMode);
|
||||
OnPlayModeChange?.Invoke(localMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Size = new Vector2(modeButtons.Children.Count() * ToolbarButton.WIDTH + padding * 2, 1);
|
||||
}
|
||||
|
||||
public void SetGameMode(PlayMode mode)
|
||||
{
|
||||
foreach (ToolbarModeButton m in modeButtons.Children.Cast<ToolbarModeButton>())
|
||||
{
|
||||
bool isActive = m.Mode == mode;
|
||||
m.Active = isActive;
|
||||
if (isActive)
|
||||
activeButton = m;
|
||||
}
|
||||
|
||||
activeMode.Invalidate();
|
||||
}
|
||||
|
||||
private Cached<Drawable> activeMode = new Cached<Drawable>();
|
||||
|
||||
protected override void UpdateLayout()
|
||||
{
|
||||
base.UpdateLayout();
|
||||
|
||||
if (!activeMode.EnsureValid())
|
||||
activeMode.Refresh(() => modeButtonLine.MoveToX(activeButton.Position.X + activeButton.Size.X / 2 + padding, 200, EasingTypes.OutQuint));
|
||||
}
|
||||
}
|
||||
}
|
@ -81,6 +81,7 @@
|
||||
<Compile Include="GameModes\Play\ModSelect.cs" />
|
||||
<Compile Include="GameModes\Play\Player.cs" />
|
||||
<Compile Include="GameModes\Charts\ChartListing.cs" />
|
||||
<Compile Include="GameModes\Play\PlayMode.cs" />
|
||||
<Compile Include="GameModes\Play\Results.cs" />
|
||||
<Compile Include="GameModes\Direct\OnlineListing.cs" />
|
||||
<Compile Include="GameModes\Play\SongSelectPlay.cs" />
|
||||
@ -119,6 +120,9 @@
|
||||
<Compile Include="OsuGameBase.cs" />
|
||||
<Compile Include="Overlays\Options.cs" />
|
||||
<Compile Include="Overlays\Toolbar.cs" />
|
||||
<Compile Include="Overlays\ToolbarButton.cs" />
|
||||
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
||||
<Compile Include="Overlays\ToolbarModeSelector.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Users\User.cs" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user