源战役客户端
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.

118 lines
3.0 KiB

  1. TaskVerTabSubBtn = TaskVerTabSubBtn or BaseClass(BaseItem)
  2. local TaskVerTabSubBtn =TaskVerTabSubBtn
  3. TaskVerTabSubBtn.Height = 73
  4. function TaskVerTabSubBtn:__init(parent_wnd,prefab_asset,layer_name)
  5. self.base_file = "task"
  6. self.layout_file = "TaskVerTabSubBtn"
  7. self.model = TaskModel:getInstance()
  8. self.is_show_select = -1
  9. self.is_show_dot = -1
  10. self.force_fire_event = -1
  11. self:Load()
  12. end
  13. function TaskVerTabSubBtn:Load_callback()
  14. self.content_txt = self:GetChild("Text"):GetComponent("Text")
  15. self.status_img = self:GetChild("Status"):GetComponent("Image")
  16. self.status_flag = self:GetChild("Status").gameObject
  17. self.click_btn,
  18. self.select_flag,
  19. self.dot = self:GetChildGameObjects({
  20. "ClickBtn",
  21. "Select",
  22. "Dot",
  23. })
  24. local function onClickHandler(target)
  25. if target == self.click_btn then
  26. if self.call_back then
  27. self.call_back(self.parent_index, self.sub_index,self.data)
  28. end
  29. end
  30. end
  31. AddClickEvent(self.click_btn,onClickHandler)
  32. if self.need_refreshData then
  33. self:SetData(self.data,self.parent_index,self.sub_index,self.call_back)
  34. end
  35. end
  36. function TaskVerTabSubBtn:SetSelected( isSelect,force_fire_event)
  37. isSelect = isSelect == nil and -1 or isSelect
  38. if self.is_loaded then
  39. if isSelect ~= -1 then
  40. self.select_flag:SetActive(isSelect)
  41. if force_fire_event and isSelect then
  42. if self.call_back then
  43. self.call_back(self.parent_index, self.sub_index,self.data)
  44. end
  45. end
  46. end
  47. self.is_show_select = -1
  48. self.force_fire_event = -1
  49. else
  50. self.is_show_select = isSelect
  51. self.force_fire_event = force_fire_event
  52. end
  53. end
  54. function TaskVerTabSubBtn:ShowRedDot(bool)
  55. bool = bool == nil and -1 or bool
  56. if self.is_loaded then
  57. if bool ~= -1 then
  58. self.dot:SetActive(bool)
  59. end
  60. self.is_show_dot = -1
  61. else
  62. self.is_show_dot = bool
  63. end
  64. end
  65. function TaskVerTabSubBtn:SetData(data, parent_index, sub_index, call_back)
  66. self.parent_index = parent_index
  67. self.sub_index = sub_index
  68. self.call_back = call_back
  69. self.data = data
  70. if self.is_loaded then
  71. self.need_refreshData = false
  72. self.content_txt.text = Trim(self.data.taskName)
  73. if self.is_show_dot ~= -1 then
  74. self:ShowRedDot(self.is_show_dot)
  75. end
  76. if self.is_show_select ~= -1 then
  77. self:SetSelected(self.is_show_select,self.force_fire_event)
  78. end
  79. if self.data.type == TaskType.EXTENSION_LINE and self.data.acceptType == 0 and self.model:IsTaskProgressFinish(self.data) then --已接任务
  80. self.status_flag:SetActive(true)
  81. lua_resM:setImageSprite(self, self.status_img, "task_asset", "zxui_wc")
  82. elseif self.data.acceptType == 0 and not self.model:IsTaskProgressFinish(self.data) then
  83. self.status_flag:SetActive(true)
  84. lua_resM:setImageSprite(self, self.status_img, "task_asset", "zxui_jx")
  85. else
  86. self.status_flag:SetActive(false)
  87. end
  88. else
  89. self.need_refreshData = true
  90. end
  91. end
  92. function TaskVerTabSubBtn:SetTabSubBtnSize(width)
  93. end
  94. function TaskVerTabSubBtn:__delete( )
  95. if self.event_id then
  96. self.model:UnBind(self.event_id)
  97. self.event_id = nil
  98. end
  99. end