1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 05:53:10 +08:00

Merge pull request #2 from ppy/master

Actualize fork
This commit is contained in:
UselessToucan 2016-10-09 20:34:18 +03:00 committed by GitHub
commit b004961d07
41 changed files with 1423 additions and 249 deletions

@ -1 +1 @@
Subproject commit 4d78fdfbe01e3ecb213c19a3f3243c80a71bb668
Subproject commit 1f770847b245e6d250e63e60c24e9e84131d15e7

@ -1 +1 @@
Subproject commit cc107f9bcfc8efeeff88f19c2df8cec9755eda39
Subproject commit 6d9bbe6c838e4b89b69d5ad49b37b434aa62281e

View File

@ -3,7 +3,7 @@
using System;
using osu.Framework.Desktop;
using osu.Framework.OS;
using osu.Framework.Platform;
namespace osu.Framework.VisualTests
{
@ -13,7 +13,7 @@ namespace osu.Framework.VisualTests
public static void Main(string[] args)
{
BasicGameHost host = Host.GetSuitableHost();
host.Load(new VisualTestGame());
host.Add(new VisualTestGame());
host.Run();
}
}

View File

@ -19,17 +19,22 @@ namespace osu.Desktop.Tests
{
base.Reset();
KeyCounterCollection kc = new KeyCounterCollection
Children = new[]
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
IsCounting = true
new KeyCounterCollection
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
IsCounting = true,
Counters = new KeyCounter[]
{
new KeyCounterKeyboard(@"Z", Key.Z),
new KeyCounterKeyboard(@"X", Key.X),
new KeyCounterMouse(@"M1", MouseButton.Left),
new KeyCounterMouse(@"M2", MouseButton.Right),
},
},
};
Add(kc);
kc.AddKey(new KeyCounterKeyboard(@"Z", Key.Z));
kc.AddKey(new KeyCounterKeyboard(@"X", Key.X));
kc.AddKey(new KeyCounterMouse(@"M1", MouseButton.Left));
kc.AddKey(new KeyCounterMouse(@"M2", MouseButton.Right));
}
}
}

View File

@ -58,7 +58,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
<Prefer32Bit>true</Prefer32Bit>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
@ -78,18 +78,6 @@
<Win32Resource>
</Win32Resource>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Deploy|AnyCPU'">
<OutputPath>bin\Deploy\</OutputPath>
<DefineConstants>CuttingEdge</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<NoStdLib>true</NoStdLib>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="OpenTK, Version=1.2.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">

View File

@ -3,7 +3,7 @@
using System;
using osu.Framework.Desktop;
using osu.Framework.OS;
using osu.Framework.Platform;
using osu.Game;
namespace osu.Desktop
@ -14,7 +14,7 @@ namespace osu.Desktop
public static void Main()
{
BasicGameHost host = Host.GetSuitableHost();
host.Load(new OsuGame());
host.Add(new OsuGame());
host.Run();
}
}

View File

@ -58,7 +58,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
<Prefer32Bit>true</Prefer32Bit>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
@ -77,18 +77,6 @@
<PropertyGroup>
<Win32Resource>osu!.res</Win32Resource>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Deploy|AnyCPU'">
<OutputPath>bin\Deploy\</OutputPath>
<DefineConstants>CuttingEdge</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<NoStdLib>true</NoStdLib>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />

View File

@ -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,12 @@ namespace osu.Game.Configuration
Set(OsuConfig.Username, string.Empty);
Set(OsuConfig.Password, string.Empty);
Set(OsuConfig.Token, string.Empty);
Set(OsuConfig.PlayMode, PlayMode.Osu);
Set(OsuConfig.VolumeGlobal, 0.8, 0, 1);
Set(OsuConfig.VolumeMusic, 1.0, 0, 1);
Set(OsuConfig.VolumeEffect, 1.0, 0, 1);
}
}
@ -27,6 +34,10 @@ namespace osu.Game.Configuration
MouseSensitivity,
Username,
Password,
Token
Token,
PlayMode,
VolumeGlobal,
VolumeEffect,
VolumeMusic
}
}

