123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using ShadowStudio.Model;
- using Studio.Scripts;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- namespace ShadowStudio.UI
- {
- [RequireComponent(typeof(WorldDlg))]
- public class PersonalFileDlg : UnitySingleton<PersonalFileDlg>
- {
- private PersonalFileList personalFileList;
- private Transform wuwenjian;
- private Button closeBtn;
- private Button loadBtn;
- private Button canelBtn;
- public List<ArtInfo> NeedLoadartInfos;
- public Action<int> ShowOrHideGrayImage;
- public Action CanelLoadAction;
- protected override void Awake()
- {
- base.Awake();
- HomeProxy.Instance.SearchArtListAction += SearchArtList;
- HomeProxy.Instance.NoArtReturnAction += ShowNoArt;
- NeedLoadartInfos = new List<ArtInfo>();
- }
- // Start is called before the first frame update
- void Start()
- {
- WorldDlg dlg = GetComponent<WorldDlg>();
- personalFileList = dlg.GetBreadthChild<PersonalFileList>("ItemFileList");
- wuwenjian = dlg.GetBreadthChild<Transform>("Wuwenjian");
- closeBtn = dlg.GetBreadthChild<Button>("CloseBtn");
- closeBtn.onClick.AddListener(ClickOnClose);
- loadBtn = dlg.GetBreadthChild<Button>("LoadBtn");
- loadBtn.onClick.AddListener(ClickOnLoad);
- canelBtn = dlg.GetBreadthChild<Button>("CanelBtn");
- canelBtn.onClick.AddListener(ClickOnCanel);
- }
- private void OnEnable()
- {
- Init();
- }
- public void Init()
- {
- if (NeedLoadartInfos != null && NeedLoadartInfos.Count > 0)
- {
- ClickOnCanel();
- }
- HomeProxy.Instance.RequestSearchArtList(-1, 1, "");
- }
- private void ClickOnCanel()
- {
- NeedLoadartInfos.Clear();
- CanelLoadAction?.Invoke();
- }
- private void ClickOnLoad()
- {
- if (NeedLoadartInfos.Count > 0)
- {
- for (int i = 0; i < NeedLoadartInfos.Count; i++)
- {
- WSHandler.Room.CreateGood(NeedLoadartInfos[i].AID, NeedLoadartInfos[i].ArtId, NeedLoadartInfos[i].ArtName, UnityUtil.ArtTransferInfo(NeedLoadartInfos[i], i, true), "", ShowViewMgr.Instance.roomId);
- }
- if (NeedLoadartInfos.Count == 1)
- {
- ConsoleDlg.IsOne = true;
- }
- else
- {
- ConsoleDlg.IsOne = false;
- }
- ClickOnClose();
- }
- }
- private void ClickOnClose()
- {
- if (ConsoleDlg.Instance)
- {
- ConsoleDlg.Instance.SetClose();
- }
- }
- private void OnDisable()
- {
- ClickOnCanel();
- }
- private void SearchArtList(List<ArtInfo> ArtInfoList)
- {
- if (gameObject.activeSelf)
- {
- wuwenjian.gameObject.SetActive(false);
- personalFileList.DestoryAll();
- if (ArtInfoList != null && ArtInfoList.Count > 0)
- {
- for (int i = 0; i < ArtInfoList.Count; i++)
- {
- if (personalFileList)
- {
- personalFileList.AddFileItem(ArtInfoList[i]);
- }
- }
- }
- else
- {
- wuwenjian.gameObject.SetActive(true);
- }
- }
- }
- private void ShowNoArt()
- {
- if (gameObject.activeSelf)
- {
- personalFileList.DestoryAll();
- wuwenjian.gameObject.SetActive(true);
- }
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- if (HomeProxy.Instance)
- {
- HomeProxy.Instance.SearchArtListAction -= SearchArtList;
- HomeProxy.Instance.NoArtReturnAction -= ShowNoArt;
- }
- }
- }
- }
|