miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/GeneralPopup.lua

99 lines
2.8 KiB
Lua

----- 通用弹窗 -----
require("Base/BasePanel")
GeneralPopup = Inherit(BasePanel)
local this=GeneralPopup
--子模块脚本
local contentScripts = {
--回溯
[1] = {view = require("Modules/Popup/View/GeneralPopup_ResolveRecall"), panelName = "GeneralPopup_ResolveRecall",type=GENERAL_POPUP_TYPE.ResolveRecall},
--献祭
[2] = {view = require("Modules/Popup/View/GeneralPopup_ResolveDismantle"), panelName = "GeneralPopup_ResolveDismantle",type=GENERAL_POPUP_TYPE.ResolveDismantle},
--装备合成
[3]= {view=require("Modules/Popup/View/GeneralPopup_EquipCompound"),panelName="GeneralPopup_EquipCompound",type=GENERAL_POPUP_TYPE.EquipCompound},
--公会技能重置返还
[4]= {view=require("Modules/Popup/View/GeneralPopup_GuildSkillReset"),panelName="GeneralPopup_GuildSkillReset",type=GENERAL_POPUP_TYPE.GuildSkill},
}
--子模块预设
local contentPrefabs={}
--打开弹窗类型
local popupType
--打开弹窗索引
local index=0
function GeneralPopup:InitComponent()
this.contents=Util.GetGameObject(this.gameObject,"Contents")
this.backBtn=Util.GetGameObject(this.contents,"BackBtn")
--子模块脚本初始化
for i = 1, #contentScripts do
contentScripts[i].view:InitComponent(Util.GetGameObject(this.contents, contentScripts[i].panelName))
end
--预设赋值
for i=1,#contentScripts do
contentPrefabs[i]=Util.GetGameObject(this.contents,contentScripts[i].panelName)
end
end
function GeneralPopup:BindEvent()
for i = 1, #contentScripts do
contentScripts[i].view:BindEvent()
end
--返回按钮
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
end
function GeneralPopup:AddListener()
for i = 1, #contentScripts do
contentScripts[i].view:AddListener()
end
end
function GeneralPopup:RemoveListener()
for i = 1, #contentScripts do
contentScripts[i].view:RemoveListener()
end
end
function GeneralPopup:OnSortingOrderChange()
this.sortingOrder = self.sortingOrder
end
function GeneralPopup:OnOpen(...)
local args={...}
popupType=args[1]
--根据传入类型打开对应面板
for i,v in pairs(contentScripts) do
if popupType==v.type then
index=i
break
end
end
for i=1,#contentPrefabs do
contentPrefabs[i].gameObject:SetActive(false)
end
contentPrefabs[index].gameObject:SetActive(true)
contentScripts[index].view:OnShow(this,args)--1、传入自己 2、传入不定参
end
function GeneralPopup:OnShow()
end
function GeneralPopup:OnClose()
for i = 1, #contentScripts do
contentScripts[i].view:OnClose()
end
end
function GeneralPopup:OnDestroy()
for i = 1, #contentScripts do
contentScripts[i].view:OnDestroy()
end
end
return GeneralPopup