123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /// #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.PanelEvent.Add(OnClickClickBtn);
- VM.DownBtn.onClick.Add(OnClickDownBtn);
- VM.PartnerItem.VM.EpiSetBase.VM.PanelEvent.Add(OnClickEpiSet);
- }
- private void RemoveUIListenres()
- {
- VM.PartnerItem.VM.PartnerBase.VM.PanelEvent.Remove(OnClickClickBtn);
- VM.DownBtn.onClick.Remove(OnClickDownBtn);
- VM.PartnerItem.VM.EpiSetBase.VM.PanelEvent.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,
- new PartnerDetailsPanelParam()
- {
- PlanId = PartnersData.Instance.UsePlanId,
- SlotId = -1,
- PartnerId = _sbId,
- }
- );
- }
- else
- {
- Context.UI.OpenAsync(
- UIKeys.PartnerReplacePartnerPanel,
- new PartnerReplacePartnerPanelCtrlParam()
- {
- PlanId = PartnersData.Instance.UsePlanId,
- SlotId = _slotId,
- }
- );
- }
- }
- private void OnClickDownBtn(EventContext context)
- {
- var slotData = PartnersData.Instance.CurUsePlan.GetSlot(_slotId);
- if (slotData.SbId <= 0)
- return;
- PartnersService.Instance.RequestPartnerDown(slotData.SbId);
- }
- #endregion
- #region 属性
- private int _slotId;
- private int _sbId;
- #endregion
- public void OnRefresh(int index, int slotId)
- {
- _slotId = slotId;
- var slotData = PartnersData.Instance.CurUsePlan.GetSlot(slotId);
- _sbId = slotData?.SbId ?? 0;
- VM.IsUp.selectedIndex = _sbId > 0 ? 0 : 1;
- VM.PartnerItem.Ctrl.ShowUI(_sbId);
- }
- }
- }
|