CommonActivityIconTipView = CommonActivityIconTipView or BaseClass(BaseView)
|
|
local CommonActivityIconTipView = CommonActivityIconTipView
|
|
function CommonActivityIconTipView:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "CommonActivityIconTipView"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.use_background = false
|
|
self.append_to_ctl_queue = false
|
|
self.str = ""
|
|
self.pos_x = 0
|
|
self.pos_y = 0
|
|
self.time = 10
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:UpdateView(self.str,self.pos_x,self.pos_y)
|
|
end
|
|
self.close_callback = function ()
|
|
self:Remove()
|
|
end
|
|
end
|
|
|
|
function CommonActivityIconTipView:Remove()
|
|
if self.event_list_id then
|
|
GlobalEventSystem:UnBind(self.event_list_id)
|
|
self.event_list_id = nil
|
|
end
|
|
|
|
if self.timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
end
|
|
|
|
function CommonActivityIconTipView:Open( str,x,y )
|
|
self.str = str or self.str
|
|
self.pos_x = x or self.pos_x
|
|
self.pos_y = y or self.pos_y
|
|
print("huangcong:CommonActivityIconTipView [35]: ",str,x,y)
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function CommonActivityIconTipView:LoadSuccess()
|
|
local nodes = {
|
|
"layout/bg","layout/text:txt","layout:obj"
|
|
}
|
|
self:GetChildren(nodes)
|
|
self:InitEvent()
|
|
end
|
|
|
|
function CommonActivityIconTipView:InitEvent()
|
|
local updateFunc2 = function ()
|
|
self:Close()
|
|
end
|
|
self.event_list_id = GlobalEventSystem:Bind(EventName.CLOSE_ACTIVITY_ICON_TIP_VIEW, updateFunc2)
|
|
end
|
|
|
|
function CommonActivityIconTipView:UpdateView(str,x,y)
|
|
self.str = str or self.str
|
|
self.pos_x = x or self.pos_x
|
|
self.pos_y = y or self.pos_y
|
|
self.layout_obj:SetActive(false)
|
|
-- local width = self.text_txt.preferredWidth
|
|
-- width = width + 150
|
|
-- self.bg.sizeDelta = Vector2(width,80)
|
|
self.text_txt.text = self.str
|
|
if self.pos_x and self.pos_y then
|
|
-- local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
|
|
-- self.layout.sizeDelta = Vector2(307,self.curr_height)
|
|
self.layout.anchoredPosition = Vector3(self.pos_x+313,self.pos_y+242,0)
|
|
end
|
|
self.layout_obj:SetActive(true)
|
|
self:SetTimer()
|
|
end
|
|
|
|
function CommonActivityIconTipView:SetTimer()
|
|
if self.timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
local function onTimer()
|
|
self.time = self.time - 1
|
|
if self.time > 0 then
|
|
else
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
self:Close()
|
|
end
|
|
end
|
|
self.timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
|
|
end
|