protected RedirectorTextAssetLoadedHandlerBase(TextResourceRedirector plugin, string extraEnableHelp = null, bool allowTranslationRegistration = false) { CheckDirectory = true; AllowTranslationRegistration = allowTranslationRegistration; Plugin = plugin; ConfigSectionName = GetType().Name; EnableHandler = this.ConfigEntryBind("Enabled", true, new ConfigDescription( $"Handle {nameof(TextAsset)} assets {extraEnableHelp ?? string.Empty}".Trim(), null, "Advanced")); if (allowTranslationRegistration) { EnableRegisterAsTranslationsHandler = this.ConfigEntryBind( "Register as Translations", true, new ConfigDescription( $"Register strings replaced by {ConfigSectionName} as text translations with " + XUAPluginData.Name, null, "Advanced")); #if !HS SceneManager.sceneLoaded += SceneManagerSceneLoadedRegisterAsTranslations; #endif plugin.TranslatorTranslationsLoaded += TranslatorTranslationsLoadedRegisterAsTranslations; } Logger.LogInfo($"{GetType()} {(Enabled ? "enabled" : "disabled")}"); }
private void ConfigureHandlersForKK(TextResourceRedirector sender, EventArgs eventArgs) { sender.NickNameHandler = new NickNameHandler(sender); sender.MapInfoHandler = new MapInfoHandler(sender); sender.EventInfoHandler = new EventInfoHandler(sender); sender.MakerCustomDataHandler = new MakerCustomDataHandler(sender); // limit what handlers will attempt to handle to speed things up if (sender.ScenarioDataHandler is IPathListBoundHandler scenarioHandler) { scenarioHandler.WhiteListPaths.Add("abdata/adv"); } //if (sender.TextAssetTableHandler is IPathListBoundHandler tableHandler) // tableHandler.WhiteListPaths.Add("abdata/h/list"); TextAssetTableHandler.TableRulesGetters.Add(HTextRulesGetter); if (sender.ChaListDataHandler is IPathListBoundHandler chaListHandler) { chaListHandler.WhiteListPaths.Add("abdata/list/characustom"); } /* * if (sender.TextAssetRawBytesHandler is IPathListBoundHandler textAssetRawBytesHandler) * { * TextAssetRawBytesHandler.Enabled = true; * textAssetRawBytesHandler.WhiteListPaths.Add("abdata/action/fixchara"); * } */ }
private void ConfigureHandlersForAI(TextResourceRedirector sender, EventArgs eventArgs) { sender.TitleSkillNameHandler = new TitleSkillNameHandler(this, true); sender.ChaListDataHandler.WhiteListPaths.Add("abdata/list/characustom"); var excelSkipPaths = new[] { "abdata/list/map/area", "abdata/list/map/chunk", "abdata/list/map/enviro", "abdata/list/map/event_item", "abdata/list/map/ikinfo", "abdata/list/map/mapinfo", "abdata/list/map/minimap", "abdata/list/map/openstate", "abdata/list/map/particle", "abdata/list/map/plant_item", "abdata/list/map/storypoint", "abdata/list/map/timeinfo", "abdata/list/map/vanish" }; foreach (var path in excelSkipPaths) { sender.ExcelDataHandler.BlackListPaths.Add(path); } }
public NickNameHandler(TextResourceRedirector plugin) : base(plugin) { Instance = this; // replacement fires INSIDE the function we need to postfix, so init hooks up front InitHooks(); }
public NickNameHandler(TextResourceRedirector plugin) : base(plugin, allowTranslationRegistration: true) { Instance = this; plugin.TranslatorTranslationsLoaded += Plugin_TranslatorTranslationsLoaded; InitHooks(); SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.sceneUnloaded += SceneManager_sceneUnloaded; }
protected UntestedParamAssetLoadedHandler(TextResourceRedirector plugin, bool allowTranslationRegistration = false, bool enableSafeModeByDefault = true) : base(plugin, allowTranslationRegistration) { EnableSafeMode = this.ConfigEntryBind("Enable Safe Mode", enableSafeModeByDefault, new ConfigDescription($@" Handle {typeof(T).Name} assets indirectly, enable this if you suspect this handler is causing game to misbehave.".ToSingleLineString(), null, "Advanced")); }
public MakerCustomDataHandler(TextResourceRedirector plugin) : base(plugin, true) { WhiteListPaths.Add("abdata/custom"); var baseHandler = plugin.ExcelDataHandler; SupportedColumnNames.AddRange(baseHandler.SupportedColumnNames.ToList()); foreach (var pth in WhiteListPaths) { baseHandler.BlackListPaths.Add(pth); } }
internal static void Init(TextResourceRedirector plugin) { if (Initialized) { return; } Initialized = true; EnableTextReflow = plugin.Config.Bind("Text Formatter", "Alternate Text Reflow", true, "Use whitespace based text reflow for non-Japanese languages."); TextResourceRedirector.Logger.LogDebug($"Hooking {typeof(Hooks).FullName}"); Harmony.CreateAndPatchAll(typeof(Hooks)); }
internal static void FormatDoPostfix(Format __instance, List <object> ___parameters) { if (TextResourceRedirector.Instance == null) { return; } if (!TextResourceRedirector.Instance.TextResourceHelper.FormatKeys.Contains(__instance.name)) { return; } try { var scope = TextResourceRedirector.GetCurrentTranslationScope(); var orig = __instance.scenario.Vars[__instance.name].o as string; if (string.IsNullOrEmpty(orig) || !LanguageHelper.IsTranslatable(orig)) { return; } if (TryGetFormatDoCacheValue(__instance.name, scope, orig, out var cachedTrans)) { __instance.scenario.Vars[__instance.name] = new ValData(cachedTrans); return; } var parameters = ___parameters.Select( p => p is string origP && LanguageHelper.IsTranslatable(origP) && AutoTranslator.Default.TryTranslate(origP, scope, out var transP) ? transP : p).ToArray(); var format = __instance.format; format = LanguageHelper.IsTranslatable(format) && AutoTranslator.Default.TryTranslate(format, out var transFormat) ? transFormat : format; var newResult = string.Format(format, parameters); __instance.scenario.Vars[__instance.name] = new ValData(newResult); if (!string.IsNullOrEmpty(orig) && !string.IsNullOrEmpty(newResult) && orig != newResult) { AddToFormatDoCache(__instance.name, scope, orig, newResult); } } catch (Exception err) { TextResourceRedirector.Logger?.LogWarning( $"{nameof(FormatDoPostfix)}: Unexpected error: {err.Message}"); UnityEngine.Debug.LogException(err); } }
private void ConfigureHandlersForHS2(TextResourceRedirector sender, EventArgs eventArgs) { sender.VoiceInfoHandler = new VoiceInfoHandler(sender); sender.BGMNameInfoHandler = new BGMNameInfoHandler(sender); sender.EventContentInfoDataHandler = new EventContentInfoDataHandler(sender); sender.MapInfoHandler = new MapInfoHandler(sender); sender.ParameterNameInfoHandler = new ParameterNameInfoHandler(sender); sender.AchievementInfoDataHandler = new AchievementInfoDataHandler(sender); sender.ChaListDataHandler.WhiteListPaths.Add("abdata/list/characustom"); if (TextResourceHelper is HS2_TextResourceHelper helper && helper.IsHS2DX()) { // DX only sender.PlanNameInfoHandler = new PlanNameInfoHandler(sender); } }
protected StringArrayParamAssetLoadedHandler(TextResourceRedirector plugin, int translatedIndex = -1, bool allowTranslationRegistration = true) : base(plugin, allowTranslationRegistration) { EnableInternalAssetTranslation = this.ConfigEntryBind("Use Translation from Asset", true, $"Use translation stored in {typeof(T).Name} assets if possible"); if (translatedIndex == -1) { translatedIndex = Plugin.GetCurrentGameLanguage(); } if (translatedIndex > 0) { DisableEmptyCacheCheck = true; } TranslatedIndex = translatedIndex; }
internal void Awake() { _instance = this; Logger = Logger ?? base.Logger; TextResourceHelper = GetTextResourceHelper(); ExcelDataHandler = new ExcelDataHandler(this); ScenarioDataHandler = new ScenarioDataHandler(this); TextAssetTableHandler = new TextAssetTableHandler(this); #if RAW_DUMP_SUPPORT TextAssetRawBytesHandler = new TextAssetRawBytesHandler(this); #endif enabled = false; #if !HS ChaListDataHandler = new ChaListDataHandler(this); #endif XuaHooks.Init(); OnTextResourceRedirectorAwake(EventArgs.Empty); }
protected RedirectorTextAssetLoadedHandlerBase(TextResourceRedirector plugin, string extraEnableHelp = null, bool allowTranslationRegistration = false, bool allowFallbackMapping = false) { CheckDirectory = true; AllowTranslationRegistration = allowTranslationRegistration; AllowFallbackMapping = allowFallbackMapping; Plugin = plugin; ConfigSectionName = GetType().Name; EnableHandler = this.ConfigEntryBind("Enabled", true, new ConfigDescription( $"Handle {nameof(TextAsset)} assets {extraEnableHelp ?? string.Empty}".Trim(), null, "Advanced")); if (allowTranslationRegistration) { EnableRegisterAsTranslationsHandler = this.ConfigEntryBind( "Register as Translations", true, new ConfigDescription( $"Register strings replaced by {ConfigSectionName} as text translations with " + XUAPluginData.Name, null, "Advanced")); #if !HS SceneManager.sceneLoaded += SceneManagerSceneLoadedRegisterAsTranslations; #endif plugin.TranslatorTranslationsLoaded += TranslatorTranslationsLoadedRegisterAsTranslations; } if (allowFallbackMapping) { EnableFallbackMappingConfig = this.ConfigEntryBind("Allow fallback mapping", TextResourceRedirector.EnableFallbackMappingConfigDefault, new ConfigDescription( $@" Allow searching related assets for otherwise unhandled {ConfigSectionName} translations. May slow down load times at cost of improved translations (especially useful when game has new content).".ToSingleLineString(), null, "Advanced")); } Logger.LogInfo($"{GetType()} {(Enabled ? "enabled" : "disabled")}"); }
public ScenarioDataHandler(TextResourceRedirector _ = null) { }
internal void Main() { _instance = this; Logger = Logger ?? base.Logger; }
public AnimationInfoDataHandler(TextResourceRedirector plugin) : base(plugin, true) { _instance = this; InitHooks(); }
public ScenarioDataHandler(TextResourceRedirector plugin) : base(plugin) { }
public EventInfoHandler(TextResourceRedirector plugin) : base(plugin, true) { }
// game searches by personality name against this table // can't do an in-place update of personality name table without possibly // breaking things public VoiceInfoHandler(TextResourceRedirector plugin) : base(plugin, true) { _instance = this; InitHooks(); }
public MapThumbnailInfoHandler(TextResourceRedirector plugin) : base(plugin, true) { }
protected TextAssetMessagePackHandlerBase(TextResourceRedirector plugin, string mark, bool allowTranslationRegistration = false) : base(plugin, $"with {typeof(T).Name} packed inside", allowTranslationRegistration) { SetObjectMark(mark); }
private void ConfigureHandlersForAI(TextResourceRedirector sender, EventArgs eventArgs) { sender.TitleSkillNameHandler = new TitleSkillNameHandler(this, true); sender.ChaListDataHandler.WhiteListPaths.Add("abdata/list/characustom"); }
public EstheticVoiceInfoHandler(TextResourceRedirector plugin) : base(plugin, true) { }
public TopicPersonalityGroupHandler(TextResourceRedirector plugin) : base(plugin, true) { }
public WhereLiveDataHandler(TextResourceRedirector plugin) : base(plugin, true) { }
public MapInfoHandler(TextResourceRedirector plugin) : base(plugin, allowTranslationRegistration: true) { Instance = this; }
public TopicHandler(TextResourceRedirector plugin) : base(plugin, true) { }
public ParameterNameInfoHandler(TextResourceRedirector plugin) : base(plugin) { }
public CommunicationInfoHandler(TextResourceRedirector plugin) : base(plugin, true) { }
public ExcelDataHandler(TextResourceRedirector plugin, bool allowTranslationRegistration = false) : base(plugin, null, allowTranslationRegistration) { }