KLGrailItem.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ---@class KLGrailItem:UIKmlLuaPanelBase
  2. ---@field view KLGrailItemView
  3. ---@field baseUI KLArchangelGrailPanel
  4. local KLGrailItem = class(UIKmlLuaPanelBase)
  5. local this = KLGrailItem
  6. ---创建时调用一次
  7. function this:Init()
  8. --self.isGray = self.args.isGray
  9. --self.itemCfgId = self.args and self.args.itemCfgId or nil
  10. --self.id = self.args and self.args.id or nil
  11. --self.holeIndex = self.args and self.args.holeIndex or -1
  12. end
  13. ---注册UI事件和服务器消息
  14. function this:RegistEvents()
  15. GUI:AddOnClickEvent(self.view.bg, self, self.SelectItem)
  16. GUI:AddOnClickEvent(self.view.xie_btn, self, self.Unload)
  17. SL:RegisterLUAEvent(LUA_EVENT_GRAIL_STRENGTH_SUCCESS_REFRESH_REDPOINT, self.RefreshRedPoint, self)
  18. end
  19. ---界面显示时调用一次
  20. function this:Show()
  21. --GUI:setVisible(self.view.select, false)
  22. end
  23. ---创建或者刷新界面数据时调用
  24. function this:Refresh()
  25. end
  26. function this:UpdateUI(data,isHideSelect)
  27. if isHideSelect then
  28. GUI:setVisible(self.view.select, false)
  29. end
  30. self.isGray = data.isGray
  31. self.itemCfgId = data.itemCfgId
  32. self.id = data.id
  33. self.holeIndex = data.holeIndex
  34. self:RefreshUI()
  35. end
  36. function this:RefreshUI()
  37. GUI:setVisible(self.view.img_red, false)
  38. GUI:Text_setString(self.view.add, "可融合" .. self.holeIndex .. "阶圣杯")
  39. if self.isGray then
  40. -- 置灰
  41. GUI:setVisible(self.view.gray, true)
  42. GUI:setVisible(self.view.xie_btn, false)
  43. GUI:setVisible(self.view.scroll_text_template, false)
  44. GUI:setVisible(self.view.add, false)
  45. return
  46. end
  47. GUI:setVisible(self.view.gray, false)
  48. if self.itemCfgId then
  49. GUI:setVisible(self.view.scroll_text_template, true)
  50. GUI:setVisible(self.view.add, false)
  51. local itemCfg = SL:GetConfig("cfg_item", self.itemCfgId, "id")
  52. GUI:SetOnPrefabControlLoaded(self.view.scroll_text_template, function()
  53. GUI:Text_setTextColor(self.view.txt_item_name, SL:GetConfig("cfg_color", tonumber(itemCfg.color), "id").color)
  54. GUI:Text_setString(self.view.txt_item_name, itemCfg.name)
  55. end)
  56. GUI:setVisible(self.view.xie_btn, true)
  57. self:RefreshRedPoint()
  58. else
  59. GUI:setVisible(self.view.xie_btn, false)
  60. GUI:setVisible(self.view.scroll_text_template, false)
  61. GUI:setVisible(self.view.add, true)
  62. local show = self.baseUI:GetGrailByHoleIndex(self.holeIndex)
  63. GUI:setVisible(self.view.img_red, show)
  64. end
  65. end
  66. function this:RefreshRedPoint()
  67. if self.holeIndex and self.itemCfgId then
  68. local isShow = self.baseUI:GetGrailItemShowRedPoint(self.holeIndex, self.itemCfgId)
  69. if isShow then
  70. isShow = self.baseUI:IsGrailEntryMax(self.holeIndex)
  71. isShow = not isShow
  72. end
  73. GUI:setVisible(self.view.img_red, isShow)
  74. end
  75. end
  76. function this:SelectItem()
  77. if self.isGray then
  78. SL:MessageTip({ id = 500 })
  79. return
  80. end
  81. self.baseUI:GrailSelect(self.holeIndex, self.itemCfgId, self.id)
  82. end
  83. function this:FusionPanel()
  84. if self.isGray then
  85. SL:MessageTip({ id = 500 })
  86. return
  87. end
  88. end
  89. function this:SelectItemUIChange(holeIndex)
  90. if holeIndex == self.holeIndex then
  91. GUI:setVisible(self.view.select, true)
  92. else
  93. GUI:setVisible(self.view.select, false)
  94. end
  95. end
  96. function this:Unload()
  97. self.baseUI:UnFusion(self.id, self.itemCfgId, self.holeIndex)
  98. end
  99. function this:Hide()
  100. end
  101. function this:Close()
  102. end
  103. return this