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

113 行
3.0 KiB

  1. CSMainExploitRankTab = CSMainExploitRankTab or BaseClass(BaseItem)
  2. local CSMainExploitRankTab = CSMainExploitRankTab
  3. function CSMainExploitRankTab:__init()
  4. self.base_file = "csMain"
  5. self.layout_file = "CSMainExploitRankTab"
  6. self.model = CSMainModel:getInstance()
  7. self:Load()
  8. end
  9. function CSMainExploitRankTab:Load_callback()
  10. self.nodes = {
  11. "bg:obj", "select:obj", "red:obj", "tabName:tmp", "countryFlag:obj",
  12. }
  13. self:GetChildren(self.nodes)
  14. self:AddEvents()
  15. if self.need_refreshData then
  16. self:UpdateView()
  17. end
  18. if self.need_reclick then
  19. self:OnClick(self.click_index)
  20. end
  21. end
  22. function CSMainExploitRankTab:AddEvents( )
  23. local on_click = function ( click_obj )
  24. if self.gameObject == click_obj then
  25. if self.in_select then return end
  26. self.model:Fire(CSMainConst.ON_CLICK_CONTRAY_TAB,self.index)
  27. end
  28. end
  29. AddClickEvent(self.gameObject, on_click)
  30. --事件绑定:点击自身item处理
  31. local click_func = function(id)
  32. self:OnClick(id)
  33. end
  34. self:BindEvent(self.model, CSMainConst.ON_CLICK_CONTRAY_TAB, click_func)
  35. local function update_red_dot(tab_id)
  36. if not self.is_loaded then return end
  37. if tab_id == CSMainConst.RedType.WorShip then
  38. self:RefreshRed()
  39. end
  40. end
  41. self:BindEvent(self.model, CSMainConst.ANS_UPDATE_RED_DOT, update_red_dot)
  42. end
  43. function CSMainExploitRankTab:RefreshRed( )
  44. local my_country_id = KfWorldModel:GetInstance():GetMyCountryId()
  45. if self.data and my_country_id and self.data.contray_id == my_country_id then
  46. local red = self.model:GetWorShipRed()
  47. self.red_obj:SetActive(red)
  48. else
  49. self.red_obj:SetActive(false)
  50. end
  51. end
  52. function CSMainExploitRankTab:UpdateView( )
  53. local my_country_id = KfWorldModel:GetInstance():GetMyCountryId()
  54. if my_country_id and self.data.contray_id == my_country_id then
  55. self.countryFlag_obj:SetActive(true)
  56. else
  57. self.countryFlag_obj:SetActive(false)
  58. end
  59. self.tabName_tmp.text = self.data.name
  60. self:RefreshRed()
  61. end
  62. function CSMainExploitRankTab:OnClick(click_index)
  63. self.click_index = click_index
  64. if self.is_loaded then
  65. self.need_reclick = false
  66. if self.click_index == self.index then
  67. self.in_select = true
  68. self.bg_obj:SetActive(false)
  69. self.select_obj:SetActive(true)
  70. self.tabName_tmp.color = ColorUtil:ConvertHexToRGBColor("ffffff")
  71. SetTMPSharedMaterial(self.tabName_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab)
  72. if self.call_back then
  73. self.call_back(self.index,self.data.contray_id)
  74. end
  75. else
  76. self.in_select = false
  77. self.bg_obj:SetActive(true)
  78. self.select_obj:SetActive(false)
  79. self.tabName_tmp.color = ColorUtil:ConvertHexToRGBColor("7d91ac")
  80. SetTMPSharedMaterial(self.tabName_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
  81. end
  82. else
  83. self.need_reclick = true
  84. end
  85. end
  86. function CSMainExploitRankTab:SetData( data,index,call_back)
  87. self.data = data
  88. self.index = index
  89. self.call_back = call_back
  90. if self.is_loaded then
  91. self.need_refreshData = false
  92. self:UpdateView()
  93. else
  94. self.need_refreshData = true
  95. end
  96. end
  97. function CSMainExploitRankTab:__delete( )
  98. end