UIArtifactNotesTipsView.lua 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. local UIArtifactNotesTipsView = require("UIArtifactTips/UIArtifactNotesTipsView_Generate")
  2. local curSkill
  3. function UIArtifactNotesTipsView:OnAwake(data)
  4. self.controller = require("UIArtifactTips/UIArtifactNotesTipsCtr"):new()
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UIArtifactNotesTipsView:AddEventListener()
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  10. end
  11. function UIArtifactNotesTipsView:FillContent(data, uiBase)
  12. self.uiBase = uiBase
  13. local gameObject = self.uiBase:GetRoot()
  14. if gameObject ~= nil then
  15. self.gameObject = gameObject
  16. self.transform = gameObject.transform
  17. end
  18. self:InitGenerate(self.transform, data)
  19. self:Init()
  20. end
  21. function UIArtifactNotesTipsView:Init()
  22. self:Refresh()
  23. end
  24. function UIArtifactNotesTipsView:Refresh()
  25. local skillEquipData = self.controller:GetSkillEquipData()
  26. local idx = self.controller:GetIdx()
  27. local cfgId = skillEquipData.cfgId
  28. local cfgData = ManagerContainer.CfgMgr:GetArtifactCfgDataByCfgId(cfgId)
  29. if not cfgData or not skillEquipData then return end
  30. local heroId = self.controller:GetHeroId()
  31. local heroData = CommonUtil.GetHeroLogicDataByUid(heroId)
  32. if not heroData then return end
  33. local skillData = heroData.skillData
  34. local slotSkills = skillData.slotSkills
  35. local unLockSkillMap = skillData.unlockSkillMap
  36. local data = cfgData.ArtifacFuncId[idx]
  37. if not data then return end
  38. local oldSkillId = heroId == 1 and data[2] or data[3]
  39. local skillTreeCfgData = ManagerContainer.CfgMgr:GetSkillTreeCfgById(oldSkillId)
  40. if not skillTreeCfgData then
  41. skillTreeCfgData = ManagerContainer.CfgMgr:GetParterSkillTreeCfgById(oldSkillId)
  42. end
  43. if not skillTreeCfgData then return end
  44. local lastSkillId = skillTreeCfgData.beforeSkill
  45. if unLockSkillMap[oldSkillId] then
  46. curSkill = oldSkillId
  47. else
  48. curSkill = lastSkillId
  49. end
  50. local oldSkillCfgData = ManagerContainer.CfgMgr:GetSkillCfgById(lastSkillId)
  51. local newSkillCfgData = ManagerContainer.CfgMgr:GetSkillCfgById(oldSkillId)
  52. if not oldSkillCfgData or not newSkillCfgData then return end
  53. local condition1 = self.controller:GetCondition1State()
  54. if not condition1 then
  55. condition1 = unLockSkillMap[oldSkillId] ~= nil
  56. end
  57. local condition2 = self.controller:GetCondition2State()
  58. if not condition2 then
  59. condition2 = false
  60. for i = 1, #slotSkills do
  61. if slotSkills[i].isUnlock and slotSkills[i].skillId == oldSkillId then
  62. condition2 = true
  63. break
  64. end
  65. end
  66. end
  67. local condition3 = self.controller:GetCondition3State()
  68. if not condition3 then
  69. condition3 = data ~= nil and idx <= skillEquipData.starLv
  70. end
  71. self.condition1.actived:SetActive(condition1)
  72. self.condition1.dsc.text.text = condition1 and I18N.SetLanguageValue("ArtifactTips1", I18N.T(newSkillCfgData.Name))
  73. or I18N.SetLanguageValue("ArtifactTips2", I18N.T(newSkillCfgData.Name), I18N.T(oldSkillCfgData.Name))
  74. self.condition2.actived:SetActive(condition2)
  75. self.condition2.dsc.text.text = condition2 and I18N.SetLanguageValue("ArtifactTips3", I18N.T(newSkillCfgData.Name))
  76. or I18N.SetLanguageValue("ArtifactTips4", I18N.T(newSkillCfgData.Name))
  77. self.condition3.actived:SetActive(condition3)
  78. self.condition3.dsc.text.text = condition3 and I18N.T("ArtifactTips5")
  79. or I18N.T("ArtifactTips6")
  80. local tipsUI = ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIArtifactTips)
  81. if tipsUI then
  82. self.condition1.btnGoto:SetActive(not condition1)
  83. self.condition2.btnGoto:SetActive(not condition2)
  84. self.condition3.btnGoto:SetActive(false)
  85. else
  86. local isSkillSettingUI = ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UISkillSettings)
  87. self.condition1.btnGoto:SetActive(not condition1 and not isSkillSettingUI)
  88. self.condition2.btnGoto:SetActive(not condition2 and not isSkillSettingUI)
  89. self.condition3.btnGoto:SetActive(not condition3 and isSkillSettingUI ~= nil)
  90. end
  91. end
  92. function UIArtifactNotesTipsView:RemoveEventListener()
  93. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  94. end
  95. function UIArtifactNotesTipsView:AddUIEventListener()
  96. self.uiBase:AddButtonEventListener(self.AnyBtn.button, self, self.OnUICloseClick)
  97. self.uiBase:AddButtonEventListener(self.btnClose.button, self, self.OnUICloseClick)
  98. self.uiBase:AddButtonEventListener(self.condition1.btnGoto.button, self, self.OnGotoSkillSetting)
  99. self.uiBase:AddButtonEventListener(self.condition2.btnGoto.button, self, self.OnGotoSkillSetting)
  100. self.uiBase:AddButtonEventListener(self.condition3.btnGoto.button, self, self.OnGotoArtifactTips)
  101. end
  102. function UIArtifactNotesTipsView:OnUICloseClick()
  103. self:UIClose()
  104. end
  105. function UIArtifactNotesTipsView:OnGotoSkillSetting()
  106. if not ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UISkillSettings) then
  107. local heroId = self.controller:GetHeroId()
  108. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillSettings, {heroId, curSkill})
  109. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIArtifactTips)
  110. end
  111. self:OnUICloseClick()
  112. end
  113. function UIArtifactNotesTipsView:OnGotoArtifactTips()
  114. if not ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIArtifactTips) then
  115. local heroId = self.controller:GetHeroId()
  116. local heroData = CommonUtil.GetHeroLogicDataByUid(heroId)
  117. local skillEquipData = self.controller:GetSkillEquipData()
  118. local jobType
  119. if heroId == 1 then
  120. local jobData = ManagerContainer.CfgMgr:GetJobDataById(heroData.configId)
  121. jobType = jobData.JobType
  122. else
  123. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(heroData.configId)
  124. jobType = cfgData.JobType
  125. end
  126. local data = {{cfgId = skillEquipData.cfgId, jobType = jobType, logicData = skillEquipData, heroId = heroId, heroCfgId = heroData.configId, nickname = heroData.nickname}, Enum.ItemIEnterType.SkillEquip, self.uiData.id}
  127. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIArtifactTips, data)
  128. end
  129. self:OnUICloseClick()
  130. end
  131. function UIArtifactNotesTipsView:OnHide()
  132. end
  133. function UIArtifactNotesTipsView:OnShow(data)
  134. self.controller:SetData(data)
  135. end
  136. function UIArtifactNotesTipsView:OnClose()
  137. curSkill = nil
  138. end
  139. function UIArtifactNotesTipsView:OnDispose()
  140. self.controller:OnDispose()
  141. end
  142. return UIArtifactNotesTipsView