/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using FairyGUI; using FL.Data.Items; 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(intent as IItemBase); } } 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(IItemBase data) { _itemInfo = ItemTableRepo.Get(data.TableId); VM.NameLabel.text = _itemInfo.Name; VM.DescLabel.text = _itemInfo.Desc; if (data is ItemBase itemBase) { VM.CountLabel.visible = true; VM.CountLabel.text = itemBase.Count.ToString(); } else { VM.CountLabel.visible = false; } 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); } } }