public bool TryGetUIResize(string[] segments, int scope, out UIResizeResult result) { UIResizeAttachment attachment = this; result = null; var len = segments.Length; for (int i = 0; i < len; i++) { var segment = segments[i]; if (attachment.Descendants.TryGetValue(segment, out var newAttachment)) { if (result == null) { result = newAttachment.Result?.Copy(); } else { result.MergeInto(newAttachment.Result); } if (scope != TranslationScopes.None) { if (result == null) { if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult)) { result = scopedResult.Copy(); } } else { if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult)) { result.MergeInto(scopedResult); } } } attachment = newAttachment; } else { return(result != null); } } return(result != null); }
private UIResizeAttachment GetOrCreateAttachment(string[] segments) { UIResizeAttachment attachment = this; var len = segments.Length; for (int i = 0; i < len; i++) { var segment = segments[i]; if (!attachment.Descendants.TryGetValue(segment, out var newAttachment)) { newAttachment = new UIResizeAttachment(); attachment.Descendants[segment] = newAttachment; } attachment = newAttachment; } return(attachment); }
internal void LoadResizeCommandsInFiles() { try { Directory.CreateDirectory(Path.Combine(PluginEnvironment.Current.TranslationPath, Settings.TranslationDirectory).Parameterize()); Directory.CreateDirectory(Path.GetDirectoryName(Settings.AutoTranslationsFilePath)); _root = new UIResizeAttachment(); foreach (var fullFileName in GetTranslationFiles().Reverse()) { LoadResizeCommandsInFile(fullFileName); } XuaLogger.AutoTranslator.Info($"Loaded resize command text files."); } catch (Exception e) { XuaLogger.AutoTranslator.Error(e, "An error occurred while resize commands."); } }
internal void LoadResizeCommandsInFiles() { try { Directory.CreateDirectory(Settings.TranslationsPath); Directory.CreateDirectory(Path.GetDirectoryName(Settings.AutoTranslationsFilePath)); _root = new UIResizeAttachment(); foreach (var fullFileName in GetTranslationFiles().Reverse()) { LoadResizeCommandsInFile(fullFileName); } _root.Trim(); XuaLogger.AutoTranslator.Debug($"Loaded resize command text files."); } catch (Exception e) { XuaLogger.AutoTranslator.Error(e, "An error occurred while resize commands."); } }
public bool TryGetUIResize(string[] segments, int startIndex, int scope, out UIResizeResult result) { UIResizeAttachment attachment = this; result = null; var len = segments.Length; for (int i = startIndex; i < len; i++) { var segment = segments[i]; if (attachment.Descendants.TryGetValue(segment, out var newAttachment)) { if (result == null) { result = newAttachment.Result?.Copy(); } else { result.MergeInto(newAttachment.Result); } if (scope != TranslationScopes.None) { if (result == null) { if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult)) { result = scopedResult.Copy(); } } else { if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult)) { result.MergeInto(scopedResult); } } } //if( attachment.HasWildcardBelow ) //{ // // we have to iterate all descendants of this attachment // foreach( var childAttachment in attachment.Descendants.Values ) // { // if( childAttachment.TryGetUIResize( segments, i + 1, scope, out var otherResult ) ) // { // if( result == null ) // { // result = otherResult.Copy(); // } // else // { // result.MergeInto( otherResult ); // } // } // } //} attachment = newAttachment; } else { return(result != null); } } return(result != null); }