(ae2d4614b) Added: NPCConversation translations

This commit is contained in:
Joonas Rikkonen
2019-05-07 16:24:41 +03:00
parent 799c2d4a5c
commit cc22268f0e
9 changed files with 35 additions and 46 deletions
@@ -20,7 +20,7 @@ namespace Barotrauma
var skillContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 0.5f), paddedFrame.RectTransform) var skillContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 0.5f), paddedFrame.RectTransform)
{ RelativeOffset = new Vector2(0.0f, 0.2f + descriptionBlock.RectTransform.RelativeSize.Y) }); { RelativeOffset = new Vector2(0.0f, 0.2f + descriptionBlock.RectTransform.RelativeSize.Y) });
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), skillContainer.RectTransform), new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), skillContainer.RectTransform),
TextManager.Get("Skills"), font: GUI.LargeFont); TextManager.Get("Skills") + ": ", font: GUI.LargeFont);
foreach (SkillPrefab skill in Skills) foreach (SkillPrefab skill in Skills)
{ {
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), skillContainer.RectTransform), new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), skillContainer.RectTransform),
@@ -30,7 +30,7 @@ namespace Barotrauma
var itemContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 0.5f), paddedFrame.RectTransform, Anchor.TopRight) var itemContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 0.5f), paddedFrame.RectTransform, Anchor.TopRight)
{ RelativeOffset = new Vector2(0.0f, 0.2f + descriptionBlock.RectTransform.RelativeSize.Y) }); { RelativeOffset = new Vector2(0.0f, 0.2f + descriptionBlock.RectTransform.RelativeSize.Y) });
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), itemContainer.RectTransform), new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), itemContainer.RectTransform),
TextManager.Get("Items", fallBackTag: "mapentitycategory.equipment"), font: GUI.LargeFont); TextManager.Get("Items") + ": ", font: GUI.LargeFont);
foreach (string itemName in ItemNames) foreach (string itemName in ItemNames)
{ {
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), itemContainer.RectTransform), new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), itemContainer.RectTransform),
@@ -315,7 +315,7 @@ namespace Barotrauma
var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform),
TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true)
{ CanBeFocused = false }; { CanBeFocused = false };
new GUITextBlock(new RectTransform(new Vector2(0.45f, 0.0f), dimensionsText.RectTransform, Anchor.TopRight), new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), dimensionsText.RectTransform, Anchor.TopRight),
dimensionsStr, textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) dimensionsStr, textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true)
{ CanBeFocused = false }; { CanBeFocused = false };
dimensionsText.RectTransform.MinSize = new Point(0, dimensionsText.Children.First().Rect.Height); dimensionsText.RectTransform.MinSize = new Point(0, dimensionsText.Children.First().Rect.Height);
@@ -326,7 +326,7 @@ namespace Barotrauma
var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform),
TextManager.Get("RecommendedCrewSize"), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) TextManager.Get("RecommendedCrewSize"), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true)
{ CanBeFocused = false }; { CanBeFocused = false };
new GUITextBlock(new RectTransform(new Vector2(0.45f, 0.0f), crewSizeText.RectTransform, Anchor.TopRight), new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), crewSizeText.RectTransform, Anchor.TopRight),
RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax, textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax, textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true)
{ CanBeFocused = false }; { CanBeFocused = false };
crewSizeText.RectTransform.MinSize = new Point(0, crewSizeText.Children.First().Rect.Height); crewSizeText.RectTransform.MinSize = new Point(0, crewSizeText.Children.First().Rect.Height);
@@ -337,7 +337,7 @@ namespace Barotrauma
var crewExperienceText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), var crewExperienceText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform),
TextManager.Get("RecommendedCrewExperience"), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) TextManager.Get("RecommendedCrewExperience"), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true)
{ CanBeFocused = false }; { CanBeFocused = false };
new GUITextBlock(new RectTransform(new Vector2(0.45f, 0.0f), crewExperienceText.RectTransform, Anchor.TopRight), new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), crewExperienceText.RectTransform, Anchor.TopRight),
TextManager.Get(RecommendedCrewExperience), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) TextManager.Get(RecommendedCrewExperience), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true)
{ CanBeFocused = false }; { CanBeFocused = false };
crewExperienceText.RectTransform.MinSize = new Point(0, crewExperienceText.Children.First().Rect.Height); crewExperienceText.RectTransform.MinSize = new Point(0, crewExperienceText.Children.First().Rect.Height);
@@ -348,21 +348,18 @@ namespace Barotrauma
var contentPackagesText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), var contentPackagesText = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform),
TextManager.Get("RequiredContentPackages"), textAlignment: Alignment.TopLeft, font: GUI.Font) TextManager.Get("RequiredContentPackages"), textAlignment: Alignment.TopLeft, font: GUI.Font)
{ CanBeFocused = false }; { CanBeFocused = false };
new GUITextBlock(new RectTransform(new Vector2(0.45f, 0.0f), contentPackagesText.RectTransform, Anchor.TopRight), new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), contentPackagesText.RectTransform, Anchor.TopRight),
string.Join(", ", RequiredContentPackages), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true) string.Join(", ", RequiredContentPackages), textAlignment: Alignment.TopLeft, font: GUI.Font, wrap: true)
{ CanBeFocused = false }; { CanBeFocused = false };
contentPackagesText.RectTransform.MinSize = new Point(0, contentPackagesText.Children.First().Rect.Height); contentPackagesText.RectTransform.MinSize = new Point(0, contentPackagesText.Children.First().Rect.Height);
} }
GUITextBlock.AutoScaleAndNormalize(descriptionBox.Content.Children.Where(c => c is GUITextBlock).Cast<GUITextBlock>());
//space //space
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), descriptionBox.Content.RectTransform), style: null); new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), descriptionBox.Content.RectTransform), style: null);
if (Description.Length != 0) if (Description.Length != 0)
{ {
new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), TextManager.Get("SaveSubDialogDescription") + ":", font: GUI.Font, wrap: true) { CanBeFocused = false, ForceUpperCase = true };
TextManager.Get("SaveSubDialogDescription", fallBackTag: "WorkshopItemDescription"), font: GUI.Font, wrap: true) { CanBeFocused = false, ForceUpperCase = true };
} }
new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), Description, font: GUI.Font, wrap: true) new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), Description, font: GUI.Font, wrap: true)
@@ -280,7 +280,7 @@ namespace Barotrauma
{ {
IsFixedSize = false IsFixedSize = false
}, },
TextManager.Get("Shuttle", fallBackTag: "RespawnShuttle"), textAlignment: Alignment.Right, font: GUI.SmallFont) TextManager.Get("Shuttle"), textAlignment: Alignment.Right, font: GUI.SmallFont)
{ {
TextColor = textBlock.TextColor * 0.8f, TextColor = textBlock.TextColor * 0.8f,
ToolTip = textBlock.ToolTip ToolTip = textBlock.ToolTip
@@ -437,13 +437,9 @@ namespace Barotrauma
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), modeList.Content.RectTransform), GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), modeList.Content.RectTransform),
mode.Name, style: "ListBoxElement", textAlignment: Alignment.CenterLeft) mode.Name, style: "ListBoxElement", textAlignment: Alignment.CenterLeft)
{ {
ToolTip = mode.Description,
UserData = mode UserData = mode
}; };
//TODO: translate mission descriptions
if (TextManager.Language == "English")
{
textBlock.ToolTip = mode.Description;
}
} }
//mission type ------------------------------------------------------------------ //mission type ------------------------------------------------------------------
@@ -1220,7 +1216,7 @@ namespace Barotrauma
if (sub.HasTag(SubmarineTag.Shuttle)) if (sub.HasTag(SubmarineTag.Shuttle))
{ {
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), frame.RectTransform, Anchor.CenterRight) { RelativeOffset = new Vector2(0.1f, 0.0f) }, new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), frame.RectTransform, Anchor.CenterRight) { RelativeOffset = new Vector2(0.1f, 0.0f) },
TextManager.Get("Shuttle", fallBackTag: "RespawnShuttle"), textAlignment: Alignment.CenterRight, font: GUI.SmallFont) TextManager.Get("Shuttle"), textAlignment: Alignment.CenterRight, font: GUI.SmallFont)
{ {
TextColor = subTextBlock.TextColor * 0.8f, TextColor = subTextBlock.TextColor * 0.8f,
ToolTip = subTextBlock.ToolTip, ToolTip = subTextBlock.ToolTip,
@@ -1355,7 +1355,7 @@ namespace Barotrauma
if (sub.HasTag(SubmarineTag.Shuttle)) if (sub.HasTag(SubmarineTag.Shuttle))
{ {
var shuttleText = new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), textBlock.RectTransform, Anchor.CenterRight), var shuttleText = new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), textBlock.RectTransform, Anchor.CenterRight),
TextManager.Get("Shuttle", fallBackTag: "RespawnShuttle"), font: GUI.SmallFont) TextManager.Get("Shuttle"), font: GUI.SmallFont)
{ {
TextColor = textBlock.TextColor * 0.8f, TextColor = textBlock.TextColor * 0.8f,
ToolTip = textBlock.ToolTip ToolTip = textBlock.ToolTip
@@ -48,7 +48,7 @@ namespace Barotrauma
DebugConsole.ThrowError("NPCConversation Localization .csv to .xml conversion failed for: " + conversationFiles[i]); DebugConsole.ThrowError("NPCConversation Localization .csv to .xml conversion failed for: " + conversationFiles[i]);
continue; continue;
} }
string xmlFileFullPath = $"{conversationsPath}/NPCConversations_{language}_NEW.xml"; string xmlFileFullPath = $"{conversationsPath}/NpcConversations_{language}_NEW.xml";
File.WriteAllLines(xmlFileFullPath, xmlContent); File.WriteAllLines(xmlFileFullPath, xmlContent);
DebugConsole.NewMessage("Conversation localization .xml file successfully created at: " + xmlFileFullPath); 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 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( xmlContent.Add(
$"<PersonalityTrait " + $"<PersonalityTrait " +
$"{GetVariable("name", split[1])}" + $"{GetVariable("name", split[1])}" +
@@ -151,8 +152,10 @@ namespace Barotrauma
for (int i = traitStart + NPCPersonalityTrait.List.Count; i < csvContent.Length; i++) // Conversations for (int i = traitStart + NPCPersonalityTrait.List.Count; i < csvContent.Length; i++) // Conversations
{ {
string[] presplit = csvContent[i].Split(separator); // Handling speaker index fetching, somehow doesn't work with the regex //string[] presplit = csvContent[i].Split(separator); // Handling speaker index fetching, somehow doesn't work with the regex
string[] split = SplitCSV(csvContent[i]); //string[] split = SplitCSV(csvContent[i]);
string[] split = csvContent[i].Split(separator);
int emptyFields = 0; int emptyFields = 0;
@@ -173,15 +176,15 @@ namespace Barotrauma
continue; continue;
} }
string speaker = presplit[1]; string speaker = split[1];
int depthIndex = int.Parse(presplit[2]); int depthIndex = int.Parse(split[2]);
// 3 = original line // 3 = original line
string line = split[4].Replace("\"", ""); string line = split[3].Replace("\"", "");
string flags = split[5].Replace("\"", ""); string flags = split[4].Replace("\"", "");
string allowedJobs = split[6].Replace("\"", ""); string allowedJobs = split[5].Replace("\"", "");
string speakerTags = split[7].Replace("\"", ""); string speakerTags = split[6].Replace("\"", "");
string minIntensity = split[8].Replace("\"", "").Replace(",", "."); string minIntensity = split[7].Replace("\"", "").Replace(",", ".");
string maxIntensity = split[9].Replace("\"", "").Replace(",", "."); string maxIntensity = split[8].Replace("\"", "").Replace(",", ".");
string element = string element =
$"{GetIndenting(depthIndex)}" + $"{GetIndenting(depthIndex)}" +
@@ -73,7 +73,6 @@
<Character file="Content/Characters/Watcher/Watcher.xml" /> <Character file="Content/Characters/Watcher/Watcher.xml" />
<Character file="Content/Characters/Hammerhead/Hammerhead.xml" /> <Character file="Content/Characters/Hammerhead/Hammerhead.xml" />
<Outpost file="Content/Map/Outposts/Outpost.sub" /> <Outpost file="Content/Map/Outposts/Outpost.sub" />
<Outpost file="Content/Map/Outposts/Outpost2.sub" />
<Submarine file="Submarines/Orca.sub" /> <Submarine file="Submarines/Orca.sub" />
<Submarine file="Submarines/Typhon.sub" /> <Submarine file="Submarines/Typhon.sub" />
<Submarine file="Submarines/Selkie.sub" /> <Submarine file="Submarines/Selkie.sub" />
@@ -103,7 +102,13 @@
<MapGenerationParameters file="Content/Map/MapGenerationParameters.xml" /> <MapGenerationParameters file="Content/Map/MapGenerationParameters.xml" />
<LevelGenerationParameters file="Content/Map/LevelGenerationParameters.xml" /> <LevelGenerationParameters file="Content/Map/LevelGenerationParameters.xml" />
<Missions file="Content/Missions.xml" /> <Missions file="Content/Missions.xml" />
<NPCConversations file="Content/NPCConversations/NpcConversations.xml"/> <NPCConversations file="Content/NPCConversations/NpcConversations_English.xml"/>
<NPCConversations file="Content/NPCConversations/NpcConversations_German.xml"/>
<NPCConversations file="Content/NPCConversations/NpcConversations_French.xml"/>
<NPCConversations file="Content/NPCConversations/NpcConversations_Russian.xml"/>
<NPCConversations file="Content/NPCConversations/NpcConversations_BrazilianPortuguese.xml"/>
<NPCConversations file="Content/NPCConversations/NpcConversations_SimplifiedChinese.xml"/>
<NPCConversations file="Content/NPCConversations/NpcConversations_TraditionalChinese.xml"/>
<Jobs file="Content/Jobs.xml" /> <Jobs file="Content/Jobs.xml" />
<Sounds file="Content/Sounds/sounds.xml" /> <Sounds file="Content/Sounds/sounds.xml" />
<Tutorials file="Content/Tutorials/Tutorials.xml" /> <Tutorials file="Content/Tutorials/Tutorials.xml" />
@@ -2094,9 +2094,6 @@
<None Include="$(MSBuildThisFileDirectory)Content\Items\Weapons\ElectricalDischarger.ogg"> <None Include="$(MSBuildThisFileDirectory)Content\Items\Weapons\ElectricalDischarger.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="$(MSBuildThisFileDirectory)Content\Map\Outposts\Outpost2.sub">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\Gore1.ogg"> <None Include="$(MSBuildThisFileDirectory)Content\Sounds\Damage\Gore1.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
@@ -79,7 +79,7 @@ namespace Barotrauma
} }
} }
public static string Get(string textTag, bool returnNull = false, string fallBackTag = null) public static string Get(string textTag, bool returnNull = false)
{ {
if (!textPacks.ContainsKey(Language)) if (!textPacks.ContainsKey(Language))
{ {
@@ -94,16 +94,7 @@ namespace Barotrauma
foreach (TextPack textPack in textPacks[Language]) foreach (TextPack textPack in textPacks[Language])
{ {
string text = textPack.Get(textTag); string text = textPack.Get(textTag);
if (text != null) { return text; } if (text != null) return text;
}
if (!string.IsNullOrEmpty(fallBackTag))
{
foreach (TextPack textPack in textPacks[Language])
{
string text = textPack.Get(fallBackTag);
if (text != null) { return text; }
}
} }
//if text was not found and we're using a language other than English, see if we can find an English version //if text was not found and we're using a language other than English, see if we can find an English version