---@class KLUIBuffInfoPanel:UIKmlLuaPanelBase
---@field view KLUIBuffInfoPanelView
local KLUIBuffInfoPanel = class(UIKmlLuaPanelBase)
---创建时调用一次
function KLUIBuffInfoPanel:Init()
end
---创建或者刷新界面数据时调用
function KLUIBuffInfoPanel:Refresh()
if self.timer then
SL:UnSchedule(self.timer)
self.timer = nil
end
---@type cfg_buff_column
local buffTbl = SL:GetConfig("cfg_buff",self.args.cfgId)
local des = SL:GetMetaValue(EMetaVarGetKey.GET_BUFF_DESCRIDE,self.args.cfgId)
if self.args.buffText then
des = self.args.buffText
end
if buffTbl then
if self.args.endTime > 0 then
self.timer = SL:Schedule(self.timer,0,1,-1,function()
local leftTime = self.args.endTime - Time.GetServerTime()
if leftTime <= 0 then
SL:UnSchedule(self.timer)
self.timer = nil
self:ClosePanel()
else
local time_str = ""..self:GetTime(leftTime) ..""
local str = buffTbl.buffName .. "\n".. time_str .. "\n" ..des
GUI:Text_setString(self.view.des,str)
end
end)
else
local str = buffTbl.buffName .. "\n" ..des
--特权卡永久使用特殊处理
if self.args.cfgId == 30000011 or self.args.cfgId == 30000012 or self.args.cfgId == 30000013 then
str = buffTbl.buffName .. "\n".. "已永久激活" .. "\n" ..des
end
GUI:Text_setString(self.view.des,str)
end
end
end
function KLUIBuffInfoPanel:GetTime(_second)
local second = math.floor(_second/1000)
local day = math.floor(second / (3600 * 24))
local hour = math.floor(second % (3600 * 24) / 3600)
local minute = math.floor(second % 3600 / 60)
local sec = math.floor(second % 60)
local str = ""
if day>0 then
str = str ..day .. "天"
end
if hour>0 then
str = str ..hour .. "小时"
end
if minute>0 then
str = str ..minute .. "分"
end
str = str ..sec .. "秒"
return str
end
---注册UI事件和服务器消息
function KLUIBuffInfoPanel:RegistEvents()
GUI:AddOnClickEvent(self.view.maskBtn,self,self.ClosePanel)
end
function KLUIBuffInfoPanel:ClosePanel()
GUI:UIPanel_Close(nil,self)
if self.timer then
SL:UnSchedule(self.timer)
self.timer = nil
end
end
function KLUIBuffInfoPanel:Close()
if self.timer then
SL:UnSchedule(self.timer)
self.timer = nil
end
end
return KLUIBuffInfoPanel