ShuJuYuanGuanLi.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using static Manager;
  6. public class ShuJuYuanGuanLi : MonoBehaviour
  7. {
  8. public Toggle xst;
  9. public Toggle yct;
  10. public Toggle yt;
  11. public Toggle zt;
  12. public Toggle dt;
  13. public Text dqsj;
  14. public Toggle bzt;
  15. public Toggle bst;
  16. public Toggle szt;
  17. public Toggle sst;
  18. public GameObject go;
  19. public List<GameObject> golist;
  20. int index = 0;
  21. private void Awake()
  22. {
  23. yt.onValueChanged.AddListener((b) => {
  24. if(b&& ainfo!=null)
  25. {
  26. index=0;
  27. refinfo(ainfo.yunneng_option);
  28. }
  29. });
  30. zt.onValueChanged.AddListener((b) => {
  31. if (b && ainfo != null)
  32. {
  33. index=1;
  34. refinfo(ainfo.zongji_ption);
  35. }
  36. });
  37. dt.onValueChanged.AddListener((b) => {
  38. if (b && ainfo != null)
  39. {
  40. index=2;
  41. refinfo(ainfo.donghuan_option);
  42. }
  43. });
  44. }
  45. private void OnDestroy()
  46. {
  47. yt.onValueChanged.RemoveAllListeners();
  48. zt.onValueChanged.RemoveAllListeners();
  49. dt.onValueChanged.RemoveAllListeners();
  50. }
  51. Toption nt;
  52. public void refinfo(Toption t)
  53. {
  54. Debug.Log("refinfo===>"+t);
  55. nt=t;
  56. for (int i = 0; i < golist.Count; i++)
  57. {
  58. Destroy(golist[i]);
  59. }
  60. switch(t.current_data_source)
  61. {
  62. case 1:
  63. dqsj.text = "云能智维实时数据";
  64. dqsj.color = Color.green;
  65. break;
  66. default:
  67. dqsj.text = "云能智维备份数据";
  68. dqsj.color = new Color(277,115,24,255);
  69. break;
  70. }
  71. bzt.isOn = t.backup_data_switch_type == 1 ? true : false;
  72. bst.isOn = t.backup_data_switch_type != 1 ? true : false;
  73. szt.isOn = t.data_recover_type == 1 ? true : false;
  74. sst.isOn = t.data_recover_type != 1 ? true : false;
  75. for (int i = 0; i <t.details.Count; i++)
  76. {
  77. GameObject ngo= GameObject.Instantiate(go, go.transform.parent);
  78. ngo.SetActive(true);
  79. ngo.GetComponent<ShuJuYuanItem>().init(t.details[i]);
  80. golist.Add(ngo);
  81. }
  82. }
  83. AdminsystemInfo ainfo;
  84. private void OnEnable()
  85. {
  86. if(DataManager.Instance)
  87. {
  88. DataManager.Instance.getInfo((msg) => {
  89. Debug.Log("ainfo===>"+msg.general_option.update_time_display_switch);
  90. ainfo = msg;
  91. yct.isOn = msg.general_option.update_time_display_switch!=1;
  92. Debug.Log(msg.general_option.update_time_display_switch==1);
  93. xst.isOn = msg.general_option.update_time_display_switch==1;
  94. Debug.Log("xst.isOn===>"+xst.isOn);
  95. Debug.Log("ai yct.isOnnfo===>"+yct.isOn);
  96. yt.isOn = true;
  97. refinfo(msg.yunneng_option);
  98. });
  99. }
  100. }
  101. public void setty(bool b)
  102. {
  103. Debug.Log("setty===>"+b);
  104. ainfo.general_option.update_time_display_switch= b?1:0;
  105. StartCoroutine( DataManager.Instance.SetgeneralSetting(b,(msg)=>{}));
  106. }
  107. public void setbackup(bool b)
  108. {
  109. nt.backup_data_switch_type = b?1:0;
  110. switch(index)
  111. {
  112. case 0:
  113. StartCoroutine(DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  114. break;
  115. case 1:
  116. StartCoroutine(DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  117. break;
  118. case 2:
  119. StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  120. break;
  121. }
  122. }
  123. public void setrecover(bool b)
  124. {
  125. nt.data_recover_type = b?1:0;
  126. switch(index)
  127. {
  128. case 0:
  129. StartCoroutine( DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  130. break;
  131. case 1:
  132. StartCoroutine( DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  133. break;
  134. case 2:
  135. StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  136. break;
  137. }
  138. }
  139. }