Exemplo n.º 1
0
        protected override IEnumerable <KeyValuePair <string, AssetDumpColumnInfo> > GetLists()
        {
            foreach (var list in base.GetLists())
            {
                yield return(list);
            }

            if (!TextDump.IsReadyForFinalDump())
            {
                yield break;
            }
            yield return(new KeyValuePair <string, AssetDumpColumnInfo>("actor/animal", ItemLookupAndAssetCols));

            foreach (var animal in new[] { "cat", "chicken" })
            {
                foreach (var state in new[] { "wild", "pet" })
                {
                    yield return(new KeyValuePair <string, AssetDumpColumnInfo>($"actor/animal/action/{animal}/{state}",
                                                                                StdExcelAssetCols));
                }
            }

            yield return(new KeyValuePair <string, AssetDumpColumnInfo>("actor/gameitem/recipe/recycling", ItemLookup));

            foreach (var mapdir in new[] { "eventpoint", "popupinfo", "mapinfo" })
            {
                yield return(new KeyValuePair <string, AssetDumpColumnInfo>($"map/{mapdir}", StdExcelAssetCols));
            }
        }
Exemplo n.º 2
0
        protected KKP_AssetDumpHelper(TextDump plugin) : base(plugin)
        {
            this.AssetDumpGenerators.Clear(); // FIXME: delete
#if RAW_DUMP_SUPPORT
            AssetDumpGenerators.Add(GetFixCharaDumpers);
#endif
        }
Exemplo n.º 3
0
        protected virtual Dictionary <string, string> FallbackPersonalityLinesLocalizer()
        {
            var results = new Dictionary <string, string>();
            var subdirs = new[] { "2", "2_0" };

            foreach (var voiceInfo in Singleton <Voice> .Instance.voiceInfoList)
            {
                for (var i = 0; i < 3; i++)
                {
                    foreach (var subdir1 in subdirs)
                    {
                        var fileKey = CombinePaths(TextDump.AssetsRoot,
                                                   "adv", "scenario", $"c{voiceInfo.No:00}", "00", $"{i:00}", subdir1, "translation.txt");

                        if (TextDump.GetTranslationPaths().Contains(fileKey))
                        {
                            var dict = TextDump.GetTranslationsForPath(fileKey);
                            foreach (var entry in dict.Where(e =>
                                                             e.Key.Contains("{0}") && !string.IsNullOrEmpty(e.Value)))
                            {
                                if (entry.Key.Contains("{0}が"))
                                {
                                    var key = new StringBuilder(entry.Key.Length * 3);
                                    var hit = false;
                                    foreach (var c in entry.Key)
                                    {
                                        if (c == 'が')
                                        {
                                            hit = true;
                                        }

                                        key.Append(c);
                                        if (hit)
                                        {
                                            key.Append(@"\n?");
                                        }
                                    }

                                    //sr: "^\[(?<stat>[\w]+)(?<num_i>[\+\-]{1}[0-9]+)?\](?<after>[\s\S]+)?$" = "[${stat}${num_i}]${after}"
                                    key = key.Replace("{0}",
                                                      @"^(?<color_open_i><color[^>]+>)(?<item_name>[\S\s]+)x(?<item_count_i>[1-9][0-9]*)(?<color_close_i><\/color>)$");
                                    key.Insert(0, "sr:\"");
                                    key.Append("\"");
                                    var value = entry.Value.Replace("{0}",
                                                                    "${color_open_i}${item_name} x${item_count_i}${color_close_i}");
                                    AddLocalizationToResults(results, key.ToString(), value);
                                }
                                else
                                {
                                    AddLocalizationToResults(results, entry.Key, entry.Value);
                                }
                            }
                        }
                    }
                }
            }

            return(results);
        }
Exemplo n.º 4
0
 private void KKP_TextDumpAwake(TextDump sender, EventArgs eventArgs)
 {
     ManualDumpHotkey = Config.Bind("Keyboard Shortcuts", "Dump Translations",
                                    new KeyboardShortcut(KeyCode.F9, KeyCode.LeftControl, KeyCode.LeftAlt),
                                    "Once you have control of the player and have visited all the screens you'd like to collect press this key to start dump");
     SceneManager.sceneLoaded   += SceneManager_sceneLoaded;
     SceneManager.sceneUnloaded += SceneManager_sceneUnloaded;
 }
        protected AI_AssetDumpHelper(TextDump plugin) : base(plugin)
        {
            TitleAssetCols = new AssetDumpColumnInfo {
                CombineWithParentBundle = true
            };

            ListEntryDumpers.Add(TryDumpTitleSkillName);
        }
