PersonalFileDlg.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using ShadowStudio.Model;
  2. using Studio.Scripts;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. using XRTool.Util;
  9. using XRTool.WorldUI;
  10. namespace ShadowStudio.UI
  11. {
  12. [RequireComponent(typeof(WorldDlg))]
  13. public class PersonalFileDlg : UnitySingleton<PersonalFileDlg>
  14. {
  15. private PersonalFileList personalFileList;
  16. private Transform wuwenjian;
  17. private Button closeBtn;
  18. private Button loadBtn;
  19. private Button canelBtn;
  20. public List<ArtInfo> NeedLoadartInfos;
  21. public Action<int> ShowOrHideGrayImage;
  22. public Action CanelLoadAction;
  23. protected override void Awake()
  24. {
  25. base.Awake();
  26. HomeProxy.Instance.SearchArtListAction += SearchArtList;
  27. HomeProxy.Instance.NoArtReturnAction += ShowNoArt;
  28. NeedLoadartInfos = new List<ArtInfo>();
  29. }
  30. // Start is called before the first frame update
  31. void Start()
  32. {
  33. WorldDlg dlg = GetComponent<WorldDlg>();
  34. personalFileList = dlg.GetBreadthChild<PersonalFileList>("ItemFileList");
  35. wuwenjian = dlg.GetBreadthChild<Transform>("Wuwenjian");
  36. closeBtn = dlg.GetBreadthChild<Button>("CloseBtn");
  37. closeBtn.onClick.AddListener(ClickOnClose);
  38. loadBtn = dlg.GetBreadthChild<Button>("LoadBtn");
  39. loadBtn.onClick.AddListener(ClickOnLoad);
  40. canelBtn = dlg.GetBreadthChild<Button>("CanelBtn");
  41. canelBtn.onClick.AddListener(ClickOnCanel);
  42. }
  43. private void OnEnable()
  44. {
  45. Init();
  46. }
  47. public void Init()
  48. {
  49. if (NeedLoadartInfos != null && NeedLoadartInfos.Count > 0)
  50. {
  51. ClickOnCanel();
  52. }
  53. HomeProxy.Instance.RequestSearchArtList(-1, 1, "");
  54. }
  55. private void ClickOnCanel()
  56. {
  57. NeedLoadartInfos.Clear();
  58. CanelLoadAction?.Invoke();
  59. }
  60. private void ClickOnLoad()
  61. {
  62. if (NeedLoadartInfos.Count > 0)
  63. {
  64. for (int i = 0; i < NeedLoadartInfos.Count; i++)
  65. {
  66. WSHandler.Room.CreateGood(NeedLoadartInfos[i].AID, NeedLoadartInfos[i].ArtId, NeedLoadartInfos[i].ArtName, UnityUtil.ArtTransferInfo(NeedLoadartInfos[i], i, true), "", ShowViewMgr.Instance.roomId);
  67. }
  68. if (NeedLoadartInfos.Count == 1)
  69. {
  70. ConsoleDlg.IsOne = true;
  71. }
  72. else
  73. {
  74. ConsoleDlg.IsOne = false;
  75. }
  76. ClickOnClose();
  77. }
  78. }
  79. private void ClickOnClose()
  80. {
  81. if (ConsoleDlg.Instance)
  82. {
  83. ConsoleDlg.Instance.SetClose();
  84. }
  85. }
  86. private void OnDisable()
  87. {
  88. ClickOnCanel();
  89. }
  90. private void SearchArtList(List<ArtInfo> ArtInfoList)
  91. {
  92. if (gameObject.activeSelf)
  93. {
  94. wuwenjian.gameObject.SetActive(false);
  95. personalFileList.DestoryAll();
  96. if (ArtInfoList != null && ArtInfoList.Count > 0)
  97. {
  98. for (int i = 0; i < ArtInfoList.Count; i++)
  99. {
  100. if (personalFileList)
  101. {
  102. personalFileList.AddFileItem(ArtInfoList[i]);
  103. }
  104. }
  105. }
  106. else
  107. {
  108. wuwenjian.gameObject.SetActive(true);
  109. }
  110. }
  111. }
  112. private void ShowNoArt()
  113. {
  114. if (gameObject.activeSelf)
  115. {
  116. personalFileList.DestoryAll();
  117. wuwenjian.gameObject.SetActive(true);
  118. }
  119. }
  120. protected override void OnDestroy()
  121. {
  122. base.OnDestroy();
  123. if (HomeProxy.Instance)
  124. {
  125. HomeProxy.Instance.SearchArtListAction -= SearchArtList;
  126. HomeProxy.Instance.NoArtReturnAction -= ShowNoArt;
  127. }
  128. }
  129. }
  130. }