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

Merge branch 'master' into mod-overlay

This commit is contained in:
Seth 2017-02-23 08:00:24 -04:00 committed by GitHub
commit b4b88712ad
26 changed files with 291 additions and 71 deletions

@ -1 +1 @@
Subproject commit de1568254c4c9a4ea540ccad94700c5c51f70dc2
Subproject commit 56535b834cf2329e5abc8ecf698d19ece9ef7b07

View File

@ -24,7 +24,7 @@ namespace osu.Desktop.VisualTests
private double timePerTest = 200;
[BackgroundDependencyLoader]
private void load(BaseGame game)
private void load(Framework.Game game)
{
Host.MaximumDrawHz = int.MaxValue;
Host.MaximumUpdateHz = int.MaxValue;

View File

@ -20,7 +20,7 @@ namespace osu.Desktop.VisualTests
{
bool benchmark = args.Length > 0 && args[0] == @"-benchmark";
using (BasicGameHost host = Host.GetSuitableHost(@"osu"))
using (GameHost host = Host.GetSuitableHost(@"osu"))
{
Ruleset.Register(new OsuRuleset());
Ruleset.Register(new TaikoRuleset());

View File

@ -60,7 +60,16 @@ namespace osu.Desktop.VisualTests.Tests
Beatmap b = new Beatmap
{
HitObjects = objects
HitObjects = objects,
BeatmapInfo = new BeatmapInfo
{
Metadata = new BeatmapMetadata
{
Artist = @"Unknown",
Title = @"Sample Beatmap",
Author = @"peppy",
}
}
};
decoder.Process(b);
@ -74,10 +83,13 @@ namespace osu.Desktop.VisualTests.Tests
Colour = Color4.Black,
});
Add(new Player
Add(new PlayerLoader(new Player
{
PreferredPlayMode = PlayMode.Osu,
Beatmap = beatmap
})
{
Beatmap = beatmap
});
}
}

View File

@ -42,7 +42,7 @@ namespace osu.Desktop
};
}
public override void SetHost(BasicGameHost host)
public override void SetHost(GameHost host)
{
base.SetHost(host);
var desktopWindow = host.Window as DesktopGameWindow;

View File

@ -3,14 +3,9 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using osu.Desktop.Beatmaps.IO;
using osu.Framework;
using osu.Framework.Desktop;
using osu.Framework.Desktop.Platform;
using osu.Framework.Platform;
using osu.Game;
using osu.Game.IPC;
using osu.Game.Modes;
using osu.Game.Modes.Catch;
@ -51,8 +46,7 @@ namespace osu.Desktop
Ruleset.Register(new ManiaRuleset());
Ruleset.Register(new CatchRuleset());
BaseGame osu = new OsuGameDesktop(args);
host.Add(osu);
host.Add(new OsuGameDesktop(args));
host.Run();
}
return 0;

View File