Exemplo n.º 6
0
 private void TextDump_TextDumpUpdate(TextDump sender, EventArgs eventArgs)
 {
     if (Enabled.Value && DumpLevelCompleted == (int)DumpLevels.Main &&
         DumpLevelReady < DumpLevelMax &&
         ManualDumpHotkey.Value.IsPressed())
     {
         DumpLevelReady = (int)DumpLevels.Manual;
     }
 }
        protected IEnumerable <ITranslationDumper> GetScenarioTextMergers()
        {
            if (!TextDump.IsReadyForFinalDump())
            {
                yield break;
            }
            var needle = CombinePaths("", "abdata", "adv", "scenario", "");
            var paths  = TextDump.GetTranslationPaths().Where(k => k.Contains(needle)).ToList();

            paths.Sort();
            paths.Reverse();
            var personalityCheckChars = "01234567890-".ToCharArray();

            var mappings = new Dictionary <string, Dictionary <string, string> >();
            var fileMaps = new Dictionary <string, List <string> >();

            foreach (var path in paths)
            {
                var parts            = path.Split(PathSplitter).ToList();
                var personalityIndex = parts.IndexOf("scenario") + 1;
                if (personalityIndex == 0)
                {
                    continue;
                }
                var personality       = parts[personalityIndex];
                var isPersonalityFile = personality.Length > 1 && personality.StartsWith("c") &&
                                        personalityCheckChars.Contains(personality[1]);
                if (!isPersonalityFile)
                {
                    continue;
                }

                if (!mappings.TryGetValue(personality, out var personalityMap))
                {
                    mappings[personality] =
                        personalityMap    = new Dictionary <string, string>(new TrimmedStringComparer());
                }

                if (!fileMaps.TryGetValue(personality, out var personalityFiles))
                {
                    fileMaps[personality] = personalityFiles = new List <string>();
                }

                personalityFiles.Add(path);

                foreach (var entry in TextDump.GetTranslationsForPath(path)
                         .Where(entry => !entry.Value.IsNullOrEmpty()))
                {
                    AddLocalizationToResults(personalityMap, entry);
                }
            }

            foreach (var translationDumper in BuildTranslationMergers(fileMaps, mappings))
            {
                yield return(translationDumper);
            }
        }
Exemplo n.º 8
0
        protected override IEnumerable <TranslationGenerator> GetLocalizationGenerators()
        {
            foreach (var generator in base.GetLocalizationGenerators())
            {
                yield return(generator);
            }

            var readyToDump = TextDump.IsReadyForFinalDump();

            if (!readyToDump)
            {
                yield break;
            }
            foreach (var dir in new[]
                     { "scene/common", "housing/base", "h/scene", "prefabs/tutorial_ui", "scene/map", "title/scene" })
            {
                yield return(() => GetBindLocalizers(dir));
            }

            yield return(GetStaticLocalizers);

            yield return(GetPopupLocalizers);

            yield return(GetHousingItemLocalizers);

            yield return(GetItemLocalizers);

            yield return(MakeManagerResourceLocalizers);

            yield return(WrapTranslationCollector("Fallback/PersonalityLines", FallbackPersonalityLinesLocalizer));



            yield return(MakeCharacterCategoryLocalizers);

            yield return(WrapTranslationCollector("GameInfoTables/AgentLifeStyle", AgentLifeStyleLocalizer));

            yield return(GetRecipeLocalizers);

            yield return(WrapTranslationCollector("Manager/Resources/DateActionName", DateActionNameLocalizer));

            yield return(WrapTranslationCollector("Manager/Resources/MapName", MapNameLocalizer));

            yield return(WrapTranslationCollector("Manager/Resources/ActionName", ActionNameLocalizer));

            yield return(WrapTranslationCollector("Manager/Resources/SickName", SickNameLocalizer));

            yield return(() => new[]
                         { MapLabelPostProcessor(new StringTranslationDumper("Manager/Resources/BaseName", BaseNameLocalizer)) });

            yield return(WrapTranslationCollector("Manager/Resources/MiniMapIconName", MiniMapIconNameLocalizer));

            yield return(GetHAnimationLocalizers);

            // add this one an extra time at the end
            yield return(() => GetBindLocalizers("scene/map"));
        }