View 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.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.GameModes;
using osu.Framework.Graphics.Transformations;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Input;
namespace osu.Game.GameModes
{
public abstract class BackgroundMode : GameMode, IEquatable<BackgroundMode>
{
public virtual bool Equals(BackgroundMode other)
{
return other?.GetType() == GetType();
}
const float transition_length = 500;
const float x_movement_amount = 50;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
//we don't want to handle escape key.
return false;
}
public override void Load()
{
base.Load();
Content.Scale *= 1 + (x_movement_amount / Size.X) * 2;
}
protected override void OnEntering(GameMode last)
{
Content.FadeOut();
Content.MoveToX(x_movement_amount);
Content.FadeIn(transition_length, EasingTypes.InOutQuart);
Content.MoveToX(0, transition_length, EasingTypes.InOutQuart);
base.OnEntering(last);
}
protected override void OnSuspending(GameMode next)
{
Content.MoveToX(-x_movement_amount, transition_length, EasingTypes.InOutQuart);
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
{
Content.FadeOut(transition_length, EasingTypes.OutExpo);
Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo);
return base.OnExiting(next);
}
protected override void OnResuming(GameMode last)
{
Content.MoveToX(0, transition_length, EasingTypes.OutExpo);
base.OnResuming(last);
}
}
}

View File

@ -0,0 +1,28 @@
//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.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds
{
public class BackgroundModeCustom : BackgroundMode
{
private readonly string textureName;
public BackgroundModeCustom(string textureName)
{
this.textureName = textureName;
}
public override void Load()
{
base.Load();
Add(new Background(textureName));
}
public override bool Equals(BackgroundMode other)
{
return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName;
}
}
}

View File

@ -0,0 +1,17 @@
//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.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds
{
public class BackgroundModeDefault : BackgroundMode
{
public override void Load()
{
base.Load();
Add(new Background());
}
}
}

View File

@ -0,0 +1,10 @@
//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.GameModes.Backgrounds
{
public class BackgroundModeEmpty : BackgroundMode
{
}
}

View File

@ -3,13 +3,16 @@
using System;
using System.Collections.Generic;
using osu.Game.GameModes.Backgrounds;
namespace osu.Game.GameModes.Edit
{
class SongSelectEdit : GameModeWhiteBox
class EditSongSelect : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Editor)
};
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
}
}

View File

