1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:47:25 +08:00

Merge pull request #365 from peppy/general-fixes

Better screen hierarchy
This commit is contained in:
Thomas Müller 2017-02-18 07:58:03 +01:00 committed by GitHub
commit 7a29603800
52 changed files with 377 additions and 216 deletions

@ -1 +1 @@
Subproject commit 4a5848453240326ba08b09a33a2467af8c174b6a
Subproject commit b62e49ecb06c4a5b6fb304568e03b0689a8bdac3

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Desktop.Platform;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Game;
using osu.Game.Modes;
using osu.Game.Modes.Catch;

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;

View File

@ -2,7 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Timing;

View File

@ -3,7 +3,7 @@
using System.Collections.Generic;
using osu.Framework;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using OpenTK;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using OpenTK.Input;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Sprites;
using osu.Game.Screens.Menu;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using osu.Game.Overlays;

View File

@ -3,7 +3,7 @@
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Overlays;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using OpenTK.Input;

View File

@ -9,7 +9,7 @@ using osu.Game.Overlays.Pause;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Colour;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics.UserInterface;
namespace osu.Desktop.VisualTests.Tests

View File

@ -3,7 +3,7 @@
using System.Collections.Generic;
using osu.Desktop.VisualTests.Platform;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Game.Database;
using osu.Game.Modes;
using osu.Game.Screens.Select;

View File

