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

151 lines
6.4 KiB

  1. PsionicToolTipsItem = PsionicToolTipsItem or BaseClass(BaseItem)
  2. local PsionicToolTipsItem = PsionicToolTipsItem
  3. local string_format = string.format
  4. function PsionicToolTipsItem:__init(parent_wnd,prefab_asset,layer_name)
  5. self.base_file = "common"
  6. self.layout_file = "PsionicToolTipsItem"
  7. self.parent_wnd = parent_wnd
  8. self.layer_name = layer_name
  9. self.model = PsionicModel:getInstance()
  10. self.awake_pro_imgs = {} -- 圣物觉醒进度表现
  11. self:Load()
  12. end
  13. function PsionicToolTipsItem:Load_callback()
  14. local nodes = {
  15. -- 标题
  16. "title:obj", "title/title_lb:tmp",
  17. "title/title_extra", "title/title_extra/title_extra_lb:tmp",
  18. -- 配置属性描述
  19. "attr_basic:obj",
  20. "attr_basic/attr_basic_lb:tmp",
  21. "attr_basic/attr_arrow:obj:img", "attr_basic/attr_basic_dif:tmp",
  22. -- 洗练属性描述
  23. "attr_wash:obj", "attr_wash/wash_icon:imgex",
  24. "attr_wash/attr_wash_lb:tmp",
  25. -- 装备技能描述
  26. "attr_break:obj",
  27. "attr_break/attr_break_lb:tmp",
  28. }
  29. self:GetChildren(nodes)
  30. self:AddEvents()
  31. if self.need_refreshData then
  32. self:UpdateView()
  33. end
  34. end
  35. function PsionicToolTipsItem:AddEvents( )
  36. end
  37. function PsionicToolTipsItem:UpdateView( )
  38. local height = 0
  39. -- 初始化节点
  40. self:InitCons()
  41. if self.data.title then -- 标题
  42. self.title_obj:SetActive(true)
  43. self.title_lb_tmp.text = self.data.title
  44. local ex_data = self.data.title_extra
  45. if ex_data then -- 有标题额外参数
  46. local awake_req = PsionicConst.RequireEquipColor[PsionicConst.TabId.PSkill] -- 品质需求前端配置
  47. self.title_extra_lb_tmp.text = ex_data.equip_color < awake_req.color
  48. and string_format("<color=%s>橙品圣物可激活</color>", ColorUtil.RED_DARK)
  49. or (ex_data.has_weared and ex_data.has_weared.color >= awake_req.color
  50. and string_format("<color=#fdffc2>%s段</color>", ChineseNumber(ex_data.awake_lv))
  51. or string_format("<color=%s>穿戴可激活</color>", ColorUtil.RED_DARK))
  52. -- 觉醒需要有进度表现
  53. if ex_data.equip_color >= awake_req.color and ex_data.has_weared and ex_data.has_weared.color >= awake_req.color then
  54. for i = 1, 6 do
  55. self.awake_pro_imgs[i] = self.awake_pro_imgs[i] or UiFactory.createChild(self.title_extra, UIType.Image, "pro" .. i)
  56. SetAnchoredPosition(self.awake_pro_imgs[i].transform, (i-3) * 12 + 25, 0)
  57. lua_resM:setImageSprite(self, self.awake_pro_imgs[i]:GetComponent("Image"), "common_asset",
  58. i <= ex_data.awake_lv and "ps_skill_pro1" or "ps_skill_pro0", true)
  59. end
  60. end
  61. else
  62. self.title_extra_lb_tmp.text = ""
  63. end
  64. height = 28
  65. elseif self.data.attr_basic then -- 基础属性
  66. self.attr_basic_obj:SetActive(true)
  67. local attr_type = WordManager:GetProperties(self.data.attr_basic[1])
  68. -- 属性值要加上槽位等级带来的等级提升属性量
  69. local attr_val = WordManager:GetPropertyValue(self.data.attr_basic[1], self.data.attr_basic[2] + self.data.add_attr * self.data.slot_lv)
  70. self.attr_basic_lb_tmp.text = attr_type .. " " .. string_format("<color=%s>+%s</color>", ColorUtil.GREEN_DARK, attr_val)
  71. if self.data.show_diff then -- 有展示属性差距的要求,传入的内容是对比的属性值
  72. self.attr_basic_dif_tmp.text = self.data.show_diff ~= 0 and
  73. string_format("<color=%s>%s</color>",
  74. self.data.show_diff > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
  75. WordManager:GetPropertyValue(self.data.attr_basic[1], math.abs(self.data.show_diff)))
  76. or ""
  77. lua_resM:setImageSprite(self, self.attr_arrow_img, "common_asset", self.data.show_diff > 0 and "tyui_Arrow_3" or "tyui_Arrow_4")
  78. self.attr_arrow_obj:SetActive(self.data.show_diff ~= 0)
  79. -- 移动箭头位置
  80. if self.data.show_diff ~= 0 then
  81. SetAnchoredPositionX(self.attr_arrow, self.attr_basic_lb.anchoredPosition.x + self.attr_basic_lb_tmp.preferredWidth + 8)
  82. SetAnchoredPositionX(self.attr_basic_dif, self.attr_arrow.anchoredPosition.x + 25)
  83. end
  84. else
  85. self.attr_basic_dif_tmp.text = ""
  86. self.attr_arrow_obj:SetActive(false)
  87. end
  88. height = 24 + (self.data.is_last and 7 or 0)
  89. elseif self.data.attr_wash then -- 洗练属性
  90. self.attr_wash_obj:SetActive(true)
  91. local attr_type = self.data.attr_wash[1]
  92. local attr_max_val = self.data.attr_wash[2]
  93. self.attr_wash_lb_tmp.text = string_format("%s <color=%s>+%s</color> / %s",
  94. WordManager:GetProperties(attr_type),
  95. ColorUtil.GREEN_DARK,
  96. self.data.cur_val,
  97. WordManager:GetPropertyValue(attr_type, attr_max_val))
  98. -- 洗练属性满了才显示左侧小点
  99. self.wash_icon_imgex.enabled = self.data.cur_val >= attr_max_val
  100. height = 24 + (self.data.is_last and 7 or 0)
  101. elseif self.data.skill_data then -- 技能数据
  102. self.attr_break_obj:SetActive(true)
  103. local attr_type = self.data.skill_data[1]
  104. local attr_val = self.data.skill_data[2]
  105. self.attr_break_lb_tmp.text = string_format("%s <color=%s>+%s</color>",
  106. WordManager:GetProperties(attr_type),
  107. ColorUtil.GREEN_DARK,
  108. WordManager:GetPropertyValue(attr_type, attr_val))
  109. height = 24 + (self.data.is_last and 7 or 0)
  110. end
  111. return height
  112. end
  113. -- 初始化界面显示
  114. function PsionicToolTipsItem:InitCons( )
  115. if self.title_obj.activeSelf then
  116. self.title_obj:SetActive(false)
  117. end
  118. if self.attr_basic_obj.activeSelf then
  119. self.attr_basic_obj:SetActive(false)
  120. end
  121. if self.attr_wash_obj.activeSelf then
  122. self.attr_wash_obj:SetActive(false)
  123. end
  124. if self.attr_break_obj.activeSelf then
  125. self.attr_break_obj:SetActive(false)
  126. end
  127. end
  128. function PsionicToolTipsItem:SetData( data )
  129. local height = 0
  130. self.data = data
  131. if self.is_loaded then
  132. self.need_refreshData = false
  133. height = self:UpdateView()
  134. else
  135. self.need_refreshData = true
  136. end
  137. return height
  138. end
  139. function PsionicToolTipsItem:__delete( )
  140. end