1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-03 15:04:26 +08:00

Compare commits

..

68 Commits

84 changed files with 348 additions and 290 deletions
+56 -11
View File
@@ -11,25 +11,70 @@ We are accepting bug reports (please report with as much detail as possible). Fe
# Requirements
- A desktop platform with the [.NET Core SDK 2.2](https://www.microsoft.com/net/learn/get-started) or higher installed.
- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio Community Edition](https://www.visualstudio.com/) (Windows), [Visual Studio Code](https://code.visualstudio.com/) (with the C# plugin installed) or [Jetbrains Rider](https://www.jetbrains.com/rider/) (commercial).
- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio 2017+](https://visualstudio.microsoft.com/vs/), [Jetbrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
# Building and running
# Running osu!
If you are not interested in developing the game, please head over to the [releases](https://github.com/ppy/osu/releases) to download a precompiled build with automatic updating enabled (download and run the install executable for your platform).
## Releases
Clone the repository including submodules
If you are not interested in developing the game, please head over to the [releases](https://github.com/ppy/osu/releases) to download a precompiled build with automatic updating enabled.
`git clone --recurse-submodules https://github.com/ppy/osu`
- Windows (x64) users should download and run `install.exe`.
- macOS users (10.12 "Sierra" and higher) should download and run `osu.app.zip`.
- iOS users can join the [TestFlight beta program](https://t.co/xQJmHkfC18).
Build and run
If your platform is not listed above, there is still a chance you can manually build it by following the instructions below.
- Using Visual Studio 2017, Rider or Visual Studio Code (configurations are included)
- From command line using `dotnet run --project osu.Desktop`. When building for non-development purposes, add `-c Release` to gain higher performance.
- To run with code analysis, instead use `powershell ./build.ps1` or `build.sh`. This is currently only supported under windows due to [resharper cli shortcomings](https://youtrack.jetbrains.com/issue/RSRP-410004). Alternative, you can install resharper or use rider to get inline support in your IDE of choice.
## Downloading the source code
Note: If you run from command line under linux, you will need to prefix the output folder to your `LD_LIBRARY_PATH`. See `.vscode/launch.json` for an example
Clone the repository **including submodules**:
If you run into issues building you may need to restore nuget packages (commonly via `dotnet restore`). Visual Studio Code users must run `Restore` task from debug tab before attempt to build.
```shell
git clone --recurse-submodules https://github.com/ppy/osu
cd osu
```
> If you forgot the `--recurse-submodules` option, run this command inside the `osu` directory:
>
> `git submodule update --init --recursive`
To update the source code to the latest commit, run the following command inside the `osu` directory:
```shell
git pull --recurse-submodules
```
## Building
Build configurations for the recommended IDEs (listed above) are included. You should use the provided Build/Run functionality of your IDE to get things going. When testing or building new components, it's highly encouraged you use the `VisualTests` project/configuration. More information on this provided below.
> Visual Studio Code users must run the `Restore` task before any build attempt.
You can also build and run osu! from the command-line with a single command:
```shell
dotnet run --project osu.Desktop
```
If you are not interested in debugging osu!, you can add `-c Release` to gain performance. In this case, you must replace `Debug` with `Release` in any commands mentioned in this document.
If the build fails, try to restore nuget packages with `dotnet restore`.
### A note for Linux users
On Linux, the environment variable `LD_LIBRARY_PATH` must point to the build directory, located at `osu.Desktop/bin/Debug/$NETCORE_VERSION`.
`$NETCORE_VERSION` is the version of .NET Core SDK. You can have it with `grep TargetFramework osu.Desktop/osu.Desktop.csproj | sed -r 's/.*>(.*)<\/.*/\1/'`.
For example, you can run osu! with the following command:
```shell
LD_LIBRARY_PATH="$(pwd)/osu.Desktop/bin/Debug/netcoreapp2.2" dotnet run --project osu.Desktop
```
## Code analysis
Code analysis can be run with `powershell ./build.ps1` or `build.sh`. This is currently only supported under windows due to [resharper cli shortcomings](https://youtrack.jetbrains.com/issue/RSRP-410004). Alternative, you can install resharper or use rider to get inline support in your IDE of choice.
# Contributing
+1 -1
View File
@@ -97,7 +97,7 @@ namespace osu.Desktop
private void fileDrop(object sender, FileDropEventArgs e)
{
var filePaths = new[] { e.FileName };
var filePaths = e.FileNames;
var firstExtension = Path.GetExtension(filePaths.First());
+2 -2
View File
@@ -28,8 +28,8 @@
<ItemGroup Label="Package References">
<PackageReference Include="System.IO.Packaging" Version="4.5.0" />
<PackageReference Include="ppy.squirrel.windows" Version="1.9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.1" />
</ItemGroup>
<ItemGroup Label="Resources">
<EmbeddedResource Include="lazer.ico" />
@@ -26,7 +26,6 @@ namespace osu.Game.Rulesets.Catch.Tests
}
};
for (int i = 0; i < 512; i++)
beatmap.HitObjects.Add(new Fruit { X = 0.5f + i / 2048f * (i % 10 - 5), StartTime = i * 100, NewCombo = i % 8 == 0 });
@@ -19,7 +19,6 @@ namespace osu.Game.Rulesets.Catch.Tests
{
var beatmap = new Beatmap { BeatmapInfo = { Ruleset = ruleset.RulesetInfo } };
for (int i = 0; i < 512; i++)
if (i % 5 < 3)
beatmap.HitObjects.Add(new Fruit { X = i % 10 < 5 ? 0.02f : 0.98f, StartTime = i * 100, NewCombo = i % 8 == 0 });
@@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">
@@ -14,7 +14,6 @@ namespace osu.Game.Rulesets.Catch.Difficulty
{
public class CatchDifficultyCalculator : DifficultyCalculator
{
/// <summary>
/// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP.
/// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain.
@@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">
@@ -180,7 +180,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
foreach (var obj in newPattern.HitObjects)
yield return obj;
}
}
@@ -53,7 +53,6 @@ namespace osu.Game.Rulesets.Mania.Difficulty
if (!calculateStrainValues(difficultyHitObjects, timeRate))
return new DifficultyAttributes(mods, 0);
double starRating = calculateDifficulty(difficultyHitObjects, timeRate) * star_scaling_factor;
return new ManiaDifficultyAttributes(mods, starRating)
@@ -3,14 +3,14 @@
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.Beatmaps;
namespace osu.Game.Rulesets.Mania.Mods
{
public class ManiaModMirror : Mod, IApplicableToRulesetContainer<ManiaHitObject>
public class ManiaModMirror : Mod, IApplicableToBeatmap<ManiaHitObject>
{
public override string Name => "Mirror";
public override string Acronym => "MR";
@@ -18,11 +18,11 @@ namespace osu.Game.Rulesets.Mania.Mods
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
public void ApplyToRulesetContainer(RulesetContainer<ManiaHitObject> rulesetContainer)
public void ApplyToBeatmap(Beatmap<ManiaHitObject> beatmap)
{
var availableColumns = ((ManiaRulesetContainer)rulesetContainer).Beatmap.TotalColumns;
var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns;
rulesetContainer.Objects.OfType<ManiaHitObject>().ForEach(h => h.Column = availableColumns - 1 - h.Column);
beatmap.HitObjects.OfType<ManiaHitObject>().ForEach(h => h.Column = availableColumns - 1 - h.Column);
}
}
}
@@ -4,15 +4,15 @@
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.MathUtils;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Mania.Mods
{
public class ManiaModRandom : Mod, IApplicableToRulesetContainer<ManiaHitObject>
public class ManiaModRandom : Mod, IApplicableToBeatmap<ManiaHitObject>
{
public override string Name => "Random";
public override string Acronym => "RD";
@@ -21,12 +21,12 @@ namespace osu.Game.Rulesets.Mania.Mods
public override string Description => @"Shuffle around the keys!";
public override double ScoreMultiplier => 1;
public void ApplyToRulesetContainer(RulesetContainer<ManiaHitObject> rulesetContainer)
public void ApplyToBeatmap(Beatmap<ManiaHitObject> beatmap)
{
var availableColumns = ((ManiaRulesetContainer)rulesetContainer).Beatmap.TotalColumns;
var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns;
var shuffledColumns = Enumerable.Range(0, availableColumns).OrderBy(item => RNG.Next()).ToList();
rulesetContainer.Objects.OfType<ManiaHitObject>().ForEach(h => h.Column = shuffledColumns[h.Column]);
beatmap.HitObjects.OfType<ManiaHitObject>().ForEach(h => h.Column = shuffledColumns[h.Column]);
}
}
}
@@ -21,7 +21,6 @@ namespace osu.Game.Rulesets.Mania.Objects
private readonly int beatmapColumnCount;
private readonly double endTime;
private readonly double[] heldUntil;
@@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">
@@ -57,6 +57,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty
s.Process(h);
}
// The peak strain will not be saved for the last section in the above loop
foreach (Skill s in skills)
s.SaveCurrentPeak();
double aimRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier;
double speedRating = Math.Sqrt(skills[1].DifficultyValue()) * difficulty_multiplier;
double starRating = aimRating + speedRating + Math.Abs(aimRating - speedRating) / 2;
@@ -101,7 +101,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
break;
}
float aimRotation = MathHelper.RadiansToDegrees((float)Math.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
while (Math.Abs(aimRotation - Rotation) > 180)
aimRotation += aimRotation < Rotation ? 360 : -360;
@@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, IBindableBeatmap beatmap)
private void load(OsuConfigManager config, IBindable<WorkingBeatmap> beatmap)
{
InternalChild = expandTarget = new Container
{
@@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">
@@ -149,7 +149,6 @@ namespace osu.Game.Tests.Beatmaps.Formats
using (var stream = Resource.OpenResource(filename))
using (var sr = new StreamReader(stream))
{
var legacyDecoded = new LegacyBeatmapDecoder { ApplyOffsets = false }.Decode(sr);
using (var ms = new MemoryStream())
using (var sw = new StreamWriter(ms))
@@ -40,7 +40,6 @@ namespace osu.Game.Tests.Visual
typeof(DrawableCarouselBeatmapSet),
};
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>();
@@ -55,7 +55,6 @@ namespace osu.Game.Tests.Visual
AddStep("resize to normal", () => container.ResizeWidthTo(0.8f, 300));
AddStep("online scores", () => scoresContainer.Beatmap = new BeatmapInfo { OnlineBeatmapID = 75, Ruleset = new OsuRuleset().RulesetInfo });
scores = new[]
{
new APIScoreInfo
@@ -16,7 +16,6 @@ namespace osu.Game.Tests.Visual
public TestCaseBreadcrumbs()
{
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
{
Anchor = Anchor.Centre,
@@ -85,7 +85,7 @@ namespace osu.Game.Tests.Visual
}
[BackgroundDependencyLoader]
private void load(IAdjustableClock adjustableClock, IBindableBeatmap beatmap)
private void load(IAdjustableClock adjustableClock, IBindable<WorkingBeatmap> beatmap)
{
this.adjustableClock = adjustableClock;
this.beatmap.BindTo(beatmap);
@@ -39,7 +39,6 @@ namespace osu.Game.Tests.Visual
},
};
AddStep("Add random", () =>
{
Key key = (Key)((int)Key.A + RNG.Next(26));
@@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual
this.room = room;
}
protected override IEnumerable<IResultPageInfo> CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap, room) };
protected override IEnumerable<IResultPageInfo> CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap.Value, room) };
}
private class TestRoomLeaderboardPageInfo : RoomLeaderboardPageInfo
@@ -57,5 +57,4 @@ namespace osu.Game.Tests.Visual
}
}
}
}
@@ -7,7 +7,7 @@ using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
{
[TestFixture]
public class TestCaseSkipButton : OsuTestCase
public class TestCaseSkipOverlay : OsuTestCase
{
protected override void LoadComplete()
{
+1 -1
View File
@@ -5,7 +5,7 @@
<PackageReference Include="DeepEqual" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">
+2 -5
View File
@@ -12,9 +12,9 @@ namespace osu.Game.Beatmaps
{
/// <summary>
/// A <see cref="Bindable{WorkingBeatmap}"/> for the <see cref="OsuGame"/> beatmap.
/// This should be used sparingly in-favour of <see cref="IBindableBeatmap"/>.
/// This should be used sparingly in-favour of <see cref="IBindable<WorkingBeatmap>"/>.
/// </summary>
public abstract class BindableBeatmap : NonNullableBindable<WorkingBeatmap>, IBindableBeatmap
public abstract class BindableBeatmap : NonNullableBindable<WorkingBeatmap>
{
private AudioManager audioManager;
private WorkingBeatmap lastBeatmap;
@@ -62,9 +62,6 @@ namespace osu.Game.Beatmaps
lastBeatmap = beatmap;
}
[NotNull]
IBindableBeatmap IBindableBeatmap.GetBoundCopy() => GetBoundCopy();
/// <summary>
/// Retrieve a new <see cref="BindableBeatmap"/> instance weakly bound to this <see cref="BindableBeatmap"/>.
/// If you are further binding to events of the retrieved <see cref="BindableBeatmap"/>, ensure a local reference is held.
-19
View File
@@ -1,19 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Configuration;
namespace osu.Game.Beatmaps
{
/// <summary>
/// Read-only interface for the <see cref="OsuGame"/> beatmap.
/// </summary>
public interface IBindableBeatmap : IBindable<WorkingBeatmap>
{
/// <summary>
/// Retrieve a new <see cref="IBindableBeatmap"/> instance weakly bound to this <see cref="IBindableBeatmap"/>.
/// If you are further binding to events of the retrieved <see cref="IBindableBeatmap"/>, ensure a local reference is held.
/// </summary>
IBindableBeatmap GetBoundCopy();
}
}
@@ -74,7 +74,7 @@ namespace osu.Game.Graphics.Containers
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap)
private void load(IBindable<WorkingBeatmap> beatmap)
{
Beatmap.BindTo(beatmap);
}
@@ -28,6 +28,8 @@ namespace osu.Game.Graphics.Containers
private readonly Container content;
protected override Container<Drawable> Content => content;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
private readonly Container sizableContainer;
private Drawable backgroundLayer;
@@ -41,7 +43,7 @@ namespace osu.Game.Graphics.Containers
this.targetMode = targetMode;
RelativeSizeAxes = Axes.Both;
InternalChild = sizableContainer = new Container
InternalChild = sizableContainer = new AlwaysInputContainer
{
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
@@ -55,6 +57,8 @@ namespace osu.Game.Graphics.Containers
private readonly bool applyUIScale;
private Bindable<float> uiScale;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public ScalingDrawSizePreservingFillContainer(bool applyUIScale)
{
this.applyUIScale = applyUIScale;
@@ -143,5 +147,15 @@ namespace osu.Game.Graphics.Containers
sizableContainer.MoveTo(targetPosition, 500, Easing.OutQuart);
sizableContainer.ResizeTo(targetSize, 500, Easing.OutQuart).OnComplete(_ => { sizableContainer.Masking = requiresMasking; });
}
private class AlwaysInputContainer : Container
{
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public AlwaysInputContainer()
{
RelativeSizeAxes = Axes.Both;
}
}
}
}
@@ -92,6 +92,12 @@ namespace osu.Game.Graphics.UserInterface
AccentColour = colours.Pink;
}
protected override void LoadComplete()
{
updateTooltipText(Current.Value);
base.LoadComplete();
}
protected override bool OnHover(HoverEvent e)
{
Nub.Glowing = true;
@@ -160,7 +160,6 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.BottomLeft,
Text = (value as IHasDescription)?.Description ?? (value as Enum)?.GetDescription() ?? value.ToString(),
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},
Bar = new Box
{
@@ -173,6 +172,8 @@ namespace osu.Game.Graphics.UserInterface
},
new HoverClickSounds()
};
Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true);
}
protected override void OnActivated() => fadeActive();
@@ -46,7 +46,6 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.BottomLeft,
Text = (value as Enum)?.GetDescription() ?? value.ToString(),
TextSize = 14,
Font = @"Exo2.0-Bold",
},
box = new Box
{
@@ -59,6 +58,8 @@ namespace osu.Game.Graphics.UserInterface
},
new HoverClickSounds()
};
Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true);
}
[BackgroundDependencyLoader]
-1
View File
@@ -41,7 +41,6 @@ namespace osu.Game.Online.Chat
/// </summary>
private readonly List<LocalEchoMessage> pendingMessages = new List<LocalEchoMessage>();
/// <summary>
/// An event that fires when new messages arrived.
/// </summary>
+2 -35
View File
@@ -102,7 +102,7 @@ namespace osu.Game
private OnScreenDisplay onscreenDisplay;
private Bindable<int> configRuleset;
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly LeasableBindable<RulesetInfo> ruleset = new LeasableBindable<RulesetInfo>(new Bindable<RulesetInfo>());
private Bindable<int> configSkin;
@@ -172,6 +172,7 @@ namespace osu.Game
dependencies.CacheAs(ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(ruleset);
dependencies.CacheAs<IMutableBindable<RulesetInfo>>(ruleset);
// bind config int to database RulesetInfo
configRuleset = LocalConfig.GetBindable<int>(OsuSetting.Ruleset);
@@ -688,44 +689,10 @@ namespace osu.Game
{
base.UpdateAfterChildren();
// we only want to apply these restrictions when we are inside a screen stack.
// the use case for not applying is in visual/unit tests.
bool applyBeatmapRulesetRestrictions = !currentScreen?.AllowBeatmapRulesetChange ?? false;
ruleset.Disabled = applyBeatmapRulesetRestrictions;
Beatmap.Disabled = applyBeatmapRulesetRestrictions;
screenContainer.Padding = new MarginPadding { Top = ToolbarOffset };
MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false;
}
/// <summary>
/// Sets <see cref="Beatmap"/> while ignoring any beatmap.
/// </summary>
/// <param name="beatmap">The beatmap to set.</param>
public void ForcefullySetBeatmap(WorkingBeatmap beatmap)
{
var beatmapDisabled = Beatmap.Disabled;
Beatmap.Disabled = false;
Beatmap.Value = beatmap;
Beatmap.Disabled = beatmapDisabled;
}
/// <summary>
/// Sets <see cref="Ruleset"/> while ignoring any ruleset restrictions.
/// </summary>
/// <param name="beatmap">The beatmap to set.</param>
public void ForcefullySetRuleset(RulesetInfo ruleset)
{
var rulesetDisabled = this.ruleset.Disabled;
this.ruleset.Disabled = false;
this.ruleset.Value = ruleset;
this.ruleset.Disabled = rulesetDisabled;
}
protected virtual void ScreenChanged(OsuScreen current, Screen newScreen)
{
currentScreen = (OsuScreen)newScreen;
+8 -5
View File
@@ -69,8 +69,9 @@ namespace osu.Game
protected override Container<Drawable> Content => content;
private OsuBindableBeatmap beatmap;
protected BindableBeatmap Beatmap => beatmap;
private LeasableBindable<WorkingBeatmap> beatmap;
protected IMutableBindable<WorkingBeatmap> Beatmap => beatmap;
private Bindable<bool> fpsDisplayVisible;
@@ -155,7 +156,6 @@ namespace osu.Game
dependencies.CacheAs<IAPIProvider>(API);
var defaultBeatmap = new DummyWorkingBeatmap(this);
beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio);
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage));
@@ -174,8 +174,11 @@ namespace osu.Game
// this adds a global reduction of track volume for the time being.
Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8));
dependencies.CacheAs<BindableBeatmap>(beatmap);
dependencies.CacheAs<IBindableBeatmap>(beatmap);
beatmap = new LeasableBindable<WorkingBeatmap>(new OsuBindableBeatmap(defaultBeatmap, Audio));
dependencies.CacheAs<IBindable<WorkingBeatmap>>(beatmap);
dependencies.CacheAs<IMutableBindable<WorkingBeatmap>>(beatmap);
dependencies.CacheAs(beatmap);
FileStore.Cleanup();
@@ -77,7 +77,6 @@ namespace osu.Game.Overlays.Chat.Tabs
CloseButton.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
}
protected override void FadeInactive()
{
base.FadeInactive();
@@ -18,7 +18,6 @@ namespace osu.Game.Overlays.KeyBinding
Add(new InGameKeyBindingsSubsection(manager));
}
private class DefaultBindingsSubsection : KeyBindingsSubsection
{
protected override string Header => string.Empty;
@@ -176,7 +176,6 @@ namespace osu.Game.Overlays.Mods
section.DeselectTypes(modTypes, immediate);
}
private SampleChannel sampleOn, sampleOff;
private void modButtonPressed(Mod selectedMod)
+1 -1
View File
@@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Music
}
[BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps, IBindableBeatmap beatmap)
private void load(BeatmapManager beatmaps, IBindable<WorkingBeatmap> beatmap)
{
beatmaps.GetAllUsableBeatmapSets().ForEach(b => addBeatmapSet(b, false, false));
beatmaps.ItemAdded += addBeatmapSet;
+1 -1
View File
@@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Music
private PlaylistList list;
[BackgroundDependencyLoader]
private void load(OsuColour colours, BindableBeatmap beatmap, BeatmapManager beatmaps)
private void load(OsuColour colours, IMutableBindable<WorkingBeatmap> beatmap, BeatmapManager beatmaps)
{
this.beatmap.BindTo(beatmap);
this.beatmaps = beatmaps;
+1 -1
View File
@@ -66,7 +66,7 @@ namespace osu.Game.Overlays
}
[BackgroundDependencyLoader]
private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours)
private void load(IMutableBindable<WorkingBeatmap> beatmap, BeatmapManager beatmaps, OsuColour colours)
{
this.beatmap.BindTo(beatmap);
this.beatmaps = beatmaps;
@@ -49,7 +49,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
Api.Queue(request);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
@@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
@@ -78,66 +77,15 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private class SensitivitySetting : SettingsSlider<double, SensitivitySlider>
{
public override Bindable<double> Bindable
{
get { return ((SensitivitySlider)Control).Sensitivity; }
set
{
BindableDouble doubleValue = (BindableDouble)value;
// create a second layer of bindable so we can only handle state changes when not being dragged.
((SensitivitySlider)Control).Sensitivity = doubleValue;
// this bindable will still act as the "interactive" bindable displayed during a drag.
base.Bindable = new BindableDouble(doubleValue.Value)
{
Default = doubleValue.Default,
MinValue = doubleValue.MinValue,
MaxValue = doubleValue.MaxValue
};
// one-way binding to update the sliderbar with changes from external actions.
doubleValue.DisabledChanged += disabled => base.Bindable.Disabled = disabled;
doubleValue.ValueChanged += newValue => base.Bindable.Value = newValue;
}
}
public SensitivitySetting()
{
KeyboardStep = 0.01f;
TransferValueOnCommit = true;
}
}
private class SensitivitySlider : OsuSliderBar<double>
{
public Bindable<double> Sensitivity;
public SensitivitySlider()
{
Current.ValueChanged += newValue =>
{
if (!isDragging && Sensitivity != null)
Sensitivity.Value = newValue;
};
}
private bool isDragging;
protected override bool OnDragStart(DragStartEvent e)
{
isDragging = true;
return base.OnDragStart(e);
}
protected override bool OnDragEnd(DragEndEvent e)
{
isDragging = false;
Current.TriggerChange();
return base.OnDragEnd(e);
}
public override string TooltipText => Current.Disabled ? "Enable raw input to adjust sensitivity" : Current.Value.ToString(@"0.##x");
}
}
@@ -68,7 +68,7 @@ namespace osu.Game.Overlays.Toolbar
}
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets, Bindable<RulesetInfo> parentRuleset)
private void load(RulesetStore rulesets, IMutableBindable<RulesetInfo> parentRuleset)
{
this.rulesets = rulesets;
foreach (var r in rulesets.AvailableRulesets)
+1 -1
View File
@@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Edit
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap, IFrameBasedClock framedClock)
private void load(IBindable<WorkingBeatmap> beatmap, IFrameBasedClock framedClock)
{
Beatmap.BindTo(beatmap);
+1 -1
View File
@@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Edit
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap, IAdjustableClock clock)
private void load(IBindable<WorkingBeatmap> beatmap, IAdjustableClock clock)
{
this.beatmap.BindTo(beatmap);
@@ -124,7 +124,6 @@ namespace osu.Game.Rulesets.Objects.Legacy
// osu-stable treated the first span of the slider as a repeat, but no repeats are happening
repeatCount = Math.Max(0, repeatCount - 1);
if (split.Length > 7)
length = Convert.ToDouble(split[7], CultureInfo.InvariantCulture);
+1 -1
View File
@@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.UI
private WorkingBeatmap beatmap;
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap)
private void load(IBindable<WorkingBeatmap> beatmap)
{
this.beatmap = beatmap.Value;
}
@@ -2,10 +2,14 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Online.API;
using osu.Game.Skinning;
using osu.Game.Users;
namespace osu.Game.Screens.Backgrounds
{
@@ -16,11 +20,21 @@ namespace osu.Game.Screens.Backgrounds
private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}";
private Bindable<User> user;
private Bindable<Skin> skin;
[BackgroundDependencyLoader]
private void load()
private void load(IAPIProvider api, SkinManager skinManager)
{
user = api.LocalUser.GetBoundCopy();
skin = skinManager.CurrentSkin.GetBoundCopy();
user.ValueChanged += _ => Next();
skin.ValueChanged += _ => Next();
currentDisplay = RNG.Next(0, background_count);
display(new Background(backgroundName));
Next();
}
private void display(Background newBackground)
@@ -39,8 +53,33 @@ namespace osu.Game.Screens.Backgrounds
nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() =>
{
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
Background background;
if (user.Value?.IsSupporter ?? false)
background = new SkinnedBackground(skin.Value, backgroundName);
else
background = new Background(backgroundName);
background.Depth = currentDisplay;
LoadComponentAsync(background, display);
}, 100);
}
private class SkinnedBackground : Background
{
private readonly Skin skin;
public SkinnedBackground(Skin skin, string fallbackTextureName) : base(fallbackTextureName)
{
this.skin = skin;
}
[BackgroundDependencyLoader]
private void load()
{
Sprite.Texture = skin.GetTexture("menu-background") ?? Sprite.Texture;
}
}
}
}
@@ -42,7 +42,7 @@ namespace osu.Game.Screens.Edit.Components
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap, OsuColour colours)
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours)
{
Beatmap.BindTo(beatmap);
background.Colour = colours.Gray1;
@@ -17,7 +17,6 @@ namespace osu.Game.Screens.Edit.Components
public TimeInfoContainer()
{
Children = new Drawable[]
{
trackTimer = new OsuSpriteText
@@ -32,7 +32,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap)
private void load(IBindable<WorkingBeatmap> beatmap)
{
Beatmap.BindTo(beatmap);
}
@@ -32,7 +32,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private WaveformGraph waveform;
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap, IAdjustableClock adjustableClock, OsuColour colours)
private void load(IBindable<WorkingBeatmap> beatmap, IAdjustableClock adjustableClock, OsuColour colours)
{
this.adjustableClock = adjustableClock;
+2 -1
View File
@@ -29,7 +29,8 @@ namespace osu.Game.Screens.Edit
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override bool HideOverlaysOnEnter => true;
public override bool AllowBeatmapRulesetChange => false;
protected override bool DisallowExternalBeatmapRulesetChanges => true;
private Box bottomBackground;
private Container screenContainer;
+1 -1
View File
@@ -29,7 +29,7 @@ namespace osu.Game.Screens.Edit
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap)
private void load(IBindable<WorkingBeatmap> beatmap)
{
Beatmap.BindTo(beatmap);
}
+2 -6
View File
@@ -28,8 +28,6 @@ namespace osu.Game.Screens.Menu
/// </summary>
public bool DidLoadMenu;
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
private MainMenu mainMenu;
private SampleChannel welcome;
private SampleChannel seeya;
@@ -47,10 +45,8 @@ namespace osu.Game.Screens.Menu
private WorkingBeatmap introBeatmap;
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap)
private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
{
this.beatmap.BindTo(beatmap);
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
@@ -95,7 +91,7 @@ namespace osu.Game.Screens.Menu
if (!resuming)
{
beatmap.Value = introBeatmap;
Beatmap.Value = introBeatmap;
if (menuVoice)
welcome.Play();
+2 -3
View File
@@ -3,7 +3,6 @@
using osuTK;
using osuTK.Graphics;
using osuTK.Graphics.ES30;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Batches;
@@ -75,7 +74,7 @@ namespace osu.Game.Screens.Menu
}
[BackgroundDependencyLoader]
private void load(ShaderManager shaders, IBindableBeatmap beatmap)
private void load(ShaderManager shaders, IBindable<WorkingBeatmap> beatmap)
{
this.beatmap.BindTo(beatmap);
shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
@@ -150,7 +149,7 @@ namespace osu.Game.Screens.Menu
private class VisualiserSharedData
{
public readonly LinearBatch<TexturedVertex2D> VertexBatch = new LinearBatch<TexturedVertex2D>(100 * 4, 10, PrimitiveType.Quads);
public readonly QuadBatch<TexturedVertex2D> VertexBatch = new QuadBatch<TexturedVertex2D>(100, 10);
}
private class VisualisationDrawNode : DrawNode
+1 -1
View File
@@ -42,7 +42,7 @@ namespace osu.Game.Screens.Menu
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap, OsuColour colours)
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours)
{
this.beatmap.BindTo(beatmap);
@@ -93,10 +93,14 @@ namespace osu.Game.Screens.Multi.Lounge.Components
Host.BindValueChanged(v =>
{
hostText.Clear();
hostText.AddText("hosted by ");
hostText.AddLink(v.Username, null, LinkAction.OpenUserProfile, v.Id.ToString(), "Open profile", s => s.Font = "Exo2.0-BoldItalic");
flagContainer.Clear();
flagContainer.Child = new DrawableFlag(v.Country) { RelativeSizeAxes = Axes.Both };
if (v != null)
{
hostText.AddText("hosted by ");
hostText.AddLink(v.Username, null, LinkAction.OpenUserProfile, v.Id.ToString(), "Open profile", s => s.Font = "Exo2.0-BoldItalic");
flagContainer.Child = new DrawableFlag(v.Country) { RelativeSizeAxes = Axes.Both };
}
});
ParticipantCount.BindValueChanged(v => summary.Text = $"{v:#,0}{" participant".Pluralize(v == 1)}");
@@ -266,7 +266,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private void updateParticipants()
{
var roomId = room.RoomID.Value ?? 0;
var roomId = room?.RoomID.Value ?? 0;
request?.Cancel();
@@ -297,6 +297,12 @@ namespace osu.Game.Screens.Multi.Lounge.Components
api.Queue(request);
}
protected override void Dispose(bool isDisposing)
{
request?.Cancel();
base.Dispose(isDisposing);
}
private class UserTile : CompositeDrawable, IHasTooltip
{
private readonly User user;
@@ -19,7 +19,7 @@ namespace osu.Game.Screens.Multi.Match.Components
private readonly Room room;
[Resolved]
private IBindableBeatmap gameBeatmap { get; set; }
private IBindable<WorkingBeatmap> gameBeatmap { get; set; }
[Resolved]
private BeatmapManager beatmaps { get; set; }
+22 -7
View File
@@ -20,7 +20,8 @@ namespace osu.Game.Screens.Multi.Match
{
public class MatchSubScreen : MultiplayerSubScreen
{
public override bool AllowBeatmapRulesetChange => false;
protected override bool DisallowExternalBeatmapRulesetChanges => true;
public override string Title => room.RoomID.Value == null ? "New room" : room.Name.Value;
public override string ShortTitle => "room";
@@ -51,6 +52,8 @@ namespace osu.Game.Screens.Multi.Match
MatchChatDisplay chat;
Components.Header header;
Info info;
GridContainer bottomRow;
MatchSettingsOverlay settings;
Children = new Drawable[]
@@ -61,10 +64,10 @@ namespace osu.Game.Screens.Multi.Match
Content = new[]
{
new Drawable[] { header = new Components.Header(room) { Depth = -1 } },
new Drawable[] { new Info(room) { OnStart = onStart } },
new Drawable[] { info = new Info(room) { OnStart = onStart } },
new Drawable[]
{
new GridContainer
bottomRow = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Content = new[]
@@ -106,13 +109,25 @@ namespace osu.Game.Screens.Multi.Match
},
};
header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect { Selected = addPlaylistItem });
header.OnRequestSelectBeatmap = () =>
{
Push(new MatchSongSelect { Selected = addPlaylistItem });
};
header.Tabs.Current.ValueChanged += t =>
{
const float fade_duration = 500;
if (t is SettingsMatchPage)
{
settings.Show();
info.FadeOut(fade_duration, Easing.OutQuint);
bottomRow.FadeOut(fade_duration, Easing.OutQuint);
}
else
{
settings.Hide();
info.FadeIn(fade_duration, Easing.OutQuint);
bottomRow.FadeIn(fade_duration, Easing.OutQuint);
}
};
chat.Exit += Exit;
@@ -143,7 +158,7 @@ namespace osu.Game.Screens.Multi.Match
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID);
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
}
private void setRuleset(RulesetInfo ruleset)
@@ -151,7 +166,7 @@ namespace osu.Game.Screens.Multi.Match
if (ruleset == null)
return;
game?.ForcefullySetRuleset(ruleset);
Ruleset.Value = ruleset;
}
private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() =>
@@ -166,7 +181,7 @@ namespace osu.Game.Screens.Multi.Match
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == bindings.CurrentBeatmap.Value.OnlineBeatmapID);
if (localBeatmap != null)
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
});
private void addPlaylistItem(PlaylistItem item)
-2
View File
@@ -28,8 +28,6 @@ namespace osu.Game.Screens.Multi
{
private readonly MultiplayerWaveContainer waves;
public override bool AllowBeatmapRulesetChange => currentSubScreen?.AllowBeatmapRulesetChange ?? base.AllowBeatmapRulesetChange;
private readonly OsuButton createButton;
private readonly LoungeSubScreen loungeSubScreen;
@@ -22,9 +22,9 @@ namespace osu.Game.Screens.Multi.Ranking
protected override IEnumerable<IResultPageInfo> CreateResultPages() => new IResultPageInfo[]
{
new ScoreOverviewPageInfo(Score, Beatmap),
new LocalLeaderboardPageInfo(Score, Beatmap),
new RoomLeaderboardPageInfo(Score, Beatmap, room),
new ScoreOverviewPageInfo(Score, Beatmap.Value),
new LocalLeaderboardPageInfo(Score, Beatmap.Value),
new RoomLeaderboardPageInfo(Score, Beatmap.Value, room),
};
}
}
+13 -16
View File
@@ -53,23 +53,20 @@ namespace osu.Game.Screens.Multi
Duration.UnbindFrom(room.Duration);
}
room = value;
room = value ?? new Room();
if (room != null)
{
RoomID.BindTo(room.RoomID);
Name.BindTo(room.Name);
Host.BindTo(room.Host);
Status.BindTo(room.Status);
Type.BindTo(room.Type);
Playlist.BindTo(room.Playlist);
Participants.BindTo(room.Participants);
ParticipantCount.BindTo(room.ParticipantCount);
MaxParticipants.BindTo(room.MaxParticipants);
EndDate.BindTo(room.EndDate);
Availability.BindTo(room.Availability);
Duration.BindTo(room.Duration);
}
RoomID.BindTo(room.RoomID);
Name.BindTo(room.Name);
Host.BindTo(room.Host);
Status.BindTo(room.Status);
Type.BindTo(room.Type);
Playlist.BindTo(room.Playlist);
Participants.BindTo(room.Participants);
ParticipantCount.BindTo(room.ParticipantCount);
MaxParticipants.BindTo(room.MaxParticipants);
EndDate.BindTo(room.EndDate);
Availability.BindTo(room.Availability);
Duration.BindTo(room.Duration);
}
}
+50 -14
View File
@@ -65,28 +65,54 @@ namespace osu.Game.Screens
private OsuLogo logo;
/// <summary>
/// Whether the beatmap or ruleset should be allowed to be changed by the user or game.
/// Used to mark exclusive areas where this is strongly prohibited, like gameplay.
/// </summary>
public virtual bool AllowBeatmapRulesetChange => true;
protected readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
protected virtual float BackgroundParallaxAmount => 1;
private ParallaxContainer backgroundParallaxContainer;
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
protected IMutableBindable<WorkingBeatmap> Beatmap;
protected IMutableBindable<RulesetInfo> Ruleset;
/// <summary>
/// Disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children).
/// </summary>
protected virtual bool DisallowExternalBeatmapRulesetChanges => false;
private SampleChannel sampleExit;
private bool leaseOwner;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
if (DisallowExternalBeatmapRulesetChanges)
{
Beatmap = dependencies.Get<LeasedBindable<WorkingBeatmap>>()?.GetBoundCopy();
if (Beatmap == null)
{
leaseOwner = true;
dependencies.Cache(Beatmap = dependencies.Get<LeasableBindable<WorkingBeatmap>>().BeginLease(true));
}
Ruleset = dependencies.Get<LeasedBindable<RulesetInfo>>()?.GetBoundCopy();
if (Ruleset == null)
{
leaseOwner = true;
dependencies.Cache(Ruleset = dependencies.Get<LeasableBindable<RulesetInfo>>().BeginLease(true));
}
}
else
{
Beatmap = dependencies.Get<LeasableBindable<WorkingBeatmap>>().GetBoundCopy();
Ruleset = dependencies.Get<LeasableBindable<RulesetInfo>>().GetBoundCopy();
}
return dependencies;
}
[BackgroundDependencyLoader(true)]
private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable<RulesetInfo> ruleset)
private void load(OsuGame osu, AudioManager audio)
{
Beatmap.BindTo(beatmap);
Ruleset.BindTo(ruleset);
if (osu != null)
{
OverlayActivationMode.BindTo(osu.OverlayActivationMode);
@@ -191,7 +217,17 @@ namespace osu.Game.Screens
if (base.OnExiting(next))
return true;
Beatmap.UnbindAll();
if (leaseOwner)
{
((LeasedBindable<WorkingBeatmap>)Beatmap).Return();
((LeasedBindable<RulesetInfo>)Ruleset).Return();
}
else
{
Beatmap.UnbindAll();
Ruleset.UnbindAll();
}
return false;
}
+26 -26
View File
@@ -24,8 +24,6 @@ namespace osu.Game.Screens.Play
{
private const int duration = 100;
private readonly Container content;
public readonly KeyCounterCollection KeyCounter;
public readonly RollingCounter<int> ComboCounter;
public readonly ScoreCounter ScoreCounter;
@@ -37,6 +35,7 @@ namespace osu.Game.Screens.Play
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
private Bindable<bool> showHud;
private readonly Container visibilityContainer;
private readonly BindableBool replayLoaded = new BindableBool();
private static bool hasShownNotificationOnce;
@@ -45,34 +44,35 @@ namespace osu.Game.Screens.Play
{
RelativeSizeAxes = Axes.Both;
Add(content = new Container
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true, // The hud may be hidden but certain elements may need to still be updated
Children = new Drawable[]
visibilityContainer = new Container {
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true, // The hud may be hidden but certain elements may need to still be updated
Children = new Drawable[] {
ComboCounter = CreateComboCounter(),
ScoreCounter = CreateScoreCounter(),
AccuracyCounter = CreateAccuracyCounter(),
HealthDisplay = CreateHealthDisplay(),
Progress = CreateProgress(),
ModDisplay = CreateModsContainer(),
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
}
},
new FillFlowContainer
{
ComboCounter = CreateComboCounter(),
ScoreCounter = CreateScoreCounter(),
AccuracyCounter = CreateAccuracyCounter(),
HealthDisplay = CreateHealthDisplay(),
Progress = CreateProgress(),
ModDisplay = CreateModsContainer(),
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
new FillFlowContainer
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = -new Vector2(5, TwoLayerButton.SIZE_RETRACTED.Y),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = -new Vector2(5, TwoLayerButton.SIZE_RETRACTED.Y),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
KeyCounter = CreateKeyCounter(adjustableClock as IFrameBasedClock),
HoldToQuit = CreateHoldForMenuButton(),
}
KeyCounter = CreateKeyCounter(adjustableClock as IFrameBasedClock),
HoldToQuit = CreateHoldForMenuButton(),
}
}
});
};
BindProcessor(scoreProcessor);
BindRulesetContainer(rulesetContainer);
@@ -91,7 +91,7 @@ namespace osu.Game.Screens.Play
private void load(OsuConfigManager config, NotificationOverlay notificationOverlay)
{
showHud = config.GetBindable<bool>(OsuSetting.ShowInterface);
showHud.ValueChanged += hudVisibility => content.FadeTo(hudVisibility ? 1 : 0, duration);
showHud.ValueChanged += hudVisibility => visibilityContainer.FadeTo(hudVisibility ? 1 : 0, duration);
showHud.TriggerChange();
if (!showHud && !hasShownNotificationOnce)
+2
View File
@@ -35,6 +35,8 @@ namespace osu.Game.Screens.Play
private bool hideOverlays;
protected override bool HideOverlaysOnEnter => hideOverlays;
protected override bool DisallowExternalBeatmapRulesetChanges => true;
private Task loadTask;
public PlayerLoader(Func<Player> createPlayer)
@@ -17,8 +17,6 @@ namespace osu.Game.Screens.Play
protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background;
public override bool AllowBeatmapRulesetChange => false;
protected const float BACKGROUND_FADE_DURATION = 800;
protected float BackgroundOpacity => 1 - (float)DimLevel;
+2 -2
View File
@@ -46,10 +46,10 @@ namespace osu.Game.Screens.Play
State = Visibility.Visible;
RelativePositionAxes = Axes.Both;
RelativeSizeAxes = Axes.Both;
RelativeSizeAxes = Axes.X;
Position = new Vector2(0.5f, 0.7f);
Size = new Vector2(1, 0.14f);
Size = new Vector2(1, 100);
Origin = Anchor.Centre;
}
+2 -2
View File
@@ -17,8 +17,8 @@ namespace osu.Game.Screens.Play
protected override IEnumerable<IResultPageInfo> CreateResultPages() => new IResultPageInfo[]
{
new ScoreOverviewPageInfo(Score, Beatmap),
new LocalLeaderboardPageInfo(Score, Beatmap)
new ScoreOverviewPageInfo(Score, Beatmap.Value),
new LocalLeaderboardPageInfo(Score, Beatmap.Value)
};
}
}
+1 -1
View File
@@ -32,7 +32,7 @@ namespace osu.Game.Screens.Ranking
private ResultModeTabControl modeChangeButtons;
public override bool AllowBeatmapRulesetChange => false;
protected override bool DisallowExternalBeatmapRulesetChanges => true;
protected readonly ScoreInfo Score;
@@ -101,7 +101,6 @@ namespace osu.Game.Screens.Select
private readonly Container<DrawableCarouselItem> scrollableContent;
public Bindable<bool> RightClickScrollingEnabled = new Bindable<bool>();
public Bindable<RandomSelectAlgorithm> RandomAlgorithm = new Bindable<RandomSelectAlgorithm>();
@@ -3,6 +3,7 @@
using System;
using Humanizer;
using osu.Framework.Screens;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi;
@@ -33,5 +34,21 @@ namespace osu.Game.Screens.Select
return true;
}
protected override bool OnExiting(Screen next)
{
Beatmap.Disabled = true;
Ruleset.Disabled = true;
return base.OnExiting(next);
}
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Beatmap.Disabled = false;
Ruleset.Disabled = false;
}
}
}
@@ -3,6 +3,7 @@
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Textures;
@@ -63,7 +64,7 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap, TextureStore textureStore)
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
{
var basePath = Animation.Path.ToLowerInvariant();
for (var frame = 0; frame < Animation.FrameCount; frame++)
@@ -4,6 +4,7 @@
using System.IO;
using osu.Framework.Allocation;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
@@ -28,7 +29,7 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap)
private void load(IBindable<WorkingBeatmap> beatmap)
{
// Try first with the full name, then attempt with no path
channel = beatmap.Value.Skin.GetSample(sample.Path) ?? beatmap.Value.Skin.GetSample(Path.ChangeExtension(sample.Path, null));
@@ -3,6 +3,7 @@
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
@@ -62,7 +63,7 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader]
private void load(IBindableBeatmap beatmap, TextureStore textureStore)
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
{
var spritePath = Sprite.Path.ToLowerInvariant();
var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.ToLowerInvariant() == spritePath)?.FileInfo.StoragePath;
+1 -1
View File
@@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual
beatmap.Default = new DummyWorkingBeatmap(Dependencies.Get<OsuGameBase>());
Dependencies.CacheAs<BindableBeatmap>(beatmap);
Dependencies.CacheAs<IBindableBeatmap>(beatmap);
Dependencies.CacheAs<IBindable<WorkingBeatmap>>(beatmap);
Dependencies.CacheAs(Ruleset);
Dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
-1
View File
@@ -78,6 +78,5 @@ namespace osu.Game.Users
[JsonProperty(@"country")]
public int? Country;
}
}
}
+3 -3
View File
@@ -15,10 +15,10 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Humanizer" Version="2.5.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2019.110.1" />
<PackageReference Include="ppy.osu.Framework" Version="0.0.8033" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />
+2
View File
@@ -68,6 +68,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ParameterHidesMember/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ParameterOnlyUsedForPreconditionCheck_002EGlobal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ParameterOnlyUsedForPreconditionCheck_002ELocal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleInterfaceMemberAmbiguity/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleMultipleEnumeration/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PrivateVariableCanBeMadeReadonly/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PublicConstructorInAbstractClass/@EntryIndexedValue">WARNING</s:String>
@@ -203,6 +204,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IPC/@EntryIndexedValue">IPC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LTRB/@EntryIndexedValue">LTRB</s:String>