@ -6,10 +6,26 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.GameModes;
using osu.Game.GameModes.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.GameModes.Edit
{
class Editor : GameModeWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
{
base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500);
}
protected override bool OnExiting(GameMode next)
{
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View File

@ -10,12 +10,13 @@ using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
using osu.Game.GameModes.Backgrounds;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.GameModes
{
public class GameModeWhiteBox : GameMode
public class GameModeWhiteBox : OsuGameMode
{
private Button popButton;
@ -25,9 +26,14 @@ namespace osu.Game.GameModes
private FlowContainer childModeButtons;
private Container textContainer;
private Box box;
protected override double OnEntering(GameMode last)
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg2");
protected override void OnEntering(GameMode last)
{
base.OnEntering(last);
//only show the pop button if we are entered form another gamemode.
if (last != null)
popButton.Alpha = 1;
@ -35,31 +41,40 @@ namespace osu.Game.GameModes
Content.Alpha = 0;
textContainer.Position = new Vector2(Size.X / 16, 0);
Content.Delay(300);
box.ScaleTo(0.2f);
box.RotateTo(-20);
Content.Delay(300, true);
box.ScaleTo(1, transition_time, EasingTypes.OutElastic);
box.RotateTo(0, transition_time / 2, EasingTypes.OutQuint);
textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo);
Content.FadeIn(transition_time, EasingTypes.OutExpo);
return 0;// transition_time * 1000;
}
protected override double OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
textContainer.MoveTo(new Vector2((Size.X / 16), 0), transition_time, EasingTypes.OutExpo);
Content.FadeOut(transition_time, EasingTypes.OutExpo);
return transition_time;
return base.OnExiting(next);
}
protected override double OnSuspending(GameMode next)
protected override void OnSuspending(GameMode next)
{
base.OnSuspending(next);
textContainer.MoveTo(new Vector2(-(Size.X / 16), 0), transition_time, EasingTypes.OutExpo);
Content.FadeOut(transition_time, EasingTypes.OutExpo);
return transition_time;
}
protected override double OnResuming(GameMode last)
protected override void OnResuming(GameMode last)
{
base.OnResuming(last);
textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo);
Content.FadeIn(transition_time, EasingTypes.OutExpo);
return transition_time;
}
public override void Load()
@ -68,15 +83,15 @@ namespace osu.Game.GameModes
Children = new Drawable[]
{
new Box
box = new Box
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.7f),
Size = new Vector2(0.3f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = getColourFor(GetType()),
Alpha = 0.6f,
Additive = true
Alpha = 1,
Additive = false
},
textContainer = new AutoSizeContainer
{

View File

@ -19,7 +19,7 @@ using OpenTK.Input;
namespace osu.Game.GameModes.Menu
{
public class ButtonSystem : Container
public partial class ButtonSystem : Container
{
public Action OnEdit;
public Action OnExit;
@ -103,8 +103,9 @@ namespace osu.Game.GameModes.Menu
}
}
},
osuLogo = new OsuLogo(onOsuLogo)
osuLogo = new OsuLogo
{
Action = onOsuLogo,
Origin = Anchor.Centre,
Anchor = Anchor.Centre
}
@ -112,19 +113,30 @@ namespace osu.Game.GameModes.Menu
buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0);
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"solo", @"freeplay", FontAwesome.user, new Color4(102, 68, 204, 255), OnSolo, wedge_width, Key.P)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"multi", @"multiplayer", FontAwesome.users, new Color4(94, 63, 186, 255), OnMulti, 0, Key.M)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), OnChart)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"tests", @"tests", FontAwesome.terminal, new Color4(80, 53, 160, 255), OnTest, 0, Key.T)));
buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.user, new Color4(102, 68, 204, 255), OnSolo, wedge_width, Key.P));
buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.users, new Color4(94, 63, 186, 255), OnMulti, 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), OnChart));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, wedge_width, Key.P)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), OnEdit, 0, Key.E)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), OnDirect, 0, Key.D)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q)));
buttonsTopLevel.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, wedge_width, Key.P));
buttonsTopLevel.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), OnEdit, 0, Key.E));
buttonsTopLevel.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), OnDirect, 0, Key.D));
buttonsTopLevel.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q));
buttonFlow.Add(buttonsPlay);
buttonFlow.Add(buttonsTopLevel);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Key == Key.Escape)
{
if (State == MenuState.Initial)
return false;
State = MenuState.Initial;
return true;
}
osuLogo.TriggerClick(state);
return true;
}
@ -274,95 +286,6 @@ namespace osu.Game.GameModes.Menu
base.Update();
}
/// <summary>
/// osu! logo and its attachments (pulsing, visualiser etc.)
/// </summary>
class OsuLogo : AutoSizeContainer
{
private Sprite logo;
private Container logoBounceContainer;
private MenuVisualisation vis;
private Action clickAction;
public float SizeForFlow => logo == null ? 0 : logo.Size.X * logo.Scale.X * logoBounceContainer.Scale.X * 0.8f;
public override void Load()
{
base.Load();
Sprite ripple;
Children = new Drawable[]
{
logoBounceContainer = new AutoSizeContainer
{
Children = new Drawable[]
{
logo = new Sprite()
{
Texture = Game.Textures.Get(@"Menu/logo"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
ripple = new Sprite()
{
Texture = Game.Textures.Get(@"Menu/logo"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0.4f
},
vis = new MenuVisualisation
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = logo.Size,
Additive = true,
Alpha = 0.2f,
}
}
}
};
ripple.ScaleTo(1.1f, 500);
ripple.FadeOut(500);
ripple.Loop(300);
}
public OsuLogo(Action action)
{
clickAction = action;
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
logoBounceContainer.ScaleTo(1.1f, 1000, EasingTypes.Out);
return true;
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
return true;
}
protected override bool OnClick(InputState state)
{
clickAction?.Invoke();
return true;
}
protected override bool OnHover(InputState state)
{
logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
return true;
}
protected override void OnHoverLost(InputState state)
{
logoBounceContainer.ScaleTo(1, 500, EasingTypes.OutElastic);
}
}
/// <summary>
/// A flow container with an origin based on one of its contained drawables.
/// </summary>
@ -632,9 +555,6 @@ namespace osu.Game.GameModes.Menu
FadeOut(800);
break;
}
break;
case ButtonState.Contracted2:
break;
case ButtonState.Expanded:
const int expand_duration = 500;
@ -647,15 +567,12 @@ namespace osu.Game.GameModes.Menu
FadeOut(explode_duration / 4 * 3);
break;
}
}
}
public enum ButtonState
{
Contracted,
Contracted2,
Expanded,
Exploded
}
@ -701,6 +618,4 @@ namespace osu.Game.GameModes.Menu
{
}
}
}

View File

