| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using QFramework;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using static RestoreObjectPathHelper;
- public class DeviceOfPartDataProxy : DataProxy
- {
- public string m_TableName;
- public List<PartDataInfo> m_PartInfos;
- public List<CustomPartData> m_CustomInfos;
- public List<GameObject> objects = new List<GameObject>();
- public override void OnRegister()
- {
-
- }
- public PartDataInfo GetPartInfoByPartName(string partName)
- {
- return m_PartInfos.Find(t => t.partName == partName);
- }
- /// <summary>
- /// 从Excel文件读取流程信息
- /// </summary>
- /// <param name="tableName">表名</param>
- /// <param name="headCount">表头</param>
- /// <returns></returns>
- public List<PartDataInfo> ReadStepMsgInfoFromTable(string tableName)
- {
- m_TableName = tableName + GlobalConfig.excelSuffix;
- m_PartInfos = new List<PartDataInfo>();
- string tmpPath = System.IO.Path.Combine(GlobalConfig.partTablePath, m_TableName);
- if (File.Exists(tmpPath))
- {
- m_PartInfos = ExcelHelper.ReadInfoFromExcel<PartDataInfo>(tmpPath, 1);
- }
- return m_PartInfos;
- }
- public List<CustomPartData> ReadCustomInfoFromTable(string tableName)
- {
- m_TableName = tableName + GlobalConfig.excelSuffix;
- m_CustomInfos = new List<CustomPartData>();
- string tmpPath = System.IO.Path.Combine(GlobalConfig.partEditTablePath, m_TableName);
- if (File.Exists(tmpPath))
- {
- m_CustomInfos = ExcelHelper.ReadInfoFromExcel<CustomPartData>(tmpPath, 1);
- }
- return m_CustomInfos;
- }
- public CustomPartData GetCustomByEditPartName(string partName)
- {
- return m_CustomInfos.Find(t => t.editName == partName);
- }
- public CustomPartData GetCustomByPartName(string partName)
- {
- return m_CustomInfos.Find(t => t.partName == partName);
- }
- public CustomPartData GetCustomByIdName(string id)
- {
- return m_CustomInfos.Find(t => t.id == id);
- }
- public void CoverTableInfos()
- {
- for (int i = 0; i < m_CustomInfos.Count; i++)
- {
- PartDataInfo tmpInfo = GetPartInfoByPartName(m_CustomInfos[i].partName);
- if(tmpInfo != null)
- {
- if (!string.IsNullOrEmpty(m_CustomInfos[i].editName))
- tmpInfo.partName = m_CustomInfos[i].editName;
- tmpInfo.audioClipName = m_CustomInfos[i].audioClipName;
- }
- }
- }
- public void endTableEditInfos(bool first = false)
- {
- List<RestoreData> datas = new List<RestoreData>();
- for (int i = 0; i < m_CustomInfos.Count; i++)
- {
- int j = i;
- GameObject tmpObj = GameObject.Find(m_CustomInfos[j].AbsolutePath);
- objects.Add(tmpObj);
- datas.Add(new RestoreData(tmpObj.transform, m_CustomInfos[j].EditPath));
- }
- PartMark[] allObjs = DeviceController.instance.GetComponentsInChildren<PartMark>(true);
- new RestoreObjectPathHelper().RestoreHierarchy(datas, allObjs);
- for (int i = 0; i < m_CustomInfos.Count; i++)
- {
- objects[i].name = m_CustomInfos[i].editName;
- }
- foreach(PartMark tmpPark in allObjs) { tmpPark.InitData(); }
- }
- public void returnBackTable()
- {
- for (int i = 0; i < objects.Count; i++)
- {
- PartDataInfo tmpInfo = GetPartInfoByPartName(m_CustomInfos[i].partName);
- if (tmpInfo != null )
- {
- objects[i].name = tmpInfo.partName;
- }
- }
- m_CustomInfos.Clear();
- }
- }
|