源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

118 行
3.0 KiB

TaskVerTabSubBtn = TaskVerTabSubBtn or BaseClass(BaseItem)
local TaskVerTabSubBtn =TaskVerTabSubBtn
TaskVerTabSubBtn.Height = 73
function TaskVerTabSubBtn:__init(parent_wnd,prefab_asset,layer_name)
self.base_file = "task"
self.layout_file = "TaskVerTabSubBtn"
self.model = TaskModel:getInstance()
self.is_show_select = -1
self.is_show_dot = -1
self.force_fire_event = -1
self:Load()
end
function TaskVerTabSubBtn:Load_callback()
self.content_txt = self:GetChild("Text"):GetComponent("Text")
self.status_img = self:GetChild("Status"):GetComponent("Image")
self.status_flag = self:GetChild("Status").gameObject
self.click_btn,
self.select_flag,
self.dot = self:GetChildGameObjects({
"ClickBtn",
"Select",
"Dot",
})
local function onClickHandler(target)
if target == self.click_btn then
if self.call_back then
self.call_back(self.parent_index, self.sub_index,self.data)
end
end
end
AddClickEvent(self.click_btn,onClickHandler)
if self.need_refreshData then
self:SetData(self.data,self.parent_index,self.sub_index,self.call_back)
end
end
function TaskVerTabSubBtn:SetSelected( isSelect,force_fire_event)
isSelect = isSelect == nil and -1 or isSelect
if self.is_loaded then
if isSelect ~= -1 then
self.select_flag:SetActive(isSelect)
if force_fire_event and isSelect then
if self.call_back then
self.call_back(self.parent_index, self.sub_index,self.data)
end
end
end
self.is_show_select = -1
self.force_fire_event = -1
else
self.is_show_select = isSelect
self.force_fire_event = force_fire_event
end
end
function TaskVerTabSubBtn:ShowRedDot(bool)
bool = bool == nil and -1 or bool
if self.is_loaded then
if bool ~= -1 then
self.dot:SetActive(bool)
end
self.is_show_dot = -1
else
self.is_show_dot = bool
end
end
function TaskVerTabSubBtn:SetData(data, parent_index, sub_index, call_back)
self.parent_index = parent_index
self.sub_index = sub_index
self.call_back = call_back
self.data = data
if self.is_loaded then
self.need_refreshData = false
self.content_txt.text = Trim(self.data.taskName)
if self.is_show_dot ~= -1 then
self:ShowRedDot(self.is_show_dot)
end
if self.is_show_select ~= -1 then
self:SetSelected(self.is_show_select,self.force_fire_event)
end
if self.data.type == TaskType.EXTENSION_LINE and self.data.acceptType == 0 and self.model:IsTaskProgressFinish(self.data) then --已接任务
self.status_flag:SetActive(true)
lua_resM:setImageSprite(self, self.status_img, "task_asset", "zxui_wc")
elseif self.data.acceptType == 0 and not self.model:IsTaskProgressFinish(self.data) then
self.status_flag:SetActive(true)
lua_resM:setImageSprite(self, self.status_img, "task_asset", "zxui_jx")
else
self.status_flag:SetActive(false)
end
else
self.need_refreshData = true
end
end
function TaskVerTabSubBtn:SetTabSubBtnSize(width)
end
function TaskVerTabSubBtn:__delete( )
if self.event_id then
self.model:UnBind(self.event_id)
self.event_id = nil
end
end