123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data;
- using XGame;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerEpiUpListItemCtrl : UIController<PartnerEpiUpListItemVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.PartnerItem.VM.PartnerBase.VM.ClickBtn.onClick.Add(OnClickClickBtn);
- VM.DownBtn.onClick.Add(OnClickDownBtn);
- VM.UpBtn.onClick.Add(OnClickUpBtn);
- VM.PartnerItem.VM.EpiSetBase.VM.ClickBtn.onClick.Add(OnClickEpiSet);
- }
- private void RemoveUIListenres()
- {
- VM.PartnerItem.VM.PartnerBase.VM.ClickBtn.onClick.Remove(OnClickClickBtn);
- VM.DownBtn.onClick.Remove(OnClickDownBtn);
- VM.UpBtn.onClick.Remove(OnClickUpBtn);
- VM.PartnerItem.VM.EpiSetBase.VM.ClickBtn.onClick.Remove(OnClickEpiSet);
- }
- private void OnClickEpiSet(EventContext eventContext)
- {
- if (EpigraphData.Instance.UpModeSelect > 0)
- {
- EventSingle.Instance.Notify(EventDefine.EpigraphUpModeSelect, _sbId);
- }
- else
- {
- var partnerInfo = PartnersData.Instance.GetPartnerAttrByTableId(_sbId);
- if (partnerInfo == null)
- {
- Log.Error($"圣兵数据不存在,id:{_sbId}");
- return;
- }
- Context.UI.OpenAsync(
- UIKeys.PartnerEpiChangePanel,
- new PartnerEpiChangePanelCtrlParam()
- {
- PlanId = PartnersData.Instance.UsePlanId,
- SlotId = -1,
- SbId = _sbId,
- }
- );
- }
- }
- private void OnClickClickBtn(EventContext context)
- {
- if (EpigraphData.Instance.UpModeSelect > 0)
- {
- EventSingle.Instance.Notify(EventDefine.EpigraphUpModeSelect, _sbId);
- }
- else if (_sbId > 0)
- {
- Context.UI.OpenAsync(UIKeys.PartnerDetailsPanel, _sbId);
- }
- }
- private void OnClickDownBtn(EventContext context)
- {
- var slotData = PartnersData.Instance.CurUsePlan.GetSlot(_pos);
- if (slotData.SbId <= 0)
- return;
- PartnersService.Instance.RequestPartnerDown(slotData.SbId);
- }
- private void OnClickUpBtn(EventContext context) { }
- #endregion
- #region 属性
- private int _pos;
- private int _sbId;
- #endregion
- public void OnRefresh(int index, int pos)
- {
- _pos = pos;
- var slotData = PartnersData.Instance.CurUsePlan.GetSlot(pos);
- _sbId = slotData?.SbId ?? 0;
- VM.IsUp.selectedIndex = _sbId > 0 ? 0 : 1;
- VM.PartnerItem.Ctrl.ShowUI(_sbId);
- }
- }
- }
|