227 lines
6.5 KiB
C#
227 lines
6.5 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using Animancer;
|
||
using Logic;
|
||
using Logic.Action;
|
||
using Logic.AI;
|
||
using Logic.Audio;
|
||
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;
|
||
|
||
namespace TH1_UI.View.Outside
|
||
{
|
||
|
||
|
||
public class UIOutsideHistoryView : Base.View
|
||
{
|
||
[Header("按钮")]
|
||
//public Button CloseButton;
|
||
public Button CloseButton;
|
||
|
||
|
||
public Transform ItemList;
|
||
|
||
public TMP_Dropdown DropdownForce;
|
||
public RectTransform DropdownForceRect;
|
||
private List<Empire> DropdownForceData;
|
||
|
||
// 新增:玩家人数下拉与排序下拉
|
||
public TMP_Dropdown PlayerCountDropdown;
|
||
public RectTransform PlayerCountDropdownRect;
|
||
private List<string> PlayerCountData;
|
||
|
||
public TMP_Dropdown OrderDropdown;
|
||
public RectTransform OrderDropdownRect;
|
||
private List<string> OrderDropData;
|
||
|
||
public GameObject ItemPrefab;
|
||
|
||
//关闭时执行的委托
|
||
public ViDelegateAssisstant.Dele OnBtnCloseClick;
|
||
|
||
private List<UIOutsideHistoryItemMono> _items = new List<UIOutsideHistoryItemMono>();
|
||
|
||
protected override void OnInit()
|
||
{
|
||
base.OnInit();
|
||
CloseButton.onClick.RemoveAllListeners();
|
||
CloseButton.onClick.AddListener(OnClose);
|
||
}
|
||
|
||
|
||
private void SetItemList(List<GameRecord> dataList)
|
||
{
|
||
int dataSize = Mathf.Min(dataList.Count,100);
|
||
//var dataSize = GameRecordManager.Instance.GameRecordData.Records.Count;
|
||
//var dataList = GameRecordManager.Instance.GameRecordData.Records;
|
||
while (_items.Count < dataSize)
|
||
{
|
||
var obj = Instantiate(ItemPrefab, ItemList);
|
||
var cpn = obj?.GetComponent<UIOutsideHistoryItemMono>();
|
||
if (cpn == null) break;
|
||
_items.Add(cpn);
|
||
}
|
||
|
||
for (int i = 0; i < _items.Count; i++)
|
||
{
|
||
_items[i].gameObject.SetActive(i < dataSize);
|
||
if (i >= dataSize) continue;
|
||
_items[i].SetContent(dataList[i]);
|
||
}
|
||
}
|
||
|
||
private void SetDropForce()
|
||
{
|
||
DropdownForceData = new List<Empire>() {
|
||
new Empire(){Civ = CivEnum.Common,Force = ForceEnum.Common},
|
||
new Empire(){Civ = CivEnum.Egyptian,Force = ForceEnum.Remilia},
|
||
new Empire(){Civ = CivEnum.French,Force = ForceEnum.Kaguya},
|
||
new Empire(){Civ = CivEnum.Germany,Force = ForceEnum.Kanako},
|
||
};
|
||
DropdownForce.ClearOptions();
|
||
List<string> options = new List<string>();
|
||
options.Add(MultilingualManager.Instance.GetMultilingualText(uint.Parse(Table.Instance.PlayerDataAssets.CommonForceTitleText)));
|
||
foreach (var item in DropdownForceData)
|
||
{
|
||
if (!Table.Instance.PlayerDataAssets.GetPlayerInfo(item.Civ, item.Force, out var info)) continue;
|
||
options.Add(MultilingualManager.Instance.GetMultilingualText(info.ForceName));
|
||
}
|
||
DropdownForce.AddOptions(options);
|
||
|
||
DropdownForce.onValueChanged.RemoveAllListeners();
|
||
DropdownForce.onValueChanged.AddListener(OnOrderUpdate);
|
||
|
||
}
|
||
|
||
// 新增:玩家人数下拉设置
|
||
private void SetPlayerCountDropForce()
|
||
{
|
||
if (PlayerCountDropdown == null) return;
|
||
PlayerCountData = new List<string>() {
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropListNoLimitP),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropList2P),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropList3P),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropList4P),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropList5P),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropList6P),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropList7P),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropList8P)
|
||
};
|
||
PlayerCountDropdown.ClearOptions();
|
||
PlayerCountDropdown.AddOptions(PlayerCountData);
|
||
PlayerCountDropdown.onValueChanged.RemoveAllListeners();
|
||
PlayerCountDropdown.onValueChanged.AddListener(OnOrderUpdate);
|
||
}
|
||
|
||
// 新增:排序下拉设置
|
||
private void SetOrderDropForce()
|
||
{
|
||
if (OrderDropdown == null) return;
|
||
OrderDropData = new List<string>() {
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropListTimeOrder),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropListScoreOrder),
|
||
MultilingualManager.Instance.GetMultilingualText(Table.Instance.TextDataAssets.OutsideHistoryDropListTimeOrderR),
|
||
};
|
||
OrderDropdown.ClearOptions();
|
||
OrderDropdown.AddOptions(OrderDropData);
|
||
OrderDropdown.onValueChanged.RemoveAllListeners();
|
||
OrderDropdown.onValueChanged.AddListener(OnOrderUpdate);
|
||
}
|
||
|
||
private void OnOrderUpdate(int index)
|
||
{
|
||
var gameMode = GameMode.DOMINATION;
|
||
var forceEnum = DropdownForce.value switch
|
||
{
|
||
0 => ForceEnum.Common,
|
||
1 => ForceEnum.Remilia,
|
||
2 => ForceEnum.Kaguya,
|
||
3 => ForceEnum.Kanako,
|
||
_ => ForceEnum.Common
|
||
};
|
||
var playerCount = PlayerCountDropdown.value switch
|
||
{
|
||
0 => 0,
|
||
1 => 2,
|
||
2 => 3,
|
||
3 => 4,
|
||
4 => 5,
|
||
5 => 6,
|
||
6 => 7,
|
||
7 => 8,
|
||
_ => 0
|
||
};
|
||
bool isScore = false;
|
||
bool isTime = false;
|
||
bool isTurn = false;
|
||
bool order = true;
|
||
switch( OrderDropdown.value)
|
||
{
|
||
case 0:
|
||
isTime = true;
|
||
break;
|
||
case 1:
|
||
isTurn = true;
|
||
break;
|
||
case 2:
|
||
isTime = true;
|
||
order = false;
|
||
break;
|
||
}
|
||
|
||
SetItemList(GameRecordManager.Instance.GetSortGameRecordList(gameMode,forceEnum,playerCount,isScore,isTurn,isTime,order));
|
||
}
|
||
|
||
public void SetContent(ShowUIOutsideHistory evt)
|
||
{
|
||
SetItemList(GameRecordManager.Instance.GetSortGameRecordList(GameMode.DOMINATION, ForceEnum.Common, 0,
|
||
false, false, true, true));
|
||
//GameRecordManager.Instance.GameRecordData.Records);
|
||
|
||
SetDropForce();
|
||
SetPlayerCountDropForce();
|
||
SetOrderDropForce();
|
||
|
||
//如果数量不够,先clone row补足
|
||
|
||
|
||
}
|
||
|
||
//在Controller 调用Close的时候,会先调用这个closeview
|
||
public void OnCloseView()
|
||
{
|
||
}
|
||
|
||
public void OnSettingClicked()
|
||
{
|
||
}
|
||
|
||
public void OnStartClicked()
|
||
{
|
||
EventManager.Publish(new ShowUIOutsideSelect());
|
||
}
|
||
|
||
|
||
public void OnClose()
|
||
{
|
||
OnBtnCloseClick.Invoke();
|
||
}
|
||
}
|
||
|
||
}
|