mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:20:04 +08:00
Add global key binding for FPS toggle
This commit is contained in:
parent
0a1744faca
commit
f54aff2ece
@ -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,
|
||||
|
@ -20,7 +20,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class FPSCounter : CompositeDrawable, IHasCustomTooltip
|
||||
public class FPSCounter : VisibilityContainer, IHasCustomTooltip
|
||||
{
|
||||
private RollingCounter<double> msCounter = null!;
|
||||
private RollingCounter<double> fpsCounter = null!;
|
||||
@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private const float idle_background_alpha = 0.4f;
|
||||
|
||||
private Bindable<bool> showFpsDisplay = null!;
|
||||
private readonly BindableBool showFpsDisplay = new BindableBool(true);
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
@ -83,7 +83,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
},
|
||||
};
|
||||
|
||||
showFpsDisplay = config.GetBindable<bool>(OsuSetting.ShowFpsDisplay);
|
||||
config.BindWith(OsuSetting.ShowFpsDisplay, showFpsDisplay);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -94,11 +94,18 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
showFpsDisplay.BindValueChanged(showFps =>
|
||||
{
|
||||
this.FadeTo(showFps.NewValue ? 1 : 0, 100);
|
||||
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);
|
||||
|
@ -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,7 +816,7 @@ namespace osu.Game
|
||||
ScreenStack.ScreenPushed += screenPushed;
|
||||
ScreenStack.ScreenExited += screenExited;
|
||||
|
||||
loadComponentSingleFile(new FPSCounter
|
||||
loadComponentSingleFile(fpsCounter = new FPSCounter
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
@ -1121,6 +1123,10 @@ namespace osu.Game
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.ToggleFPSDisplay:
|
||||
fpsCounter.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleSkinEditor:
|
||||
skinEditor.ToggleVisibility();
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user