mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 00:12:55 +08:00
Merge branch 'master' into remove-nullable-disable-in-the-mods-for-catch-ruleset
This commit is contained in:
commit
046a28f9b1
@ -108,6 +108,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Version = "2018.712.0",
|
||||
DisplayVersion = "2018.712.0",
|
||||
UpdateStream = streams[OsuGameBase.CLIENT_STREAM_NAME],
|
||||
CreatedAt = new DateTime(2018, 7, 12),
|
||||
ChangelogEntries = new List<APIChangelogEntry>
|
||||
{
|
||||
new APIChangelogEntry
|
||||
@ -171,6 +172,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
Version = "2019.920.0",
|
||||
DisplayVersion = "2019.920.0",
|
||||
CreatedAt = new DateTime(2019, 9, 20),
|
||||
UpdateStream = new APIUpdateStream
|
||||
{
|
||||
Name = "Test",
|
||||
|
@ -71,6 +71,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
carousel.UpdateBeatmapSet(testBeatmapSetInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("only one set visible", () => carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().Count() == 1);
|
||||
AddUntilStep("update button visible", () => getUpdateButton() != null);
|
||||
|
||||
AddStep("click button", () => getUpdateButton()?.TriggerClick());
|
||||
@ -120,6 +121,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
carousel.UpdateBeatmapSet(testBeatmapSetInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("only one set visible", () => carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().Count() == 1);
|
||||
AddUntilStep("update button visible", () => getUpdateButton() != null);
|
||||
|
||||
AddStep("click button", () => getUpdateButton()?.TriggerClick());
|
||||
|
51
osu.Game.Tests/Visual/UserInterface/TestSceneFPSCounter.cs
Normal file
51
osu.Game.Tests/Visual/UserInterface/TestSceneFPSCounter.cs
Normal file
@ -0,0 +1,51 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneFPSCounter : OsuTestScene
|
||||
{
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("create display", () =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.White,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FPSCounter(),
|
||||
new FPSCounter { Scale = new Vector2(2) },
|
||||
new FPSCounter { Scale = new Vector2(4) },
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -224,6 +224,12 @@ namespace osu.Game.Configuration
|
||||
|
||||
return new TrackedSettings
|
||||
{
|
||||
new TrackedSetting<bool>(OsuSetting.ShowFpsDisplay, state => new SettingDescription(
|
||||
rawValue: state,
|
||||
name: GlobalActionKeyBindingStrings.ToggleFPSCounter,
|
||||
value: state ? CommonStrings.Enabled.ToLower() : CommonStrings.Disabled.ToLower(),
|
||||
shortcut: LookupKeyBindings(GlobalAction.ToggleFPSDisplay))
|
||||
),
|
||||
new TrackedSetting<bool>(OsuSetting.MouseDisableButtons, disabledState => new SettingDescription(
|
||||
rawValue: !disabledState,
|
||||
name: GlobalActionKeyBindingStrings.ToggleGameplayMouseButtons,
|
||||
|
@ -28,7 +28,8 @@ namespace osu.Game.Graphics.Containers
|
||||
public class BeatSyncedContainer : Container
|
||||
{
|
||||
private int lastBeat;
|
||||
private TimingControlPoint lastTimingPoint;
|
||||
protected TimingControlPoint LastTimingPoint { get; private set; }
|
||||
protected EffectControlPoint LastEffectPoint { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of time before a beat we should fire <see cref="OnNewBeat(int, TimingControlPoint, EffectControlPoint, ChannelAmplitudes)"/>.
|
||||
@ -127,7 +128,7 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
TimeSinceLastBeat = beatLength - TimeUntilNextBeat;
|
||||
|
||||
if (ReferenceEquals(timingPoint, lastTimingPoint) && beatIndex == lastBeat)
|
||||
if (ReferenceEquals(timingPoint, LastTimingPoint) && beatIndex == lastBeat)
|
||||
return;
|
||||
|
||||
// as this event is sometimes used for sound triggers where `BeginDelayedSequence` has no effect, avoid firing it if too far away from the beat.
|
||||
@ -139,7 +140,8 @@ namespace osu.Game.Graphics.Containers
|
||||
}
|
||||
|
||||
lastBeat = beatIndex;
|
||||
lastTimingPoint = timingPoint;
|
||||
LastTimingPoint = timingPoint;
|
||||
LastEffectPoint = effectPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
302
osu.Game/Graphics/UserInterface/FPSCounter.cs
Normal file
302
osu.Game/Graphics/UserInterface/FPSCounter.cs
Normal file
@ -0,0 +1,302 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class FPSCounter : VisibilityContainer, IHasCustomTooltip
|
||||
{
|
||||
private RollingCounter<double> counterUpdateFrameTime = null!;
|
||||
private RollingCounter<double> counterDrawFPS = null!;
|
||||
|
||||
private Container mainContent = null!;
|
||||
|
||||
private Container background = null!;
|
||||
|
||||
private Container counters = null!;
|
||||
|
||||
private const float idle_background_alpha = 0.4f;
|
||||
|
||||
private readonly BindableBool showFpsDisplay = new BindableBool(true);
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
public FPSCounter()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
mainContent = new Container
|
||||
{
|
||||
Alpha = 0,
|
||||
Height = 26,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CornerRadius = 5,
|
||||
CornerExponent = 5f,
|
||||
Masking = true,
|
||||
Alpha = idle_background_alpha,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray0,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
}
|
||||
},
|
||||
counters = new Container
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
counterUpdateFrameTime = new FrameTimeCounter
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Margin = new MarginPadding(1),
|
||||
Y = -2,
|
||||
},
|
||||
counterDrawFPS = new FramesPerSecondCounter
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Margin = new MarginPadding(2),
|
||||
Y = 10,
|
||||
Scale = new Vector2(0.8f),
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
config.BindWith(OsuSetting.ShowFpsDisplay, showFpsDisplay);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
displayTemporarily();
|
||||
|
||||
showFpsDisplay.BindValueChanged(showFps =>
|
||||
{
|
||||
State.Value = showFps.NewValue ? Visibility.Visible : Visibility.Hidden;
|
||||
if (showFps.NewValue)
|
||||
displayTemporarily();
|
||||
}, true);
|
||||
|
||||
State.BindValueChanged(state => showFpsDisplay.Value = state.NewValue == Visibility.Visible);
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(100);
|
||||
|
||||
protected override void PopOut() => this.FadeOut(100);
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
background.FadeTo(1, 200);
|
||||
displayTemporarily();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
background.FadeTo(idle_background_alpha, 200);
|
||||
displayTemporarily();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private bool isDisplayed;
|
||||
|
||||
private ScheduledDelegate? fadeOutDelegate;
|
||||
|
||||
private double aimDrawFPS;
|
||||
private double aimUpdateFPS;
|
||||
|
||||
private void displayTemporarily()
|
||||
{
|
||||
if (!isDisplayed)
|
||||
{
|
||||
mainContent.FadeTo(1, 300, Easing.OutQuint);
|
||||
isDisplayed = true;
|
||||
}
|
||||
|
||||
fadeOutDelegate?.Cancel();
|
||||
fadeOutDelegate = null;
|
||||
|
||||
if (!IsHovered)
|
||||
{
|
||||
fadeOutDelegate = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
mainContent.FadeTo(0, 300, Easing.OutQuint);
|
||||
isDisplayed = false;
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private GameHost gameHost { get; set; } = null!;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
mainContent.Width = Math.Max(mainContent.Width, counters.DrawWidth);
|
||||
|
||||
// Handle the case where the window has become inactive or the user changed the
|
||||
// frame limiter (we want to show the FPS as it's changing, even if it isn't an outlier).
|
||||
bool aimRatesChanged = updateAimFPS();
|
||||
|
||||
// TODO: this is wrong (elapsed clock time, not actual run time).
|
||||
double newUpdateFrameTime = gameHost.UpdateThread.Clock.ElapsedFrameTime;
|
||||
double newDrawFrameTime = gameHost.DrawThread.Clock.ElapsedFrameTime;
|
||||
double newDrawFps = gameHost.DrawThread.Clock.FramesPerSecond;
|
||||
|
||||
const double spike_time_ms = 20;
|
||||
|
||||
bool hasUpdateSpike = counterUpdateFrameTime.Current.Value < spike_time_ms && newUpdateFrameTime > spike_time_ms;
|
||||
// use elapsed frame time rather then FramesPerSecond to better catch stutter frames.
|
||||
bool hasDrawSpike = counterDrawFPS.Current.Value > (1000 / spike_time_ms) && newDrawFrameTime > spike_time_ms;
|
||||
|
||||
// If the frame time spikes up, make sure it shows immediately on the counter.
|
||||
if (hasUpdateSpike)
|
||||
counterUpdateFrameTime.SetCountWithoutRolling(newUpdateFrameTime);
|
||||
else
|
||||
counterUpdateFrameTime.Current.Value = newUpdateFrameTime;
|
||||
|
||||
if (hasDrawSpike)
|
||||
// show spike time using raw elapsed value, to account for `FramesPerSecond` being so averaged spike frames don't show.
|
||||
counterDrawFPS.SetCountWithoutRolling(1000 / newDrawFrameTime);
|
||||
else
|
||||
counterDrawFPS.Current.Value = newDrawFps;
|
||||
|
||||
counterDrawFPS.Colour = getColour(counterDrawFPS.DisplayedCount / aimDrawFPS);
|
||||
|
||||
double displayedUpdateFPS = 1000 / counterUpdateFrameTime.DisplayedCount;
|
||||
counterUpdateFrameTime.Colour = getColour(displayedUpdateFPS / aimUpdateFPS);
|
||||
|
||||
bool hasSignificantChanges = aimRatesChanged
|
||||
|| hasDrawSpike
|
||||
|| hasUpdateSpike
|
||||
|| counterDrawFPS.DisplayedCount < aimDrawFPS * 0.8
|
||||
|| displayedUpdateFPS < aimUpdateFPS * 0.8;
|
||||
|
||||
if (hasSignificantChanges)
|
||||
displayTemporarily();
|
||||
}
|
||||
|
||||
private bool updateAimFPS()
|
||||
{
|
||||
if (gameHost.UpdateThread.Clock.Throttling)
|
||||
{
|
||||
double newAimDrawFPS = gameHost.DrawThread.Clock.MaximumUpdateHz;
|
||||
double newAimUpdateFPS = gameHost.UpdateThread.Clock.MaximumUpdateHz;
|
||||
|
||||
if (aimDrawFPS != newAimDrawFPS || aimUpdateFPS != newAimUpdateFPS)
|
||||
{
|
||||
aimDrawFPS = newAimDrawFPS;
|
||||
aimUpdateFPS = newAimUpdateFPS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double newAimFPS = gameHost.InputThread.Clock.MaximumUpdateHz;
|
||||
|
||||
if (aimDrawFPS != newAimFPS || aimUpdateFPS != newAimFPS)
|
||||
{
|
||||
aimUpdateFPS = aimDrawFPS = newAimFPS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private ColourInfo getColour(double performanceRatio)
|
||||
{
|
||||
if (performanceRatio < 0.5f)
|
||||
return Interpolation.ValueAt(performanceRatio, colours.Red, colours.Orange2, 0, 0.5);
|
||||
|
||||
return Interpolation.ValueAt(performanceRatio, colours.Orange2, colours.Lime0, 0.5, 0.9);
|
||||
}
|
||||
|
||||
public ITooltip GetCustomTooltip() => new FPSCounterTooltip();
|
||||
|
||||
public object TooltipContent => this;
|
||||
|
||||
public class FramesPerSecondCounter : RollingCounter<double>
|
||||
{
|
||||
protected override double RollingDuration => 1000;
|
||||
|
||||
protected override OsuSpriteText CreateSpriteText()
|
||||
{
|
||||
return new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Font = OsuFont.Default.With(fixedWidth: true, size: 16, weight: FontWeight.SemiBold),
|
||||
Spacing = new Vector2(-2),
|
||||
};
|
||||
}
|
||||
|
||||
protected override LocalisableString FormatCount(double count)
|
||||
{
|
||||
return $"{count:#,0}fps";
|
||||
}
|
||||
}
|
||||
|
||||
public class FrameTimeCounter : RollingCounter<double>
|
||||
{
|
||||
protected override double RollingDuration => 1000;
|
||||
|
||||
protected override OsuSpriteText CreateSpriteText()
|
||||
{
|
||||
return new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Font = OsuFont.Default.With(fixedWidth: true, size: 16, weight: FontWeight.SemiBold),
|
||||
Spacing = new Vector2(-1),
|
||||
};
|
||||
}
|
||||
|
||||
protected override LocalisableString FormatCount(double count)
|
||||
{
|
||||
if (count < 1)
|
||||
return $"{count:N1}ms";
|
||||
|
||||
return $"{count:N0}ms";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
97
osu.Game/Graphics/UserInterface/FPSCounterTooltip.cs
Normal file
97
osu.Game/Graphics/UserInterface/FPSCounterTooltip.cs
Normal file
@ -0,0 +1,97 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class FPSCounterTooltip : CompositeDrawable, ITooltip
|
||||
{
|
||||
private OsuTextFlowContainer textFlow = null!;
|
||||
|
||||
[Resolved]
|
||||
private GameHost gameHost { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
CornerRadius = 15;
|
||||
Masking = true;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray1,
|
||||
Alpha = 1,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuTextFlowContainer(cp =>
|
||||
{
|
||||
cp.Font = OsuFont.Default.With(weight: FontWeight.SemiBold);
|
||||
})
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
TextAnchor = Anchor.TopRight,
|
||||
Margin = new MarginPadding { Left = 5, Vertical = 10 },
|
||||
Text = string.Join('\n', gameHost.Threads.Select(t => t.Name))
|
||||
},
|
||||
textFlow = new OsuTextFlowContainer(cp =>
|
||||
{
|
||||
cp.Font = OsuFont.Default.With(fixedWidth: true, weight: FontWeight.Regular);
|
||||
cp.Spacing = new Vector2(-1);
|
||||
})
|
||||
{
|
||||
Width = 190,
|
||||
Margin = new MarginPadding { Left = 35, Right = 10, Vertical = 10 },
|
||||
AutoSizeAxes = Axes.Y,
|
||||
TextAnchor = Anchor.TopRight,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private int lastUpdate;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
int currentSecond = (int)(Clock.CurrentTime / 100);
|
||||
|
||||
if (currentSecond != lastUpdate)
|
||||
{
|
||||
lastUpdate = currentSecond;
|
||||
|
||||
textFlow.Clear();
|
||||
|
||||
foreach (var thread in gameHost.Threads)
|
||||
{
|
||||
var clock = thread.Clock;
|
||||
|
||||
string maximum = clock.Throttling
|
||||
? $"/{(clock.MaximumUpdateHz > 0 && clock.MaximumUpdateHz < 10000 ? clock.MaximumUpdateHz.ToString("0") : "∞"),4}"
|
||||
: string.Empty;
|
||||
|
||||
textFlow.AddParagraph($"{clock.FramesPerSecond:0}{maximum}fps ({clock.ElapsedFrameTime:0.00}ms)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetContent(object content)
|
||||
{
|
||||
}
|
||||
|
||||
public void Move(Vector2 pos)
|
||||
{
|
||||
Position = pos;
|
||||
}
|
||||
}
|
||||
}
|
@ -45,6 +45,7 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial),
|
||||
new KeyBinding(InputKey.F10, GlobalAction.ToggleGameplayMouseButtons),
|
||||
new KeyBinding(InputKey.F12, GlobalAction.TakeScreenshot),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.F }, GlobalAction.ToggleFPSDisplay),
|
||||
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
|
||||
@ -328,5 +329,8 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTapForBPM))]
|
||||
EditorTapForBPM,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleFPSCounter))]
|
||||
ToggleFPSDisplay,
|
||||
}
|
||||
}
|
||||
|
@ -274,6 +274,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ToggleSkinEditor => new TranslatableString(getKey(@"toggle_skin_editor"), @"Toggle skin editor");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle FPS counter"
|
||||
/// </summary>
|
||||
public static LocalisableString ToggleFPSCounter => new TranslatableString(getKey(@"toggle_fps_counter"), @"Toggle FPS counter");
|
||||
|
||||
/// <summary>
|
||||
/// "Previous volume meter"
|
||||
/// </summary>
|
||||
|
@ -159,6 +159,8 @@ namespace osu.Game
|
||||
|
||||
protected FirstRunSetupOverlay FirstRunOverlay { get; private set; }
|
||||
|
||||
private FPSCounter fpsCounter;
|
||||
|
||||
private VolumeOverlay volume;
|
||||
|
||||
private OsuLogo osuLogo;
|
||||
@ -814,6 +816,13 @@ namespace osu.Game
|
||||
ScreenStack.ScreenPushed += screenPushed;
|
||||
ScreenStack.ScreenExited += screenExited;
|
||||
|
||||
loadComponentSingleFile(fpsCounter = new FPSCounter
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Margin = new MarginPadding(5),
|
||||
}, topMostOverlayContent.Add);
|
||||
|
||||
if (!args?.Any(a => a == @"--no-version-overlay") ?? true)
|
||||
loadComponentSingleFile(versionManager = new VersionManager { Depth = int.MinValue }, ScreenContainer.Add);
|
||||
|
||||
@ -1114,6 +1123,10 @@ namespace osu.Game
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.ToggleFPSDisplay:
|
||||
fpsCounter.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleSkinEditor:
|
||||
skinEditor.ToggleVisibility();
|
||||
return true;
|
||||
|
@ -17,7 +17,6 @@ using osu.Framework.Development;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Performance;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Handlers;
|
||||
@ -192,8 +191,6 @@ namespace osu.Game
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
|
||||
private Bindable<bool> fpsDisplayVisible;
|
||||
|
||||
private readonly BindableNumber<double> globalTrackVolumeAdjust = new BindableNumber<double>(global_track_volume_adjust);
|
||||
|
||||
/// <summary>
|
||||
@ -406,19 +403,6 @@ namespace osu.Game
|
||||
AddFont(Resources, @"Fonts/Venera/Venera-Black");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// TODO: This is temporary until we reimplement the local FPS display.
|
||||
// It's just to allow end-users to access the framework FPS display without knowing the shortcut key.
|
||||
fpsDisplayVisible = LocalConfig.GetBindable<bool>(OsuSetting.ShowFpsDisplay);
|
||||
fpsDisplayVisible.ValueChanged += visible => { FrameStatistics.Value = visible.NewValue ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; };
|
||||
fpsDisplayVisible.TriggerChange();
|
||||
|
||||
FrameStatistics.ValueChanged += e => fpsDisplayVisible.Value = e.NewValue != FrameStatisticsMode.None;
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
|
||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
|
@ -90,6 +90,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private const double early_activation = 60;
|
||||
|
||||
private const float triangles_paused_velocity = 0.5f;
|
||||
|
||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||
|
||||
public OsuLogo()
|
||||
@ -319,6 +321,11 @@ namespace osu.Game.Screens.Menu
|
||||
.FadeTo(visualizer_default_alpha * 1.8f * amplitudeAdjust, early_activation, Easing.Out).Then()
|
||||
.FadeTo(visualizer_default_alpha, beatLength);
|
||||
}
|
||||
|
||||
this.Delay(early_activation).Schedule(() =>
|
||||
{
|
||||
triangles.Velocity += amplitudeAdjust * (effectPoint.KiaiMode ? 6 : 3);
|
||||
});
|
||||
}
|
||||
|
||||
public void PlayIntro()
|
||||
@ -340,22 +347,17 @@ namespace osu.Game.Screens.Menu
|
||||
base.Update();
|
||||
|
||||
const float scale_adjust_cutoff = 0.4f;
|
||||
const float velocity_adjust_cutoff = 0.98f;
|
||||
const float paused_velocity = 0.5f;
|
||||
|
||||
if (musicController.CurrentTrack.IsRunning)
|
||||
{
|
||||
float maxAmplitude = lastBeatIndex >= 0 ? musicController.CurrentTrack.CurrentAmplitudes.Maximum : 0;
|
||||
logoAmplitudeContainer.Scale = new Vector2((float)Interpolation.Damp(logoAmplitudeContainer.Scale.X, 1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.04f, 0.9f, Time.Elapsed));
|
||||
|
||||
if (maxAmplitude > velocity_adjust_cutoff)
|
||||
triangles.Velocity = 1 + Math.Max(0, maxAmplitude - velocity_adjust_cutoff) * 50;
|
||||
else
|
||||
triangles.Velocity = (float)Interpolation.Damp(triangles.Velocity, 1, 0.995f, Time.Elapsed);
|
||||
triangles.Velocity = (float)Interpolation.Damp(triangles.Velocity, triangles_paused_velocity * (LastEffectPoint.KiaiMode ? 4 : 2), 0.995f, Time.Elapsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
triangles.Velocity = paused_velocity;
|
||||
triangles.Velocity = (float)Interpolation.Damp(triangles.Velocity, triangles_paused_velocity, 0.9f, Time.Elapsed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private readonly NoResultsPlaceholder noResultsPlaceholder;
|
||||
|
||||
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
|
||||
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Items.OfType<CarouselBeatmapSet>();
|
||||
|
||||
// todo: only used for testing, maybe remove.
|
||||
private bool loadedTestBeatmaps;
|
||||
@ -121,7 +121,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
CarouselRoot newRoot = new CarouselRoot(this);
|
||||
|
||||
newRoot.AddChildren(beatmapSets.Select(s => createCarouselSet(s.Detach())).Where(g => g != null));
|
||||
newRoot.AddItems(beatmapSets.Select(s => createCarouselSet(s.Detach())).Where(g => g != null));
|
||||
|
||||
root = newRoot;
|
||||
|
||||
@ -300,7 +300,7 @@ namespace osu.Game.Screens.Select
|
||||
if (!root.BeatmapSetsByID.TryGetValue(beatmapSetID, out var existingSet))
|
||||
return;
|
||||
|
||||
root.RemoveChild(existingSet);
|
||||
root.RemoveItem(existingSet);
|
||||
itemsCache.Invalidate();
|
||||
|
||||
if (!Scroll.UserScrolling)
|
||||
@ -316,12 +316,17 @@ namespace osu.Game.Screens.Select
|
||||
previouslySelectedID = selectedBeatmap?.BeatmapInfo.ID;
|
||||
|
||||
var newSet = createCarouselSet(beatmapSet);
|
||||
var removedSet = root.RemoveChild(beatmapSet.ID);
|
||||
|
||||
root.RemoveChild(beatmapSet.ID);
|
||||
// If we don't remove this here, it may remain in a hidden state until scrolled off screen.
|
||||
// Doesn't really affect anything during actual user interaction, but makes testing annoying.
|
||||
var removedDrawable = Scroll.FirstOrDefault(c => c.Item == removedSet);
|
||||
if (removedDrawable != null)
|
||||
expirePanelImmediately(removedDrawable);
|
||||
|
||||
if (newSet != null)
|
||||
{
|
||||
root.AddChild(newSet);
|
||||
root.AddItem(newSet);
|
||||
|
||||
// check if we can/need to maintain our current selection.
|
||||
if (previouslySelectedID != null)
|
||||
@ -415,7 +420,7 @@ namespace osu.Game.Screens.Select
|
||||
if (selectedBeatmap == null)
|
||||
return;
|
||||
|
||||
var unfilteredDifficulties = selectedBeatmapSet.Children.Where(s => !s.Filtered.Value).ToList();
|
||||
var unfilteredDifficulties = selectedBeatmapSet.Items.Where(s => !s.Filtered.Value).ToList();
|
||||
|
||||
int index = unfilteredDifficulties.IndexOf(selectedBeatmap);
|
||||
|
||||
@ -696,11 +701,7 @@ namespace osu.Game.Screens.Select
|
||||
// panel loaded as drawable but not required by visible range.
|
||||
// remove but only if too far off-screen
|
||||
if (panel.Y + panel.DrawHeight < visibleUpperBound - distance_offscreen_before_unload || panel.Y > visibleBottomBound + distance_offscreen_before_unload)
|
||||
{
|
||||
// may want a fade effect here (could be seen if a huge change happens, like a set with 20 difficulties becomes selected).
|
||||
panel.ClearTransforms();
|
||||
panel.Expire();
|
||||
}
|
||||
expirePanelImmediately(panel);
|
||||
}
|
||||
|
||||
// Add those items within the previously found index range that should be displayed.
|
||||
@ -730,6 +731,13 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private static void expirePanelImmediately(DrawableCarouselItem panel)
|
||||
{
|
||||
// may want a fade effect here (could be seen if a huge change happens, like a set with 20 difficulties becomes selected).
|
||||
panel.ClearTransforms();
|
||||
panel.Expire();
|
||||
}
|
||||
|
||||
private readonly CarouselBoundsItem carouselBoundsItem = new CarouselBoundsItem();
|
||||
|
||||
private (int firstIndex, int lastIndex) getDisplayRange()
|
||||
@ -798,7 +806,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
scrollTarget = null;
|
||||
|
||||
foreach (CarouselItem item in root.Children)
|
||||
foreach (CarouselItem item in root.Items)
|
||||
{
|
||||
if (item.Filtered.Value)
|
||||
continue;
|
||||
@ -964,26 +972,31 @@ namespace osu.Game.Screens.Select
|
||||
this.carousel = carousel;
|
||||
}
|
||||
|
||||
public override void AddChild(CarouselItem i)
|
||||
public override void AddItem(CarouselItem i)
|
||||
{
|
||||
CarouselBeatmapSet set = (CarouselBeatmapSet)i;
|
||||
BeatmapSetsByID.Add(set.BeatmapSet.ID, set);
|
||||
|
||||
base.AddChild(i);
|
||||
base.AddItem(i);
|
||||
}
|
||||
|
||||
public void RemoveChild(Guid beatmapSetID)
|
||||
public CarouselBeatmapSet RemoveChild(Guid beatmapSetID)
|
||||
{
|
||||
if (BeatmapSetsByID.TryGetValue(beatmapSetID, out var carouselBeatmapSet))
|
||||
RemoveChild(carouselBeatmapSet);
|
||||
{
|
||||
RemoveItem(carouselBeatmapSet);
|
||||
return carouselBeatmapSet;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void RemoveChild(CarouselItem i)
|
||||
public override void RemoveItem(CarouselItem i)
|
||||
{
|
||||
CarouselBeatmapSet set = (CarouselBeatmapSet)i;
|
||||
BeatmapSetsByID.Remove(set.BeatmapSet.ID);
|
||||
|
||||
base.RemoveChild(i);
|
||||
base.RemoveItem(i);
|
||||
}
|
||||
|
||||
protected override void PerformSelection()
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
switch (State.Value)
|
||||
{
|
||||
case CarouselItemState.Selected:
|
||||
return DrawableCarouselBeatmapSet.HEIGHT + Children.Count(c => c.Visible) * DrawableCarouselBeatmap.HEIGHT;
|
||||
return DrawableCarouselBeatmapSet.HEIGHT + Items.Count(c => c.Visible) * DrawableCarouselBeatmap.HEIGHT;
|
||||
|
||||
default:
|
||||
return DrawableCarouselBeatmapSet.HEIGHT;
|
||||
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<CarouselBeatmap> Beatmaps => InternalChildren.OfType<CarouselBeatmap>();
|
||||
public IEnumerable<CarouselBeatmap> Beatmaps => Items.OfType<CarouselBeatmap>();
|
||||
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
|
||||
@ -44,15 +44,15 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
.OrderBy(b => b.Ruleset)
|
||||
.ThenBy(b => b.StarRating)
|
||||
.Select(b => new CarouselBeatmap(b))
|
||||
.ForEach(AddChild);
|
||||
.ForEach(AddItem);
|
||||
}
|
||||
|
||||
protected override CarouselItem GetNextToSelect()
|
||||
{
|
||||
if (LastSelected == null || LastSelected.Filtered.Value)
|
||||
{
|
||||
if (GetRecommendedBeatmap?.Invoke(Children.OfType<CarouselBeatmap>().Where(b => !b.Filtered.Value).Select(b => b.BeatmapInfo)) is BeatmapInfo recommended)
|
||||
return Children.OfType<CarouselBeatmap>().First(b => b.BeatmapInfo.Equals(recommended));
|
||||
if (GetRecommendedBeatmap?.Invoke(Items.OfType<CarouselBeatmap>().Where(b => !b.Filtered.Value).Select(b => b.BeatmapInfo)) is BeatmapInfo recommended)
|
||||
return Items.OfType<CarouselBeatmap>().First(b => b.BeatmapInfo.Equals(recommended));
|
||||
}
|
||||
|
||||
return base.GetNextToSelect();
|
||||
@ -122,7 +122,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
public override void Filter(FilterCriteria criteria)
|
||||
{
|
||||
base.Filter(criteria);
|
||||
Filtered.Value = InternalChildren.All(i => i.Filtered.Value);
|
||||
Filtered.Value = Items.All(i => i.Filtered.Value);
|
||||
}
|
||||
|
||||
public override string ToString() => BeatmapSet.ToString();
|
||||
|
@ -13,9 +13,9 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public override DrawableCarouselItem? CreateDrawableRepresentation() => null;
|
||||
|
||||
public IReadOnlyList<CarouselItem> Children => InternalChildren;
|
||||
public IReadOnlyList<CarouselItem> Items => items;
|
||||
|
||||
protected List<CarouselItem> InternalChildren = new List<CarouselItem>();
|
||||
private List<CarouselItem> items = new List<CarouselItem>();
|
||||
|
||||
/// <summary>
|
||||
/// Used to assign a monotonically increasing ID to children as they are added. This member is
|
||||
@ -27,16 +27,18 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private FilterCriteria? lastCriteria;
|
||||
|
||||
public virtual void RemoveChild(CarouselItem i)
|
||||
protected int GetIndexOfItem(CarouselItem lastSelected) => items.IndexOf(lastSelected);
|
||||
|
||||
public virtual void RemoveItem(CarouselItem i)
|
||||
{
|
||||
InternalChildren.Remove(i);
|
||||
items.Remove(i);
|
||||
|
||||
// it's important we do the deselection after removing, so any further actions based on
|
||||
// State.ValueChanged make decisions post-removal.
|
||||
i.State.Value = CarouselItemState.Collapsed;
|
||||
}
|
||||
|
||||
public virtual void AddChild(CarouselItem i)
|
||||
public virtual void AddItem(CarouselItem i)
|
||||
{
|
||||
i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue);
|
||||
i.ChildID = ++currentChildID;
|
||||
@ -45,21 +47,21 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
i.Filter(lastCriteria);
|
||||
|
||||
int index = InternalChildren.BinarySearch(i, criteriaComparer);
|
||||
int index = items.BinarySearch(i, criteriaComparer);
|
||||
if (index < 0) index = ~index; // BinarySearch hacks multiple return values with 2's complement.
|
||||
|
||||
InternalChildren.Insert(index, i);
|
||||
items.Insert(index, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// criteria may be null for initial population. the filtering will be applied post-add.
|
||||
InternalChildren.Add(i);
|
||||
items.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
public CarouselGroup(List<CarouselItem>? items = null)
|
||||
{
|
||||
if (items != null) InternalChildren = items;
|
||||
if (items != null) this.items = items;
|
||||
|
||||
State.ValueChanged += state =>
|
||||
{
|
||||
@ -67,11 +69,11 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
case CarouselItemState.Collapsed:
|
||||
case CarouselItemState.NotSelected:
|
||||
InternalChildren.ForEach(c => c.State.Value = CarouselItemState.Collapsed);
|
||||
this.items.ForEach(c => c.State.Value = CarouselItemState.Collapsed);
|
||||
break;
|
||||
|
||||
case CarouselItemState.Selected:
|
||||
InternalChildren.ForEach(c =>
|
||||
this.items.ForEach(c =>
|
||||
{
|
||||
if (c.State.Value == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected;
|
||||
});
|
||||
@ -84,11 +86,11 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
base.Filter(criteria);
|
||||
|
||||
InternalChildren.ForEach(c => c.Filter(criteria));
|
||||
items.ForEach(c => c.Filter(criteria));
|
||||
|
||||
// IEnumerable<T>.OrderBy() is used instead of List<T>.Sort() to ensure sorting stability
|
||||
criteriaComparer = Comparer<CarouselItem>.Create((x, y) => x.CompareTo(criteria, y));
|
||||
InternalChildren = InternalChildren.OrderBy(c => c, criteriaComparer).ToList();
|
||||
items = items.OrderBy(c => c, criteriaComparer).ToList();
|
||||
|
||||
lastCriteria = criteria;
|
||||
}
|
||||
@ -98,7 +100,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
// ensure we are the only item selected
|
||||
if (value == CarouselItemState.Selected)
|
||||
{
|
||||
foreach (var b in InternalChildren)
|
||||
foreach (var b in items)
|
||||
{
|
||||
if (item == b) continue;
|
||||
|
||||
|
@ -49,32 +49,32 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
attemptSelection();
|
||||
}
|
||||
|
||||
public override void RemoveChild(CarouselItem i)
|
||||
public override void RemoveItem(CarouselItem i)
|
||||
{
|
||||
base.RemoveChild(i);
|
||||
base.RemoveItem(i);
|
||||
|
||||
if (i != LastSelected)
|
||||
updateSelectedIndex();
|
||||
}
|
||||
|
||||
private bool addingChildren;
|
||||
private bool addingItems;
|
||||
|
||||
public void AddChildren(IEnumerable<CarouselItem> items)
|
||||
public void AddItems(IEnumerable<CarouselItem> items)
|
||||
{
|
||||
addingChildren = true;
|
||||
addingItems = true;
|
||||
|
||||
foreach (var i in items)
|
||||
AddChild(i);
|
||||
AddItem(i);
|
||||
|
||||
addingChildren = false;
|
||||
addingItems = false;
|
||||
|
||||
attemptSelection();
|
||||
}
|
||||
|
||||
public override void AddChild(CarouselItem i)
|
||||
public override void AddItem(CarouselItem i)
|
||||
{
|
||||
base.AddChild(i);
|
||||
if (!addingChildren)
|
||||
base.AddItem(i);
|
||||
if (!addingItems)
|
||||
attemptSelection();
|
||||
}
|
||||
|
||||
@ -103,15 +103,15 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
if (State.Value != CarouselItemState.Selected) return;
|
||||
|
||||
// we only perform eager selection if none of our children are in a selected state already.
|
||||
if (Children.Any(i => i.State.Value == CarouselItemState.Selected)) return;
|
||||
if (Items.Any(i => i.State.Value == CarouselItemState.Selected)) return;
|
||||
|
||||
PerformSelection();
|
||||
}
|
||||
|
||||
protected virtual CarouselItem GetNextToSelect()
|
||||
{
|
||||
return Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ??
|
||||
Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value);
|
||||
return Items.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ??
|
||||
Items.Reverse().Skip(Items.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value);
|
||||
}
|
||||
|
||||
protected virtual void PerformSelection()
|
||||
@ -131,6 +131,6 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
updateSelectedIndex();
|
||||
}
|
||||
|
||||
private void updateSelectedIndex() => lastSelectedIndex = LastSelected == null ? 0 : Math.Max(0, InternalChildren.IndexOf(LastSelected));
|
||||
private void updateSelectedIndex() => lastSelectedIndex = LastSelected == null ? 0 : Math.Max(0, GetIndexOfItem(LastSelected));
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
var carouselBeatmapSet = (CarouselBeatmapSet)Item;
|
||||
|
||||
var visibleBeatmaps = carouselBeatmapSet.Children.Where(c => c.Visible).ToArray();
|
||||
var visibleBeatmaps = carouselBeatmapSet.Items.Where(c => c.Visible).ToArray();
|
||||
|
||||
// if we are already displaying all the correct beatmaps, only run animation updates.
|
||||
// note that the displayed beatmaps may change due to the applied filter.
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
if (item is CarouselGroup group)
|
||||
{
|
||||
foreach (var c in group.Children)
|
||||
foreach (var c in group.Items)
|
||||
c.Filtered.ValueChanged -= onStateChange;
|
||||
}
|
||||
}
|
||||
@ -117,7 +117,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
if (Item is CarouselGroup group)
|
||||
{
|
||||
foreach (var c in group.Children)
|
||||
foreach (var c in group.Items)
|
||||
c.Filtered.ValueChanged += onStateChange;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user