1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 11:42:54 +08:00

Merge pull request #48 from peppy/general-fixes

General fixes
This commit is contained in:
Thomas Müller 2016-10-08 12:21:17 +02:00 committed by GitHub
commit 965cd6539f
31 changed files with 617 additions and 220 deletions

@ -1 +1 @@
Subproject commit db23910e6cbd14b321103811857a368db01b26b1
Subproject commit 6b884e1b80444c5249754634a4b5529c50b52934

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

@ -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

@ -20,6 +20,10 @@ namespace osu.Game.Configuration
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);
}
}
@ -31,6 +35,9 @@ namespace osu.Game.Configuration
Username,
Password,
Token,
PlayMode
PlayMode,
VolumeGlobal,
VolumeEffect,
VolumeMusic
}
}

View File

@ -8,8 +8,9 @@ using System.Text;
using System.Threading.Tasks;
using osu.Framework.GameModes;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Background;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Input;
namespace osu.Game.GameModes
{
@ -23,6 +24,12 @@ namespace osu.Game.GameModes
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();
@ -47,12 +54,12 @@ namespace osu.Game.GameModes
base.OnSuspending(next);
}
protected override void OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
Content.FadeOut(transition_length, EasingTypes.OutExpo);
Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo);
base.OnExiting(next);
return base.OnExiting(next);
}
protected override void OnResuming(GameMode last)
@ -61,35 +68,4 @@ namespace osu.Game.GameModes
base.OnResuming(last);
}
}
public class BackgroundModeDefault : BackgroundMode
{
public override void Load()
{
base.Load();
Add(new Background());
}
}
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,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,6 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Game.GameModes.Backgrounds;
namespace osu.Game.GameModes.Edit
{

View File

@ -7,6 +7,7 @@ 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
@ -21,10 +22,10 @@ namespace osu.Game.GameModes.Edit
Background.FadeColour(Color4.DarkGray, 500);
}
protected override void OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
base.OnExiting(next);
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View File

@ -10,6 +10,7 @@ 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;
@ -52,12 +53,12 @@ namespace osu.Game.GameModes
Content.FadeIn(transition_time, EasingTypes.OutExpo);
}
protected override void OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
base.OnExiting(next);
textContainer.MoveTo(new Vector2((Size.X / 16), 0), transition_time, EasingTypes.OutExpo);
Content.FadeOut(transition_time, EasingTypes.OutExpo);
return base.OnExiting(next);
}
protected override void OnSuspending(GameMode next)

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
}
@ -115,7 +116,6 @@ namespace osu.Game.GameModes.Menu
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)));
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)));
@ -125,6 +125,15 @@ namespace osu.Game.GameModes.Menu
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 +283,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>

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;
Game.Scheduler.Add(delegate
{
welcome.Play();
}, true);
Game.Scheduler.AddDelayed(delegate
{
bgm.Start();
}, 600);
Game.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).
Game.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;
@ -22,10 +23,6 @@ namespace osu.Game.GameModes.Menu
private ButtonSystem buttons;
public override string Name => @"Main Menu";
protected override bool IsTopLevel => true;
//private AudioTrack bgm;
protected override BackgroundMode CreateBackground() => new BackgroundModeDefault();
public override void Load()
@ -34,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
@ -48,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 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 { Game.Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
OnSettings = delegate {
osu.Options.PoppedOut = !osu.Options.PoppedOut;
},
@ -66,6 +55,8 @@ namespace osu.Game.GameModes.Menu
}
}
};
buttons.FadeIn(500);
}
protected override void OnSuspending(GameMode next)

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

@ -7,6 +7,7 @@ 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;
@ -27,10 +28,10 @@ namespace osu.Game.GameModes.Multiplayer
Background.FadeColour(Color4.DarkGray, 500);
}
protected override void OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
base.OnExiting(next);
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View File

@ -7,6 +7,7 @@ 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

View File

@ -55,25 +55,20 @@ namespace osu.Game.GameModes
base.OnEntering(last);
}
protected override void OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
OsuGameMode nextOsu = next as OsuGameMode;
if (Background != null && !Background.Equals(nextOsu?.Background))
Background.Exit();
{
if (nextOsu != null)
//We need to use MakeCurrent in case we are jumping up multiple game modes.
nextOsu.Background.MakeCurrent();
else
Background.Exit();
}
base.OnExiting(next);
return base.OnExiting(next);
}
protected override void OnResuming(GameMode last)
{
base.OnResuming(last);
}
protected override void OnSuspending(GameMode next)
{
base.OnSuspending(next);
}
}
}

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics;
using osu.Framework.GameModes;
using osu.Game.GameModes.Backgrounds;
namespace osu.Game.GameModes.Play
{
@ -21,10 +22,10 @@ namespace osu.Game.GameModes.Play
Background.FadeColour(Color4.DarkGray, 500);
}
protected override void OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
base.OnExiting(next);
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View File

@ -3,16 +3,41 @@
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

@ -12,11 +12,14 @@ 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
{
@ -59,7 +62,6 @@ namespace osu.Game.GameModes.Play
Add(new OsuHitRenderer
{
Objects = beatmap.HitObjects,
Scale = new Vector2(0.8f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
@ -68,7 +70,6 @@ namespace osu.Game.GameModes.Play
Add(new TaikoHitRenderer
{
Objects = beatmap.HitObjects,
Scale = new Vector2(0.8f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
@ -77,7 +78,6 @@ namespace osu.Game.GameModes.Play
Add(new CatchHitRenderer
{
Objects = beatmap.HitObjects,
Scale = new Vector2(0.8f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
@ -86,12 +86,27 @@ namespace osu.Game.GameModes.Play
Add(new ManiaHitRenderer
{
Objects = beatmap.HitObjects,
Scale = new Vector2(0.8f),
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

@ -7,6 +7,7 @@ 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
@ -21,10 +22,10 @@ namespace osu.Game.GameModes.Play
Background.FadeColour(Color4.DarkGray, 500);
}
protected override void OnExiting(GameMode next)
protected override bool OnExiting(GameMode next)
{
base.OnExiting(next);
Background.FadeColour(Color4.White, 500);
return base.OnExiting(next);
}
}
}

View File

@ -16,7 +16,15 @@ 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)
{

View File

@ -1,13 +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;
@ -18,7 +21,8 @@ namespace osu.Game
public class OsuGame : OsuGameBase
{
public Toolbar Toolbar;
public MainMenu MainMenu;
public MainMenu MainMenu => intro?.ChildGameMode as MainMenu;
private Intro intro;
public Bindable<PlayMode> PlayMode;
@ -33,19 +37,88 @@ namespace osu.Game
{
base.Load();
//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[] {
MainMenu = new MainMenu(),
intro = new Intro(),
Toolbar = new Toolbar
{
OnHome = delegate { MainMenu.MakeCurrent(); },
OnHome = delegate { MainMenu?.MakeCurrent(); },
OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; },
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
Alpha = 0.001f //fixes invalidation fuckup
},
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

@ -25,6 +25,8 @@ namespace osu.Game
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

@ -9,6 +9,8 @@ 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
@ -23,6 +25,23 @@ namespace osu.Game.Overlays
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();
@ -91,4 +110,10 @@ namespace osu.Game.Overlays
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
}
public enum ToolbarState
{
Visible,
Hidden,
}
}

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

@ -70,11 +70,16 @@
<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" />
@ -127,6 +132,7 @@
<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