mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08: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 OnMouseDown(MouseDownEvent e) => false;
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
@ -168,8 +177,6 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
updateKeyBindingTooltip();
|
|
||||||
|
|
||||||
HoverBackground.FadeIn(200);
|
HoverBackground.FadeIn(200);
|
||||||
tooltipContainer.FadeIn(100);
|
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);
|
keyBindingTooltip.Text = !string.IsNullOrEmpty(keyBindingString)
|
||||||
|
? $" ({keyBindingString})"
|
||||||
if (realmKeyBinding != null)
|
: string.Empty;
|
||||||
{
|
|
||||||
string keyBindingString = keyCombinationProvider.GetReadableString(realmKeyBinding.KeyCombination);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(keyBindingString))
|
|
||||||
keyBindingTooltip.Text = $" ({keyBindingString})";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user