|
@@ -22,7 +22,10 @@ namespace GFGEditor
|
|
|
|
|
|
private static List<string> _names = new List<string>();
|
|
|
private static List<string> _types = new List<string>();
|
|
|
+ private static List<string> _allNames = new List<string>();
|
|
|
+ private static List<string> _allTypes = new List<string>();
|
|
|
private static List<int> _indexs = new List<int>();
|
|
|
+ private static List<int> _allIndexs = new List<int>();
|
|
|
private static Dictionary<string, string> _idDic = new Dictionary<string, string>();
|
|
|
private static Dictionary<string, string> _itemTypeDicByName = new Dictionary<string, string>();
|
|
|
|
|
@@ -33,9 +36,12 @@ namespace GFGEditor
|
|
|
_assignmentBuilder.Clear();
|
|
|
_parseBuilder.Clear();
|
|
|
_names.Clear();
|
|
|
+ _allNames.Clear();
|
|
|
_types.Clear();
|
|
|
- _idDic.Clear();
|
|
|
+ _allTypes.Clear();
|
|
|
_indexs.Clear();
|
|
|
+ _allIndexs.Clear();
|
|
|
+ _idDic.Clear();
|
|
|
//_hasSameIds = false;
|
|
|
List<string> keyName = new List<string>();//默认用id查询单条数据
|
|
|
List<string> keyType = new List<string>();
|
|
@@ -49,13 +55,15 @@ namespace GFGEditor
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ worksheet = HandleExcelWorksheet(worksheet);
|
|
|
for (int i = 1; i <= len; ++i)
|
|
|
{
|
|
|
ET.Log.Debug($"GenerateCode for i {i}");
|
|
|
string annotation = worksheet.Cells[1, i].Text.Trim();
|
|
|
- string type = worksheet.Cells[2, i].Text.Trim();
|
|
|
+ string typeWhole = worksheet.Cells[2, i].Text.Trim();
|
|
|
+ string type = typeWhole.Split('#')[0];
|
|
|
string nameWhole = worksheet.Cells[3, i].Text.Trim();
|
|
|
- string[] nameInfos = nameWhole.Split('#');
|
|
|
+ string[] nameInfos = nameWhole.Split('#', '&');//#和&不会同时存在,即不会将数组用作数据查询的关键字key
|
|
|
string name = nameInfos[0];
|
|
|
if (i == 1)
|
|
|
{
|
|
@@ -92,7 +100,7 @@ namespace GFGEditor
|
|
|
groupOnly = true;
|
|
|
}
|
|
|
}
|
|
|
- ParseDataColumn(annotation, type, name, i);
|
|
|
+ ParseDataColumn(annotation, type, name, nameWhole, typeWhole, i);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -265,16 +273,22 @@ namespace GFGEditor
|
|
|
return FunctionGroupStr;
|
|
|
|
|
|
}
|
|
|
- private static void ParseDataColumn(string annotation, string type, string name, int index)
|
|
|
+ private static void ParseDataColumn(string annotation, string type, string name, string nameWhole, string typeWhole, int index)
|
|
|
{
|
|
|
if (type.Length > 0 && name.Length > 0)
|
|
|
{
|
|
|
+
|
|
|
+ _allNames.Add(nameWhole);
|
|
|
+ _allTypes.Add(typeWhole);
|
|
|
+ _allIndexs.Add(index);
|
|
|
+
|
|
|
+ if (_names.IndexOf(SQL_PREFIX + name) >= 0) return;
|
|
|
_names.Add(SQL_PREFIX + name);
|
|
|
_types.Add("TEXT");
|
|
|
_indexs.Add(index);
|
|
|
|
|
|
//生成解析后的数据变量
|
|
|
- _declarationBuilder.AppendFormat("\t\t//{0}", annotation);
|
|
|
+ _declarationBuilder.AppendFormat("\t\t//{0}", annotation.Split('#')[0]);
|
|
|
_declarationBuilder.AppendLine();
|
|
|
if (type.Contains("[]"))
|
|
|
{
|
|
@@ -327,7 +341,10 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ private static ExcelWorksheet HandleExcelWorksheet(ExcelWorksheet worksheet)
|
|
|
+ {
|
|
|
+ return worksheet;
|
|
|
+ }
|
|
|
|
|
|
private static void AddDataToSql(ExcelWorksheet worksheet, string configName, string configArrayName)
|
|
|
{
|
|
@@ -352,40 +369,46 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void WriteRowDataToSqlite(ExcelRange excelRange, string configArrayName, int row)
|
|
|
+ private static void WriteRowDataToSqlite(ExcelRange worksheet, string configArrayName, int row)
|
|
|
{
|
|
|
List<string> values = new List<string>();
|
|
|
- var keyValue = excelRange[row, 1].Text.Trim();
|
|
|
+ var keyValue = worksheet[row, 1].Text.Trim();
|
|
|
foreach (var i in _indexs)
|
|
|
{
|
|
|
- var fieldName = _names[i - 1];
|
|
|
- var value = excelRange[row, i].Text.Trim();
|
|
|
- if (configArrayName == nameof(ItemTypeCfgArray))
|
|
|
+ if (configArrayName == "GiftBagCfgArray")
|
|
|
{
|
|
|
- CacheItemTypeByName(keyValue, fieldName, value);
|
|
|
+ Debug.Log("zoya");
|
|
|
}
|
|
|
- else if (configArrayName == nameof(ItemCfgArray))
|
|
|
+ var fieldName = _allNames[i - 1];
|
|
|
+ var name = fieldName.Split('#')[0];
|
|
|
+ var value = worksheet[row, i].Text.Trim();
|
|
|
+ if (configArrayName == nameof(ItemTypeCfgArray) && name == "name")
|
|
|
{
|
|
|
- HandleItemCfgField(keyValue, fieldName, ref value);
|
|
|
+ CacheItemTypeByName(keyValue, name, value);
|
|
|
+ values.Add(value);
|
|
|
+ }
|
|
|
+ else if (configArrayName == nameof(ItemCfgArray) && (name == "itemType" || name == "subType"))
|
|
|
+ {
|
|
|
+ HandleItemCfgField(keyValue, name, ref value);
|
|
|
+ values.Add(value);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string _value = GetValue(configArrayName, worksheet, name, row, i);
|
|
|
+ values.Add(_value);
|
|
|
}
|
|
|
-
|
|
|
- //value = Regex.Replace(value, ":", "/:");
|
|
|
- values.Add(value);
|
|
|
}
|
|
|
SQLiteHelper.Instance.InsertValues(configArrayName, values.ToArray());
|
|
|
}
|
|
|
|
|
|
private static void CacheItemTypeByName(string idStr, string fieldName, string value)
|
|
|
{
|
|
|
- if (fieldName == SQL_PREFIX + "name")
|
|
|
- {
|
|
|
- _itemTypeDicByName[value] = idStr;
|
|
|
- }
|
|
|
+ _itemTypeDicByName[value] = idStr;
|
|
|
}
|
|
|
|
|
|
private static void HandleItemCfgField(string idStr, string fieldName, ref string value)
|
|
|
{
|
|
|
- fieldName = fieldName.Substring(1);
|
|
|
+ // fieldName = fieldName.Substring(1);
|
|
|
ET.Log.Debug($"idStr {idStr} fieldName {fieldName} value {value}");
|
|
|
int id = int.Parse(idStr);
|
|
|
int itemType = (int)Mathf.Floor(id / GameConst.MAX_COUNT_EVERY_TYPE_ITEM);
|
|
@@ -416,11 +439,6 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // else if (fieldName == "resLayer1" || fieldName == "resLayer2")
|
|
|
- // {
|
|
|
- // value = value.Replace('n', '1');
|
|
|
- // value = value.Replace('t', '2');
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
private static void CreateParamsString(List<string> keyNames, List<string> keyTypes, out string paramStr, out string colNames, out string colValues)
|
|
@@ -442,5 +460,80 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private static string GetValue(string configArrayName, ExcelRange worksheet, string name, int row, int index)
|
|
|
+ {
|
|
|
+ Dictionary<string, List<string>> _twoDimensionalDic = new Dictionary<string, List<string>>();
|
|
|
+ string value = "";
|
|
|
+ // foreach (var i in _allIndexs)
|
|
|
+ // {
|
|
|
+ for (int i = index - 1; i < _allIndexs.Count; i++)
|
|
|
+ {
|
|
|
+ // int _index = i - 1;
|
|
|
+ string _name = _allNames[i];
|
|
|
+ string[] _names = _name.Split('#');
|
|
|
+ string _type = _allTypes[i];
|
|
|
+ string[] _types = _type.Split('#');
|
|
|
+ string _value = worksheet[row, i + 1].Text.Trim();
|
|
|
+ if (_names[0] != name) continue;
|
|
|
+
|
|
|
+
|
|
|
+ if (_type.Contains("[][]") && _type.Contains("#"))
|
|
|
+ {
|
|
|
+ if (!_twoDimensionalDic.ContainsKey(_types[1]) && string.IsNullOrEmpty(_value))
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(_value))
|
|
|
+ {
|
|
|
+ ET.Log.Error(configArrayName + " 第" + row + "行 " + _type + " 无数值!");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!_twoDimensionalDic.ContainsKey(_types[1]))
|
|
|
+ {
|
|
|
+ _twoDimensionalDic.Add(_types[1], new List<string>());
|
|
|
+ }
|
|
|
+ _twoDimensionalDic[_types[1]].Add(_value);
|
|
|
+ }
|
|
|
+ else if (_type.Contains("[]") && _type.Contains("#"))
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(_value)) continue;
|
|
|
+ if (string.IsNullOrEmpty(value))
|
|
|
+ {
|
|
|
+ value = _value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ value = string.Format("{0};{1}", value, _value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ value = _value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_twoDimensionalDic.Count > 0)
|
|
|
+ {
|
|
|
+ List<string> _values = new List<string>();
|
|
|
+ foreach (string key in _twoDimensionalDic.Keys)
|
|
|
+ {
|
|
|
+ // if (!_twoDimensionalDic[key].ContainsKey(0)) continue;
|
|
|
+ // string _value0 = _twoDimensionalDic[key][0];
|
|
|
+ // if (!_twoDimensionalDic[key].ContainsKey(1))
|
|
|
+ // {
|
|
|
+ // _values.Add(_value0);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // string str = string.Format("{0}*{1}", _value0, _twoDimensionalDic[key][1]);
|
|
|
+ // _values.Add(str);
|
|
|
+ // }
|
|
|
+ _values.Add(string.Join("*", _twoDimensionalDic[key]));
|
|
|
+ }
|
|
|
+ value = string.Join(";", _values);
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|