Commit 69cd5ef3 authored by SherryChaos's avatar SherryChaos

Fix segmentation error in description of pendulum card

parent 117ecad5
...@@ -258,7 +258,7 @@ namespace MDPro3 ...@@ -258,7 +258,7 @@ namespace MDPro3
cardArtPendulum.gameObject.SetActive(true); cardArtPendulum.gameObject.SetActive(true);
cardArtPendulum.texture = art; cardArtPendulum.texture = art;
} }
var pendulumDescription = CardDescription.GetCardDescriptionSplit(data.Desc); var pendulumDescription = CardDescription.GetCardDescriptionSplit(data.Desc, true);
cardDescription.text = StringHelper.GetType(data, true).Replace(Program.slash, bigSlash) + "\r\n" + TextForRender(pendulumDescription[1]); cardDescription.text = StringHelper.GetType(data, true).Replace(Program.slash, bigSlash) + "\r\n" + TextForRender(pendulumDescription[1]);
cardDescriptionPendulum.text = TextForRender(pendulumDescription[0]); cardDescriptionPendulum.text = TextForRender(pendulumDescription[0]);
lScale.text = data.LScale.ToString(); lScale.text = data.LScale.ToString();
......
...@@ -501,30 +501,50 @@ namespace MDPro3 ...@@ -501,30 +501,50 @@ namespace MDPro3
return returnValue; return returnValue;
} }
public static string[] GetCardDescriptionSplit(string description) public static string[] GetCardDescriptionSplit(string description, bool render = false)
{ {
var returnValue = new string[2]; var returnValue = new string[2];
var lines = description.Replace("\r", "").Split('\n'); var lines = description.Replace("\r", "").Split('\n');
var language = render ? Config.Get("CardLanguage", "zh-CN") : Config.Get("Language", "zh-CN");
int pendulumEnd = 0; int beforePendulum = 1;
for (int i = 1; i < lines.Length; i++) int splitLines = 1;
string symbol = "";
int monsterStart = 0;
if (language == "en-US")
{
beforePendulum = 2;
splitLines = 2;
symbol = "[";
}
if (language == "es-ES")
{
beforePendulum = 2;
splitLines = 2;
}
if (language == "zh-TW")
{ {
if (lines[i].Contains("")) beforePendulum = 0;
}
for (int i = beforePendulum; i < lines.Length; i++)
if (lines[i].StartsWith(symbol))
{ {
pendulumEnd = i; monsterStart = i;
break; break;
} }
}
for (int i = 1; i < lines.Length; i++) for (int i = beforePendulum; i < lines.Length; i++)
{ {
if (i < pendulumEnd) if (i <= monsterStart - splitLines)
{ {
if (pendulumEnd - i == 1) if (monsterStart - i == splitLines)
returnValue[0] += lines[i]; returnValue[0] += lines[i];
else else
returnValue[0] += lines[i] + "\r\n"; returnValue[0] += lines[i] + "\r\n";
} }
else if (i > pendulumEnd) else if (i > monsterStart)
{ {
if (i == lines.Length - 1) if (i == lines.Length - 1)
returnValue[1] += lines[i]; returnValue[1] += lines[i];
...@@ -532,6 +552,8 @@ namespace MDPro3 ...@@ -532,6 +552,8 @@ namespace MDPro3
returnValue[1] += lines[i] + "\r\n"; returnValue[1] += lines[i] + "\r\n";
} }
} }
if (language == "es-ES")
returnValue[0] = returnValue[0].Replace("-n/a-", string.Empty);
return returnValue; return returnValue;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment