Files
JJBB/Assets/Project/Script/LuaScripts/UI/InvestmentActCS/InvestmentActRootCS.cs
2024-08-23 15:49:34 +08:00

151 lines
4.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GCGame.Table;
using Module.Log;
public class InvestmentActRootCS : MarketingUIBaseCS {
#region Single
private static InvestmentActRootCS _instance;
public static InvestmentActRootCS Instance
{
get
{
if (_instance != null)
{
return _instance;
}
LogModule.ErrorLog("Can't get instances");
return null;
}
}
private void Awake()
{
if (_instance == null)
{
_instance = this;
}
closeBtn.onClick.AddListener(Close);
}
#endregion
public UIContainerSelect menuContainer; // 列表容器
public GameObject pageContainer; // 页面容器
public List<MarketingActState> actPageInfo; // 菜单信息
public Button closeBtn; // 关闭按钮
private int curPageID; // 当前显示页面ID
private void OnEnable()
{
Init();
}
private void OnDisable()
{
if (MarketingActsRoot.Instance() != null)
{
MarketingActsRoot.Instance().ClearShowingWin(_ActID);
}
}
public void Close()
{
gameObject.SetActive(false);
}
private void Init()
{
//for(int i = 0; i < smallItems.Count; ++i)
//{
// smallItems[i].OnItemClick();
//}
AskForInfo();
}
private void SetMenu(List<MarketingActState> menuInfos)
{
if (menuInfos.Count > 0)
{
List<MarketingActState> selectMenus = new List<MarketingActState>();
selectMenus.Add(menuInfos[0]);
menuContainer.InitSelectContent(menuInfos, selectMenus, OnMenuSelect);
}
}
// 加载页面
private void OnMenuSelect(object info)
{
MarketingActState selectMenu = info as MarketingActState;
if (selectMenu != null)
{
if (MarketingActsRoot.Instance()._ShowingWin.ContainsKey(curPageID))
{
if (MarketingActsRoot.Instance()._ShowingWin[curPageID] != null)
{
MarketingActsRoot.Instance()._ShowingWin[curPageID].SetActive(false);
}
else
{
LogModule.DebugLog("Try to get an activity in Openservice. But is Null, please check _ActId = " + curPageID);
}
MarketingActsRoot.Instance()._ShowingWin.Remove(curPageID);
}
///////////// 临时修复Bug会出现没及时删除旧页面的情况
if (MarketingActsRoot.Instance()._ShowingWin.ContainsKey(selectMenu.actID))
{
if (MarketingActsRoot.Instance()._ShowingWin[selectMenu.actID] != null)
{
MarketingActsRoot.Instance()._ShowingWin[selectMenu.actID].SetActive(false);
}
else
{
LogModule.DebugLog("Try to get an activity in Openservice. But is Null, please check _ActId = " + curPageID);
}
MarketingActsRoot.Instance()._ShowingWin.Remove(selectMenu.actID);
}
////////////
Tab_ActInfoClient tab = TableManager.GetActInfoClientByID(selectMenu.actID, 0);
Hashtable parm = new Hashtable();
parm.Add("ActState", selectMenu);
LuaUIManager.Instance.ShowLuaUIAsChild(tab.UIPath, pageContainer, MarketingActsRoot.Instance().LoadUICallBack, parm, true);
curPageID = selectMenu.actID;
}
else
{
LogModule.ErrorLog("No this page.");
}
}
#region
// 请求
private void AskForInfo()
{
MarketingActsReq request = new MarketingActsReq();
request.actType = _ActID;
request.SendMsg();
}
// 接收
protected override void MarketingActRetInner(MarketingActsRet marketActsRet)
{
base.MarketingActRetInner(marketActsRet);
SetMenu(marketActsRet.actIDState);
}
#endregion
}