123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- public partial class PartnerInfoListItemCtrl : UIController<PartnerInfoListItemVM>
- {
- #region 属性
- /// <summary>
- /// 圣兵id
- /// </summary>
- private int _id;
- #endregion
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.DownBtn.onClick.Add(OnClickDownBtn);
- VM.UpBtn.onClick.Add(OnClickUpBtn);
- VM.PartnerItem.VM.PartnerBase.VM.PanelEvent.Add(OnClickBtn);
- VM.PartnerItem.VM.EpiSetBase.VM.PanelEvent.Add(OnClickEpiSet);
- }
- private void RemoveUIListenres()
- {
- VM.DownBtn.onClick.Remove(OnClickDownBtn);
- VM.UpBtn.onClick.Remove(OnClickUpBtn);
- VM.PartnerItem.VM.PartnerBase.VM.PanelEvent.Remove(OnClickBtn);
- VM.PartnerItem.VM.EpiSetBase.VM.PanelEvent.Remove(OnClickEpiSet);
- }
- private void OnClickEpiSet(EventContext eventContext)
- {
- var partnerInfo = PartnersData.Instance.GetPartnerAttrByTableId(_id);
- if (partnerInfo == null)
- return;
- var curUsePlan = PartnersData.Instance.CurUsePlan;
- Context.UI.OpenAsync(
- UIKeys.PartnerEpiChangePanel,
- new PartnerEpiChangePanelCtrlParam()
- {
- PlanId = PartnersData.Instance.UsePlanId,
- SlotId = -1,
- SbId = _id,
- }
- );
- }
- private void OnClickDownBtn(EventContext context)
- {
- PartnersService.Instance.RequestPartnerDown(_id);
- }
- private void OnClickUpBtn(EventContext context)
- {
- //PartnersService.Instance.RequestPartnerUp(_data.uid);
- //Context.UI.OpenAsync(UIKeys.PartnerDetailsPanel, _id);
- if (PartnersData.Instance.GetPartnerAttrByTableId(_id) == null)
- return;
- PartnersService.Instance.OpenPartnerMode(_id);
- }
- private void OnClickBtn(EventContext context)
- {
- Context.UI.OpenAsync(
- UIKeys.PartnerDetailsPanel,
- new PartnerDetailsPanelParam()
- {
- PlanId = PartnersData.Instance.UsePlanId,
- SlotId = -1,
- PartnerId = _id,
- }
- );
- }
- #endregion
- public void OnRefresh(int index, int id)
- {
- _id = id;
- VM.PartnerItem.Ctrl.ShowUI(id);
- var table = PartnerTableRepo.Get(id);
- var partnerInfo = PartnersData.Instance.GetPartnerAttrByTableId(table.Id);
- var have = partnerInfo != null;
- var upPos = PartnersData.Instance.GetPartnerUpPosById(table.Id);
- var isUp = upPos >= 0;
- if (have)
- {
- VM.UpBtn.touchable = true;
- VM.StateCtrl.selectedIndex = isUp ? 2 : 1;
- }
- else
- {
- VM.UpBtn.touchable = false;
- VM.StateCtrl.selectedIndex = 0;
- }
- }
- }
- }
|