1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Merge branch 'master' into decrease-disc-rotation-on-rewind

This commit is contained in:
Salman Ahmed 2019-09-26 04:52:11 +03:00 committed by GitHub
commit 0b2a025cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 668 additions and 215 deletions

View File

@ -1,11 +1,11 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
CFPropertyList (3.0.0) CFPropertyList (3.0.1)
addressable (2.6.0) addressable (2.7.0)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 5.0)
atomos (0.1.3) atomos (0.1.3)
babosa (1.0.2) babosa (1.0.3)
claide (1.0.3) claide (1.0.3)
colored (1.2) colored (1.2)
colored2 (3.1.2) colored2 (3.1.2)
@ -26,8 +26,8 @@ GEM
http-cookie (~> 1.0.0) http-cookie (~> 1.0.0)
faraday_middleware (0.13.1) faraday_middleware (0.13.1)
faraday (>= 0.7.4, < 1.0) faraday (>= 0.7.4, < 1.0)
fastimage (2.1.5) fastimage (2.1.7)
fastlane (2.129.0) fastlane (2.131.0)
CFPropertyList (>= 2.3, < 4.0.0) CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0) addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0) babosa (>= 1.0.2, < 2.0.0)
@ -77,9 +77,9 @@ GEM
representable (~> 3.0) representable (~> 3.0)
retriable (>= 2.0, < 4.0) retriable (>= 2.0, < 4.0)
signet (~> 0.9) signet (~> 0.9)
google-cloud-core (1.3.0) google-cloud-core (1.3.1)
google-cloud-env (~> 1.0) google-cloud-env (~> 1.0)
google-cloud-env (1.2.0) google-cloud-env (1.2.1)
faraday (~> 0.11) faraday (~> 0.11)
google-cloud-storage (1.16.0) google-cloud-storage (1.16.0)
digest-crc (~> 0.4) digest-crc (~> 0.4)
@ -100,9 +100,9 @@ GEM
json (2.2.0) json (2.2.0)
jwt (2.1.0) jwt (2.1.0)
memoist (0.16.0) memoist (0.16.0)
mime-types (3.2.2) mime-types (3.3)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331) mime-types-data (3.2019.0904)
mini_magick (4.9.5) mini_magick (4.9.5)
mini_portile2 (2.4.0) mini_portile2 (2.4.0)
multi_json (1.13.1) multi_json (1.13.1)
@ -121,14 +121,14 @@ GEM
uber (< 0.2.0) uber (< 0.2.0)
retriable (3.1.2) retriable (3.1.2)
rouge (2.0.7) rouge (2.0.7)
rubyzip (1.2.3) rubyzip (1.2.4)
security (0.1.3) security (0.1.3)
signet (0.11.0) signet (0.11.0)
addressable (~> 2.3) addressable (~> 2.3)
faraday (~> 0.9) faraday (~> 0.9)
jwt (>= 1.5, < 3.0) jwt (>= 1.5, < 3.0)
multi_json (~> 1.10) multi_json (~> 1.10)
simctl (1.6.5) simctl (1.6.6)
CFPropertyList CFPropertyList
naturally naturally
slack-notifier (2.3.2) slack-notifier (2.3.2)

View File

