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

179 lines
5.3 KiB

преди 1 месец
  1. DualGemstoneTips = DualGemstoneTips or BaseClass(BaseView)
  2. local DualGemstoneTips = DualGemstoneTips
  3. function DualGemstoneTips:__init()
  4. self.base_file = "common"
  5. self.layout_file = "goodsTooltips"
  6. self.layer_name = "Top"
  7. self.is_set_zdepth = true
  8. self.use_background = true
  9. self.click_bg_toClose = true
  10. self.hide_maincancas = false
  11. self.pos_x = 0
  12. self.pos_y = 0
  13. self.goods_vo = nil
  14. self.is_show_btn = nil
  15. self.model = GoodsModel:getInstance()
  16. self.mainVo = RoleManager.Instance.mainRoleInfo
  17. -- self.use_local_view = true
  18. self.curr_height = 0
  19. self.load_callback = function ()
  20. self:LoadSuccess()
  21. end
  22. self.open_callback = function ()
  23. self:SetData()
  24. end
  25. self.close_callback = function ()
  26. end
  27. self.destroy_callback = function ()
  28. if self.icon_item then
  29. self.icon_item:DeleteMe()
  30. end
  31. if self.event_odc then
  32. GlobalEventSystem:UnBind(self.event_odc)
  33. self.event_odc = nil
  34. end
  35. end
  36. end
  37. function DualGemstoneTips:LoadSuccess()
  38. self.layout,
  39. self.bg,
  40. self.icon_con,
  41. self.btns_con
  42. = self:GetChildTransforms({
  43. "layout",
  44. "layout/bg",
  45. "layout/icon_con",
  46. "layout/btns_con"
  47. })
  48. self.nameText,
  49. self.countText,
  50. self.levelText,
  51. self.contentText
  52. = self:GetChildTexts({
  53. "layout/nameText",
  54. "layout/countText",
  55. "layout/levelText",
  56. "layout/contentText",
  57. })
  58. self.btns_con.gameObject:SetActive(false)
  59. self.icon_item = AwardItem.New(self.icon_con, false, self.layer_name)
  60. self.icon_item:ChangeCountVisible(false)
  61. self:InitEvent()
  62. end
  63. function DualGemstoneTips:InitEvent()
  64. self.event_odc = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, function ()
  65. self:AdjustLayoutPos()
  66. end)
  67. end
  68. function DualGemstoneTips:Open(type_id, x, y, goods_vo)
  69. self.type_id = type_id
  70. self.goods_vo = goods_vo
  71. self.pos_x = x
  72. self.pos_y = y
  73. BaseView.Open(self)
  74. end
  75. function DualGemstoneTips:SetData()
  76. self.layout.gameObject:SetActive(true)
  77. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id)
  78. local a_stone, b_stone
  79. if self.goods_vo then
  80. a_stone = self.goods_vo.a_stone
  81. b_stone = self.goods_vo.b_stone
  82. else
  83. for _, goods_id in pairs(ComposeModel.Instance.add_goods_list) do
  84. local info = GoodsModel:getInstance():GetBagGoodsInfoById(goods_id)
  85. if not a_stone then
  86. a_stone = info.type_id
  87. elseif not b_stone then
  88. b_stone = info.type_id
  89. end
  90. end
  91. end
  92. self.icon_item:SetData(self.type_id)
  93. self.countText.text = "<color=#9e6d4b>类型:</color><color=#6e4737>" .. WordManager:GetGoodsTypeStr(basic.type, base.subtype) .. "</color>"
  94. local name = Trim(basic.goods_name)
  95. local level = 0
  96. if self.goods_vo then
  97. level = self.goods_vo.dstone_lv
  98. else
  99. if a_stone and Config.Equipstonelv[a_stone] then
  100. level = level + Config.Equipstonelv[a_stone].lv
  101. end
  102. if b_stone and Config.Equipstonelv[b_stone] then
  103. level = level + Config.Equipstonelv[b_stone].lv
  104. end
  105. end
  106. if level ~= 0 then
  107. name = level..""..name
  108. end
  109. self.nameText.text = Language.substitute("<color={0}>{1}</color>", WordManager.GetGoodsColor(basic.color), Trim(name))
  110. if basic.level > 0 then
  111. local str = "#6e4737"
  112. if self.mainVo.level < basic.level then
  113. str = "#f14041"
  114. end
  115. self.levelText.text = "<color=#9e6d4b>等级:</color><color="..str..">" .. basic.level .. "</color>"
  116. else
  117. self.levelText.text = ""
  118. end
  119. local contentStr = Trim(basic.intro)
  120. local str = ""
  121. if a_stone then
  122. local attr = JewelModel:getInstance():GetJewelAttr(a_stone)
  123. str = Language.substitute("<color={0}>{1}</color>", "#f18310", Trim(attr))
  124. contentStr = contentStr.."\n\n"..str
  125. end
  126. if b_stone then
  127. local attr = JewelModel:getInstance():GetJewelAttr(b_stone)
  128. str = Language.substitute("<color={0}>{1}</color>", "#f18310", Trim(attr))
  129. contentStr = contentStr.."\n"..str
  130. end
  131. local stage = self.goods_vo and self.goods_vo.stage or 1
  132. local cfg = Config.Doubleattrgemstage[basic.subtype.."@"..stage]
  133. if cfg then
  134. contentStr = contentStr.."\n"..Trim(cfg.tips)
  135. end
  136. self.contentText.text = contentStr
  137. local h = 175 + self.contentText.preferredHeight + 30
  138. self.bg.sizeDelta = Vector2(385, h)
  139. self:AdjustLayoutPos()
  140. end
  141. function DualGemstoneTips:AdjustLayoutPos()
  142. if self.pos_x and self.pos_y then
  143. --自定义显示的按钮
  144. local layout_width = self.bg.sizeDelta.x + self.btns_con.sizeDelta.x
  145. local layout_height = self.bg.sizeDelta.y
  146. local x, y = ScreenToViewportPoint(self.pos_x, self.pos_y)
  147. local iphone_x_offset = math.max(ClientConfig.iphone_x_offset_left, ClientConfig.iphone_x_offset_right)
  148. if x + layout_width + 50 + iphone_x_offset * 2 > SrcScreenWidth then
  149. x = SrcScreenWidth - layout_width - 90 - iphone_x_offset * 2
  150. end
  151. if y < layout_height + 50 then
  152. y = layout_height + 50
  153. end
  154. self.layout.anchoredPosition = Vector2(x, y)
  155. end
  156. end