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

96 行
2.7 KiB

  1. CSMainExploitRankDailyRewardItem = CSMainExploitRankDailyRewardItem or BaseClass(BaseItem)
  2. local CSMainExploitRankDailyRewardItem = CSMainExploitRankDailyRewardItem
  3. function CSMainExploitRankDailyRewardItem:__init()
  4. self.base_file = "csMain"
  5. self.layout_file = "CSMainExploitRankDailyRewardItem"
  6. self.model = CSMainModel:getInstance()
  7. self:Load()
  8. end
  9. function CSMainExploitRankDailyRewardItem:Load_callback()
  10. self.nodes = {
  11. "des:tmp",
  12. "ScrollView/Viewport/Content", "ScrollView",
  13. "getBtn:obj:img", "getBtn/red:obj", "getBtn/Text:tmp",
  14. }
  15. self:GetChildren(self.nodes)
  16. self:AddEvents()
  17. if self.need_refreshData then
  18. self:UpdateView()
  19. end
  20. end
  21. function CSMainExploitRankDailyRewardItem:AddEvents( )
  22. local on_click = function ( click_obj )
  23. if self.getBtn_obj == click_obj then
  24. if self.data.is_top == 1 then
  25. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60310)
  26. else
  27. Message.show("不可领取")
  28. end
  29. end
  30. end
  31. AddClickEvent(self.getBtn_obj, on_click)
  32. end
  33. function CSMainExploitRankDailyRewardItem:UpdateView( )
  34. if self.data.min_rank == self.data.max_rank then
  35. self.des_tmp.text = string.format("排名 <#fdffc2>%s</color> 奖励",self.data.min_rank)
  36. elseif self.data.min_rank == self.model.exploit_can_get_reward_rank then
  37. self.des_tmp.text = string.format("排名 <#fdffc2>%s</color> 后奖励",self.data.min_rank)
  38. else
  39. self.des_tmp.text = string.format("排名 <#fdffc2>%s-%s</color> 奖励",self.data.min_rank,self.data.max_rank)
  40. end
  41. if self.data.is_top == 1 then
  42. SetImageGray(self.getBtn_img,false)
  43. self.red_obj:SetActive(true)
  44. SetTMPSharedMaterial(self.Text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
  45. else
  46. SetImageGray(self.getBtn_img,true)
  47. self.red_obj:SetActive(false)
  48. SetTMPSharedMaterial(self.Text_tmp, ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn)
  49. end
  50. self.getBtn_obj:SetActive(true)
  51. local reward_cfg = stringtotable(self.data.awards)
  52. if not self.item_list_com then
  53. self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
  54. end
  55. local info = {
  56. data_list = reward_cfg,
  57. item_con = self.Content,
  58. obj_pool_type = UIObjPool.UIType.AwardItem,
  59. item_width = 62,
  60. space_x = 7,
  61. -- space_y = 0,
  62. start_x = 5,
  63. start_y = -5,
  64. scroll_view = self.ScrollView,
  65. create_frequency = 0.01,
  66. on_update_item = function(item, i, v)
  67. item:SetItemSize(62, 62)
  68. SetLocalScale(item.transform,0.7,0.7,0.7)
  69. item:SetData(v[2], v[3])
  70. end,
  71. }
  72. self.item_list_com:UpdateItems(info)
  73. end
  74. function CSMainExploitRankDailyRewardItem:SetData( data )
  75. self.data = data
  76. if self.is_loaded then
  77. self.need_refreshData = false
  78. self:UpdateView()
  79. else
  80. self.need_refreshData = true
  81. end
  82. end
  83. function CSMainExploitRankDailyRewardItem:__delete( )
  84. end