156 lines
4.3 KiB
Lua
156 lines
4.3 KiB
Lua
------------------------------------------------
|
|
--作者: 杨全福
|
|
--日期: 2020-07-27
|
|
--文件: UIFuncList.lua
|
|
--模块: UIFuncList
|
|
--描述: 功能列表公用组件,用于展示功能列表
|
|
------------------------------------------------
|
|
local L_DefaultFuncList = nil
|
|
|
|
local UIFuncList = {
|
|
Go = nil,
|
|
Trans = nil,
|
|
Grid = nil,
|
|
UIFuncList = nil,
|
|
DefaultFuncList = nil,
|
|
ClickCallBack = nil,
|
|
}
|
|
|
|
function UIFuncList:New(trans)
|
|
local _m = Utils.DeepCopy(self)
|
|
_m.Go = trans.gameObject
|
|
_m.Trans = trans
|
|
_m.Grid = UIUtils.FindGrid(trans)
|
|
_m:FindCom()
|
|
return _m
|
|
end
|
|
|
|
local L_FuncIcon = nil
|
|
function UIFuncList:FindCom()
|
|
self.UIFuncList = List:New()
|
|
local _childCount = self.Trans.childCount
|
|
for i = 1, _childCount do
|
|
local _funcUI = L_FuncIcon:New(self.Trans:GetChild(i - 1), self)
|
|
self.UIFuncList:Add(_funcUI)
|
|
end
|
|
|
|
if L_DefaultFuncList == nil then
|
|
local _gCfg = DataConfig.DataGlobal[GlobalName.clone_fail_up_way]
|
|
if _gCfg ~= nil then
|
|
L_DefaultFuncList = Utils.SplitNumber(_gCfg.Params, '_')
|
|
end
|
|
end
|
|
end
|
|
|
|
function UIFuncList:SetFailedFunc()
|
|
local _funcList = List:New()
|
|
local _showShouChong = false
|
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|
if _lp ~= nil then
|
|
_showShouChong = _lp.PropMoudle.CurRecharge <= 0
|
|
end
|
|
if _showShouChong then
|
|
--显示首充
|
|
_funcList:Add(FunctionStartIdCode.FirstCharge)
|
|
else
|
|
if GameCenter.MainFunctionSystem:FunctionIsVisible(FunctionStartIdCode.LimitDicretShop) then
|
|
--显示超值折扣
|
|
_funcList:Add(FunctionStartIdCode.LimitDicretShop)
|
|
elseif GameCenter.MainFunctionSystem:FunctionIsVisible(FunctionStartIdCode.LimitDicretShop2) then
|
|
--显示超值折扣2
|
|
_funcList:Add(FunctionStartIdCode.LimitDicretShop2)
|
|
else
|
|
--显示充值
|
|
_funcList:Add(FunctionStartIdCode.Pay)
|
|
end
|
|
end
|
|
for i = 1, #L_DefaultFuncList do
|
|
_funcList:Add(L_DefaultFuncList[i])
|
|
end
|
|
self:SetFuncList(_funcList)
|
|
end
|
|
|
|
function UIFuncList:SetFuncList(funcList)
|
|
if #self.UIFuncList <= 0 then
|
|
return
|
|
end
|
|
|
|
local _tempGo = self.UIFuncList[1].Go
|
|
for i = 1, #funcList do
|
|
local _ui = nil
|
|
if i <= #self.UIFuncList then
|
|
_ui = self.UIFuncList[i]
|
|
else
|
|
_ui = L_FuncIcon:New(UnityUtils.Clone(_tempGo).transform, self)
|
|
self.UIFuncList:Add(_ui)
|
|
end
|
|
|
|
_ui:SetFunc(DataConfig.DataFunctionStart[funcList[i]])
|
|
end
|
|
|
|
for i = #funcList + 1, #self.UIFuncList do
|
|
self.UIFuncList[i]:SetFunc(nil)
|
|
end
|
|
self.Grid:Reposition()
|
|
end
|
|
|
|
function UIFuncList:OnFuncUpdate(id, isVisible, isShowRedPoint)
|
|
for i = 1, #self.UIFuncList do
|
|
if self.UIFuncList[i].FuncCfg ~= nil and self.UIFuncList[i].FuncCfg.FunctionId == id then
|
|
self.UIFuncList[i]:RefreshFunc(isVisible, isShowRedPoint);
|
|
end
|
|
end
|
|
self.Grid:Reposition()
|
|
end
|
|
|
|
L_FuncIcon = {
|
|
Parent = nil,
|
|
Go = nil,
|
|
Trans = nil,
|
|
Spr = nil,
|
|
Btn = nil,
|
|
Name = nil,
|
|
RedPoint = nil,
|
|
FuncCfg = nil,
|
|
}
|
|
function L_FuncIcon:New(trans, parent)
|
|
local _m = Utils.DeepCopy(self)
|
|
_m.Parent = parent
|
|
_m.Go = trans.gameObject
|
|
_m.Trans = trans
|
|
_m.Spr = UIUtils.FindSpr(trans)
|
|
_m.Btn = UIUtils.FindBtn(trans)
|
|
UIUtils.AddBtnEvent(_m.Btn, _m.OnBtnClick, _m)
|
|
_m.Name = UIUtils.FindLabel(trans, "Name")
|
|
_m.RedPoint = UIUtils.FindGo(trans, "RedPoint")
|
|
return _m
|
|
end
|
|
|
|
function L_FuncIcon:SetFunc(funcCfg)
|
|
self.FuncCfg = funcCfg
|
|
if funcCfg ~= nil then
|
|
self.Go:SetActive(true)
|
|
self.Spr.spriteName = funcCfg.MainIcon
|
|
UIUtils.SetTextByStringDefinesID(self.Name, funcCfg._FunctionName)
|
|
else
|
|
self.Go:SetActive(false)
|
|
end
|
|
end
|
|
|
|
function L_FuncIcon:OnBtnClick()
|
|
if self.FuncCfg ~= nil then
|
|
GameCenter.MainFunctionSystem:DoFunctionCallBack(self.FuncCfg.FunctionId)
|
|
if self.Parent.ClickCallBack ~= nil then
|
|
self.Parent.ClickCallBack(self.FuncCfg.FunctionId)
|
|
end
|
|
end
|
|
end
|
|
|
|
function L_FuncIcon:RefreshFunc(isVisible, isShowRedPoint)
|
|
self.Go:SetActive(isVisible)
|
|
if self.RedPoint ~= nil then
|
|
self.RedPoint:SetActive(isShowRedPoint)
|
|
end
|
|
end
|
|
|
|
return UIFuncList |