1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 23:43:03 +08:00

Add to game and bind with configuration setting

This commit is contained in:
Dean Herbert 2022-07-20 20:49:57 +09:00
parent 0fb959a565
commit 0a1744faca
3 changed files with 21 additions and 17 deletions

View File

@ -3,6 +3,7 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
@ -13,6 +14,7 @@ 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;
@ -29,6 +31,8 @@ namespace osu.Game.Graphics.UserInterface
private const float idle_background_alpha = 0.4f;
private Bindable<bool> showFpsDisplay = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
@ -38,7 +42,7 @@ namespace osu.Game.Graphics.UserInterface
}
[BackgroundDependencyLoader]
private void load()
private void load(OsuConfigManager config)
{
InternalChildren = new Drawable[]
{
@ -78,12 +82,21 @@ namespace osu.Game.Graphics.UserInterface
}
},
};
showFpsDisplay = config.GetBindable<bool>(OsuSetting.ShowFpsDisplay);
}
protected override void LoadComplete()
{
base.LoadComplete();
displayTemporarily();
showFpsDisplay.BindValueChanged(showFps =>
{
this.FadeTo(showFps.NewValue ? 1 : 0, 100);
displayTemporarily();
}, true);
}
protected override bool OnHover(HoverEvent e)

View File

@ -814,6 +814,13 @@ namespace osu.Game
ScreenStack.ScreenPushed += screenPushed;
ScreenStack.ScreenExited += screenExited;
loadComponentSingleFile(new FPSCounter
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding(10),
}, topMostOverlayContent.Add);
if (!args?.Any(a => a == @"--no-version-overlay") ?? true)
loadComponentSingleFile(versionManager = new VersionManager { Depth = int.MinValue }, ScreenContainer.Add);

View File

@ -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>
@ -404,19 +401,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));