浏览代码

allow for longer texts, except when IMGUI where requirements are doubled because of component behaviour

Scrublord1336 6 年之前
父节点
当前提交
0909a1d57d

+ 8 - 2
src/XUnity.AutoTranslator.Plugin.Core/AutoTranslationPlugin.cs

@@ -720,6 +720,11 @@ namespace XUnity.AutoTranslator.Plugin.Core
          return _symbolCheck( str ) && str.Length <= Settings.MaxCharactersPerTranslation && !_reverseTranslations.ContainsKey( str );
       }
 
+      private bool IsShortText( string str )
+      {
+         return str.Length <= ( Settings.MaxCharactersPerTranslation / 2 );
+      }
+
       public bool ShouldTranslate( object ui )
       {
          var cui = ui as Component;
@@ -817,7 +822,8 @@ namespace XUnity.AutoTranslator.Plugin.Core
          if( !string.IsNullOrEmpty( text ) && IsTranslatable( text ) && ShouldTranslate( ui ) && !IsCurrentlySetting( info ) )
          {
             info?.Reset( text );
-            var textKey = new TranslationKey( ui, text, ui.IsSpammingComponent(), context != null );
+            var isSpammer = ui.IsSpammingComponent();
+            var textKey = new TranslationKey( ui, text, isSpammer, context != null );
 
 
             // if we already have translation loaded in our _translatios dictionary, simply load it and set text
@@ -943,7 +949,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
                      _ongoingOperations.Remove( ui );
                   }
                }
-               else
+               else if ( !isSpammer || ( isSpammer && IsShortText( text ) ) )
                {
                   // Lets try not to spam a service that might not be there...
                   if( _endpoint != null )

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.Core/Configuration/Settings.cs

@@ -107,7 +107,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
          AllowPluginHookOverride = Config.Current.Preferences[ "TextFrameworks" ][ "AllowPluginHookOverride" ].GetOrDefault( true );
 
          Delay = Config.Current.Preferences[ "Behaviour" ][ "Delay" ].GetOrDefault( 0f );
-         MaxCharactersPerTranslation = Config.Current.Preferences[ "Behaviour" ][ "MaxCharactersPerTranslation" ].GetOrDefault( 150 );
+         MaxCharactersPerTranslation = Config.Current.Preferences[ "Behaviour" ][ "MaxCharactersPerTranslation" ].GetOrDefault( 200 );
          IgnoreWhitespaceInDialogue = Config.Current.Preferences[ "Behaviour" ][ "IgnoreWhitespaceInDialogue" ].GetOrDefault( Types.AdvEngine == null );
          IgnoreWhitespaceInNGUI = Config.Current.Preferences[ "Behaviour" ][ "IgnoreWhitespaceInNGUI" ].GetOrDefault( true );
          MinDialogueChars = Config.Current.Preferences[ "Behaviour" ][ "MinDialogueChars" ].GetOrDefault( 20 );