Exemplo n.º 1
0
        private static void ConfirmSceneSentenceGetterPostfix(ConfirmScene __instance,
                                                              ref string __result)
        {
            if (!Configuration.AccelerationEnabled)
            {
                return;
            }
            // ReSharper disable once RedundantAssignment - used in debug builds
            var orig = __result;

            try
            {
                if (Configuration.ConfirmSceneSentenceTranslations.TryGetValue(__result, out var translatedText))
                {
                    __result = translatedText;
                }
            }

            catch (Exception err)
            {
                Logger.LogException(err, __instance, nameof(ConfirmSceneSentenceGetterPostfix));
            }

            finally
            {
                Logger.DebugLogDebug($"{nameof(ConfirmSceneSentenceGetterPostfix)}: {orig} => {__result}");
            }
        }
Exemplo n.º 2
0
        private static void ConfirmSceneSentenceSetterPrefix(ConfirmScene __instance,
                                                             ref string value)
        {
            if (!Configuration.AccelerationEnabled)
            {
                return;
            }
            var orig = value;

            try
            {
                if (Configuration.ConfirmSceneSentenceHandled.Contains(orig))
                {
                    return;
                }

                if (Configuration.ConfirmSceneSentenceTranslations.TryGetValue(value, out var translatedText))
                {
                    value = translatedText;
                    return;
                }

                if (GeBoAPI.Instance.AutoTranslationHelper.TryTranslate(value, out translatedText))
                {
                    Configuration.ConfirmSceneSentenceTranslations[orig] = value = translatedText;
                    Configuration.ConfirmSceneSentenceHandled.Add(translatedText);
                    return;
                }


                void ConfirmSceneSentenceTranslationCompleted(ITranslationResult r)
                {
                    if (!r.Succeeded)
                    {
                        return;
                    }
                    Configuration.ConfirmSceneSentenceTranslations[orig] = r.TranslatedText;
                    Configuration.ConfirmSceneSentenceHandled.Add(r.TranslatedText);
                }

                GeBoAPI.Instance.AutoTranslationHelper.TranslateAsync(orig, ConfirmSceneSentenceTranslationCompleted);
            }

            catch (Exception err)
            {
                Logger.LogException(err, __instance, nameof(ConfirmSceneSentenceSetterPrefix));
            }

            finally
            {
                Logger.DebugLogDebug($"{nameof(ConfirmSceneSentenceSetterPrefix)}: {orig} => {value}");
            }
        }