diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..6c327f01b3
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,137 @@
+# Contributing Guidelines
+
+Thank you for showing interest in the development of osu!lazer! We aim to provide a good collaborating environment for everyone involved, and as such have decided to list some of the most important things to keep in mind in the process. The guidelines below have been chosen based on past experience.
+
+These are not "official rules" *per se*, but following them will help everyone deal with things in the most efficient manner.
+
+## Table of contents
+
+1. [I would like to submit an issue!](#i-would-like-to-submit-an-issue)
+2. [I would like to submit a pull request!](#i-would-like-to-submit-a-pull-request)
+
+## I would like to submit an issue!
+
+Issues, bug reports and feature suggestions are welcomed, though please keep in mind that at any point in time, hundreds of issues are open, which vary in severity and the amount of time needed to address them. As such it's not uncommon for issues to remain unresolved for a long time or even closed outright if they are deemed not important enough to fix in the foreseeable future. Issues that are required to "go live" or otherwise achieve parity with stable are prioritised the most.
+
+* **Before submitting an issue, try searching existing issues first.**
+
+ For housekeeping purposes, we close issues that overlap with or duplicate other pre-existing issues - you can help us not to have to do that by searching existing issues yourself first. The issue search box, as well as the issue tag system, are tools you can use to check if an issue has been reported before.
+
+* **When submitting a bug report, please try to include as much detail as possible.**
+
+ Bugs are not equal - some of them will be reproducible every time on pretty much all hardware, while others will be hard to track down due to being specific to particular hardware or even somewhat random in nature. As such, providing as much detail as possible when reporting a bug is hugely appreciated. A good starting set of information consists of:
+
+ * the in-game logs, which are located at:
+ * `%AppData%/osu/logs` (on Windows),
+ * `~/.local/share/osu/logs` (on Linux and macOS),
+ * `Android/Data/sh.ppy.osulazer/logs` (on Android),
+ * on iOS they can be obtained by connecting your device to your desktop and [copying the `logs` directory from the app's own document storage using iTunes](https://support.apple.com/en-us/HT201301#copy-to-computer),
+ * your system specifications (including the operating system and platform you are playing on),
+ * a reproduction scenario (list of steps you have performed leading up to the occurrence of the bug),
+ * a video or picture of the bug, if at all possible.
+
+* **Provide more information when asked to do so.**
+
+ Sometimes when a bug is more elusive or complicated, none of the information listed above will pinpoint a concrete cause of the problem. In this case we will most likely ask you for additional info, such as a Windows Event Log dump or a copy of your local lazer database (`client.db`). Providing that information is beneficial to both parties - we can track down the problem better, and hopefully fix it for you at some point once we know where it is!
+
+* **When submitting a feature proposal, please describe it in the most understandable way you can.**
+
+ Communicating your idea for a feature can often be hard, and we would like to avoid any misunderstandings. As such, please try to explain your idea in a short, but understandable manner - it's best to avoid jargon or terms and references that could be considered obscure. A mock-up picture (doesn't have to be good!) of the feature can also go a long way in explaining.
+
+* **Refrain from posting "+1" comments.**
+
+ If an issue has already been created, saying that you also experience it without providing any additional details doesn't really help us in any way. To express support for a proposal or indicate that you are also affected by a particular bug, you can use comment reactions instead.
+
+* **Refrain from asking if an issue has been resolved yet.**
+
+ As mentioned above, the issue tracker has hundreds of issues open at any given time. Currently the game is being worked on by two members of the core team, and a handful of outside contributors who offer their free time to help out. As such, it can happen that an issue gets placed on the backburner due to being less important; generally posting a comment demanding its resolution some months or years after it is reported is not very likely to increase its priority.
+
+* **Avoid long discussions about non-development topics.**
+
+ GitHub is mostly a developer space, and as such isn't really fit for lengthened discussions about gameplay mechanics (which might not even be in any way confirmed for the final release) and similar non-technical matters. Such matters are probably best addressed at the osu! forums.
+
+## I would like to submit a pull request!
+
+We also welcome pull requests from unaffiliated contributors. The [issue tracker](https://github.com/ppy/osu/issues) should provide plenty of issues that you can work on; we also mark issues that we think would be good for newcomers with the [`good-first-issue`](https://github.com/ppy/osu/issues?q=is%3Aissue+is%3Aopen+label%3Agood-first-issue) label.
+
+However, do keep in mind that the core team is committed to bringing osu!lazer up to par with stable first and foremost, so depending on what your contribution concerns, it might not be merged and released right away. Our approach to managing issues and their priorities is described [in the wiki](https://github.com/ppy/osu/wiki/Project-management).
+
+Here are some key things to note before jumping in:
+
+* **Make sure you are comfortable with C\# and your development environment.**
+
+ While we are accepting of all kinds of contributions, we also have a certain quality standard we'd like to uphold and limited time to review your code. Therefore, we would like to avoid providing entry-level advice, and as such if you're not very familiar with C\# as a programming language, we'd recommend that you start off with a few personal projects to get acquainted with the language's syntax, toolchain and principles of object-oriented programming first.
+
+ In addition, please take the time to take a look at and get acquainted with the [development and testing](https://github.com/ppy/osu-framework/wiki/Development-and-Testing) procedure we have set up.
+
+* **Make sure you are familiar with git and the pull request workflow.**
+
+ [git](https://git-scm.com/) is a distributed version control system that might not be very intuitive at the beginning if you're not familiar with version control. In particular, projects using git have a particular workflow for submitting code changes, which is called the pull request workflow.
+
+ To make things run more smoothly, we recommend that you look up some online resources to familiarise yourself with the git vocabulary and commands, and practice working with forks and submitting pull requests at your own pace. A high-level overview of the process can be found in [this article by GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests).
+
+* **Double-check designs before starting work on new functionality.**
+
+ When implementing new features, keep in mind that we already have a lot of the UI designed. If you wish to work on something with the intention of having it included in the official distribution, please open an issue for discussion and we will give you what you need from a design perspective to proceed. If you want to make *changes* to the design, we recommend you open an issue with your intentions before spending too much time to ensure no effort is wasted.
+
+* **Make sure to submit pull requests off of a topic branch.**
+
+ As described in the article linked in the previous point, topic branches help you parallelise your work and separate it from the main `master` branch, and additionally are easier for maintainers to work with. Working with multiple `master` branches across many remotes is difficult to keep track of, and it's easy to make a mistake and push to the wrong `master` branch by accident.
+
+* **Refrain from making changes through the GitHub web interface.**
+
+ Even though GitHub provides an option to edit code or replace files in the repository using the web interface, we strongly discourage using it in most scenarios. Editing files this way is inefficient and likely to introduce whitespace or file encoding changes that make it more difficult to review the code.
+
+ Code written through the web interface will also very likely be questioned outright by the reviewers, as it is likely that it has not been properly tested or that it will fail continuous integration checks. We strongly encourage using an IDE like [Visual Studio](https://visualstudio.microsoft.com/), [Visual Studio Code](https://code.visualstudio.com/) or [JetBrains Rider](https://www.jetbrains.com/rider/) instead.
+
+* **Add tests for your code whenever possible.**
+
+ Automated tests are an essential part of a quality and reliable codebase. They help to make the code more maintainable by ensuring it is safe to reorganise (or refactor) the code in various ways, and also prevent regressions - bugs that resurface after having been fixed at some point in the past. If it is viable, please put in the time to add tests, so that the changes you make can last for a (hopefully) very long time.
+
+* **Run tests before opening a pull request.**
+
+ Tying into the previous point, sometimes changes in one part of the codebase can result in unpredictable changes in behaviour in other pieces of the code. This is why it is best to always try to run tests before opening a PR.
+
+ Continuous integration will always run the tests for you (and us), too, but it is best not to rely on it, as there might be many builds queued at any time. Running tests on your own will help you be more certain that at the point of clicking the "Create pull request" button, your changes are as ready as can be.
+
+* **Run code style analysis before opening a pull request.**
+
+ As part of continuous integration, we also run code style analysis, which is supposed to make sure that your code is formatted the same way as all the pre-existing code in the repository. The reason we enforce a particular code style everywhere is to make sure the codebase is consistent in that regard - having one whitespace convention in one place and another one elsewhere causes disorganisation.
+
+* **Make sure that the pull request is complete before opening it.**
+
+ Whether it's fixing a bug or implementing new functionality, it's best that you make sure that the change you want to submit as a pull request is as complete as it can be before clicking the *Create pull request* button. Having to track if a pull request is ready for review or not places additional burden on reviewers.
+
+ Draft pull requests are an option, but use them sparingly and within reason. They are best suited to discuss code changes that cannot be easily described in natural language or have a potential large impact on the future direction of the project. When in doubt, don't open drafts unless a maintainer asks you to do so.
+
+* **Only push code when it's ready.**
+
+ As an extension of the above, when making changes to an already-open PR, please try to only push changes you are reasonably certain of. Pushing after every commit causes the continuous integration build queue to grow in size, slowing down work and taking up time that could be spent verifying other changes.
+
+* **Make sure to keep the *Allow edits from maintainers* check box checked.**
+
+ To speed up the merging process, collaborators and team members will sometimes want to push changes to your branch themselves, to make minor code style adjustments or to otherwise refactor the code without having to describe how they'd like the code to look like in painstaking detail. Having the *Allow edits from maintainers* check box checked lets them do that; without it they are forced to report issues back to you and wait for you to address them.
+
+* **Refrain from continually merging the master branch back to the PR.**
+
+ Unless there are merge conflicts that need resolution, there is no need to keep merging `master` back to a branch over and over again. One of the maintainers will merge `master` themselves before merging the PR itself anyway, and continual merge commits can cause CI to get overwhelmed due to queueing up too many builds.
+
+* **Refrain from force-pushing to the PR branch.**
+
+ Force-pushing should be avoided, as it can lead to accidentally overwriting a maintainer's changes or CI building wrong commits. We value all history in the project, so there is no need to squash or amend commits in most cases.
+
+ The cases in which force-pushing is warranted are very rare (such as accidentally leaking sensitive info in one of the files committed, adding unrelated files, or mis-merging a dependent PR).
+
+* **Be patient when waiting for the code to be reviewed and merged.**
+
+ As much as we'd like to review all contributions as fast as possible, our time is limited, as team members have to work on their own tasks in addition to reviewing code. As such, work needs to be prioritised, and it can unfortunately take weeks or months for your PR to be merged, depending on how important it is deemed to be.
+
+* **Don't mistake criticism of code for criticism of your person.**
+
+ As mentioned before, we are highly committed to quality when it comes to the lazer project. This means that contributions from less experienced community members can take multiple rounds of review to get to a mergeable state. We try our utmost best to never conflate a person with the code they authored, and to keep the discussion focused on the code at all times. Please consider our comments and requests a learning experience, and don't treat it as a personal attack.
+
+* **Feel free to reach out for help.**
+
+ If you're uncertain about some part of the codebase or some inner workings of the game and framework, please reach out either by leaving a comment in the relevant issue or PR thread, or by posting a message in the [development Discord server](https://discord.gg/ppy). We will try to help you as much as we can.
+
+ When it comes to which form of communication is best, GitHub generally lends better to longer-form discussions, while Discord is better for snappy call-and-response answers. Use your best discretion when deciding, and try to keep a single discussion in one place instead of moving back and forth.
diff --git a/README.md b/README.md
index 336bf33f7e..dc3ee63844 100644
--- a/README.md
+++ b/README.md
@@ -93,11 +93,7 @@ JetBrains ReSharper InspectCode is also used for wider rule sets. You can run it
## Contributing
-We welcome all contributions, but keep in mind that we already have a lot of the UI designed. If you wish to work on something with the intention of having it included in the official distribution, please open an issue for discussion and we will give you what you need from a design perspective to proceed. If you want to make *changes* to the design, we recommend you open an issue with your intentions before spending too much time to ensure no effort is wasted.
-
-If you're unsure of what you can help with, check out the [list of open issues](https://github.com/ppy/osu/issues) (especially those with the ["good first issue"](https://github.com/ppy/osu/issues?q=is%3Aopen+label%3Agood-first-issue+sort%3Aupdated-desc) label).
-
-Before starting, please make sure you are familiar with the [development and testing](https://github.com/ppy/osu-framework/wiki/Development-and-Testing) procedure we have set up. New component development, and where possible, bug fixing and debugging existing components **should always be done under VisualTests**.
+When it comes to contributing to the project, the two main things you can do to help out are reporting issues and submitting pull requests. Based on past experiences, we have prepared a [list of contributing guidelines](CONTRIBUTING.md) that should hopefully ease you into our collaboration process and answer the most frequently-asked questions.
Note that while we already have certain standards in place, nothing is set in stone. If you have an issue with the way code is structured, with any libraries we are using, or with any processes involved with contributing, *please* bring it up. We welcome all feedback so we can make contributing to this project as painless as possible.
diff --git a/build/InspectCode.cake b/build/InspectCode.cake
index 2e7a1d1b28..c8f4f37c94 100644
--- a/build/InspectCode.cake
+++ b/build/InspectCode.cake
@@ -1,5 +1,5 @@
-#addin "nuget:?package=CodeFileSanity&version=0.0.33"
-#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2019.3.2"
+#addin "nuget:?package=CodeFileSanity&version=0.0.36"
+#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2020.1.3"
#tool "nuget:?package=NVika.MSBuild&version=1.0.1"
var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First();
diff --git a/global.json b/global.json
index 6c793a3f1d..bdb90eb0e9 100644
--- a/global.json
+++ b/global.json
@@ -5,6 +5,6 @@
"version": "3.1.100"
},
"msbuild-sdks": {
- "Microsoft.Build.Traversal": "2.0.34"
+ "Microsoft.Build.Traversal": "2.0.48"
}
}
\ No newline at end of file
diff --git a/osu.Android.props b/osu.Android.props
index 07be3ab0d2..596e5bfa8b 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -52,6 +52,6 @@
-
+
diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs
index 9351e17419..5f74883803 100644
--- a/osu.Desktop/OsuGameDesktop.cs
+++ b/osu.Desktop/OsuGameDesktop.cs
@@ -59,7 +59,7 @@ namespace osu.Desktop
try
{
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
- stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
+ stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString()?.Split('"')[1].Replace("osu!.exe", "");
if (checkExists(stableInstallPath))
return stableInstallPath;
diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs
index ade8460dd7..dd50b05c75 100644
--- a/osu.Desktop/Updater/SquirrelUpdateManager.cs
+++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs
@@ -48,7 +48,7 @@ namespace osu.Desktop.Updater
try
{
- if (updateManager == null) updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
+ updateManager ??= await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
var info = await updateManager.CheckForUpdate(!useDeltaPatching);
if (info.ReleasesToApply.Count == 0)
diff --git a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
index 5cd2f1f581..918ed77683 100644
--- a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
+++ b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
@@ -35,8 +35,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills
{
var catchCurrent = (CatchDifficultyHitObject)current;
- if (lastPlayerPosition == null)
- lastPlayerPosition = catchCurrent.LastNormalizedPosition;
+ lastPlayerPosition ??= catchCurrent.LastNormalizedPosition;
float playerPosition = Math.Clamp(
lastPlayerPosition.Value,
diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapSampleConversionTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapSampleConversionTest.cs
new file mode 100644
index 0000000000..d8f87195d1
--- /dev/null
+++ b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapSampleConversionTest.cs
@@ -0,0 +1,76 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Utils;
+using osu.Game.Audio;
+using osu.Game.Rulesets.Mania.Objects;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Tests.Beatmaps;
+
+namespace osu.Game.Rulesets.Mania.Tests
+{
+ [TestFixture]
+ public class ManiaBeatmapSampleConversionTest : BeatmapConversionTest, SampleConvertValue>
+ {
+ protected override string ResourceAssembly => "osu.Game.Rulesets.Mania";
+
+ [TestCase("convert-samples")]
+ [TestCase("mania-samples")]
+ public void Test(string name) => base.Test(name);
+
+ protected override IEnumerable CreateConvertValue(HitObject hitObject)
+ {
+ yield return new SampleConvertValue
+ {
+ StartTime = hitObject.StartTime,
+ EndTime = hitObject.GetEndTime(),
+ Column = ((ManiaHitObject)hitObject).Column,
+ NodeSamples = getSampleNames((hitObject as HoldNote)?.NodeSamples)
+ };
+ }
+
+ private IList> getSampleNames(List> hitSampleInfo)
+ => hitSampleInfo?.Select(samples =>
+ (IList)samples.Select(sample => sample.LookupNames.First()).ToList())
+ .ToList();
+
+ protected override Ruleset CreateRuleset() => new ManiaRuleset();
+ }
+
+ public struct SampleConvertValue : IEquatable
+ {
+ ///
+ /// A sane value to account for osu!stable using ints everywhere.
+ ///
+ private const float conversion_lenience = 2;
+
+ public double StartTime;
+ public double EndTime;
+ public int Column;
+ public IList> NodeSamples;
+
+ public bool Equals(SampleConvertValue other)
+ => Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
+ && Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
+ && samplesEqual(NodeSamples, other.NodeSamples);
+
+ private static bool samplesEqual(ICollection> firstSampleList, ICollection> secondSampleList)
+ {
+ if (firstSampleList == null && secondSampleList == null)
+ return true;
+
+ // both items can't be null now, so if any single one is, then they're not equal
+ if (firstSampleList == null || secondSampleList == null)
+ return false;
+
+ return firstSampleList.Count == secondSampleList.Count
+ // cannot use .Zip() without the selector function as it doesn't compile in android test project
+ && firstSampleList.Zip(secondSampleList, (first, second) => (first, second))
+ .All(samples => samples.first.SequenceEqual(samples.second));
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
index 32abf5e7f9..b025ac7992 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
@@ -6,6 +6,7 @@ using System;
using System.Linq;
using System.Collections.Generic;
using osu.Framework.Utils;
+using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
@@ -239,7 +240,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
Duration = endTimeData.Duration,
Column = column,
Samples = HitObject.Samples,
- NodeSamples = (HitObject as IHasRepeats)?.NodeSamples
+ NodeSamples = (HitObject as IHasRepeats)?.NodeSamples ?? defaultNodeSamples
});
}
else if (HitObject is IHasXPosition)
@@ -254,6 +255,16 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
return pattern;
}
+
+ ///
+ /// osu!mania-specific beatmaps in stable only play samples at the start of the hold note.
+ ///
+ private List> defaultNodeSamples
+ => new List>
+ {
+ HitObject.Samples,
+ new List()
+ };
}
}
}
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
index 1bd796511b..9fbdf58e21 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
@@ -472,15 +472,23 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
///
/// The time to retrieve the sample info list from.
///
- private IList sampleInfoListAt(double time)
+ private IList sampleInfoListAt(double time) => nodeSamplesAt(time)?.First() ?? HitObject.Samples;
+
+ ///
+ /// Retrieves the list of node samples that occur at time greater than or equal to .
+ ///
+ /// The time to retrieve node samples at.
+ private List> nodeSamplesAt(double time)
{
if (!(HitObject is IHasPathWithRepeats curveData))
- return HitObject.Samples;
+ return null;
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
- return curveData.NodeSamples[index];
+
+ // avoid slicing the list & creating copies, if at all possible.
+ return index == 0 ? curveData.NodeSamples : curveData.NodeSamples.Skip(index).ToList();
}
///
@@ -511,7 +519,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
Duration = endTime - startTime,
Column = column,
Samples = HitObject.Samples,
- NodeSamples = (HitObject as IHasRepeats)?.NodeSamples
+ NodeSamples = nodeSamplesAt(startTime)
};
}
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json
new file mode 100644
index 0000000000..b8ce85eef5
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json
@@ -0,0 +1,30 @@
+{
+ "Mappings": [{
+ "StartTime": 1000.0,
+ "Objects": [{
+ "StartTime": 1000.0,
+ "EndTime": 2750.0,
+ "Column": 1,
+ "NodeSamples": [
+ ["normal-hitnormal"],
+ ["soft-hitnormal"],
+ ["drum-hitnormal"]
+ ]
+ }, {
+ "StartTime": 1875.0,
+ "EndTime": 2750.0,
+ "Column": 0,
+ "NodeSamples": [
+ ["soft-hitnormal"],
+ ["drum-hitnormal"]
+ ]
+ }]
+ }, {
+ "StartTime": 3750.0,
+ "Objects": [{
+ "StartTime": 3750.0,
+ "EndTime": 3750.0,
+ "Column": 3
+ }]
+ }]
+}
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples.osu b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples.osu
new file mode 100644
index 0000000000..16b73992d2
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples.osu
@@ -0,0 +1,16 @@
+osu file format v14
+
+[Difficulty]
+HPDrainRate:5
+CircleSize:5
+OverallDifficulty:5
+ApproachRate:5
+SliderMultiplier:1.4
+SliderTickRate:1
+
+[TimingPoints]
+0,500,4,1,0,100,1,0
+
+[HitObjects]
+88,99,1000,6,0,L|306:259,2,245,0|0|0,1:0|2:0|3:0,0:0:0:0:
+259,118,3750,1,0,0:0:0:0:
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json
new file mode 100644
index 0000000000..e22540614d
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json
@@ -0,0 +1,25 @@
+{
+ "Mappings": [{
+ "StartTime": 500.0,
+ "Objects": [{
+ "StartTime": 500.0,
+ "EndTime": 1500.0,
+ "Column": 0,
+ "NodeSamples": [
+ ["normal-hitnormal"],
+ []
+ ]
+ }]
+ }, {
+ "StartTime": 2000.0,
+ "Objects": [{
+ "StartTime": 2000.0,
+ "EndTime": 3000.0,
+ "Column": 2,
+ "NodeSamples": [
+ ["drum-hitnormal"],
+ []
+ ]
+ }]
+ }]
+}
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples.osu b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples.osu
new file mode 100644
index 0000000000..7c75b45e5f
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples.osu
@@ -0,0 +1,19 @@
+osu file format v14
+
+[General]
+Mode: 3
+
+[Difficulty]
+HPDrainRate:5
+CircleSize:5
+OverallDifficulty:5
+ApproachRate:5
+SliderMultiplier:1.4
+SliderTickRate:1
+
+[TimingPoints]
+0,500,4,1,0,100,1,0
+
+[HitObjects]
+51,192,500,128,0,1500:1:0:0:0:
+256,192,2000,128,0,3000:3:0:0:0:
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSnaking.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSnaking.cs
index f5b20fd1c5..a69646507a 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSnaking.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderSnaking.cs
@@ -61,7 +61,9 @@ namespace osu.Game.Rulesets.Osu.Tests
private DrawableSlider slider;
[SetUpSteps]
- public override void SetUpSteps() { }
+ public override void SetUpSteps()
+ {
+ }
[TestCase(0)]
[TestCase(1)]
@@ -132,10 +134,9 @@ namespace osu.Game.Rulesets.Osu.Tests
checkPositionChange(16600, sliderRepeat, positionDecreased);
}
- private void retrieveDrawableSlider(int index) => AddStep($"retrieve {(index + 1).ToOrdinalWords()} slider", () =>
- {
- slider = (DrawableSlider)Player.DrawableRuleset.Playfield.AllHitObjects.ElementAt(index);
- });
+ private void retrieveDrawableSlider(int index) =>
+ AddStep($"retrieve {(index + 1).ToOrdinalWords()} slider", () =>
+ slider = (DrawableSlider)Player.DrawableRuleset.Playfield.AllHitObjects.ElementAt(index));
private void ensureSnakingIn(double startTime) => checkPositionChange(startTime, sliderEnd, positionIncreased);
private void ensureNoSnakingIn(double startTime) => checkPositionChange(startTime, sliderEnd, positionRemainsSame);
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs
index 8a0ef22c4a..2c41e6b0e9 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs
@@ -135,8 +135,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
fp.Alpha = 0;
fp.Scale = new Vector2(1.5f * osuEnd.Scale);
- if (firstTransformStartTime == null)
- firstTransformStartTime = fadeInTime;
+ firstTransformStartTime ??= fadeInTime;
fp.AnimationStartTime = fadeInTime;
diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
index 5eb11a3264..0151678db3 100644
--- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
+++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
@@ -5,16 +5,15 @@ using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Platform;
using osu.Game.IPC;
using osu.Framework.Allocation;
+using osu.Framework.Extensions;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
-using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Resources;
@@ -22,6 +21,7 @@ using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
using SharpCompress.Common;
using SharpCompress.Writers.Zip;
+using FileInfo = System.IO.FileInfo;
namespace osu.Game.Tests.Beatmaps.IO
{
@@ -93,6 +93,166 @@ namespace osu.Game.Tests.Beatmaps.IO
}
}
+ [Test]
+ public async Task TestImportThenImportWithReZip()
+ {
+ using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenImportWithReZip)))
+ {
+ try
+ {
+ var osu = loadOsu(host);
+
+ var temp = TestResources.GetTestBeatmapForImport();
+
+ string extractedFolder = $"{temp}_extracted";
+ Directory.CreateDirectory(extractedFolder);
+
+ try
+ {
+ var imported = await LoadOszIntoOsu(osu);
+
+ string hashBefore = hashFile(temp);
+
+ using (var zip = ZipArchive.Open(temp))
+ zip.WriteToDirectory(extractedFolder);
+
+ using (var zip = ZipArchive.Create())
+ {
+ zip.AddAllFromDirectory(extractedFolder);
+ zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
+ }
+
+ // zip files differ because different compression or encoder.
+ Assert.AreNotEqual(hashBefore, hashFile(temp));
+
+ var importedSecondTime = await osu.Dependencies.Get().Import(temp);
+
+ ensureLoaded(osu);
+
+ // but contents doesn't, so existing should still be used.
+ Assert.IsTrue(imported.ID == importedSecondTime.ID);
+ Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID);
+ }
+ finally
+ {
+ Directory.Delete(extractedFolder, true);
+ }
+ }
+ finally
+ {
+ host.Exit();
+ }
+ }
+ }
+
+ private string hashFile(string filename)
+ {
+ using (var s = File.OpenRead(filename))
+ return s.ComputeMD5Hash();
+ }
+
+ [Test]
+ public async Task TestImportThenImportWithChangedFile()
+ {
+ using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenImportWithChangedFile)))
+ {
+ try
+ {
+ var osu = loadOsu(host);
+
+ var temp = TestResources.GetTestBeatmapForImport();
+
+ string extractedFolder = $"{temp}_extracted";
+ Directory.CreateDirectory(extractedFolder);
+
+ try
+ {
+ var imported = await LoadOszIntoOsu(osu);
+
+ using (var zip = ZipArchive.Open(temp))
+ zip.WriteToDirectory(extractedFolder);
+
+ // arbitrary write to non-hashed file
+ using (var sw = new FileInfo(Directory.GetFiles(extractedFolder, "*.mp3").First()).AppendText())
+ await sw.WriteLineAsync("text");
+
+ using (var zip = ZipArchive.Create())
+ {
+ zip.AddAllFromDirectory(extractedFolder);
+ zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
+ }
+
+ var importedSecondTime = await osu.Dependencies.Get().Import(temp);
+
+ ensureLoaded(osu);
+
+ // check the newly "imported" beatmap is not the original.
+ Assert.IsTrue(imported.ID != importedSecondTime.ID);
+ Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID);
+ }
+ finally
+ {
+ Directory.Delete(extractedFolder, true);
+ }
+ }
+ finally
+ {
+ host.Exit();
+ }
+ }
+ }
+
+ [Test]
+ public async Task TestImportThenImportWithDifferentFilename()
+ {
+ using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenImportWithDifferentFilename)))
+ {
+ try
+ {
+ var osu = loadOsu(host);
+
+ var temp = TestResources.GetTestBeatmapForImport();
+
+ string extractedFolder = $"{temp}_extracted";
+ Directory.CreateDirectory(extractedFolder);
+
+ try
+ {
+ var imported = await LoadOszIntoOsu(osu);
+
+ using (var zip = ZipArchive.Open(temp))
+ zip.WriteToDirectory(extractedFolder);
+
+ // change filename
+ var firstFile = new FileInfo(Directory.GetFiles(extractedFolder).First());
+ firstFile.MoveTo(Path.Combine(firstFile.DirectoryName, $"{firstFile.Name}-changed{firstFile.Extension}"));
+
+ using (var zip = ZipArchive.Create())
+ {
+ zip.AddAllFromDirectory(extractedFolder);
+ zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
+ }
+
+ var importedSecondTime = await osu.Dependencies.Get().Import(temp);
+
+ ensureLoaded(osu);
+
+ // check the newly "imported" beatmap is not the original.
+ Assert.IsTrue(imported.ID != importedSecondTime.ID);
+ Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID);
+ }
+ finally
+ {
+ Directory.Delete(extractedFolder, true);
+ }
+ }
+ finally
+ {
+ host.Exit();
+ }
+ }
+ }
+
[Test]
public async Task TestImportCorruptThenImport()
{
@@ -175,7 +335,7 @@ namespace osu.Game.Tests.Beatmaps.IO
var breakTemp = TestResources.GetTestBeatmapForImport();
MemoryStream brokenOsu = new MemoryStream();
- MemoryStream brokenOsz = new MemoryStream(File.ReadAllBytes(breakTemp));
+ MemoryStream brokenOsz = new MemoryStream(await File.ReadAllBytesAsync(breakTemp));
File.Delete(breakTemp);
@@ -212,37 +372,6 @@ namespace osu.Game.Tests.Beatmaps.IO
}
}
- [Test]
- public async Task TestImportThenImportDifferentHash()
- {
- // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
- using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenImportDifferentHash)))
- {
- try
- {
- var osu = loadOsu(host);
- var manager = osu.Dependencies.Get();
-
- var imported = await LoadOszIntoOsu(osu);
-
- imported.Hash += "-changed";
- manager.Update(imported);
-
- var importedSecondTime = await LoadOszIntoOsu(osu);
-
- Assert.IsTrue(imported.ID != importedSecondTime.ID);
- Assert.IsTrue(imported.Beatmaps.First().ID < importedSecondTime.Beatmaps.First().ID);
-
- // only one beatmap will exist as the online set ID matched, causing purging of the first import.
- checkBeatmapSetCount(osu, 1);
- }
- finally
- {
- host.Exit();
- }
- }
- }
-
[Test]
public async Task TestImportThenDeleteThenImport()
{
@@ -522,7 +651,7 @@ namespace osu.Game.Tests.Beatmaps.IO
using (var resourceForkFile = File.CreateText(resourceForkFilePath))
{
- resourceForkFile.WriteLine("adding content so that it's not empty");
+ await resourceForkFile.WriteLineAsync("adding content so that it's not empty");
}
try
@@ -599,23 +728,17 @@ namespace osu.Game.Tests.Beatmaps.IO
await osu.Dependencies.Get().Import(temp);
BeatmapSetInfo setToUpdate = manager.GetAllUsableBeatmapSets()[0];
+
+ var beatmapInfo = setToUpdate.Beatmaps.First(b => b.RulesetID == 0);
Beatmap beatmapToUpdate = (Beatmap)manager.GetWorkingBeatmap(setToUpdate.Beatmaps.First(b => b.RulesetID == 0)).Beatmap;
BeatmapSetFileInfo fileToUpdate = setToUpdate.Files.First(f => beatmapToUpdate.BeatmapInfo.Path.Contains(f.Filename));
- using (var stream = new MemoryStream())
- {
- using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
- {
- beatmapToUpdate.HitObjects.Clear();
- beatmapToUpdate.HitObjects.Add(new HitCircle { StartTime = 5000 });
+ string oldMd5Hash = beatmapToUpdate.BeatmapInfo.MD5Hash;
- new LegacyBeatmapEncoder(beatmapToUpdate).Encode(writer);
- }
+ beatmapToUpdate.HitObjects.Clear();
+ beatmapToUpdate.HitObjects.Add(new HitCircle { StartTime = 5000 });
- stream.Seek(0, SeekOrigin.Begin);
-
- manager.UpdateFile(setToUpdate, fileToUpdate, stream);
- }
+ manager.Save(beatmapInfo, beatmapToUpdate);
// Check that the old file reference has been removed
Assert.That(manager.QueryBeatmapSet(s => s.ID == setToUpdate.ID).Files.All(f => f.ID != fileToUpdate.ID));
@@ -624,6 +747,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Beatmap updatedBeatmap = (Beatmap)manager.GetWorkingBeatmap(manager.QueryBeatmap(b => b.ID == beatmapToUpdate.BeatmapInfo.ID)).Beatmap;
Assert.That(updatedBeatmap.HitObjects.Count, Is.EqualTo(1));
Assert.That(updatedBeatmap.HitObjects[0].StartTime, Is.EqualTo(5000));
+ Assert.That(updatedBeatmap.BeatmapInfo.MD5Hash, Is.Not.EqualTo(oldMd5Hash));
}
finally
{
diff --git a/osu.Game.Tests/Chat/MessageFormatterTests.cs b/osu.Game.Tests/Chat/MessageFormatterTests.cs
index fbb0416c45..600c820ce1 100644
--- a/osu.Game.Tests/Chat/MessageFormatterTests.cs
+++ b/osu.Game.Tests/Chat/MessageFormatterTests.cs
@@ -428,22 +428,27 @@ namespace osu.Game.Tests.Chat
Assert.AreEqual(5, result.Links.Count);
Link f = result.Links.Find(l => l.Url == "https://osu.ppy.sh/wiki/wiki links");
+ Assert.That(f, Is.Not.Null);
Assert.AreEqual(44, f.Index);
Assert.AreEqual(10, f.Length);
f = result.Links.Find(l => l.Url == "http://www.simple-test.com");
+ Assert.That(f, Is.Not.Null);
Assert.AreEqual(10, f.Index);
Assert.AreEqual(11, f.Length);
f = result.Links.Find(l => l.Url == "http://google.com");
+ Assert.That(f, Is.Not.Null);
Assert.AreEqual(97, f.Index);
Assert.AreEqual(4, f.Length);
f = result.Links.Find(l => l.Url == "https://osu.ppy.sh");
+ Assert.That(f, Is.Not.Null);
Assert.AreEqual(78, f.Index);
Assert.AreEqual(18, f.Length);
f = result.Links.Find(l => l.Url == "\uD83D\uDE12");
+ Assert.That(f, Is.Not.Null);
Assert.AreEqual(101, f.Index);
Assert.AreEqual(3, f.Length);
}
diff --git a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs
index 90bf419644..57f0d7e957 100644
--- a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs
+++ b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs
@@ -183,11 +183,8 @@ namespace osu.Game.Tests.Scores.IO
{
var beatmapManager = osu.Dependencies.Get();
- if (score.Beatmap == null)
- score.Beatmap = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
-
- if (score.Ruleset == null)
- score.Ruleset = new OsuRuleset().RulesetInfo;
+ score.Beatmap ??= beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
+ score.Ruleset ??= new OsuRuleset().RulesetInfo;
var scoreManager = osu.Dependencies.Get();
await scoreManager.Import(score, archive);
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs
index 5ef4dd6773..55b026eff6 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs
@@ -4,12 +4,18 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Framework.Platform;
using osu.Framework.Testing;
+using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
+using osu.Game.Overlays;
+using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Multi;
@@ -23,6 +29,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
private TestPlaylist playlist;
+ private BeatmapManager manager;
+ private RulesetStore rulesets;
+
+ [BackgroundDependencyLoader]
+ private void load(GameHost host, AudioManager audio)
+ {
+ Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
+ Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
+
+ manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait();
+ }
+
[Test]
public void TestNonEditableNonSelectable()
{
@@ -182,6 +200,28 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
}
+ [Test]
+ public void TestDownloadButtonHiddenInitiallyWhenBeatmapExists()
+ {
+ createPlaylist(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo);
+
+ AddAssert("download button hidden", () => !playlist.ChildrenOfType().Single().IsPresent);
+ }
+
+ [Test]
+ public void TestDownloadButtonVisibleInitiallyWhenBeatmapDoesNotExist()
+ {
+ var byOnlineId = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
+ byOnlineId.BeatmapSet.OnlineBeatmapSetID = 1337; // Some random ID that does not exist locally.
+
+ var byChecksum = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
+ byChecksum.MD5Hash = "1337"; // Some random checksum that does not exist locally.
+
+ createPlaylist(byOnlineId, byChecksum);
+
+ AddAssert("download buttons shown", () => playlist.ChildrenOfType().All(d => d.IsPresent));
+ }
+
private void moveToItem(int index, Vector2? offset = null)
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType>().ElementAt(index), offset));
@@ -235,6 +275,39 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
}
+ private void createPlaylist(params BeatmapInfo[] beatmaps)
+ {
+ AddStep("create playlist", () =>
+ {
+ Child = playlist = new TestPlaylist(false, false)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(500, 300)
+ };
+
+ int index = 0;
+
+ foreach (var b in beatmaps)
+ {
+ playlist.Items.Add(new PlaylistItem
+ {
+ ID = index++,
+ Beatmap = { Value = b },
+ Ruleset = { Value = new OsuRuleset().RulesetInfo },
+ RequiredMods =
+ {
+ new OsuModHardRock(),
+ new OsuModDoubleTime(),
+ new OsuModAutoplay()
+ }
+ });
+ }
+ });
+
+ AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
+ }
+
private class TestPlaylist : DrawableRoomPlaylist
{
public new IReadOnlyDictionary> ItemMap => base.ItemMap;
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs
index 77b41c89b0..83f2297bd2 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneLoungeRoomsContainer.cs
@@ -141,6 +141,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
public readonly BindableList Rooms = new BindableList();
+
+ public Bindable InitialRoomsReceived { get; } = new Bindable(true);
+
IBindableList IRoomManager.Rooms => Rooms;
public void CreateRoom(Room room, Action onSuccess = null, Action onError = null) => Rooms.Add(room);
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs
index 34c6940552..fdc20dc477 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs
@@ -133,6 +133,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
remove { }
}
+ public Bindable InitialRoomsReceived { get; } = new Bindable(true);
+
public IBindableList Rooms { get; } = null;
public void CreateRoom(Room room, Action onSuccess = null, Action onError = null)
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs
index d678d5a814..b687724105 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs
@@ -5,7 +5,9 @@ using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Audio;
using osu.Framework.Bindables;
+using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
@@ -29,14 +31,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Cached(typeof(IRoomManager))]
private readonly TestRoomManager roomManager = new TestRoomManager();
- [Resolved]
- private BeatmapManager beatmaps { get; set; }
-
- [Resolved]
- private RulesetStore rulesets { get; set; }
+ private BeatmapManager manager;
+ private RulesetStore rulesets;
private TestMatchSubScreen match;
+ [BackgroundDependencyLoader]
+ private void load(GameHost host, AudioManager audio)
+ {
+ Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
+ Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
+
+ manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait();
+ }
+
[SetUp]
public void Setup() => Schedule(() =>
{
@@ -75,10 +83,49 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("first playlist item selected", () => match.SelectedItem.Value == Room.Playlist[0]);
}
+ [Test]
+ public void TestBeatmapUpdatedOnReImport()
+ {
+ BeatmapSetInfo importedSet = null;
+
+ AddStep("import altered beatmap", () =>
+ {
+ var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo);
+ beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
+
+ importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result;
+ });
+
+ AddStep("load room", () =>
+ {
+ Room.Name.Value = "my awesome room";
+ Room.Host.Value = new User { Id = 2, Username = "peppy" };
+ Room.Playlist.Add(new PlaylistItem
+ {
+ Beatmap = { Value = importedSet.Beatmaps[0] },
+ Ruleset = { Value = new OsuRuleset().RulesetInfo }
+ });
+ });
+
+ AddStep("create room", () =>
+ {
+ InputManager.MoveMouseTo(match.ChildrenOfType().Single());
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddAssert("match has altered beatmap", () => match.Beatmap.Value.Beatmap.BeatmapInfo.BaseDifficulty.CircleSize == 1);
+
+ AddStep("re-import original beatmap", () => manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait());
+
+ AddAssert("match has original beatmap", () => match.Beatmap.Value.Beatmap.BeatmapInfo.BaseDifficulty.CircleSize != 1);
+ }
+
private class TestMatchSubScreen : MatchSubScreen
{
public new Bindable SelectedItem => base.SelectedItem;
+ public new Bindable Beatmap => base.Beatmap;
+
public TestMatchSubScreen(Room room)
: base(room)
{
@@ -93,6 +140,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
remove => throw new NotImplementedException();
}
+ public Bindable InitialRoomsReceived { get; } = new Bindable(true);
+
public IBindableList Rooms { get; } = new BindableList();
public void CreateRoom(Room room, Action onSuccess = null, Action onError = null)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
index 05b33e4386..0025a26baf 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
@@ -246,7 +246,12 @@ namespace osu.Game.Tests.Visual.Online
{
((BindableList)ChannelManager.AvailableChannels).AddRange(channels);
- Child = ChatOverlay = new TestChatOverlay { RelativeSizeAxes = Axes.Both, };
+ InternalChildren = new Drawable[]
+ {
+ ChannelManager,
+ ChatOverlay = new TestChatOverlay { RelativeSizeAxes = Axes.Both, },
+ };
+
ChatOverlay.Show();
}
}
diff --git a/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
index 745820696a..3d335995ac 100644
--- a/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
+++ b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
@@ -1,13 +1,19 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Diagnostics;
+using System.Linq;
using NUnit.Framework;
+using osu.Framework.Testing;
+using osu.Framework.Threading;
using osu.Game.Overlays;
+using osu.Game.Overlays.KeyBinding;
+using osuTK.Input;
namespace osu.Game.Tests.Visual.Settings
{
[TestFixture]
- public class TestSceneKeyBindingPanel : OsuTestScene
+ public class TestSceneKeyBindingPanel : OsuManualInputManagerTestScene
{
private readonly KeyBindingPanel panel;
@@ -21,5 +27,42 @@ namespace osu.Game.Tests.Visual.Settings
base.LoadComplete();
panel.Show();
}
+
+ [Test]
+ public void TestClickTwiceOnClearButton()
+ {
+ KeyBindingRow firstRow = null;
+
+ AddStep("click first row", () =>
+ {
+ firstRow = panel.ChildrenOfType().First();
+ InputManager.MoveMouseTo(firstRow);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddStep("schedule button clicks", () =>
+ {
+ var clearButton = firstRow.ChildrenOfType().Single();
+
+ InputManager.MoveMouseTo(clearButton);
+
+ int buttonClicks = 0;
+ ScheduledDelegate clickDelegate = null;
+
+ clickDelegate = Scheduler.AddDelayed(() =>
+ {
+ InputManager.PressButton(MouseButton.Left);
+ InputManager.ReleaseButton(MouseButton.Left);
+
+ if (++buttonClicks == 2)
+ {
+ // ReSharper disable once AccessToModifiedClosure
+ Debug.Assert(clickDelegate != null);
+ // ReSharper disable once AccessToModifiedClosure
+ clickDelegate.Cancel();
+ }
+ }, 0, true);
+ });
+ }
}
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuIcon.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuIcon.cs
index 061039b297..c5374d50ab 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuIcon.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuIcon.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Diagnostics;
using System.Reflection;
using NUnit.Framework;
using osu.Framework.Extensions.IEnumerableExtensions;
@@ -45,7 +46,12 @@ namespace osu.Game.Tests.Visual.UserInterface
});
foreach (var p in typeof(OsuIcon).GetProperties(BindingFlags.Public | BindingFlags.Static))
- flow.Add(new Icon($"{nameof(OsuIcon)}.{p.Name}", (IconUsage)p.GetValue(null)));
+ {
+ var propValue = p.GetValue(null);
+ Debug.Assert(propValue != null);
+
+ flow.Add(new Icon($"{nameof(OsuIcon)}.{p.Name}", (IconUsage)propValue));
+ }
AddStep("toggle shadows", () => flow.Children.ForEach(i => i.SpriteIcon.Shadow = !i.SpriteIcon.Shadow));
AddStep("change icons", () => flow.Children.ForEach(i => i.SpriteIcon.Icon = new IconUsage((char)(i.SpriteIcon.Icon.Icon + 1))));
diff --git a/osu.Game.Tournament.Tests/LadderTestScene.cs b/osu.Game.Tournament.Tests/LadderTestScene.cs
index b962d035ab..2f4373679c 100644
--- a/osu.Game.Tournament.Tests/LadderTestScene.cs
+++ b/osu.Game.Tournament.Tests/LadderTestScene.cs
@@ -24,8 +24,7 @@ namespace osu.Game.Tournament.Tests
[BackgroundDependencyLoader]
private void load()
{
- if (Ladder.Ruleset.Value == null)
- Ladder.Ruleset.Value = rulesetStore.AvailableRulesets.First();
+ Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
Ruleset.BindTo(Ladder.Ruleset);
}
diff --git a/osu.Game.Tournament/IPC/FileBasedIPC.cs b/osu.Game.Tournament/IPC/FileBasedIPC.cs
index 53ba597a7e..de4d482d13 100644
--- a/osu.Game.Tournament/IPC/FileBasedIPC.cs
+++ b/osu.Game.Tournament/IPC/FileBasedIPC.cs
@@ -34,6 +34,7 @@ namespace osu.Game.Tournament.IPC
private int lastBeatmapId;
private ScheduledDelegate scheduled;
+ private GetBeatmapRequest beatmapLookupRequest;
public Storage Storage { get; private set; }
@@ -77,6 +78,8 @@ namespace osu.Game.Tournament.IPC
if (lastBeatmapId != beatmapId)
{
+ beatmapLookupRequest?.Cancel();
+
lastBeatmapId = beatmapId;
var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.BeatmapInfo != null);
@@ -85,9 +88,9 @@ namespace osu.Game.Tournament.IPC
Beatmap.Value = existing.BeatmapInfo;
else
{
- var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId });
- req.Success += b => Beatmap.Value = b.ToBeatmap(Rulesets);
- API.Queue(req);
+ beatmapLookupRequest = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId });
+ beatmapLookupRequest.Success += b => Beatmap.Value = b.ToBeatmap(Rulesets);
+ API.Queue(beatmapLookupRequest);
}
}
diff --git a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
index 7f2563c948..de909af152 100644
--- a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
+++ b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
@@ -47,8 +47,7 @@ namespace osu.Game.Tournament.Screens.Drawings
this.storage = storage;
- if (TeamList == null)
- TeamList = new StorageBackedTeamList(storage);
+ TeamList ??= new StorageBackedTeamList(storage);
if (!TeamList.Teams.Any())
{
diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs
index 29908e8e7c..b01c93ae03 100644
--- a/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs
@@ -14,7 +14,10 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
{
private readonly TeamScore score;
- public bool ShowScore { set => score.FadeTo(value ? 1 : 0, 200); }
+ public bool ShowScore
+ {
+ set => score.FadeTo(value ? 1 : 0, 200);
+ }
public TeamDisplay(TournamentTeam team, TeamColour colour, Bindable currentTeamScore, int pointsToWin)
: base(team)
diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/TeamScoreDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/TeamScoreDisplay.cs
index 3e60a03f92..da55ba53ea 100644
--- a/osu.Game.Tournament/Screens/Gameplay/Components/TeamScoreDisplay.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/Components/TeamScoreDisplay.cs
@@ -21,7 +21,10 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
private TeamDisplay teamDisplay;
- public bool ShowScore { set => teamDisplay.ShowScore = value; }
+ public bool ShowScore
+ {
+ set => teamDisplay.ShowScore = value;
+ }
public TeamScoreDisplay(TeamColour teamColour)
{
diff --git a/osu.Game.Tournament/TournamentGame.cs b/osu.Game.Tournament/TournamentGame.cs
index 78bb66d553..7b1a174c1e 100644
--- a/osu.Game.Tournament/TournamentGame.cs
+++ b/osu.Game.Tournament/TournamentGame.cs
@@ -1,11 +1,19 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Drawing;
using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Configuration;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Colour;
using osu.Game.Graphics.Cursor;
using osu.Game.Tournament.Models;
+using osu.Game.Graphics;
+using osuTK;
using osuTK.Graphics;
namespace osu.Game.Tournament
@@ -21,19 +29,87 @@ namespace osu.Game.Tournament
public static readonly Color4 ELEMENT_FOREGROUND_COLOUR = Color4Extensions.FromHex("#000");
public static readonly Color4 TEXT_COLOUR = Color4Extensions.FromHex("#fff");
+ private Drawable heightWarning;
+ private Bindable windowSize;
- protected override void LoadComplete()
+ [BackgroundDependencyLoader]
+ private void load(FrameworkConfigManager frameworkConfig)
{
- base.LoadComplete();
-
- Add(new OsuContextMenuContainer
+ windowSize = frameworkConfig.GetBindable(FrameworkSetting.WindowedSize);
+ windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
{
- RelativeSizeAxes = Axes.Both,
- Child = new TournamentSceneManager()
- });
+ var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
- // we don't want to show the menu cursor as it would appear on stream output.
- MenuCursorContainer.Cursor.Alpha = 0;
+ heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
+ }), true);
+
+ AddRange(new[]
+ {
+ new Container
+ {
+ CornerRadius = 10,
+ Depth = float.MinValue,
+ Position = new Vector2(5),
+ Masking = true,
+ AutoSizeAxes = Axes.Both,
+ Anchor = Anchor.BottomRight,
+ Origin = Anchor.BottomRight,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ Colour = OsuColour.Gray(0.2f),
+ RelativeSizeAxes = Axes.Both,
+ },
+ new TourneyButton
+ {
+ Text = "Save Changes",
+ Width = 140,
+ Height = 50,
+ Padding = new MarginPadding
+ {
+ Top = 10,
+ Left = 10,
+ },
+ Margin = new MarginPadding
+ {
+ Right = 10,
+ Bottom = 10,
+ },
+ Action = SaveChanges,
+ },
+ }
+ },
+ heightWarning = new Container
+ {
+ Masking = true,
+ CornerRadius = 5,
+ Depth = float.MinValue,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ AutoSizeAxes = Axes.Both,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ Colour = Color4.Red,
+ RelativeSizeAxes = Axes.Both,
+ },
+ new TournamentSpriteText
+ {
+ Text = "Please make the window wider",
+ Font = OsuFont.Torus.With(weight: FontWeight.Bold),
+ Colour = Color4.White,
+ Padding = new MarginPadding(20)
+ }
+ }
+ },
+ new OsuContextMenuContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Child = new TournamentSceneManager()
+ }
+ });
}
}
}
diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs
index 9716f0cd5f..bc9999381b 100644
--- a/osu.Game.Tournament/TournamentGameBase.cs
+++ b/osu.Game.Tournament/TournamentGameBase.cs
@@ -2,34 +2,25 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using System.Drawing;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Allocation;
-using osu.Framework.Bindables;
-using osu.Framework.Configuration;
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.IO.Stores;
using osu.Game.Beatmaps;
-using osu.Game.Graphics;
using osu.Game.Online.API.Requests;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.IO;
using osu.Game.Tournament.Models;
using osu.Game.Users;
-using osuTK;
-using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Tournament
{
[Cached(typeof(TournamentGameBase))]
- public abstract class TournamentGameBase : OsuGameBase
+ public class TournamentGameBase : OsuGameBase
{
private const string bracket_filename = "bracket.json";
@@ -38,19 +29,15 @@ namespace osu.Game.Tournament
private TournamentStorage storage;
private DependencyContainer dependencies;
-
- private Bindable windowSize;
private FileBasedIPC ipc;
- private Drawable heightWarning;
-
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
return dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
}
[BackgroundDependencyLoader]
- private void load(FrameworkConfigManager frameworkConfig)
+ private void load(Storage storage)
{
Resources.AddStore(new DllResourceStore(typeof(TournamentGameBase).Assembly));
@@ -58,83 +45,12 @@ namespace osu.Game.Tournament
Textures.AddStore(new TextureLoaderStore(storage.VideoStore));
- windowSize = frameworkConfig.GetBindable(FrameworkSetting.WindowedSize);
- windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
- {
- var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
-
- heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
- }), true);
-
readBracket();
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
dependencies.CacheAs(ipc = new FileBasedIPC());
Add(ipc);
-
- AddRange(new[]
- {
- new Container
- {
- CornerRadius = 10,
- Depth = float.MinValue,
- Position = new Vector2(5),
- Masking = true,
- AutoSizeAxes = Axes.Both,
- Anchor = Anchor.BottomRight,
- Origin = Anchor.BottomRight,
- Children = new Drawable[]
- {
- new Box
- {
- Colour = OsuColour.Gray(0.2f),
- RelativeSizeAxes = Axes.Both,
- },
- new TourneyButton
- {
- Text = "Save Changes",
- Width = 140,
- Height = 50,
- Padding = new MarginPadding
- {
- Top = 10,
- Left = 10,
- },
- Margin = new MarginPadding
- {
- Right = 10,
- Bottom = 10,
- },
- Action = SaveChanges,
- },
- }
- },
- heightWarning = new Container
- {
- Masking = true,
- CornerRadius = 5,
- Depth = float.MinValue,
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
- AutoSizeAxes = Axes.Both,
- Children = new Drawable[]
- {
- new Box
- {
- Colour = Color4.Red,
- RelativeSizeAxes = Axes.Both,
- },
- new TournamentSpriteText
- {
- Text = "Please make the window wider",
- Font = OsuFont.Torus.With(weight: FontWeight.Bold),
- Colour = Color4.White,
- Padding = new MarginPadding(20)
- }
- }
- },
- });
}
private void readBracket()
@@ -146,11 +62,8 @@ namespace osu.Game.Tournament
ladder = JsonConvert.DeserializeObject(sr.ReadToEnd());
}
- if (ladder == null)
- ladder = new LadderInfo();
-
- if (ladder.Ruleset.Value == null)
- ladder.Ruleset.Value = RulesetStore.AvailableRulesets.First();
+ ladder ??= new LadderInfo();
+ ladder.Ruleset.Value ??= RulesetStore.AvailableRulesets.First();
Ruleset.BindTo(ladder.Ruleset);
@@ -312,6 +225,8 @@ namespace osu.Game.Tournament
protected override void LoadComplete()
{
MenuCursorContainer.Cursor.AlwaysPresent = true; // required for tooltip display
+
+ // we don't want to show the menu cursor as it would appear on stream output.
MenuCursorContainer.Cursor.Alpha = 0;
base.LoadComplete();
diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index f626b45e42..2cf3a21975 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -79,6 +79,8 @@ namespace osu.Game.Beatmaps
beatmaps = (BeatmapStore)ModelStore;
beatmaps.BeatmapHidden += b => beatmapHidden.Value = new WeakReference(b);
beatmaps.BeatmapRestored += b => beatmapRestored.Value = new WeakReference(b);
+ beatmaps.ItemRemoved += removeWorkingCache;
+ beatmaps.ItemUpdated += removeWorkingCache;
onlineLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
}
@@ -203,12 +205,17 @@ namespace osu.Game.Beatmaps
stream.Seek(0, SeekOrigin.Begin);
- UpdateFile(setInfo, setInfo.Files.Single(f => string.Equals(f.Filename, info.Path, StringComparison.OrdinalIgnoreCase)), stream);
+ using (ContextFactory.GetForWrite())
+ {
+ var beatmapInfo = setInfo.Beatmaps.Single(b => b.ID == info.ID);
+ beatmapInfo.MD5Hash = stream.ComputeMD5Hash();
+
+ stream.Seek(0, SeekOrigin.Begin);
+ UpdateFile(setInfo, setInfo.Files.Single(f => string.Equals(f.Filename, info.Path, StringComparison.OrdinalIgnoreCase)), stream);
+ }
}
- var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == info.ID);
- if (working != null)
- workingCache.Remove(working);
+ removeWorkingCache(info);
}
private readonly WeakList workingCache = new WeakList();
@@ -239,8 +246,7 @@ namespace osu.Game.Beatmaps
if (working == null)
{
- if (beatmapInfo.Metadata == null)
- beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
+ beatmapInfo.Metadata ??= beatmapInfo.BeatmapSet.Metadata;
workingCache.Add(working = new BeatmapManagerWorkingBeatmap(Files.Store,
new LargeTextureStore(host?.CreateTextureLoaderStore(Files.Store)), beatmapInfo, audioManager));
@@ -258,9 +264,9 @@ namespace osu.Game.Beatmaps
/// The first result for the provided query, or null if no results were found.
public BeatmapSetInfo QueryBeatmapSet(Expression> query) => beatmaps.ConsumableItems.AsNoTracking().FirstOrDefault(query);
- protected override bool CanUndelete(BeatmapSetInfo existing, BeatmapSetInfo import)
+ protected override bool CanReuseExisting(BeatmapSetInfo existing, BeatmapSetInfo import)
{
- if (!base.CanUndelete(existing, import))
+ if (!base.CanReuseExisting(existing, import))
return false;
var existingIds = existing.Beatmaps.Select(b => b.OnlineBeatmapID).OrderBy(i => i);
@@ -410,6 +416,24 @@ namespace osu.Game.Beatmaps
return endTime - startTime;
}
+ private void removeWorkingCache(BeatmapSetInfo info)
+ {
+ if (info.Beatmaps == null) return;
+
+ foreach (var b in info.Beatmaps)
+ removeWorkingCache(b);
+ }
+
+ private void removeWorkingCache(BeatmapInfo info)
+ {
+ lock (workingCache)
+ {
+ var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == info.ID);
+ if (working != null)
+ workingCache.Remove(working);
+ }
+ }
+
public void Dispose()
{
onlineLookupQueue?.Dispose();
diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs
index e62a9bb39d..39c5ccab27 100644
--- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs
+++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Beatmaps
}
}
- private string getPathForFile(string filename) => BeatmapSetInfo.Files.FirstOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
+ private string getPathForFile(string filename) => BeatmapSetInfo.Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
private TextureStore textureStore;
diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
index 388abf4648..be5cd78dc8 100644
--- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
@@ -425,8 +425,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleHitObject(string line)
{
// If the ruleset wasn't specified, assume the osu!standard ruleset.
- if (parser == null)
- parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);
+ parser ??= new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);
var obj = parser.Parse(line);
if (obj != null)
diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs
index ae55a7b14a..915d980d24 100644
--- a/osu.Game/Database/ArchiveModelManager.cs
+++ b/osu.Game/Database/ArchiveModelManager.cs
@@ -276,7 +276,7 @@ namespace osu.Game.Database
// for now, concatenate all .osu files in the set to create a unique hash.
MemoryStream hashable = new MemoryStream();
- foreach (TFileModel file in item.Files.Where(f => HashableFileTypes.Any(f.Filename.EndsWith)))
+ foreach (TFileModel file in item.Files.Where(f => HashableFileTypes.Any(f.Filename.EndsWith)).OrderBy(f => f.Filename))
{
using (Stream s = Files.Store.GetStream(file.FileInfo.StoragePath))
s.CopyTo(hashable);
@@ -332,7 +332,7 @@ namespace osu.Game.Database
if (existing != null)
{
- if (CanUndelete(existing, item))
+ if (CanReuseExisting(existing, item))
{
Undelete(existing);
LogForModel(item, $"Found existing {HumanisedModelName} for {item} (ID {existing.ID}) – skipping import.");
@@ -429,7 +429,6 @@ namespace osu.Game.Database
using (ContextFactory.GetForWrite())
{
item.Hash = computeHash(item);
-
ModelStore.Update(item);
}
}
@@ -660,13 +659,29 @@ namespace osu.Game.Database
protected TModel CheckForExisting(TModel model) => model.Hash == null ? null : ModelStore.ConsumableItems.FirstOrDefault(b => b.Hash == model.Hash);
///
- /// After an existing is found during an import process, the default behaviour is to restore the existing
+ /// After an existing is found during an import process, the default behaviour is to use/restore the existing
/// item and skip the import. This method allows changing that behaviour.
///
/// The existing model.
/// The newly imported model.
/// Whether the existing model should be restored and used. Returning false will delete the existing and force a re-import.
- protected virtual bool CanUndelete(TModel existing, TModel import) => true;
+ protected virtual bool CanReuseExisting(TModel existing, TModel import) =>
+ // for the best or worst, we copy and import files of a new import before checking whether
+ // it is a duplicate. so to check if anything has changed, we can just compare all FileInfo IDs.
+ getIDs(existing.Files).SequenceEqual(getIDs(import.Files)) &&
+ getFilenames(existing.Files).SequenceEqual(getFilenames(import.Files));
+
+ private IEnumerable getIDs(List files)
+ {
+ foreach (var f in files.OrderBy(f => f.Filename))
+ yield return f.FileInfo.ID;
+ }
+
+ private IEnumerable getFilenames(List files)
+ {
+ foreach (var f in files.OrderBy(f => f.Filename))
+ yield return f.Filename;
+ }
private DbSet queryModel() => ContextFactory.Get().Set();
diff --git a/osu.Game/IO/Serialization/Converters/TypedListConverter.cs b/osu.Game/IO/Serialization/Converters/TypedListConverter.cs
index f98fa05821..50b28ea74b 100644
--- a/osu.Game/IO/Serialization/Converters/TypedListConverter.cs
+++ b/osu.Game/IO/Serialization/Converters/TypedListConverter.cs
@@ -41,12 +41,24 @@ namespace osu.Game.IO.Serialization.Converters
var list = new List();
var obj = JObject.Load(reader);
+
+ if (obj["$lookup_table"] == null)
+ return list;
+
var lookupTable = serializer.Deserialize>(obj["$lookup_table"].CreateReader());
+ if (lookupTable == null)
+ return list;
+
+ if (obj["$items"] == null)
+ return list;
foreach (var tok in obj["$items"])
{
var itemReader = tok.CreateReader();
+ if (tok["$type"] == null)
+ throw new JsonException("Expected $type token.");
+
var typeName = lookupTable[(int)tok["$type"]];
var instance = (T)Activator.CreateInstance(Type.GetType(typeName));
serializer.Populate(itemReader, instance);
diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs
index 4945f7f185..4ea5c192fe 100644
--- a/osu.Game/Online/API/APIAccess.cs
+++ b/osu.Game/Online/API/APIAccess.cs
@@ -11,6 +11,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ExceptionExtensions;
+using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Game.Configuration;
@@ -250,7 +251,7 @@ namespace osu.Game.Online.API
{
try
{
- return JObject.Parse(req.GetResponseString()).SelectToken("form_error", true).ToObject();
+ return JObject.Parse(req.GetResponseString()).SelectToken("form_error", true).AsNonNull().ToObject();
}
catch
{
diff --git a/osu.Game/Online/API/APIPlaylistBeatmap.cs b/osu.Game/Online/API/APIPlaylistBeatmap.cs
new file mode 100644
index 0000000000..4f7786e880
--- /dev/null
+++ b/osu.Game/Online/API/APIPlaylistBeatmap.cs
@@ -0,0 +1,23 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using osu.Game.Beatmaps;
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Rulesets;
+
+namespace osu.Game.Online.API
+{
+ public class APIPlaylistBeatmap : APIBeatmap
+ {
+ [JsonProperty("checksum")]
+ public string Checksum { get; set; }
+
+ public override BeatmapInfo ToBeatmap(RulesetStore rulesets)
+ {
+ var b = base.ToBeatmap(rulesets);
+ b.MD5Hash = Checksum;
+ return b;
+ }
+ }
+}
diff --git a/osu.Game/Online/API/Requests/CreateChannelRequest.cs b/osu.Game/Online/API/Requests/CreateChannelRequest.cs
new file mode 100644
index 0000000000..42cb201969
--- /dev/null
+++ b/osu.Game/Online/API/Requests/CreateChannelRequest.cs
@@ -0,0 +1,34 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using System.Net.Http;
+using osu.Framework.IO.Network;
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Online.Chat;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class CreateChannelRequest : APIRequest
+ {
+ private readonly Channel channel;
+
+ public CreateChannelRequest(Channel channel)
+ {
+ this.channel = channel;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+ req.Method = HttpMethod.Post;
+
+ req.AddParameter("type", $"{ChannelType.PM}");
+ req.AddParameter("target_id", $"{channel.Users.First().Id}");
+
+ return req;
+ }
+
+ protected override string Target => @"chat/channels";
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs
index e023a2502f..ae65ac09b2 100644
--- a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs
+++ b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs
@@ -64,7 +64,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"max_combo")]
private int? maxCombo { get; set; }
- public BeatmapInfo ToBeatmap(RulesetStore rulesets)
+ public virtual BeatmapInfo ToBeatmap(RulesetStore rulesets)
{
var set = BeatmapSet?.ToBeatmapSet(rulesets);
diff --git a/osu.Game/Online/API/Requests/Responses/APIChatChannel.cs b/osu.Game/Online/API/Requests/Responses/APIChatChannel.cs
new file mode 100644
index 0000000000..fc3b2a8e31
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/APIChatChannel.cs
@@ -0,0 +1,18 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using osu.Game.Online.Chat;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class APIChatChannel
+ {
+ [JsonProperty(@"channel_id")]
+ public int? ChannelID { get; set; }
+
+ [JsonProperty(@"recent_messages")]
+ public List RecentMessages { get; set; }
+ }
+}
diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs
index dbb2da5c03..8c1e1ad128 100644
--- a/osu.Game/Online/Chat/Channel.cs
+++ b/osu.Game/Online/Chat/Channel.cs
@@ -84,7 +84,8 @@ namespace osu.Game.Online.Chat
public long? LastReadId;
///
- /// Signalles if the current user joined this channel or not. Defaults to false.
+ /// Signals if the current user joined this channel or not. Defaults to false.
+ /// Note that this does not guarantee a join has completed. Check Id > 0 for confirmation.
///
public Bindable Joined = new Bindable();
diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs
index 53872ddcba..3b336fef4f 100644
--- a/osu.Game/Online/Chat/ChannelManager.cs
+++ b/osu.Game/Online/Chat/ChannelManager.cs
@@ -86,19 +86,13 @@ namespace osu.Game.Online.Chat
return;
CurrentChannel.Value = JoinedChannels.FirstOrDefault(c => c.Type == ChannelType.PM && c.Users.Count == 1 && c.Users.Any(u => u.Id == user.Id))
- ?? new Channel(user);
+ ?? JoinChannel(new Channel(user));
}
private void currentChannelChanged(ValueChangedEvent e)
{
if (!(e.NewValue is ChannelSelectorTabItem.ChannelSelectorTabChannel))
JoinChannel(e.NewValue);
-
- if (e.NewValue?.MessagesLoaded == false)
- {
- // let's fetch a small number of messages to bring us up-to-date with the backlog.
- fetchInitalMessages(e.NewValue);
- }
}
///
@@ -114,8 +108,7 @@ namespace osu.Game.Online.Chat
/// An optional target channel. If null, will be used.
public void PostMessage(string text, bool isAction = false, Channel target = null)
{
- if (target == null)
- target = CurrentChannel.Value;
+ target ??= CurrentChannel.Value;
if (target == null)
return;
@@ -146,7 +139,7 @@ namespace osu.Game.Online.Chat
target.AddLocalEcho(message);
// if this is a PM and the first message, we need to do a special request to create the PM channel
- if (target.Type == ChannelType.PM && !target.Joined.Value)
+ if (target.Type == ChannelType.PM && target.Id == 0)
{
var createNewPrivateMessageRequest = new CreateNewPrivateMessageRequest(target.Users.First(), message);
@@ -198,8 +191,7 @@ namespace osu.Game.Online.Chat
/// An optional target channel. If null, will be used.
public void PostCommand(string text, Channel target = null)
{
- if (target == null)
- target = CurrentChannel.Value;
+ target ??= CurrentChannel.Value;
if (target == null)
return;
@@ -240,7 +232,6 @@ namespace osu.Game.Online.Chat
}
JoinChannel(channel);
- CurrentChannel.Value = channel;
break;
case "help":
@@ -275,7 +266,7 @@ namespace osu.Game.Online.Chat
// join any channels classified as "defaults"
if (joinDefaults && defaultChannels.Any(c => c.Equals(channel.Name, StringComparison.OrdinalIgnoreCase)))
- JoinChannel(ch);
+ joinChannel(ch);
}
};
req.Failure += error =>
@@ -296,7 +287,7 @@ namespace osu.Game.Online.Chat
/// The channel
private void fetchInitalMessages(Channel channel)
{
- if (channel.Id <= 0) return;
+ if (channel.Id <= 0 || channel.MessagesLoaded) return;
var fetchInitialMsgReq = new GetMessagesRequest(channel);
fetchInitialMsgReq.Success += messages =>
@@ -351,9 +342,10 @@ namespace osu.Game.Online.Chat
/// Joins a channel if it has not already been joined.
///
/// The channel to join.
- /// Whether the channel has already been joined server-side. Will skip a join request.
/// The joined channel. Note that this may not match the parameter channel as it is a backed object.
- public Channel JoinChannel(Channel channel, bool alreadyJoined = false)
+ public Channel JoinChannel(Channel channel) => joinChannel(channel, true);
+
+ private Channel joinChannel(Channel channel, bool fetchInitialMessages = false)
{
if (channel == null) return null;
@@ -362,24 +354,47 @@ namespace osu.Game.Online.Chat
// ensure we are joined to the channel
if (!channel.Joined.Value)
{
- if (alreadyJoined)
- channel.Joined.Value = true;
- else
+ channel.Joined.Value = true;
+
+ switch (channel.Type)
{
- switch (channel.Type)
- {
- case ChannelType.Public:
- var req = new JoinChannelRequest(channel, api.LocalUser.Value);
- req.Success += () => JoinChannel(channel, true);
- req.Failure += ex => LeaveChannel(channel);
- api.Queue(req);
- return channel;
- }
+ case ChannelType.Multiplayer:
+ // join is implicit. happens when you join a multiplayer game.
+ // this will probably change in the future.
+ joinChannel(channel, fetchInitialMessages);
+ return channel;
+
+ case ChannelType.PM:
+ var createRequest = new CreateChannelRequest(channel);
+ createRequest.Success += resChannel =>
+ {
+ if (resChannel.ChannelID.HasValue)
+ {
+ channel.Id = resChannel.ChannelID.Value;
+
+ handleChannelMessages(resChannel.RecentMessages);
+ channel.MessagesLoaded = true; // this will mark the channel as having received messages even if there were none.
+ }
+ };
+
+ api.Queue(createRequest);
+ break;
+
+ default:
+ var req = new JoinChannelRequest(channel, api.LocalUser.Value);
+ req.Success += () => joinChannel(channel, fetchInitialMessages);
+ req.Failure += ex => LeaveChannel(channel);
+ api.Queue(req);
+ return channel;
}
}
+ else
+ {
+ if (fetchInitialMessages)
+ fetchInitalMessages(channel);
+ }
- if (CurrentChannel.Value == null)
- CurrentChannel.Value = channel;
+ CurrentChannel.Value ??= channel;
return channel;
}
@@ -420,7 +435,8 @@ namespace osu.Game.Online.Chat
foreach (var channel in updates.Presence)
{
// we received this from the server so should mark the channel already joined.
- JoinChannel(channel, true);
+ channel.Joined.Value = true;
+ joinChannel(channel);
}
//todo: handle left channels
diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs
index 4fbeac1db9..f8810c778f 100644
--- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs
+++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs
@@ -73,8 +73,7 @@ namespace osu.Game.Online.Chat
[BackgroundDependencyLoader(true)]
private void load(ChannelManager manager)
{
- if (ChannelManager == null)
- ChannelManager = manager;
+ ChannelManager ??= manager;
}
protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) =>
diff --git a/osu.Game/Online/Multiplayer/PlaylistItem.cs b/osu.Game/Online/Multiplayer/PlaylistItem.cs
index 9d6e8eb8e3..416091a1aa 100644
--- a/osu.Game/Online/Multiplayer/PlaylistItem.cs
+++ b/osu.Game/Online/Multiplayer/PlaylistItem.cs
@@ -7,7 +7,6 @@ using Newtonsoft.Json;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
-using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
@@ -37,7 +36,7 @@ namespace osu.Game.Online.Multiplayer
public readonly BindableList RequiredMods = new BindableList();
[JsonProperty("beatmap")]
- private APIBeatmap apiBeatmap { get; set; }
+ private APIPlaylistBeatmap apiBeatmap { get; set; }
private APIMod[] allowedModsBacking;
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index 5e44562144..3e7311092e 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -164,7 +164,7 @@ namespace osu.Game
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore(Resources, "Skins/Legacy")));
dependencies.CacheAs(SkinManager);
- if (API == null) API = new APIAccess(LocalConfig);
+ API ??= new APIAccess(LocalConfig);
dependencies.CacheAs(API);
@@ -311,11 +311,10 @@ namespace osu.Game
{
base.SetHost(host);
- if (Storage == null) // may be non-null for certain tests
- Storage = new OsuStorage(host);
+ // may be non-null for certain tests
+ Storage ??= new OsuStorage(host);
- if (LocalConfig == null)
- LocalConfig = new OsuConfigManager(Storage);
+ LocalConfig ??= new OsuConfigManager(Storage);
}
private readonly List fileImporters = new List();
diff --git a/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs b/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs
index a72f182450..cb6abb7cc6 100644
--- a/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs
+++ b/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs
@@ -68,8 +68,7 @@ namespace osu.Game.Overlays.Chat.Tabs
if (!Items.Contains(channel))
AddItem(channel);
- if (Current.Value == null)
- Current.Value = channel;
+ Current.Value ??= channel;
}
///
diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs
index 01d5991d3e..eafb4572ca 100644
--- a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs
+++ b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs
@@ -274,6 +274,9 @@ namespace osu.Game.Overlays.KeyBinding
private void clear()
{
+ if (bindTarget == null)
+ return;
+
bindTarget.UpdateKeyCombination(InputKey.None);
finalise();
}
@@ -333,7 +336,7 @@ namespace osu.Game.Overlays.KeyBinding
}
}
- private class ClearButton : TriangleButton
+ public class ClearButton : TriangleButton
{
public ClearButton()
{
diff --git a/osu.Game/Rulesets/Mods/ModEasy.cs b/osu.Game/Rulesets/Mods/ModEasy.cs
index 7cf9656810..c6f3930029 100644
--- a/osu.Game/Rulesets/Mods/ModEasy.cs
+++ b/osu.Game/Rulesets/Mods/ModEasy.cs
@@ -35,7 +35,9 @@ namespace osu.Game.Rulesets.Mods
private BindableNumber health;
- public void ReadFromDifficulty(BeatmapDifficulty difficulty) { }
+ public void ReadFromDifficulty(BeatmapDifficulty difficulty)
+ {
+ }
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
diff --git a/osu.Game/Rulesets/Mods/ModHardRock.cs b/osu.Game/Rulesets/Mods/ModHardRock.cs
index 58c9a58408..0e589735c1 100644
--- a/osu.Game/Rulesets/Mods/ModHardRock.cs
+++ b/osu.Game/Rulesets/Mods/ModHardRock.cs
@@ -17,7 +17,9 @@ namespace osu.Game.Rulesets.Mods
public override string Description => "Everything just got a bit harder...";
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModDifficultyAdjust) };
- public void ReadFromDifficulty(BeatmapDifficulty difficulty) { }
+ public void ReadFromDifficulty(BeatmapDifficulty difficulty)
+ {
+ }
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs
index e2cc98813a..1d60b266e3 100644
--- a/osu.Game/Rulesets/Objects/HitObject.cs
+++ b/osu.Game/Rulesets/Objects/HitObject.cs
@@ -133,8 +133,7 @@ namespace osu.Game.Rulesets.Objects
{
Kiai = controlPointInfo.EffectPointAt(StartTime + control_point_leniency).KiaiMode;
- if (HitWindows == null)
- HitWindows = CreateHitWindows();
+ HitWindows ??= CreateHitWindows();
HitWindows?.SetDifficulty(difficulty.OverallDifficulty);
}
diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs
index bc9401a095..d574991fa0 100644
--- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs
+++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs
@@ -181,8 +181,7 @@ namespace osu.Game.Rulesets.UI
private void setClock()
{
// in case a parent gameplay clock isn't available, just use the parent clock.
- if (parentGameplayClock == null)
- parentGameplayClock = Clock;
+ parentGameplayClock ??= Clock;
Clock = GameplayClock;
ProcessCustomClock = false;
diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs
index a40f436a6e..7b37c267bc 100644
--- a/osu.Game/Scoring/ScoreInfo.cs
+++ b/osu.Game/Scoring/ScoreInfo.cs
@@ -115,9 +115,7 @@ namespace osu.Game.Scoring
get => User?.Username;
set
{
- if (User == null)
- User = new User();
-
+ User ??= new User();
User.Username = value;
}
}
@@ -129,9 +127,7 @@ namespace osu.Game.Scoring
get => User?.Id ?? 1;
set
{
- if (User == null)
- User = new User();
-
+ User ??= new User();
User.Id = value ?? 1;
}
}
diff --git a/osu.Game/Screens/Edit/Timing/Section.cs b/osu.Game/Screens/Edit/Timing/Section.cs
index ccf1582486..603fb77f31 100644
--- a/osu.Game/Screens/Edit/Timing/Section.cs
+++ b/osu.Game/Screens/Edit/Timing/Section.cs
@@ -57,7 +57,7 @@ namespace osu.Game.Screens.Edit.Timing
{
checkbox = new OsuCheckbox
{
- LabelText = typeof(T).Name.Replace(typeof(ControlPoint).Name, string.Empty)
+ LabelText = typeof(T).Name.Replace(nameof(Beatmaps.ControlPoints.ControlPoint), string.Empty)
}
}
},
diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs
index 0d5f3d1142..b99d8ae9d1 100644
--- a/osu.Game/Screens/Menu/IntroScreen.cs
+++ b/osu.Game/Screens/Menu/IntroScreen.cs
@@ -41,9 +41,9 @@ namespace osu.Game.Screens.Menu
protected IBindable MenuMusic { get; private set; }
- private WorkingBeatmap introBeatmap;
+ private WorkingBeatmap initialBeatmap;
- protected Track Track { get; private set; }
+ protected Track Track => initialBeatmap?.Track;
private readonly BindableDouble exitingVolumeFade = new BindableDouble(1);
@@ -58,6 +58,11 @@ namespace osu.Game.Screens.Menu
[Resolved]
private AudioManager audio { get; set; }
+ ///
+ /// Whether the is provided by osu! resources, rather than a user beatmap.
+ ///
+ protected bool UsingThemedIntro { get; private set; }
+
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game)
{
@@ -71,29 +76,45 @@ namespace osu.Game.Screens.Menu
BeatmapSetInfo setInfo = null;
+ // if the user has requested not to play theme music, we should attempt to find a random beatmap from their collection.
if (!MenuMusic.Value)
{
var sets = beatmaps.GetAllUsableBeatmapSets(IncludedDetails.Minimal);
+
if (sets.Count > 0)
- setInfo = beatmaps.QueryBeatmapSet(s => s.ID == sets[RNG.Next(0, sets.Count - 1)].ID);
- }
-
- if (setInfo == null)
- {
- setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapHash);
-
- if (setInfo == null)
{
- // we need to import the default menu background beatmap
- setInfo = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream($"Tracks/{BeatmapFile}"), BeatmapFile)).Result;
-
- setInfo.Protected = true;
- beatmaps.Update(setInfo);
+ setInfo = beatmaps.QueryBeatmapSet(s => s.ID == sets[RNG.Next(0, sets.Count - 1)].ID);
+ initialBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
}
}
- introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
- Track = introBeatmap.Track;
+ // we generally want a song to be playing on startup, so use the intro music even if a user has specified not to if no other track is available.
+ if (setInfo == null)
+ {
+ if (!loadThemedIntro())
+ {
+ // if we detect that the theme track or beatmap is unavailable this is either first startup or things are in a bad state.
+ // this could happen if a user has nuked their files store. for now, reimport to repair this.
+ var import = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream($"Tracks/{BeatmapFile}"), BeatmapFile)).Result;
+ import.Protected = true;
+ beatmaps.Update(import);
+
+ loadThemedIntro();
+ }
+ }
+
+ bool loadThemedIntro()
+ {
+ setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapHash);
+
+ if (setInfo != null)
+ {
+ initialBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
+ UsingThemedIntro = !(Track is TrackVirtual);
+ }
+
+ return UsingThemedIntro;
+ }
}
public override void OnResuming(IScreen last)
@@ -119,7 +140,7 @@ namespace osu.Game.Screens.Menu
public override void OnSuspending(IScreen next)
{
base.OnSuspending(next);
- Track = null;
+ initialBeatmap = null;
}
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack();
@@ -127,7 +148,7 @@ namespace osu.Game.Screens.Menu
protected void StartTrack()
{
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu.
- if (MenuMusic.Value)
+ if (UsingThemedIntro)
Track.Restart();
}
@@ -141,8 +162,7 @@ namespace osu.Game.Screens.Menu
if (!resuming)
{
- beatmap.Value = introBeatmap;
- introBeatmap = null;
+ beatmap.Value = initialBeatmap;
logo.MoveTo(new Vector2(0.5f));
logo.ScaleTo(Vector2.One);
diff --git a/osu.Game/Screens/Menu/IntroTriangles.cs b/osu.Game/Screens/Menu/IntroTriangles.cs
index 188a49c147..225ad02ec4 100644
--- a/osu.Game/Screens/Menu/IntroTriangles.cs
+++ b/osu.Game/Screens/Menu/IntroTriangles.cs
@@ -46,7 +46,7 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader]
private void load()
{
- if (MenuVoice.Value && !MenuMusic.Value)
+ if (MenuVoice.Value && !UsingThemedIntro)
welcome = audio.Samples.Get(@"welcome");
}
@@ -61,7 +61,7 @@ namespace osu.Game.Screens.Menu
LoadComponentAsync(new TrianglesIntroSequence(logo, background)
{
RelativeSizeAxes = Axes.Both,
- Clock = new FramedClock(MenuMusic.Value ? Track : null),
+ Clock = new FramedClock(UsingThemedIntro ? Track : null),
LoadMenu = LoadMenu
}, t =>
{
diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs
index 0db7f2a2dc..6a28740d4e 100644
--- a/osu.Game/Screens/Menu/LogoVisualisation.cs
+++ b/osu.Game/Screens/Menu/LogoVisualisation.cs
@@ -12,17 +12,16 @@ using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
-using osu.Game.Skinning;
-using osu.Game.Online.API;
-using osu.Game.Users;
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
-using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Utils;
namespace osu.Game.Screens.Menu
{
+ ///
+ /// A visualiser that reacts to music coming from beatmaps.
+ ///
public class LogoVisualisation : Drawable, IHasAccentColour
{
private readonly IBindable beatmap = new Bindable();
@@ -71,9 +70,6 @@ namespace osu.Game.Screens.Menu
private IShader shader;
private readonly Texture texture;
- private Bindable user;
- private Bindable skin;
-
public LogoVisualisation()
{
texture = Texture.WhitePixel;
@@ -81,15 +77,10 @@ namespace osu.Game.Screens.Menu
}
[BackgroundDependencyLoader]
- private void load(ShaderManager shaders, IBindable beatmap, IAPIProvider api, SkinManager skinManager)
+ private void load(ShaderManager shaders, IBindable beatmap)
{
this.beatmap.BindTo(beatmap);
shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
- user = api.LocalUser.GetBoundCopy();
- skin = skinManager.CurrentSkin.GetBoundCopy();
-
- user.ValueChanged += _ => updateColour();
- skin.BindValueChanged(_ => updateColour(), true);
}
private void updateAmplitudes()
@@ -118,16 +109,6 @@ namespace osu.Game.Screens.Menu
indexOffset = (indexOffset + index_change) % bars_per_visualiser;
}
- private void updateColour()
- {
- Color4 defaultColour = Color4.White.Opacity(0.2f);
-
- if (user.Value?.IsSupporter ?? false)
- AccentColour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? defaultColour;
- else
- AccentColour = defaultColour;
- }
-
protected override void LoadComplete()
{
base.LoadComplete();
diff --git a/osu.Game/Screens/Menu/MenuLogoVisualisation.cs b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs
new file mode 100644
index 0000000000..5eb3f1efa0
--- /dev/null
+++ b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs
@@ -0,0 +1,39 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osuTK.Graphics;
+using osu.Game.Skinning;
+using osu.Game.Online.API;
+using osu.Game.Users;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Extensions.Color4Extensions;
+
+namespace osu.Game.Screens.Menu
+{
+ internal class MenuLogoVisualisation : LogoVisualisation
+ {
+ private Bindable user;
+ private Bindable skin;
+
+ [BackgroundDependencyLoader]
+ private void load(IAPIProvider api, SkinManager skinManager)
+ {
+ user = api.LocalUser.GetBoundCopy();
+ skin = skinManager.CurrentSkin.GetBoundCopy();
+
+ user.ValueChanged += _ => updateColour();
+ skin.BindValueChanged(_ => updateColour(), true);
+ }
+
+ private void updateColour()
+ {
+ Color4 defaultColour = Color4.White.Opacity(0.2f);
+
+ if (user.Value?.IsSupporter ?? false)
+ AccentColour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? defaultColour;
+ else
+ AccentColour = defaultColour;
+ }
+ }
+}
diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs
index 800520100e..9cadfd7df6 100644
--- a/osu.Game/Screens/Menu/OsuLogo.cs
+++ b/osu.Game/Screens/Menu/OsuLogo.cs
@@ -38,7 +38,7 @@ namespace osu.Game.Screens.Menu
private readonly Container logoBeatContainer;
private readonly Container logoAmplitudeContainer;
private readonly Container logoHoverContainer;
- private readonly LogoVisualisation visualizer;
+ private readonly MenuLogoVisualisation visualizer;
private readonly IntroSequence intro;
@@ -139,7 +139,7 @@ namespace osu.Game.Screens.Menu
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
- visualizer = new LogoVisualisation
+ visualizer = new MenuLogoVisualisation
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
diff --git a/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs
index c024304856..414c1f5748 100644
--- a/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs
+++ b/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs
@@ -188,7 +188,7 @@ namespace osu.Game.Screens.Multi
X = -18,
Children = new Drawable[]
{
- new PlaylistDownloadButton(item.Beatmap.Value.BeatmapSet)
+ new PlaylistDownloadButton(item)
{
Size = new Vector2(50, 30)
},
@@ -212,9 +212,15 @@ namespace osu.Game.Screens.Multi
private class PlaylistDownloadButton : BeatmapPanelDownloadButton
{
- public PlaylistDownloadButton(BeatmapSetInfo beatmapSet)
- : base(beatmapSet)
+ private readonly PlaylistItem playlistItem;
+
+ [Resolved]
+ private BeatmapManager beatmapManager { get; set; }
+
+ public PlaylistDownloadButton(PlaylistItem playlistItem)
+ : base(playlistItem.Beatmap.Value.BeatmapSet)
{
+ this.playlistItem = playlistItem;
Alpha = 0;
}
@@ -223,11 +229,26 @@ namespace osu.Game.Screens.Multi
base.LoadComplete();
State.BindValueChanged(stateChanged, true);
+ FinishTransforms(true);
}
private void stateChanged(ValueChangedEvent state)
{
- this.FadeTo(state.NewValue == DownloadState.LocallyAvailable ? 0 : 1, 500);
+ switch (state.NewValue)
+ {
+ case DownloadState.LocallyAvailable:
+ // Perform a local query of the beatmap by beatmap checksum, and reset the state if not matching.
+ if (beatmapManager.QueryBeatmap(b => b.MD5Hash == playlistItem.Beatmap.Value.MD5Hash) == null)
+ State.Value = DownloadState.NotDownloaded;
+ else
+ this.FadeTo(0, 500);
+
+ break;
+
+ default:
+ this.FadeTo(1, 500);
+ break;
+ }
}
}
diff --git a/osu.Game/Screens/Multi/IRoomManager.cs b/osu.Game/Screens/Multi/IRoomManager.cs
index f6c979851e..bf75843c3e 100644
--- a/osu.Game/Screens/Multi/IRoomManager.cs
+++ b/osu.Game/Screens/Multi/IRoomManager.cs
@@ -14,6 +14,11 @@ namespace osu.Game.Screens.Multi
///
event Action RoomsUpdated;
+ ///
+ /// Whether an initial listing of rooms has been received.
+ ///
+ Bindable InitialRoomsReceived { get; }
+
///
/// All the active s.
///
diff --git a/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs b/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs
index 300418441e..2742ef3404 100644
--- a/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs
+++ b/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs
@@ -34,8 +34,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
[BackgroundDependencyLoader]
private void load()
{
- if (filter == null)
- filter = new Bindable();
+ filter ??= new Bindable();
}
protected override void LoadComplete()
diff --git a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs
index 7c10f0f975..d4b6a3b79f 100644
--- a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs
+++ b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs
@@ -22,12 +22,16 @@ namespace osu.Game.Screens.Multi.Lounge
protected readonly FilterControl Filter;
+ private readonly Bindable initialRoomsReceived = new Bindable();
+
private readonly Container content;
private readonly LoadingLayer loadingLayer;
[Resolved]
private Bindable selectedRoom { get; set; }
+ private bool joiningRoom;
+
public LoungeSubScreen()
{
SearchContainer searchContainer;
@@ -73,6 +77,14 @@ namespace osu.Game.Screens.Multi.Lounge
};
}
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ initialRoomsReceived.BindTo(RoomManager.InitialRoomsReceived);
+ initialRoomsReceived.BindValueChanged(onInitialRoomsReceivedChanged, true);
+ }
+
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
@@ -126,12 +138,29 @@ namespace osu.Game.Screens.Multi.Lounge
private void joinRequested(Room room)
{
- loadingLayer.Show();
+ joiningRoom = true;
+ updateLoadingLayer();
+
RoomManager?.JoinRoom(room, r =>
{
Open(room);
+ joiningRoom = false;
+ updateLoadingLayer();
+ }, _ =>
+ {
+ joiningRoom = false;
+ updateLoadingLayer();
+ });
+ }
+
+ private void onInitialRoomsReceivedChanged(ValueChangedEvent received) => updateLoadingLayer();
+
+ private void updateLoadingLayer()
+ {
+ if (joiningRoom || !initialRoomsReceived.Value)
+ loadingLayer.Show();
+ else
loadingLayer.Hide();
- }, _ => loadingLayer.Hide());
}
///
diff --git a/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs b/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs
index 54c4f8f7c7..49a0fc434b 100644
--- a/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs
+++ b/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs
@@ -433,7 +433,7 @@ namespace osu.Game.Screens.Multi.Match.Components
}
}
- private class CreateRoomButton : TriangleButton
+ public class CreateRoomButton : TriangleButton
{
public CreateRoomButton()
{
diff --git a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs
index e1f86fcc97..a64f24dd7e 100644
--- a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs
+++ b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs
@@ -3,6 +3,7 @@
using System;
using System.Linq;
+using System.Linq.Expressions;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
@@ -52,24 +53,14 @@ namespace osu.Game.Screens.Multi.Match.Components
private void updateSelectedItem(PlaylistItem item)
{
- hasBeatmap = false;
-
- int? beatmapId = SelectedItem.Value?.Beatmap.Value?.OnlineBeatmapID;
- if (beatmapId == null)
- return;
-
- hasBeatmap = beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == beatmapId) != null;
+ hasBeatmap = findBeatmap(expr => beatmaps.QueryBeatmap(expr));
}
private void beatmapUpdated(ValueChangedEvent> weakSet)
{
if (weakSet.NewValue.TryGetTarget(out var set))
{
- int? beatmapId = SelectedItem.Value?.Beatmap.Value?.OnlineBeatmapID;
- if (beatmapId == null)
- return;
-
- if (set.Beatmaps.Any(b => b.OnlineBeatmapID == beatmapId))
+ if (findBeatmap(expr => set.Beatmaps.AsQueryable().FirstOrDefault(expr)))
Schedule(() => hasBeatmap = true);
}
}
@@ -78,15 +69,22 @@ namespace osu.Game.Screens.Multi.Match.Components
{
if (weakSet.NewValue.TryGetTarget(out var set))
{
- int? beatmapId = SelectedItem.Value?.Beatmap.Value?.OnlineBeatmapID;
- if (beatmapId == null)
- return;
-
- if (set.Beatmaps.Any(b => b.OnlineBeatmapID == beatmapId))
+ if (findBeatmap(expr => set.Beatmaps.AsQueryable().FirstOrDefault(expr)))
Schedule(() => hasBeatmap = false);
}
}
+ private bool findBeatmap(Func>, BeatmapInfo> expression)
+ {
+ int? beatmapId = SelectedItem.Value?.Beatmap.Value?.OnlineBeatmapID;
+ string checksum = SelectedItem.Value?.Beatmap.Value?.MD5Hash;
+
+ if (beatmapId == null || checksum == null)
+ return false;
+
+ return expression(b => b.OnlineBeatmapID == beatmapId && b.MD5Hash == checksum) != null;
+ }
+
protected override void Update()
{
base.Update();
diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs
index e1d72d9600..bbfbaf81af 100644
--- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs
+++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs
@@ -207,6 +207,8 @@ namespace osu.Game.Screens.Multi.Match
Ruleset.Value = item.Ruleset.Value;
}
+ private void beatmapUpdated(ValueChangedEvent> weakSet) => Schedule(updateWorkingBeatmap);
+
private void updateWorkingBeatmap()
{
var beatmap = SelectedItem.Value?.Beatmap.Value;
@@ -217,17 +219,6 @@ namespace osu.Game.Screens.Multi.Match
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
}
- private void beatmapUpdated(ValueChangedEvent> weakSet)
- {
- Schedule(() =>
- {
- if (Beatmap.Value != beatmapManager.DefaultBeatmap)
- return;
-
- updateWorkingBeatmap();
- });
- }
-
private void onStart()
{
switch (type.Value)
diff --git a/osu.Game/Screens/Multi/RoomManager.cs b/osu.Game/Screens/Multi/RoomManager.cs
index ad461af57f..4d6ac46c84 100644
--- a/osu.Game/Screens/Multi/RoomManager.cs
+++ b/osu.Game/Screens/Multi/RoomManager.cs
@@ -25,6 +25,9 @@ namespace osu.Game.Screens.Multi
public event Action RoomsUpdated;
private readonly BindableList rooms = new BindableList();
+
+ public Bindable InitialRoomsReceived { get; } = new Bindable();
+
public IBindableList Rooms => rooms;
public double TimeBetweenListingPolls
@@ -62,7 +65,11 @@ namespace osu.Game.Screens.Multi
InternalChildren = new Drawable[]
{
- listingPollingComponent = new ListingPollingComponent { RoomsReceived = onListingReceived },
+ listingPollingComponent = new ListingPollingComponent
+ {
+ InitialRoomsReceived = { BindTarget = InitialRoomsReceived },
+ RoomsReceived = onListingReceived
+ },
selectionPollingComponent = new SelectionPollingComponent { RoomReceived = onSelectedRoomReceived }
};
}
@@ -262,6 +269,8 @@ namespace osu.Game.Screens.Multi
{
public Action> RoomsReceived;
+ public readonly Bindable InitialRoomsReceived = new Bindable();
+
[Resolved]
private IAPIProvider api { get; set; }
@@ -273,6 +282,8 @@ namespace osu.Game.Screens.Multi
{
currentFilter.BindValueChanged(_ =>
{
+ InitialRoomsReceived.Value = false;
+
if (IsLoaded)
PollImmediately();
});
@@ -292,6 +303,7 @@ namespace osu.Game.Screens.Multi
pollReq.Success += result =>
{
+ InitialRoomsReceived.Value = true;
RoomsReceived?.Invoke(result);
tcs.SetResult(true);
};
diff --git a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs
index fd8ac33aef..81d5d113ae 100644
--- a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs
+++ b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs
@@ -211,7 +211,7 @@ namespace osu.Game.Screens.Ranking.Expanded
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold),
- Text = $"Played on {score.Date.ToLocalTime():g}"
+ Text = $"Played on {score.Date.ToLocalTime():d MMMM yyyy HH:mm}"
}
}
};
diff --git a/osu.Game/Screens/Ranking/ScorePanel.cs b/osu.Game/Screens/Ranking/ScorePanel.cs
index a99b48e8f0..65fb901c89 100644
--- a/osu.Game/Screens/Ranking/ScorePanel.cs
+++ b/osu.Game/Screens/Ranking/ScorePanel.cs
@@ -243,5 +243,10 @@ namespace osu.Game.Screens.Ranking
return true;
}
+
+ public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
+ => base.ReceivePositionalInputAt(screenSpacePos)
+ || topLayerContainer.ReceivePositionalInputAt(screenSpacePos)
+ || middleLayerContainer.ReceivePositionalInputAt(screenSpacePos);
}
}
diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs
index 2d714d1794..e174c46610 100644
--- a/osu.Game/Screens/Select/BeatmapCarousel.cs
+++ b/osu.Game/Screens/Select/BeatmapCarousel.cs
@@ -607,10 +607,7 @@ namespace osu.Game.Screens.Select
// todo: remove the need for this.
foreach (var b in beatmapSet.Beatmaps)
- {
- if (b.Metadata == null)
- b.Metadata = beatmapSet.Metadata;
- }
+ b.Metadata ??= beatmapSet.Metadata;
var set = new CarouselBeatmapSet(beatmapSet)
{
diff --git a/osu.Game/Tests/Beatmaps/TestBeatmap.cs b/osu.Game/Tests/Beatmaps/TestBeatmap.cs
index a7c84bf692..9fc20fd0f2 100644
--- a/osu.Game/Tests/Beatmaps/TestBeatmap.cs
+++ b/osu.Game/Tests/Beatmaps/TestBeatmap.cs
@@ -1,9 +1,11 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
+using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.IO;
using osu.Game.Rulesets;
@@ -43,10 +45,25 @@ namespace osu.Game.Tests.Beatmaps
private static Beatmap createTestBeatmap()
{
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data)))
- using (var reader = new LineBufferedReader(stream))
- return Decoder.GetDecoder(reader).Decode(reader);
+ {
+ using (var reader = new LineBufferedReader(stream))
+ {
+ var b = Decoder.GetDecoder(reader).Decode(reader);
+
+ b.BeatmapInfo.MD5Hash = test_beatmap_hash.Value.md5;
+ b.BeatmapInfo.Hash = test_beatmap_hash.Value.sha2;
+
+ return b;
+ }
+ }
}
+ private static readonly Lazy<(string md5, string sha2)> test_beatmap_hash = new Lazy<(string md5, string sha2)>(() =>
+ {
+ using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data)))
+ return (stream.ComputeMD5Hash(), stream.ComputeSHA2Hash());
+ });
+
private const string test_beatmap_data = @"osu file format v14
[General]
diff --git a/osu.Game/Users/Drawables/DrawableAvatar.cs b/osu.Game/Users/Drawables/DrawableAvatar.cs
index 09750c5bfe..42d2dbb1c6 100644
--- a/osu.Game/Users/Drawables/DrawableAvatar.cs
+++ b/osu.Game/Users/Drawables/DrawableAvatar.cs
@@ -43,7 +43,7 @@ namespace osu.Game.Users.Drawables
Texture texture = null;
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
- if (texture == null) texture = textures.Get(@"Online/avatar-guest");
+ texture ??= textures.Get(@"Online/avatar-guest");
ClickableArea clickableArea;
Add(clickableArea = new ClickableArea
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index 4d6358575b..1d3bafbfd6 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -20,13 +20,13 @@
-
+
-
+
-
+
diff --git a/osu.iOS.props b/osu.iOS.props
index 6b55fa51ff..ad7850599b 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -70,17 +70,17 @@
-
+
-
+
-
+
diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings
index b9fc3de734..85d5fce29a 100644
--- a/osu.sln.DotSettings
+++ b/osu.sln.DotSettings
@@ -60,6 +60,7 @@
WARNING
WARNING
WARNING
+ WARNING
WARNING
WARNING
WARNING
@@ -105,6 +106,8 @@
HINT
WARNING
WARNING
+ WARNING
+ WARNING
WARNING
WARNING
WARNING
@@ -138,6 +141,7 @@
WARNING
WARNING
WARNING
+ WARNING
WARNING
WARNING
WARNING
@@ -196,6 +200,7 @@
WARNING
WARNING
HINT
+ WARNING
DO_NOT_SHOW
DO_NOT_SHOW
DO_NOT_SHOW
@@ -222,6 +227,7 @@
WARNING
WARNING
WARNING
+ WARNING
True
WARNING