mirror of
https://github.com/ppy/osu
synced 2024-12-24 15:53:37 +00:00
Merge pull request #26086 from peppy/fix-toolbar-button-lag
Use a realm subscription to avoid overhead when hovering a toolbar button
This commit is contained in:
commit
ee00f7ea1f
@ -157,6 +157,15 @@ namespace osu.Game.Overlays.Toolbar
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
if (Hotkey != null)
|
||||
{
|
||||
realm.SubscribeToPropertyChanged(r => r.All<RealmKeyBinding>().FirstOrDefault(rkb => rkb.RulesetName == null && rkb.ActionInt == (int)Hotkey.Value), kb => kb.KeyCombinationString, updateKeyBindingTooltip);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => false;
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
@ -168,8 +177,6 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateKeyBindingTooltip();
|
||||
|
||||
HoverBackground.FadeIn(200);
|
||||
tooltipContainer.FadeIn(100);
|
||||
|
||||
@ -197,19 +204,13 @@ namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
}
|
||||
|
||||
private void updateKeyBindingTooltip()
|
||||
private void updateKeyBindingTooltip(string keyCombination)
|
||||
{
|
||||
if (Hotkey == null) return;
|
||||
string keyBindingString = keyCombinationProvider.GetReadableString(keyCombination);
|
||||
|
||||
var realmKeyBinding = realm.Realm.All<RealmKeyBinding>().FirstOrDefault(rkb => rkb.RulesetName == null && rkb.ActionInt == (int)Hotkey.Value);
|
||||
|
||||
if (realmKeyBinding != null)
|
||||
{
|
||||
string keyBindingString = keyCombinationProvider.GetReadableString(realmKeyBinding.KeyCombination);
|
||||
|
||||
if (!string.IsNullOrEmpty(keyBindingString))
|
||||
keyBindingTooltip.Text = $" ({keyBindingString})";
|
||||
}
|
||||
keyBindingTooltip.Text = !string.IsNullOrEmpty(keyBindingString)
|
||||
? $" ({keyBindingString})"
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user