mirror of
https://github.com/ppy/osu.git
synced 2026-05-29 23:51:01 +08:00
Tidy up flow for retrieving key binding representations
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Configuration;
|
||||
@@ -35,6 +34,11 @@ namespace osu.Game.Configuration
|
||||
Migrate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For a given <see cref="GlobalAction"/>, return a human-readable string representing the bindings bound to the action.
|
||||
/// </summary>
|
||||
public LocalisableString LookupKeyBindings(GlobalAction action) => LookupKeyBindingsFunc(action);
|
||||
|
||||
protected override void InitialiseDefaults()
|
||||
{
|
||||
// UI/selection defaults
|
||||
@@ -263,10 +267,6 @@ namespace osu.Game.Configuration
|
||||
|
||||
public override TrackedSettings CreateTrackedSettings()
|
||||
{
|
||||
// these need to be assigned in normal game startup scenarios.
|
||||
Debug.Assert(LookupKeyBindings != null);
|
||||
Debug.Assert(LookupSkinName != null);
|
||||
|
||||
return new TrackedSettings
|
||||
{
|
||||
new TrackedSetting<bool>(OsuSetting.ShowFpsDisplay, state => new SettingDescription(
|
||||
@@ -308,7 +308,7 @@ namespace osu.Game.Configuration
|
||||
string skinName = string.Empty;
|
||||
|
||||
if (Guid.TryParse(skin, out var id))
|
||||
skinName = LookupSkinName(id);
|
||||
skinName = LookupSkinNameFunc(id);
|
||||
|
||||
return new SettingDescription(
|
||||
rawValue: skinName,
|
||||
@@ -329,9 +329,8 @@ namespace osu.Game.Configuration
|
||||
};
|
||||
}
|
||||
|
||||
public Func<Guid, string> LookupSkinName { private get; set; } = _ => @"unknown";
|
||||
|
||||
public Func<GlobalAction, LocalisableString> LookupKeyBindings { get; set; } = _ => @"unknown";
|
||||
public Func<Guid, string> LookupSkinNameFunc { private get; set; } = _ => @"unknown";
|
||||
public Func<GlobalAction, LocalisableString> LookupKeyBindingsFunc { private get; set; } = _ => @"unknown";
|
||||
|
||||
IBindable<float> IGameplaySettings.ComboColourNormalisationAmount => GetOriginalBindable<float>(OsuSetting.ComboColourNormalisationAmount);
|
||||
IBindable<float> IGameplaySettings.PositionalHitsoundsLevel => GetOriginalBindable<float>(OsuSetting.PositionalHitsoundsLevel);
|
||||
|
||||
+2
-2
@@ -979,9 +979,9 @@ namespace osu.Game
|
||||
|
||||
// make config aware of how to lookup skins for on-screen display purposes.
|
||||
// if this becomes a more common thing, tracked settings should be reconsidered to allow local DI.
|
||||
LocalConfig.LookupSkinName = id => SkinManager.Query(s => s.ID == id)?.ToString() ?? "Unknown";
|
||||
LocalConfig.LookupSkinNameFunc = id => SkinManager.Query(s => s.ID == id)?.ToString() ?? "Unknown";
|
||||
|
||||
LocalConfig.LookupKeyBindings = l =>
|
||||
LocalConfig.LookupKeyBindingsFunc = l =>
|
||||
{
|
||||
var combinations = KeyBindingStore.GetReadableKeyCombinationsFor(l);
|
||||
|
||||
|
||||
@@ -44,13 +44,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
TextBox.PlaceholderText = ChatStrings.InGameInputPlaceholder(config.LookupKeyBindings(GlobalAction.ToggleChatFocus));
|
||||
resetPlaceholderText();
|
||||
TextBox.Focus = () => TextBox.PlaceholderText = Resources.Localisation.Web.ChatStrings.InputPlaceholder;
|
||||
TextBox.FocusLost = () =>
|
||||
{
|
||||
TextBox.PlaceholderText = ChatStrings.InGameInputPlaceholder(config.LookupKeyBindings(GlobalAction.ToggleChatFocus));
|
||||
resetPlaceholderText();
|
||||
expandedFromTextBoxFocus.Value = false;
|
||||
};
|
||||
|
||||
void resetPlaceholderText() => TextBox.PlaceholderText = ChatStrings.InGameInputPlaceholder(config.LookupKeyBindings(GlobalAction.ToggleChatFocus));
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e) => true; // use UI mouse cursor.
|
||||
|
||||
Reference in New Issue
Block a user