@ -65,7 +65,7 @@ namespace osu.Game.Tests.Beatmaps.IO
}
}
private OsuGameBase loadOsu(BasicGameHost host)
private OsuGameBase loadOsu(GameHost host)
{
var osu = new OsuGameBase();
host.Add(osu);

View File

@ -14,13 +14,13 @@ namespace osu.Game.Beatmaps.IO
{
private class Reader
{
public Func<BasicStorage, string, bool> Test { get; set; }
public Func<Storage, string, bool> Test { get; set; }
public Type Type { get; set; }
}
private static List<Reader> readers { get; } = new List<Reader>();
public static ArchiveReader GetReader(BasicStorage storage, string path)
public static ArchiveReader GetReader(Storage storage, string path)
{
foreach (var reader in readers)
{
@ -30,7 +30,7 @@ namespace osu.Game.Beatmaps.IO
throw new IOException(@"Unknown file format");
}
protected static void AddReader<T>(Func<BasicStorage, string, bool> test) where T : ArchiveReader
protected static void AddReader<T>(Func<Storage, string, bool> test) where T : ArchiveReader
{
readers.Add(new Reader { Test = test, Type = typeof(T) });
}

View File

@ -113,6 +113,8 @@ namespace osu.Game.Beatmaps
public WorkingBeatmap(Beatmap beatmap)
{
this.beatmap = beatmap;
BeatmapInfo = beatmap.BeatmapInfo;
BeatmapSetInfo = beatmap.BeatmapInfo.BeatmapSet;
}
public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database, bool withStoryboard = false)

View File

@ -189,7 +189,7 @@ namespace osu.Game.Configuration
public string GetUnicodeString(string nonunicode, string unicode)
=> Get<bool>(OsuConfig.ShowUnicode) ? unicode ?? nonunicode : nonunicode ?? unicode;
public OsuConfigManager(BasicStorage storage) : base(storage)
public OsuConfigManager(Storage storage) : base(storage)
{
}
}

View File

@ -22,12 +22,12 @@ namespace osu.Game.Database
public class BeatmapDatabase
{
private SQLiteConnection connection { get; set; }
private BasicStorage storage;
private Storage storage;
public event Action<BeatmapSetInfo> BeatmapSetAdded;
private BeatmapImporter ipc;
public BeatmapDatabase(BasicStorage storage, BasicGameHost importHost = null)
public BeatmapDatabase(Storage storage, GameHost importHost = null)
{
this.storage = storage;

View File

@ -13,7 +13,7 @@ namespace osu.Game.IPC
private IpcChannel<BeatmapImportMessage> channel;
private BeatmapDatabase beatmaps;
public BeatmapImporter(BasicGameHost host, BeatmapDatabase beatmaps = null)
public BeatmapImporter(GameHost host, BeatmapDatabase beatmaps = null)
{
this.beatmaps = beatmaps;

View File

@ -20,7 +20,7 @@ using osu.Game.Online.API;
namespace osu.Game
{
public class OsuGameBase : BaseGame, IOnlineComponent
public class OsuGameBase : Framework.Game, IOnlineComponent
{
protected OsuConfigManager LocalConfig;
@ -101,7 +101,7 @@ namespace osu.Game
});
}
public override void SetHost(BasicGameHost host)
public override void SetHost(GameHost host)
{
if (LocalConfig == null)
LocalConfig = new OsuConfigManager(host.Storage);

View File

@ -45,7 +45,7 @@ namespace osu.Game.Overlays
private Bindable<bool> preferUnicode;
private WorkingBeatmap current;
private BeatmapDatabase beatmaps;
private BaseGame game;
private Framework.Game game;
private Container dragContainer;
@ -322,7 +322,7 @@ namespace osu.Game.Overlays
updateDisplay(current, isNext ? TransformDirection.Next : TransformDirection.Prev);
}
protected override void PerformLoad(BaseGame game)
protected override void PerformLoad(Framework.Game game)
{
this.game = game;
base.PerformLoad(game);

View File

@ -111,12 +111,14 @@ namespace osu.Game.Overlays.Options.Sections.General
{
PlaceholderText = "Username",
RelativeSizeAxes = Axes.X,
Text = api?.Username ?? string.Empty
Text = api?.Username ?? string.Empty,
TabbableContentContainer = this
},
password = new OsuPasswordTextBox
{
PlaceholderText = "Password",
RelativeSizeAxes = Axes.X
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this
},
new OsuCheckbox
{

View File

@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Options.Sections.General
protected override string Header => "Updates";
[BackgroundDependencyLoader]
private void load(BasicStorage storage, OsuConfigManager config)
private void load(Storage storage, OsuConfigManager config)
{
Children = new Drawable[]
{

View File

@ -18,10 +18,10 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
Children = new Drawable[]
{
new OptionLabel { Text = "Resolution: TODO dropdown" },
new OsuCheckbox
new OptionEnumDropDown<WindowMode>
{
LabelText = "Fullscreen mode",
Bindable = config.GetBindable<bool>(FrameworkConfig.Fullscreen),
LabelText = "Screen mode",
Bindable = config.GetBindable<WindowMode>(FrameworkConfig.WindowMode),
},
new OsuCheckbox
{

View File

@ -29,10 +29,10 @@ namespace osu.Game.Screens
return false;
}
BaseGame game;
Framework.Game game;
[BackgroundDependencyLoader]
private void load(BaseGame game)
private void load(Framework.Game game)
{
this.game = game;
}

View File

@ -60,9 +60,9 @@ namespace osu.Game.Screens.Backgrounds
Beatmap = beatmap;
}
public void BlurTo(Vector2 sigma, double duration)
public void BlurTo(Vector2 sigma, double duration, EasingTypes easing = EasingTypes.None)
{
background?.BlurTo(sigma, duration, EasingTypes.OutExpo);
background?.BlurTo(sigma, duration, easing);
blurTarget = sigma;
}

View File

@ -10,7 +10,7 @@ namespace osu.Game.Screens.Backgrounds
public class BackgroundScreenDefault : BackgroundScreen
{
[BackgroundDependencyLoader]
private void load(BaseGame game)
private void load(Framework.Game game)
{
Add(new Background(@"Backgrounds/bg1"));
}

View File

@ -23,6 +23,7 @@ using System.Linq;
using osu.Game.Beatmaps;
using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Logging;
namespace osu.Game.Screens.Play
@ -270,15 +271,19 @@ namespace osu.Game.Screens.Play
{
base.OnEntering(last);
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000);
Background?.FadeTo((100f - dimLevel) / 100, 1000);
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1500, EasingTypes.OutQuint);
Background?.FadeTo((100f - dimLevel) / 100, 1500, EasingTypes.OutQuint);
Content.Alpha = 0;
dimLevel.ValueChanged += dimChanged;
Content.ScaleTo(0.7f);
Content.Delay(250);
Content.FadeIn(250);
Content.ScaleTo(1, 750, EasingTypes.OutQuint);
Delay(750);
Schedule(() =>
{
@ -290,6 +295,8 @@ namespace osu.Game.Screens.Play
protected override void OnSuspending(Screen next)
{
Content.FadeOut(350);
Content.ScaleTo(0.7f, 750, EasingTypes.InQuint);
base.OnSuspending(next);
}

View File

@ -14,7 +14,7 @@ namespace osu.Game.Screens.Play
{
class PlayerInputManager : UserInputManager
{
public PlayerInputManager(BasicGameHost host)
public PlayerInputManager(GameHost host)
: base(host)
{
}

View File

@ -0,0 +1,211 @@
// 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.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Menu;
using OpenTK;
namespace osu.Game.Screens.Play
{
public class PlayerLoader : OsuScreen
{
private readonly Player player;
private OsuLogo logo;
private BeatmapMetadataDisplay info;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
public PlayerLoader(Player player)
{
ValidForResume = false;
this.player = player;
Children = new Drawable[]
{
logo = new OsuLogo
{
Scale = new Vector2(0.15f),
Interactive = false,
},
};
}
[BackgroundDependencyLoader]
private void load()
{
Add(info = new BeatmapMetadataDisplay(Beatmap)
{
Alpha = 0,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
player.Preload(Game);
}
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.FadeTo(0.4f, 250);
Content.ScaleTo(0.7f);
Content.ScaleTo(1, 750, EasingTypes.OutQuint);
Content.FadeInFromZero(500);
Delay(1000, true);
logo.MoveToOffset(new Vector2(0, -180), 500, EasingTypes.InOutExpo);
Delay(250, true);
info.FadeIn(500);
Delay(2000, true);
Content.ScaleTo(0.7f, 300, EasingTypes.InQuint);
Content.FadeOut(250);
Delay(250);
Schedule(() =>
{
if (!Push(player))
Exit();
});
}
protected override bool OnExiting(Screen next)
{
Content.ScaleTo(0.7f, 150, EasingTypes.InQuint);
FadeOut(150);
return base.OnExiting(next);
}
class BeatmapMetadataDisplay : Container
{
class MetadataLine : Container
{
public MetadataLine(string left, string right)
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopRight,
Margin = new MarginPadding { Right = 5 },
Colour = OsuColour.Gray(0.5f),
Text = left,
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopLeft,
Margin = new MarginPadding { Left = 5 },
Text = string.IsNullOrEmpty(right) ? @"-" : right,
}
};
}
}
public BeatmapMetadataDisplay(WorkingBeatmap beatmap)
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new FlowContainer()
{
AutoSizeAxes = Axes.Both,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Direction = FlowDirections.Vertical,
Children = new Drawable[]
{
new OsuSpriteText
{
Text = beatmap.BeatmapInfo.Metadata.Title,
TextSize = 36,
Font = @"Exo2.0-MediumItalic",
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
},
new OsuSpriteText
{
Text = beatmap.BeatmapInfo.Metadata.Artist,
TextSize = 26,
Font = @"Exo2.0-MediumItalic",
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
},
new Container
{
Size = new Vector2(300, 60),
Margin = new MarginPadding(10),
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
CornerRadius = 10,
Masking = true,
Children = new[]
{
new Sprite
{
Texture = beatmap.Background,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
FillMode = FillMode.Fill,
},
}
},
new OsuSpriteText
{
Text = beatmap.BeatmapInfo.Version,
TextSize = 26,
Font = @"Exo2.0-MediumItalic",
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Margin = new MarginPadding
{
Bottom = 40
},
},
new MetadataLine("Source", beatmap.BeatmapInfo.Metadata.Source)
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
},
new MetadataLine("Composer", string.Empty)
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
},
new MetadataLine("Mapper", beatmap.BeatmapInfo.Metadata.Author)
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
},
},
}
};
}
}
}
}

View File

@ -32,6 +32,8 @@ namespace osu.Game.Screens.Select
private FlowContainer buttons;
public OsuLogo StartButton;
public void AddButton(string text, Color4 colour, Action action)
{
var button = new FooterButton
@ -76,7 +78,7 @@ namespace osu.Game.Screens.Select
Height = 3,
Position = new Vector2(0, -3),
},
new OsuLogo()
StartButton = new OsuLogo
{
Anchor = Anchor.BottomRight,
Scale = new Vector2(0.4f),

View File

@ -57,34 +57,12 @@ namespace osu.Game.Screens.Select
private Footer footer;
Player player;
OsuScreen player;
FilterControl filter;
private void start()
{
if (player != null || Beatmap == null)
return;
//in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition
//and provide a better loading experience (at the moment song select is still accepting input during preload).
player = new Player
{
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
PreferredPlayMode = playMode.Value
};
player.Preload(Game, delegate
{
if (!Push(player))
{
player = null;
//error occured?
}
});
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game,
private void load(BeatmapDatabase beatmaps, AudioManager audio, Framework.Game game,
OsuGame osuGame, OsuColour colours)
{
const float carousel_width = 640;
@ -145,10 +123,20 @@ namespace osu.Game.Screens.Select
Bottom = 50,
},
},
footer = new Footer()
footer = new Footer
{
OnBack = Exit,
OnStart = start,
OnStart = () =>
{
if (player != null || Beatmap == null)
return;
(player = new PlayerLoader(new Player
{
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
PreferredPlayMode = playMode.Value
})).Preload(Game, l => Push(player));
}
}
};
@ -295,6 +283,7 @@ namespace osu.Game.Screens.Select
{
backgroundModeBeatmap.Beatmap = beatmap;
backgroundModeBeatmap.BlurTo(background_blur, 1000);
backgroundModeBeatmap.FadeTo(1, 250);
}
if (beatmap != null)
@ -347,7 +336,7 @@ namespace osu.Game.Screens.Select
}
}
private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game, bool select = false)
private void addBeatmapSet(BeatmapSetInfo beatmapSet, Framework.Game game, bool select = false)
{
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
beatmapSet.Beatmaps.ForEach(b =>
@ -365,7 +354,7 @@ namespace osu.Game.Screens.Select
var group = new BeatmapGroup(beatmap)
{
SelectionChanged = selectionChanged,
StartRequested = b => start()
StartRequested = b => footer.StartButton.TriggerClick()
};
//for the time being, let's completely load the difficulty panels in the background.
@ -387,7 +376,7 @@ namespace osu.Game.Screens.Select
}));
}
private void addBeatmapSets(BaseGame game, CancellationToken token)
private void addBeatmapSets(Framework.Game game, CancellationToken token)
{
foreach (var beatmapSet in database.Query<BeatmapSetInfo>())
{
@ -401,7 +390,7 @@ namespace osu.Game.Screens.Select
switch (args.Key)
{
case Key.Enter:
start();
footer.StartButton.TriggerClick();
return true;
}

View File

@ -147,6 +147,7 @@
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
<Compile Include="Screens\Play\FailDialog.cs" />
<Compile Include="Screens\Play\PlayerInputManager.cs" />
<Compile Include="Screens\Play\PlayerLoader.cs" />
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Screens\Select\CarouselContainer.cs" />
<Compile Include="Screens\Select\MatchSongSelect.cs" />