138 lines
3.9 KiB
C#
138 lines
3.9 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 UIOutsideMenuAboutPanelMono : MonoBehaviour
|
|
{
|
|
|
|
public AnimancerComponent Animancer;
|
|
public Button CloseButton;
|
|
public Button BlockButton;
|
|
public TextMeshProUGUI VersionLabel;
|
|
|
|
[Header("外链")]
|
|
public Button BilibiliButton;
|
|
public string BilibiliUrl = "https://space.bilibili.com/3546860362926973";
|
|
public Button WebsiteButton;
|
|
public string WebsiteUrl = "https://tohotopia.com";
|
|
public Button XButton;
|
|
public string XUrl = "https://x.com/tohotopia";
|
|
public Button YoutubeButton;
|
|
public string YoutubeUrl = "https://youtube.com/@tohotopia";
|
|
public Button DiscordButton;
|
|
public string DiscordUrl = "https://discord.gg/wu2T3FCwCC";
|
|
|
|
[Header("Staff")]
|
|
public RectTransform StaffArea;
|
|
public UIOutsideAboutStaffTitleLineMono StaffTitlePrefab;
|
|
public UIOutsideAboutStaffLineMono StaffLinePrefab;
|
|
private readonly List<GameObject> _spawnedStaffNodes = new List<GameObject>();
|
|
|
|
//关闭时执行的委托
|
|
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);
|
|
if (VersionLabel != null)
|
|
VersionLabel.text = "V" + ConfigManager.Instance.VersionCfg.CurVersionInfo.FullVersion;
|
|
BindUrlButton(BilibiliButton, BilibiliUrl);
|
|
BindUrlButton(WebsiteButton, WebsiteUrl);
|
|
BindUrlButton(XButton, XUrl);
|
|
BindUrlButton(YoutubeButton, YoutubeUrl);
|
|
BindUrlButton(DiscordButton, DiscordUrl);
|
|
BuildStaffList();
|
|
}
|
|
|
|
// 通用外链按钮绑定: button 可为空(没在 prefab 上挂引用就跳过)
|
|
private void BindUrlButton(Button button, string url)
|
|
{
|
|
if (button == null) return;
|
|
button.onClick.RemoveAllListeners();
|
|
button.onClick.AddListener(() =>
|
|
{
|
|
if (!string.IsNullOrEmpty(url))
|
|
Application.OpenURL(url);
|
|
});
|
|
}
|
|
|
|
// 按 StaffList 顺序生成 staff 行: 相邻同 title 共用一个 title 行
|
|
private void BuildStaffList()
|
|
{
|
|
if (StaffArea == null || StaffLinePrefab == null || StaffTitlePrefab == null) return;
|
|
foreach (var go in _spawnedStaffNodes)
|
|
if (go != null) Destroy(go);
|
|
_spawnedStaffNodes.Clear();
|
|
|
|
var asset = Table.Instance?.StaffDataAssets;
|
|
if (asset == null) return;
|
|
|
|
var prevTitle = StaffTitleEnum.None;
|
|
bool hasPrev = false;
|
|
foreach (var item in asset.StaffList)
|
|
{
|
|
if (!hasPrev || item.Title != prevTitle)
|
|
{
|
|
var titleGo = Instantiate(StaffTitlePrefab, StaffArea);
|
|
titleGo.SetContent(item.Title);
|
|
_spawnedStaffNodes.Add(titleGo.gameObject);
|
|
prevTitle = item.Title;
|
|
hasPrev = true;
|
|
}
|
|
var lineGo = Instantiate(StaffLinePrefab, StaffArea);
|
|
lineGo.SetContent(item);
|
|
_spawnedStaffNodes.Add(lineGo.gameObject);
|
|
}
|
|
}
|
|
|
|
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); };
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|