public void GenerateLua()
{
_list = new List<string>();
_list.Add("");
Structs.Child parentObj = null;
if(_root.document.children.Count > 1)
{
_list.Add("-- REMOVE ALL GROUPING IN YOUR PROJECT TO CONTINUE!!!");
return;
}
//Get parent window size
foreach(var el in _root.document.children[0].children)
{
if(el == null)
continue;
if(el.name.Equals(_parent))
{
parentObj = el;
break;
}
}
if (parentObj == null)
{
_list.Add("-- CAN T FIND THE PARENT ELEMENT, TRY AGAIN!");
return;
}
if(parentObj.absoluteBoundingBox == null)
{
_list.Add("-- YOUR BACKGROUND IS INVALID, PLEASE SELECT THE MOST DEEP IMAGE");
return;
}
double width, height;
if (double.TryParse(parentObj.absoluteBoundingBox.width.ToString(), out width)
&& double.TryParse(parentObj.absoluteBoundingBox.height.ToString(), out height))
{
_list.Add($"function sw(value)
return sx*value/{width}
end
function sh(value)
return sy*value/{height}
end");
}
else
{
_list.Add("-- WIDTH OR HEIGHT IS NULL OR IN INVALID FORMAT, PLEASE CHECK YOUR ELEMENTS");
}
//_list.Add("local x, y = (sW/resW), (sH/resH)");
_list.Add("");
_list.Add("function on()");
foreach(var el in _root.document.children[0].children)
{
if (el == null)
continue;
if (el.name.Equals(_parent))
continue;
var elType = el.type;
if(elType.Equals("RECTANGLE"))
{
if (el.fills[0].type.Equals("IMAGE"))
{
double opacity = 1.0f;
if (el.fills[0].opacity != null)
opacity = el.fills[0].opacity.GetValueOrDefault();
else
opacity = 1.0f;
//Console.WriteLine("test {0}",el.absoluteBoundingBox);
if (el.absoluteBoundingBox == null)
{
_list.Add(" -- ELEMENT jakis IS INVALID, PLEASE CONFIGURE IT PROPERLY");
continue;
}
int val_0 = int.Parse(el.absoluteBoundingBox.x.ToString());
int val_1 = int.Parse(el.absoluteBoundingBox.y.ToString());
int val_2 = int.Parse(el.absoluteBoundingBox.width.ToString());
int val_3 = int.Parse(el.absoluteBoundingBox.height.ToString());
请帮助。 我不知道这一错误会发生什么,我浪费了一小时或多小时的时间,超出了我,但对于一些人来说,这或许会很容易。
Throws an error System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s) ...
https://i.stack.imgur.com/ad41L.png” rel=“nofollow noreferer”>
_list.Add(string.Format(”) - ELEMENT jakis IS INVALID, PLEASE CONFIGURE IT PROPERLY”;
我删除了号”。 格式“,在“扼杀”方面仍有错误。