mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:13:34 +08:00
Merge branch 'master' into medals
This commit is contained in:
commit
31f667224f
@ -7,6 +7,7 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.Win32;
|
||||
using osu.Desktop.Performance;
|
||||
using osu.Desktop.Security;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game;
|
||||
@ -15,9 +16,11 @@ using osu.Framework;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Updater;
|
||||
using osu.Desktop.Windows;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.IPC;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Performance;
|
||||
using osu.Game.Utils;
|
||||
using SDL2;
|
||||
|
||||
@ -28,6 +31,9 @@ namespace osu.Desktop
|
||||
private OsuSchemeLinkIPCChannel? osuSchemeLinkIPCChannel;
|
||||
private ArchiveImportIPCChannel? archiveImportIPCChannel;
|
||||
|
||||
[Cached(typeof(IHighPerformanceSessionManager))]
|
||||
private readonly HighPerformanceSessionManager highPerformanceSessionManager = new HighPerformanceSessionManager();
|
||||
|
||||
public OsuGameDesktop(string[]? args = null)
|
||||
: base(args)
|
||||
{
|
||||
|
43
osu.Desktop/Performance/HighPerformanceSessionManager.cs
Normal file
43
osu.Desktop/Performance/HighPerformanceSessionManager.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// 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.Runtime;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Performance;
|
||||
|
||||
namespace osu.Desktop.Performance
|
||||
{
|
||||
public class HighPerformanceSessionManager : IHighPerformanceSessionManager
|
||||
{
|
||||
private GCLatencyMode originalGCMode;
|
||||
|
||||
public IDisposable BeginSession()
|
||||
{
|
||||
enableHighPerformanceSession();
|
||||
return new InvokeOnDisposal<HighPerformanceSessionManager>(this, static m => m.disableHighPerformanceSession());
|
||||
}
|
||||
|
||||
private void enableHighPerformanceSession()
|
||||
{
|
||||
Logger.Log("Starting high performance session");
|
||||
|
||||
originalGCMode = GCSettings.LatencyMode;
|
||||
GCSettings.LatencyMode = GCLatencyMode.LowLatency;
|
||||
|
||||
// Without doing this, the new GC mode won't kick in until the next GC, which could be at a more noticeable point in time.
|
||||
GC.Collect(0);
|
||||
}
|
||||
|
||||
private void disableHighPerformanceSession()
|
||||
{
|
||||
Logger.Log("Ending high performance session");
|
||||
|
||||
if (GCSettings.LatencyMode == GCLatencyMode.LowLatency)
|
||||
GCSettings.LatencyMode = originalGCMode;
|
||||
|
||||
// No GC.Collect() as we were already collecting at a higher frequency in the old mode.
|
||||
}
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
protected override IEnumerable<Drawable> DimmablePieces => new Drawable[]
|
||||
{
|
||||
HeadCircle,
|
||||
// HeadCircle should not be added to this list, as it handles dimming itself
|
||||
TailCircle,
|
||||
repeatContainer,
|
||||
Body,
|
||||
|
@ -28,6 +28,21 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddAssert("state is top level", () => buttons.State == ButtonSystemState.TopLevel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFastShortcutKeys()
|
||||
{
|
||||
AddAssert("state is initial", () => buttons.State == ButtonSystemState.Initial);
|
||||
|
||||
AddStep("press P three times", () =>
|
||||
{
|
||||
InputManager.Key(Key.P);
|
||||
InputManager.Key(Key.P);
|
||||
InputManager.Key(Key.P);
|
||||
});
|
||||
|
||||
AddAssert("entered song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShortcutKeys()
|
||||
{
|
||||
|
@ -17,12 +17,15 @@ namespace osu.Game.Audio.Effects
|
||||
/// </summary>
|
||||
public const int MAX_LOWPASS_CUTOFF = 22049; // nyquist - 1hz
|
||||
|
||||
/// <summary>
|
||||
/// Whether this filter is currently attached to the audio track and thus applying an adjustment.
|
||||
/// </summary>
|
||||
public bool IsAttached { get; private set; }
|
||||
|
||||
private readonly AudioMixer mixer;
|
||||
private readonly BQFParameters filter;
|
||||
private readonly BQFType type;
|
||||
|
||||
private bool isAttached;
|
||||
|
||||
private readonly Cached filterApplication = new Cached();
|
||||
|
||||
private int cutoff;
|
||||
@ -132,22 +135,22 @@ namespace osu.Game.Audio.Effects
|
||||
|
||||
private void ensureAttached()
|
||||
{
|
||||
if (isAttached)
|
||||
if (IsAttached)
|
||||
return;
|
||||
|
||||
Debug.Assert(!mixer.Effects.Contains(filter));
|
||||
mixer.Effects.Add(filter);
|
||||
isAttached = true;
|
||||
IsAttached = true;
|
||||
}
|
||||
|
||||
private void ensureDetached()
|
||||
{
|
||||
if (!isAttached)
|
||||
if (!IsAttached)
|
||||
return;
|
||||
|
||||
Debug.Assert(mixer.Effects.Contains(filter));
|
||||
mixer.Effects.Remove(filter);
|
||||
isAttached = false;
|
||||
IsAttached = false;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -115,6 +115,11 @@ namespace osu.Game.Collections
|
||||
};
|
||||
}
|
||||
|
||||
public override bool IsPresent => base.IsPresent
|
||||
// Safety for low pass filter potentially getting stuck in applied state due to
|
||||
// transforms on `this` causing children to no longer be updated.
|
||||
|| lowPassFilter.IsAttached;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
lowPassFilter.CutoffTo(300, 100, Easing.OutCubic);
|
||||
|
@ -220,12 +220,16 @@ namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
activeCursor.FadeTo(1, 250, Easing.OutQuint);
|
||||
activeCursor.ScaleTo(1, 400, Easing.OutQuint);
|
||||
activeCursor.RotateTo(0, 400, Easing.OutQuint);
|
||||
dragRotationState = DragRotationState.NotDragging;
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
activeCursor.FadeTo(0, 250, Easing.OutQuint);
|
||||
activeCursor.ScaleTo(0.6f, 250, Easing.In);
|
||||
activeCursor.RotateTo(0, 400, Easing.OutQuint);
|
||||
dragRotationState = DragRotationState.NotDragging;
|
||||
}
|
||||
|
||||
private void playTapSample(double baseFrequency = 1f)
|
||||
|
@ -55,7 +55,6 @@ using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Overlays.SkinEditor;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using osu.Game.Performance;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
@ -792,8 +791,6 @@ namespace osu.Game
|
||||
|
||||
protected virtual UpdateManager CreateUpdateManager() => new UpdateManager();
|
||||
|
||||
protected virtual HighPerformanceSession CreateHighPerformanceSession() => new HighPerformanceSession();
|
||||
|
||||
protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything);
|
||||
|
||||
#region Beatmap progression
|
||||
@ -1089,8 +1086,6 @@ namespace osu.Game
|
||||
loadComponentSingleFile<IDialogOverlay>(new DialogOverlay(), topMostOverlayContent.Add, true);
|
||||
loadComponentSingleFile(new MedalOverlay(), topMostOverlayContent.Add);
|
||||
|
||||
loadComponentSingleFile(CreateHighPerformanceSession(), Add);
|
||||
|
||||
loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add);
|
||||
|
||||
Add(difficultyRecommender);
|
||||
|
@ -27,6 +27,12 @@ namespace osu.Game.Overlays
|
||||
|
||||
public PopupDialog CurrentDialog { get; private set; }
|
||||
|
||||
public override bool IsPresent => Scheduler.HasPendingTasks
|
||||
|| dialogContainer.Children.Count > 0
|
||||
// Safety for low pass filter potentially getting stuck in applied state due to
|
||||
// transforms on `this` causing children to no longer be updated.
|
||||
|| lowPassFilter.IsAttached;
|
||||
|
||||
public DialogOverlay()
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
@ -95,8 +101,6 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsPresent => Scheduler.HasPendingTasks || dialogContainer.Children.Count > 0;
|
||||
|
||||
protected override bool BlockNonPositionalInput => true;
|
||||
|
||||
protected override void PopIn()
|
||||
|
@ -67,8 +67,25 @@ namespace osu.Game.Overlays.Mods
|
||||
private IModHotkeyHandler hotkeyHandler = null!;
|
||||
|
||||
private Task? latestLoadTask;
|
||||
private ICollection<ModPanel>? latestLoadedPanels;
|
||||
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && latestLoadedPanels?.All(panel => panel.Parent != null) == true;
|
||||
private ModPanel[]? latestLoadedPanels;
|
||||
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && allPanelsLoaded;
|
||||
|
||||
private bool allPanelsLoaded
|
||||
{
|
||||
get
|
||||
{
|
||||
if (latestLoadedPanels == null)
|
||||
return false;
|
||||
|
||||
foreach (var panel in latestLoadedPanels)
|
||||
{
|
||||
if (panel.Parent == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||
|
||||
|
@ -15,6 +15,7 @@ using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -349,15 +350,18 @@ namespace osu.Game.Overlays.Mods
|
||||
});
|
||||
}
|
||||
|
||||
private static readonly LocalisableString input_search_placeholder = Resources.Localisation.Web.CommonStrings.InputSearch;
|
||||
private static readonly LocalisableString tab_to_search_placeholder = ModSelectOverlayStrings.TabToSearch;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? Resources.Localisation.Web.CommonStrings.InputSearch : ModSelectOverlayStrings.TabToSearch;
|
||||
SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? input_search_placeholder : tab_to_search_placeholder;
|
||||
|
||||
if (beatmapAttributesDisplay != null)
|
||||
{
|
||||
float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X;
|
||||
float rightEdgeOfLastButton = footerButtonFlow[^1].ScreenSpaceDrawQuad.TopRight.X;
|
||||
|
||||
// this is cheating a bit; the 640 value is hardcoded based on how wide the expanded panel _generally_ is.
|
||||
// due to the transition applied, the raw screenspace quad of the panel cannot be used, as it will trigger an ugly feedback cycle of expanding and collapsing.
|
||||
|
@ -1,42 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Performance
|
||||
{
|
||||
public partial class HighPerformanceSession : Component
|
||||
{
|
||||
private readonly IBindable<bool> localUserPlaying = new Bindable<bool>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ILocalUserPlayInfo localUserInfo)
|
||||
{
|
||||
localUserPlaying.BindTo(localUserInfo.IsPlaying);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
localUserPlaying.BindValueChanged(playing =>
|
||||
{
|
||||
if (playing.NewValue)
|
||||
EnableHighPerformanceSession();
|
||||
else
|
||||
DisableHighPerformanceSession();
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected virtual void EnableHighPerformanceSession()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void DisableHighPerformanceSession()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
23
osu.Game/Performance/IHighPerformanceSessionManager.cs
Normal file
23
osu.Game/Performance/IHighPerformanceSessionManager.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Performance
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows creating a temporary "high performance" session, with the goal of optimising runtime
|
||||
/// performance for gameplay purposes.
|
||||
///
|
||||
/// On desktop platforms, this will set a low latency GC mode which collects more frequently to avoid
|
||||
/// GC spikes.
|
||||
/// </summary>
|
||||
public interface IHighPerformanceSessionManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Start a new high performance session.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IDisposable"/> which will end the session when disposed.</returns>
|
||||
IDisposable BeginSession();
|
||||
}
|
||||
}
|
@ -64,6 +64,10 @@ namespace osu.Game.Screens.Menu
|
||||
private Sample? sampleHover;
|
||||
private SampleChannel? sampleChannel;
|
||||
|
||||
public override bool IsPresent => base.IsPresent
|
||||
// Allow keyboard interaction based on state rather than waiting for delayed animations.
|
||||
|| state == ButtonState.Expanded;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action? clickAction = null, float extraWidth = 0, params Key[] triggerKeys)
|
||||
|
@ -25,6 +25,7 @@ using osu.Game.Input;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Performance;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Skinning;
|
||||
@ -78,8 +79,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private readonly BindableDouble volumeAdjustment = new BindableDouble(1);
|
||||
|
||||
private AudioFilter lowPassFilter = null!;
|
||||
private AudioFilter highPassFilter = null!;
|
||||
private AudioFilter? lowPassFilter;
|
||||
private AudioFilter? highPassFilter;
|
||||
|
||||
private SkinnableSound sampleRestart = null!;
|
||||
|
||||
@ -140,6 +141,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private bool quickRestart;
|
||||
|
||||
private IDisposable? highPerformanceSession;
|
||||
|
||||
[Resolved]
|
||||
private INotificationOverlay? notificationOverlay { get; set; }
|
||||
|
||||
@ -152,13 +155,16 @@ namespace osu.Game.Screens.Play
|
||||
[Resolved]
|
||||
private BatteryInfo? batteryInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IHighPerformanceSessionManager? highPerformanceSessionManager { get; set; }
|
||||
|
||||
public PlayerLoader(Func<Player> createPlayer)
|
||||
{
|
||||
this.createPlayer = createPlayer;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(SessionStatics sessionStatics, AudioManager audio, OsuConfigManager config)
|
||||
private void load(SessionStatics sessionStatics, OsuConfigManager config)
|
||||
{
|
||||
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
|
||||
batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce);
|
||||
@ -205,8 +211,6 @@ namespace osu.Game.Screens.Play
|
||||
},
|
||||
},
|
||||
idleTracker = new IdleTracker(750),
|
||||
lowPassFilter = new AudioFilter(audio.TrackMixer),
|
||||
highPassFilter = new AudioFilter(audio.TrackMixer, BQFType.HighPass),
|
||||
sampleRestart = new SkinnableSound(new SampleInfo(@"Gameplay/restart", @"pause-retry-click"))
|
||||
};
|
||||
|
||||
@ -264,6 +268,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
Debug.Assert(CurrentPlayer != null);
|
||||
|
||||
highPerformanceSession?.Dispose();
|
||||
highPerformanceSession = null;
|
||||
|
||||
// prepare for a retry.
|
||||
CurrentPlayer = null;
|
||||
playerConsumed = false;
|
||||
@ -284,8 +291,9 @@ namespace osu.Game.Screens.Play
|
||||
// stop the track before removing adjustment to avoid a volume spike.
|
||||
Beatmap.Value.Track.Stop();
|
||||
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
|
||||
highPassFilter.CutoffTo(0);
|
||||
|
||||
lowPassFilter?.RemoveAndDisposeImmediately();
|
||||
highPassFilter?.RemoveAndDisposeImmediately();
|
||||
}
|
||||
|
||||
public override bool OnExiting(ScreenExitEvent e)
|
||||
@ -304,6 +312,9 @@ namespace osu.Game.Screens.Play
|
||||
BackgroundBrightnessReduction = false;
|
||||
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||
|
||||
highPerformanceSession?.Dispose();
|
||||
highPerformanceSession = null;
|
||||
|
||||
return base.OnExiting(e);
|
||||
}
|
||||
|
||||
@ -425,6 +436,12 @@ namespace osu.Game.Screens.Play
|
||||
settingsScroll.FadeInFromZero(500, Easing.Out)
|
||||
.MoveToX(0, 500, Easing.OutQuint);
|
||||
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
lowPassFilter = new AudioFilter(audioManager.TrackMixer),
|
||||
highPassFilter = new AudioFilter(audioManager.TrackMixer, BQFType.HighPass),
|
||||
});
|
||||
|
||||
lowPassFilter.CutoffTo(1000, 650, Easing.OutQuint);
|
||||
highPassFilter.CutoffTo(300).Then().CutoffTo(0, 1250); // 1250 is to line up with the appearance of MetadataInfo (750 delay + 500 fade-in)
|
||||
|
||||
@ -437,13 +454,23 @@ namespace osu.Game.Screens.Play
|
||||
content.StopTracking();
|
||||
|
||||
content.ScaleTo(0.7f, CONTENT_OUT_DURATION * 2, Easing.OutQuint);
|
||||
content.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint);
|
||||
content.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint)
|
||||
// Safety for filter potentially getting stuck in applied state due to
|
||||
// transforms on `this` causing children to no longer be updated.
|
||||
.OnComplete(_ =>
|
||||
{
|
||||
highPassFilter?.RemoveAndDisposeImmediately();
|
||||
highPassFilter = null;
|
||||
|
||||
lowPassFilter?.RemoveAndDisposeImmediately();
|
||||
lowPassFilter = null;
|
||||
});
|
||||
|
||||
settingsScroll.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint)
|
||||
.MoveToX(settingsScroll.DrawWidth, CONTENT_OUT_DURATION * 2, Easing.OutQuint);
|
||||
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, CONTENT_OUT_DURATION);
|
||||
highPassFilter.CutoffTo(0, CONTENT_OUT_DURATION);
|
||||
lowPassFilter?.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, CONTENT_OUT_DURATION);
|
||||
highPassFilter?.CutoffTo(0, CONTENT_OUT_DURATION);
|
||||
}
|
||||
|
||||
private void pushWhenLoaded()
|
||||
@ -463,6 +490,10 @@ namespace osu.Game.Screens.Play
|
||||
if (scheduledPushPlayer != null)
|
||||
return;
|
||||
|
||||
// Now that everything's been loaded, we can safely switch to a higher performance session without incurring too much overhead.
|
||||
// Doing this prior to the game being pushed gives us a bit of time to stabilise into the high performance mode before gameplay starts.
|
||||
highPerformanceSession ??= highPerformanceSessionManager?.BeginSession();
|
||||
|
||||
scheduledPushPlayer = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
// ensure that once we have reached this "point of no return", readyForPush will be false for all future checks (until a new player instance is prepared).
|
||||
|
Loading…
Reference in New Issue
Block a user