KLShapeShiftCardTipsPanel.lua 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. ---@class KLShapeShiftCardTipsPanel:UIKmlLuaPanelBase
  2. ---@field view KLShapeShiftCardTipsPanelView
  3. local KLShapeShiftCardTipsPanel = class(UIKmlLuaPanelBase)
  4. local this = KLShapeShiftCardTipsPanel
  5. function this:AsyncLoadUI()
  6. end
  7. ---创建时调用一次
  8. function this:Init()
  9. GUI:DataListInitData(self.view.all_info_data,
  10. function()
  11. return self:EquipAttrDataListItemCountFunc()
  12. end,
  13. nil,
  14. nil,
  15. function(realIndex, kmlcontrol)
  16. return self:EquipAttrDataListItemUpdateFunc(realIndex, kmlcontrol)
  17. end)
  18. self.qualityText = { "蓝色", "金色", "红色" }
  19. self.subTypeText = { "变身泰坦卡牌", "赋能泰坦卡牌", "神赋泰坦卡牌" }
  20. end
  21. function this:EquipAttrDataListItemCountFunc()
  22. return #self.all_info
  23. end
  24. function this:EquipAttrDataListItemUpdateFunc(realIndex)
  25. local data = self.all_info[realIndex + 1]
  26. local root = GUI:GetChildControl(self.view.all_info_data, realIndex, "root")
  27. local title = GUI:GetChildControl(self.view.all_info_data, realIndex, "title")
  28. local di = GUI:GetChildControl(self.view.all_info_data, realIndex, "di")
  29. local value = GUI:GetChildControl(self.view.all_info_data, realIndex, "value")
  30. local desc = GUI:GetChildControl(self.view.all_info_data, realIndex, "desc")
  31. local lock = GUI:GetChildControl(self.view.all_info_data, realIndex, "lock")
  32. local upgrade = GUI:GetChildControl(self.view.all_info_data, realIndex, "upgrade")
  33. if data.title then
  34. GUI:setContentSize(root, 350, 25)
  35. GUI:setVisible(title, true)
  36. GUI:setVisible(di, true)
  37. GUI:setVisible(value, false)
  38. GUI:setVisible(desc, false)
  39. GUI:setVisible(lock, false)
  40. GUI:setVisible(upgrade, false)
  41. self.panelHeight = self.panelHeight + 31
  42. GUI:Image_loadTexture(title, data.title, "Atlas/TipsAttTitle.spriteatlas")
  43. elseif data.icon then
  44. GUI:setContentSize(root, 350, 60)
  45. if data.atlas then
  46. GUI:Image_loadTexture(title, data.icon, data.atlas)
  47. else
  48. GUI:Image_loadTexture(title, data.icon, "Atlas/UIOutSkillIcon.spriteatlas")
  49. end
  50. GUI:setContentSize(title, 50, 50)
  51. GUI:setVisible(title, true)
  52. GUI:setVisible(di, false)
  53. GUI:setVisible(value, false)
  54. GUI:setVisible(desc, true)
  55. GUI:setVisible(lock, data.lock)
  56. GUI:setVisible(upgrade, data.upgrade)
  57. GUI:Text_setString(desc, data.tips)
  58. self.panelHeight = self.panelHeight + 66
  59. else
  60. GUI:setContentSize(root, 350, 16)
  61. GUI:setVisible(title, false)
  62. GUI:setVisible(di, false)
  63. GUI:setVisible(value, true)
  64. GUI:setVisible(desc, false)
  65. GUI:setVisible(lock, false)
  66. GUI:setVisible(upgrade, false)
  67. local value_str
  68. if data.value2 then
  69. value_str = data.name .. " " .. data.value .. "~" .. data.value2
  70. else
  71. value_str = data.name .. " " .. data.value
  72. end
  73. GUI:Text_setString(value, value_str)
  74. local color = "#DCE1E5"
  75. if data.color then
  76. local strColor = SL:GetColorCfg(data.color)
  77. if strColor then
  78. color = strColor. color
  79. end
  80. end
  81. GUI:Text_setTextColor(value, color)
  82. if data.special then
  83. GUI:setVisible(title, true)
  84. GUI:setPosition(title, 21, 2)
  85. GUI:Image_loadTexture(title, "ty_icon_arrow_small", "Atlas/TS_Common.spriteatlas")
  86. end
  87. self.panelHeight = self.panelHeight + 22
  88. end
  89. end
  90. ---注册UI事件和服务器消息
  91. function this:RegistEvents()
  92. GUI:AddOnClickEvent(self.view.img_close, self, self.CloseSelf)
  93. GUI:AddOnClickEvent(self.view.btn_func, self, self.OnClickFuncBtn)
  94. end
  95. ---界面显示时调用一次
  96. function this:Show()
  97. end
  98. ---创建或者刷新界面数据时调用
  99. function this:Refresh()
  100. self.all_info = {}
  101. self.cardInfo = self.args.cardInfo
  102. ---@type cfg_item_column
  103. self.item_tbl = SL:GetConfig("cfg_item", self.cardInfo.cfgid)
  104. ---@type cfg_card_shapeshift_column
  105. self.card_tbl = SL:GetConfig("cfg_card_shapeshift", self.cardInfo.cfgid)
  106. GUI:Image_loadTexture(self.view.card_bg, "card_quality_" .. self.card_tbl.quality, "Atlas/KLShapeShiftCard.spriteatlas")
  107. GUI:Image_loadTexture(self.view.card_level, "num_quality_" .. self.card_tbl.quality .. "_" .. self.card_tbl.level, "Atlas/KLShapeShiftCard.spriteatlas")
  108. GUI:Image_loadTexture(self.view.card_img, self.card_tbl.img, "Atlas/KLShapeShiftCard.spriteatlas")
  109. if #self.card_tbl.position > 0 then
  110. GUI:setPosition(self.view.card_img, self.card_tbl.position[1], self.card_tbl.position[2])
  111. else
  112. GUI:setPosition(self.view.card_img, 0, 0)
  113. end
  114. if self.card_tbl.scale ~= 0 then
  115. GUI:setScale(self.view.card_img, self.card_tbl.scale)
  116. else
  117. GUI:setScale(self.view.card_img, 1)
  118. end
  119. GUI:Text_setString(self.view.card_name, self.item_tbl.name)
  120. GUI:Text_setTextColor(self.view.card_name, tostring(self.item_tbl.color))
  121. GUI:Text_setString(self.view.text_name, self.item_tbl.name)
  122. GUI:Text_setTextColor(self.view.text_name, tostring(self.item_tbl.color))
  123. GUI:Text_setString(self.view.text_tips, "不可交易")
  124. GUI:Text_setString(self.view.text_quality, "品质:" .. self.qualityText[self.card_tbl.quality])
  125. GUI:Text_setString(self.view.text_type, "泰坦类型:" .. self.subTypeText[self.item_tbl.subType])
  126. GUI:Text_setString(self.view.text_level, "等级:" .. self.card_tbl.level)
  127. self:RefreshAttrItem()
  128. self:RefreshSkillItem()
  129. self:RefreshNextUnLockAttr()
  130. self.panelHeight = 0
  131. GUI:DataListUpdateData(self.view.all_info_data, nil, function()
  132. if self.panelHeight >= 300 then
  133. self.panelHeight = 300
  134. end
  135. GUI:setContentSize(self.view.info_view, 360, self.panelHeight)
  136. GUI:setContentSize(self.view.img_panel, 380, 300 + self.panelHeight)
  137. GUI:setVisible(self.view.img_panel, true)
  138. end)
  139. if self.args.type then
  140. GUI:setVisible(self.view.btn_func, true)
  141. if self.args.type == E_ShapeShiftCardFuncType.UnInlay then
  142. GUI:Button_setTitleText(self.view.btn_func, "卸下")
  143. elseif self.args.type == E_ShapeShiftCardFuncType.Inlay then
  144. GUI:Button_setTitleText(self.view.btn_func, "镶嵌")
  145. elseif self.args.type == E_ShapeShiftCardFuncType.Synthesis then
  146. if self.args.select then
  147. GUI:Button_setTitleText(self.view.btn_func, "卸下")
  148. else
  149. GUI:Button_setTitleText(self.view.btn_func, "合成")
  150. end
  151. elseif self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then
  152. GUI:Button_setTitleText(self.view.btn_func, "卸下")
  153. elseif self.args.type == E_ShapeShiftCardFuncType.Break then
  154. if self.args.select then
  155. GUI:Button_setTitleText(self.view.btn_func, "卸下")
  156. else
  157. GUI:Button_setTitleText(self.view.btn_func, "突破")
  158. end
  159. elseif self.args.type == E_ShapeShiftCardFuncType.UnBreak then
  160. GUI:Button_setTitleText(self.view.btn_func, "卸下")
  161. else
  162. GUI:setVisible(self.view.btn_func, false)
  163. end
  164. else
  165. GUI:setVisible(self.view.btn_func, false)
  166. end
  167. end
  168. function this:RefreshAttrItem()
  169. self.all_info[#self.all_info + 1] = { title = "tips_attribute1" }
  170. local specialIndex
  171. for _, v in pairs(self.card_tbl.attribute) do
  172. local preValue
  173. local tbl = SL:GetConfig("cfg_att_info", tonumber(v[1]))
  174. local attrName = tbl.name
  175. local att_remark = tbl.remarks
  176. if att_remark == 1 then
  177. preValue = v[2]
  178. else
  179. preValue = tonumber(v[2]) / 100 .. '%'
  180. end
  181. if v[1] == 201021 then
  182. if specialIndex then
  183. self.all_info[specialIndex].value = preValue
  184. else
  185. specialIndex = #self.all_info + 1
  186. self.all_info[specialIndex] = { name = "攻击力" .. ":", value = preValue }
  187. end
  188. elseif v[1] == 201011 then
  189. if specialIndex then
  190. self.all_info[specialIndex].value2 = preValue
  191. else
  192. specialIndex = #self.all_info + 1
  193. self.all_info[specialIndex] = { name = "攻击力" .. ":", value2 = preValue }
  194. end
  195. else
  196. self.all_info[#self.all_info + 1] = { name = attrName .. ":", value = preValue }
  197. end
  198. end
  199. if self.cardInfo.entry and table.count(self.cardInfo.entry) > 0 then
  200. self.all_info[#self.all_info + 1] = { title = "tips_attribute24" }
  201. local attrTbl = {}
  202. for _, v in pairs(self.cardInfo.entry) do
  203. local info = {}
  204. ---@type cfg_att_info_column
  205. local tbl = SL:GetConfig("cfg_att_info", tonumber(v.attrid))
  206. info.attrName = tbl.name
  207. info.sort = tbl.sort
  208. if tbl.remarks == 1 then
  209. info.preValue = v.attrvalue
  210. else
  211. info.preValue = tonumber(v.attrvalue) / 100 .. '%'
  212. end
  213. ---@type cfg_card_att_column
  214. local tbl_2 = SL:GetConfig("cfg_card_att", tonumber(v.entryid))
  215. if tbl_2 then
  216. info.color = tbl_2.color
  217. end
  218. attrTbl[#attrTbl + 1] = info
  219. end
  220. table.sort(attrTbl, function(a, b)
  221. return a.sort < b.sort
  222. end)
  223. for i, v in ipairs(attrTbl) do
  224. self.all_info[#self.all_info + 1] = { name = v.attrName .. ":", value = v.preValue, color = v.color }
  225. end
  226. end
  227. end
  228. function this:RefreshSkillItem()
  229. if self.card_tbl.skill and next(self.card_tbl.skill) then
  230. self.all_info[#self.all_info + 1] = { title = "tips_attribute22" }
  231. ---@type cfg_monster_column
  232. local monster = SL:GetConfig("cfg_monster", self.card_tbl.model)
  233. local text = "变身为" .. self.card_tbl.name .. ", 持续变身时间" .. math.floor(self.card_tbl.time / 1000) .. "秒, 冷却时间" .. math.floor(self.card_tbl.cd / 1000) .. "秒"
  234. self.all_info[#self.all_info + 1] = { icon = monster.icon, tips = text, atlas = "Atlas/UIbianshentb.spriteatlas" }
  235. local allSkill = InfoManager.shapeShiftCardInfo:GetAllCardSkillByGroup(self.card_tbl.group, self.card_tbl.level)
  236. local skillList = {}
  237. for i, v in pairs(allSkill) do
  238. skillList[#skillList + 1] = v
  239. end
  240. table.sort(skillList, function(a, b)
  241. return a.cardLevel < b.cardLevel
  242. end)
  243. for _, v in pairs(skillList) do
  244. ---@type cfg_skill_info_column
  245. self.all_info[#self.all_info + 1] = { icon = v.icon, tips = v.tips, lock = v.lock, upgrade = v.upgrade }
  246. end
  247. end
  248. end
  249. function this:RefreshNextUnLockAttr()
  250. local level = self.card_tbl.level
  251. local info, eachLevel = InfoManager.shapeShiftCardInfo:GetNextLevelUnLockAttr(self.card_tbl.group, self.card_tbl.level)
  252. if info and #info > 0 then
  253. local isShow = false
  254. if eachLevel then
  255. self.all_info[#self.all_info + 1] = { title = "tips_attribute25" }
  256. self.all_info[#self.all_info + 1] = { name = "Lv ", value = "随机解锁新赋能", special = true }
  257. isShow = true
  258. end
  259. for i, v in ipairs(info) do
  260. if v and v.special and v.special >= 1 then
  261. if not isShow then
  262. self.all_info[#self.all_info + 1] = { title = "tips_attribute25" }
  263. isShow = true
  264. end
  265. self.all_info[#self.all_info + 1] = { name = "Lv" .. level + i, value = "额外解锁新赋能" }
  266. end
  267. end
  268. end
  269. end
  270. function this:OnClickFuncBtn()
  271. if self.args.type == E_ShapeShiftCardFuncType.Inlay then
  272. if self.args.index > 0 then
  273. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TRANSFER_CARD_INLAY, { self.args.part, self.args.index, self.cardInfo.id })
  274. else
  275. SL:TipMessage("当前无法镶嵌卡牌",1, NoticeType.NoticeMid)
  276. end
  277. elseif self.args.type == E_ShapeShiftCardFuncType.UnInlay then
  278. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TRANSFER_CARD_PUTOFF, { self.args.part, self.args.index })
  279. elseif self.args.type == E_ShapeShiftCardFuncType.Synthesis then
  280. ---@type KLShapeShiftCardSynthesisPanel
  281. local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardSynthesis/KLShapeShiftCardSynthesisPanel")
  282. if panel then
  283. if panel.synthesisIsShow then
  284. if not self.args.select then
  285. local result = panel:SetSynthesisInfo(self.cardInfo, true)
  286. if result then
  287. SL:TipMessage(SL:GetConfig('cfg_string', 20007).text, 1, NoticeType.NoticeMid)
  288. end
  289. else
  290. panel:SetSynthesisInfo(self.cardInfo, false)
  291. end
  292. else
  293. panel:RefreshSynthesisPanel()
  294. panel:SetSynthesisInfo(self.cardInfo, true)
  295. end
  296. end
  297. elseif self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then
  298. ---@type KLShapeShiftCardSynthesisPanel
  299. local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardSynthesis/KLShapeShiftCardSynthesisPanel")
  300. if panel then
  301. if panel.synthesisIsShow then
  302. panel:SetSynthesisInfo(self.cardInfo, false)
  303. end
  304. end
  305. elseif self.args.type == E_ShapeShiftCardFuncType.Break then
  306. ---@type KLShapeShiftCardBreakPanel
  307. local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardBreak/KLShapeShiftCardBreakPanel")
  308. if panel then
  309. if panel.breakIsShow then
  310. if not self.args.select then
  311. local result = panel:SetBreakInfo(self.cardInfo, true)
  312. if result then
  313. SL:TipMessage(SL:GetConfig('cfg_string', 20007).text, 1, NoticeType.NoticeMid)
  314. end
  315. else
  316. panel:SetBreakInfo(self.cardInfo, false)
  317. end
  318. else
  319. panel:RefreshBreakPanel()
  320. panel:SetBreakInfo(self.cardInfo, true)
  321. end
  322. end
  323. elseif self.args.type == E_ShapeShiftCardFuncType.UnBreak then
  324. ---@type KLShapeShiftCardBreakPanel
  325. local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardBreak/KLShapeShiftCardBreakPanel")
  326. if panel then
  327. if panel.breakIsShow then
  328. panel:SetBreakInfo(self.cardInfo, false)
  329. end
  330. end
  331. end
  332. self:CloseSelf()
  333. end
  334. function this:CloseSelf()
  335. GUI:UIPanel_Close("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardTips/KLShapeShiftCardTipsPanel")
  336. end
  337. function this:Close()
  338. end
  339. return this