Exemplo n.º 9
0
        protected AI_HS2_AssetDumpHelper(TextDump plugin) : base(plugin)
        {
            ItemLookup = new AssetDumpColumnInfo(null, null, true, new[]
            {
                "アイテム名",
                "名前(メモ)",
            });

            ItemLookupAndAssetCols =
                new AssetDumpColumnInfo(null, StdExcelAssetCols.NameMappings, true, ItemLookup.ItemLookupColumns);
        }
        protected override IEnumerable <KeyValuePair <string, AssetDumpColumnInfo> > GetLists()
        {
            foreach (var list in base.GetLists())
            {
                yield return(list);
            }

            if (TextDump.IsReadyForFinalDump())
            {
                yield return(new KeyValuePair <string, AssetDumpColumnInfo>("title", TitleAssetCols));
            }
        }
Exemplo n.º 11
0
 private void AI_INT_TextDumpLevelComplete(TextDump sender, EventArgs eventArgs)
 {
     if (DumpLevelCompleted >= DumpLevelMax)
     {
         NotificationMessage = string.Empty;
     }
     else if (DumpLevelCompleted > 0)
     {
         NotificationMessage =
             "Localizations not loaded. Start/Load game and play until you have control of the player";
     }
 }
Exemplo n.º 12
0
        protected override IEnumerable <KeyValuePair <string, string> > HandleChaListData(TextAsset asset,
                                                                                          AssetDumpColumnInfo assetDumpColumnInfo)
        {
            if (!TextDump.IsReadyForFinalDump())
            {
                foreach (var result in base.HandleChaListData(asset, assetDumpColumnInfo))
                {
                    yield return(result);
                }
            }
            else
            {
                // now try and redump/populate
                if (!TextDump.IsReadyForFinalDump())
                {
                    yield break;
                }
                var categoryName = asset.name.Substring(0, asset.name.LastIndexOf("_", StringComparison.Ordinal));
                var category     = (ChaListDefine.CategoryNo)Enum.Parse(typeof(ChaListDefine.CategoryNo), categoryName);
                var catInfo      = Singleton <Character> .Instance.chaListCtrl.GetCategoryInfo(category);

                var lookupDict = new Dictionary <string, string>();

                foreach (var value in catInfo.Select(c => c.Value))
                {
                    if (!value.Name.IsNullOrEmpty())
                    {
                        lookupDict[$"{value.Kind}_{value.Id}"] = value.Name;
                    }
                }

                var chaListData = MessagePackSerializer.Deserialize <ChaListData>(asset.bytes);

                foreach (var entry in chaListData.dictList.Values)
                {
                    foreach (var id in chaListData.dictList.Keys)
                    {
                        var key = chaListData.GetInfo(id, "Name");
                        if (string.IsNullOrEmpty(key))
                        {
                            continue;
                        }
                        if (!lookupDict.TryGetValue($"{chaListData.GetInfo(id, "Kind")}_{id}", out var val))
                        {
                            val = string.Empty;
                        }

                        yield return(new KeyValuePair <string, string>(key, val));
                    }
                }
            }
        }
Exemplo n.º 13
0
        protected KK_AssetDumpHelper(TextDump plugin) : base(plugin)
        {
            AssetDumpGenerators.Add(GetCustomListDumpers);
            AssetDumpGenerators.Add(GetAnimationInfoDumpers);
            AssetDumpGenerators.Add(GetHPointToggleDumpers);
            AssetDumpGenerators.Add(GetSpecialNickNameDumpers);
            AssetDumpGenerators.Add(GetEventInfoDumpers);

            AssetDumpGenerators.Add(GetScenarioTextMergers);
            AssetDumpGenerators.Add(GetCommunicationTextMergers);

            TextDump.TranslationPostProcessors.Add(OptionDisplayItemsPostProcessor);
        }
