|
|
@@ -28,7 +28,7 @@ namespace QFramework
|
|
|
private string ConfigSerachPath;
|
|
|
private string AbsolutePath;
|
|
|
|
|
|
- private List<PartItem> PartListData;
|
|
|
+ public List<CustomItem> CustomAllData;
|
|
|
|
|
|
private int ExcelIndex;
|
|
|
|
|
|
@@ -37,7 +37,7 @@ namespace QFramework
|
|
|
/// <summary> 是否修改存储文件修改 </summary>
|
|
|
private bool ifSaveFileChange = false;
|
|
|
|
|
|
- List<CustomItem> editObjs;
|
|
|
+ public List<CustomItem> editObjs;
|
|
|
|
|
|
public enum CustomPanelBtnkState
|
|
|
{
|
|
|
@@ -67,8 +67,8 @@ namespace QFramework
|
|
|
AudioSearchPath = $"{Application.streamingAssetsPath}/Config/Audios/内部结构/{DeviceController.instance.DeviceName}";
|
|
|
SubtitleSearchPath = $"{Application.streamingAssetsPath}/SubTitles/内部结构/{DeviceController.instance.DeviceName}";
|
|
|
ConfigSerachPath = $"{Application.streamingAssetsPath}/Config/内部结构设备自定义配置/{DeviceController.instance.DeviceName}.xlsx";
|
|
|
-
|
|
|
- PartListData = new List<PartItem>();
|
|
|
+
|
|
|
+ CustomAllData = new List<CustomItem>();
|
|
|
editObjs = new List<CustomItem>();
|
|
|
|
|
|
//如果修改表格不存在就创建表格
|
|
|
@@ -84,10 +84,14 @@ namespace QFramework
|
|
|
|
|
|
//创建Item
|
|
|
CustomItem customExample = Instantiate(CustomItem.gameObject,Content).GetComponent<CustomItem>();
|
|
|
- customExample.gameObject.SetActive(true);
|
|
|
- customExample.InitData(DeviceController.instance.GetDevicePartInfos(DeviceController.instance.transform.GetComponent<PartMark>()));
|
|
|
+ customExample.InitData(DeviceController.instance.GetDevicePartInfos(DeviceController.instance.transform.GetComponent<PartMark>()),ref CustomAllData);
|
|
|
customExample.UnExpandChildPartItem();
|
|
|
customExample.ExpandChildPartItem();
|
|
|
+
|
|
|
+ for (int i = 0; i < DAL.Instance.Get<DeviceOfPartDataProxy>().m_CustomInfos.Count; i++)
|
|
|
+ {
|
|
|
+ editObjs.Add( CustomAllData.Find(t => t.partInfo.partName == DAL.Instance.Get<DeviceOfPartDataProxy>().m_CustomInfos[i].partName));
|
|
|
+ }
|
|
|
|
|
|
addBtnOnclick();
|
|
|
}
|
|
|
@@ -97,8 +101,11 @@ namespace QFramework
|
|
|
//修改名称按钮
|
|
|
PartNameBtn.onClick.AddListener(() =>
|
|
|
{
|
|
|
- if(initCustomTable())
|
|
|
+ if (SelectItem == null)
|
|
|
+ {
|
|
|
return;
|
|
|
+ }
|
|
|
+ initCustomTable();
|
|
|
SetBtnInteractable(false);
|
|
|
CustomState = CustomPanelBtnkState.NameEdit;
|
|
|
|
|
|
@@ -117,8 +124,11 @@ namespace QFramework
|
|
|
//修改媒体资源按钮
|
|
|
ResourcesBtn.onClick.AddListener(() =>
|
|
|
{
|
|
|
- if (initCustomTable())
|
|
|
+ if(SelectItem == null)
|
|
|
+ {
|
|
|
return;
|
|
|
+ }
|
|
|
+ initCustomTable();
|
|
|
SetBtnInteractable(false);
|
|
|
CustomState = CustomPanelBtnkState.ResourceEdit;
|
|
|
|
|
|
@@ -135,8 +145,11 @@ namespace QFramework
|
|
|
|
|
|
HierarchyBtn.onClick.AddListener(() =>
|
|
|
{
|
|
|
- if (initCustomTable())
|
|
|
+ if (SelectItem == null)
|
|
|
+ {
|
|
|
return;
|
|
|
+ }
|
|
|
+ initCustomTable();
|
|
|
IFChangeLayer = true;
|
|
|
SetBtnInteractable(false);
|
|
|
CustomState = CustomPanelBtnkState.LayerEdit;
|
|
|
@@ -153,7 +166,8 @@ namespace QFramework
|
|
|
|
|
|
PanelExitBtn.onClick.AddListener(() =>
|
|
|
{
|
|
|
- UIKit.ClosePanel<CustomPartPanel>();
|
|
|
+ UIKit.HidePanel<CustomPartPanel>();
|
|
|
+
|
|
|
DeviceController.instance.ShowCustomPanel = !DeviceController.instance.ShowCustomPanel;
|
|
|
});
|
|
|
|
|
|
@@ -175,7 +189,12 @@ namespace QFramework
|
|
|
|
|
|
RefreshPartItemList();
|
|
|
RefreshCustomItemList();
|
|
|
- DeleteTableBtnText.text = "点击添加修改配置表";
|
|
|
+ DeleteTableBtnText.text = "配置表已删除";
|
|
|
+ PromptMessage.text = "重新启动以恢复配置修改。\n配置表将在下次打开编辑页面时自动生成。";
|
|
|
+ DeleteCustomTbaleBtn.interactable = false;
|
|
|
+ SelectItem = null;
|
|
|
+ DeviceController.instance.isDelectCustomTable = true;
|
|
|
+ isDelectTable = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -192,22 +211,25 @@ namespace QFramework
|
|
|
}
|
|
|
|
|
|
|
|
|
- private bool initCustomTable()
|
|
|
+
|
|
|
+ private void initCustomTable()
|
|
|
{
|
|
|
if (SelectItem == null)
|
|
|
- return true;
|
|
|
+ return;
|
|
|
|
|
|
- if (DAL.Instance.Get<DeviceOfPartDataProxy>().GetCustomByEditPartName(SelectItem.partInfo.partName) == null
|
|
|
- && DAL.Instance.Get<DeviceOfPartDataProxy>().GetCustomByPartName(SelectItem.partInfo.partName) == null)
|
|
|
- {
|
|
|
- DAL.Instance.Get<DeviceOfPartDataProxy>().ReadCustomInfoFromTable(DeviceController.instance.DeviceName);
|
|
|
- CustomPartData data = new CustomPartData(SelectItem.partInfo.partName, SubtitleName.text.Substring(0, SubtitleName.text.LastIndexOf('.')), SelectItem.partInfo.partName, AbsolutePath);
|
|
|
- ExcelHelper.WriteInfoToExcel(ConfigSerachPath, data);
|
|
|
- ExcelIndex = data.id.ToInt()+1;
|
|
|
- editObjs.Add(SelectItem);
|
|
|
- }
|
|
|
+ if (DAL.Instance.Get<DeviceOfPartDataProxy>().GetCustomByEditPartName(SelectItem.TitleText.text) != null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (DAL.Instance.Get<DeviceOfPartDataProxy>().GetCustomByPartName(SelectItem.TitleText.text) != null)
|
|
|
+ return;
|
|
|
+
|
|
|
+
|
|
|
+ CustomPartData data = new CustomPartData(SelectItem.partInfo.partName, SubtitleName.text.Substring(0, SubtitleName.text.LastIndexOf('.')), SelectItem.partInfo.partName, AbsolutePath, AbsolutePath);
|
|
|
+ ExcelHelper.WriteInfoToExcel(ConfigSerachPath, data);
|
|
|
+ DAL.Instance.Get<DeviceOfPartDataProxy>().ReadCustomInfoFromTable(DeviceController.instance.DeviceName);
|
|
|
+ ExcelIndex = data.id.ToInt()+1;
|
|
|
+ editObjs.Add(SelectItem);
|
|
|
|
|
|
- return false;
|
|
|
}
|
|
|
public string GetAbsolutePath(CustomItem tmpItem)
|
|
|
{
|
|
|
@@ -228,11 +250,15 @@ namespace QFramework
|
|
|
PartNameBtn.interactable = ifOpen;
|
|
|
}
|
|
|
|
|
|
+ public bool isDelectTable = false;
|
|
|
+
|
|
|
#region 获取选中信息
|
|
|
/// <summary> 获取选中的组件信息 </summary>
|
|
|
/// <param name="customItem"></param>
|
|
|
public void GetSelectChangeMessage(CustomItem customItem)
|
|
|
{
|
|
|
+ if (isDelectTable)
|
|
|
+ return;
|
|
|
if (IFChangeLayer)
|
|
|
{
|
|
|
if (SelectItem == customItem)
|
|
|
@@ -491,9 +517,32 @@ namespace QFramework
|
|
|
|
|
|
#region 层级修改
|
|
|
|
|
|
+ public bool ifChangeInChild(CustomItem tmpItem)
|
|
|
+ {
|
|
|
+ foreach (CustomItem item in tmpItem.childCustomInfo)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (item.TitleText.text.Equals(SelectNewParent.TitleText.text))
|
|
|
+ {
|
|
|
+ PromptMessage.text = $"请先将子层级部件上移\n禁止直接将父层级下移至其子层级";
|
|
|
+ return false; // 找到匹配,返回 false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ifChangeInChild(item))
|
|
|
+ {
|
|
|
+ return false; // 子项中找到匹配,返回 false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true; // 所有子项都没有匹配,返回 true
|
|
|
+ }
|
|
|
+
|
|
|
public void SaveLayerBtnOnClick()
|
|
|
{
|
|
|
- if (SelectNewParent == null)
|
|
|
+
|
|
|
+ if (SelectNewParent == null )
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (! ifChangeInChild(SelectItem))
|
|
|
return;
|
|
|
|
|
|
ChangeLayer();
|
|
|
@@ -658,9 +707,40 @@ namespace QFramework
|
|
|
DeviceController.instance.ifShowCoustom = false;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- protected override void OnClose()
|
|
|
+
|
|
|
+ protected override void OnHide()
|
|
|
+ {
|
|
|
+ FileInfo tmpFileInfo = new FileInfo(ConfigSerachPath);
|
|
|
+ if (!tmpFileInfo.Exists)
|
|
|
+ return;
|
|
|
+
|
|
|
+ DeviceController.instance.ifShowCoustom = true;
|
|
|
+
|
|
|
+ DAL.Instance.Get<DeviceOfPartDataProxy>().ReadCustomInfoFromTable(DeviceController.instance.DeviceName);
|
|
|
+ DAL.Instance.Get<DeviceOfPartDataProxy>().CoverTableInfos();
|
|
|
+ RefreshPartItemList();
|
|
|
+
|
|
|
+ foreach (CustomItem item in editObjs)
|
|
|
+ {
|
|
|
+
|
|
|
+ CustomPartData customPartData = DAL.Instance.Get<DeviceOfPartDataProxy>().GetCustomByEditPartName(item.TitleText.text);
|
|
|
+ ExcelIndex = customPartData.id.ToInt() + 1;
|
|
|
+
|
|
|
+ using (ExcelPackage excelPackage = new ExcelPackage(new FileInfo(ConfigSerachPath)))
|
|
|
+ {
|
|
|
+ ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[1];
|
|
|
+ worksheet.Cells[ExcelIndex, 6].Value = GetAbsolutePath(item);
|
|
|
+ excelPackage.Save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnClose()
|
|
|
{
|
|
|
+ FileInfo tmpFileInfo = new FileInfo(ConfigSerachPath);
|
|
|
+ if (!tmpFileInfo.Exists)
|
|
|
+ return;
|
|
|
+
|
|
|
DeviceController.instance.ifShowCoustom = true;
|
|
|
|
|
|
DAL.Instance.Get<DeviceOfPartDataProxy>().ReadCustomInfoFromTable(DeviceController.instance.DeviceName);
|
|
|
@@ -693,7 +773,7 @@ namespace QFramework
|
|
|
public string AbsolutePath;
|
|
|
public string EditPath;
|
|
|
|
|
|
- public CustomPartData( string partName,string audioClipName,string editName,string AbsolutePath,string EditParh = "",string EditPath = "")
|
|
|
+ public CustomPartData( string partName,string audioClipName,string editName,string AbsolutePath,string EditPath = "")
|
|
|
{
|
|
|
id = (DAL.Instance.Get<DeviceOfPartDataProxy>().m_CustomInfos.Count+1).ToString();
|
|
|
this.partName = partName;
|