123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /// #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
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerEpiChangeListItemCtrl : UIController<PartnerEpiChangeListItemVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.EpiLabel.VM.PanelEvent.Add(OnClick);
- }
- private void RemoveUIListenres()
- {
- VM.EpiLabel.VM.PanelEvent.Remove(OnClick);
- }
- private void OnClick(EventContext eventContext)
- {
- EventSingle.Instance.Notify(EventDefine.EpigraphChangeSelect, _mwId);
- }
- #endregion
- #region 属性
- private int _sbId;
- private int _mwId;
- private int _planId;
- private int _curSelectId;
- #endregion
- #region 页面
- public void OnRefresh(int index, EpiChangeListData data)
- {
- _sbId = data.SbId;
- _mwId = data.MwId;
- _planId = data.PlanId;
- _curSelectId = data.CurSelectId;
- UpEpiInfo();
- }
- private void UpEpiInfo()
- {
- var table = EpigraphTableRepo.Get(_mwId);
- if (table == null)
- {
- Log.Error($"铭文表不存在id:{_mwId}");
- return;
- }
- VM.EpiLabel.Ctrl.SetEpiIcon(_mwId, true);
- VM.NameLabel.text = table.Name;
- VM.IsSelect.selectedIndex = _mwId == _curSelectId ? 1 : 0;
- var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId);
- if (info == null)
- {
- Log.Error($"铭文数据不存在,id:{_mwId}");
- return;
- }
- if (_planId != PartnersData.Instance.UsePlanId)
- {
- if (!PartnersData.Instance.TryGetPlan(_planId, out var plan))
- {
- Log.Error($"方案信息不存在,planid:{_planId}");
- return;
- }
- var isUP = false;
- foreach (var slot in plan.Slots)
- {
- if (slot.MwId == _mwId)
- {
- isUP = true;
- break;
- }
- }
- VM.IsUp.selectedIndex = isUP ? 1 : 0;
- }
- else
- {
- VM.IsUp.selectedIndex = info.PartnerId > 0 ? 1 : 0;
- }
- }
- #endregion
- }
- }
|