(32ba1d322) When editing an item label or a room name, the text is colored gray/green according to whether the text can be translated (= if a matching text tag is found in the language files). There's also now a "text picker menu" that can be used to pick the text from a list of translatable texts. TODO: use this in ItemComponent.Msg and CustomInterface button/tickbox labels.
This commit is contained in:
@@ -109,6 +109,25 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private string roomName;
|
||||
[Editable, Serialize("", true, translationTextTag: "RoomName.")]
|
||||
public string RoomName
|
||||
{
|
||||
get { return roomName; }
|
||||
set
|
||||
{
|
||||
if (roomName == value) { return; }
|
||||
roomName = value;
|
||||
DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName;
|
||||
}
|
||||
}
|
||||
|
||||
public override Rectangle Rect
|
||||
{
|
||||
get
|
||||
|
||||
@@ -55,11 +55,20 @@ namespace Barotrauma
|
||||
{
|
||||
public object defaultValue;
|
||||
public bool isSaveable;
|
||||
public string translationTextTag;
|
||||
|
||||
public Serialize(object defaultValue, bool isSaveable)
|
||||
/// <summary>
|
||||
/// Makes the property serializable to/from XML
|
||||
/// </summary>
|
||||
/// <param name="defaultValue">The property is set to this value during deserialization if the value is not defined in XML.</param>
|
||||
/// <param name="isSaveable">Is the value saved to XML when serializing.</param>
|
||||
/// <param name="translationTextTag">If set to anything else than null, SerializableEntityEditors will show what the text gets translated to or warn if the text is not found in the language files.
|
||||
/// Setting the value to a non-empty string will let the user select the text from one whose tag starts with the given string (e.g. RoomName. would show all texts with a RoomName.* tag)</param>
|
||||
public Serialize(object defaultValue, bool isSaveable, string translationTextTag = null)
|
||||
{
|
||||
this.defaultValue = defaultValue;
|
||||
this.isSaveable = isSaveable;
|
||||
this.translationTextTag = translationTextTag;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,6 +252,28 @@ namespace Barotrauma
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<KeyValuePair<string, string>> GetAllTagTextPairs()
|
||||
{
|
||||
if (!textPacks.ContainsKey(Language))
|
||||
{
|
||||
DebugConsole.ThrowError("No text packs available for the selected language (" + Language + ")! Switching to English...");
|
||||
Language = "English";
|
||||
if (!textPacks.ContainsKey(Language))
|
||||
{
|
||||
throw new Exception("No text packs available in English!");
|
||||
}
|
||||
}
|
||||
|
||||
List<KeyValuePair<string, string>> allText = new List<KeyValuePair<string, string>>();
|
||||
|
||||
foreach (TextPack textPack in textPacks[Language])
|
||||
{
|
||||
allText.AddRange(textPack.GetAllTagTextPairs());
|
||||
}
|
||||
|
||||
return allText;
|
||||
}
|
||||
|
||||
public static string ReplaceGenderPronouns(string text, Gender gender)
|
||||
{
|
||||
if (gender == Gender.Male)
|
||||
|
||||
@@ -62,6 +62,20 @@ namespace Barotrauma
|
||||
return textList;
|
||||
}
|
||||
|
||||
public List<KeyValuePair<string, string>> GetAllTagTextPairs()
|
||||
{
|
||||
var pairs = new List<KeyValuePair<string, string>>();
|
||||
foreach (KeyValuePair<string, List<string>> kvp in texts)
|
||||
{
|
||||
foreach (string line in kvp.Value)
|
||||
{
|
||||
pairs.Add(new KeyValuePair<string, string>(kvp.Key, line));
|
||||
}
|
||||
}
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public void CheckForDuplicates(int index)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user