/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using FairyGUI;
using System.Collections.Generic;
using XGame.Database;
using XGame;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class PartnerEpiBookDetailPanelCtrl : UIController
{
private bool _initView = false;
private int _curId;
private List _list;
protected override void OnEnable(object intent)
{
_curId = (int)intent;
AddUIListenres();
UpView();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres()
{
VM.LeftBtn.onClick.Add(OnClickLeftBtn);
VM.RightBtn.onClick.Add(OnClickRightBtn);
VM.GetBtn.onClick.Add(OnClickGetBtn);
}
private void RemoveUIListenres()
{
VM.LeftBtn.onClick.Remove(OnClickLeftBtn);
VM.RightBtn.onClick.Remove(OnClickRightBtn);
VM.GetBtn.onClick.Remove(OnClickGetBtn);
}
private void OnClickLeftBtn(EventContext context)
{
SelectOffset(-1);
}
private void OnClickRightBtn(EventContext context)
{
SelectOffset(1);
}
private void OnClickGetBtn(EventContext context) { }
#endregion
private void InitView()
{
if (_initView)
return;
_initView = true;
VM.List.ListType = EGListType.None;
VM.RwdList.ListType = EGListType.Virtual;
var tableList = collectTableRepo.GetAllEpiCollectList();
var list = new List();
foreach (var item in tableList)
{
list.Add(item.Id);
}
_list = list;
}
private void UpView()
{
var table = collectTableRepo.Get(_curId);
if (table == null)
{
Log.Error($"羁绊表不存在,id:{_curId}");
return;
}
VM.List.BindDatas(table.Param);
VM.NameLabel.text = table.Name;
var list = collect_rewardTableRepo.GetCollectRwdList(_curId);
VM.RwdList.BindDatas(list);
}
private void SelectOffset(int offset)
{
var index = _list.IndexOf(offset);
index += offset;
if (index < 0)
{
index += _list.Count;
}
else if (index >= _list.Count)
{
index -= _list.Count;
}
_curId = _list[index];
UpView();
}
}
}