@ -31,12 +31,10 @@ If you are not interested in developing the game, you can still consume our [bin
**Latest build:** **Latest build:**
| [Windows (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | [macOS 10.12+](https://github.com/ppy/osu/releases/latest/download/osu.app.zip) | | [Windows (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | [macOS 10.12+](https://github.com/ppy/osu/releases/latest/download/osu.app.zip) | [iOS(iOS 10+)](https://testflight.apple.com/join/2tLcjWlF) | [Android (5+)](https://github.com/ppy/osu/releases/latest/download/sh.ppy.osulazer.apk)
| ------------- | ------------- | | ------------- | ------------- | ------------- | ------------- |
- **Linux** users are recommended to self-compile until we have official deployment in place. - **Linux** users are recommended to self-compile until we have official deployment in place.
- **iOS** users can join the [TestFlight beta program](https://testflight.apple.com/join/2tLcjWlF) (note that due to high demand this is regularly full).
- **Android** users can self-compile, and expect a public beta soon.
If your platform is not listed above, there is still a chance you can manually build it by following the instructions below. If your platform is not listed above, there is still a chance you can manually build it by following the instructions below.

View File

@ -1,5 +1,83 @@
update_fastlane update_fastlane
platform :android do
desc 'Deploy to play store'
lane :beta do |options|
update_version(
version: options[:version],
build: options[:build],
)
build(options)
supply(
apk: './osu.Android/bin/Release/sh.ppy.osulazer-Signed.apk',
package_name: 'sh.ppy.osulazer',
track: 'alpha', # upload to alpha, we can promote it later
json_key: options[:json_key],
)
end
desc 'Deploy to github release'
lane :build_github do |options|
update_version(
version: options[:version],
build: options[:build],
)
build(options)
client = HTTPClient.new
changelog = client.get_content 'https://gist.githubusercontent.com/peppy/aaa2ec1a323554b619671cac6dbbb776/raw'
changelog.gsub!('$BUILD_ID', options[:build])
set_github_release(
repository_name: "ppy/osu",
api_token: ENV["GITHUB_TOKEN"],
name: options[:build],
tag_name: options[:build],
is_draft: true,
description: changelog,
commitish: "master",
upload_assets: ["osu.Android/bin/Release/sh.ppy.osulazer.apk"]
)
end
desc 'Compile the project'
lane :build do |options|
nuget_restore(
project_path: 'osu.Android.sln'
)
souyuz(
build_configuration: 'Release',
solution_path: 'osu.Android.sln',
platform: "android",
output_path: "osu.Android/bin/Release/",
keystore_path: options[:keystore_path],
keystore_alias: options[:keystore_alias],
keystore_password: ENV["KEYSTORE_PASSWORD"]
)
end
lane :update_version do |options|
split = options[:build].split('.')
split[1] = split[1].to_s.rjust(4, '0')
android_build = split.join('')
app_version(
solution_path: 'osu.Android.sln',
version: options[:version],
build: android_build,
)
end
end
platform :ios do platform :ios do
desc 'Deploy to testflight' desc 'Deploy to testflight'
lane :beta do |options| lane :beta do |options|

View File

@ -15,6 +15,30 @@ Install _fastlane_ using
or alternatively using `brew cask install fastlane` or alternatively using `brew cask install fastlane`
# Available Actions # Available Actions
## Android
### android beta
```
fastlane android beta
```
Deploy to play store
### android build_github
```
fastlane android build_github
```
Deploy to github release
### android build
```
fastlane android build
```
Compile the project
### android update_version
```
fastlane android update_version
```
----
## iOS ## iOS
### ios beta ### ios beta
``` ```

View File

@ -4,11 +4,37 @@
using System; using System;
using Android.App; using Android.App;
using osu.Game; using osu.Game;
using osu.Game.Updater;
namespace osu.Android namespace osu.Android
{ {
public class OsuGameAndroid : OsuGame public class OsuGameAndroid : OsuGame
{ {
public override Version AssemblyVersion => new Version(Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName); public override Version AssemblyVersion
{
get
{
var packageInfo = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0);
try
{
string versionName = packageInfo.VersionCode.ToString();
// undo play store version garbling
return new Version(int.Parse(versionName.Substring(0, 4)), int.Parse(versionName.Substring(4, 4)), int.Parse(versionName.Substring(8, 1)));
}
catch
{
}
return new Version(packageInfo.VersionName);
}
}
protected override void LoadComplete()
{
base.LoadComplete();
Add(new SimpleUpdateManager());
}
} }
} }

View File

@ -17,6 +17,7 @@ using osu.Framework.Logging;
using osu.Framework.Platform.Windows; using osu.Framework.Platform.Windows;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Updater;
namespace osu.Desktop namespace osu.Desktop
{ {

View File

@ -8,11 +8,8 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game; using osu.Game;
using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -20,17 +17,9 @@ namespace osu.Desktop.Overlays
{ {
public class VersionManager : OverlayContainer public class VersionManager : OverlayContainer
{ {
private OsuConfigManager config;
private OsuGameBase game;
private NotificationOverlay notificationOverlay;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config) private void load(OsuColour colours, TextureStore textures, OsuGameBase game)
{ {
notificationOverlay = notification;
this.config = config;
this.game = game;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Anchor = Anchor.BottomCentre; Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre; Origin = Anchor.BottomCentre;
@ -85,48 +74,6 @@ namespace osu.Desktop.Overlays
}; };
} }
protected override void LoadComplete()
{
base.LoadComplete();
var version = game.Version;
var lastVersion = config.Get<string>(OsuSetting.Version);
if (game.IsDeployedBuild && version != lastVersion)
{
config.Set(OsuSetting.Version, version);
// only show a notification if we've previously saved a version to the config file (ie. not the first run).
if (!string.IsNullOrEmpty(lastVersion))
notificationOverlay.Post(new UpdateCompleteNotification(version));
}
}
private class UpdateCompleteNotification : SimpleNotification
{
private readonly string version;
public UpdateCompleteNotification(string version)
{
this.version = version;
Text = $"You are now running osu!lazer {version}.\nClick to see what's new!";
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, ChangelogOverlay changelog, NotificationOverlay notificationOverlay)
{
Icon = FontAwesome.Solid.CheckSquare;
IconBackgound.Colour = colours.BlueDark;
Activated = delegate
{
notificationOverlay.Hide();
changelog.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version);
return true;
};
}
}
protected override void PopIn() protected override void PopIn()
{ {
this.FadeIn(1400, Easing.OutQuint); this.FadeIn(1400, Easing.OutQuint);

View File

@ -20,7 +20,7 @@ using LogLevel = Splat.LogLevel;
namespace osu.Desktop.Updater namespace osu.Desktop.Updater
{ {
public class SquirrelUpdateManager : Component public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager
{ {
private UpdateManager updateManager; private UpdateManager updateManager;
private NotificationOverlay notificationOverlay; private NotificationOverlay notificationOverlay;

View File

@ -15,7 +15,6 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK; using osuTK;
@ -67,6 +66,8 @@ namespace osu.Game.Rulesets.Mania.Tests
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.TopCentre)); AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.TopCentre));
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.BottomCentre)); AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.BottomCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.TopCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.BottomCentre));
AddStep("flip direction", () => AddStep("flip direction", () =>
{ {
@ -76,10 +77,14 @@ namespace osu.Game.Rulesets.Mania.Tests
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.BottomCentre)); AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.BottomCentre));
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.TopCentre)); AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.TopCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.BottomCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.TopCentre));
} }
private bool notesInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.Columns.SelectMany(c => c.AllHitObjects).All(o => o.Anchor == anchor); private bool notesInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.Columns.SelectMany(c => c.AllHitObjects).All(o => o.Anchor == anchor);
private bool barsInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.AllHitObjects.Where(obj => obj is DrawableBarLine).All(o => o.Anchor == anchor);
private void createNote() private void createNote()
{ {
foreach (var stage in stages) foreach (var stage in stages)

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Mania.Objects
{
public class BarLine : ManiaHitObject, IBarLine
{
public bool Major { get; set; }
}
}

View File

@ -4,7 +4,6 @@
using osuTK; using osuTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osuTK.Graphics; using osuTK.Graphics;
@ -14,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
/// Visualises a <see cref="BarLine"/>. Although this derives DrawableManiaHitObject, /// Visualises a <see cref="BarLine"/>. Although this derives DrawableManiaHitObject,
/// this does not handle input/sound like a normal hit object. /// this does not handle input/sound like a normal hit object.
/// </summary> /// </summary>
public class DrawableBarLine : DrawableHitObject<BarLine> public class DrawableBarLine : DrawableManiaHitObject<BarLine>
{ {
/// <summary> /// <summary>
/// Height of major bar line triangles. /// Height of major bar line triangles.

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.UI
public DrawableManiaRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) public DrawableManiaRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
: base(ruleset, beatmap, mods) : base(ruleset, beatmap, mods)
{ {
BarLines = new BarLineGenerator(Beatmap).BarLines; BarLines = new BarLineGenerator<BarLine>(Beatmap).BarLines;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osuTK; using osuTK;

View File

@ -12,7 +12,6 @@ using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;

View File

@ -40,9 +40,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
for (int i = 0; i < max_sprites; i++) for (int i = 0; i < max_sprites; i++)
{ {
// InvalidationID 1 forces an update of each part of the cursor trail the first time ApplyState is run on the draw node // -1 signals that the part is unusable, and should not be drawn
// This is to prevent garbage data from being sent to the vertex shader, resulting in visual issues on some platforms parts[i].InvalidationID = -1;
parts[i].InvalidationID = 1;
} }
} }
@ -112,7 +111,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
for (int i = 0; i < parts.Length; ++i) for (int i = 0; i < parts.Length; ++i)
{ {
parts[i].Time -= time; parts[i].Time -= time;
++parts[i].InvalidationID;
if (parts[i].InvalidationID != -1)
++parts[i].InvalidationID;
} }
time = 0; time = 0;
@ -205,8 +206,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public TrailDrawNode(CursorTrail source) public TrailDrawNode(CursorTrail source)
: base(source) : base(source)
{ {
for (int i = 0; i < max_sprites; i++)
parts[i].InvalidationID = 0;
} }
public override void ApplyState() public override void ApplyState()
@ -218,11 +217,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
size = Source.partSize; size = Source.partSize;
time = Source.time; time = Source.time;
for (int i = 0; i < Source.parts.Length; ++i) Source.parts.CopyTo(parts, 0);
{
if (Source.parts[i].InvalidationID > parts[i].InvalidationID)
parts[i] = Source.parts[i];
}
} }
public override void Draw(Action<TexturedVertex2D> vertexAction) public override void Draw(Action<TexturedVertex2D> vertexAction)
@ -234,6 +229,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
for (int i = 0; i < parts.Length; ++i) for (int i = 0; i < parts.Length; ++i)
{ {
if (parts[i].InvalidationID == -1)
continue;
vertexBatch.DrawTime = parts[i].Time; vertexBatch.DrawTime = parts[i].Time;
Vector2 pos = parts[i].Position; Vector2 pos = parts[i].Position;

View File

@ -53,6 +53,11 @@ namespace osu.Game.Rulesets.Taiko.Tests
AddStep("Strong Rim", () => addRimHit(true)); AddStep("Strong Rim", () => addRimHit(true));
AddStep("Add bar line", () => addBarLine(false)); AddStep("Add bar line", () => addBarLine(false));
AddStep("Add major bar line", () => addBarLine(true)); AddStep("Add major bar line", () => addBarLine(true));
AddStep("Add centre w/ bar line", () =>
{
addCentreHit(false);
addBarLine(true);
});
AddStep("Height test 1", () => changePlayfieldSize(1)); AddStep("Height test 1", () => changePlayfieldSize(1));
AddStep("Height test 2", () => changePlayfieldSize(2)); AddStep("Height test 2", () => changePlayfieldSize(2));
AddStep("Height test 3", () => changePlayfieldSize(3)); AddStep("Height test 3", () => changePlayfieldSize(3));

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Objects
{
public class BarLine : TaikoHitObject, IBarLine
{
public bool Major { get; set; }
}
}

View File

@ -5,7 +5,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osuTK; using osuTK;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {

View File

@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Taiko.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
new BarLineGenerator(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar.Major ? new DrawableBarLineMajor(bar) : new DrawableBarLine(bar))); new BarLineGenerator<BarLine>(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar.Major ? new DrawableBarLineMajor(bar) : new DrawableBarLine(bar)));
} }
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this); public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -115,6 +116,32 @@ namespace osu.Game.Tests.Visual.Gameplay
assertPosition(4, 1f); assertPosition(4, 1f);
} }
[Test]
public void TestSliderMultiplierDoesNotAffectRelativeBeatLength()
{
var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range });
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
AddStep("adjust time range", () => drawableRuleset.TimeRange.Value = 5000);
for (int i = 0; i < 5; i++)
assertPosition(i, i / 5f);
}
[Test]
public void TestSliderMultiplierAffectsNonRelativeBeatLength()
{
var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range });
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
createTest(beatmap);
AddStep("adjust time range", () => drawableRuleset.TimeRange.Value = 2000);
assertPosition(0, 0);
assertPosition(1, 1);
}
private void assertPosition(int index, float relativeY) => AddAssert($"hitobject {index} at {relativeY}", private void assertPosition(int index, float relativeY) => AddAssert($"hitobject {index} at {relativeY}",
() => Precision.AlmostEquals(drawableRuleset.Playfield.AllHitObjects.ElementAt(index).DrawPosition.Y, drawableRuleset.Playfield.HitObjectContainer.DrawHeight * relativeY)); () => Precision.AlmostEquals(drawableRuleset.Playfield.AllHitObjects.ElementAt(index).DrawPosition.Y, drawableRuleset.Playfield.HitObjectContainer.DrawHeight * relativeY));
@ -193,6 +220,8 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping; protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
public new Bindable<double> TimeRange => base.TimeRange;
public TestDrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) public TestDrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
: base(ruleset, beatmap, mods) : base(ruleset, beatmap, mods)
{ {

View File

@ -0,0 +1,202 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Screens;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Select;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
using IntroSequence = osu.Game.Configuration.IntroSequence;
namespace osu.Game.Tests.Visual.Menus
{
public class TestSceneScreenNavigation : ManualInputManagerTestScene
{
private const float click_padding = 25;
private GameHost host;
private TestOsuGame osuGame;
private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, osuGame.LayoutRectangle.Bottom - click_padding));
private Vector2 optionsButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, click_padding));
[BackgroundDependencyLoader]
private void load(GameHost host)
{
this.host = host;
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
};
}
[SetUpSteps]
public void SetUpSteps()
{
AddStep("Create new game instance", () =>
{
if (osuGame != null)
{
Remove(osuGame);
osuGame.Dispose();
}
osuGame = new TestOsuGame(LocalStorage, API);
osuGame.SetHost(host);
// todo: this can be removed once we can run audio trakcs without a device present
// see https://github.com/ppy/osu/issues/1302
osuGame.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
Add(osuGame);
});
AddUntilStep("Wait for load", () => osuGame.IsLoaded);
AddUntilStep("Wait for intro", () => osuGame.ScreenStack.CurrentScreen is IntroScreen);
confirmAtMainMenu();
}
[Test]
public void TestExitSongSelectWithEscape()
{
TestSongSelect songSelect = null;
pushAndConfirm(() => songSelect = new TestSongSelect());
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
AddStep("Press escape", () => pressAndRelease(Key.Escape));
AddAssert("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
exitViaEscapeAndConfirm();
}
[Test]
public void TestExitSongSelectWithClick()
{
TestSongSelect songSelect = null;
pushAndConfirm(() => songSelect = new TestSongSelect());
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
// BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered.
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == osuGame.BackButton));
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
AddUntilStep("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
exitViaBackButtonAndConfirm();
}
[Test]
public void TestExitMultiWithEscape()
{
pushAndConfirm(() => new Screens.Multi.Multiplayer());
exitViaEscapeAndConfirm();
}
[Test]
public void TestExitMultiWithBackButton()
{
pushAndConfirm(() => new Screens.Multi.Multiplayer());
exitViaBackButtonAndConfirm();
}
[Test]
public void TestOpenOptionsAndExitWithEscape()
{
AddUntilStep("Wait for options to load", () => osuGame.Settings.IsLoaded);
AddStep("Enter menu", () => pressAndRelease(Key.Enter));
AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition));
AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left));
AddAssert("Options overlay was opened", () => osuGame.Settings.State.Value == Visibility.Visible);
AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape));
AddAssert("Options overlay was closed", () => osuGame.Settings.State.Value == Visibility.Hidden);
}
private void pushAndConfirm(Func<Screen> newScreen)
{
Screen screen = null;
AddStep("Push new screen", () => osuGame.ScreenStack.Push(screen = newScreen()));
AddUntilStep("Wait for new screen", () => osuGame.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
}
private void exitViaEscapeAndConfirm()
{
AddStep("Press escape", () => pressAndRelease(Key.Escape));
confirmAtMainMenu();
}
private void exitViaBackButtonAndConfirm()
{
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
confirmAtMainMenu();
}
private void confirmAtMainMenu() => AddUntilStep("Wait for main menu", () => osuGame.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
private void pressAndRelease(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
private class TestOsuGame : OsuGame
{
public new ScreenStack ScreenStack => base.ScreenStack;
public new BackButton BackButton => base.BackButton;
public new SettingsPanel Settings => base.Settings;
public new OsuConfigManager LocalConfig => base.LocalConfig;
protected override Loader CreateLoader() => new TestLoader();
public TestOsuGame(Storage storage, IAPIProvider api)
{
Storage = storage;
API = api;
}
protected override void LoadComplete()
{
base.LoadComplete();
API.Login("Rhythm Champion", "osu!");
}
}
private class TestSongSelect : PlaySongSelect
{
public ModSelectOverlay ModSelectOverlay => ModSelect;
}
private class TestLoader : Loader
{
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler();
private class TestShaderPrecompiler : ShaderPrecompiler
{
protected override bool AllLoaded => true;
}
}
}
}

View File

@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.SongSelect
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>(); private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>(); private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>();
private BeatmapInfo currentSelection; private BeatmapInfo currentSelection => carousel.SelectedBeatmap;
private const int set_count = 5; private const int set_count = 5;
@ -56,37 +56,26 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}); });
List<BeatmapSetInfo> beatmapSets = new List<BeatmapSetInfo>();
for (int i = 1; i <= set_count; i++)
beatmapSets.Add(createTestBeatmapSet(i));
carousel.SelectionChanged = s => currentSelection = s;
loadBeatmaps(beatmapSets);
testTraversal();
testFiltering();
testRandom();
testAddRemove();
testSorting();
testRemoveAll();
testEmptyTraversal();
testHiding();
testSelectingFilteredRuleset();
testCarouselRootIsRandom();
} }
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets) private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null)
{ {
if (beatmapSets == null)
{
beatmapSets = new List<BeatmapSetInfo>();
for (int i = 1; i <= set_count; i++)
beatmapSets.Add(createTestBeatmapSet(i));
}
bool changed = false; bool changed = false;
AddStep($"Load {beatmapSets.Count} Beatmaps", () => AddStep($"Load {beatmapSets.Count} Beatmaps", () =>
{ {
carousel.Filter(new FilterCriteria());
carousel.BeatmapSetsChanged = () => changed = true; carousel.BeatmapSetsChanged = () => changed = true;
carousel.BeatmapSets = beatmapSets; carousel.BeatmapSets = beatmapSets;
}); });
AddUntilStep("Wait for load", () => changed); AddUntilStep("Wait for load", () => changed);
} }
@ -173,8 +162,11 @@ namespace osu.Game.Tests.Visual.SongSelect
/// <summary> /// <summary>
/// Test keyboard traversal /// Test keyboard traversal
/// </summary> /// </summary>
private void testTraversal() [Test]
public void TestTraversal()
{ {
loadBeatmaps();
advanceSelection(direction: 1, diff: false); advanceSelection(direction: 1, diff: false);
checkSelected(1, 1); checkSelected(1, 1);
@ -199,8 +191,11 @@ namespace osu.Game.Tests.Visual.SongSelect
/// <summary> /// <summary>
/// Test filtering /// Test filtering
/// </summary> /// </summary>
private void testFiltering() [Test]
public void TestFiltering()
{ {
loadBeatmaps();
// basic filtering // basic filtering
setSelected(1, 1); setSelected(1, 1);
@ -262,8 +257,11 @@ namespace osu.Game.Tests.Visual.SongSelect
/// <summary> /// <summary>
/// Test random non-repeating algorithm /// Test random non-repeating algorithm
/// </summary> /// </summary>
private void testRandom() [Test]
public void TestRandom()
{ {
loadBeatmaps();
setSelected(1, 1); setSelected(1, 1);
nextRandom(); nextRandom();
@ -299,8 +297,11 @@ namespace osu.Game.Tests.Visual.SongSelect
/// <summary> /// <summary>
/// Test adding and removing beatmap sets /// Test adding and removing beatmap sets
/// </summary> /// </summary>
private void testAddRemove() [Test]
public void TestAddRemove()
{ {
loadBeatmaps();
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 1))); AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 1)));
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 2))); AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 2)));
@ -322,16 +323,22 @@ namespace osu.Game.Tests.Visual.SongSelect
/// <summary> /// <summary>
/// Test sorting /// Test sorting
/// </summary> /// </summary>
private void testSorting() [Test]
public void TestSorting()
{ {
loadBeatmaps();
AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false)); AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false));
AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz"); AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz");
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false)); AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!")); AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
} }
private void testRemoveAll() [Test]
public void TestRemoveAll()
{ {
loadBeatmaps();
setSelected(2, 1); setSelected(2, 1);
AddAssert("Selection is non-null", () => currentSelection != null); AddAssert("Selection is non-null", () => currentSelection != null);
@ -353,8 +360,11 @@ namespace osu.Game.Tests.Visual.SongSelect
checkNoSelection(); checkNoSelection();
} }
private void testEmptyTraversal() [Test]
public void TestEmptyTraversal()
{ {
loadBeatmaps(new List<BeatmapSetInfo>());
advanceSelection(direction: 1, diff: false); advanceSelection(direction: 1, diff: false);
checkNoSelection(); checkNoSelection();
@ -368,11 +378,14 @@ namespace osu.Game.Tests.Visual.SongSelect
checkNoSelection(); checkNoSelection();
} }
private void testHiding() [Test]
public void TestHiding()
{ {
var hidingSet = createTestBeatmapSet(1); BeatmapSetInfo hidingSet = createTestBeatmapSet(1);
hidingSet.Beatmaps[1].Hidden = true; hidingSet.Beatmaps[1].Hidden = true;
AddStep("Add set with diff 2 hidden", () => carousel.UpdateBeatmapSet(hidingSet));
loadBeatmaps(new List<BeatmapSetInfo> { hidingSet });
setSelected(1, 1); setSelected(1, 1);
checkVisibleItemCount(true, 2); checkVisibleItemCount(true, 2);
@ -402,7 +415,8 @@ namespace osu.Game.Tests.Visual.SongSelect
} }
} }
private void testSelectingFilteredRuleset() [Test]
public void TestSelectingFilteredRuleset()
{ {
var testMixed = createTestBeatmapSet(set_count + 1); var testMixed = createTestBeatmapSet(set_count + 1);
AddStep("add mixed ruleset beatmapset", () => AddStep("add mixed ruleset beatmapset", () =>
@ -437,14 +451,16 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle)); AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
} }
private void testCarouselRootIsRandom() [Test]
public void TestCarouselRootIsRandom()
{ {
List<BeatmapSetInfo> beatmapSets = new List<BeatmapSetInfo>(); List<BeatmapSetInfo> manySets = new List<BeatmapSetInfo>();
for (int i = 1; i <= 50; i++) for (int i = 1; i <= 50; i++)
beatmapSets.Add(createTestBeatmapSet(i)); manySets.Add(createTestBeatmapSet(i));
loadBeatmaps(manySets);
loadBeatmaps(beatmapSets);
advanceSelection(direction: 1, diff: false); advanceSelection(direction: 1, diff: false);
checkNonmatchingFilter(); checkNonmatchingFilter();
checkNonmatchingFilter(); checkNonmatchingFilter();

View File

@ -22,6 +22,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public TestSceneBackButton() public TestSceneBackButton()
{ {
BackButton button; BackButton button;
BackButton.Receptor receptor = new BackButton.Receptor();
Child = new Container Child = new Container
{ {
@ -31,12 +32,13 @@ namespace osu.Game.Tests.Visual.UserInterface
Masking = true, Masking = true,
Children = new Drawable[] Children = new Drawable[]
{ {
receptor,
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.SlateGray Colour = Color4.SlateGray
}, },
button = new BackButton button = new BackButton(receptor)
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,

View File

@ -10,14 +10,16 @@ using osu.Game.Input.Bindings;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public class BackButton : VisibilityContainer, IKeyBindingHandler<GlobalAction> public class BackButton : VisibilityContainer
{ {
public Action Action; public Action Action;
private readonly TwoLayerButton button; private readonly TwoLayerButton button;
public BackButton() public BackButton(Receptor receptor)
{ {
receptor.OnBackPressed = () => Action?.Invoke();
Size = TwoLayerButton.SIZE_EXTENDED; Size = TwoLayerButton.SIZE_EXTENDED;
Child = button = new TwoLayerButton Child = button = new TwoLayerButton
@ -37,19 +39,6 @@ namespace osu.Game.Graphics.UserInterface
button.HoverColour = colours.PinkDark; button.HoverColour = colours.PinkDark;
} }
public bool OnPressed(GlobalAction action)
{
if (action == GlobalAction.Back)
{
Action?.Invoke();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
protected override void PopIn() protected override void PopIn()
{ {
button.MoveToX(0, 400, Easing.OutQuint); button.MoveToX(0, 400, Easing.OutQuint);
@ -61,5 +50,24 @@ namespace osu.Game.Graphics.UserInterface
button.MoveToX(-TwoLayerButton.SIZE_EXTENDED.X / 2, 400, Easing.OutQuint); button.MoveToX(-TwoLayerButton.SIZE_EXTENDED.X / 2, 400, Easing.OutQuint);
button.FadeOut(400, Easing.OutQuint); button.FadeOut(400, Easing.OutQuint);
} }
public class Receptor : Drawable, IKeyBindingHandler<GlobalAction>
{
public Action OnBackPressed;
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
OnBackPressed?.Invoke();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
}
} }
} }

View File

@ -64,7 +64,10 @@ namespace osu.Game.Online.API
public void Perform(IAPIProvider api) public void Perform(IAPIProvider api)
{ {
if (!(api is APIAccess apiAccess)) if (!(api is APIAccess apiAccess))
throw new NotSupportedException($"A {nameof(APIAccess)} is required to perform requests."); {
Fail(new NotSupportedException($"A {nameof(APIAccess)} is required to perform requests."));
return;
}
API = apiAccess; API = apiAccess;

View File

@ -81,10 +81,14 @@ namespace osu.Game
public readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(); public readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
private OsuScreenStack screenStack; protected OsuScreenStack ScreenStack;
protected BackButton BackButton;
protected SettingsPanel Settings;
private VolumeOverlay volume; private VolumeOverlay volume;
private OsuLogo osuLogo; private OsuLogo osuLogo;
private BackButton backButton;
private MainMenu menuScreen; private MainMenu menuScreen;
@ -96,8 +100,6 @@ namespace osu.Game
private readonly string[] args; private readonly string[] args;
private SettingsPanel settings;
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>(); private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
private readonly List<OverlayContainer> toolbarElements = new List<OverlayContainer>(); private readonly List<OverlayContainer> toolbarElements = new List<OverlayContainer>();
@ -318,6 +320,8 @@ namespace osu.Game
}, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true); }, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true);
} }
protected virtual Loader CreateLoader() => new Loader();
#region Beatmap progression #region Beatmap progression
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap) private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap)
@ -356,7 +360,7 @@ namespace osu.Game
performFromMainMenuTask?.Cancel(); performFromMainMenuTask?.Cancel();
// if the current screen does not allow screen changing, give the user an option to try again later. // if the current screen does not allow screen changing, give the user an option to try again later.
if (!bypassScreenAllowChecks && (screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange == false) if (!bypassScreenAllowChecks && (ScreenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange == false)
{ {
notifications.Post(new SimpleNotification notifications.Post(new SimpleNotification
{ {
@ -374,7 +378,7 @@ namespace osu.Game
CloseAllOverlays(false); CloseAllOverlays(false);
// we may already be at the target screen type. // we may already be at the target screen type.
if (targetScreen != null && screenStack.CurrentScreen?.GetType() == targetScreen) if (targetScreen != null && ScreenStack.CurrentScreen?.GetType() == targetScreen)
{ {
action(); action();
return; return;
@ -421,6 +425,7 @@ namespace osu.Game
ScoreManager.PresentImport = items => PresentScore(items.First()); ScoreManager.PresentImport = items => PresentScore(items.First());
Container logoContainer; Container logoContainer;
BackButton.Receptor receptor;
dependencies.CacheAs(idleTracker = new GameIdleTracker(6000)); dependencies.CacheAs(idleTracker = new GameIdleTracker(6000));
@ -437,15 +442,16 @@ namespace osu.Game
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
screenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }, receptor = new BackButton.Receptor(),
backButton = new BackButton ScreenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both },
BackButton = new BackButton(receptor)
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Action = () => Action = () =>
{ {
if ((screenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true) if ((ScreenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
screenStack.Exit(); ScreenStack.Exit();
} }
}, },
logoContainer = new Container { RelativeSizeAxes = Axes.Both }, logoContainer = new Container { RelativeSizeAxes = Axes.Both },
@ -458,18 +464,15 @@ namespace osu.Game
idleTracker idleTracker
}); });
screenStack.ScreenPushed += screenPushed; ScreenStack.ScreenPushed += screenPushed;
screenStack.ScreenExited += screenExited; ScreenStack.ScreenExited += screenExited;
loadComponentSingleFile(osuLogo, logo => loadComponentSingleFile(osuLogo, logo =>
{ {
logoContainer.Add(logo); logoContainer.Add(logo);
// Loader has to be created after the logo has finished loading as Loader performs logo transformations on entering. // Loader has to be created after the logo has finished loading as Loader performs logo transformations on entering.
screenStack.Push(new Loader ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both));
{
RelativeSizeAxes = Axes.Both
});
}); });
loadComponentSingleFile(Toolbar = new Toolbar loadComponentSingleFile(Toolbar = new Toolbar
@ -504,7 +507,7 @@ namespace osu.Game
loadComponentSingleFile(social = new SocialOverlay(), overlayContent.Add, true); loadComponentSingleFile(social = new SocialOverlay(), overlayContent.Add, true);
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true); loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true); loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
loadComponentSingleFile(settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true); loadComponentSingleFile(Settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true);
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true); var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true); loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
@ -535,7 +538,7 @@ namespace osu.Game
Add(externalLinkOpener = new ExternalLinkOpener()); Add(externalLinkOpener = new ExternalLinkOpener());
var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications }; var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
overlays.AddRange(singleDisplaySideOverlays); overlays.AddRange(singleDisplaySideOverlays);
foreach (var overlay in singleDisplaySideOverlays) foreach (var overlay in singleDisplaySideOverlays)
@ -588,7 +591,7 @@ namespace osu.Game
{ {
float offset = 0; float offset = 0;
if (settings.State.Value == Visibility.Visible) if (Settings.State.Value == Visibility.Visible)
offset += ToolbarButton.WIDTH / 2; offset += ToolbarButton.WIDTH / 2;
if (notifications.State.Value == Visibility.Visible) if (notifications.State.Value == Visibility.Visible)
offset -= ToolbarButton.WIDTH / 2; offset -= ToolbarButton.WIDTH / 2;
@ -596,7 +599,7 @@ namespace osu.Game
screenContainer.MoveToX(offset, SettingsPanel.TRANSITION_LENGTH, Easing.OutQuint); screenContainer.MoveToX(offset, SettingsPanel.TRANSITION_LENGTH, Easing.OutQuint);
} }
settings.State.ValueChanged += _ => updateScreenOffset(); Settings.State.ValueChanged += _ => updateScreenOffset();
notifications.State.ValueChanged += _ => updateScreenOffset(); notifications.State.ValueChanged += _ => updateScreenOffset();
} }
@ -741,7 +744,7 @@ namespace osu.Game
return true; return true;
case GlobalAction.ToggleSettings: case GlobalAction.ToggleSettings:
settings.ToggleVisibility(); Settings.ToggleVisibility();
return true; return true;
case GlobalAction.ToggleDirect: case GlobalAction.ToggleDirect:
@ -788,13 +791,13 @@ namespace osu.Game
protected override bool OnExiting() protected override bool OnExiting()
{ {
if (screenStack.CurrentScreen is Loader) if (ScreenStack.CurrentScreen is Loader)
return false; return false;
if (introScreen == null) if (introScreen == null)
return true; return true;
if (!introScreen.DidLoadMenu || !(screenStack.CurrentScreen is IntroScreen)) if (!introScreen.DidLoadMenu || !(ScreenStack.CurrentScreen is IntroScreen))
{ {
Scheduler.Add(introScreen.MakeCurrent); Scheduler.Add(introScreen.MakeCurrent);
return true; return true;
@ -822,7 +825,7 @@ namespace osu.Game
screenContainer.Padding = new MarginPadding { Top = ToolbarOffset }; screenContainer.Padding = new MarginPadding { Top = ToolbarOffset };
overlayContent.Padding = new MarginPadding { Top = ToolbarOffset }; overlayContent.Padding = new MarginPadding { Top = ToolbarOffset };
MenuCursorContainer.CanShowCursor = (screenStack.CurrentScreen as IOsuScreen)?.CursorVisible ?? false; MenuCursorContainer.CanShowCursor = (ScreenStack.CurrentScreen as IOsuScreen)?.CursorVisible ?? false;
} }
protected virtual void ScreenChanged(IScreen current, IScreen newScreen) protected virtual void ScreenChanged(IScreen current, IScreen newScreen)
@ -848,9 +851,9 @@ namespace osu.Game
Toolbar.Show(); Toolbar.Show();
if (newOsuScreen.AllowBackButton) if (newOsuScreen.AllowBackButton)
backButton.Show(); BackButton.Show();
else else
backButton.Hide(); BackButton.Hide();
} }
} }

