/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using FairyGUI; using FL.Data; using XGame; using XGame.Database; using XGame.Framework.UI; namespace FL.FGUI { /// /// UI逻辑处理类 /// /// public partial class CommonComCurrencyNestedCtrl : UIController { protected override void OnEnable(object intent) { AddUIListenres(); } protected override void OnDisable() { RemoveUIListenres(); } #region UI事件 private void AddUIListenres() { Context.AddListener(EventDefine.UpdataItemData, OnUpdateItemNum); } private void RemoveUIListenres() { Context.RemoveListener(EventDefine.UpdataItemData, OnUpdateItemNum); } #endregion private int _id; private void OnUpdateItemNum(int eventId, object args) { ShowItemNum(); } public void ShowUI(int currencyId, long count) { var currencyInfo = ItemTableRepo.Get(currencyId); if (currencyInfo != null) VM.IconLoader.icon = currencyInfo?.Icon; VM.NumLabel.text = count.ToString(); } private void SetItem(int id) { _id = id; ShowItemNum(); } private void ShowItemNum() { if (_id == 0) return; var currencyInfo = ItemTableRepo.Get(_id); if (currencyInfo == null) { Log.Error($"道具表不存在,id:{_id}"); return; } long num = ItemData.Instance.GetItemNum(_id); VM.IconLoader.icon = currencyInfo?.Icon; VM.NumLabel.text = num.FormatNumber(); } } }