(03ab09991) Load chinese fonts dynamically, removed unnecessary duplicate block from DynamicRenderAtlas

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:39:25 +03:00
parent c583181e3b
commit 3575c8df52
79 changed files with 1720 additions and 2745 deletions
@@ -11,7 +11,7 @@ namespace Barotrauma
{
private static Regex csvSplit = new Regex("(?:^|,)(\"(?:[^\"])*\"|[^,]*)", RegexOptions.Compiled); // Handling commas inside data fields surrounded by ""
private static List<int> conversationClosingIndent = new List<int>();
private static char[] separator = new char[1] { ',' };
private static char[] separator = new char[1] { '|' };
private const string conversationsPath = "Content/NPCConversations";
private const string infoTextPath = "Content/Texts";
@@ -48,7 +48,7 @@ namespace Barotrauma
DebugConsole.ThrowError("NPCConversation Localization .csv to .xml conversion failed for: " + conversationFiles[i]);
continue;
}
string xmlFileFullPath = $"{conversationsPath}/NPCConversations_{language}_NEW.xml";
string xmlFileFullPath = $"{conversationsPath}/NpcConversations_{language}_NEW.xml";
File.WriteAllLines(xmlFileFullPath, xmlContent);
DebugConsole.NewMessage("Conversation localization .xml file successfully created at: " + xmlFileFullPath);
}
@@ -141,7 +141,8 @@ namespace Barotrauma
for (int i = 0; i < NPCPersonalityTrait.List.Count; i++) // Traits
{
string[] split = SplitCSV(csvContent[traitStart + i].Trim(separator));
//string[] split = SplitCSV(csvContent[traitStart + i].Trim(separator));
string[] split = csvContent[traitStart + i].Split(separator);
xmlContent.Add(
$"<PersonalityTrait " +
$"{GetVariable("name", split[1])}" +
@@ -151,8 +152,10 @@ namespace Barotrauma
for (int i = traitStart + NPCPersonalityTrait.List.Count; i < csvContent.Length; i++) // Conversations
{
string[] presplit = csvContent[i].Split(','); // Handling speaker index fetching, somehow doesn't work with the regex
string[] split = SplitCSV(csvContent[i]);
//string[] presplit = csvContent[i].Split(separator); // Handling speaker index fetching, somehow doesn't work with the regex
//string[] split = SplitCSV(csvContent[i]);
string[] split = csvContent[i].Split(separator);
int emptyFields = 0;
@@ -173,15 +176,15 @@ namespace Barotrauma
continue;
}
string speaker = presplit[1];
int depthIndex = int.Parse(presplit[2]);
string speaker = split[1];
int depthIndex = int.Parse(split[2]);
// 3 = original line
string line = split[4].Replace("\"", "");
string flags = split[5].Replace("\"", "");
string allowedJobs = split[6].Replace("\"", "");
string speakerTags = split[7].Replace("\"", "");
string minIntensity = split[8].Replace("\"", "").Replace(",", ".");
string maxIntensity = split[9].Replace("\"", "").Replace(",", ".");
string line = split[3].Replace("\"", "");
string flags = split[4].Replace("\"", "");
string allowedJobs = split[5].Replace("\"", "");
string speakerTags = split[6].Replace("\"", "");
string minIntensity = split[7].Replace("\"", "").Replace(",", ".");
string maxIntensity = split[8].Replace("\"", "").Replace(",", ".");
string element =
$"{GetIndenting(depthIndex)}" +
@@ -257,7 +260,7 @@ namespace Barotrauma
list.Add("");
}
list.Add(curr.TrimStart(','));
list.Add(curr.TrimStart(separator));
}
return list.ToArray();
@@ -107,24 +107,42 @@ namespace Barotrauma
text = text.Replace("\n", " \n ");
string[] words;
if (TextManager.NoWhiteSpace)
List<string> words = new List<string>();
string currWord = "";
for (int i = 0; i < text.Length; i++)
{
words = new string[text.Length];
for (int i = 0; i < text.Length; i++)
if (isCJK.IsMatch(text[i].ToString()))
{
words[i] = text[i].ToString();
if (currWord.Length > 0)
{
words.Add(currWord);
currWord = "";
}
words.Add(text[i].ToString());
}
else if (text[i] == ' ')
{
if (currWord.Length > 0)
{
words.Add(currWord);
currWord = "";
}
}
else
{
currWord += text[i];
}
}
else
if (currWord.Length > 0)
{
words = text.Split(' ');
words.Add(currWord);
currWord = "";
}
StringBuilder wrappedText = new StringBuilder();
float linePos = 0f;
Vector2 spaceSize = font.MeasureString(" ") * textScale;
for (int i = 0; i < words.Length; ++i)
for (int i = 0; i < words.Count; ++i)
{
if (words[i].Length == 0)
{