PGRData/Script/matrix/xui/xuiguildwar/map/XUiPanelBottom.lua

200 lines
5.9 KiB
Lua
Raw Normal View History

local XUiPanelBottom = XClass(nil, "XUiPanelBottom")
local CSTextManagerGetText = CS.XTextManager.GetText
local MAX_CHAT_WIDTH = 470
local CHAT_SUB_LENGTH = 30
local Normal = CS.UiButtonState.Normal
local Select = CS.UiButtonState.Select
function XUiPanelBottom:Ctor(ui, base, battleManager)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.Base = base
self.BattleManager = battleManager
XTool.InitUiObject(self)
2024-09-01 22:49:41 +02:00
self:InitButton()
self.IsMenuOn = false
end
function XUiPanelBottom:AddEventListener()
XEventManager.AddEventListener(XEventId.EVENT_GUILD_RECEIVE_CHAT, self.UpdateChart, self)
2024-09-01 22:49:41 +02:00
XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.CheckRedDotTask, self)
end
function XUiPanelBottom:RemoveEventListener()
XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_RECEIVE_CHAT, self.UpdateChart, self)
2024-09-01 22:49:41 +02:00
XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.CheckRedDotTask, self)
end
2024-09-01 22:49:41 +02:00
function XUiPanelBottom:InitButton()
self.BtnTask.CallBack = function()
self:OnBtnTaskClick()
end
self.BtnRole.CallBack = function()
self:OnBtnRoleClick()
end
self.BtnReport.CallBack = function()
self:OnBtnReportClick()
end
self.BtnMap.CallBack = function()
self:OnBtnMapClick()
end
self.BtnMenu.CallBack = function()
self:OnBtnMenuClick()
end
self.BtnChat.CallBack = function()
self:OnBtnChatClick()
end
self.BtnMe.CallBack = function()
self:OnBtnMeClick()
end
self.BtnInformation.CallBack = function()
self:OnBtnInformationClick()
end
2024-09-01 22:49:41 +02:00
self.BtnSupport.CallBack = function()
self:OnBtnSupportClick()
end
self.BtnLz.CallBack = function()
self:OnBtnBossRewardClick()
end
XRedPointManager.AddRedPointEvent(self.BtnSupport, self.OnSupportRedPointEvent, self, {
XRedPointConditions.Types.CONDITION_GUILDWAR_SUPPLY,
XRedPointConditions.Types.CONDITION_GUILDWAR_ASSISTANT
})
self.BtnDifficulty.CallBack = function()
self:OnBtnDifficultyClick()
end
end
function XUiPanelBottom:UpdatePanel()
self:UpdateChart()
self:UpdateMenu()
2024-09-01 22:49:41 +02:00
self:UpdateBossReward()
local GuildLeader = XDataCenter.GuildWarManager.IsCanSelectDifficulty()
self.BtnMap.gameObject:SetActiveEx(GuildLeader)
end
function XUiPanelBottom:UpdateMenu()
self.BtnMenu:SetButtonState(self.IsMenuOn and Normal or Select)
if self.IsMenuOn then
self.PanelBtn.gameObject:SetActiveEx(true)
self.Base:PlayAnimationWithMask("ButtonEnable")
else
2024-09-01 22:49:41 +02:00
self.Base:PlayAnimationWithMask("ButtonDisable", function()
self.PanelBtn.gameObject:SetActiveEx(false)
end)
end
2024-09-01 22:49:41 +02:00
self:CheckRedDotTask()
end
--更新聊天
function XUiPanelBottom:UpdateChart()
local chatList = XDataCenter.ChatManager.GetGuildChatList()
2024-09-01 22:49:41 +02:00
if not chatList then
return
end
local lastChat = chatList[1]
if not lastChat then
self.TxtMessage.text = ""
return
end
local nameRemark = XDataCenter.SocialManager.GetPlayerRemark(lastChat.SenderId, lastChat.NickName)
local content = lastChat.Content
if lastChat.MsgType == ChatMsgType.System then
content = string.format("%s%s", CS.XTextManager.GetText("GuildChannelTypeAll"), lastChat.Content)
self.TxtMessage.text = content
else
content = lastChat.Content
if lastChat.MsgType == ChatMsgType.Emoji then
content = CS.XTextManager.GetText("GuildEmojiReplace")
end
self.TxtMessage.text = string.format("%s%s", nameRemark, content)
end
if XUiHelper.CalcTextWidth(self.TxtMessage) > MAX_CHAT_WIDTH then
self.TxtMessage.text = string.Utf8Sub(self.TxtMessage.text, 1, CHAT_SUB_LENGTH) .. [[...]]
end
end
function XUiPanelBottom:OnBtnTaskClick()
XLuaUiManager.Open("UiGuildWarTask")
end
function XUiPanelBottom:OnBtnRoleClick()
XLuaUiManager.Open("UiGuildWarUpCharacter")
end
function XUiPanelBottom:OnBtnReportClick()
XLuaUiManager.Open("UiGuildWarRank")
end
function XUiPanelBottom:OnBtnMapClick()
if not XDataCenter.GuildWarManager.CheckRoundIsInTime() then
XUiManager.TipText("GuildWarNoInRound")
return
end
self.Base:PathEdit()
end
function XUiPanelBottom:OnBtnMenuClick()
self.IsMenuOn = not self.IsMenuOn
self:UpdateMenu()
end
function XUiPanelBottom:OnBtnChatClick()
if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SocialChat) then
return
end
2024-09-01 22:49:41 +02:00
XUiHelper.OpenUiChatServeMain(false, ChatChannelType.Guild, ChatChannelType.World)
end
function XUiPanelBottom:OnBtnMeClick()
XEventManager.DispatchEvent(XEventId.EVENT_GUILDWAR_LOOKAT_ME)
end
function XUiPanelBottom:OnBtnInformationClick()
XLuaUiManager.Open("UiGuildWarInformation")
end
function XUiPanelBottom:ShowPanel()
self.GameObject:SetActiveEx(true)
end
function XUiPanelBottom:HidePanel()
self.GameObject:SetActiveEx(false)
end
2024-09-01 22:49:41 +02:00
function XUiPanelBottom:CheckRedDotTask()
local IsHasAchievedTask = XDataCenter.GuildWarManager.CheckTaskAchieved()
2024-09-01 22:49:41 +02:00
self.BtnTask:ShowReddot(IsHasAchievedTask)
end
function XUiPanelBottom:OnBtnSupportClick()
if XDataCenter.GuildWarManager.CheckIsPlayerSkipRound() then
XUiManager.TipText("GuildWarNotQualifySupport")
return
end
XLuaUiManager.Open("UiGuildWarSupport")
end
function XUiPanelBottom:OnBtnDifficultyClick()
XLuaUiManager.Open("UiGuildWarSelect")
end
2024-09-01 22:49:41 +02:00
function XUiPanelBottom:OnSupportRedPointEvent(count)
self.BtnSupport:ShowReddot(count >= 0)
self.BtnMenu:ShowReddot(count >= 0)
end
function XUiPanelBottom:OnBtnBossRewardClick()
local bossNode = XDataCenter.GuildWarManager.GetBattleManager():GetNodeBossRoot()
XLuaUiManager.Open("UiGuildWarLzTask", bossNode)
end
2024-09-01 22:49:41 +02:00
function XUiPanelBottom:UpdateBossReward()
local isShowRedPoint = XDataCenter.GuildWarManager.IsShowRedPointBossReward()
self.BtnLz:ShowReddot(isShowRedPoint)
end
return XUiPanelBottom