123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /// #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
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerEpiBookDetailPanelCtrl : UIController<PartnerEpiBookDetailPanelVM>
- {
- private bool _initView = false;
- private int _curId;
- private List<int> _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<int>();
- 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();
- }
- }
- }
|