mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:42:55 +08:00
Merge branch 'master' into mod-adaptive-speed
This commit is contained in:
commit
76d257fbe4
@ -50,7 +50,7 @@ Please make sure you have the following prerequisites:
|
|||||||
|
|
||||||
- A desktop platform with the [.NET 6.0 SDK](https://dotnet.microsoft.com/download) installed.
|
- A desktop platform with the [.NET 6.0 SDK](https://dotnet.microsoft.com/download) installed.
|
||||||
- When developing with mobile, [Xamarin](https://docs.microsoft.com/en-us/xamarin/) is required, which is shipped together with Visual Studio or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/).
|
- When developing with mobile, [Xamarin](https://docs.microsoft.com/en-us/xamarin/) is required, which is shipped together with Visual Studio or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/).
|
||||||
- When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as [Visual Studio 2019+](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
|
- When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as the latest version of [Visual Studio](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
|
||||||
- When running on Linux, please have a system-wide FFmpeg installation available to support video decoding.
|
- When running on Linux, please have a system-wide FFmpeg installation available to support video decoding.
|
||||||
|
|
||||||
### Downloading the source code
|
### Downloading the source code
|
||||||
@ -72,7 +72,7 @@ git pull
|
|||||||
|
|
||||||
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 is provided [below](#contributing).
|
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 is provided [below](#contributing).
|
||||||
|
|
||||||
- Visual Studio / Rider users should load the project via one of the platform-specific `.slnf` files, rather than the main `.sln.` This will allow access to template run configurations.
|
- Visual Studio / Rider users should load the project via one of the platform-specific `.slnf` files, rather than the main `.sln`. This will allow access to template run configurations.
|
||||||
|
|
||||||
You can also build and run *osu!* from the command-line with a single command:
|
You can also build and run *osu!* from the command-line with a single command:
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -108,10 +109,7 @@ namespace osu.Desktop
|
|||||||
presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty);
|
presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty);
|
||||||
|
|
||||||
// update ruleset
|
// update ruleset
|
||||||
int onlineID = ruleset.Value.OnlineID;
|
presence.Assets.SmallImageKey = ruleset.Value.IsLegacyRuleset() ? $"mode_{ruleset.Value.OnlineID}" : "mode_custom";
|
||||||
bool isLegacyRuleset = onlineID >= 0 && onlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID;
|
|
||||||
|
|
||||||
presence.Assets.SmallImageKey = isLegacyRuleset ? $"mode_{onlineID}" : "mode_custom";
|
|
||||||
presence.Assets.SmallImageText = ruleset.Value.Name;
|
presence.Assets.SmallImageText = ruleset.Value.Name;
|
||||||
|
|
||||||
client.SetPresence(presence);
|
client.SetPresence(presence);
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string scrollSpeed = ScrollSpeed.IsDefault ? string.Empty : $"Scroll x{ScrollSpeed.Value:N1}";
|
string scrollSpeed = ScrollSpeed.IsDefault ? string.Empty : $"Scroll x{ScrollSpeed.Value:N2}";
|
||||||
|
|
||||||
return string.Join(", ", new[]
|
return string.Join(", ", new[]
|
||||||
{
|
{
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
@ -18,6 +20,33 @@ namespace osu.Game.Tests.Database
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class RealmSubscriptionRegistrationTests : RealmTest
|
public class RealmSubscriptionRegistrationTests : RealmTest
|
||||||
{
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestSubscriptionWithAsyncWrite()
|
||||||
|
{
|
||||||
|
ChangeSet? lastChanges = null;
|
||||||
|
|
||||||
|
RunTestWithRealm((realm, _) =>
|
||||||
|
{
|
||||||
|
var registration = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>(), onChanged);
|
||||||
|
|
||||||
|
realm.Run(r => r.Refresh());
|
||||||
|
|
||||||
|
// Without forcing the write onto its own thread, realm will internally run the operation synchronously, which can cause a deadlock with `WaitSafely`.
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await realm.WriteAsync(r => r.Add(TestResources.CreateTestBeatmapSetInfo()));
|
||||||
|
}).WaitSafely();
|
||||||
|
|
||||||
|
realm.Run(r => r.Refresh());
|
||||||
|
|
||||||
|
Assert.That(lastChanges?.InsertedIndices, Has.One.Items);
|
||||||
|
|
||||||
|
registration.Dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
void onChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet? changes, Exception error) => lastChanges = changes;
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSubscriptionWithContextLoss()
|
public void TestSubscriptionWithContextLoss()
|
||||||
{
|
{
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Testing;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.Menus;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editing
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
{
|
{
|
||||||
@ -22,7 +20,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("switch between all screens at once", () =>
|
AddStep("switch between all screens at once", () =>
|
||||||
{
|
{
|
||||||
foreach (var screen in Enum.GetValues(typeof(EditorScreenMode)).Cast<EditorScreenMode>())
|
foreach (var screen in Enum.GetValues(typeof(EditorScreenMode)).Cast<EditorScreenMode>())
|
||||||
Editor.ChildrenOfType<EditorMenuBar>().Single().Mode.Value = screen;
|
Editor.Mode.Value = screen;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
|
using osu.Game.Tests.Visual.Ranking;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
|
{
|
||||||
|
public class TestSceneBeatmapOffsetControl : OsuTestScene
|
||||||
|
{
|
||||||
|
private BeatmapOffsetControl offsetControl;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("Create control", () =>
|
||||||
|
{
|
||||||
|
Child = new PlayerSettingsGroup("Some settings")
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
offsetControl = new BeatmapOffsetControl()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTooShortToDisplay()
|
||||||
|
{
|
||||||
|
AddStep("Set short reference score", () =>
|
||||||
|
{
|
||||||
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||||
|
{
|
||||||
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(0, 2)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDisplay()
|
||||||
|
{
|
||||||
|
const double average_error = -4.5;
|
||||||
|
|
||||||
|
AddAssert("Offset is neutral", () => offsetControl.Current.Value == 0);
|
||||||
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
AddStep("Set reference score", () =>
|
||||||
|
{
|
||||||
|
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||||
|
{
|
||||||
|
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("Has calibration button", () => offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
AddStep("Press button", () => offsetControl.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
||||||
|
AddAssert("Offset is adjusted", () => offsetControl.Current.Value == -average_error);
|
||||||
|
|
||||||
|
AddAssert("Button is disabled", () => !offsetControl.ChildrenOfType<SettingsButton>().Single().Enabled.Value);
|
||||||
|
AddStep("Remove reference score", () => offsetControl.ReferenceScore.Value = null);
|
||||||
|
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -131,9 +131,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
if (!FirstFrameClockTime.HasValue)
|
if (!FirstFrameClockTime.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -71,16 +71,16 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
public static List<HitEvent> CreateDistributedHitEvents()
|
public static List<HitEvent> CreateDistributedHitEvents(double centre = 0, double range = 25)
|
||||||
{
|
{
|
||||||
var hitEvents = new List<HitEvent>();
|
var hitEvents = new List<HitEvent>();
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < range * 2; i++)
|
||||||
{
|
{
|
||||||
int count = (int)(Math.Pow(25 - Math.Abs(i - 25), 2));
|
int count = (int)(Math.Pow(range - Math.Abs(i - range), 2));
|
||||||
|
|
||||||
for (int j = 0; j < count; j++)
|
for (int j = 0; j < count; j++)
|
||||||
hitEvents.Add(new HitEvent(i - 25, HitResult.Perfect, new HitCircle(), new HitCircle(), null));
|
hitEvents.Add(new HitEvent(centre + i - range, HitResult.Perfect, new HitCircle(), new HitCircle(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
return hitEvents;
|
return hitEvents;
|
||||||
|
@ -17,10 +17,13 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
|
using osu.Game.Screens.Ranking.Expanded.Statistics;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -256,6 +259,23 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
AddAssert("download button is enabled", () => screen.ChildrenOfType<DownloadButton>().Last().Enabled.Value);
|
AddAssert("download button is enabled", () => screen.ChildrenOfType<DownloadButton>().Last().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRulesetWithNoPerformanceCalculator()
|
||||||
|
{
|
||||||
|
var ruleset = new RulesetWithNoPerformanceCalculator();
|
||||||
|
var score = TestResources.CreateTestScoreInfo(ruleset.RulesetInfo);
|
||||||
|
|
||||||
|
AddStep("load results", () => Child = new TestResultsContainer(createResultsScreen(score)));
|
||||||
|
AddUntilStep("wait for load", () => this.ChildrenOfType<ScorePanelList>().Single().AllPanelsVisible);
|
||||||
|
|
||||||
|
AddAssert("PP displayed as 0", () =>
|
||||||
|
{
|
||||||
|
var performance = this.ChildrenOfType<PerformanceStatistic>().Single();
|
||||||
|
var counter = performance.ChildrenOfType<StatisticCounter>().Single();
|
||||||
|
return counter.Current.Value == 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private TestResultsScreen createResultsScreen(ScoreInfo score = null) => new TestResultsScreen(score ?? TestResources.CreateTestScoreInfo());
|
private TestResultsScreen createResultsScreen(ScoreInfo score = null) => new TestResultsScreen(score ?? TestResources.CreateTestScoreInfo());
|
||||||
|
|
||||||
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(TestResources.CreateTestScoreInfo());
|
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(TestResources.CreateTestScoreInfo());
|
||||||
@ -367,5 +387,10 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RulesetWithNoPerformanceCalculator : OsuRuleset
|
||||||
|
{
|
||||||
|
public override PerformanceCalculator CreatePerformanceCalculator(DifficultyAttributes attributes, ScoreInfo score) => null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep(@"Network failure", () => leaderboard.SetErrorState(LeaderboardState.NetworkFailure));
|
AddStep(@"Network failure", () => leaderboard.SetErrorState(LeaderboardState.NetworkFailure));
|
||||||
AddStep(@"No supporter", () => leaderboard.SetErrorState(LeaderboardState.NotSupporter));
|
AddStep(@"No supporter", () => leaderboard.SetErrorState(LeaderboardState.NotSupporter));
|
||||||
AddStep(@"Not logged in", () => leaderboard.SetErrorState(LeaderboardState.NotLoggedIn));
|
AddStep(@"Not logged in", () => leaderboard.SetErrorState(LeaderboardState.NotLoggedIn));
|
||||||
AddStep(@"Unavailable", () => leaderboard.SetErrorState(LeaderboardState.Unavailable));
|
AddStep(@"Ruleset unavailable", () => leaderboard.SetErrorState(LeaderboardState.RulesetUnavailable));
|
||||||
|
AddStep(@"Beatmap unavailable", () => leaderboard.SetErrorState(LeaderboardState.BeatmapUnavailable));
|
||||||
AddStep(@"None selected", () => leaderboard.SetErrorState(LeaderboardState.NoneSelected));
|
AddStep(@"None selected", () => leaderboard.SetErrorState(LeaderboardState.NoneSelected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
187
osu.Game.Tests/Visual/UserInterface/TestSceneModColumn.cs
Normal file
187
osu.Game.Tests/Visual/UserInterface/TestSceneModColumn.cs
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Mods;
|
||||||
|
using osu.Game.Rulesets.Catch;
|
||||||
|
using osu.Game.Rulesets.Mania;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Taiko;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneModColumn : OsuManualInputManagerTestScene
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||||
|
|
||||||
|
[TestCase(ModType.DifficultyReduction)]
|
||||||
|
[TestCase(ModType.DifficultyIncrease)]
|
||||||
|
[TestCase(ModType.Conversion)]
|
||||||
|
[TestCase(ModType.Automation)]
|
||||||
|
[TestCase(ModType.Fun)]
|
||||||
|
public void TestBasic(ModType modType)
|
||||||
|
{
|
||||||
|
AddStep("create content", () => Child = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(30),
|
||||||
|
Child = new ModColumn(modType, false)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("change ruleset to osu!", () => Ruleset.Value = new OsuRuleset().RulesetInfo);
|
||||||
|
AddStep("change ruleset to taiko", () => Ruleset.Value = new TaikoRuleset().RulesetInfo);
|
||||||
|
AddStep("change ruleset to catch", () => Ruleset.Value = new CatchRuleset().RulesetInfo);
|
||||||
|
AddStep("change ruleset to mania", () => Ruleset.Value = new ManiaRuleset().RulesetInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultiSelection()
|
||||||
|
{
|
||||||
|
ModColumn column = null;
|
||||||
|
AddStep("create content", () => Child = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(30),
|
||||||
|
Child = column = new ModColumn(ModType.DifficultyIncrease, true)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for panel load", () => column.IsLoaded && column.ItemsLoaded);
|
||||||
|
|
||||||
|
clickToggle();
|
||||||
|
AddUntilStep("all panels selected", () => this.ChildrenOfType<ModPanel>().All(panel => panel.Active.Value));
|
||||||
|
|
||||||
|
clickToggle();
|
||||||
|
AddUntilStep("all panels deselected", () => this.ChildrenOfType<ModPanel>().All(panel => !panel.Active.Value));
|
||||||
|
|
||||||
|
AddStep("manually activate all panels", () => this.ChildrenOfType<ModPanel>().ForEach(panel => panel.Active.Value = true));
|
||||||
|
AddUntilStep("checkbox selected", () => this.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||||
|
|
||||||
|
AddStep("deselect first panel", () => this.ChildrenOfType<ModPanel>().First().Active.Value = false);
|
||||||
|
AddUntilStep("checkbox not selected", () => !this.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||||
|
|
||||||
|
void clickToggle() => AddStep("click toggle", () =>
|
||||||
|
{
|
||||||
|
var checkbox = this.ChildrenOfType<OsuCheckbox>().Single();
|
||||||
|
InputManager.MoveMouseTo(checkbox);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFiltering()
|
||||||
|
{
|
||||||
|
TestModColumn column = null;
|
||||||
|
|
||||||
|
AddStep("create content", () => Child = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(30),
|
||||||
|
Child = column = new TestModColumn(ModType.Fun, true)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("set filter", () => column.Filter = mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => !panel.Filtered.Value) == 2);
|
||||||
|
|
||||||
|
clickToggle();
|
||||||
|
AddUntilStep("wait for animation", () => !column.SelectionAnimationRunning);
|
||||||
|
AddAssert("only visible items selected", () => column.ChildrenOfType<ModPanel>().Where(panel => panel.Active.Value).All(panel => !panel.Filtered.Value));
|
||||||
|
|
||||||
|
AddStep("unset filter", () => column.Filter = null);
|
||||||
|
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => !panel.Filtered.Value));
|
||||||
|
AddAssert("checkbox not selected", () => !column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||||
|
|
||||||
|
AddStep("set filter", () => column.Filter = mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => !panel.Filtered.Value) == 2);
|
||||||
|
AddAssert("checkbox selected", () => column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||||
|
|
||||||
|
AddStep("filter out everything", () => column.Filter = _ => false);
|
||||||
|
AddUntilStep("no panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.Filtered.Value));
|
||||||
|
AddUntilStep("checkbox hidden", () => !column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
|
||||||
|
|
||||||
|
AddStep("inset filter", () => column.Filter = null);
|
||||||
|
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => !panel.Filtered.Value));
|
||||||
|
AddUntilStep("checkbox visible", () => column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
|
||||||
|
|
||||||
|
void clickToggle() => AddStep("click toggle", () =>
|
||||||
|
{
|
||||||
|
var checkbox = this.ChildrenOfType<OsuCheckbox>().Single();
|
||||||
|
InputManager.MoveMouseTo(checkbox);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestKeyboardSelection()
|
||||||
|
{
|
||||||
|
ModColumn column = null;
|
||||||
|
AddStep("create content", () => Child = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(30),
|
||||||
|
Child = column = new ModColumn(ModType.DifficultyReduction, true, new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P })
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for panel load", () => column.IsLoaded && column.ItemsLoaded);
|
||||||
|
|
||||||
|
AddStep("press W", () => InputManager.Key(Key.W));
|
||||||
|
AddAssert("NF panel selected", () => this.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.Acronym == "NF").Active.Value);
|
||||||
|
|
||||||
|
AddStep("press W again", () => InputManager.Key(Key.W));
|
||||||
|
AddAssert("NF panel deselected", () => !this.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.Acronym == "NF").Active.Value);
|
||||||
|
|
||||||
|
AddStep("set filter to NF", () => column.Filter = mod => mod.Acronym == "NF");
|
||||||
|
|
||||||
|
AddStep("press W", () => InputManager.Key(Key.W));
|
||||||
|
AddAssert("NF panel selected", () => this.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.Acronym == "NF").Active.Value);
|
||||||
|
|
||||||
|
AddStep("press W again", () => InputManager.Key(Key.W));
|
||||||
|
AddAssert("NF panel deselected", () => !this.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.Acronym == "NF").Active.Value);
|
||||||
|
|
||||||
|
AddStep("filter out everything", () => column.Filter = _ => false);
|
||||||
|
|
||||||
|
AddStep("press W", () => InputManager.Key(Key.W));
|
||||||
|
AddAssert("NF panel not selected", () => !this.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.Acronym == "NF").Active.Value);
|
||||||
|
|
||||||
|
AddStep("clear filter", () => column.Filter = null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestModColumn : ModColumn
|
||||||
|
{
|
||||||
|
public new bool SelectionAnimationRunning => base.SelectionAnimationRunning;
|
||||||
|
|
||||||
|
public TestModColumn(ModType modType, bool allowBulkSelection)
|
||||||
|
: base(modType, allowBulkSelection)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,8 @@ namespace osu.Game.Beatmaps
|
|||||||
[Backlink(nameof(ScoreInfo.BeatmapInfo))]
|
[Backlink(nameof(ScoreInfo.BeatmapInfo))]
|
||||||
public IQueryable<ScoreInfo> Scores { get; } = null!;
|
public IQueryable<ScoreInfo> Scores { get; } = null!;
|
||||||
|
|
||||||
|
public BeatmapUserSettings UserSettings { get; set; } = null!;
|
||||||
|
|
||||||
public BeatmapInfo(RulesetInfo? ruleset = null, BeatmapDifficulty? difficulty = null, BeatmapMetadata? metadata = null)
|
public BeatmapInfo(RulesetInfo? ruleset = null, BeatmapDifficulty? difficulty = null, BeatmapMetadata? metadata = null)
|
||||||
{
|
{
|
||||||
ID = Guid.NewGuid();
|
ID = Guid.NewGuid();
|
||||||
@ -51,6 +53,7 @@ namespace osu.Game.Beatmaps
|
|||||||
};
|
};
|
||||||
Difficulty = difficulty ?? new BeatmapDifficulty();
|
Difficulty = difficulty ?? new BeatmapDifficulty();
|
||||||
Metadata = metadata ?? new BeatmapMetadata();
|
Metadata = metadata ?? new BeatmapMetadata();
|
||||||
|
UserSettings = new BeatmapUserSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
|
19
osu.Game/Beatmaps/BeatmapUserSettings.cs
Normal file
19
osu.Game/Beatmaps/BeatmapUserSettings.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
using Realms;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// User settings overrides that are attached to a beatmap.
|
||||||
|
/// </summary>
|
||||||
|
public class BeatmapUserSettings : EmbeddedObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An audio offset that can be used for timing adjustments.
|
||||||
|
/// </summary>
|
||||||
|
public double Offset { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -83,7 +84,7 @@ namespace osu.Game.Beatmaps
|
|||||||
requestedUserId = api.LocalUser.Value.Id;
|
requestedUserId = api.LocalUser.Value.Id;
|
||||||
|
|
||||||
// only query API for built-in rulesets
|
// only query API for built-in rulesets
|
||||||
rulesets.AvailableRulesets.Where(ruleset => ruleset.OnlineID >= 0 && ruleset.OnlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID).ForEach(rulesetInfo =>
|
rulesets.AvailableRulesets.Where(ruleset => ruleset.IsLegacyRuleset()).ForEach(rulesetInfo =>
|
||||||
{
|
{
|
||||||
var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo);
|
var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo);
|
||||||
|
|
||||||
|
@ -240,9 +240,9 @@ namespace osu.Game.Configuration
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<Guid, string> LookupSkinName { private get; set; }
|
public Func<Guid, string> LookupSkinName { private get; set; } = _ => @"unknown";
|
||||||
|
|
||||||
public Func<GlobalAction, LocalisableString> LookupKeyBindings { get; set; }
|
public Func<GlobalAction, LocalisableString> LookupKeyBindings { get; set; } = _ => @"unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
// IMPORTANT: These are used in user configuration files.
|
// IMPORTANT: These are used in user configuration files.
|
||||||
|
@ -8,20 +8,21 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Development;
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Statistics;
|
using osu.Framework.Statistics;
|
||||||
using osu.Game.Configuration;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Models;
|
using osu.Game.Models;
|
||||||
using osu.Game.Skinning;
|
|
||||||
using osu.Game.Stores;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Stores;
|
||||||
using Realms;
|
using Realms;
|
||||||
using Realms.Exceptions;
|
using Realms.Exceptions;
|
||||||
|
|
||||||
@ -53,8 +54,9 @@ namespace osu.Game.Database
|
|||||||
/// 11 2021-11-22 Use ShortName instead of RulesetID for ruleset key bindings.
|
/// 11 2021-11-22 Use ShortName instead of RulesetID for ruleset key bindings.
|
||||||
/// 12 2021-11-24 Add Status to RealmBeatmapSet.
|
/// 12 2021-11-24 Add Status to RealmBeatmapSet.
|
||||||
/// 13 2022-01-13 Final migration of beatmaps and scores to realm (multiple new storage fields).
|
/// 13 2022-01-13 Final migration of beatmaps and scores to realm (multiple new storage fields).
|
||||||
|
/// 14 2022-03-01 Added BeatmapUserSettings to BeatmapInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int schema_version = 13;
|
private const int schema_version = 14;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
||||||
@ -85,6 +87,14 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private static readonly GlobalStatistic<int> total_subscriptions = GlobalStatistics.Get<int>(@"Realm", @"Subscriptions");
|
private static readonly GlobalStatistic<int> total_subscriptions = GlobalStatistics.Get<int>(@"Realm", @"Subscriptions");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_reads_update = GlobalStatistics.Get<int>(@"Realm", @"Reads (Update)");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_reads_async = GlobalStatistics.Get<int>(@"Realm", @"Reads (Async)");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_writes_update = GlobalStatistics.Get<int>(@"Realm", @"Writes (Update)");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_writes_async = GlobalStatistics.Get<int>(@"Realm", @"Writes (Async)");
|
||||||
|
|
||||||
private readonly object realmLock = new object();
|
private readonly object realmLock = new object();
|
||||||
|
|
||||||
private Realm? updateRealm;
|
private Realm? updateRealm;
|
||||||
@ -213,8 +223,12 @@ namespace osu.Game.Database
|
|||||||
public T Run<T>(Func<Realm, T> action)
|
public T Run<T>(Func<Realm, T> action)
|
||||||
{
|
{
|
||||||
if (ThreadSafety.IsUpdateThread)
|
if (ThreadSafety.IsUpdateThread)
|
||||||
|
{
|
||||||
|
total_reads_update.Value++;
|
||||||
return action(Realm);
|
return action(Realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
total_reads_async.Value++;
|
||||||
using (var realm = getRealmInstance())
|
using (var realm = getRealmInstance())
|
||||||
return action(realm);
|
return action(realm);
|
||||||
}
|
}
|
||||||
@ -226,9 +240,13 @@ namespace osu.Game.Database
|
|||||||
public void Run(Action<Realm> action)
|
public void Run(Action<Realm> action)
|
||||||
{
|
{
|
||||||
if (ThreadSafety.IsUpdateThread)
|
if (ThreadSafety.IsUpdateThread)
|
||||||
|
{
|
||||||
|
total_reads_update.Value++;
|
||||||
action(Realm);
|
action(Realm);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
total_reads_async.Value++;
|
||||||
using (var realm = getRealmInstance())
|
using (var realm = getRealmInstance())
|
||||||
action(realm);
|
action(realm);
|
||||||
}
|
}
|
||||||
@ -241,14 +259,30 @@ namespace osu.Game.Database
|
|||||||
public void Write(Action<Realm> action)
|
public void Write(Action<Realm> action)
|
||||||
{
|
{
|
||||||
if (ThreadSafety.IsUpdateThread)
|
if (ThreadSafety.IsUpdateThread)
|
||||||
|
{
|
||||||
|
total_writes_update.Value++;
|
||||||
Realm.Write(action);
|
Realm.Write(action);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
total_writes_async.Value++;
|
||||||
|
|
||||||
using (var realm = getRealmInstance())
|
using (var realm = getRealmInstance())
|
||||||
realm.Write(action);
|
realm.Write(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write changes to realm asynchronously, guaranteeing order of execution.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action">The work to run.</param>
|
||||||
|
public async Task WriteAsync(Action<Realm> action)
|
||||||
|
{
|
||||||
|
total_writes_async.Value++;
|
||||||
|
using (var realm = getRealmInstance())
|
||||||
|
await realm.WriteAsync(action);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Subscribe to a realm collection and begin watching for asynchronous changes.
|
/// Subscribe to a realm collection and begin watching for asynchronous changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -531,6 +565,11 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 14:
|
||||||
|
foreach (var beatmap in migration.NewRealm.All<BeatmapInfo>())
|
||||||
|
beatmap.UserSettings = new BeatmapUserSettings();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ namespace osu.Game.Database
|
|||||||
c.CreateMap<BeatmapInfo, BeatmapInfo>()
|
c.CreateMap<BeatmapInfo, BeatmapInfo>()
|
||||||
.ForMember(s => s.Ruleset, cc => cc.Ignore())
|
.ForMember(s => s.Ruleset, cc => cc.Ignore())
|
||||||
.ForMember(s => s.Metadata, cc => cc.Ignore())
|
.ForMember(s => s.Metadata, cc => cc.Ignore())
|
||||||
|
.ForMember(s => s.UserSettings, cc => cc.Ignore())
|
||||||
.ForMember(s => s.Difficulty, cc => cc.Ignore())
|
.ForMember(s => s.Difficulty, cc => cc.Ignore())
|
||||||
.ForMember(s => s.BeatmapSet, cc => cc.Ignore())
|
.ForMember(s => s.BeatmapSet, cc => cc.Ignore())
|
||||||
.AfterMap((s, d) =>
|
.AfterMap((s, d) =>
|
||||||
@ -154,6 +155,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
c.CreateMap<RealmKeyBinding, RealmKeyBinding>();
|
c.CreateMap<RealmKeyBinding, RealmKeyBinding>();
|
||||||
c.CreateMap<BeatmapMetadata, BeatmapMetadata>();
|
c.CreateMap<BeatmapMetadata, BeatmapMetadata>();
|
||||||
|
c.CreateMap<BeatmapUserSettings, BeatmapUserSettings>();
|
||||||
c.CreateMap<BeatmapDifficulty, BeatmapDifficulty>();
|
c.CreateMap<BeatmapDifficulty, BeatmapDifficulty>();
|
||||||
c.CreateMap<RulesetInfo, RulesetInfo>();
|
c.CreateMap<RulesetInfo, RulesetInfo>();
|
||||||
c.CreateMap<ScoreInfo, ScoreInfo>();
|
c.CreateMap<ScoreInfo, ScoreInfo>();
|
||||||
|
@ -72,6 +72,11 @@ namespace osu.Game.Extensions
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether this <see cref="IRulesetInfo"/>'s online ID is within the range that defines it as a legacy ruleset (ie. either osu!, osu!taiko, osu!catch or osu!mania).
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsLegacyRuleset(this IRulesetInfo ruleset) => ruleset.OnlineID >= 0 && ruleset.OnlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether the online ID of two <see cref="IBeatmapSetInfo"/>s match.
|
/// Check whether the online ID of two <see cref="IBeatmapSetInfo"/>s match.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -5,6 +5,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
@ -38,24 +39,24 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private BackgroundScreenStack backgroundStack;
|
private BackgroundScreenStack backgroundStack;
|
||||||
|
|
||||||
private bool allowScaling = true;
|
private RectangleF? customRect;
|
||||||
|
private bool customRectIsRelativePosition;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether user scaling preferences should be applied. Enabled by default.
|
/// Set a custom position and scale which overrides any user specification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowScaling
|
/// <param name="rect">A rectangle with positional and sizing information for this container to conform to. <c>null</c> will clear the custom rect and revert to user settings.</param>
|
||||||
|
/// <param name="relativePosition">Whether the position portion of the provided rect is in relative coordinate space or not.</param>
|
||||||
|
public void SetCustomRect(RectangleF? rect, bool relativePosition = false)
|
||||||
{
|
{
|
||||||
get => allowScaling;
|
customRect = rect;
|
||||||
set
|
customRectIsRelativePosition = relativePosition;
|
||||||
{
|
|
||||||
if (value == allowScaling)
|
|
||||||
return;
|
|
||||||
|
|
||||||
allowScaling = value;
|
if (IsLoaded) Scheduler.AddOnce(updateSize);
|
||||||
if (IsLoaded) Scheduler.AddOnce(updateSize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const float corner_radius = 10;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new instance.
|
/// Create a new instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -69,7 +70,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
CornerRadius = 10,
|
CornerRadius = corner_radius,
|
||||||
Child = content = new ScalingDrawSizePreservingFillContainer(targetMode != ScalingMode.Gameplay)
|
Child = content = new ScalingDrawSizePreservingFillContainer(targetMode != ScalingMode.Gameplay)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -137,7 +138,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private void updateSize()
|
private void updateSize()
|
||||||
{
|
{
|
||||||
const float fade_time = 500;
|
const float duration = 500;
|
||||||
|
|
||||||
if (targetMode == ScalingMode.Everything)
|
if (targetMode == ScalingMode.Everything)
|
||||||
{
|
{
|
||||||
@ -156,17 +157,31 @@ namespace osu.Game.Graphics.Containers
|
|||||||
backgroundStack.Push(new ScalingBackgroundScreen());
|
backgroundStack.Push(new ScalingBackgroundScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
backgroundStack.FadeIn(fade_time);
|
backgroundStack.FadeIn(duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
backgroundStack?.FadeOut(fade_time);
|
backgroundStack?.FadeOut(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scaling = AllowScaling && (targetMode == null || scalingMode.Value == targetMode);
|
RectangleF targetRect = new RectangleF(Vector2.Zero, Vector2.One);
|
||||||
|
|
||||||
var targetSize = scaling ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One;
|
if (customRect != null)
|
||||||
var targetPosition = scaling ? new Vector2(posX.Value, posY.Value) * (Vector2.One - targetSize) : Vector2.Zero;
|
{
|
||||||
bool requiresMasking = (scaling && targetSize != Vector2.One)
|
sizableContainer.RelativePositionAxes = customRectIsRelativePosition ? Axes.Both : Axes.None;
|
||||||
|
|
||||||
|
targetRect = customRect.Value;
|
||||||
|
}
|
||||||
|
else if (targetMode == null || scalingMode.Value == targetMode)
|
||||||
|
{
|
||||||
|
sizableContainer.RelativePositionAxes = Axes.Both;
|
||||||
|
|
||||||
|
Vector2 scale = new Vector2(sizeX.Value, sizeY.Value);
|
||||||
|
Vector2 pos = new Vector2(posX.Value, posY.Value) * (Vector2.One - scale);
|
||||||
|
|
||||||
|
targetRect = new RectangleF(pos, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool requiresMasking = targetRect.Size != Vector2.One
|
||||||
// For the top level scaling container, for now we apply masking if safe areas are in use.
|
// For the top level scaling container, for now we apply masking if safe areas are in use.
|
||||||
// In the future this can likely be removed as more of the actual UI supports overflowing into the safe areas.
|
// In the future this can likely be removed as more of the actual UI supports overflowing into the safe areas.
|
||||||
|| (targetMode == ScalingMode.Everything && safeAreaPadding.Value.Total != Vector2.Zero);
|
|| (targetMode == ScalingMode.Everything && safeAreaPadding.Value.Total != Vector2.Zero);
|
||||||
@ -174,8 +189,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
if (requiresMasking)
|
if (requiresMasking)
|
||||||
sizableContainer.Masking = true;
|
sizableContainer.Masking = true;
|
||||||
|
|
||||||
sizableContainer.MoveTo(targetPosition, 500, Easing.OutQuart);
|
sizableContainer.MoveTo(targetRect.Location, duration, Easing.OutQuart);
|
||||||
sizableContainer.ResizeTo(targetSize, 500, Easing.OutQuart).OnComplete(_ => { sizableContainer.Masking = requiresMasking; });
|
sizableContainer.ResizeTo(targetRect.Size, duration, Easing.OutQuart);
|
||||||
|
|
||||||
|
// Of note, this will not work great in the case of nested ScalingContainers where multiple are applying corner radius.
|
||||||
|
// Masking and corner radius should likely only be applied at one point in the full game stack to fix this.
|
||||||
|
// An example of how this can occur is when the skin editor is visible and the game screen scaling is set to "Everything".
|
||||||
|
sizableContainer.TransformTo(nameof(CornerRadius), requiresMasking ? corner_radius : 0, duration, requiresMasking ? Easing.OutQuart : Easing.None)
|
||||||
|
.OnComplete(_ => { sizableContainer.Masking = requiresMasking; });
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScalingBackgroundScreen : BackgroundScreenDefault
|
private class ScalingBackgroundScreen : BackgroundScreenDefault
|
||||||
|
34
osu.Game/Localisation/BeatmapOffsetControlStrings.cs
Normal file
34
osu.Game/Localisation/BeatmapOffsetControlStrings.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
|
namespace osu.Game.Localisation
|
||||||
|
{
|
||||||
|
public static class BeatmapOffsetControlStrings
|
||||||
|
{
|
||||||
|
private const string prefix = @"osu.Game.Resources.Localisation.BeatmapOffsetControl";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Beatmap offset"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString BeatmapOffset => new TranslatableString(getKey(@"beatmap_offset"), @"Beatmap offset");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Previous play:"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PreviousPlay => new TranslatableString(getKey(@"previous_play"), @"Previous play:");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Previous play too short to use for calibration"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PreviousPlayTooShortToUseForCalibration => new TranslatableString(getKey(@"previous_play_too_short_to_use_for_calibration"), @"Previous play too short to use for calibration");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Calibrate using last play"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString CalibrateUsingLastPlay => new TranslatableString(getKey(@"calibrate_using_last_play"), @"Calibrate using last play");
|
||||||
|
|
||||||
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
|
}
|
||||||
|
}
|
49
osu.Game/Localisation/LeaderboardStrings.cs
Normal file
49
osu.Game/Localisation/LeaderboardStrings.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
|
namespace osu.Game.Localisation
|
||||||
|
{
|
||||||
|
public static class LeaderboardStrings
|
||||||
|
{
|
||||||
|
private const string prefix = @"osu.Game.Resources.Localisation.Leaderboard";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Couldn't fetch scores!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString CouldntFetchScores => new TranslatableString(getKey(@"couldnt_fetch_scores"), @"Couldn't fetch scores!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Please select a beatmap!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PleaseSelectABeatmap => new TranslatableString(getKey(@"please_select_a_beatmap"), @"Please select a beatmap!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Leaderboards are not available for this ruleset!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString LeaderboardsAreNotAvailableForThisRuleset => new TranslatableString(getKey(@"leaderboards_are_not_available_for_this_ruleset"), @"Leaderboards are not available for this ruleset!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Leaderboards are not available for this beatmap!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString LeaderboardsAreNotAvailableForThisBeatmap => new TranslatableString(getKey(@"leaderboards_are_not_available_for_this_beatmap"), @"Leaderboards are not available for this beatmap!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "No records yet!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString NoRecordsYet => new TranslatableString(getKey(@"no_records_yet"), @"No records yet!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Please sign in to view online leaderboards!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PleaseSignInToViewOnlineLeaderboards => new TranslatableString(getKey(@"please_sign_in_to_view_online_leaderboards"), @"Please sign in to view online leaderboards!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Please invest in an osu!supporter tag to view this leaderboard!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PleaseInvestInAnOsuSupporterTagToViewThisLeaderboard => new TranslatableString(getKey(@"please_invest_in_an_osu_supporter_tag_to_view_this_leaderboard"), @"Please invest in an osu!supporter tag to view this leaderboard!");
|
||||||
|
|
||||||
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.Placeholders;
|
using osu.Game.Online.Placeholders;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Online.Leaderboards
|
namespace osu.Game.Online.Leaderboards
|
||||||
{
|
{
|
||||||
@ -311,25 +312,28 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case LeaderboardState.NetworkFailure:
|
case LeaderboardState.NetworkFailure:
|
||||||
return new ClickablePlaceholder(@"Couldn't fetch scores!", FontAwesome.Solid.Sync)
|
return new ClickablePlaceholder(LeaderboardStrings.CouldntFetchScores, FontAwesome.Solid.Sync)
|
||||||
{
|
{
|
||||||
Action = RefetchScores
|
Action = RefetchScores
|
||||||
};
|
};
|
||||||
|
|
||||||
case LeaderboardState.NoneSelected:
|
case LeaderboardState.NoneSelected:
|
||||||
return new MessagePlaceholder(@"Please select a beatmap!");
|
return new MessagePlaceholder(LeaderboardStrings.PleaseSelectABeatmap);
|
||||||
|
|
||||||
case LeaderboardState.Unavailable:
|
case LeaderboardState.RulesetUnavailable:
|
||||||
return new MessagePlaceholder(@"Leaderboards are not available for this beatmap!");
|
return new MessagePlaceholder(LeaderboardStrings.LeaderboardsAreNotAvailableForThisRuleset);
|
||||||
|
|
||||||
|
case LeaderboardState.BeatmapUnavailable:
|
||||||
|
return new MessagePlaceholder(LeaderboardStrings.LeaderboardsAreNotAvailableForThisBeatmap);
|
||||||
|
|
||||||
case LeaderboardState.NoScores:
|
case LeaderboardState.NoScores:
|
||||||
return new MessagePlaceholder(@"No records yet!");
|
return new MessagePlaceholder(LeaderboardStrings.NoRecordsYet);
|
||||||
|
|
||||||
case LeaderboardState.NotLoggedIn:
|
case LeaderboardState.NotLoggedIn:
|
||||||
return new LoginPlaceholder(@"Please sign in to view online leaderboards!");
|
return new LoginPlaceholder(LeaderboardStrings.PleaseSignInToViewOnlineLeaderboards);
|
||||||
|
|
||||||
case LeaderboardState.NotSupporter:
|
case LeaderboardState.NotSupporter:
|
||||||
return new MessagePlaceholder(@"Please invest in an osu!supporter tag to view this leaderboard!");
|
return new MessagePlaceholder(LeaderboardStrings.PleaseInvestInAnOsuSupporterTagToViewThisLeaderboard);
|
||||||
|
|
||||||
case LeaderboardState.Retrieving:
|
case LeaderboardState.Retrieving:
|
||||||
return null;
|
return null;
|
||||||
|
@ -8,7 +8,8 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
Success,
|
Success,
|
||||||
Retrieving,
|
Retrieving,
|
||||||
NetworkFailure,
|
NetworkFailure,
|
||||||
Unavailable,
|
BeatmapUnavailable,
|
||||||
|
RulesetUnavailable,
|
||||||
NoneSelected,
|
NoneSelected,
|
||||||
NoScores,
|
NoScores,
|
||||||
NotLoggedIn,
|
NotLoggedIn,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
|
||||||
namespace osu.Game.Online.Placeholders
|
namespace osu.Game.Online.Placeholders
|
||||||
@ -12,7 +13,7 @@ namespace osu.Game.Online.Placeholders
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private LoginOverlay login { get; set; }
|
private LoginOverlay login { get; set; }
|
||||||
|
|
||||||
public LoginPlaceholder(string actionMessage)
|
public LoginPlaceholder(LocalisableString actionMessage)
|
||||||
: base(actionMessage, FontAwesome.Solid.UserLock)
|
: base(actionMessage, FontAwesome.Solid.UserLock)
|
||||||
{
|
{
|
||||||
Action = () => login?.Show();
|
Action = () => login?.Show();
|
||||||
|
426
osu.Game/Overlays/Mods/ModColumn.cs
Normal file
426
osu.Game/Overlays/Mods/ModColumn.cs
Normal file
@ -0,0 +1,426 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Humanizer;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Mods
|
||||||
|
{
|
||||||
|
public class ModColumn : CompositeDrawable
|
||||||
|
{
|
||||||
|
private Func<Mod, bool>? filter;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Function determining whether each mod in the column should be displayed.
|
||||||
|
/// A return value of <see langword="true"/> means that the mod is not filtered and therefore its corresponding panel should be displayed.
|
||||||
|
/// A return value of <see langword="false"/> means that the mod is filtered out and therefore its corresponding panel should be hidden.
|
||||||
|
/// </summary>
|
||||||
|
public Func<Mod, bool>? Filter
|
||||||
|
{
|
||||||
|
get => filter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
filter = value;
|
||||||
|
updateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly ModType modType;
|
||||||
|
private readonly Key[]? toggleKeys;
|
||||||
|
|
||||||
|
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
||||||
|
|
||||||
|
private readonly TextFlowContainer headerText;
|
||||||
|
private readonly Box headerBackground;
|
||||||
|
private readonly Container contentContainer;
|
||||||
|
private readonly Box contentBackground;
|
||||||
|
private readonly FillFlowContainer<ModPanel> panelFlow;
|
||||||
|
private readonly ToggleAllCheckbox? toggleAllCheckbox;
|
||||||
|
|
||||||
|
private Colour4 accentColour;
|
||||||
|
|
||||||
|
private Task? latestLoadTask;
|
||||||
|
internal bool ItemsLoaded => latestLoadTask == null;
|
||||||
|
|
||||||
|
private const float header_height = 42;
|
||||||
|
|
||||||
|
public ModColumn(ModType modType, bool allowBulkSelection, Key[]? toggleKeys = null)
|
||||||
|
{
|
||||||
|
this.modType = modType;
|
||||||
|
this.toggleKeys = toggleKeys;
|
||||||
|
|
||||||
|
Width = 320;
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
Shear = new Vector2(ModPanel.SHEAR_X, 0);
|
||||||
|
CornerRadius = ModPanel.CORNER_RADIUS;
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
Container controlContainer;
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = header_height + ModPanel.CORNER_RADIUS,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
headerBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = header_height + ModPanel.CORNER_RADIUS
|
||||||
|
},
|
||||||
|
headerText = new OsuTextFlowContainer(t =>
|
||||||
|
{
|
||||||
|
t.Font = OsuFont.TorusAlternate.With(size: 17);
|
||||||
|
t.Shadow = false;
|
||||||
|
t.Colour = Colour4.Black;
|
||||||
|
})
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Shear = new Vector2(-ModPanel.SHEAR_X, 0),
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Horizontal = 17,
|
||||||
|
Bottom = ModPanel.CORNER_RADIUS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Top = header_height },
|
||||||
|
Child = contentContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = ModPanel.CORNER_RADIUS,
|
||||||
|
BorderThickness = 3,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
contentBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension()
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
controlContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Padding = new MarginPadding { Horizontal = 14 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
ScrollbarOverlapsContent = false,
|
||||||
|
Child = panelFlow = new FillFlowContainer<ModPanel>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(0, 7),
|
||||||
|
Padding = new MarginPadding(7)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
createHeaderText();
|
||||||
|
|
||||||
|
if (allowBulkSelection)
|
||||||
|
{
|
||||||
|
controlContainer.Height = 35;
|
||||||
|
controlContainer.Add(toggleAllCheckbox = new ToggleAllCheckbox(this)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Scale = new Vector2(0.8f),
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
LabelText = "Enable All",
|
||||||
|
Shear = new Vector2(-ModPanel.SHEAR_X, 0)
|
||||||
|
});
|
||||||
|
panelFlow.Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Top = 0,
|
||||||
|
Bottom = 7,
|
||||||
|
Horizontal = 7
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createHeaderText()
|
||||||
|
{
|
||||||
|
IEnumerable<string> headerTextWords = modType.Humanize(LetterCasing.Title).Split(' ');
|
||||||
|
|
||||||
|
if (headerTextWords.Count() > 1)
|
||||||
|
{
|
||||||
|
headerText.AddText($"{headerTextWords.First()} ", t => t.Font = t.Font.With(weight: FontWeight.SemiBold));
|
||||||
|
headerTextWords = headerTextWords.Skip(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
headerText.AddText(string.Join(' ', headerTextWords));
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuGameBase game, OverlayColourProvider colourProvider, OsuColour colours)
|
||||||
|
{
|
||||||
|
availableMods.BindTo(game.AvailableMods);
|
||||||
|
|
||||||
|
headerBackground.Colour = accentColour = colours.ForModType(modType);
|
||||||
|
|
||||||
|
if (toggleAllCheckbox != null)
|
||||||
|
{
|
||||||
|
toggleAllCheckbox.AccentColour = accentColour;
|
||||||
|
toggleAllCheckbox.AccentHoverColour = accentColour.Lighten(0.3f);
|
||||||
|
}
|
||||||
|
|
||||||
|
contentContainer.BorderColour = ColourInfo.GradientVertical(colourProvider.Background4, colourProvider.Background3);
|
||||||
|
contentBackground.Colour = colourProvider.Background4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
availableMods.BindValueChanged(_ => Scheduler.AddOnce(updateMods));
|
||||||
|
updateMods();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource? cancellationTokenSource;
|
||||||
|
|
||||||
|
private void updateMods()
|
||||||
|
{
|
||||||
|
var newMods = ModUtils.FlattenMods(availableMods.Value.GetValueOrDefault(modType) ?? Array.Empty<Mod>()).ToList();
|
||||||
|
|
||||||
|
if (newMods.SequenceEqual(panelFlow.Children.Select(p => p.Mod)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
cancellationTokenSource?.Cancel();
|
||||||
|
|
||||||
|
var panels = newMods.Select(mod => new ModPanel(mod)
|
||||||
|
{
|
||||||
|
Shear = new Vector2(-ModPanel.SHEAR_X, 0)
|
||||||
|
});
|
||||||
|
|
||||||
|
Task? loadTask;
|
||||||
|
|
||||||
|
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
|
||||||
|
{
|
||||||
|
panelFlow.ChildrenEnumerable = loaded;
|
||||||
|
|
||||||
|
foreach (var panel in panelFlow)
|
||||||
|
panel.Active.BindValueChanged(_ => updateToggleState());
|
||||||
|
updateToggleState();
|
||||||
|
|
||||||
|
updateFilter();
|
||||||
|
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
||||||
|
loadTask.ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
if (loadTask == latestLoadTask)
|
||||||
|
latestLoadTask = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Bulk select / deselect
|
||||||
|
|
||||||
|
private const double initial_multiple_selection_delay = 120;
|
||||||
|
|
||||||
|
private double selectionDelay = initial_multiple_selection_delay;
|
||||||
|
private double lastSelection;
|
||||||
|
|
||||||
|
private readonly Queue<Action> pendingSelectionOperations = new Queue<Action>();
|
||||||
|
|
||||||
|
protected bool SelectionAnimationRunning => pendingSelectionOperations.Count > 0;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (selectionDelay == initial_multiple_selection_delay || Time.Current - lastSelection >= selectionDelay)
|
||||||
|
{
|
||||||
|
if (pendingSelectionOperations.TryDequeue(out var dequeuedAction))
|
||||||
|
{
|
||||||
|
dequeuedAction();
|
||||||
|
|
||||||
|
// each time we play an animation, we decrease the time until the next animation (to ramp the visual and audible elements).
|
||||||
|
selectionDelay = Math.Max(30, selectionDelay * 0.8f);
|
||||||
|
lastSelection = Time.Current;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// reset the selection delay after all animations have been completed.
|
||||||
|
// this will cause the next action to be immediately performed.
|
||||||
|
selectionDelay = initial_multiple_selection_delay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateToggleState()
|
||||||
|
{
|
||||||
|
if (toggleAllCheckbox != null && !SelectionAnimationRunning)
|
||||||
|
{
|
||||||
|
toggleAllCheckbox.Alpha = panelFlow.Any(panel => !panel.Filtered.Value) ? 1 : 0;
|
||||||
|
toggleAllCheckbox.Current.Value = panelFlow.Where(panel => !panel.Filtered.Value).All(panel => panel.Active.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects all mods.
|
||||||
|
/// </summary>
|
||||||
|
public void SelectAll()
|
||||||
|
{
|
||||||
|
pendingSelectionOperations.Clear();
|
||||||
|
|
||||||
|
foreach (var button in panelFlow.Where(b => !b.Active.Value && !b.Filtered.Value))
|
||||||
|
pendingSelectionOperations.Enqueue(() => button.Active.Value = true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deselects all mods.
|
||||||
|
/// </summary>
|
||||||
|
public void DeselectAll()
|
||||||
|
{
|
||||||
|
pendingSelectionOperations.Clear();
|
||||||
|
|
||||||
|
foreach (var button in panelFlow.Where(b => b.Active.Value && !b.Filtered.Value))
|
||||||
|
pendingSelectionOperations.Enqueue(() => button.Active.Value = false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ToggleAllCheckbox : OsuCheckbox
|
||||||
|
{
|
||||||
|
private Color4 accentColour;
|
||||||
|
|
||||||
|
public Color4 AccentColour
|
||||||
|
{
|
||||||
|
get => accentColour;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
accentColour = value;
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color4 accentHoverColour;
|
||||||
|
|
||||||
|
public Color4 AccentHoverColour
|
||||||
|
{
|
||||||
|
get => accentHoverColour;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
accentHoverColour = value;
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly ModColumn column;
|
||||||
|
|
||||||
|
public ToggleAllCheckbox(ModColumn column)
|
||||||
|
: base(false)
|
||||||
|
{
|
||||||
|
this.column = column;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ApplyLabelParameters(SpriteText text)
|
||||||
|
{
|
||||||
|
base.ApplyLabelParameters(text);
|
||||||
|
text.Font = text.Font.With(weight: FontWeight.SemiBold);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
Nub.AccentColour = AccentColour;
|
||||||
|
Nub.GlowingAccentColour = AccentHoverColour;
|
||||||
|
Nub.GlowColour = AccentHoverColour.Opacity(0.2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnUserChange(bool value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
column.SelectAll();
|
||||||
|
else
|
||||||
|
column.DeselectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Filtering support
|
||||||
|
|
||||||
|
private void updateFilter()
|
||||||
|
{
|
||||||
|
foreach (var modPanel in panelFlow)
|
||||||
|
modPanel.ApplyFilter(Filter);
|
||||||
|
|
||||||
|
updateToggleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Keyboard selection support
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
|
{
|
||||||
|
if (e.ControlPressed || e.AltPressed) return false;
|
||||||
|
if (toggleKeys == null) return false;
|
||||||
|
|
||||||
|
int index = Array.IndexOf(toggleKeys, e.Key);
|
||||||
|
if (index < 0) return false;
|
||||||
|
|
||||||
|
var panel = panelFlow.ElementAtOrDefault(index);
|
||||||
|
if (panel == null || panel.Filtered.Value) return false;
|
||||||
|
|
||||||
|
panel.Active.Toggle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
@ -28,6 +29,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
public Mod Mod { get; }
|
public Mod Mod { get; }
|
||||||
public BindableBool Active { get; } = new BindableBool();
|
public BindableBool Active { get; } = new BindableBool();
|
||||||
|
public BindableBool Filtered { get; } = new BindableBool();
|
||||||
|
|
||||||
protected readonly Box Background;
|
protected readonly Box Background;
|
||||||
protected readonly Container SwitchContainer;
|
protected readonly Container SwitchContainer;
|
||||||
@ -40,10 +42,10 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
protected const double TRANSITION_DURATION = 150;
|
protected const double TRANSITION_DURATION = 150;
|
||||||
|
|
||||||
protected const float SHEAR_X = 0.2f;
|
public const float SHEAR_X = 0.2f;
|
||||||
|
public const float CORNER_RADIUS = 7;
|
||||||
|
|
||||||
protected const float HEIGHT = 42;
|
protected const float HEIGHT = 42;
|
||||||
protected const float CORNER_RADIUS = 7;
|
|
||||||
protected const float IDLE_SWITCH_WIDTH = 54;
|
protected const float IDLE_SWITCH_WIDTH = 54;
|
||||||
protected const float EXPANDED_SWITCH_WIDTH = 70;
|
protected const float EXPANDED_SWITCH_WIDTH = 70;
|
||||||
|
|
||||||
@ -157,6 +159,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
playStateChangeSamples();
|
playStateChangeSamples();
|
||||||
UpdateState();
|
UpdateState();
|
||||||
});
|
});
|
||||||
|
Filtered.BindValueChanged(_ => updateFilterState());
|
||||||
|
|
||||||
UpdateState();
|
UpdateState();
|
||||||
FinishTransforms(true);
|
FinishTransforms(true);
|
||||||
@ -190,7 +193,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
mouseDown = true;
|
mouseDown = true;
|
||||||
|
|
||||||
UpdateState();
|
UpdateState();
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnMouseUp(MouseUpEvent e)
|
protected override void OnMouseUp(MouseUpEvent e)
|
||||||
@ -235,5 +238,19 @@ namespace osu.Game.Overlays.Mods
|
|||||||
TextBackground.FadeColour(textBackgroundColour, transitionDuration, Easing.OutQuint);
|
TextBackground.FadeColour(textBackgroundColour, transitionDuration, Easing.OutQuint);
|
||||||
TextFlow.FadeColour(textColour, transitionDuration, Easing.OutQuint);
|
TextFlow.FadeColour(textColour, transitionDuration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Filtering support
|
||||||
|
|
||||||
|
public void ApplyFilter(Func<Mod, bool>? filter)
|
||||||
|
{
|
||||||
|
Filtered.Value = filter != null && !filter.Invoke(Mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateFilterState()
|
||||||
|
{
|
||||||
|
this.FadeTo(Filtered.Value ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,9 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
public class SettingsToolboxGroup : Container, IExpandable
|
public class SettingsToolboxGroup : Container, IExpandable
|
||||||
{
|
{
|
||||||
|
public const int CONTAINER_WIDTH = 270;
|
||||||
|
|
||||||
private const float transition_duration = 250;
|
private const float transition_duration = 250;
|
||||||
private const int container_width = 270;
|
|
||||||
private const int border_thickness = 2;
|
private const int border_thickness = 2;
|
||||||
private const int header_height = 30;
|
private const int header_height = 30;
|
||||||
private const int corner_radius = 5;
|
private const int corner_radius = 5;
|
||||||
@ -49,7 +50,7 @@ namespace osu.Game.Overlays
|
|||||||
public SettingsToolboxGroup(string title)
|
public SettingsToolboxGroup(string title)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Width = container_width;
|
Width = CONTAINER_WIDTH;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = corner_radius;
|
CornerRadius = corner_radius;
|
||||||
BorderColour = Color4.Black;
|
BorderColour = Color4.Black;
|
||||||
@ -201,7 +202,5 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,19 @@ using osu.Game.Rulesets.UI;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface for <see cref="Mod"/>s that are updated every frame by a <see cref="Playfield"/>.
|
||||||
|
/// </summary>
|
||||||
public interface IUpdatableByPlayfield : IApplicableMod
|
public interface IUpdatableByPlayfield : IApplicableMod
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Update this <see cref="Mod"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playfield">The main <see cref="Playfield"/></param>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method is called once per frame during gameplay by the main <see cref="Playfield"/> only.
|
||||||
|
/// To access nested <see cref="Playfield"/>s, use <see cref="Playfield.NestedPlayfields"/>.
|
||||||
|
/// </remarks>
|
||||||
void Update(Playfield playfield);
|
void Update(Playfield playfield);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,15 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// A non-null <see langword="double"/> value if unstable rate could be calculated,
|
/// A non-null <see langword="double"/> value if unstable rate could be calculated,
|
||||||
/// and <see langword="null"/> if unstable rate cannot be calculated due to <paramref name="hitEvents"/> being empty.
|
/// and <see langword="null"/> if unstable rate cannot be calculated due to <paramref name="hitEvents"/> being empty.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static double? CalculateAverageHitError(this IEnumerable<HitEvent> hitEvents) =>
|
public static double? CalculateAverageHitError(this IEnumerable<HitEvent> hitEvents)
|
||||||
hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset).Average();
|
{
|
||||||
|
double[] timeOffsets = hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset).ToArray();
|
||||||
|
|
||||||
|
if (timeOffsets.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return timeOffsets.Average();
|
||||||
|
}
|
||||||
|
|
||||||
private static bool affectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
|
private static bool affectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
|
||||||
|
|
||||||
|
@ -79,6 +79,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
private readonly List<Playfield> nestedPlayfields = new List<Playfield>();
|
private readonly List<Playfield> nestedPlayfields = new List<Playfield>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this <see cref="Playfield"/> is nested in another <see cref="Playfield"/>.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsNested { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether judgements should be displayed by this and and all nested <see cref="Playfield"/>s.
|
/// Whether judgements should be displayed by this and and all nested <see cref="Playfield"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -206,6 +211,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <param name="otherPlayfield">The <see cref="Playfield"/> to add.</param>
|
/// <param name="otherPlayfield">The <see cref="Playfield"/> to add.</param>
|
||||||
protected void AddNested(Playfield otherPlayfield)
|
protected void AddNested(Playfield otherPlayfield)
|
||||||
{
|
{
|
||||||
|
otherPlayfield.IsNested = true;
|
||||||
|
|
||||||
otherPlayfield.DisplayJudgements.BindTo(DisplayJudgements);
|
otherPlayfield.DisplayJudgements.BindTo(DisplayJudgements);
|
||||||
|
|
||||||
otherPlayfield.NewResult += (d, r) => NewResult?.Invoke(d, r);
|
otherPlayfield.NewResult += (d, r) => NewResult?.Invoke(d, r);
|
||||||
@ -229,7 +236,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (mods != null)
|
if (!IsNested && mods != null)
|
||||||
{
|
{
|
||||||
foreach (var mod in mods)
|
foreach (var mod in mods)
|
||||||
{
|
{
|
||||||
|
@ -7,10 +7,15 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.IO.Legacy;
|
using osu.Game.IO.Legacy;
|
||||||
|
using osu.Game.Replays.Legacy;
|
||||||
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.Replays.Types;
|
using osu.Game.Rulesets.Replays.Types;
|
||||||
using SharpCompress.Compressors.LZMA;
|
using SharpCompress.Compressors.LZMA;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
namespace osu.Game.Scoring.Legacy
|
namespace osu.Game.Scoring.Legacy
|
||||||
{
|
{
|
||||||
public class LegacyScoreEncoder
|
public class LegacyScoreEncoder
|
||||||
@ -27,15 +32,24 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
public const int FIRST_LAZER_VERSION = 30000000;
|
public const int FIRST_LAZER_VERSION = 30000000;
|
||||||
|
|
||||||
private readonly Score score;
|
private readonly Score score;
|
||||||
private readonly IBeatmap beatmap;
|
private readonly IBeatmap? beatmap;
|
||||||
|
|
||||||
public LegacyScoreEncoder(Score score, IBeatmap beatmap)
|
/// <summary>
|
||||||
|
/// Create a new score encoder for a specific score.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="score">The score to be encoded.</param>
|
||||||
|
/// <param name="beatmap">The beatmap used to convert frames for the score. May be null if the frames are already <see cref="LegacyReplayFrame"/>s.</param>
|
||||||
|
/// <exception cref="ArgumentException"></exception>
|
||||||
|
public LegacyScoreEncoder(Score score, IBeatmap? beatmap)
|
||||||
{
|
{
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
|
||||||
if (score.ScoreInfo.BeatmapInfo.Ruleset.OnlineID < 0 || score.ScoreInfo.BeatmapInfo.Ruleset.OnlineID > 3)
|
if (beatmap == null && !score.Replay.Frames.All(f => f is LegacyReplayFrame))
|
||||||
throw new ArgumentException("Only scores in the osu, taiko, catch, or mania rulesets can be encoded to the legacy score format.", nameof(score));
|
throw new ArgumentException(@"Beatmap must be provided if frames are not already legacy frames.", nameof(beatmap));
|
||||||
|
|
||||||
|
if (!score.ScoreInfo.Ruleset.IsLegacyRuleset())
|
||||||
|
throw new ArgumentException(@"Only scores in the osu, taiko, catch, or mania rulesets can be encoded to the legacy score format.", nameof(score));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Encode(Stream stream)
|
public void Encode(Stream stream)
|
||||||
@ -101,11 +115,13 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
{
|
{
|
||||||
int lastTime = 0;
|
int lastTime = 0;
|
||||||
|
|
||||||
foreach (var f in score.Replay.Frames.OfType<IConvertibleReplayFrame>().Select(f => f.ToLegacy(beatmap)))
|
foreach (var f in score.Replay.Frames)
|
||||||
{
|
{
|
||||||
|
var legacyFrame = getLegacyFrame(f);
|
||||||
|
|
||||||
// Rounding because stable could only parse integral values
|
// Rounding because stable could only parse integral values
|
||||||
int time = (int)Math.Round(f.Time);
|
int time = (int)Math.Round(legacyFrame.Time);
|
||||||
replayData.Append(FormattableString.Invariant($"{time - lastTime}|{f.MouseX ?? 0}|{f.MouseY ?? 0}|{(int)f.ButtonState},"));
|
replayData.Append(FormattableString.Invariant($"{time - lastTime}|{legacyFrame.MouseX ?? 0}|{legacyFrame.MouseY ?? 0}|{(int)legacyFrame.ButtonState},"));
|
||||||
lastTime = time;
|
lastTime = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,6 +133,21 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LegacyReplayFrame getLegacyFrame(ReplayFrame replayFrame)
|
||||||
|
{
|
||||||
|
switch (replayFrame)
|
||||||
|
{
|
||||||
|
case LegacyReplayFrame legacyFrame:
|
||||||
|
return legacyFrame;
|
||||||
|
|
||||||
|
case IConvertibleReplayFrame convertibleFrame:
|
||||||
|
return convertibleFrame.ToLegacy(beatmap);
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException(@"Frame could not be converted to legacy frames", nameof(replayFrame));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string getHpGraphFormatted()
|
private string getHpGraphFormatted()
|
||||||
{
|
{
|
||||||
// todo: implement, maybe?
|
// todo: implement, maybe?
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -18,8 +17,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
|||||||
{
|
{
|
||||||
public class EditorMenuBar : OsuMenu
|
public class EditorMenuBar : OsuMenu
|
||||||
{
|
{
|
||||||
public readonly Bindable<EditorScreenMode> Mode = new Bindable<EditorScreenMode>();
|
|
||||||
|
|
||||||
public EditorMenuBar()
|
public EditorMenuBar()
|
||||||
: base(Direction.Horizontal, true)
|
: base(Direction.Horizontal, true)
|
||||||
{
|
{
|
||||||
@ -28,25 +25,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
|||||||
MaskingContainer.CornerRadius = 0;
|
MaskingContainer.CornerRadius = 0;
|
||||||
ItemsContainer.Padding = new MarginPadding { Left = 100 };
|
ItemsContainer.Padding = new MarginPadding { Left = 100 };
|
||||||
BackgroundColour = Color4Extensions.FromHex("111");
|
BackgroundColour = Color4Extensions.FromHex("111");
|
||||||
|
|
||||||
ScreenSelectionTabControl tabControl;
|
|
||||||
AddRangeInternal(new Drawable[]
|
|
||||||
{
|
|
||||||
tabControl = new ScreenSelectionTabControl
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomRight,
|
|
||||||
Origin = Anchor.BottomRight,
|
|
||||||
X = -15
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Mode.BindTo(tabControl.Current);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
Mode.TriggerChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
||||||
|
@ -89,6 +89,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private NotificationOverlay notifications { get; set; }
|
private NotificationOverlay notifications { get; set; }
|
||||||
|
|
||||||
|
public readonly Bindable<EditorScreenMode> Mode = new Bindable<EditorScreenMode>();
|
||||||
|
|
||||||
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
||||||
|
|
||||||
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
||||||
@ -115,8 +117,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
[CanBeNull] // Should be non-null once it can support custom rulesets.
|
[CanBeNull] // Should be non-null once it can support custom rulesets.
|
||||||
private EditorChangeHandler changeHandler;
|
private EditorChangeHandler changeHandler;
|
||||||
|
|
||||||
private EditorMenuBar menuBar;
|
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
|
|
||||||
private TestGameplayButton testGameplayButton;
|
private TestGameplayButton testGameplayButton;
|
||||||
@ -239,40 +239,49 @@ namespace osu.Game.Screens.Edit
|
|||||||
Name = "Top bar",
|
Name = "Top bar",
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 40,
|
Height = 40,
|
||||||
Child = menuBar = new EditorMenuBar
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
new EditorMenuBar
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Mode = { Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose },
|
|
||||||
Items = new[]
|
|
||||||
{
|
{
|
||||||
new MenuItem("File")
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Items = new[]
|
||||||
{
|
{
|
||||||
Items = createFileMenuItems()
|
new MenuItem("File")
|
||||||
},
|
|
||||||
new MenuItem("Edit")
|
|
||||||
{
|
|
||||||
Items = new[]
|
|
||||||
{
|
{
|
||||||
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
|
Items = createFileMenuItems()
|
||||||
redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, Redo),
|
},
|
||||||
new EditorMenuItemSpacer(),
|
new MenuItem("Edit")
|
||||||
cutMenuItem = new EditorMenuItem("Cut", MenuItemType.Standard, Cut),
|
|
||||||
copyMenuItem = new EditorMenuItem("Copy", MenuItemType.Standard, Copy),
|
|
||||||
pasteMenuItem = new EditorMenuItem("Paste", MenuItemType.Standard, Paste),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new MenuItem("View")
|
|
||||||
{
|
|
||||||
Items = new MenuItem[]
|
|
||||||
{
|
{
|
||||||
new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
|
Items = new[]
|
||||||
new HitAnimationsMenuItem(config.GetBindable<bool>(OsuSetting.EditorHitAnimations))
|
{
|
||||||
|
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
|
||||||
|
redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, Redo),
|
||||||
|
new EditorMenuItemSpacer(),
|
||||||
|
cutMenuItem = new EditorMenuItem("Cut", MenuItemType.Standard, Cut),
|
||||||
|
copyMenuItem = new EditorMenuItem("Copy", MenuItemType.Standard, Copy),
|
||||||
|
pasteMenuItem = new EditorMenuItem("Paste", MenuItemType.Standard, Paste),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new MenuItem("View")
|
||||||
|
{
|
||||||
|
Items = new MenuItem[]
|
||||||
|
{
|
||||||
|
new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
|
||||||
|
new HitAnimationsMenuItem(config.GetBindable<bool>(OsuSetting.EditorHitAnimations))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
new ScreenSelectionTabControl
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
X = -15,
|
||||||
|
Current = Mode,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -340,14 +349,15 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
|
|
||||||
menuBar.Mode.ValueChanged += onModeChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
setUpClipboardActionAvailability();
|
setUpClipboardActionAvailability();
|
||||||
|
|
||||||
|
Mode.Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose;
|
||||||
|
Mode.BindValueChanged(onModeChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -517,23 +527,23 @@ namespace osu.Game.Screens.Edit
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorComposeMode:
|
case GlobalAction.EditorComposeMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Compose;
|
Mode.Value = EditorScreenMode.Compose;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorDesignMode:
|
case GlobalAction.EditorDesignMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Design;
|
Mode.Value = EditorScreenMode.Design;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorTimingMode:
|
case GlobalAction.EditorTimingMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Timing;
|
Mode.Value = EditorScreenMode.Timing;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorSetupMode:
|
case GlobalAction.EditorSetupMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.SongSetup;
|
Mode.Value = EditorScreenMode.SongSetup;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorVerifyMode:
|
case GlobalAction.EditorVerifyMode:
|
||||||
menuBar.Mode.Value = EditorScreenMode.Verify;
|
Mode.Value = EditorScreenMode.Verify;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.EditorTestGameplay:
|
case GlobalAction.EditorTestGameplay:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -13,6 +14,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -43,7 +45,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Precision = 0.1,
|
Precision = 0.1,
|
||||||
};
|
};
|
||||||
|
|
||||||
private double totalAppliedOffset => userOffsetClock.RateAdjustedOffset + platformOffsetClock.RateAdjustedOffset;
|
private double totalAppliedOffset => userBeatmapOffsetClock.RateAdjustedOffset + userGlobalOffsetClock.RateAdjustedOffset + platformOffsetClock.RateAdjustedOffset;
|
||||||
|
|
||||||
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
||||||
|
|
||||||
@ -52,12 +54,21 @@ namespace osu.Game.Screens.Play
|
|||||||
private readonly bool startAtGameplayStart;
|
private readonly bool startAtGameplayStart;
|
||||||
private readonly double firstHitObjectTime;
|
private readonly double firstHitObjectTime;
|
||||||
|
|
||||||
private HardwareCorrectionOffsetClock userOffsetClock;
|
private HardwareCorrectionOffsetClock userGlobalOffsetClock;
|
||||||
|
private HardwareCorrectionOffsetClock userBeatmapOffsetClock;
|
||||||
private HardwareCorrectionOffsetClock platformOffsetClock;
|
private HardwareCorrectionOffsetClock platformOffsetClock;
|
||||||
private MasterGameplayClock masterGameplayClock;
|
private MasterGameplayClock masterGameplayClock;
|
||||||
private Bindable<double> userAudioOffset;
|
private Bindable<double> userAudioOffset;
|
||||||
private double startOffset;
|
private double startOffset;
|
||||||
|
|
||||||
|
private IDisposable beatmapOffsetSubscription;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RealmAccess realm { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
public MasterGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false)
|
public MasterGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false)
|
||||||
: base(beatmap.Track)
|
: base(beatmap.Track)
|
||||||
{
|
{
|
||||||
@ -68,11 +79,33 @@ namespace osu.Game.Screens.Play
|
|||||||
firstHitObjectTime = beatmap.Beatmap.HitObjects.First().StartTime;
|
firstHitObjectTime = beatmap.Beatmap.HitObjects.First().StartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
protected override void LoadComplete()
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
||||||
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
userAudioOffset.BindValueChanged(offset => userGlobalOffsetClock.Offset = offset.NewValue, true);
|
||||||
|
|
||||||
|
beatmapOffsetSubscription = realm.RegisterCustomSubscription(r =>
|
||||||
|
{
|
||||||
|
var userSettings = r.Find<BeatmapInfo>(beatmap.BeatmapInfo.ID)?.UserSettings;
|
||||||
|
|
||||||
|
if (userSettings == null) // only the case for tests.
|
||||||
|
return null;
|
||||||
|
|
||||||
|
void onUserSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.PropertyName == nameof(BeatmapUserSettings.Offset))
|
||||||
|
updateOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateOffset();
|
||||||
|
userSettings.PropertyChanged += onUserSettingsOnPropertyChanged;
|
||||||
|
|
||||||
|
return new InvokeOnDisposal(() => userSettings.PropertyChanged -= onUserSettingsOnPropertyChanged);
|
||||||
|
|
||||||
|
void updateOffset() => userBeatmapOffsetClock.Offset = userSettings.Offset;
|
||||||
|
});
|
||||||
|
|
||||||
// sane default provided by ruleset.
|
// sane default provided by ruleset.
|
||||||
startOffset = gameplayStartTime;
|
startOffset = gameplayStartTime;
|
||||||
@ -161,9 +194,10 @@ namespace osu.Game.Screens.Play
|
|||||||
platformOffsetClock = new HardwareCorrectionOffsetClock(source, pauseFreqAdjust) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
|
platformOffsetClock = new HardwareCorrectionOffsetClock(source, pauseFreqAdjust) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
|
||||||
|
|
||||||
// the final usable gameplay clock with user-set offsets applied.
|
// the final usable gameplay clock with user-set offsets applied.
|
||||||
userOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock, pauseFreqAdjust);
|
userGlobalOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock, pauseFreqAdjust);
|
||||||
|
userBeatmapOffsetClock = new HardwareCorrectionOffsetClock(userGlobalOffsetClock, pauseFreqAdjust);
|
||||||
|
|
||||||
return masterGameplayClock = new MasterGameplayClock(userOffsetClock);
|
return masterGameplayClock = new MasterGameplayClock(userBeatmapOffsetClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -209,6 +243,7 @@ namespace osu.Game.Screens.Play
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
beatmapOffsetSubscription?.Dispose();
|
||||||
removeSourceClockAdjustments();
|
removeSourceClockAdjustments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,11 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public readonly PlayerConfiguration Configuration;
|
public readonly PlayerConfiguration Configuration;
|
||||||
|
|
||||||
protected Score Score { get; private set; }
|
/// <summary>
|
||||||
|
/// The score for the current play session.
|
||||||
|
/// Available only after the player is loaded.
|
||||||
|
/// </summary>
|
||||||
|
public Score Score { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new player instance.
|
/// Create a new player instance.
|
||||||
|
@ -61,6 +61,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected VisualSettings VisualSettings { get; private set; }
|
protected VisualSettings VisualSettings { get; private set; }
|
||||||
|
|
||||||
|
protected AudioSettings AudioSettings { get; private set; }
|
||||||
|
|
||||||
protected Task LoadTask { get; private set; }
|
protected Task LoadTask { get; private set; }
|
||||||
|
|
||||||
protected Task DisposalTask { get; private set; }
|
protected Task DisposalTask { get; private set; }
|
||||||
@ -141,6 +143,8 @@ namespace osu.Game.Screens.Play
|
|||||||
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
|
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
|
||||||
batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce);
|
batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce);
|
||||||
|
|
||||||
|
const float padding = 25;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
(content = new LogoTrackingContainer
|
(content = new LogoTrackingContainer
|
||||||
@ -156,19 +160,27 @@ namespace osu.Game.Screens.Play
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
},
|
},
|
||||||
PlayerSettings = new FillFlowContainer<PlayerSettingsGroup>
|
new OsuScrollContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Direction = FillDirection.Vertical,
|
Width = SettingsToolboxGroup.CONTAINER_WIDTH + padding * 2,
|
||||||
Spacing = new Vector2(0, 20),
|
Padding = new MarginPadding { Vertical = padding },
|
||||||
Margin = new MarginPadding(25),
|
Masking = false,
|
||||||
Children = new PlayerSettingsGroup[]
|
Child = PlayerSettings = new FillFlowContainer<PlayerSettingsGroup>
|
||||||
{
|
{
|
||||||
VisualSettings = new VisualSettings(),
|
AutoSizeAxes = Axes.Both,
|
||||||
new InputSettings()
|
Direction = FillDirection.Vertical,
|
||||||
}
|
Spacing = new Vector2(0, 20),
|
||||||
|
Padding = new MarginPadding { Horizontal = padding },
|
||||||
|
Children = new PlayerSettingsGroup[]
|
||||||
|
{
|
||||||
|
VisualSettings = new VisualSettings(),
|
||||||
|
AudioSettings = new AudioSettings(),
|
||||||
|
new InputSettings()
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
idleTracker = new IdleTracker(750),
|
idleTracker = new IdleTracker(750),
|
||||||
}),
|
}),
|
||||||
@ -225,6 +237,10 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
|
|
||||||
|
var lastScore = player.Score;
|
||||||
|
|
||||||
|
AudioSettings.ReferenceScore.Value = lastScore?.ScoreInfo;
|
||||||
|
|
||||||
// prepare for a retry.
|
// prepare for a retry.
|
||||||
player = null;
|
player = null;
|
||||||
playerConsumed = false;
|
playerConsumed = false;
|
||||||
|
37
osu.Game/Screens/Play/PlayerSettings/AudioSettings.cs
Normal file
37
osu.Game/Screens/Play/PlayerSettings/AudioSettings.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.PlayerSettings
|
||||||
|
{
|
||||||
|
public class AudioSettings : PlayerSettingsGroup
|
||||||
|
{
|
||||||
|
public Bindable<ScoreInfo> ReferenceScore { get; } = new Bindable<ScoreInfo>();
|
||||||
|
|
||||||
|
private readonly PlayerCheckbox beatmapHitsoundsToggle;
|
||||||
|
|
||||||
|
public AudioSettings()
|
||||||
|
: base("Audio Settings")
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" },
|
||||||
|
new BeatmapOffsetControl
|
||||||
|
{
|
||||||
|
ReferenceScore = { BindTarget = ReferenceScore },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
beatmapHitsoundsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
213
osu.Game/Screens/Play/PlayerSettings/BeatmapOffsetControl.cs
Normal file
213
osu.Game/Screens/Play/PlayerSettings/BeatmapOffsetControl.cs
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.PlayerSettings
|
||||||
|
{
|
||||||
|
public class BeatmapOffsetControl : CompositeDrawable
|
||||||
|
{
|
||||||
|
public Bindable<ScoreInfo> ReferenceScore { get; } = new Bindable<ScoreInfo>();
|
||||||
|
|
||||||
|
public BindableDouble Current { get; } = new BindableDouble
|
||||||
|
{
|
||||||
|
Default = 0,
|
||||||
|
Value = 0,
|
||||||
|
MinValue = -50,
|
||||||
|
MaxValue = 50,
|
||||||
|
Precision = 0.1,
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly FillFlowContainer referenceScoreContainer;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
|
private double lastPlayAverage;
|
||||||
|
|
||||||
|
private SettingsButton? useAverageButton;
|
||||||
|
|
||||||
|
private IDisposable? beatmapOffsetSubscription;
|
||||||
|
|
||||||
|
private Task? realmWriteTask;
|
||||||
|
|
||||||
|
public BeatmapOffsetControl()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
InternalChild = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new PlayerSliderBar<double>
|
||||||
|
{
|
||||||
|
KeyboardStep = 5,
|
||||||
|
LabelText = BeatmapOffsetControlStrings.BeatmapOffset,
|
||||||
|
Current = Current,
|
||||||
|
},
|
||||||
|
referenceScoreContainer = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
ReferenceScore.BindValueChanged(scoreChanged, true);
|
||||||
|
|
||||||
|
beatmapOffsetSubscription = realm.RegisterCustomSubscription(r =>
|
||||||
|
{
|
||||||
|
var userSettings = r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID)?.UserSettings;
|
||||||
|
|
||||||
|
if (userSettings == null) // only the case for tests.
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Current.Value = userSettings.Offset;
|
||||||
|
userSettings.PropertyChanged += onUserSettingsOnPropertyChanged;
|
||||||
|
|
||||||
|
return new InvokeOnDisposal(() => userSettings.PropertyChanged -= onUserSettingsOnPropertyChanged);
|
||||||
|
|
||||||
|
void onUserSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.PropertyName == nameof(BeatmapUserSettings.Offset))
|
||||||
|
Current.Value = userSettings.Offset;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Current.BindValueChanged(currentChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void currentChanged(ValueChangedEvent<double> offset)
|
||||||
|
{
|
||||||
|
Scheduler.AddOnce(updateOffset);
|
||||||
|
|
||||||
|
void updateOffset()
|
||||||
|
{
|
||||||
|
// ensure the previous write has completed. ignoring performance concerns, if we don't do this, the async writes could be out of sequence.
|
||||||
|
if (realmWriteTask?.IsCompleted == false)
|
||||||
|
{
|
||||||
|
Scheduler.AddOnce(updateOffset);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useAverageButton != null)
|
||||||
|
useAverageButton.Enabled.Value = !Precision.AlmostEquals(lastPlayAverage, -Current.Value, Current.Precision / 2);
|
||||||
|
|
||||||
|
realmWriteTask = realm.WriteAsync(r =>
|
||||||
|
{
|
||||||
|
var settings = r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID)?.UserSettings;
|
||||||
|
|
||||||
|
if (settings == null) // only the case for tests.
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (settings.Offset == Current.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
settings.Offset = Current.Value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scoreChanged(ValueChangedEvent<ScoreInfo> score)
|
||||||
|
{
|
||||||
|
referenceScoreContainer.Clear();
|
||||||
|
|
||||||
|
if (score.NewValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (score.NewValue.Mods.Any(m => !m.UserPlayable))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var hitEvents = score.NewValue.HitEvents;
|
||||||
|
|
||||||
|
if (!(hitEvents.CalculateAverageHitError() is double average))
|
||||||
|
return;
|
||||||
|
|
||||||
|
referenceScoreContainer.Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = BeatmapOffsetControlStrings.PreviousPlay
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (hitEvents.Count < 10)
|
||||||
|
{
|
||||||
|
referenceScoreContainer.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuTextFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Colour = colours.Red1,
|
||||||
|
Text = BeatmapOffsetControlStrings.PreviousPlayTooShortToUseForCalibration
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastPlayAverage = average;
|
||||||
|
|
||||||
|
referenceScoreContainer.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new HitEventTimingDistributionGraph(hitEvents)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 50,
|
||||||
|
},
|
||||||
|
new AverageHitError(hitEvents),
|
||||||
|
useAverageButton = new SettingsButton
|
||||||
|
{
|
||||||
|
Text = BeatmapOffsetControlStrings.CalibrateUsingLastPlay,
|
||||||
|
Action = () => Current.Value = -lastPlayAverage
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
beatmapOffsetSubscription?.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,6 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
private readonly PlayerCheckbox showStoryboardToggle;
|
private readonly PlayerCheckbox showStoryboardToggle;
|
||||||
private readonly PlayerCheckbox beatmapSkinsToggle;
|
private readonly PlayerCheckbox beatmapSkinsToggle;
|
||||||
private readonly PlayerCheckbox beatmapColorsToggle;
|
private readonly PlayerCheckbox beatmapColorsToggle;
|
||||||
private readonly PlayerCheckbox beatmapHitsoundsToggle;
|
|
||||||
|
|
||||||
public VisualSettings()
|
public VisualSettings()
|
||||||
: base("Visual Settings")
|
: base("Visual Settings")
|
||||||
@ -45,7 +44,6 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboard / Video" },
|
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboard / Video" },
|
||||||
beatmapSkinsToggle = new PlayerCheckbox { LabelText = "Beatmap skins" },
|
beatmapSkinsToggle = new PlayerCheckbox { LabelText = "Beatmap skins" },
|
||||||
beatmapColorsToggle = new PlayerCheckbox { LabelText = "Beatmap colours" },
|
beatmapColorsToggle = new PlayerCheckbox { LabelText = "Beatmap colours" },
|
||||||
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" }
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +55,6 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
showStoryboardToggle.Current = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
showStoryboardToggle.Current = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
beatmapSkinsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
|
beatmapSkinsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
|
||||||
beatmapColorsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapColours);
|
beatmapColorsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapColours);
|
||||||
beatmapHitsoundsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Online.Solo;
|
using osu.Game.Online.Solo;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (beatmapId <= 0)
|
if (beatmapId <= 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (rulesetId < 0 || rulesetId > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
|
if (!Ruleset.Value.IsLegacyRuleset())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
|
return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
|
||||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
performanceCache.CalculatePerformanceAsync(score, cancellationTokenSource.Token)
|
performanceCache.CalculatePerformanceAsync(score, cancellationTokenSource.Token)
|
||||||
.ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely().Total)), cancellationTokenSource.Token);
|
.ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely()?.Total)), cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +160,6 @@ namespace osu.Game.Screens.Ranking.Statistics
|
|||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Padding = new MarginPadding { Horizontal = 1 };
|
|
||||||
|
|
||||||
InternalChild = new Circle
|
InternalChild = new Circle
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
@ -98,6 +99,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
protected override APIRequest FetchScores(CancellationToken cancellationToken)
|
protected override APIRequest FetchScores(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var fetchBeatmapInfo = BeatmapInfo;
|
var fetchBeatmapInfo = BeatmapInfo;
|
||||||
|
var fetchRuleset = ruleset.Value ?? fetchBeatmapInfo.Ruleset;
|
||||||
|
|
||||||
if (fetchBeatmapInfo == null)
|
if (fetchBeatmapInfo == null)
|
||||||
{
|
{
|
||||||
@ -117,9 +119,15 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fetchRuleset.IsLegacyRuleset())
|
||||||
|
{
|
||||||
|
SetErrorState(LeaderboardState.RulesetUnavailable);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (fetchBeatmapInfo.OnlineID <= 0 || fetchBeatmapInfo.Status <= BeatmapOnlineStatus.Pending)
|
if (fetchBeatmapInfo.OnlineID <= 0 || fetchBeatmapInfo.Status <= BeatmapOnlineStatus.Pending)
|
||||||
{
|
{
|
||||||
SetErrorState(LeaderboardState.Unavailable);
|
SetErrorState(LeaderboardState.BeatmapUnavailable);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +145,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
else if (filterMods)
|
else if (filterMods)
|
||||||
requestMods = mods.Value;
|
requestMods = mods.Value;
|
||||||
|
|
||||||
var req = new GetScoresRequest(fetchBeatmapInfo, ruleset.Value ?? fetchBeatmapInfo.Ruleset, Scope, requestMods);
|
var req = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
|
||||||
|
|
||||||
req.Success += r =>
|
req.Success += r =>
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,8 @@ namespace osu.Game.Skinning.Editor
|
|||||||
{
|
{
|
||||||
public class SkinComponentToolbox : ScrollingToolboxGroup
|
public class SkinComponentToolbox : ScrollingToolboxGroup
|
||||||
{
|
{
|
||||||
|
public const float WIDTH = 200;
|
||||||
|
|
||||||
public Action<Type> RequestPlacement;
|
public Action<Type> RequestPlacement;
|
||||||
|
|
||||||
private const float component_display_scale = 0.8f;
|
private const float component_display_scale = 0.8f;
|
||||||
@ -41,7 +43,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
: base("Components", height)
|
: base("Components", height)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
Width = 200;
|
Width = WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -8,14 +8,14 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Screens.Edit.Components.Menus;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Skinning.Editor
|
namespace osu.Game.Skinning.Editor
|
||||||
{
|
{
|
||||||
@ -57,13 +57,43 @@ namespace osu.Game.Skinning.Editor
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
headerText = new OsuTextFlowContainer
|
new Container
|
||||||
{
|
{
|
||||||
TextAnchor = Anchor.TopCentre,
|
Name = "Top bar",
|
||||||
Padding = new MarginPadding(20),
|
RelativeSizeAxes = Axes.X,
|
||||||
Anchor = Anchor.TopCentre,
|
Depth = float.MinValue,
|
||||||
Origin = Anchor.TopCentre,
|
Height = 40,
|
||||||
RelativeSizeAxes = Axes.X
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new EditorMenuBar
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Items = new[]
|
||||||
|
{
|
||||||
|
new MenuItem("File")
|
||||||
|
{
|
||||||
|
Items = new[]
|
||||||
|
{
|
||||||
|
new EditorMenuItem("Save", MenuItemType.Standard, Save),
|
||||||
|
new EditorMenuItem("Revert to default", MenuItemType.Destructive, revert),
|
||||||
|
new EditorMenuItemSpacer(),
|
||||||
|
new EditorMenuItem("Exit", MenuItemType.Standard, Hide),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headerText = new OsuTextFlowContainer
|
||||||
|
{
|
||||||
|
TextAnchor = Anchor.TopRight,
|
||||||
|
Padding = new MarginPadding(5),
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new GridContainer
|
new GridContainer
|
||||||
{
|
{
|
||||||
@ -89,46 +119,6 @@ namespace osu.Game.Skinning.Editor
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SkinBlueprintContainer(targetScreen),
|
new SkinBlueprintContainer(targetScreen),
|
||||||
new TriangleButton
|
|
||||||
{
|
|
||||||
Margin = new MarginPadding(10),
|
|
||||||
Text = CommonStrings.ButtonsClose,
|
|
||||||
Width = 100,
|
|
||||||
Action = Hide,
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Spacing = new Vector2(5),
|
|
||||||
Padding = new MarginPadding
|
|
||||||
{
|
|
||||||
Top = 10,
|
|
||||||
Left = 10,
|
|
||||||
},
|
|
||||||
Margin = new MarginPadding
|
|
||||||
{
|
|
||||||
Right = 10,
|
|
||||||
Bottom = 10,
|
|
||||||
},
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new TriangleButton
|
|
||||||
{
|
|
||||||
Text = "Save Changes",
|
|
||||||
Width = 140,
|
|
||||||
Action = Save,
|
|
||||||
},
|
|
||||||
new DangerousTriangleButton
|
|
||||||
{
|
|
||||||
Text = "Revert to default",
|
|
||||||
Width = 140,
|
|
||||||
Action = revert,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -161,7 +151,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
{
|
{
|
||||||
headerText.Clear();
|
headerText.Clear();
|
||||||
|
|
||||||
headerText.AddParagraph("Skin editor", cp => cp.Font = OsuFont.Default.With(size: 24));
|
headerText.AddParagraph("Skin editor", cp => cp.Font = OsuFont.Default.With(size: 16));
|
||||||
headerText.NewParagraph();
|
headerText.NewParagraph();
|
||||||
headerText.AddText("Currently editing ", cp =>
|
headerText.AddText("Currently editing ", cp =>
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ using JetBrains.Annotations;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -100,30 +101,14 @@ namespace osu.Game.Skinning.Editor
|
|||||||
{
|
{
|
||||||
if (visibility.NewValue == Visibility.Visible)
|
if (visibility.NewValue == Visibility.Visible)
|
||||||
{
|
{
|
||||||
updateMasking();
|
target.SetCustomRect(new RectangleF(0.18f, 0.1f, VISIBLE_TARGET_SCALE, VISIBLE_TARGET_SCALE), true);
|
||||||
target.AllowScaling = false;
|
|
||||||
target.RelativePositionAxes = Axes.Both;
|
|
||||||
|
|
||||||
target.ScaleTo(VISIBLE_TARGET_SCALE, SkinEditor.TRANSITION_DURATION, Easing.OutQuint);
|
|
||||||
target.MoveToX(0.095f, SkinEditor.TRANSITION_DURATION, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
target.AllowScaling = true;
|
target.SetCustomRect(null);
|
||||||
|
|
||||||
target.ScaleTo(1, SkinEditor.TRANSITION_DURATION, Easing.OutQuint).OnComplete(_ => updateMasking());
|
|
||||||
target.MoveToX(0f, SkinEditor.TRANSITION_DURATION, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMasking()
|
|
||||||
{
|
|
||||||
if (skinEditor == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
target.Masking = skinEditor.State.Value == Visibility.Visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user