@ -0,0 +1,90 @@
//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.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.GameModes.Menu
{
class Intro : OsuGameMode
{
private OsuLogo logo;
/// <summary>
/// Whether we have loaded the menu previously.
/// </summary>
internal bool DidLoadMenu;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
public override void Load()
{
base.Load();
Children = new Drawable[]
{
logo = new OsuLogo()
{
Alpha = 0,
Additive = true,
Interactive = false,
Colour = Color4.DarkGray,
Ripple = false
}
};
AudioSample welcome = Game.Audio.Sample.Get(@"welcome");
AudioTrack bgm = Game.Audio.Track.Get(@"circles");
bgm.Looping = true;
Scheduler.Add(delegate
{
welcome.Play();
}, true);
Scheduler.AddDelayed(delegate
{
bgm.Start();
}, 600);
Scheduler.AddDelayed(delegate
{
DidLoadMenu = true;
Push(new MainMenu());
}, 2900);
logo.ScaleTo(0);
logo.ScaleTo(1,5900, EasingTypes.OutQuint);
logo.FadeIn(30000, EasingTypes.OutQuint);
}
protected override void OnSuspending(GameMode next)
{
Content.FadeOut(300);
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
{
//cancel exiting if we haven't loaded the menu yet.
return !DidLoadMenu;
}
protected override void OnResuming(GameMode last)
{
//we are just an intro. if we are resumed, we just want to exit after a short delay (to allow the last mode to transition out).
Scheduler.AddDelayed(Exit, 300);
base.OnResuming(last);
}
}
}

View File

@ -7,6 +7,7 @@ using osu.Framework.GameModes;
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds;
using osu.Game.GameModes.Charts;
using osu.Game.GameModes.Direct;
using osu.Game.GameModes.Edit;
@ -17,12 +18,12 @@ using OpenTK;
namespace osu.Game.GameModes.Menu
{
internal class MainMenu : GameMode
public class MainMenu : OsuGameMode
{
private ButtonSystem buttons;
public override string Name => @"Main Menu";
//private AudioTrack bgm;
protected override BackgroundMode CreateBackground() => new BackgroundModeDefault();
public override void Load()
{
@ -30,11 +31,6 @@ namespace osu.Game.GameModes.Menu
OsuGame osu = (OsuGame)Game;
AudioSample welcome = Game.Audio.Sample.Get(@"welcome");
welcome.Play();
//bgm = Game.Audio.Track.Get(@"circles");
//bgm.Start();
Children = new Drawable[]
{
new ParallaxContainer
@ -44,17 +40,14 @@ namespace osu.Game.GameModes.Menu
{
buttons = new ButtonSystem()
{
Alpha = 0,
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new SongSelectEdit()); },
OnSolo = delegate { Push(new SongSelectPlay()); },
OnEdit = delegate { Push(new EditSongSelect()); },
OnSolo = delegate { Push(new PlaySongSelect()); },
OnMulti = delegate { Push(new Lobby()); },
OnTest = delegate { Push(new TestBrowser()); },
OnExit = delegate {
Game.Scheduler.AddDelayed(delegate {
Game.Host.Exit();
}, ButtonSystem.EXIT_DELAY);
},
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
OnSettings = delegate {
osu.Options.PoppedOut = !osu.Options.PoppedOut;
},
@ -62,29 +55,32 @@ namespace osu.Game.GameModes.Menu
}
}
};
buttons.FadeIn(500);
}
protected override double OnSuspending(GameMode next)
protected override void OnSuspending(GameMode next)
{
base.OnSuspending(next);
const float length = 400;
buttons.State = ButtonSystem.MenuState.EnteringMode;
Content.FadeOut(length, EasingTypes.InSine);
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
return base.OnSuspending(next);
}
protected override double OnResuming(GameMode last)
protected override void OnResuming(GameMode last)
{
base.OnResuming(last);
const float length = 300;
buttons.State = ButtonSystem.MenuState.TopLevel;
Content.FadeIn(length, EasingTypes.OutQuint);
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
return base.OnResuming(last);
}
}
}

View File