@ -3,7 +3,7 @@
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
@ -71,7 +71,7 @@ namespace osu.Desktop.VisualTests.Tests
Add(new Box
{
RelativeSizeAxes = Framework.Graphics.Axes.Both,
Colour = Color4.Gray,
Colour = Color4.Black,
});
Add(new Player

View File

@ -2,7 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;

View File

@ -2,7 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;

View File

@ -2,7 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics.Cursor;
using osu.Game.Database;
using osu.Game;
@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests
{
base.LoadComplete();
(new BackgroundModeDefault() { Depth = 10 }).Preload(this, AddInternal);
(new BackgroundScreenDefault() { Depth = 10 }).Preload(this, AddInternal);
// Have to construct this here, rather than in the constructor, because
// we depend on some dependencies to be loaded within OsuGameBase.load().

View File

@ -14,22 +14,32 @@ using osu.Game.Database;
using osu.Desktop.Overlays;
using System.Reflection;
using System.Drawing;
using osu.Game.Screens.Menu;
namespace osu.Desktop
{
class OsuGameDesktop : OsuGame
{
private VersionManager versionManager;
public override bool IsDeployedBuild => versionManager.IsDeployedBuild;
public OsuGameDesktop(string[] args = null)
: base(args)
{
versionManager = new VersionManager { Depth = int.MinValue };
}
protected override void LoadComplete()
{
base.LoadComplete();
(new VersionManager()).Preload(this, Add);
versionManager.Preload(this);
ModeChanged += m =>
{
if (!versionManager.IsAlive && m is Intro)
Add(versionManager);
};
}
public override void SetHost(BasicGameHost host)

View File

@ -23,6 +23,10 @@ namespace osu.Desktop.Overlays
private UpdateManager updateManager;
private NotificationManager notification;
AssemblyName assembly = Assembly.GetEntryAssembly().GetName();
public bool IsDeployedBuild => assembly.Version.Major > 0;
protected override bool HideOnEscape => false;
public override bool HandleInput => false;
@ -40,14 +44,13 @@ namespace osu.Desktop.Overlays
bool isDebug = false;
Debug.Assert(isDebug = true);
var asm = Assembly.GetEntryAssembly().GetName();
string version;
if (asm.Version.Major == 0)
if (!IsDeployedBuild)
{
version = @"local " + (isDebug ? @"debug" : @"release");
}
else
version = $@"{asm.Version.Major}.{asm.Version.Minor}.{asm.Version.Build}";
version = $@"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}";
Children = new Drawable[]
{

View File

@ -57,10 +57,10 @@ namespace osu.Game.Modes.Osu.Objects
ControlPoint overridePoint;
ControlPoint timingPoint = beatmap.TimingPointAt(StartTime, out overridePoint);
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
var baseVelocity = 100 * baseDifficulty.SliderMultiplier;
var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment;
Velocity = baseVelocity / (timingPoint.BeatLength * velocityAdjustment);
TickDistance = baseVelocity / (baseDifficulty.SliderTickRate * velocityAdjustment);
Velocity = baseVelocity / timingPoint.BeatLength;
TickDistance = baseVelocity / baseDifficulty.SliderTickRate;
}
public int RepeatCount = 1;

View File

@ -40,7 +40,10 @@ namespace osu.Game.Beatmaps
ControlPoint timingPoint = null;
foreach (var controlPoint in ControlPoints)
{
if (controlPoint.Time <= time)
// Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s).
// This null check makes it so that the first ControlPoint that makes a timing change is used as
// the timingPoint for those HitObject(s).
if (controlPoint.Time <= time || timingPoint == null)
{
if (controlPoint.TimingChange)
{
@ -49,19 +52,10 @@ namespace osu.Game.Beatmaps
}
else overridePoint = controlPoint;
}
// Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s).
// This branch makes it so that the first ControlPoint that makes a timing change is used as the timingPoint for the HitObject(s).
else if (timingPoint == null && controlPoint.TimingChange)
{
timingPoint = controlPoint;
}
else
{
break;
}
else break;
}
return timingPoint;
return timingPoint ?? ControlPoint.Default;
}
}
}

View File

@ -1,20 +1,21 @@
// Copyright (c) 2007-2017 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;
namespace osu.Game.Beatmaps.Timing
{
public class ControlPoint
{
public static ControlPoint Default = new ControlPoint
{
BeatLength = 500,
TimingChange = true,
};
public double Time;
public double BeatLength;
public double VelocityAdjustment;
public bool TimingChange;
}
internal enum TimeSignatures

View File

@ -38,6 +38,7 @@ namespace osu.Game.Online.Chat.Drawables
},
new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
flow = new FlowContainer

View File

@ -3,7 +3,7 @@
using System;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -31,6 +31,8 @@ namespace osu.Game
{
public class OsuGame : OsuGameBase
{
public virtual bool IsDeployedBuild => false;
public Toolbar Toolbar;
private ChatOverlay chat;
@ -39,10 +41,18 @@ namespace osu.Game
private NotificationManager notificationManager;
private MainMenu mainMenu => modeStack?.ChildGameMode as MainMenu;
private Intro intro => modeStack as Intro;
private Intro intro
{
get
{
Screen s = screenStack;
while (s != null && !(s is Intro))
s = s.ChildScreen;
return s as Intro;
}
}
private OsuGameMode modeStack;
private OsuScreen screenStack;
private VolumeControl volume;
@ -106,11 +116,11 @@ namespace osu.Game
}
});
(modeStack = new Intro()).Preload(this, d =>
(screenStack = new Loader()).Preload(this, d =>
{
modeStack.ModePushed += modeAdded;
modeStack.Exited += modeRemoved;
mainContent.Add(modeStack);
screenStack.ModePushed += screenAdded;
screenStack.Exited += screenRemoved;
mainContent.Add(screenStack);
});
//overlay elements
@ -148,7 +158,7 @@ namespace osu.Game
(Toolbar = new Toolbar
{
Depth = -3,
OnHome = delegate { mainMenu?.MakeCurrent(); },
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
}).Preload(this, t =>
{
@ -206,20 +216,16 @@ namespace osu.Game
return base.OnKeyDown(state, args);
}
public Action<GameMode> ModeChanged;
public event Action<Screen> ModeChanged;
private Container mainContent;
private Container overlayContent;
private void modeChanged(GameMode newMode)
private void modeChanged(Screen newScreen)
{
// - Ability to change window size
// - Ability to adjust music playback
// - Frame limiter changes
//central game mode change logic.
if ((newMode as OsuGameMode)?.ShowOverlays != true)
if ((newScreen as OsuScreen)?.ShowOverlays != true)
{
Toolbar.State = Visibility.Hidden;
musicController.State = Visibility.Hidden;
@ -230,22 +236,24 @@ namespace osu.Game
Toolbar.State = Visibility.Visible;
}
Cursor.FadeIn(100);
if (newScreen is MainMenu)
Cursor.FadeIn(100);
ModeChanged?.Invoke(newMode);
ModeChanged?.Invoke(newScreen);
if (newMode == null)
Host.Exit();
if (newScreen == null)
Exit();
}
protected override bool OnExiting()
{
if (!intro.DidLoadMenu || intro.ChildGameMode != null)
if (screenStack.ChildScreen == null) return false;
if (intro == null) return true;
if (!intro.DidLoadMenu || intro.ChildScreen != null)
{
Scheduler.Add(delegate
{
intro.MakeCurrent();
});
Scheduler.Add(intro.MakeCurrent);
return true;
}
@ -256,21 +264,21 @@ namespace osu.Game
{
base.UpdateAfterChildren();
if (modeStack.ChildGameMode != null)
modeStack.ChildGameMode.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight };
if (intro?.ChildScreen != null)
intro.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight };
}
private void modeAdded(GameMode newMode)
private void screenAdded(Screen newScreen)
{
newMode.ModePushed += modeAdded;
newMode.Exited += modeRemoved;
newScreen.ModePushed += screenAdded;
newScreen.Exited += screenRemoved;
modeChanged(newMode);
modeChanged(newScreen);
}
private void modeRemoved(GameMode newMode)
private void screenRemoved(Screen newScreen)
{
modeChanged(newMode);
modeChanged(newScreen);
}
}
}