Exemplo n.º 14
0
        protected IEnumerable <ITranslationDumper> GetCommunicationTextMergers()
        {
            if (!TextDump.IsReadyForFinalDump())
            {
                yield break;
            }
            var needle = CombinePaths("", "abdata", "communication", "");
            var paths  = TextDump.GetTranslationPaths().Where(k => k.Contains(needle)).ToList();

            paths.Sort();
            paths.Reverse();

            var splitter = new HashSet <char> {
                Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar
            }.ToArray();

            var mappings = new Dictionary <string, Dictionary <string, string> >();
            var fileMaps = new Dictionary <string, List <string> >();

            foreach (var path in paths)
            {
                var parent = Path.GetFileName(Path.GetDirectoryName(path));
                if (parent is null)
                {
                    continue;
                }
                if (!mappings.TryGetValue(parent, out var personalityMap))
                {
                    mappings[parent] = personalityMap = new Dictionary <string, string>(new TrimmedStringComparer());
                }

                if (!fileMaps.TryGetValue(parent, out var personalityFiles))
                {
                    fileMaps[parent] = personalityFiles = new List <string>();
                }

                personalityFiles.Add(path);

                foreach (var entry in TextDump.GetTranslationsForPath(path)
                         .Where(entry => !entry.Value.IsNullOrEmpty()))
                {
                    AddLocalizationToResults(personalityMap, entry);
                }
            }

            foreach (var translationDumper in BuildTranslationMergers(fileMaps, mappings))
            {
                yield return(translationDumper);
            }
        }
Exemplo n.º 15
0
        private void AI_TextDumpLevelComplete(TextDump sender, EventArgs eventArgs)
        {
            var delta = _total - _lastTotal;

            if (DumpLevelCompleted >= DumpLevelMax)
            {
                NotificationMessage = string.Empty;


                if (_total == _lastTotal)
                {
                    _stableCount++;
                }
                else
                {
                    _lastTotal = _total;
                    if (_stableCount != 0)
                    {
                        _lastDelta = delta;
                    }
                    _stableCount = 0;
                }

                if (_stableCount < 3)
                {
                    StartCoroutine(RetryDelay(10));
                    if (_stableCount == 0)
                    {
                        NotificationMessage = $"Number of translations found is continuing to change ({delta})";
                    }
                    else
                    {
                        NotificationMessage = $"Number of translations unchanged";
                    }


                    NotificationMessage +=
                        $", will keep re-dumping until it's stable for {3 - _stableCount} more cycle(s)";
                    DumpLevelCompleted--;
                    DumpLevelReady = DumpLevelCompleted;
                }
            }
            else if (DumpLevelCompleted > 0)
            {
                NotificationMessage =
                    "Multiple brute-force dump attempts are required, please wait until you see a message saying files are available";
            }
        }
