源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

96 lines
2.5 KiB

EquipCollectTabItem = EquipCollectTabItem or BaseClass(BaseItem)
local EquipCollectTabItem = EquipCollectTabItem
function EquipCollectTabItem:__init()
self.base_file = "equipCollect"
self.layout_file = "EquipCollectTabItem"
self.model = EquipCollectModel:GetInstance()
self:Load()
end
function EquipCollectTabItem:Load_callback()
self.nodes = {
"name_text:tmp", "bg:img:obj", "bg/red_dot:obj", "click_con:obj"
}
self:GetChildren(self.nodes)
self:AddEvents()
if self.need_refreshData then
self:UpdateView()
end
if self.need_show_red then
self:ShowRedPoint(self.show_red_dot)
end
if self.need_reselect then
self:SetSelect(self.is_select)
end
end
function EquipCollectTabItem:AddEvents( )
local function on_click( target )
if self.callback then
self.callback(self.index)
end
end
AddClickEvent(self.click_con_obj, on_click)
end
function EquipCollectTabItem:UpdateView( )
self.dynamic_num = 2
if self.index % 2 == 0 then
self.dynamic_num = 1
end
local str = string.format("equipCollect_tab%s_%s", self.dynamic_num, self.is_select and "light" or "normal")
lua_resM:setImageSprite(self, self.bg_img, "equipCollect_asset", str, true)
SetAnchoredPositionX(self.name_text, self.is_select and 9 or -4)
self.name_text_tmp.text = self.data.name
end
function EquipCollectTabItem:SetCallBackFunc( func )
self.callback = func
end
function EquipCollectTabItem:SetData( data,index )
self.data = data
self.index = index
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function EquipCollectTabItem:ShowRedPoint( bool )
bool = bool == nil and false or bool
self.show_red_dot = bool
if self.is_loaded then
self.red_dot_obj:SetActive(bool)
self.need_show_red = false
else
self.need_show_red = true
end
end
function EquipCollectTabItem:SetSelect( bool )
self.is_select = bool
if self.is_loaded then
self.need_reselect = false
local str = string.format("equipCollect_tab%s_%s", self.dynamic_num, self.is_select and "light" or "normal")
lua_resM:setImageSprite(self, self.bg_img, "equipCollect_asset", str, true)
if self.is_select then
SetTMPSharedMaterial(self.name_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkPurpleTitle)
else
SetTMPSharedMaterial(self.name_text_tmp, ShaderTools.TMPSharedMaterialType.FZZZDefault)
end
SetAnchoredPositionX(self.name_text, self.is_select and 9 or -4)
else
self.need_reselect = true
end
end
function EquipCollectTabItem:__delete( )
end