View File

@ -65,7 +65,7 @@ namespace osu.Game
protected RulesetConfigCache RulesetConfigCache; protected RulesetConfigCache RulesetConfigCache;
protected APIAccess API; protected IAPIProvider API;
protected MenuCursorContainer MenuCursorContainer; protected MenuCursorContainer MenuCursorContainer;
@ -73,6 +73,8 @@ namespace osu.Game
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
protected Storage Storage { get; set; }
private Bindable<WorkingBeatmap> beatmap; // cached via load() method private Bindable<WorkingBeatmap> beatmap; // cached via load() method
[Cached] [Cached]
@ -123,7 +125,7 @@ namespace osu.Game
{ {
Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll")); Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll"));
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage));
var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures"))); var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures")));
largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore()));
@ -158,21 +160,21 @@ namespace osu.Game
runMigrations(); runMigrations();
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy"))); dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
dependencies.CacheAs<ISkinSource>(SkinManager); dependencies.CacheAs<ISkinSource>(SkinManager);
API = new APIAccess(LocalConfig); if (API == null) API = new APIAccess(LocalConfig);
dependencies.CacheAs<IAPIProvider>(API); dependencies.CacheAs(API);
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures); var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); dependencies.Cache(FileStore = new FileStore(contextFactory, Storage));
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Host.Storage, API, contextFactory, Host)); dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Host));
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap)); dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap));
// this should likely be moved to ArchiveModelManager when another case appers where it is necessary // this should likely be moved to ArchiveModelManager when another case appers where it is necessary
// to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to // to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to
@ -206,7 +208,8 @@ namespace osu.Game
FileStore.Cleanup(); FileStore.Cleanup();
AddInternal(API); if (API is APIAccess apiAcces)
AddInternal(apiAcces);
AddInternal(RulesetConfigCache); AddInternal(RulesetConfigCache);
GlobalActionContainer globalBinding; GlobalActionContainer globalBinding;
@ -266,9 +269,13 @@ namespace osu.Game
public override void SetHost(GameHost host) public override void SetHost(GameHost host)
{ {
if (LocalConfig == null)
LocalConfig = new OsuConfigManager(host.Storage);
base.SetHost(host); base.SetHost(host);
if (Storage == null)
Storage = host.Storage;
if (LocalConfig == null)
LocalConfig = new OsuConfigManager(Storage);
} }
private readonly List<ICanAcceptFiles> fileImporters = new List<ICanAcceptFiles>(); private readonly List<ICanAcceptFiles> fileImporters = new List<ICanAcceptFiles>();

