Recommended crew experience is saved using text tags instead of the actual text (-> experience texts can be translated without the translation showing up in sub files).

This commit is contained in:
Joonas Rikkonen
2018-08-15 12:06:22 +03:00
parent b1f8de887c
commit c2f9e1481f
3 changed files with 24 additions and 11 deletions

View File

@@ -146,7 +146,7 @@ namespace Barotrauma
"", frame, GUI.SmallFont);
new GUITextBlock(new Rectangle(246, 100, 100, 20),
TextManager.Get("RecommendedCrewExperience") + ": " + (string.IsNullOrEmpty(RecommendedCrewExperience) ? TextManager.Get("unknown") : RecommendedCrewExperience),
TextManager.Get("RecommendedCrewExperience") + ": " + (string.IsNullOrEmpty(RecommendedCrewExperience) ? TextManager.Get("unknown") : TextManager.Get(RecommendedCrewExperience)),
"", frame, GUI.SmallFont);
new GUITextBlock(new Rectangle(246, 120, 0, 20),

View File

@@ -15,9 +15,9 @@ namespace Barotrauma
{
private static string[] crewExperienceLevels = new string[]
{
TextManager.Get("CrewExperienceLow"),
TextManager.Get("CrewExperienceMid"),
TextManager.Get("CrewExperienceHigh")
"CrewExperienceLow",
"CrewExperienceMid",
"CrewExperienceHigh"
};
private Camera cam;
@@ -587,23 +587,26 @@ namespace Barotrauma
var toggleExpRight = new GUIButton(new Rectangle(350, y, 20, 20), ">", "", saveFrame);
var experienceText = new GUITextBlock(new Rectangle(250, y, 100, 20), crewExperienceLevels[0], "", Alignment.TopLeft, Alignment.Center, saveFrame);
toggleExpLeft.OnClicked += (btn, userData) =>
{
int currentIndex = Array.IndexOf(crewExperienceLevels, experienceText.Text);
int currentIndex = Array.IndexOf(crewExperienceLevels, (string)experienceText.UserData);
currentIndex--;
if (currentIndex < 0) currentIndex = crewExperienceLevels.Length - 1;
experienceText.Text = crewExperienceLevels[currentIndex];
Submarine.MainSub.RecommendedCrewExperience = experienceText.Text;
experienceText.UserData = crewExperienceLevels[currentIndex];
experienceText.Text = TextManager.Get(crewExperienceLevels[currentIndex]);
Submarine.MainSub.RecommendedCrewExperience = (string)experienceText.UserData;
return true;
};
toggleExpRight.OnClicked += (btn, userData) =>
{
int currentIndex = Array.IndexOf(crewExperienceLevels, experienceText.Text);
int currentIndex = Array.IndexOf(crewExperienceLevels, (string)experienceText.UserData);
currentIndex++;
if (currentIndex >= crewExperienceLevels.Length) currentIndex = 0;
experienceText.Text = crewExperienceLevels[currentIndex];
Submarine.MainSub.RecommendedCrewExperience = experienceText.Text;
experienceText.UserData = crewExperienceLevels[currentIndex];
experienceText.Text = TextManager.Get(crewExperienceLevels[currentIndex]);
Submarine.MainSub.RecommendedCrewExperience = (string)experienceText.UserData;
return true;
};
@@ -613,8 +616,9 @@ namespace Barotrauma
int max = Submarine.MainSub.RecommendedCrewSizeMax;
crewSizeMin.IntValue = min;
crewSizeMax.IntValue = max;
experienceText.Text = string.IsNullOrEmpty(Submarine.MainSub.RecommendedCrewExperience) ?
experienceText.UserData = string.IsNullOrEmpty(Submarine.MainSub.RecommendedCrewExperience) ?
crewExperienceLevels[0] : Submarine.MainSub.RecommendedCrewExperience;
experienceText.Text = TextManager.Get((string)experienceText.UserData);
}
var saveButton = new GUIButton(new Rectangle(-90, 0, 80, 20), TextManager.Get("SaveSubButton"), Alignment.Right | Alignment.Bottom, "", saveFrame);

View File

@@ -296,6 +296,15 @@ namespace Barotrauma
RecommendedCrewSizeMin = doc.Root.GetAttributeInt("recommendedcrewsizemin", 0);
RecommendedCrewSizeMax = doc.Root.GetAttributeInt("recommendedcrewsizemax", 0);
RecommendedCrewExperience = doc.Root.GetAttributeString("recommendedcrewexperience", "Unknown");
//backwards compatibility (use text tags instead of the actual text)
if (RecommendedCrewExperience == "Beginner")
RecommendedCrewExperience = "CrewExperienceLow";
else if (RecommendedCrewExperience == "Intermediate")
RecommendedCrewExperience = "CrewExperienceMid";
else if (RecommendedCrewExperience == "Experienced")
RecommendedCrewExperience = "CrewExperienceHigh";
string[] contentPackageNames = doc.Root.GetAttributeStringArray("compatiblecontentpackages", new string[0]);
foreach (string contentPackageName in contentPackageNames)
{