/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using System.Collections.Generic;
using FairyGUI;
using FL.Data;
using XGame;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class PartnerSbMainPanelCtrl : UIController
{
protected override void OnEnable(object intent)
{
AddUIListenres();
InitView();
ShowUI();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres()
{
VM.ReplaceBtn.onClick.Add(OnClickReplaceBtn);
VM.StrengthBtn.onClick.Add(OnClickStrengthBtn);
VM.OneUpBtn.onClick.Add(OnClickOneUpBtn);
VM.RecommendBtn.onClick.Add(OnClickRecommendBtn);
VM.BagBtn.onClick.Add(OnClickBagBtn);
VM.MaskBtn.onClick.Add(OnClickMaskBtn);
VM.ConfirmBtn.onClick.Add(OnClickConfirmBtn);
VM.CancelBtn.onClick.Add(OnClickCancelBtn);
}
private void RemoveUIListenres()
{
VM.ReplaceBtn.onClick.Remove(OnClickReplaceBtn);
VM.StrengthBtn.onClick.Remove(OnClickStrengthBtn);
VM.OneUpBtn.onClick.Remove(OnClickOneUpBtn);
VM.RecommendBtn.onClick.Remove(OnClickRecommendBtn);
VM.BagBtn.onClick.Remove(OnClickBagBtn);
VM.MaskBtn.onClick.Remove(OnClickMaskBtn);
VM.ConfirmBtn.onClick.Remove(OnClickConfirmBtn);
VM.CancelBtn.onClick.Remove(OnClickCancelBtn);
}
private void OnClickReplaceBtn(EventContext context) { }
private void OnClickStrengthBtn(EventContext context) { }
private void OnClickOneUpBtn(EventContext context) { }
private void OnClickRecommendBtn(EventContext context) { }
private void OnClickBagBtn(EventContext context) { }
private void OnClickMaskBtn(EventContext context) { }
private void OnClickConfirmBtn(EventContext context) { }
private void OnClickCancelBtn(EventContext context) { }
#endregion
#region 属性
private bool _initView = false;
private int _curSelectPos = 0;
#endregion
#region 页面
private void InitView()
{
if (_initView)
return;
_initView = true;
VM.SbList.ListType = EGListType.None;
}
private void ShowUI()
{
RefreshGoneUpPartners(true);
UpdateDetail();
}
private void RefreshGoneUpPartners(bool chooseFirstSb)
{
var plan = PartnersData.Instance.CurUsePlan;
if(plan == null)
{
Log.Error($"圣兵上阵方案不存在,id:{PartnersData.Instance.CurUsePlan}");
return;
}
if (chooseFirstSb)
{
_curSelectPos = 0;
for (int i = 0; i < PartnersData.GoneUpLimit; i++)
{
var slot = plan.GetSlot(i);
if (slot?.SbId > 0)
{
_curSelectPos = i;
break;
}
}
}
var list = new List();
for (int i = 0; i < PartnersData.GoneUpLimit; i++)
{
var data = new PartnerSbUpListItemParam()
{
PosId = i,
CurSelectPos = _curSelectPos,
};
list.Add(data);
}
VM.SbList.BindDatas(list);
}
private void UpdateDetail()
{
var plan = PartnersData.Instance.CurUsePlan;
if (plan == null)
{
Log.Error($"圣兵上阵方案不存在,id:{PartnersData.Instance.CurUsePlan}");
return;
}
var slot = plan.GetSlot(_curSelectPos);
VM.SbDetailNested.Ctrl.ShowUI(slot?.SbId ?? 0);
}
#endregion
}
}