@ -0,0 +1,132 @@
//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.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
namespace osu.Game.GameModes.Menu
{
/// <summary>
/// osu! logo and its attachments (pulsing, visualiser etc.)
/// </summary>
public partial class OsuLogo : AutoSizeContainer
{
private Sprite logo;
private Container logoBounceContainer;
private ButtonSystem.MenuVisualisation vis;
public Action Action;
public float SizeForFlow => logo == null ? 0 : logo.Size.X * logo.Scale.X * logoBounceContainer.Scale.X * 0.8f;
private Sprite ripple;
private Container rippleContainer;
public bool Ripple
{
get { return rippleContainer.Alpha > 0; }
set
{
rippleContainer.Alpha = value ? 1 : 0;
}
}
public bool Interactive = true;
public OsuLogo()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Children = new Drawable[]
{
logoBounceContainer = new AutoSizeContainer
{
Children = new Drawable[]
{
logo = new Sprite()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
rippleContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
ripple = new Sprite()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Additive = true,
Alpha = 0.05f
}
}
},
vis = new ButtonSystem.MenuVisualisation
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = logo.Size,
Additive = true,
Alpha = 0.2f,
}
}
}
};
}
public override void Load()
{
base.Load();
logo.Texture = Game.Textures.Get(@"Menu/logo");
ripple.Texture = Game.Textures.Get(@"Menu/logo");
ripple.ScaleTo(1.1f, 500);
ripple.FadeOut(500);
ripple.Loop(300);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
if (!Interactive) return false;
logoBounceContainer.ScaleTo(1.1f, 1000, EasingTypes.Out);
return true;
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
return true;
}
protected override bool OnClick(InputState state)
{
if (!Interactive) return false;
Action?.Invoke();
return true;
}
protected override bool OnHover(InputState state)
{
if (!Interactive) return false;
logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
return true;
}
protected override void OnHoverLost(InputState state)
{
logoBounceContainer.ScaleTo(1, 500, EasingTypes.OutElastic);
}
}
}

View File

@ -6,7 +6,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.GameModes;
using osu.Game.GameModes.Backgrounds;
using osu.Game.GameModes.Play;
using OpenTK.Graphics;
namespace osu.Game.GameModes.Multiplayer
{
@ -16,5 +19,19 @@ namespace osu.Game.GameModes.Multiplayer
typeof(MatchSongSelect),
typeof(Player),
};
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
{
base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500);
}
protected override bool OnExiting(GameMode next)
{
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View File

@ -6,10 +6,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.GameModes;
using osu.Game.GameModes.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.GameModes.Multiplayer
{
class MatchSongSelect : GameModeWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
}
}

View File

@ -0,0 +1,73 @@
//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.GameModes;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Background;
using osu.Game.Graphics.Containers;
namespace osu.Game.GameModes
{
public class OsuGameMode : GameMode
{
internal BackgroundMode Background { get; private set; }
/// <summary>
/// Override to create a BackgroundMode for the current GameMode.
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
/// </summary>
protected virtual BackgroundMode CreateBackground() => null;
protected override void OnEntering(GameMode last)
{
OsuGameMode lastOsu = last as OsuGameMode;
BackgroundMode bg = CreateBackground();
if (lastOsu?.Background != null)
{
if (bg == null || lastOsu.Background.Equals(bg))
//we can keep the previous mode's background.
Background = lastOsu.Background;
else
{
lastOsu.Background.Push(Background = bg);
}
}
else if (bg != null)
{
AddInternal(new ParallaxContainer
{
Depth = float.MinValue,
Children = new[]
{
Background = bg
}
});
}
base.OnEntering(last);
}
protected override bool OnExiting(GameMode next)
{
OsuGameMode nextOsu = next as OsuGameMode;
if (Background != null && !Background.Equals(nextOsu?.Background))
{
if (nextOsu != null)
//We need to use MakeCurrent in case we are jumping up multiple game modes.
nextOsu.Background.MakeCurrent();
else
Background.Exit();
}
return base.OnExiting(next);
}
}
}

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Game.Beatmaps.Objects;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.GameModes.Play
{
@ -24,7 +25,12 @@ namespace osu.Game.GameModes.Play
{
base.Load();
Add(new Box() { RelativeSizeAxes = Axes.Both, Alpha = 0.1f, Scale = new Vector2(0.99f) });
Add(new Box()
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.8f,
Colour = new Color4(5, 5, 5, 255),
});
}
}
}

View File

@ -6,10 +6,26 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics;
using osu.Framework.GameModes;
using osu.Game.GameModes.Backgrounds;
namespace osu.Game.GameModes.Play
{
class ModSelect : GameModeWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
{
base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500);
}
protected override bool OnExiting(GameMode next)
{
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View 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
}
}

View File

@ -0,0 +1,43 @@
//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 osu.Framework.Configuration;
using osu.Game.GameModes.Backgrounds;
namespace osu.Game.GameModes.Play
{
class PlaySongSelect : GameModeWhiteBox
{
private Bindable<PlayMode> playMode;
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(ModSelect),
typeof(Player)
};
public override void Load()
{
base.Load();
OsuGame osu = Game as OsuGame;
playMode = osu.PlayMode;
playMode.ValueChanged += PlayMode_ValueChanged;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
playMode.ValueChanged -= PlayMode_ValueChanged;
}
private void PlayMode_ValueChanged(object sender, EventArgs e)
{
}
}
}

