(edb24c37f) Fixed ItemComponents overwriting the Msg-tags ("ItemMsgPressSelect" etc) with the text fetched from the text xml, preventing the texts from being translated after the sub has been saved.
This commit is contained in:
@@ -496,7 +496,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
msg = msg.Replace("[" + inputType.ToString().ToLowerInvariant() + "]", GameMain.Config.KeyBind(inputType).ToString());
|
||||
}
|
||||
Msg = msg;
|
||||
DisplayMsg = msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayMsg = Msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (attachable)
|
||||
{
|
||||
prevMsg = Msg;
|
||||
prevMsg = DisplayMsg;
|
||||
prevPickKey = PickKey;
|
||||
prevRequiredItems = new Dictionary<RelatedItem.RelationType, List<RelatedItem>>(requiredItems);
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Barotrauma.Items.Components
|
||||
base.Load(componentElement);
|
||||
if (attachable)
|
||||
{
|
||||
prevMsg = Msg;
|
||||
prevMsg = DisplayMsg;
|
||||
prevPickKey = PickKey;
|
||||
prevRequiredItems = new Dictionary<RelatedItem.RelationType, List<RelatedItem>>(requiredItems);
|
||||
}
|
||||
@@ -404,8 +404,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
body.Enabled = false;
|
||||
item.body = null;
|
||||
|
||||
Msg = prevMsg;
|
||||
|
||||
DisplayMsg = prevMsg;
|
||||
PickKey = prevPickKey;
|
||||
requiredItems = new Dictionary<RelatedItem.RelationType, List<RelatedItem>>(prevRequiredItems);
|
||||
|
||||
@@ -420,7 +420,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
//make the item pickable with the default pick key and with no specific tools/items when it's deattached
|
||||
requiredItems.Clear();
|
||||
Msg = "";
|
||||
DisplayMsg = "";
|
||||
PickKey = InputType.Select;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,7 @@ namespace Barotrauma.Items.Components
|
||||
protected const float CorrectionDelay = 1.0f;
|
||||
protected CoroutineHandle delayedCorrectionCoroutine;
|
||||
protected float correctionTimer;
|
||||
|
||||
private string msg;
|
||||
|
||||
|
||||
[Editable, Serialize(0.0f, false)]
|
||||
public float PickingTime
|
||||
{
|
||||
@@ -191,13 +189,24 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
//TODO: this shouldn't be saved as-is, causes tags ("ItemMsgPressSelect" etc) to be converted into actual texts when saving the subs
|
||||
|
||||
[Editable, Serialize("", true)]
|
||||
public string Msg
|
||||
{
|
||||
get { return msg; }
|
||||
set { msg = value; }
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string DisplayMsg
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public AITarget AITarget
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public AITarget AITarget
|
||||
@@ -238,13 +247,13 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
string pickKeyStr = element.GetAttributeString("pickkey", "Select");
|
||||
pickKeyStr = ToolBox.ConvertInputType(pickKeyStr);
|
||||
PickKey = (InputType)Enum.Parse(typeof(InputType),pickKeyStr, true);
|
||||
PickKey = (InputType)Enum.Parse(typeof(InputType), pickKeyStr, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid pick key in " + element + "!", e);
|
||||
}
|
||||
|
||||
|
||||
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
|
||||
ParseMsg();
|
||||
|
||||
@@ -535,6 +544,7 @@ namespace Barotrauma.Items.Components
|
||||
GameAnalyticsManager.AddErrorEventOnce("ItemComponent.DegreeOfSuccess:CharacterNull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return 0.0f;
|
||||
}
|
||||
float average = skillSuccessSum / requiredSkills.Count;
|
||||
|
||||
float skillSuccessSum = 0.0f;
|
||||
for (int i = 0; i < requiredSkills.Count; i++)
|
||||
|
||||
@@ -1551,14 +1551,14 @@ namespace Barotrauma
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ic.Msg)) continue;
|
||||
if (string.IsNullOrEmpty(ic.DisplayMsg)) continue;
|
||||
if (!ic.CanBePicked && !ic.CanBeSelected) continue;
|
||||
if (ic is Holdable holdable && !holdable.CanBeDeattached()) continue;
|
||||
|
||||
Color color = Color.Red;
|
||||
if (ic.HasRequiredSkills(character) && ic.HasRequiredItems(character, false)) color = Color.Orange;
|
||||
|
||||
texts.Add(new ColoredText(ic.Msg, color, false));
|
||||
texts.Add(new ColoredText(ic.DisplayMsg, color, false));
|
||||
}
|
||||
|
||||
return texts;
|
||||
|
||||
Reference in New Issue
Block a user