UIFashionGotView.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. local UIFashionGotView = require("UIFashion/UIFashionGotView_Generate")
  2. function UIFashionGotView:OnAwake(data)
  3. self.controller = require("UIFashion/UIFashionGotCtr")
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIFashionGotView:AddEventListener()
  8. end
  9. function UIFashionGotView:FillContent(data, uiBase)
  10. self.uiBase = uiBase
  11. local gameObject = self.uiBase:GetRoot()
  12. if gameObject ~= nil then
  13. self.gameObject = gameObject
  14. self.transform = gameObject.transform
  15. end
  16. self:InitGenerate(self.transform, data)
  17. self:Init()
  18. end
  19. function UIFashionGotView:Init()
  20. local cfgId = self.controller:GetCfgId()
  21. self.icon.image.sprite = nil
  22. self.frame.image.sprite = nil
  23. local fashionCfgData = ManagerContainer.CfgMgr:GetFashionById(cfgId)
  24. CommonUtil.LoadIcon(self, fashionCfgData.FashionIcon, function (sprite)
  25. self.icon.image.sprite = sprite
  26. end, self, 'IconAsyncIdx')
  27. CommonUtil.LoadIcon(self, Constant.Quality_Frame_Icons[fashionCfgData.FashionQuality], function (sprite)
  28. self.frame.image.sprite = sprite
  29. end, self, 'FrameAsyncIdx')
  30. self.nameTxt.text.text = I18N.SetLanguageValue(fashionCfgData.FashionName)
  31. local fashionLogicData = self.controller:GetFashionLogicData(fashionCfgData.FashionId)
  32. if fashionLogicData then
  33. local attrs = fashionLogicData.attrs
  34. for i = 1, 5 do
  35. local propertyItem = self['property' .. i]
  36. if propertyItem then
  37. local fashionAttr = attrs[i]
  38. if fashionAttr then
  39. local jobType = fashionAttr.jobType
  40. local attrId = fashionAttr.attrId
  41. local attrValue = fashionAttr.value
  42. local jobName = self.controller:GetJobTypeName(jobType)
  43. propertyItem.attrName.text.text = jobName..I18N.SetLanguageValue(CommonUtil.HeroAttrFormatName(attrId, attrValue))
  44. propertyItem.number.text.text = "+"..attrValue
  45. propertyItem:SetActive(true)
  46. else
  47. propertyItem:SetActive(false)
  48. end
  49. end
  50. end
  51. else
  52. for i = 1, 5 do
  53. local propertyItem = self['property' .. i]
  54. if propertyItem then
  55. propertyItem:SetActive(i <= fashionCfgData.AttrNum)
  56. if i <= fashionCfgData.AttrNum then
  57. propertyItem.attrName.text.text = I18N.T("RandomAttr1")
  58. propertyItem.number.text.text = I18N.T("RandomAttr2")
  59. end
  60. end
  61. end
  62. end
  63. local jobCfgId = ManagerContainer.DataMgr.UserData:GetJobCfgId()
  64. if not fashionCfgData.FashionUseJob or IsTableHasValue(fashionCfgData.FashionUseJob, jobCfgId) then
  65. CommonUtil.SetTotalChildrenGray(self.equipBtn, false)
  66. else
  67. CommonUtil.SetTotalChildrenGray(self.equipBtn, true)
  68. end
  69. end
  70. function UIFashionGotView:RemoveEventListener()
  71. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  72. end
  73. function UIFashionGotView:AddUIEventListener()
  74. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  75. self.uiBase:AddButtonUniqueEventListener(self.alpha.button, self, self.OnClickCloseBtn)
  76. self.uiBase:AddButtonEventListener(self.equipBtn.button, self, self.OnClickEquipBtn)
  77. end
  78. function UIFashionGotView:OnHide()
  79. end
  80. function UIFashionGotView:OnShow(data)
  81. self.controller:SetData(data)
  82. self:Init()
  83. end
  84. function UIFashionGotView:OnClose()
  85. ManagerContainer.PopGotMgr:PageViewKeep(false)
  86. end
  87. function UIFashionGotView:OnDispose()
  88. end
  89. function UIFashionGotView:OnClickCloseBtn()
  90. self:UIClose()
  91. end
  92. function UIFashionGotView:OnClickEquipBtn()
  93. local cfgId = self.controller:GetCfgId()
  94. local fashionCfgData = ManagerContainer.CfgMgr:GetFashionById(cfgId)
  95. local jobCfgId = ManagerContainer.DataMgr.UserData:GetJobCfgId()
  96. if not fashionCfgData.FashionUseJob or IsTableHasValue(fashionCfgData.FashionUseJob, jobCfgId) then
  97. self.controller:SendEquip()
  98. self:UIClose()
  99. else
  100. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('WeaponfashionTip_3')
  101. end
  102. end
  103. return UIFashionGotView