123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- using System;
- using System.Collections.Generic;
- using LitJson;
- using SC.XR.Unity;
- using TMPro;
- using UnityEngine;
- using UnityEngine.UI;
- using static WindowsManager;
- public class RoomFile : SingletonMono<RoomFile>
- {
- public Toggle fileToggle;
- public GameObject tubiao1;
- public GameObject tubiao2;
- public GameObject allFile;
- public Button clearAllBtn;
- public GameObject msgRemind;
- public TextMeshProUGUI msgRemindText;
- public TextMeshProUGUI showfileCountText;
- public static int fileUpdataCount = 0;
- public Action<int> UpdataCountAction;
- public static Action<FileConfig> ClickFileItemAction;
- public List<FileConfig> FilePrefabConfigList = new List<FileConfig>();//是否实例化的List
- public static Action<FileConfig> IfFilePrefabConfigListAction;//点击知道是否实例化的监听
- public static Action<FileConfig> ClickOnPrefabAction;
- public static Action<FileConfig> HideChooseKuangAction;
- public static Action<FileConfig> HidefileChooseAction;
- public static Action SetIsOnFalse;
- public Transform PngJpgPoint;
- public Transform PrintscreenPoint;
- public Transform Mp4Point;
- public Transform PdfPoint;
- public Transform ModelPoint;
- void Awake()
- {
-
- UpdataCountAction += OnUpdataCount;
- // MQTTClient.Instance.OnCoordinate += Coordinate;
- }
- private void ReceiveSharePrintscreen(JsonData data)
- {
- if (PrintscreenList.Instance)
- {
- PrintscreenList.Instance.AddItem(data);
- }
- }
- private void OnUpdataCount(int num)
- {
- msgRemind.SetActive(true);
- msgRemindText.text = num.ToString();
- }
- private void Start()
- {
- ClickFileItemAction += ClickFileItme;
- fileToggle.onValueChanged.AddListener(OnFileToggleValueChange);
- clearAllBtn.onClick.AddListener(ClickOnClearAllBtn);
- ClearAllfileAction += ClearAllfile;
-
-
- }
- private void ReceiveFile(JsonData data)
- {
- FileConfig fileConfig = new FileConfig();
- fileConfig.PeerId = data["data"]["peerId"].ToString();
- fileConfig.From = data["data"]["from"].ToString();
- fileConfig.CreateTime = data["data"]["createTime"].ToString();
- fileConfig.Url = data["data"]["url"].ToString();
- fileConfig.Path = data["data"]["path"].ToString();
- fileConfig.FileName = data["data"]["fileName"].ToString();
- InstantFileConfig(fileConfig);
- }
- private void InstantFileConfig(FileConfig fileConfig)
- {
- if (FileList.Instance)
- {
- FileList.Instance.AddItem(fileConfig);
- }
- }
- void initShow()
- {
-
- HideClearBtn();
- if (FileList.Instance)
- {
- fileUpdataCount = 0;
- // FileList.Instance.Init(ShowRoom.Instance.fileConfiglist);
- }
- if (fileToggle)
- {
- fileToggle.isOn = true;
- }
- allFile.SetActive(true);
- tubiao1.SetActive(false);
- tubiao2.SetActive(true);
- msgRemind.SetActive(false);
- fileUpdataCount = 0;
- }
- public void ShowClearBtn()
- {
- clearAllBtn.gameObject.SetActive(true);
- //showfileCountText.transform.localPosition = new Vector3(15, 0, 0);
- }
- public void HideClearBtn()
- {
- clearAllBtn.gameObject.SetActive(false);
- //showfileCountText.transform.localPosition = new Vector3(-3, 0, 0);
- }
- private void OnFileToggleValueChange(bool isOn)
- {
- if (isOn)
- {
- allFile.SetActive(true);
- tubiao1.SetActive(false);
- tubiao2.SetActive(true);
- msgRemind.SetActive(false);
- fileUpdataCount = 0;
- }
- else
- {
- allFile.SetActive(false);
- tubiao1.SetActive(true);
- tubiao2.SetActive(false);
- }
- }
- public void ResetToggleValue()
- {
- if (!fileToggle.isOn)
- {
- fileToggle.isOn = true;
- }
- }
- private Action ClearAllfileAction;
- private void ClickOnClearAllBtn()
- {
- // PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Pop, RtcStrConfig.clearallFile, "确定", ClearAllfileAction);
- }
- private void ClearAllfile()
- {
- HideClearBtn();
-
- }
- private void ClearFileSucess(JsonData data)
- {
- if (data["data"]["code"].ToString() == "200")
- {
- ClearAllFileItem();
- }
- }
- private void ClearFile(JsonData data)
- {
- if (data["method"].ToString() == "clearFile")
- {
- ClearAllFileItem();
- }
- }
- public void ClearAllFileItem()
- {
- //if (ShowRoom.Instance && ShowRoom.Instance.fileConfiglist != null && ShowRoom.Instance.fileConfiglist.Count > 0)
- //{
- // ShowRoom.Instance.fileConfiglist.Clear();
- //}
- if (FileList.Instance)
- {
- msgRemind.SetActive(false);
- fileUpdataCount = 0;
- FileList.Instance.DestoryAll();
- }
- ClearAllFilePrefab();
- }
- public void ClearAllFilePrefab()
- {
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.DeleteAll();
- }
- if (Mp4List.Instance)
- {
- Mp4List.Instance.DeleteAll();
- }
- if (PdfList.Instance)
- {
- PdfList.Instance.DeleteAll();
- }
- //if (ModelList.Instance)
- //{
- // ModelList.Instance.DeleteAll();
- //}
- FilePrefabConfigList.Clear();
- }
- private void ClickFileItme(FileConfig fileConfig)
- {
- if (fileConfig != null)
- {
- switch (fileConfig.FileType)
- {
- case RoomFileType.png:
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.jpg:
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.jpeg:
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.mp4:
- if (Mp4List.Instance)
- {
- Mp4List.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.zip:
- //if (ModelList.Instance)
- //{
- // ModelList.Instance.AddItem(fileConfig);
- //}
- break;
- case RoomFileType.pdf:
- if (PdfList.Instance)
- {
- PdfList.Instance.AddItem(fileConfig);
- }
- break;
- }
- }
- }
- private void OnDestroy()
- {
- ClickFileItemAction -= ClickFileItme;
- UpdataCountAction -= OnUpdataCount;
- ClearAllfileAction -= ClearAllfile;
- }
- }
|