Переглянути джерело

work on automatic configuration migrations

Scrublord1336 6 роки тому
батько
коміт
5add536e25

+ 2 - 0
CHANGELOG.md

@@ -1,6 +1,8 @@
 ### 2.10.0
  * FEATURE - Support Yandex translate (requires key)
  * FEATURE - Support Watson translate (requires key)
+ * MISC - Added automatic configuration migration support
+   * Versions of this plugin were being distributed with predefined configuration to target "GoogleTranslateHack". The first time the plugin is run under this version, it will change this value back to the default.
 
 ### 2.9.0
  * FEATURE - Installation as UnityInjector plugin

+ 4 - 0
README.md

@@ -66,6 +66,10 @@ WatsonAPIPassword=               ;OPTIONAL, needed if WatsonTranslate is configu
 EnablePrintHierarchy=False       ;Used for debugging
 EnableConsole=False              ;Enables the console. Do not enable if other plugins (managers) handles this
 EnableLog=False                  ;Enables extra logging for debugging purposes
+
+[Migrations]
+Enable=True                      ;Used to enable automatic migrations of this configuration file
+Tag=2.9.0                        ;Tag representing the last version this plugin was executed under. Do not edit
 ```
 
 ## Key Mapping

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

@@ -118,7 +118,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
          }
 
          // update tag
-         Config.Current.Preferences[ "Migrations" ][ "Tag" ].Value = PluginData.Version;
+         MigrationsTag = Config.Current.Preferences[ "Migrations" ][ "Tag" ].Value = PluginData.Version;
 
          Config.Current.SaveConfig();
       }
@@ -131,7 +131,10 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
          // migrate from unknown version to known version. Reset to google translate
          if( string.IsNullOrEmpty( currentTag ) )
          {
-            Config.Current.Preferences[ "Service" ][ "Endpoint" ].Value = KnownEndpointNames.GoogleTranslate;
+            if( ServiceEndpoint == KnownEndpointNames.GoogleTranslateHack )
+            {
+               ServiceEndpoint = Config.Current.Preferences[ "Service" ][ "Endpoint" ].Value = KnownEndpointNames.GoogleTranslate;
+            }
          }
       }
    }