View File

@ -38,8 +38,9 @@ namespace osu.Game.Overlays
Colour = Color4.Black,
Alpha = 0.6f,
},
scrollContainer = new ScrollContainer()
scrollContainer = new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = Toolbar.Toolbar.HEIGHT },
Children = new[]
{

View File

@ -5,7 +5,7 @@ using System;
using System.Threading;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
@ -13,9 +13,9 @@ using OpenTK;
namespace osu.Game.Screens
{
public abstract class BackgroundMode : GameMode, IEquatable<BackgroundMode>
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
{
public virtual bool Equals(BackgroundMode other)
public virtual bool Equals(BackgroundScreen other)
{
return other?.GetType() == GetType();
}
@ -37,21 +37,21 @@ namespace osu.Game.Screens
this.game = game;
}
public override bool Push(GameMode mode)
public override bool Push(Screen screen)
{
// When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push
// once it's done.
if (mode.LoadState == LoadState.NotLoaded)
if (screen.LoadState == LoadState.NotLoaded)
{
mode.Preload(game, d => Push((BackgroundMode)d));
screen.Preload(game, d => Push((BackgroundScreen)d));
return true;
}
// Make sure the in-progress loading is complete before pushing the GameMode.
while (mode.LoadState < LoadState.Loaded)
while (screen.LoadState < LoadState.Loaded)
Thread.Sleep(1);
base.Push(mode);
base.Push(screen);
return true;
}
@ -62,7 +62,7 @@ namespace osu.Game.Screens
Content.Scale = new Vector2(1 + (x_movement_amount / DrawSize.X) * 2);
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
Content.FadeOut();
Content.MoveToX(x_movement_amount);
@ -73,13 +73,13 @@ namespace osu.Game.Screens
base.OnEntering(last);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
Content.MoveToX(-x_movement_amount, transition_length, EasingTypes.InOutQuart);
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Content.FadeOut(transition_length, EasingTypes.OutExpo);
Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo);
@ -87,7 +87,7 @@ namespace osu.Game.Screens
return base.OnExiting(next);
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
Content.MoveToX(0, transition_length, EasingTypes.OutExpo);
base.OnResuming(last);

View File

@ -9,7 +9,7 @@ using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeBeatmap : BackgroundMode
public class BackgroundScreenBeatmap : BackgroundScreen
{
private Background background;
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Backgrounds
}
}
public BackgroundModeBeatmap(WorkingBeatmap beatmap)
public BackgroundScreenBeatmap(WorkingBeatmap beatmap)
{
Beatmap = beatmap;
}
@ -66,9 +66,9 @@ namespace osu.Game.Screens.Backgrounds
blurTarget = sigma;
}
public override bool Equals(BackgroundMode other)
public override bool Equals(BackgroundScreen other)
{
return base.Equals(other) && beatmap == ((BackgroundModeBeatmap)other).Beatmap;
return base.Equals(other) && beatmap == ((BackgroundScreenBeatmap)other).Beatmap;
}
class BeatmapBackground : Background

