/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using System.Collections.Generic; using FairyGUI; using FL.Data; using XGame; using XGame.Framework.UI; namespace FL.FGUI { public class PartnerEpiChangePanelCtrlParam { public int SbId; ///// ///// 方案id ///// //public int PlanId; ///// ///// 方案内槽位,如果有planId则必填 ///// //public int SlotId; } /// /// UI逻辑处理类 /// /// public partial class PartnerEpiChangePanelCtrl : UIController { protected override void OnEnable(object intent) { var param = intent as PartnerEpiChangePanelCtrlParam; _sbId = param.SbId; //_planId = param.PlanId; //_slotId = param.SlotId; AddUIListenres(); InitView(); UpView(); } protected override void OnDisable() { RemoveUIListenres(); } #region UI事件 private void AddUIListenres() { Context.AddListener(EventDefine.PartnerBinding, OnUpdateList); Context.AddListener(EventDefine.EpigraphChangeSelect, OnClickItem); VM.UpBtn.onClick.Add(OnClickUpBtn); } private void RemoveUIListenres() { Context.RemoveListener(EventDefine.PartnerBinding, OnUpdateList); Context.RemoveListener(EventDefine.EpigraphChangeSelect, OnClickItem); VM.UpBtn.onClick.Remove(OnClickUpBtn); } private void OnUpdateList(int eventId, object args) { RefreshList(); } private void OnClickItem(int eventId, object args) { var id = (int)args; if (id == _curSelectId) { //Context.UI.OpenAsync( // UIKeys.PartnerEpiDetailInfo, // new PartnerEpiDetailInfoParam() { EpigraphId = _curSelectId } //); //Context.ClosePanel(); return; } _curSelectId = id; RefreshList(); } private void OnClickUpBtn(EventContext eventContext) { var id = _curSelectId; //if (_planId == PartnersData.Instance.UsePlanId) //{ if (!PartnersData.Instance.TryGetPartnerAttrByTableId(_sbId, out var info)) { Context.ShowTips(StringDefine.PartnerEmptyTips); return; } if (id == info.EpigraphId) return; EpigraphService.Instance.RequestEpiInset(_sbId, id); Context.ClosePanel(); //} //else if (_planId >= 0 && _slotId >= 0 && _sbId > 0) //{ // var plan = PartnersData.Instance.GetPlanById(_planId); // foreach (var slot in plan.Slots) // { // if (slot.MwId == id) // { // Context.ShowTips(StringDefine.EpigraphAlreadyUpTips); // return; // } // } // PartnersService.Instance.RequestUpdatePlanMw(_planId, _slotId, _sbId, id); // Context.ClosePanel(); //} } #endregion #region 属性 private bool _isInit = false; /// /// 圣兵id /// private int _sbId; //private int _planId; //private int _slotId; private List _list; private int _curSelectId; #endregion #region 页面 private void InitView() { if (_isInit) return; _isInit = true; VM.List.ListType = EGListType.Virtual; } private void UpView() { var epiList = EpigraphData.Instance.EpiList; //if (_slotId < 0) //{ if (!PartnersData.Instance.TryGetPartnerAttrByTableId(_sbId, out var attr)) { Log.Error($"圣兵数据不存在,id:{_sbId}"); return; } if (attr.EpigraphId > 0) { _curSelectId = attr.EpigraphId; } else { _curSelectId = epiList[0].TableId; } //} //else //{ // var slot = PartnersData.Instance.GetPlanSlot(_planId, _slotId); // if (slot == null || slot.MwId == 0) // { // _curSelectId = epiList[0].TableId; // } // else // { // _curSelectId = slot.MwId; // } //} var list = new List(); _list = list; foreach (var epi in epiList) { list.Add(new EpiChangeListData(epi.TableId, _curSelectId)); } VM.List.BindDatas(list); } private void RefreshList() { var epiList = EpigraphData.Instance.EpiList; var list = new List(); foreach (var epi in epiList) { list.Add(new EpiChangeListData(epi.TableId, _curSelectId)); } _list = list; VM.List.BindDatas(list); } #endregion } }