/// #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 { #region 属性 /// /// 圣兵id /// 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; } } } }