miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/RedPacketView/RedPacketPanel.lua

177 lines
5.8 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
----- 公会红包 -----
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
local RedPacketPanel = Inherit(BasePanel)
local this=RedPacketPanel
local TabBox = require("Modules/Common/TabBox")
local _TabImgData = {select = "r_tongyong_xiaanniu_01", default = "r_tongyong_xiaanniu_02",}
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1) }
local _TabData = {
2021-04-09 12:26:35 +08:00
[1]= {txt = Language[11037]},
2021-05-21 14:47:04 +08:00
[2]= {txt = "发福利红包"},
[3]= {txt = Language[11038]},
[4]= {txt = Language[11039]},
2020-05-09 13:31:21 +08:00
}
--子模块脚本
this.contents = {
--主面板
[1] = {view = require("Modules/Guild/RedPacketView/RedPacket_SendView"), panelName = "SendView"},
2021-05-21 14:47:04 +08:00
--发送福利红包
[2] = {view = require("Modules/Guild/RedPacketView/RedPacket_SendWealView"), panelName = "SendWealView"},
2020-05-09 13:31:21 +08:00
--天官赐福
2021-05-21 14:47:04 +08:00
[3] = {view = require("Modules/Guild/RedPacketView/RedPacket_GetView"), panelName = "GetView"},
2020-05-09 13:31:21 +08:00
--每日仙缘礼
2021-05-21 14:47:04 +08:00
[4] = {view = require("Modules/Guild/RedPacketView/RedPacket_RankView"), panelName = "RankView"},
2020-05-09 13:31:21 +08:00
}
-- this.contentPanel={}
this.sortingOrder = 0
2021-05-21 14:47:04 +08:00
this.curIndex=1
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function RedPacketPanel:InitComponent()
this.panel=Util.GetGameObject(self.gameObject, "Panel")
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
2021-05-21 14:47:04 +08:00
this.tabbox = Util.GetGameObject(this.panel, "Contents/TabBox")
2020-05-09 13:31:21 +08:00
this.content=Util.GetGameObject(this.panel,"Contents")
this.contentPanel={}
--预设
for i = 1, #this.contents do
this.contentPanel[i]=Util.GetGameObject(this.content,this.contents[i].panelName)
end
--脚本
for i = 1, #this.contents do
this.contents[i].view:InitComponent(Util.GetGameObject(this.content, this.contents[i].panelName))
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
end
this.redPoint=Util.GetGameObject(this.content,"RedPoint")
end
--绑定事件(用于子类重写)
function RedPacketPanel:BindEvent()
for i = 1, #this.contents do
this.contents[i].view:BindEvent()
end
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function RedPacketPanel:AddListener()
for i = 1, #this.contents do
this.contents[i].view:AddListener()
end
Game.GlobalEvent:AddEvent(GameEvent.GuildRedPacket.OnCloseRedPointClick, this.CloseRedPointClick)
end
--移除事件监听(用于子类重写)
function RedPacketPanel:RemoveListener()
for i = 1, #this.contents do
this.contents[i].view:RemoveListener()
end
Game.GlobalEvent:RemoveEvent(GameEvent.GuildRedPacket.OnCloseRedPointClick, this.CloseRedPointClick)
end
--界面打开时调用(用于子类重写)
2021-05-21 14:47:04 +08:00
function RedPacketPanel:OnOpen(index)
if index then
this.curIndex=index
end
2020-05-09 13:31:21 +08:00
end
2021-05-21 14:47:04 +08:00
local redPointList
2020-05-09 13:31:21 +08:00
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function RedPacketPanel:OnShow()
2021-05-21 14:47:04 +08:00
-- BindRedPointObject(RedPointType.Guild_RedPacket,this.redPoint)
2021-03-01 18:29:21 +08:00
this.tabbox:SetActive(true)
2020-05-09 13:31:21 +08:00
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.OnTabChange)
2021-05-21 14:47:04 +08:00
this.TabCtrl:Init(this.tabbox, _TabData,this.curIndex)
redPointList = {}
for i = 1, Util.GetGameObject(this.tabbox,"box").transform.childCount do
redPointList[i] =Util.GetGameObject(Util.GetGameObject(this.tabbox,"box").transform:GetChild(i-1).gameObject,"RedPoint")
redPointList[i]:SetActive(false)
end
if redPointList[2] and redPointList[3] then
BindRedPointObject(RedPointType.Guid_SendPackage, redPointList[2])
BindRedPointObject(RedPointType.Guid_GetPackage, redPointList[3])
end
--CheckRedPointStatus(RedPointType.Guid_SendPackage)
--CheckRedPointStatus(RedPointType.Guid_GetPackage)
2020-05-09 13:31:21 +08:00
end
2021-05-21 14:47:04 +08:00
2020-05-09 13:31:21 +08:00
--重设层级
function RedPacketPanel:OnSortingOrderChange()
this.sortingOrder = self.sortingOrder
end
--界面关闭时调用(用于子类重写)
function RedPacketPanel:OnClose()
for i = 1, #this.contents do
this.contents[i].view:OnClose()
end
ClearRedPointObject(RedPointType.Guild_RedPacket,this.redPoint)
2021-06-04 14:19:16 +08:00
if redPointList[2] and redPointList[3] then
ClearRedPointObject(RedPointType.Guid_SendPackage, redPointList[2])
ClearRedPointObject(RedPointType.Guid_GetPackage, redPointList[3])
end
2020-05-09 13:31:21 +08:00
end
--界面销毁时调用(用于子类重写)
function RedPacketPanel:OnDestroy()
for i = 1, #this.contents do
this.contents[i].view:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2021-06-04 14:19:16 +08:00
redPointList=nil
2020-05-09 13:31:21 +08:00
end
-- tab按钮自定义显示设置
function this.TabAdapter(tab, index, status)
local img = Util.GetGameObject(tab, "Image")
local txt = Util.GetGameObject(tab, "Text")
2021-04-21 13:12:04 +08:00
img:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabImgData[status])
2020-05-09 13:31:21 +08:00
txt:GetComponent("Text").text = _TabData[index].txt
txt:GetComponent("Text").color = _TabFontColor[status]
end
-- tab改变回调事件
function this.OnTabChange(index, lastIndex)
if lastIndex then
this.CloseView(lastIndex)
end
this.OpenView(index)
if index==2 then
Game.GlobalEvent:DispatchEvent(GameEvent.GuildRedPacket.OnCloseRedPointClick)
end
end
-- 打开View
function this.OpenView(index)
this.contents[index].view:OnShow(this.sortingOrder)
for i = 1, #this.contentPanel do
this.contentPanel[i]:SetActive(i==index)
end
end
-- 关闭View
function this.CloseView(lastIndex)
2021-05-21 18:18:53 +08:00
CheckRedPointStatus(RedPointType.Guild_RedPacket)
2020-05-09 13:31:21 +08:00
this.contents[lastIndex].view:OnClose()
end
-- 刷新红包查看后红点点击操作
function this.CloseRedPointClick()
GuildRedPacketManager.isCheck=false
CheckRedPointStatus(RedPointType.Guild_RedPacket)
end
2020-06-23 18:36:24 +08:00
return RedPacketPanel