View File

@ -1,16 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Rulesets.Objects
{
/// <summary>
/// A hit object representing the end of a bar.
/// </summary>
public class BarLine : HitObject
{
/// <summary>
/// Whether this barline is a prominent beat (based on time signature of beatmap).
/// </summary>
public bool Major;
}
}

View File

@ -10,12 +10,13 @@ using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Objects namespace osu.Game.Rulesets.Objects
{ {
public class BarLineGenerator public class BarLineGenerator<TBarLine>
where TBarLine : class, IBarLine, new()
{ {
/// <summary> /// <summary>
/// The generated bar lines. /// The generated bar lines.
/// </summary> /// </summary>
public readonly List<BarLine> BarLines = new List<BarLine>(); public readonly List<TBarLine> BarLines = new List<TBarLine>();
/// <summary> /// <summary>
/// Constructs and generates bar lines for provided beatmap. /// Constructs and generates bar lines for provided beatmap.
@ -46,7 +47,7 @@ namespace osu.Game.Rulesets.Objects
for (double t = currentTimingPoint.Time; Precision.DefinitelyBigger(endTime, t); t += barLength, currentBeat++) for (double t = currentTimingPoint.Time; Precision.DefinitelyBigger(endTime, t); t += barLength, currentBeat++)
{ {
BarLines.Add(new BarLine BarLines.Add(new TBarLine
{ {
StartTime = t, StartTime = t,
Major = currentBeat % (int)currentTimingPoint.TimeSignature == 0 Major = currentBeat % (int)currentTimingPoint.TimeSignature == 0

View File

@ -316,8 +316,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
get => lifetimeStart ?? (HitObject.StartTime - InitialLifetimeOffset); get => lifetimeStart ?? (HitObject.StartTime - InitialLifetimeOffset);
set set
{ {
base.LifetimeStart = value;
lifetimeStart = value; lifetimeStart = value;
base.LifetimeStart = value;
} }
} }

View File

@ -0,0 +1,22 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Rulesets.Objects
{
/// <summary>
/// Interface for bar line hitobjects.
/// Used to decouple bar line generation from ruleset-specific rendering/drawing hierarchies.
/// </summary>
public interface IBarLine
{
/// <summary>
/// The time position of the bar.
/// </summary>
double StartTime { set; }
/// <summary>
/// Whether this bar line is a prominent beat (based on time signature of beatmap).
/// </summary>
bool Major { set; }
}
}

View File

@ -131,7 +131,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
if (duration > maxDuration) if (duration > maxDuration)
{ {
maxDuration = duration; maxDuration = duration;
baseBeatLength = timingPoints[i].BeatLength; // The slider multiplier is post-multiplied to determine the final velocity, but for relative scale beat lengths
// the multiplier should not affect the effective timing point (the longest in the beatmap), so it is factored out here
baseBeatLength = timingPoints[i].BeatLength / Beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier;
} }
} }
} }

View File

@ -77,6 +77,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
if (!initialStateCache.IsValid) if (!initialStateCache.IsValid)
{ {
foreach (var cached in hitObjectInitialStateCache.Values)
cached.Invalidate();
switch (direction.Value) switch (direction.Value)
{ {
case ScrollingDirection.Up: case ScrollingDirection.Up:

View File

@ -82,6 +82,9 @@ namespace osu.Game.Screens.Select
var _ = newRoot.Drawables; var _ = newRoot.Drawables;
root = newRoot; root = newRoot;
if (selectedBeatmapSet != null && !beatmapSets.Contains(selectedBeatmapSet.BeatmapSet))
selectedBeatmapSet = null;
scrollableContent.Clear(false); scrollableContent.Clear(false);
itemsCache.Invalidate(); itemsCache.Invalidate();
scrollPositionCache.Invalidate(); scrollPositionCache.Invalidate();

View File

@ -6,31 +6,25 @@ using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
namespace osu.Desktop.Updater namespace osu.Game.Updater
{ {
/// <summary> /// <summary>
/// An update manager that shows notifications if a newer release is detected. /// An update manager that shows notifications if a newer release is detected.
/// Installation is left up to the user. /// Installation is left up to the user.
/// </summary> /// </summary>
internal class SimpleUpdateManager : CompositeDrawable public class SimpleUpdateManager : UpdateManager
{ {
private NotificationOverlay notificationOverlay;
private string version; private string version;
private GameHost host; private GameHost host;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(NotificationOverlay notification, OsuGameBase game, GameHost host) private void load(OsuGameBase game, GameHost host)
{ {
notificationOverlay = notification;
this.host = host; this.host = host;
version = game.Version; version = game.Version;
@ -50,7 +44,7 @@ namespace osu.Desktop.Updater
if (latest.TagName != version) if (latest.TagName != version)
{ {
notificationOverlay.Post(new SimpleNotification Notifications.Post(new SimpleNotification
{ {
Text = $"A newer release of osu! has been found ({version} → {latest.TagName}).\n\n" Text = $"A newer release of osu! has been found ({version} → {latest.TagName}).\n\n"
+ "Click here to download the new version, which can be installed over the top of your existing installation", + "Click here to download the new version, which can be installed over the top of your existing installation",
@ -82,6 +76,11 @@ namespace osu.Desktop.Updater
case RuntimeInfo.Platform.MacOsx: case RuntimeInfo.Platform.MacOsx:
bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".app.zip")); bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".app.zip"));
break; break;
case RuntimeInfo.Platform.Android:
// on our testing device this causes the download to magically disappear.
//bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".apk"));
break;
} }
return bestAsset?.BrowserDownloadUrl ?? release.HtmlUrl; return bestAsset?.BrowserDownloadUrl ?? release.HtmlUrl;

View File

@ -0,0 +1,67 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
namespace osu.Game.Updater
{
public abstract class UpdateManager : CompositeDrawable
{
[Resolved]
private OsuConfigManager config { get; set; }
[Resolved]
private OsuGameBase game { get; set; }
[Resolved]
protected NotificationOverlay Notifications { get; private set; }
protected override void LoadComplete()
{
base.LoadComplete();
var version = game.Version;
var lastVersion = config.Get<string>(OsuSetting.Version);
if (game.IsDeployedBuild && version != lastVersion)
{
config.Set(OsuSetting.Version, version);
// only show a notification if we've previously saved a version to the config file (ie. not the first run).
if (!string.IsNullOrEmpty(lastVersion))
Notifications.Post(new UpdateCompleteNotification(version));
}
}
private class UpdateCompleteNotification : SimpleNotification
{
private readonly string version;
public UpdateCompleteNotification(string version)
{
this.version = version;
Text = $"You are now running osu!lazer {version}.\nClick to see what's new!";
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, ChangelogOverlay changelog, NotificationOverlay notificationOverlay)
{
Icon = FontAwesome.Solid.CheckSquare;
IconBackgound.Colour = colours.BlueDark;
Activated = delegate
{
notificationOverlay.Hide();
changelog.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version);
return true;
};
}
}
}
}