ConfigMgr.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class ConfigMgr : Singleton<ConfigMgr>
  5. {
  6. private int linestart = 1;
  7. private int rowstart = 1;
  8. private string splitword = ",";
  9. private static bool m_bInitCSVFinished = false;
  10. private static bool m_bInitXMLFinished = false;
  11. public static bool InitFinished
  12. {
  13. get { return m_bInitCSVFinished && m_bInitXMLFinished; }
  14. }
  15. private static string m_strCurLangKey = LangKeys.ChinaSimplifiedFull;
  16. public static string CurLangKey
  17. {
  18. get { return m_strCurLangKey; }
  19. set
  20. {
  21. if (m_strCurLangKey != value)
  22. {
  23. //m_bInitCSVFinished = false;
  24. m_strCurLangKey = value;
  25. //I18N
  26. }
  27. }
  28. }
  29. public Dictionary<string, Dictionary<string, Dictionary<string, string>>> ConfigDictionary;
  30. public Dictionary<string, int> ConfigLongthDictionary;
  31. private Dictionary<string, string> mXmlConfigDict;
  32. public Dictionary<string, string> XmlConfigDict
  33. {
  34. get { return mXmlConfigDict; }
  35. }
  36. public override void Init()
  37. {
  38. base.Init();
  39. m_bInitCSVFinished = false;
  40. m_bInitXMLFinished = false;
  41. ConfigDictionary = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>(19);
  42. ConfigLongthDictionary = new Dictionary<string, int>(19);
  43. mXmlConfigDict = new Dictionary<string, string>();
  44. GetConfigAsset();
  45. }
  46. public override void UnInit()
  47. {
  48. if (LaunchThread.HasInstance())
  49. {
  50. LaunchThread.Instance.Stop(LaunchThread.AsyncLaunchState.ConfigInit);
  51. }
  52. base.UnInit();
  53. }
  54. private void GetConfigAsset()
  55. {
  56. if (InitFinished)
  57. return;
  58. ResourceMgr.Instance.LoadDirAsset<List<TextAsset>>(OnLoadXmlCallback, Constants.XmlConfig);
  59. ResourceMgr.Instance.LoadDirAsset<List<TextAsset>>(OnCallBack, Constants.CsvConfig);
  60. }
  61. public void ResetKeywords()
  62. {
  63. if (InitFinished)
  64. return;
  65. string m_tableName = string.Format("LanguagePackage{0}", ConfigMgr.CurLangKey);
  66. if (ConfigDictionary != null && ConfigDictionary.ContainsKey(m_tableName))
  67. {
  68. m_bInitCSVFinished = true;
  69. DebugHelper.Log(" [ConfigMgr] getKeywordsConfigAsset");
  70. }
  71. else
  72. {
  73. ResourceMgr.Instance.LoadAsset<List<TextAsset>>(OnResetKeywordsCallBack, Constants.CsvConfig, ELoadType.UI, m_tableName);
  74. }
  75. }
  76. void OnCallBack(List<TextAsset> objs, string path_, string[] assetNames_)
  77. {
  78. if (objs == null || objs.Count <= 0)
  79. {
  80. EventMgr.DispatchEvent(new CoreEvent<int>(ECoreEventType.EID_ConfigMgrInit, 0));
  81. return;
  82. }
  83. if (LaunchThread.HasInstance())
  84. {
  85. string keyword = "LanguagePackage";
  86. string keywordname = string.Format("{0}{1}", keyword, CurLangKey);
  87. string curname = string.Empty;
  88. TextAsset tx;
  89. List<string> names = new List<string>();
  90. List<string> contents = new List<string>();
  91. for (int i = 0; i < objs.Count; ++i)
  92. {
  93. tx = objs[i];
  94. curname = tx.name;
  95. //Debug.Log($"Config Name = [{curname}]");
  96. if (/*curname.Contains(keyword) && !curname.Equals(keywordname) ||*/ tx.text.Length <= 0)
  97. continue;
  98. names.Add(curname);
  99. contents.Add(tx.text);
  100. }
  101. keyword = string.Empty;
  102. keywordname = string.Empty;
  103. curname = string.Empty;
  104. System.Action action = () =>
  105. {
  106. for (int i = 0, iMax = names.Count; i < iMax; i++)
  107. {
  108. curname = names[i];
  109. Dictionary<string, Dictionary<string, string>> ts = getData(curname, contents[i]);
  110. if (ConfigDictionary.ContainsKey(curname))
  111. {
  112. ConfigDictionary[curname] = ts;
  113. }
  114. else
  115. {
  116. ConfigDictionary.Add(curname, ts);
  117. }
  118. }
  119. m_bInitCSVFinished = true;
  120. };
  121. LaunchThread.Instance.Start(LaunchThread.AsyncLaunchState.ConfigInit, action, CheckCfgOk, null);
  122. }
  123. else
  124. {
  125. string keyword = "LanguagePackage";
  126. string keywordname = string.Format("{0}{1}", keyword, CurLangKey);
  127. string curname = string.Empty;
  128. TextAsset tx;
  129. for (int i = 0; i < objs.Count; ++i)
  130. {
  131. tx = objs[i];
  132. curname = tx.name;
  133. if (/*curname.Contains(keyword) && !curname.Equals(keywordname) || */tx.text.Length <= 0)
  134. continue;
  135. Dictionary<string, Dictionary<string, string>> ts = getData(curname, tx.text);
  136. if (ConfigDictionary.ContainsKey(curname))
  137. {
  138. ConfigDictionary[curname] = ts;
  139. }
  140. else
  141. {
  142. ConfigDictionary.Add(curname, ts);
  143. }
  144. }
  145. m_bInitCSVFinished = true;
  146. keyword = string.Empty;
  147. keywordname = string.Empty;
  148. curname = string.Empty;
  149. tx = null;
  150. CheckCfgOk();
  151. }
  152. }
  153. void OnLoadXmlCallback(List<TextAsset> objs, string path_, string[] assetNames_)
  154. {
  155. TextAsset tx;
  156. for (int i = 0; i < objs.Count; ++i)
  157. {
  158. tx = objs[i];
  159. mXmlConfigDict.Add(tx.name, tx.text);
  160. }
  161. m_bInitXMLFinished = true;
  162. CheckCfgOk();
  163. }
  164. void CheckCfgOk()
  165. {
  166. if(InitFinished)
  167. {
  168. EventMgr.DispatchEvent(new CoreEvent<int>(ECoreEventType.EID_ConfigMgrInit, 1));
  169. }
  170. }
  171. void OnResetKeywordsCallBack(List<TextAsset> objs, string assetPath_, string[] assetNames_)
  172. {
  173. if (objs == null || objs.Count <= 0)
  174. {
  175. DebugHelper.Log("No Config Data AssetBundle");
  176. return;
  177. }
  178. string keyword = "LanguagePackage";
  179. string keywordname = string.Format("{0}{1}", keyword, CurLangKey);
  180. TextAsset tx;
  181. string curname = string.Empty;
  182. for (int i = 0; i < objs.Count; ++i)
  183. {
  184. tx = objs[i];
  185. curname = tx.name;
  186. if (/*curname.Contains(keyword) && !curname.Equals(keywordname) ||*/ tx.text.Length <= 0)
  187. continue;
  188. Dictionary<string, Dictionary<string, string>> ts = getData(curname, tx.text);
  189. if (ConfigDictionary != null)
  190. {
  191. if (ConfigDictionary.ContainsKey(curname))
  192. {
  193. ConfigDictionary[curname] = ts;
  194. }
  195. else
  196. {
  197. ConfigDictionary.Add(curname, ts);
  198. }
  199. }
  200. }
  201. m_bInitCSVFinished = true;
  202. }
  203. private Dictionary<string, Dictionary<string, string>> getData(string name, string content)
  204. {
  205. if (name.Contains("Language"))
  206. {
  207. return getData_New(name,content);
  208. }
  209. string[] lineArray;
  210. string[] charArray = null;
  211. // string text = content.Replace("\r", "@");
  212. // lineArray = text.Split("@"[0]);
  213. System.IO.StringReader reader = new System.IO.StringReader(content);
  214. string str = reader.ReadLine();
  215. List<string> tempList = new List<string>();
  216. while (!string.IsNullOrEmpty(str))
  217. {
  218. tempList.Add(str);
  219. str = reader.ReadLine();
  220. }
  221. lineArray = tempList.ToArray();
  222. //DebugHelper.LogWarning("[TableName: {0}]lineArray {1}",name, lineArray[0]);
  223. string[] indexname = null;
  224. if (name.Contains("Language"))
  225. {
  226. indexname = FileHelper.SpiltData(lineArray[1]);
  227. }
  228. else
  229. {
  230. indexname = lineArray[1].Split(splitword[0]);
  231. }
  232. Dictionary<string, Dictionary<string, string>> Table = new Dictionary<string, Dictionary<string, string>>(lineArray.Length);
  233. int linelength = 0;
  234. for (int i = linestart; i < lineArray.Length; ++i)
  235. {
  236. if (name.Contains("Language"))
  237. {
  238. charArray = FileHelper.SpiltData(lineArray[i]);
  239. }
  240. else
  241. {
  242. charArray = lineArray[i].Split(splitword[0]);
  243. }
  244. linelength = charArray.Length;
  245. if (linelength > 0 && charArray[0] == string.Empty)
  246. {
  247. //DebugHelper.LogWarning("[ConfigMgr. getData] Empty Index {0} {1}", name, i);
  248. continue;
  249. }
  250. Dictionary<string, string> Row = new Dictionary<string, string>(linelength);
  251. for (int j = rowstart; j < linelength; ++j)
  252. {
  253. if (j == rowstart && indexname[j] == string.Empty)
  254. {
  255. DebugHelper.LogWarning("[ConfigMgr. getData] Empty key {0} {1}", name, j);
  256. continue;
  257. }
  258. #if UNITY_EDITOR
  259. if (j >= indexname.Length)
  260. {
  261. DebugHelper.LogError("{0},Split error in {1}", name, charArray[0]);
  262. }
  263. #endif
  264. if (Row.ContainsKey(indexname[j]))
  265. {
  266. //DebugHelper.LogWarning("[ConfigMgr. getData] {0} {1}", name, indexname[j]);
  267. continue;
  268. }
  269. Row.Add(indexname[j], charArray[j]);
  270. }
  271. if (Table.ContainsKey(charArray[0]))
  272. {
  273. //DebugHelper.LogWarning("[ConfigMgr. getData] {0} {1} {2}" , name , i, lineArray[i-1]);
  274. continue;
  275. }
  276. Table.Add(charArray[0], Row);
  277. }
  278. if (ConfigLongthDictionary != null && !ConfigLongthDictionary.ContainsKey(name))
  279. {
  280. //int length = lineArray.Length - (linestart + 1);
  281. int length = lineArray.Length - (linestart);
  282. ConfigLongthDictionary.Add(name, length);
  283. }
  284. return Table;
  285. }
  286. private string[] GetLanguageString(string text)
  287. {
  288. string[] ret = null;
  289. int i = text.IndexOf(',');
  290. if (i >= 0)
  291. {
  292. ret = new string[2];
  293. ret[0] = text.Substring(0,i);
  294. ret[1] = FileHelper.RemoveHeadandTailChar(text.Substring(i + 1, text.Length - i - 1), '"');
  295. //Debug.Log($"1 = {ret[0]} 2 = {ret[1]}");
  296. }
  297. return ret;
  298. }
  299. private Dictionary<string, Dictionary<string, string>> getData_New(string name, string content)
  300. {
  301. string[] lineArray;
  302. string[] charArray = null;
  303. System.IO.StringReader reader = new System.IO.StringReader(content);
  304. string str = reader.ReadLine();
  305. List<string> tempList = new List<string>();
  306. while (!string.IsNullOrEmpty(str))
  307. {
  308. tempList.Add(str);
  309. str = reader.ReadLine();
  310. }
  311. lineArray = tempList.ToArray();
  312. string[] indexname = null;
  313. indexname = GetLanguageString(lineArray[1]);
  314. Dictionary<string, Dictionary<string, string>> Table = new Dictionary<string, Dictionary<string, string>>(lineArray.Length);
  315. int linelength = 0;
  316. for (int i = linestart; i < lineArray.Length; ++i)
  317. {
  318. charArray = GetLanguageString(lineArray[i]);
  319. linelength = charArray.Length;
  320. if (linelength > 0 && charArray[0] == string.Empty)
  321. {
  322. //DebugHelper.LogWarning("[ConfigMgr. getData] Empty Index {0} {1}", name, i);
  323. continue;
  324. }
  325. Dictionary<string, string> Row = new Dictionary<string, string>(linelength);
  326. for (int j = rowstart; j < linelength; ++j)
  327. {
  328. if (j == rowstart && indexname[j] == string.Empty)
  329. {
  330. DebugHelper.LogWarning("[ConfigMgr. getData] Empty key {0} {1}", name, j);
  331. continue;
  332. }
  333. #if UNITY_EDITOR
  334. if (j >= indexname.Length)
  335. {
  336. DebugHelper.LogError("{0},Split error in {1}", name, charArray[0]);
  337. }
  338. #endif
  339. if (Row.ContainsKey(indexname[j]))
  340. {
  341. //DebugHelper.LogWarning("[ConfigMgr. getData] {0} {1}", name, indexname[j]);
  342. continue;
  343. }
  344. Row.Add(indexname[j], charArray[j]);
  345. }
  346. if (Table.ContainsKey(charArray[0]))
  347. {
  348. //DebugHelper.LogWarning("[ConfigMgr. getData] {0} {1} {2}" , name , i, lineArray[i-1]);
  349. continue;
  350. }
  351. Table.Add(charArray[0], Row);
  352. }
  353. if (ConfigLongthDictionary != null && !ConfigLongthDictionary.ContainsKey(name))
  354. {
  355. //int length = lineArray.Length - (linestart + 1);
  356. int length = lineArray.Length - (linestart);
  357. ConfigLongthDictionary.Add(name, length);
  358. }
  359. return Table;
  360. }
  361. public Dictionary<string, Dictionary<string, string>> getTable(string tablename)
  362. {
  363. if (!InitFinished || ConfigDictionary == null)
  364. return null;
  365. Dictionary<string, Dictionary<string, string>> ts;
  366. ConfigDictionary.TryGetValue(tablename, out ts);
  367. if (ts != null && ts.Count > 0)
  368. return ts;
  369. else
  370. {
  371. DebugHelper.LogWarning("[ConfigMgr] {0} cant find", tablename);
  372. return null;
  373. }
  374. }
  375. public string GetXmlCfg(string fileName)
  376. {
  377. string cfg;
  378. mXmlConfigDict.TryGetValue(fileName, out cfg);
  379. return cfg;
  380. }
  381. public int getTableLength(string tablename)
  382. {
  383. if (!InitFinished)
  384. return -1;
  385. if (ConfigLongthDictionary.ContainsKey(tablename))
  386. return ConfigLongthDictionary[tablename];
  387. return 0;
  388. }
  389. public Dictionary<string, string> getLine(int id, string tablename)
  390. {
  391. return getLine(id.ToString(), tablename);
  392. }
  393. public Dictionary<string, string> getLine(string id, string tablename)
  394. {
  395. if (!InitFinished) {
  396. Debug.LogError("配置未加载!!!");
  397. return null;
  398. }
  399. Dictionary<string, Dictionary<string, string>> ts = getTable(tablename);
  400. if (ts != null && ts.ContainsKey(id))
  401. {
  402. return ts[id];
  403. }
  404. else
  405. return null;
  406. }
  407. public string getValue(int id, string keyname, string tablename)
  408. {
  409. return getValue(id.ToString(), keyname, tablename);
  410. }
  411. public string getValue(string id, string keyname, string tablename)
  412. {
  413. if (!InitFinished)
  414. return null;
  415. Dictionary<string, Dictionary<string, string>> ts = getTable(tablename);
  416. //Log.E("id {0} {1} {2}",id,keyname,tablename);
  417. if (ts != null && ts.ContainsKey(id) && ts[id].ContainsKey(keyname))
  418. {
  419. return ts[id][keyname];
  420. }
  421. else
  422. return null;
  423. }
  424. }
  425. public class I18N
  426. {
  427. static string m_tableName = "";
  428. static string m_curLangKey = "";
  429. static string tableName
  430. {
  431. get
  432. {
  433. if (string.IsNullOrEmpty(m_tableName) || m_curLangKey != ConfigMgr.CurLangKey)
  434. {
  435. m_tableName = string.Format("LanguagePackage{0}", ConfigMgr.CurLangKey);
  436. m_curLangKey = ConfigMgr.CurLangKey;
  437. }
  438. return m_tableName;
  439. }
  440. }
  441. public static string T(string key)
  442. {
  443. string result = key;
  444. if (key == null)
  445. {
  446. DebugHelper.LogWarning("[ I18N.T ] keyword is null!!!");
  447. return "";
  448. }
  449. if (ConfigMgr.HasInstance())
  450. {
  451. if (!ConfigMgr.InitFinished)
  452. {
  453. ConfigMgr.Instance.ResetKeywords();
  454. m_tableName = string.Empty;
  455. }
  456. string value = ConfigMgr.Instance.getValue(key, "Language", tableName);
  457. if (value != null)
  458. {
  459. result = value.Replace("\\n", "\n");
  460. }
  461. }
  462. return result;
  463. }
  464. public static string SetLanguageValue(string key, params string[] param)
  465. {
  466. if (param == null || param.Length == 0)
  467. {
  468. return T(key);
  469. }
  470. string result = key;
  471. if (key == null)
  472. {
  473. DebugHelper.LogWarning("[ I18N.T ] keyword is null!!!");
  474. return "";
  475. }
  476. if (ConfigMgr.HasInstance())
  477. {
  478. if (!ConfigMgr.InitFinished)
  479. {
  480. ConfigMgr.Instance.ResetKeywords();
  481. m_tableName = string.Empty;
  482. }
  483. string value = ConfigMgr.Instance.getValue(key, "Language", tableName);
  484. if (value != null)
  485. {
  486. result = value.Replace("\\n", "\n");
  487. result = string.Format(result, param);
  488. }
  489. else
  490. {
  491. DebugHelper.LogWarning("[ I18N.T ]ConfigMgr.cant find the key or keyword is null!!! " + key);
  492. }
  493. }
  494. return result;
  495. }
  496. }
  497. public class I18NOpera
  498. {
  499. static string m_tableName = "";
  500. static string tableName
  501. {
  502. get
  503. {
  504. if (string.IsNullOrEmpty(m_tableName))
  505. m_tableName = string.Format("OperaKeywords{0}", ConfigMgr.CurLangKey);
  506. return m_tableName;
  507. }
  508. }
  509. public static string T(int key)
  510. {
  511. string result = key.ToString();
  512. if (ConfigMgr.HasInstance())
  513. {
  514. if (!ConfigMgr.InitFinished)
  515. {
  516. ConfigMgr.Instance.ResetKeywords();
  517. m_tableName = string.Empty;
  518. }
  519. result = ConfigMgr.Instance.getValue(key, "info", tableName);
  520. result = result.Replace("\\n", "\n");//��������
  521. //if (value != null)
  522. //{
  523. // result = value.Replace("|", "\r\n");
  524. //}
  525. //else
  526. //{
  527. // DebugHelper.LogWarning("[ I18NOpera.T ]ConfigMgr.cant find the key or keyword is null!!!");
  528. //}
  529. }
  530. return result;
  531. }
  532. }
  533. public class I18NOperaBranch
  534. {
  535. static string m_tableName = "";
  536. static string tableName
  537. {
  538. get
  539. {
  540. if (string.IsNullOrEmpty(m_tableName))
  541. m_tableName = string.Format("OperaBranchwords{0}", ConfigMgr.CurLangKey);
  542. return m_tableName;
  543. }
  544. }
  545. public static string T(int key)
  546. {
  547. string result = key.ToString();
  548. if (ConfigMgr.HasInstance())
  549. {
  550. if (!ConfigMgr.InitFinished)
  551. {
  552. ConfigMgr.Instance.ResetKeywords();
  553. m_tableName = string.Empty;
  554. }
  555. result = ConfigMgr.Instance.getValue(key, "info", tableName);
  556. if (result == null)
  557. {
  558. DebugHelper.LogError(string.Format("in {0},can not find value by key :{1}", tableName, key));
  559. }
  560. result = result.Replace("\\n", "\n");//��������
  561. }
  562. return result;
  563. }
  564. }
  565. public class EditorConfigCSV
  566. {
  567. private string m_tableName = "";
  568. public string TableName
  569. {
  570. get
  571. {
  572. return m_tableName;
  573. }
  574. }
  575. private int linestart = 1;
  576. private int rowstart = 1;
  577. private string splitword = ",";
  578. private Dictionary<string, Dictionary<string, string>> m_tableData;
  579. public string T(string key, string filed, string tableName_)
  580. {
  581. m_tableName = tableName_;
  582. string result = key;
  583. #if UNITY_EDITOR
  584. string value = GetValue(key, filed);
  585. if (value != null)
  586. {
  587. result = value.Replace("\\n", "\n");
  588. }
  589. #endif //UNITY_EDITOR
  590. return result;
  591. }
  592. public string GetValue(string id, string keyName_, string tableName_ = null)
  593. {
  594. #if UNITY_EDITOR
  595. if (m_tableData == null)
  596. {
  597. if (tableName_ != null)
  598. m_tableName = tableName_;
  599. string path = string.Format("{0}/{1}.csv", Constants.CsvConfig, TableName);
  600. TextAsset tx = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(path) as TextAsset;
  601. m_tableData = GetData(tx);
  602. }
  603. if (id == null)
  604. {
  605. return null;
  606. }
  607. if (m_tableData.ContainsKey(id) && m_tableData[id].ContainsKey(keyName_))
  608. {
  609. return m_tableData[id][keyName_];
  610. }
  611. #endif //UNITY_EDITOR
  612. return null;
  613. }
  614. public List<string> GetId2Key(string keyName_, string keyValue_, string tableName_ = null)
  615. {
  616. List<string> idList = new List<string>();
  617. #if UNITY_EDITOR
  618. if (m_tableData == null)
  619. {
  620. if (tableName_ != null)
  621. m_tableName = tableName_;
  622. string path = string.Format("{0}/{1}.csv", Constants.CsvConfig, TableName);
  623. TextAsset tx = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(path) as TextAsset;
  624. m_tableData = GetData(tx);
  625. }
  626. foreach (var dic in m_tableData)
  627. {
  628. if (dic.Value[keyName_] == keyValue_)
  629. {
  630. idList.Add(dic.Key);
  631. }
  632. }
  633. #endif //UNITY_EDITOR
  634. return idList;
  635. }
  636. private Dictionary<string, Dictionary<string, string>> GetData(Object obj)
  637. {
  638. if (obj == null)
  639. return null;
  640. string[] lineArray;
  641. string[] charArray;
  642. TextAsset binAsset = obj as TextAsset;
  643. string text = binAsset.text.Replace("\r\n", "@");
  644. lineArray = text.Split("@"[0]);
  645. //DebugHelper.LogWarning("[TableName: {0}]lineArray {1}",binAsset.name, lineArray[0]);
  646. string[] indexname = lineArray[1].Split(splitword[0]);
  647. Dictionary<string, Dictionary<string, string>> Table = new Dictionary<string, Dictionary<string, string>>();
  648. for (int i = linestart; i < lineArray.Length; ++i)
  649. {
  650. charArray = lineArray[i].Split(splitword[0]);
  651. if (charArray.Length > 0 && charArray[0] == string.Empty)
  652. {
  653. DebugHelper.LogWarning("[ConfigMgr. GetData] Empty Index {0} {1}", binAsset.name, i);
  654. continue;
  655. }
  656. Dictionary<string, string> Row = new Dictionary<string, string>();
  657. for (int j = rowstart; j < charArray.Length; ++j)
  658. {
  659. if (indexname[j] == "" || indexname[j] == string.Empty)
  660. {
  661. DebugHelper.LogWarning("[ConfigMgr. GetData] Empty key {0} {1}", binAsset.name, j);
  662. continue;
  663. }
  664. if (Row.ContainsKey(indexname[j]))
  665. {
  666. DebugHelper.LogWarning("[ConfigMgr. GetData] {0} {1}", binAsset.name, indexname[j]);
  667. continue;
  668. }
  669. Row.Add(indexname[j], charArray[j]);
  670. }
  671. if (Table.ContainsKey(charArray[0]))
  672. {
  673. DebugHelper.LogWarning("[ConfigMgr. GetData] {0} {1} {2}", binAsset.name, i, lineArray[i - 1]);
  674. continue;
  675. }
  676. Table.Add(charArray[0], Row);
  677. }
  678. return Table;
  679. }
  680. }