125 lines
3.4 KiB
C#
125 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Animancer;
|
|
using Logic;
|
|
using Logic.Action;
|
|
using Logic.AI;
|
|
using Logic.Audio;
|
|
using Logic.Config;
|
|
using Logic.Multilingual;
|
|
using ParadoxNotion;
|
|
using RuntimeData;
|
|
using Steamworks;
|
|
using TH1_Core.Events;
|
|
using TH1_Core.Managers;
|
|
using TH1_Logic.Action;
|
|
using TH1_Logic.Config;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.Net;
|
|
using TH1_Logic.Steam;
|
|
using TH1_UI.View.Announce;
|
|
using TH1Resource;
|
|
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using ConfigManager = TH1_Logic.Config.ConfigManager;
|
|
|
|
namespace TH1_UI.View.Outside
|
|
{
|
|
|
|
|
|
public class UIOutsideMenuAnnouncementPanelMono : MonoBehaviour
|
|
{
|
|
|
|
public Button CloseButton;
|
|
public Button BlockButton;
|
|
public AnimancerComponent Animancer;
|
|
|
|
public Transform VersionButtonList;
|
|
public TextMeshProUGUI VersionContent;
|
|
public GameObject VersionLabelPrefab;
|
|
|
|
private List<UIOutsideMenuAnnouncementPanelVersionLabelMono> _versionLabelList;
|
|
private List<VersionInfo> _vers;
|
|
|
|
|
|
//关闭时执行的委托
|
|
public ViDelegateAssisstant.Dele OnBtnCloseClick;
|
|
|
|
//开始游戏时执行的委托(目前委托内容就是执行controller的Close())
|
|
public ViDelegateAssisstant.Dele OnStartGame;
|
|
|
|
public void OnInit()
|
|
{
|
|
CloseButton.onClick.RemoveAllListeners();
|
|
CloseButton.onClick.AddListener(OnClose);
|
|
BlockButton.onClick.RemoveAllListeners();
|
|
BlockButton.onClick.AddListener(OnClose);
|
|
gameObject.SetActive(false);
|
|
_versionLabelList = new List<UIOutsideMenuAnnouncementPanelVersionLabelMono>();
|
|
_vers = ConfigManager.Instance.VersionCfg.Versions;
|
|
}
|
|
|
|
private void SetVersionList()
|
|
{
|
|
while (_versionLabelList.Count < _vers.Count)
|
|
{
|
|
var versionLabel = Instantiate(VersionLabelPrefab,VersionButtonList);
|
|
_versionLabelList.Add(versionLabel.GetComponent<UIOutsideMenuAnnouncementPanelVersionLabelMono>());
|
|
}
|
|
|
|
bool firstSelect = true;
|
|
for (int i = 0; i < _versionLabelList.Count; i++)
|
|
{
|
|
_versionLabelList[i].gameObject.SetActive(i<_vers.Count);
|
|
|
|
_versionLabelList[i].Clear();
|
|
if (i >= _vers.Count) continue;
|
|
var rk = i;
|
|
var info = ConfigManager.Instance.VersionCfg.GetVersionInfo(_vers[rk].VersionId);
|
|
_versionLabelList[i].SetContent(info.FullVersion,firstSelect, () =>
|
|
{
|
|
SetVersionContent(rk);
|
|
for(int j = 0;j < _versionLabelList.Count && j < _vers.Count;j++)
|
|
if (_versionLabelList[j].Selected)
|
|
_versionLabelList[j].Unselect();
|
|
});
|
|
if (firstSelect) firstSelect = false;
|
|
}
|
|
var infoFirst = ConfigManager.Instance.VersionCfg.GetVersionInfo(ConfigManager.Instance.VersionCfg.CurVersionId);
|
|
MultilingualManager.Instance.SetUIText(VersionContent,infoFirst.Description);
|
|
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(VersionButtonList.GetComponent<RectTransform>());
|
|
}
|
|
|
|
private void SetVersionContent(int rk)
|
|
{
|
|
if(rk>_vers.Count) return;
|
|
var info = ConfigManager.Instance.VersionCfg.GetVersionInfo(_vers[rk].VersionId);
|
|
MultilingualManager.Instance.SetUIText(VersionContent,info.Description);
|
|
|
|
}
|
|
|
|
public void SetContent()
|
|
{
|
|
SetVersionList();
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
gameObject.SetActive(true);
|
|
Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeIn);
|
|
}
|
|
|
|
public void OnClose()
|
|
{
|
|
AnimancerState state = Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeOut);
|
|
state.Events.OnEnd += () => { gameObject.SetActive(false); };
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|