UIGuildHuntLogView.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. local UIGuildHuntLogView = require("UIGuild/UIGuildHuntLogView_Generate")
  2. local LoadStatusLoopListCtr = require('Common/LoadStatusLoopListCtr')
  3. function UIGuildHuntLogView:OnAwake(data)
  4. self.controller = require("UIGuild/UIGuildHuntLogCtr"):new()
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UIGuildHuntLogView:AddEventListener()
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_HUNT_BOSS_BATTLE_LOG_CHANGED, self, self.OnGuildHuntBossBattleLogChanged)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_DISBAND_SUCCESS, self, self.OnGuildDisBandSuccess)
  11. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_QUIT_SUCCESS, self, self.OnGuildQuitSuccess)
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_KICKOUT_SUCCESS, self, self.OnGuildKickoutSuccess)
  13. end
  14. function UIGuildHuntLogView:FillContent(data, uiBase)
  15. self.uiBase = uiBase
  16. local gameObject = self.uiBase:GetRoot()
  17. if gameObject ~= nil then
  18. self.gameObject = gameObject
  19. self.transform = gameObject.transform
  20. end
  21. self:InitGenerate(self.transform, data)
  22. self:Init()
  23. end
  24. function UIGuildHuntLogView:Init()
  25. if self.loadStatusLoopListCtr then
  26. self.loadStatusLoopListCtr:Dispose()
  27. self.loadStatusLoopListCtr = nil
  28. end
  29. local logMaxNum = self.controller:GetLogMaxNum()
  30. self:SetListShowStatus((0 ~= logMaxNum))
  31. self.loadStatusLoopListCtr = LoadStatusLoopListCtr:new(self, self.damageList.loopListView, 0, logMaxNum,
  32. false, 'LoadingItem', Enum.ListLoadingStatus.None,
  33. true, 'LoadingItem', Enum.ListLoadingStatus.WaitLoad,
  34. self.GetItemByIndex,nil, self.OnBeginLoad)
  35. self.damageList.loopListView.ScrollRect.enabled = false
  36. local errorCode = self.controller:SendGuildHuntBossLogReq(true)
  37. if errorCode ~= 0 then
  38. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  39. end
  40. end
  41. function UIGuildHuntLogView:RemoveEventListener()
  42. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  43. end
  44. function UIGuildHuntLogView:AddUIEventListener()
  45. self.uiBase:AddButtonEventListener(self.btnClose.button, self, self.OnClickCancelBtn)
  46. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickCancelBtn)
  47. end
  48. function UIGuildHuntLogView:OnHide()
  49. end
  50. function UIGuildHuntLogView:OnShow(data)
  51. self.controller:SetData(data)
  52. end
  53. function UIGuildHuntLogView:OnClose()
  54. end
  55. function UIGuildHuntLogView:OnDispose()
  56. if self.loadStatusLoopListCtr then
  57. self.loadStatusLoopListCtr:Dispose()
  58. self.loadStatusLoopListCtr = nil
  59. end
  60. self.controller:OnDispose()
  61. end
  62. function UIGuildHuntLogView:OnPageInEnd()
  63. self.super.OnPageInEnd(self)
  64. self.damageList.loopListView.ScrollRect.enabled = true
  65. end
  66. function UIGuildHuntLogView:OnGuildDisBandSuccess()
  67. self:UIClose()
  68. end
  69. function UIGuildHuntLogView:OnGuildQuitSuccess()
  70. self:UIClose()
  71. end
  72. function UIGuildHuntLogView:OnGuildKickoutSuccess()
  73. self:UIClose()
  74. end
  75. function UIGuildHuntLogView:OnGuildHuntBossBattleLogChanged(bossId)
  76. if self.controller:GetBossId() ~= bossId then return end
  77. self:RefreshList()
  78. end
  79. function UIGuildHuntLogView:OnClickCancelBtn()
  80. self:UIClose()
  81. end
  82. function UIGuildHuntLogView:OnClickHeadItem(_, params)
  83. local uid = params[0]
  84. ManagerContainer.LuaUIMgr:OpenRoleMessagePanel(uid)
  85. end
  86. function UIGuildHuntLogView:GetItemByIndex(loopListView, idx, dataIdx)
  87. local itemData = self.controller:GetLogById(dataIdx)
  88. if not itemData then return nil end
  89. local item = loopListView:NewListViewItem('GuildPeopleHurtItem')
  90. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'GuildPeopleHurtItem', item.gameObject)
  91. if itemLua then
  92. local playerBrief = itemData.playerBrief
  93. local data = {}
  94. local uid
  95. local headFrameId = nil
  96. if playerBrief then
  97. uid = playerBrief.uid
  98. headFrameId = playerBrief.headFrame
  99. if int64.equals(uid, ManagerContainer.DataMgr.UserData:GetUserId()) then
  100. headFrameId = ManagerContainer.DataMgr.UserData:GetHeadFrameId()
  101. end
  102. local jobCfg = ManagerContainer.CfgMgr:GetJobDataById(playerBrief.configId)
  103. local jobIcon = ''
  104. if jobCfg then
  105. jobIcon = jobCfg.JobIcon
  106. end
  107. data = {Level = playerBrief.level, ProfessionIcon = jobIcon, HeadIcon = playerBrief.headPortraitName, IsHero = true}
  108. itemLua.nameTxt.text.text = tostring(playerBrief.nickName)
  109. else
  110. itemLua.nameTxt.text.text = ''
  111. end
  112. CommonUtil.SetPlayerHeadAndFrame(self, itemLua.headItem, data, false, headFrameId, self, self.OnClickHeadItem, uid)
  113. itemLua.damageTxt.text.text = tostring(itemData.damage)
  114. end
  115. ManagerContainer.LuaUIMgr:ForceRebuildLayoutImmediate(item.CachedRectTransform)
  116. return item
  117. end
  118. function UIGuildHuntLogView:OnBeginLoad(isBegin)
  119. local errorCode = self.controller:SendGuildHuntBossLogReq(isBegin)
  120. if errorCode ~= 0 then
  121. self:RefreshList()
  122. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  123. end
  124. end
  125. function UIGuildHuntLogView:RefreshList()
  126. local whole = self.controller:GetLogWhole()
  127. local dataLength = self.controller:GetLogNum()
  128. self.loadStatusLoopListCtr:SetHasBegin(true)
  129. self.loadStatusLoopListCtr:OnAllLoaded()
  130. self.loadStatusLoopListCtr:RefreshMaxDataLength((whole and dataLength or (dataLength + 1)))
  131. self.loadStatusLoopListCtr:RefreshDataLength(dataLength)
  132. self:SetListShowStatus(not (whole and dataLength == 0))
  133. end
  134. function UIGuildHuntLogView:SetListShowStatus(state)
  135. self.emptyTips:SetActive(not state)
  136. self.damageList:SetActive(state)
  137. end
  138. return UIGuildHuntLogView