View File

@ -6,13 +6,107 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.GameModes.Backgrounds;
using osu.Game.GameModes.Play.Catch;
using osu.Game.GameModes.Play.Mania;
using osu.Game.GameModes.Play.Osu;
using osu.Game.GameModes.Play.Taiko;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Input;
namespace osu.Game.GameModes.Play
{
class Player : GameModeWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Results)
};
public override void Load()
{
base.Load();
List<HitObject> objects = new List<HitObject>();
double time = Time + 1000;
for (int i = 0; i < 100; i++)
{
objects.Add(new Circle()
{
StartTime = time,
Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384))
});
time += RNG.Next(50, 500);
}
Beatmap beatmap = new Beatmap
{
HitObjects = objects
};
OsuGame osu = Game as OsuGame;
switch (osu.PlayMode.Value)
{
case PlayMode.Osu:
Add(new OsuHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
break;
case PlayMode.Taiko:
Add(new TaikoHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
break;
case PlayMode.Catch:
Add(new CatchHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
break;
case PlayMode.Mania:
Add(new ManiaHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
break;
}
Add(new KeyCounterCollection
{
IsCounting = true,
FadeTime = 50,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = new Vector2(10, 50),
Counters = new KeyCounter[]
{
new KeyCounterKeyboard(@"Z", Key.Z),
new KeyCounterKeyboard(@"X", Key.X),
new KeyCounterMouse(@"M1", MouseButton.Left),
new KeyCounterMouse(@"M2", MouseButton.Right),
}
});
}
}
}
}

View File

@ -6,10 +6,26 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.GameModes;
using osu.Game.GameModes.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.GameModes.Play
{
class Results : GameModeWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
{
base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500);
}
protected override bool OnExiting(GameMode next)
{
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View File

@ -1,16 +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
using System;
using System.Collections.Generic;
namespace osu.Game.GameModes.Play
{
class SongSelectPlay : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(ModSelect),
typeof(Player)
};
}
}

View File

