123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using static Manager;
- public class ShuJuYuanGuanLi : MonoBehaviour
- {
- public Toggle xst;
- public Toggle yct;
- public Toggle yt;
- public Toggle zt;
- public Toggle dt;
- public Text dqsj;
- public Toggle bzt;
- public Toggle bst;
- public Toggle szt;
- public Toggle sst;
- public GameObject go;
- public List<GameObject> golist;
- int index = 0;
- private void Awake()
- {
- yt.onValueChanged.AddListener((b) => {
- if(b&& ainfo!=null)
- {
- index=0;
- refinfo(ainfo.yunneng_option);
- }
- });
- zt.onValueChanged.AddListener((b) => {
- if (b && ainfo != null)
- {
- index=1;
- refinfo(ainfo.zongji_ption);
- }
- });
- dt.onValueChanged.AddListener((b) => {
- if (b && ainfo != null)
- {
- index=2;
- refinfo(ainfo.donghuan_option);
- }
- });
- }
- private void OnDestroy()
- {
- yt.onValueChanged.RemoveAllListeners();
- zt.onValueChanged.RemoveAllListeners();
- dt.onValueChanged.RemoveAllListeners();
- }
- Toption nt;
- public void refinfo(Toption t)
- {
- nt=t;
- for (int i = 0; i < golist.Count; i++)
- {
- Destroy(golist[i]);
- }
- switch(t.current_data_source)
- {
- case 1:
- dqsj.text = "云能智维实时数据";
- dqsj.color = Color.green;
- break;
- default:
- dqsj.text = "云能智维备份数据";
- dqsj.color = new Color(277,115,24,255);
- break;
- }
- bzt.isOn = t.backup_data_switch_type == 1 ? true : false;
- bst.isOn = t.backup_data_switch_type != 1 ? true : false;
- szt.isOn = t.data_recover_type == 1 ? true : false;
- sst.isOn = t.data_recover_type != 1 ? true : false;
- for (int i = 0; i <t.details.Count; i++)
- {
- GameObject ngo= GameObject.Instantiate(go, go.transform.parent);
- ngo.SetActive(true);
- ngo.GetComponent<ShuJuYuanItem>().init(t.details[i]);
- golist.Add(ngo);
- }
- }
- AdminsystemInfo ainfo;
- private void OnEnable()
- {
- if(DataManager.Instance)
- {
- DataManager.Instance.getInfo((msg) => {
- ainfo = msg;
- xst.isOn = msg.general_option.update_time_display_switch;
- yct.isOn = !msg.general_option.update_time_display_switch;
- yt.isOn = true;
- refinfo(msg.yunneng_option);
- });
- }
- }
- public void setty(bool b)
- {
- ainfo.general_option.update_time_display_switch= b;
- StartCoroutine( DataManager.Instance.SetgeneralSetting(b,(msg)=>{}));
- }
- public void setbackup(bool b)
- {
- nt.backup_data_switch_type = b?1:0;
- switch(index)
- {
- case 0:
- StartCoroutine(DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
- break;
- case 1:
- StartCoroutine(DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
- break;
- case 2:
- StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
- break;
- }
- }
- public void setrecover(bool b)
- {
- nt.data_recover_type = b?1:0;
- switch(index)
- {
- case 0:
- StartCoroutine( DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
- break;
- case 1:
- StartCoroutine( DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
- break;
- case 2:
- StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
- break;
- }
- }
- }
|