1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /// #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
- {
- /// <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(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);
- }
- }
- /// <summary>
- /// 显示来源跳转UI
- /// </summary>
- private void ShowJumpUI(int[] jumpIds)
- {
- VM.JumpList.BindDatas(jumpIds);
- }
- }
- }
|