@@ -46,6 +46,7 @@ public static class PluginManager
4646 private static List < PluginMetadata > _metadatas ;
4747 private static readonly List < string > _modifiedPlugins = new ( ) ;
4848
49+ private static readonly Dictionary < PluginPair , List < BasePluginHotkey > > _pluginHotkeyInfo = new ( ) ;
4950 private static readonly Dictionary < HotkeyModel , List < ( PluginMetadata , SearchWindowPluginHotkey ) > > _windowPluginHotkeys = new ( ) ;
5051
5152 /// <summary>
@@ -263,9 +264,9 @@ public static async Task InitializePluginsAsync()
263264
264265 await Task . WhenAll ( InitTasks ) ;
265266
266- var pluginHotkeyInfo = GetPluginHotkeyInfo ( ) ;
267- Settings . UpdatePluginHotkeyInfo ( pluginHotkeyInfo ) ;
268- InitializeWindowPluginHotkeys ( pluginHotkeyInfo ) ;
267+ InitializePluginHotkeyInfo ( ) ;
268+ Settings . UpdatePluginHotkeyInfo ( GetPluginHotkeyInfo ( ) ) ;
269+ InitializeWindowPluginHotkeys ( ) ;
269270
270271 foreach ( var plugin in AllPlugins )
271272 {
@@ -478,24 +479,53 @@ public static IList<PluginPair> GetTranslationPlugins()
478479
479480 public static Dictionary < PluginPair , List < BasePluginHotkey > > GetPluginHotkeyInfo ( )
480481 {
481- var hotkeyPluginInfos = new Dictionary < PluginPair , List < BasePluginHotkey > > ( ) ;
482+ return _pluginHotkeyInfo ;
483+ }
484+
485+ public static Dictionary < HotkeyModel , List < ( PluginMetadata Metadata , SearchWindowPluginHotkey SearchWindowPluginHotkey ) > > GetWindowPluginHotkeys ( )
486+ {
487+ return _windowPluginHotkeys ;
488+ }
489+
490+ public static void UpdatePluginHotkeyInfoTranslations ( )
491+ {
482492 foreach ( var plugin in _hotkeyPlugins )
483493 {
484- var hotkeys = ( ( IPluginHotkey ) plugin . Plugin ) . GetPuginHotkeys ( ) ;
485- hotkeyPluginInfos . Add ( plugin , hotkeys ) ;
494+ var newHotkeys = ( ( IPluginHotkey ) plugin . Plugin ) . GetPuginHotkeys ( ) ;
495+ if ( _pluginHotkeyInfo . TryGetValue ( plugin , out var oldHotkeys ) )
496+ {
497+ foreach ( var newHotkey in newHotkeys )
498+ {
499+ if ( oldHotkeys . FirstOrDefault ( h => h . Id == newHotkey . Id ) is BasePluginHotkey pluginHotkey )
500+ {
501+ pluginHotkey . Name = newHotkey . Name ;
502+ pluginHotkey . Description = newHotkey . Description ;
503+ }
504+ else
505+ {
506+ oldHotkeys . Add ( newHotkey ) ;
507+ }
508+ }
509+ }
510+ else
511+ {
512+ _pluginHotkeyInfo . Add ( plugin , newHotkeys ) ;
513+ }
486514 }
487-
488- return hotkeyPluginInfos ;
489515 }
490516
491- public static Dictionary < HotkeyModel , List < ( PluginMetadata Metadata , SearchWindowPluginHotkey SearchWindowPluginHotkey ) > > GetWindowPluginHotkeys ( )
517+ private static void InitializePluginHotkeyInfo ( )
492518 {
493- return _windowPluginHotkeys ;
519+ foreach ( var plugin in _hotkeyPlugins )
520+ {
521+ var hotkeys = ( ( IPluginHotkey ) plugin . Plugin ) . GetPuginHotkeys ( ) ;
522+ _pluginHotkeyInfo . Add ( plugin , hotkeys ) ;
523+ }
494524 }
495525
496- private static void InitializeWindowPluginHotkeys ( Dictionary < PluginPair , List < BasePluginHotkey > > pluginHotkeyInfo )
526+ private static void InitializeWindowPluginHotkeys ( )
497527 {
498- foreach ( var info in pluginHotkeyInfo )
528+ foreach ( var info in GetPluginHotkeyInfo ( ) )
499529 {
500530 var pluginPair = info . Key ;
501531 var hotkeyInfo = info . Value ;
0 commit comments