LightItem = LightItem or BaseClass(BaseItem)
|
|
local LightItem = LightItem
|
|
|
|
function LightItem:__init()
|
|
self.base_file = "light"
|
|
self.layout_file = "LightItem"
|
|
self.model = LightModel:GetInstance()
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function LightItem:Load_callback()
|
|
self.nodes = {
|
|
"mark_image:obj","name_text:txt","click_con:obj","red_image:obj","select_image:obj",
|
|
"wear_image:obj","active_image2:obj","lock_image:obj","up_image:obj","head:img",
|
|
}
|
|
self:GetChildren(self.nodes)
|
|
|
|
|
|
self:AddEvents()
|
|
if self.need_refreshData then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function LightItem:AddEvents( )
|
|
local function onClick(target,x,y)
|
|
if target == self.click_con_obj then
|
|
self.call_back(self.data.id)
|
|
end
|
|
end
|
|
AddClickEvent(self.click_con_obj,onClick)
|
|
|
|
local function on_ans_update_red_dot( )
|
|
self:RedDotRefresh()
|
|
end
|
|
self:BindEvent(NewMainRoleModel:getInstance(), NewMainRoleModel.ANS_UPDATE_RED_DOT, on_ans_update_red_dot)
|
|
end
|
|
|
|
|
|
function LightItem:RedDotRefresh( )
|
|
self.red_image_obj:SetActive(self.model:GetLightOneRed(false,self.data.id))
|
|
end
|
|
|
|
function LightItem:UpdateView( )
|
|
if not self.data then
|
|
return
|
|
end
|
|
local can_active = self.model:CanLightActive( false,self.data.id )
|
|
local is_active = self.model:GetLightIsActive( self.data.id )
|
|
self.wear_image_obj:SetActive(self.model:GetLightUsingSkin() == self.data.id)
|
|
self.mark_image_obj:SetActive(not is_active and (not can_active))
|
|
self.lock_image_obj:SetActive((not is_active) and (not can_active))
|
|
self.select_image_obj:SetActive(self.data.id == self.select_id)
|
|
self.active_image2_obj:SetActive(can_active)
|
|
self.up_image_obj:SetActive(self.model:CanLightUpGrade( false,self.data.id ))
|
|
lua_resM:setImageSprite(self, self.head_img, "lighticon_asset", "light_icon_" .. self.index,true)
|
|
|
|
self:RedDotRefresh()
|
|
local conf = self.model:GetLightConfOne( self.data.id )
|
|
if conf then
|
|
self.name_text_txt.text = Trim(conf.name)
|
|
end
|
|
end
|
|
|
|
function LightItem:GetId( )
|
|
return self.fashion_id or 0
|
|
end
|
|
|
|
function LightItem:SetData(index, data, call_back,select_id)
|
|
self.index = index
|
|
self.data = data
|
|
self.call_back = call_back
|
|
self.select_id = select_id
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
self:UpdateView()
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function LightItem:__delete( )
|
|
|
|
end
|