miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/GeneralBigPopup.lua

97 lines
3.4 KiB
Lua
Raw Normal View History

----- 中号通用弹窗 -----
require("Base/BasePanel")
2020-11-05 19:10:20 +08:00
GeneralBigPopup = Inherit(BasePanel)
local this = GeneralBigPopup
local sorting = 0
--子模块脚本
local contentScripts = {
--易经宝库
2021-05-12 17:40:38 +08:00
[GENERAL_POPUP_TYPE.YiJingBaoKu] = {view = require("Modules/GeneralPanel/View/GeneralBigPopup_YiJingBaoKu"), panelName = "GeneralBigPopup_YiJingBaoKu"},
--易经宝库奖励预览
2021-05-12 17:40:38 +08:00
[GENERAL_POPUP_TYPE.YiJingBaoKuRewardPreview] = {view = require("Modules/GeneralPanel/View/GeneralBigPopup_YiJingBaoKuRewardPreview"), panelName = "GeneralBigPopup_YiJingBaoKuRewardPreview"},
--修行境界预览
[GENERAL_POPUP_TYPE.PracticeStatePreview] = {view = require("Modules/GeneralPanel/View/GeneralBigPopup_PracticeStatePreview"), panelName = "GeneralBigPopup_PracticeStatePreview"},
2021-05-17 10:54:36 +08:00
[GENERAL_POPUP_TYPE.RecrutReward] = {view = require("Modules/GeneralPanel/View/GeneralBigPopup_ExpertRewardSortPanel"), panelName = "GeneralBigPopup_ExpertRewardSortPanel"},
[GENERAL_POPUP_TYPE.RecrutDetail] = {view = require("Modules/GeneralPanel/View/GeneralBigPopup_RecrutDetail"), panelName = "GeneralBigPopup_RecrutDetail"},
}
--子模块预设
local contentPrefabs={}
--打开弹窗类型
local popupType
--初始化组件(用于子类重写)
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:InitComponent()
this.contents=Util.GetGameObject(this.gameObject,"Contents")
this.backBtn=Util.GetGameObject(this.contents,"BG/BackBtn")
this.BG=Util.GetGameObject(this.contents,"BG")
this.Mask=Util.GetGameObject(this.gameObject,"Mask")
--子模块脚本初始化
2021-05-12 17:40:38 +08:00
for key, value in pairs(contentScripts) do
value.view:InitComponent(Util.GetGameObject(this.contents, value.panelName))
end
--预设赋值
2021-05-12 17:40:38 +08:00
for key, value in pairs(contentScripts) do
contentPrefabs[key]=Util.GetGameObject(this.contents,value.panelName)
end
end
--绑定事件(用于子类重写)
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:BindEvent()
2021-05-12 17:40:38 +08:00
for key, value in pairs(contentScripts) do
value.view:BindEvent()
end
--返回按钮
2021-05-12 17:40:38 +08:00
Util.AddClick(this.backBtn,function()
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged)
self:ClosePanel()
end)
Util.AddClick(this.Mask,function()
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged)
self:ClosePanel()
end)
end
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:AddListener()
2021-05-12 17:40:38 +08:00
for key, value in pairs(contentScripts) do
value.view:AddListener()
end
end
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:RemoveListener()
2021-05-12 17:40:38 +08:00
for key, value in pairs(contentScripts) do
value.view:RemoveListener()
end
end
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:OnSortingOrderChange()
this.sortingOrder = self.sortingOrder
end
2021-05-12 17:40:38 +08:00
function GeneralBigPopup:OnOpen(popupKey,...)
for key, value in pairs(contentPrefabs) do
value.gameObject:SetActive(false)
end
2021-05-12 17:40:38 +08:00
this.Mask:SetActive(popupKey ~= GENERAL_POPUP_TYPE.Onhook)
this.BG:SetActive(popupKey ~= GENERAL_POPUP_TYPE.Onhook)
2021-05-12 17:40:38 +08:00
contentPrefabs[popupKey].gameObject:SetActive(true)
contentScripts[popupKey].view:OnShow(this,...)--1、传入自己 2、传入不定参
end
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:OnShow()
end
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:OnClose()
2021-05-12 17:40:38 +08:00
for key, value in pairs(contentScripts) do
value.view:OnClose()
end
end
2020-11-05 19:10:20 +08:00
function GeneralBigPopup:OnDestroy()
2021-05-12 17:40:38 +08:00
for key, value in pairs(contentScripts) do
value.view:OnDestroy()
end
end
2020-11-05 19:10:20 +08:00
return GeneralBigPopup