@ -15,9 +15,13 @@ namespace osu.Game.Graphics.Background
{
protected Sprite BackgroundSprite;
public Background()
string textureName;
public Background(string textureName = @"Backgrounds/bg1")
{
this.textureName = textureName;
RelativeSizeAxes = Axes.Both;
Depth = float.MinValue;
}
public override void Load()
@ -26,7 +30,7 @@ namespace osu.Game.Graphics.Background
Add(BackgroundSprite = new Sprite
{
Texture = Game.Textures.Get(@"Menu/background"),
Texture = Game.Textures.Get(textureName),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.DarkGray

View File

@ -14,21 +14,21 @@ namespace osu.Game.Graphics.Containers
public ParallaxContainer()
{
RelativeSizeAxes = Axes.Both;
AddInternal(content = new Container()
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
}
private Container content = new Container()
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
};
private Container content;
protected override Container AddTarget => content;
protected override Container Content => content;
public override void Load()
{
base.Load();
Add(content);
}
protected override bool OnMouseMove(InputState state)

View File

@ -16,16 +16,25 @@ namespace osu.Game.Graphics.UserInterface
}
private List<KeyCounter> counters = new List<KeyCounter>();
public IReadOnlyList<KeyCounter> Counters => counters;
public IEnumerable<KeyCounter> Counters
{
get { return counters; }
set
{
foreach (var k in value)
addKey(k);
public void AddKey(KeyCounter key)
Children = value;
}
}
private void addKey(KeyCounter key)
{
counters.Add(key);
key.IsCounting = this.IsCounting;
key.FadeTime = this.FadeTime;
key.KeyDownTextColor = this.KeyDownTextColor;
key.KeyUpTextColor = this.KeyUpTextColor;
base.Add(key);
key.IsCounting = IsCounting;
key.FadeTime = FadeTime;
key.KeyDownTextColor = KeyDownTextColor;
key.KeyUpTextColor = KeyUpTextColor;
}
public void ResetCount()

View File

@ -1,12 +1,16 @@
//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.Configuration;
using osu.Framework.GameModes;
using osu.Game.Configuration;
using osu.Game.GameModes.Menu;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.OS;
using osu.Framework.Platform;
using osu.Game.GameModes;
using osu.Game.Graphics.Background;
using osu.Game.GameModes.Play;
using osu.Game.Graphics.Containers;
@ -17,6 +21,10 @@ namespace osu.Game
public class OsuGame : OsuGameBase
{
public Toolbar Toolbar;
public MainMenu MainMenu => intro?.ChildGameMode as MainMenu;
private Intro intro;
public Bindable<PlayMode> PlayMode;
public override void SetHost(BasicGameHost host)
{
@ -29,18 +37,88 @@ namespace osu.Game
{
base.Load();
ShowPerformanceOverlay = true;
//attach our bindables to the audio subsystem.
Audio.Volume.Weld(Config.GetBindable<double>(OsuConfig.VolumeGlobal));
Audio.VolumeSample.Weld(Config.GetBindable<double>(OsuConfig.VolumeEffect));
Audio.VolumeTrack.Weld(Config.GetBindable<double>(OsuConfig.VolumeMusic));
Add(new Drawable[] {
new ParallaxContainer
intro = new Intro(),
Toolbar = new Toolbar
{
Children = new [] {
new Background()
}
OnHome = delegate { MainMenu?.MakeCurrent(); },
OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; },
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
Alpha = 0.001f //fixes invalidation fuckup
},
new MainMenu(),
Toolbar = new Toolbar(),
new VolumeControl
{
VolumeGlobal = Audio.Volume,
VolumeSample = Audio.VolumeSample,
VolumeTrack = Audio.VolumeTrack
}
});
Toolbar.SetState(ToolbarState.Hidden, true);
intro.ModePushed += modeAdded;
intro.Exited += modeRemoved;
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
PlayMode.TriggerChange();
Cursor.Alpha = 0;
}
public Action<GameMode> ModeChanged;
private void modeChanged(GameMode newMode)
{
// - Ability to change window size
// - Ability to adjust music playback
// - Frame limiter changes
//central game mode change logic.
if (newMode is Player || newMode is Intro)
{
Toolbar.SetState(ToolbarState.Hidden);
}
else
{
Toolbar.SetState(ToolbarState.Visible);
}
Cursor.FadeIn(100);
ModeChanged?.Invoke(newMode);
if (newMode == null)
Host.Exit();
}
protected override bool OnExiting()
{
if (!intro.DidLoadMenu || intro.ChildGameMode != null)
{
intro.MakeCurrent();
return true;
}
return base.OnExiting();
}
private void modeAdded(GameMode newMode)
{
newMode.ModePushed += modeAdded;
newMode.Exited += modeRemoved;
modeChanged(newMode);
}
private void modeRemoved(GameMode newMode)
{
modeChanged(newMode);
}
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)

View File

@ -21,10 +21,12 @@ namespace osu.Game
public Options Options;
public APIAccess API;
protected override Container AddTarget => ratioContainer?.IsLoaded == true ? ratioContainer : base.AddTarget;
protected override Container Content => ratioContainer?.IsLoaded == true ? ratioContainer : base.Content;
private RatioAdjust ratioContainer;
public CursorContainer Cursor;
public override void Load()
{
base.Load();
@ -49,7 +51,7 @@ namespace osu.Game
Children = new Drawable[]
{
Options = new Options(),
new OsuCursorContainer()
Cursor = new OsuCursorContainer()
}
}
});

View File

@ -1,16 +1,17 @@
//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.Framework.Graphics.Transformations;
using osu.Framework.Timing;
using osu.Game.GameModes.Play;
namespace osu.Game.Overlays
{
@ -18,6 +19,29 @@ namespace osu.Game.Overlays
{
const float height = 50;
public Action OnSettings;
public Action OnHome;
public Action<PlayMode> OnPlayModeChange;
private ToolbarModeSelector modeSelector;
public void SetState(ToolbarState state, bool instant = false)
{
int time = instant ? 0 : 200;
switch (state)
{
case ToolbarState.Hidden:
MoveToY(-Size.Y, time, EasingTypes.InQuint);
FadeOut(time);
break;
case ToolbarState.Visible:
MoveToY(0, time, EasingTypes.OutQuint);
FadeIn(time);
break;
}
}
public override void Load()
{
base.Load();
@ -30,9 +54,66 @@ 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);
}
public enum ToolbarState
{
Visible,
Hidden,
}
}

View File

@ -0,0 +1,184 @@
//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 void Update()
{
base.Update();
//todo: find a way to avoid using this (autosize needs to be able to ignore certain drawables.. in this case the tooltip)
Size = new Vector2(WIDTH + DrawableText.Size.X, 1);
}
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);
}
}
}

View 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;
}
}
}

View 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));
}
}
}

107
osu.Game/VolumeControl.cs Normal file
View File

