ShuJuYuanGuanLi.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. nt=t;
  55. for (int i = 0; i < golist.Count; i++)
  56. {
  57. Destroy(golist[i]);
  58. }
  59. switch(t.current_data_source)
  60. {
  61. case 1:
  62. dqsj.text = "云能智维实时数据";
  63. dqsj.color = Color.green;
  64. break;
  65. default:
  66. dqsj.text = "云能智维备份数据";
  67. dqsj.color = new Color(277,115,24,255);
  68. break;
  69. }
  70. bzt.isOn = t.backup_data_switch_type == 1 ? true : false;
  71. bst.isOn = t.backup_data_switch_type != 1 ? true : false;
  72. szt.isOn = t.data_recover_type == 1 ? true : false;
  73. sst.isOn = t.data_recover_type != 1 ? true : false;
  74. for (int i = 0; i <t.details.Count; i++)
  75. {
  76. GameObject ngo= GameObject.Instantiate(go, go.transform.parent);
  77. ngo.SetActive(true);
  78. ngo.GetComponent<ShuJuYuanItem>().init(t.details[i]);
  79. golist.Add(ngo);
  80. }
  81. }
  82. AdminsystemInfo ainfo;
  83. private void OnEnable()
  84. {
  85. if(DataManager.Instance)
  86. {
  87. DataManager.Instance.getInfo((msg) => {
  88. ainfo = msg;
  89. xst.isOn = msg.general_option.update_time_display_switch;
  90. yct.isOn = !msg.general_option.update_time_display_switch;
  91. yt.isOn = true;
  92. refinfo(msg.yunneng_option);
  93. });
  94. }
  95. }
  96. public void setty(bool b)
  97. {
  98. ainfo.general_option.update_time_display_switch= b;
  99. StartCoroutine( DataManager.Instance.SetgeneralSetting(b,(msg)=>{}));
  100. }
  101. public void setbackup(bool b)
  102. {
  103. nt.backup_data_switch_type = b?1:0;
  104. switch(index)
  105. {
  106. case 0:
  107. StartCoroutine(DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  108. break;
  109. case 1:
  110. StartCoroutine(DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  111. break;
  112. case 2:
  113. StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  114. break;
  115. }
  116. }
  117. public void setrecover(bool b)
  118. {
  119. nt.data_recover_type = b?1:0;
  120. switch(index)
  121. {
  122. case 0:
  123. StartCoroutine( DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  124. break;
  125. case 1:
  126. StartCoroutine( DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  127. break;
  128. case 2:
  129. StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
  130. break;
  131. }
  132. }
  133. }