/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using Codice.CM.Common; using FairyGUI; using XGame.Database; using XGame.Framework.UI; namespace FL.FGUI { /// /// UI逻辑处理类 /// /// public partial class BagSourceOfPropsPanelCtrl : UIController { private ItemTable _itemInfo; protected override void OnEnable(object intent) { AddUIListenres(); if (intent != null) { ShowUI((ItemInfoParam)intent); } } protected override void OnDisable() { RemoveUIListenres(); } #region UI事件 private void AddUIListenres() { VM.UseBtn.onClick.Add(OnClickUseBtn); } private void RemoveUIListenres() { VM.UseBtn.onClick.Remove(OnClickUseBtn); } private void OnClickUseBtn(EventContext context) { Context.UI.OpenAsync(UIKeys.BagUsePanel,_itemInfo); Context.ClosePanel(); } #endregion private void ShowUI(ItemInfoParam data) { if (data.itemInfo != null) { _itemInfo = data.itemInfo; VM.NameLabel.text = _itemInfo.Name; VM.DescLabel.text = _itemInfo.Desc; bool bShowNum = data.numDesc != null; VM.CountLabel.visible = bShowNum; if (bShowNum) VM.CountLabel.text = data.numDesc; VM.QualityIcon.icon = AddressableDefine.ItemFrame(_itemInfo.Quality); VM.ItemIcon.icon = _itemInfo.Icon; VM.UseBtn.visible = _itemInfo.Type == (int)EItemType.Gift || _itemInfo.Type == (int)EItemType.RedEnvelope; bool bHideJumpUI = _itemInfo.Jump?.Length == 0; VM.JumpUICtrl.selectedIndex = bHideJumpUI ? 1 : 0; if (!bHideJumpUI) { ShowJumpUI(_itemInfo.Jump); } } } /// /// 显示来源跳转UI /// private void ShowJumpUI(int[] jumpIds) { VM.JumpList.BindDatas(jumpIds); } } }