【优化】支持excel定义字段时支持tags属性

【优化】解析excel字段属性时,只拆解第一个'='
main
walon 2021-08-31 17:33:40 +08:00
parent f82df5d68d
commit ec84a0be64
3 changed files with 137 additions and 1 deletions

View File

@ -0,0 +1,126 @@
using Luban.Job.Cfg.Datas;
using System;
using System.Numerics;
namespace Luban.Job.Cfg.DataVisitors
{
class IsSimpleLiteralDataVisitor2 : IDataFuncVisitor<bool>
{
public static IsSimpleLiteralDataVisitor2 Ins { get; } = new();
public bool Accept(DBool type)
{
return true;
}
public bool Accept(DByte type)
{
return true;
}
public bool Accept(DShort type)
{
return true;
}
public bool Accept(DFshort type)
{
return true;
}
public bool Accept(DInt type)
{
return true;
}
public bool Accept(DFint type)
{
return true;
}
public bool Accept(DLong type)
{
return true;
}
public bool Accept(DFlong type)
{
return true;
}
public bool Accept(DFloat type)
{
return true;
}
public bool Accept(DDouble type)
{
return true;
}
public bool Accept(DEnum type)
{
return true;
}
public bool Accept(DString type)
{
return true;
}
public bool Accept(DBytes type)
{
throw new NotSupportedException();
}
public bool Accept(DText type)
{
return true;
}
public bool Accept(DBean type)
{
return false;
}
public bool Accept(DArray type)
{
return false;
}
public bool Accept(DList type)
{
return false;
}
public bool Accept(DSet type)
{
return false;
}
public bool Accept(DMap type)
{
return false;
}
public bool Accept(DVector2 type)
{
return true;
}
public bool Accept(DVector3 type)
{
return true;
}
public bool Accept(DVector4 type)
{
return true;
}
public bool Accept(DDateTime type)
{
return true;
}
}
}

View File

@ -353,7 +353,7 @@ namespace Luban.Job.Cfg.Defs
for (int i = 1; i < attrs.Length; i++) for (int i = 1; i < attrs.Length; i++)
{ {
var pair = attrs[i].Split('='); var pair = attrs[i].Split('=', 2);
if (pair.Length != 2) if (pair.Length != 2)
{ {
throw new Exception($"table:'{table.Name}' file:{file.OriginFile} title:'{f.Name}' attr:'{attrs[i]}' is invalid!"); throw new Exception($"table:'{table.Name}' file:{file.OriginFile} title:'{f.Name}' attr:'{attrs[i]}' is invalid!");
@ -406,6 +406,11 @@ namespace Luban.Job.Cfg.Defs
cf.DefaultValue = attrValue; cf.DefaultValue = attrValue;
break; break;
} }
case "tags":
{
cf.Tags = attrValue;
break;
}
default: default:
{ {
throw new Exception($"table:'{table.Name}' file:{file.OriginFile} title:'{f.Name}' attr:'{attrs[i]}' is invalid!"); throw new Exception($"table:'{table.Name}' file:{file.OriginFile} title:'{f.Name}' attr:'{attrs[i]}' is invalid!");

View File

@ -16,6 +16,11 @@ namespace Luban.Job.Cfg.Utils
return type.Apply(IsSimpleLiteralDataVisitor.Ins); return type.Apply(IsSimpleLiteralDataVisitor.Ins);
} }
public static bool IsSimpleLiteralData2(DType type)
{
return type.Apply(IsSimpleLiteralDataVisitor2.Ins);
}
public static string ToLocalizedText(DText type) public static string ToLocalizedText(DText type)
{ {
var ass = DefAssembly.LocalAssebmly; var ass = DefAssembly.LocalAssebmly;