12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- /// #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
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class BagSourceOfPropsPanelCtrl : UIController<BagSourceOfPropsPanelVM>
- {
- 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);
- }
- }
- }
- /// <summary>
- /// 显示来源跳转UI
- /// </summary>
- private void ShowJumpUI(int[] jumpIds)
- {
- VM.JumpList.BindDatas(jumpIds);
- }
- }
- }
|