Пример #1
0
        private static void RandomizeVowelsInternal(TalkFile tf, List <int> skipIDs, Dictionary <char, char> translationMap, bool isMERTlk, RandomizationOption option)
        {
            var tfName   = Path.GetFileNameWithoutExtension(tf.path);
            var langCode = tfName.Substring(tfName.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase) + 1);

            foreach (var sref in tf.StringRefs.Where(x => x.StringID > 0 && !string.IsNullOrWhiteSpace(x.Data)).ToList())
            {
                option.IncrementProgressValue();

                if (sref.Data.Contains("DLC_"))
                {
                    continue;                             // Don't modify
                }
                if (!isMERTlk && skipIDs.Contains(sref.StringID))
                {
                    continue; // Do not randomize this version of the string as it's in the DLC version specifically
                }
                // See if strref has CUSTOMTOKEN or a control symbol
                List <int> skipRanges = new List <int>();
                FindSkipRanges(sref, skipRanges);

                var newStr = sref.Data.ToArray();
                for (int i = 0; i < sref.Data.Length; i++) // For every letter
                {
                    // Skip any items we should not skip.
                    if (skipRanges.Any() && skipRanges[0] == i)
                    {
                        i = skipRanges[1] - 1;  // We subtract one as the next iteration of the loop will +1 it again, which then will make it read the 'next' character
                        skipRanges.RemoveAt(0); // remove first 2
                        skipRanges.RemoveAt(0); // remove first 2

                        if (i >= sref.Data.Length - 1)
                        {
                            break;
                        }
                        continue;
                    }

                    if (translationMap.ContainsKey(newStr[i]))
                    {
                        // Remap the letter
                        newStr[i] = translationMap[newStr[i]];
                    }
                    else
                    {
                        // Do not change the letter. It might be something like <.
                    }

                    TLKHandler.ReplaceString(sref.StringID, new string(newStr), langCode);
                }
            }
        }
Пример #2
0
        private static void UwuifyTalkFile(TalkFile tf, bool keepCasing, bool addReactions, List <int> skipIDs, bool isMERTlk, RandomizationOption option)
        {
            var tfName   = Path.GetFileNameWithoutExtension(tf.path);
            var langCode = tfName.Substring(tfName.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase) + 1);

            if (langCode != "INT")
            {
                return;
            }
            foreach (var sref in tf.StringRefs.Where(x => x.StringID > 0 && !string.IsNullOrWhiteSpace(x.Data)))
            {
                option.IncrementProgressValue();

                var strData = sref.Data;

                //strData = "New Game";
                if (strData.Contains("DLC_"))
                {
                    continue;                           // Don't modify
                }
                if (!isMERTlk && skipIDs.Contains(sref.StringID))
                {
                    continue; // Do not randomize this version of the string as it's in the DLC version specifically
                }

                //if (sref.StringID != 325648)
                //    continue;
                // See if strref has CUSTOMTOKEN or a control symbol
                List <int> skipRanges = new List <int>();
                FindSkipRanges(sref, skipRanges);
                // uwuify it
                StringBuilder sb           = new StringBuilder();
                char          previousChar = (char)0x00;
                char          currentChar;
                for (int i = 0; i < strData.Length; i++)
                {
                    if (skipRanges.Any() && skipRanges[0] == i)
                    {
                        sb.Append(strData.Substring(skipRanges[0], skipRanges[1] - skipRanges[0]));
                        previousChar = (char)0x00;
                        i            = skipRanges[1] - 1; // We subtract one as the next iteration of the loop will +1 it again, which then will make it read the 'next' character
                        skipRanges.RemoveAt(0);           // remove first 2
                        skipRanges.RemoveAt(0);           // remove first 2

                        if (i >= strData.Length - 1)
                        {
                            break;
                        }
                        continue;
                    }

                    currentChar = strData[i];
                    if (currentChar == 'L' || currentChar == 'R')
                    {
                        sb.Append(keepCasing ? 'W' : 'w');
                    }
                    else if (currentChar == 'l' || currentChar == 'r')
                    {
                        sb.Append('w');
                        if (ThreadSafeRandom.Next(5) == 0)
                        {
                            sb.Append('w'); // append another w 20% of the time
                            if (ThreadSafeRandom.Next(8) == 0)
                            {
                                sb.Append('w'); // append another w 20% of the time
                            }
                        }
                    }
                    else if (currentChar == 'N' && (previousChar == 0x00 || previousChar == ' '))
                    {
                        sb.Append(keepCasing ? "Nyaa" : "nyaa");
                    }
                    else if (currentChar == 'O' || currentChar == 'o')
                    {
                        if (previousChar == 'N' || previousChar == 'n' ||
                            previousChar == 'M' || previousChar == 'm')
                        {
                            sb.Append("yo");
                        }
                        else
                        {
                            sb.Append(keepCasing ? strData[i] : char.ToLower(strData[i]));
                        }
                    }
                    else if (currentChar == '!' && !addReactions)
                    {
                        sb.Append(currentChar);
                        if (ThreadSafeRandom.Next(2) == 0)
                        {
                            sb.Append(currentChar); // append another ! 50% of the time
                        }
                    }
                    else
                    {
                        sb.Append(keepCasing ? strData[i] : char.ToLower(strData[i]));
                    }

                    previousChar = currentChar;
                }

                var str = sb.ToString();

                if (addReactions)
                {
                    str = AddReactionToLine(strData, str, keepCasing);
                }
                else
                {
                    str = str.Replace("f**k", keepCasing ? "UwU" : "uwu", StringComparison.InvariantCultureIgnoreCase);
                }

                TLKHandler.ReplaceString(sref.StringID, str, langCode);
            }
        }