View File

@ -5,19 +5,19 @@ using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeCustom : BackgroundMode
public class BackgroundScreenCustom : BackgroundScreen
{
private readonly string textureName;
public BackgroundModeCustom(string textureName)
public BackgroundScreenCustom(string textureName)
{
this.textureName = textureName;
Add(new Background(textureName));
}
public override bool Equals(BackgroundMode other)
public override bool Equals(BackgroundScreen other)
{
return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName;
return base.Equals(other) && textureName == ((BackgroundScreenCustom)other).textureName;
}
}
}

View File

@ -7,7 +7,7 @@ using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeDefault : BackgroundMode
public class BackgroundScreenDefault : BackgroundScreen
{
[BackgroundDependencyLoader]
private void load(BaseGame game)

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeEmpty : BackgroundMode
public class BackgroundScreenEmpty : BackgroundScreen
{
}

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.Charts
{
class ChartInfo : GameModeWhiteBox
class ChartInfo : ScreenWhiteBox
{
}
}

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace osu.Game.Screens.Charts
{
class ChartListing : GameModeWhiteBox
class ChartListing : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(ChartInfo)

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.Direct
{
class OnlineListing : GameModeWhiteBox
class OnlineListing : ScreenWhiteBox
{
}
}

View File

@ -1,23 +1,23 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Screens.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.Screens.Edit
{
class Editor : GameModeWhiteBox
class Editor : ScreenWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -17,7 +17,7 @@ using OpenTK.Graphics;
namespace osu.Game.Screens
{
public class GameModeWhiteBox : OsuGameMode
public class ScreenWhiteBox : OsuScreen
{
private BackButton popButton;
@ -29,9 +29,9 @@ namespace osu.Game.Screens
private Container textContainer;
private Box box;
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg2");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
@ -54,7 +54,7 @@ namespace osu.Game.Screens
Content.FadeIn(transition_time, EasingTypes.OutExpo);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
textContainer.MoveTo(new Vector2((DrawSize.X / 16), 0), transition_time, EasingTypes.OutExpo);
Content.FadeOut(transition_time, EasingTypes.OutExpo);
@ -62,7 +62,7 @@ namespace osu.Game.Screens
return base.OnExiting(next);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
base.OnSuspending(next);
@ -70,7 +70,7 @@ namespace osu.Game.Screens
Content.FadeOut(transition_time, EasingTypes.OutExpo);
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
base.OnResuming(last);
@ -78,7 +78,7 @@ namespace osu.Game.Screens
Content.FadeIn(transition_time, EasingTypes.OutExpo);
}
public GameModeWhiteBox()
public ScreenWhiteBox()
{
Children = new Drawable[]
{
@ -148,7 +148,7 @@ namespace osu.Game.Screens
BackgroundColour = getColourFor(t),
Action = delegate
{
Push(Activator.CreateInstance(t) as GameMode);
Push(Activator.CreateInstance(t) as Screen);
}
});
}

View File

@ -0,0 +1,28 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Game.Screens.Menu;
namespace osu.Game.Screens
{
class Loader : OsuScreen
{
internal override bool ShowOverlays => false;
public Loader()
{
ValidForResume = false;
}
[BackgroundDependencyLoader]
private void load(OsuGame game)
{
if (game.IsDeployedBuild)
new Disclaimer().Preload(game, d => Push((Screen)d));
else
new Intro().Preload(game, d => Push((Screen)d));
}
}
}

View File

@ -218,6 +218,7 @@ namespace osu.Game.Screens.Menu
switch (state)
{
case MenuState.Exit:
case MenuState.Initial:
toolbar?.Hide();
@ -233,6 +234,12 @@ namespace osu.Game.Screens.Menu
foreach (Button b in buttonsPlay)
b.State = ButtonState.Contracted;
if (state == MenuState.Exit)
{
osuLogo.RotateTo(20, EXIT_DELAY * 1.5f);
osuLogo.FadeOut(EXIT_DELAY);
}
break;
case MenuState.TopLevel:
buttonArea.Flush(true);
@ -276,21 +283,6 @@ namespace osu.Game.Screens.Menu
foreach (Button b in buttonsPlay)
b.State = ButtonState.Contracted;
break;
case MenuState.Exit:
buttonArea.FadeOut(200);
foreach (Button b in buttonsTopLevel)
b.State = ButtonState.Contracted;
foreach (Button b in buttonsPlay)
b.State = ButtonState.Contracted;
osuLogo.Delay(150);
osuLogo.ScaleTo(1f, EXIT_DELAY * 1.5f);
osuLogo.RotateTo(20, EXIT_DELAY * 1.5f);
osuLogo.FadeOut(EXIT_DELAY);
break;
}
backButton.State = state == MenuState.Play ? ButtonState.Expanded : ButtonState.Contracted;

View File

@ -0,0 +1,119 @@
// Copyright (c) 2007-2017 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.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Menu
{
class Disclaimer : OsuScreen
{
private Intro intro;
private TextAwesome icon;
private Color4 iconColour;
internal override bool ShowOverlays => false;
public Disclaimer()
{
ValidForResume = false;
Children = new Drawable[]
{
new FlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FlowDirections.Vertical,
Spacing = new Vector2(0, 2),
Children = new Drawable[]
{
icon = new TextAwesome
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Icon = FontAwesome.fa_warning,
TextSize = 30,
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 30,
Text = "This is a development build",
Margin = new MarginPadding
{
Bottom = 20
},
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Don't expect shit to work perfectly as this is very much a work in progress."
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Don't report bugs because we are aware. Don't complain about missing features because we are adding them."
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Sit back and enjoy. Visit discord.gg/ppy if you want to help out!",
Margin = new MarginPadding { Bottom = 20 },
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 12,
Text = "oh and yes, you will get seizures.",
},
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuGame game, OsuColour colours)
{
(intro = new Intro()).Preload(game);
iconColour = colours.Yellow;
}
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Content.FadeInFromZero(500);
icon.Delay(1500);
icon.FadeColour(iconColour, 200);
Delay(6000, true);
Content.FadeOut(250);
Delay(250);
Schedule(() => Push(intro));
}
}
}

View File

@ -5,7 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Containers;
@ -14,7 +14,7 @@ using OpenTK.Graphics;
namespace osu.Game.Screens.Menu
{
class Intro : OsuGameMode
public class Intro : OsuScreen
{
private OsuLogo logo;
@ -28,9 +28,9 @@ namespace osu.Game.Screens.Menu
private AudioSample seeya;
private AudioTrack bgm;
internal override bool ShowOverlays => (ParentGameMode as OsuGameMode)?.ShowOverlays ?? false;
internal override bool ShowOverlays => false;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
public Intro()
{
@ -65,7 +65,7 @@ namespace osu.Game.Screens.Menu
bgm.Looping = true;
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
@ -77,8 +77,7 @@ namespace osu.Game.Screens.Menu
{
bgm.Start();
mainMenu = new MainMenu();
mainMenu.Preload(Game);
(mainMenu = new MainMenu()).Preload(Game);
Scheduler.AddDelayed(delegate
{
@ -95,24 +94,27 @@ namespace osu.Game.Screens.Menu
logo.FadeIn(20000, EasingTypes.OutQuint);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
Content.FadeOut(300);
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
//cancel exiting if we haven't loaded the menu yet.
return !DidLoadMenu;
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
if (!(last is MainMenu))
Content.FadeIn(300);
//we also handle the exit transition.
seeya.Play();
double fadeOutTime = (last.LifetimeEnd - Time.Current) + 100;
double fadeOutTime = 2000;
Scheduler.AddDelayed(Exit, fadeOutTime);

View File

@ -2,8 +2,8 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.GameModes;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Containers;
@ -16,20 +16,20 @@ using osu.Game.Screens.Select;
namespace osu.Game.Screens.Menu
{
public class MainMenu : OsuGameMode
public class MainMenu : OsuScreen
{
private ButtonSystem buttons;
public override string Name => @"Main Menu";
internal override bool ShowOverlays => buttons.State != MenuState.Initial;
private BackgroundMode background;
private BackgroundScreen background;
protected override BackgroundMode CreateBackground() => background;
protected override BackgroundScreen CreateBackground() => background;
public MainMenu()
{
background = new BackgroundModeDefault();
background = new BackgroundScreenDefault();
Children = new Drawable[]
{
@ -62,13 +62,13 @@ namespace osu.Game.Screens.Menu
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
buttons.FadeInFromZero(500);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
base.OnSuspending(next);
@ -80,7 +80,7 @@ namespace osu.Game.Screens.Menu
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
base.OnResuming(last);
@ -92,10 +92,10 @@ namespace osu.Game.Screens.Menu
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
buttons.State = MenuState.Exit;
Content.FadeOut(ButtonSystem.EXIT_DELAY);
Content.FadeOut(3000);
return base.OnExiting(next);
}
}

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace osu.Game.Screens.Multiplayer
{
class Lobby : GameModeWhiteBox
class Lobby : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(MatchCreate),

View File

@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Play;
using OpenTK.Graphics;
@ -11,23 +11,23 @@ using osu.Game.Screens.Select;
namespace osu.Game.Screens.Multiplayer
{
class Match : GameModeWhiteBox
class Match : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(MatchSongSelect),
typeof(Player),
};
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace osu.Game.Screens.Multiplayer
{
class MatchCreate : GameModeWhiteBox
class MatchCreate : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Match)

View File

@ -4,21 +4,21 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
namespace osu.Game.Screens
{
public abstract class OsuGameMode : GameMode
public abstract class OsuScreen : Screen
{
internal BackgroundMode Background { get; private set; }
internal BackgroundScreen 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 virtual BackgroundScreen CreateBackground() => null;
internal virtual bool ShowOverlays => true;
@ -73,15 +73,15 @@ namespace osu.Game.Screens
beatmap = game?.Beatmap;
}
public override bool Push(GameMode mode)
public override bool Push(Screen screen)
{
OsuGameMode nextOsu = mode as OsuGameMode;
OsuScreen nextOsu = screen as OsuScreen;
if (nextOsu != null)
{
nextOsu.beatmap = beatmap;
}
return base.Push(mode);
return base.Push(screen);
}
protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap)
@ -89,11 +89,11 @@ namespace osu.Game.Screens
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
OsuGameMode lastOsu = last as OsuGameMode;
OsuScreen lastOsu = last as OsuScreen;
BackgroundMode bg = CreateBackground();
BackgroundScreen bg = CreateBackground();
if (lastOsu?.Background != null)
{
@ -120,9 +120,9 @@ namespace osu.Game.Screens
base.OnEntering(last);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
OsuGameMode nextOsu = next as OsuGameMode;
OsuScreen nextOsu = next as OsuScreen;
if (Background != null && !Background.Equals(nextOsu?.Background))
{

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -14,9 +14,9 @@ using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
class FailDialog : OsuGameMode
class FailDialog : OsuScreen
{
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
private static readonly Vector2 background_blur = new Vector2(20);
@ -31,13 +31,13 @@ namespace osu.Game.Screens.Play
});
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => (Background as BackgroundModeBeatmap)?.BlurTo(background_blur, 1000));
Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -1,23 +1,23 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Screens.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
class ModSelect : GameModeWhiteBox
class ModSelect : ScreenWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -12,7 +12,7 @@ using osu.Game.Modes;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Screens.Backgrounds;
using OpenTK;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Modes.UI;
using osu.Game.Screens.Ranking;
using osu.Game.Configuration;
@ -27,11 +27,11 @@ using osu.Framework.Logging;
namespace osu.Game.Screens.Play
{
public class Player : OsuGameMode
public class Player : OsuScreen
{
public bool Autoplay;
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
internal override bool ShowOverlays => false;
@ -281,18 +281,18 @@ namespace osu.Game.Screens.Play
});
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
(Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000);
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000);
Background?.FadeTo((100f - dimLevel) / 100, 1000);
Content.Alpha = 0;
dimLevel.ValueChanged += dimChanged;
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
if (pauseOverlay == null) return false;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -14,21 +14,21 @@ using OpenTK.Graphics;
namespace osu.Game.Screens.Ranking
{
class Results : OsuGameMode
class Results : OsuScreen
{
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
private static readonly Vector2 background_blur = new Vector2(20);
ScoreDisplay scoreDisplay;
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => (Background as BackgroundModeBeatmap)?.BlurTo(background_blur, 1000));
Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -8,12 +8,12 @@ using osu.Game.Screens.Edit;
namespace osu.Game.Screens.Select
{
class EditSongSelect : GameModeWhiteBox
class EditSongSelect : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Editor)
};
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
}
}

View File

@ -5,8 +5,8 @@ using osu.Game.Screens.Backgrounds;
namespace osu.Game.Screens.Select
{
class MatchSongSelect : GameModeWhiteBox
class MatchSongSelect : ScreenWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
}
}

View File

@ -9,7 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Beatmaps;
@ -32,11 +32,11 @@ using osu.Framework.Threading;
namespace osu.Game.Screens.Select
{
public class PlaySongSelect : OsuGameMode
public class PlaySongSelect : OsuScreen
{
private Bindable<PlayMode> playMode;
private BeatmapDatabase database;
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
private CarouselContainer carousel;
private TrackManager trackManager;
@ -203,7 +203,7 @@ namespace osu.Game.Screens.Select
Schedule(() => addBeatmapSet(s, Game, true));
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
ensurePlayingSelected();
@ -218,7 +218,7 @@ namespace osu.Game.Screens.Select
filter.Activate();
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
player = null;
@ -233,7 +233,7 @@ namespace osu.Game.Screens.Select
filter.Activate();
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
Content.ScaleTo(1.1f, 250, EasingTypes.InSine);
@ -243,7 +243,7 @@ namespace osu.Game.Screens.Select
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
beatmapInfoWedge.MoveToX(-100, 800, EasingTypes.InQuint);
beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint);
@ -271,7 +271,7 @@ namespace osu.Game.Screens.Select
private void changeBackground(WorkingBeatmap beatmap)
{
var backgroundModeBeatmap = Background as BackgroundModeBeatmap;
var backgroundModeBeatmap = Background as BackgroundScreenBeatmap;
if (backgroundModeBeatmap != null)
{
backgroundModeBeatmap.Beatmap = beatmap;

View File

@ -123,15 +123,17 @@
<Compile Include="Overlays\Toolbar\ToolbarOverlayToggleButton.cs" />
<Compile Include="Overlays\Toolbar\ToolbarUserArea.cs" />
<Compile Include="Overlays\Toolbar\ToolbarUserButton.cs" />
<Compile Include="Screens\BackgroundMode.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeBeatmap.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeCustom.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeDefault.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeEmpty.cs" />
<Compile Include="Screens\BackgroundScreen.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenBeatmap.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenCustom.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenDefault.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenEmpty.cs" />
<Compile Include="Screens\Charts\ChartInfo.cs" />
<Compile Include="Screens\Edit\Editor.cs" />
<Compile Include="Screens\GameModeWhiteBox.cs" />
<Compile Include="Screens\GameScreenWhiteBox.cs" />
<Compile Include="Screens\Loader.cs" />
<Compile Include="Screens\Menu\Button.cs" />
<Compile Include="Screens\Menu\Disclaimer.cs" />
<Compile Include="Screens\Menu\FlowContainerWithOrigin.cs" />
<Compile Include="Screens\Menu\Intro.cs" />
<Compile Include="Screens\Menu\ButtonSystem.cs" />
@ -146,7 +148,7 @@
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Screens\Select\CarouselContainer.cs" />
<Compile Include="Screens\Select\MatchSongSelect.cs" />
<Compile Include="Screens\OsuGameMode.cs" />
<Compile Include="Screens\OsuGameScreen.cs" />
<Compile Include="Screens\Play\ModSelect.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapGroup.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapPanel.cs" />