Exemplo n.º 16
0
        protected AssetDumpHelper(TextDump plugin) : base(plugin)
        {
            StdTextAssetCols = new AssetDumpColumnInfo(new Dictionary <string, string>
            {
                { "Name", "EN_US" }
            });

            StdStudioAssetCols = new AssetDumpColumnInfo(null, null, true, new[]
            {
                "名称",
                "表示名"
            });

            AssetDumpGenerators = new List <TranslationGenerator>
            {
                GetRandomNameListDumpers,
                GetCommunicationTextDumpers,
                GetListTextDumpers,
                GetScenarioTextDumpers,
                GetHTextDumpers,
                GetMapInfoDumpers
            };

            //RawAssetDumpGenerators = new List<RawTranslationGenerator> { };

            StdExcelAssetCols = new AssetDumpColumnInfo(new Dictionary <string, string>
            {
                { "Name", "EN_US" },
                { "Text", "Text _EnUS" },
                { "タイトル(日本語)", "タイトル(英語)" },
                { "サブタイトル(日本語)", "サブタイトル(英語)" },
                { "タイトル", "英語" },
                { "日本語", "英語" },
                { "本文(日本語)", "本文(英語?)" },
                { "日本語(0)", "英語" },
                { "選択肢1", "選択肢1(英語)" },
                { "選択肢2", "選択肢2(英語)" },
                { "選択肢3", "選択肢3(英語)" },
                { "名前(メモ)", string.Empty }
            });

            ListEntryDumpers = new List <TryDumpListEntry>
            {
                TryDumpExcelData,
                TryDumpTextAsset
            };
        }
 private static void Unpatch(TextDump sender, EventArgs eventArgs)
 {
     if (_harmony == null)
     {
         return;
     }
     lock (InitialDumpLock)
     {
         var tmp = _harmony;
         if (tmp == null)
         {
             return;
         }
         _harmony = null;
         tmp.UnpatchAll(HarmonyId);
         sender.TextDumpUpdate -= Unpatch;
     }
 }
 public static void DumpBeforeInitialLoad()
 {
     if (_pluginInstance is null)
     {
         return;
     }
     lock (InitialDumpLock)
     {
         var plugin = _pluginInstance;
         if (plugin == null || !Enabled.Value || DumpLevelCompleted > 0)
         {
             return;
         }
         _pluginInstance = null;
         plugin.DumpText(nameof(DumpBeforeInitialLoad));
         plugin.TextDumpUpdate += Unpatch;
     }
 }
        protected virtual IEnumerable <TranslationGenerator> GetLocalizationGenerators()
        {
            yield return(GetHookedTextLocalizationGenerators);

            yield return(GetAutoLocalizerDumpers);

            yield return(GetStaticLocalizers);

            yield return(WrapTranslationCollector("Personalities", PersonalityLocalizer));

#if LOCALIZE
            yield return(GetOtherDataLocalizers);
#endif
            if (TextDump.IsReadyForFinalDump())
            {
                yield return(GetInstanceLocalizers);
            }
        }
Exemplo n.º 20
0
        protected IEnumerable <ITranslationDumper> BuildTranslationMergers(Dictionary <string, List <string> > fileMaps,
                                                                           Dictionary <string, Dictionary <string, string> > mappings)
        {
            foreach (var personalityFileMap in fileMaps)
            {
                var personality      = personalityFileMap.Key;
                var personalityMap   = mappings[personality];
                var personalityFiles = personalityFileMap.Value;

                foreach (var path in personalityFiles)
                {
                    var mapPath = path.Substring(TextDump.AssetsRoot.Length).TrimStart(PathSplitter);
                    mapPath = CombinePaths(Path.GetDirectoryName(mapPath), Path.GetFileNameWithoutExtension(mapPath));

                    var toUpdate = new HashSet <string>(TextDump.GetTranslationsForPath(path)
                                                        .Where(e => e.Value.IsNullOrWhiteSpace()).Select(e => e.Key));

                    if (toUpdate.Count == 0)
                    {
                        continue;
                    }

                    IDictionary <string, string> Dumper()
                    {
                        var result = new OrderedDictionary <string, string>();

                        foreach (var key in toUpdate)
                        {
                            if (personalityMap.TryGetValue(key, out var match))
                            {
                                AddLocalizationToResults(result, key, match);
                            }
                        }

                        return(result);
                    }

                    yield return(new StringTranslationDumper(mapPath, Dumper));
                }
            }
        }
Exemplo n.º 21
0
        protected override IEnumerable <TranslationGenerator> GetLocalizationGenerators()
        {
            foreach (var generator in base.GetLocalizationGenerators())
            {
                yield return(generator);
            }
            var readyToDump = TextDump.IsReadyForFinalDump();

            yield return(LocalizationMappingLocalizers);

            yield return(WrapTranslationCollector("Tutorials/TutorialTitles", TutorialTitleLocalizer));

            yield return(GetTutorialPrefabLocalizers);


            // this crashes, and doesn't find anything not covered already
            //foreach (var entry in GetUILocalizers(Singleton<Manager.Resources>.Instance.DefinePack, nameof(Singleton<Manager.Resources>.Instance.DefinePack)))
            //{
            //    yield return entry;
            //}
        }
Exemplo n.º 22
0
        private void KKP_TextDumpLevelComplete(TextDump sender, EventArgs eventArgs)
        {
            _waitForTitleUnload |= (DumpLevelCompleted > 0 && DumpLevelCompleted < (int)DumpLevels.Main);

            if (DumpLevelCompleted < (int)DumpLevels.Initial)
            {
                NotificationMessage = string.Empty;
            }

            /*
             * else if (DumpLevelCompleted < (int) DumpLevels.Maker)
             * {
             *  NotificationMessage =
             *      "Localizations not fully loaded. Please launch the character maker.";
             * }
             */
            else if (DumpLevelCompleted < (int)DumpLevels.Main)
            {
                NotificationMessage =
                    "Localizations not fully loaded. Start/Load main game and play until you have control of the player";
            }

            if (DumpLevelCompleted == (int)DumpLevels.Main)
            {
                TextDumpUpdate     += TextDump_TextDumpUpdate;
                NotificationMessage =
                    $"Visit as many dialogs/screens as possible then press {ManualDumpHotkey.Value} to execute dump";
            }

            if (DumpLevelCompleted < DumpLevelMax)
            {
                return;
            }

            NotificationMessage         = string.Empty;
            SceneManager.sceneUnloaded -= SceneManager_sceneUnloaded;
            SceneManager.sceneLoaded   -= SceneManager_sceneLoaded;
            TextDumpUpdate             -= TextDump_TextDumpUpdate;
        }
Exemplo n.º 23
0
 protected AI_INT_LocalizationDumpHelper(TextDump plugin) : base(plugin)
 {
     OtherDataByTag[100] = new Dictionary <string, string>
     {
         { "DeleteScene", "データを消去しますか?" },
         {
             "DeleteWarning",
             string.Concat("本当に削除しますか?\n", "このキャラにはパラメータが含まれています。".Coloring("#DE4529FF").Size(24))
         },
         { "Delete", "本当に削除しますか?" },
         { "EndHousing", "ハウジングを終了しますか?" },
         { "EndHScene", "Hシーンを終了しますか" },
         {
             "LoadScene",
             string.Concat("データを読込みますか?\n", "セットされたアイテムは削除されます。".Coloring("#DE4529FF").Size(24))
         },
         { "Migration", "{0}に移動しますか?" },
         {
             "OverwriteWarn",
             string.Concat("本当に上書きしますか?\n", "上書きするとパラメータは初期化されます。".Coloring("#DE4529FF").Size(24))
         },
         { "Overwrite", "本当に上書きしますか?" },
         { "ReleaseHousingItem", "作成しますか" },
         {
             "RestoreScene",
             string.Concat("初期化しますか?\n", "セットされたアイテムは削除されます。".Coloring("#DE4529FF").Size(24))
         },
         { "Save", "セーブしますか?" },
         { "SleepTogether", "一緒に寝た場合2人で行動状態が解除されます。" },
         { "Sleep", "一日を終了しますか?" },
         { "Teleport", "このポイントに移動しますか" },
         { "Warp", "移動しますか" },
         {
             "ReleasePet",
             string.Concat("{0}を逃しますか?\n", "逃がすとアイテムとして戻ってきません。".Coloring("#DE4529FF").Size(24))
         }
     };
 }
 protected LocalizationDumpHelper(TextDump plugin) : base(plugin)
 {
     _instance = this;
 }
Exemplo n.º 25
0
        protected KKP_AssetDumpHelper(TextDump plugin) : base(plugin)
        {
#if RAW_DUMP_SUPPORT
            AssetDumpGenerators.Add(GetFixCharaDumpers);
#endif
        }
 protected AI_HS2_LocalizationDumpHelper(TextDump plugin) : base(plugin)
 {
 }
Exemplo n.º 27
0
 protected BaseDumpHelper(TextDump plugin)
 {
     Plugin = plugin;
 }
Exemplo n.º 28
0
 private void AI_TextDumpAwake(TextDump sender, EventArgs eventArgs)
 {
     SceneManager.sceneLoaded += AI_sceneLoaded;
 }
 internal static void Setup(TextDump textDump)
 {
     _pluginInstance = textDump;
     _harmony        = Harmony.CreateAndPatchAll(typeof(InitialDumpHook), HarmonyId);
 }
 protected HS2_AssetDumpHelper(TextDump plugin) : base(plugin)
 {
 }