@ -0,0 +1,107 @@
using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Framework.Input;
using osu.Framework.Graphics.Transformations;
namespace osu.Game
{
internal class VolumeControl : Container
{
private Box meterFill;
private Container meterContainer;
public BindableDouble VolumeGlobal { get; set; }
public BindableDouble VolumeSample { get; set; }
public BindableDouble VolumeTrack { get; set; }
public VolumeControl()
{
RelativeSizeAxes = Axes.Both;
}
public override void Load()
{
base.Load();
Children = new Drawable[]
{
meterContainer = new Container {
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = new Vector2(10, 10),
Size = new Vector2(40, 180),
Alpha = 0,
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f, 0.9f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Box
{
Colour = Color4.DarkGray,
RelativeSizeAxes = Axes.Both,
},
meterFill = new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre
},
}
}
}
}
};
updateFill();
}
protected override bool OnWheelDown(InputState state)
{
appear();
VolumeGlobal.Value -= 0.05f;
updateFill();
return base.OnWheelDown(state);
}
protected override bool OnWheelUp(InputState state)
{
appear();
VolumeGlobal.Value += 0.05f;
updateFill();
return base.OnWheelUp(state);
}
private void updateFill()
{
meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint);
}
private void appear()
{
meterContainer.ClearTransformations();
meterContainer.FadeIn(100);
meterContainer.Delay(1000);
meterContainer.FadeOut(100);
}
}
}

View File

@ -69,21 +69,29 @@
<Compile Include="Beatmaps\Timing\SampleChange.cs" />
<Compile Include="Beatmaps\Timing\TimingChange.cs" />
<Compile Include="Configuration\OsuConfigManager.cs" />
<Compile Include="GameModes\BackgroundMode.cs" />
<Compile Include="GameModes\Backgrounds\BackgroundModeCustom.cs" />
<Compile Include="GameModes\Backgrounds\BackgroundModeDefault.cs" />
<Compile Include="GameModes\Backgrounds\BackgroundModeEmpty.cs" />
<Compile Include="GameModes\Charts\ChartInfo.cs" />
<Compile Include="GameModes\Edit\Editor.cs" />
<Compile Include="GameModes\GameModeWhiteBox.cs" />
<Compile Include="GameModes\Menu\Intro.cs" />
<Compile Include="GameModes\Menu\ButtonSystem.cs" />
<Compile Include="GameModes\Menu\MainMenu.cs" />
<Compile Include="GameModes\Menu\OsuLogo.cs" />
<Compile Include="GameModes\Multiplayer\Lobby.cs" />
<Compile Include="GameModes\Multiplayer\Match.cs" />
<Compile Include="GameModes\Multiplayer\MatchCreate.cs" />
<Compile Include="GameModes\Multiplayer\MatchSongSelect.cs" />
<Compile Include="GameModes\OsuGameMode.cs" />
<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" />
<Compile Include="GameModes\Play\PlaySongSelect.cs" />
<Compile Include="GameModes\Play\Catch\CatchHitRenderer.cs" />
<Compile Include="GameModes\Play\Catch\CatchPlayfield.cs" />
<Compile Include="GameModes\Play\HitRenderer.cs" />
@ -94,7 +102,7 @@
<Compile Include="GameModes\Play\Playfield.cs" />
<Compile Include="GameModes\Play\Taiko\TaikoHitRenderer.cs" />
<Compile Include="GameModes\Play\Taiko\TaikoPlayfield.cs" />
<Compile Include="GameModes\Edit\SongSelectEdit.cs" />
<Compile Include="GameModes\Edit\EditSongSelect.cs" />
<Compile Include="Graphics\Background\Background.cs" />
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />
@ -119,8 +127,12 @@
<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" />
<Compile Include="VolumeControl.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">

13
osu.sln
View File

@ -22,44 +22,31 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Deploy|Any CPU = Deploy|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Deploy|Any CPU.ActiveCfg = Deploy|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Deploy|Any CPU.Build.0 = Deploy|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Deploy|Any CPU.Build.0 = Debug|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.Build.0 = Release|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Deploy|Any CPU.Build.0 = Debug|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}.Release|Any CPU.Build.0 = Release|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Deploy|Any CPU.Build.0 = Debug|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.Build.0 = Release|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Deploy|Any CPU.Build.0 = Debug|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65DC628F-A640-4111-AB35-3A5652BC1E17}.Release|Any CPU.Build.0 = Release|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Deploy|Any CPU.ActiveCfg = Deploy|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Deploy|Any CPU.Build.0 = Deploy|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69051C69-12AE-4E7D-A3E6-460D2E282312}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection