UIGuildWarLogView.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. local UIGuildWarLogView = require("UIHundredDojo/UIHundredDojoLogView_Generate")
  2. local LoadStatusLoopListCtr = require('Common/LoadStatusLoopListCtr')
  3. function UIGuildWarLogView:OnAwake(data)
  4. self.controller = require("UIGuildWar/UIGuildWarLogCtr"):new()
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UIGuildWarLogView:AddEventListener()
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_WAR_BATTLE_LOG_DATA_CHANGED, self, self.OnLogChanged)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_WAR_OPEN_STATE_CHANGED, self, self.OnOpenStateChanged)
  11. end
  12. function UIGuildWarLogView:FillContent(data, uiBase)
  13. self.uiBase = uiBase
  14. local gameObject = self.uiBase:GetRoot()
  15. if gameObject ~= nil then
  16. self.gameObject = gameObject
  17. self.transform = gameObject.transform
  18. end
  19. self:InitGenerate(self.transform, data)
  20. self:Init()
  21. end
  22. function UIGuildWarLogView:Init()
  23. self.textTitle.uILocalizeScript:SetContent('GuildWarBattle12')
  24. self.controller:InitData()
  25. if self.loadStatusLoopListCtr then
  26. self.loadStatusLoopListCtr:Dispose()
  27. self.loadStatusLoopListCtr = nil
  28. end
  29. local logMaxNum = 0
  30. if self.controller:GetLogWhole() then
  31. logMaxNum = self.controller:GetLogNum()
  32. else
  33. logMaxNum = self.controller:GetLogMaxNum()
  34. end
  35. self.loadStatusLoopListCtr = LoadStatusLoopListCtr:new(self, self.changeList.loopListView, 0, logMaxNum,
  36. false, 'LoadingItem', Enum.ListLoadingStatus.None,
  37. true, 'LoadingItem', Enum.ListLoadingStatus.WaitLoad,
  38. self.GetItemByIndex,nil, self.OnBeginLoad)
  39. self.changeList.loopListView.ScrollRect.enabled = false
  40. local errorCode = self.controller:SendGetLogInfoReq(true)
  41. if errorCode ~= 0 then
  42. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  43. end
  44. end
  45. function UIGuildWarLogView:RemoveEventListener()
  46. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  47. end
  48. function UIGuildWarLogView:AddUIEventListener()
  49. self.uiBase:AddButtonEventListener(self.btnClose.button, self, self.OnClickCancelBtn)
  50. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickCancelBtn)
  51. end
  52. function UIGuildWarLogView:OnHide()
  53. end
  54. function UIGuildWarLogView:OnShow(data)
  55. self.controller:SetData(data)
  56. end
  57. function UIGuildWarLogView:OnClose()
  58. end
  59. function UIGuildWarLogView:OnDispose()
  60. if self.loadStatusLoopListCtr then
  61. self.loadStatusLoopListCtr:Dispose()
  62. self.loadStatusLoopListCtr = nil
  63. end
  64. self.controller:OnDispose()
  65. end
  66. function UIGuildWarLogView:OnPageInEnd()
  67. self.super.OnPageInEnd(self)
  68. self.changeList.loopListView.ScrollRect.enabled = true
  69. end
  70. function UIGuildWarLogView:OnLogChanged(changed, startChanged, endChanged)
  71. self.controller:RefreshLogData()
  72. self:RefreshList(startChanged)
  73. end
  74. function UIGuildWarLogView:OnOpenStateChanged(isOpen)
  75. if isOpen then return end
  76. self:UIClose()
  77. end
  78. function UIGuildWarLogView:OnClickCancelBtn()
  79. self:UIClose()
  80. end
  81. function UIGuildWarLogView:GetItemByIndex(loopListView, idx, dataIdx)
  82. local itemData = self.controller:GetLogById(dataIdx)
  83. if not itemData then return nil end
  84. local item = loopListView:NewListViewItem('HundredDojoLogItem')
  85. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'HundredDojoLogItem', item.gameObject)
  86. if itemLua then
  87. itemLua.fightBtn:SetActive(false)
  88. local logType = itemData.type
  89. local time = itemData.time
  90. itemLua.timeTxt.text.text = ManagerContainer.LuaTimerMgr:ParseTimeStamp2Format(time, '%Y-%m-%d %H:%M:%S')
  91. -- local areaCfgData = nil
  92. -- if itemData.areaId then
  93. -- areaCfgData = ManagerContainer.CfgMgr:GetGuildWarDojoCfgById(itemData.areaId)
  94. -- end
  95. -- local areaName = string.formatbykey(areaCfgData and areaCfgData.Name or '')
  96. local guildName, guildColor = self.controller:GetGuildNameAndColor(itemData.guildId)
  97. local challengeGuildName, challengeGuildColor = self.controller:GetGuildNameAndColor(itemData.challengeGuildId)
  98. if logType == 1 then
  99. if itemData.winSteak > 0 then
  100. itemLua.contentTxt.text.text = string.formatbykey('GuildWarBattle16', guildName, itemData.playerName, challengeGuildName, itemData.challengePlayerName, tostring(itemData.winSteak), guildColor, challengeGuildColor)
  101. else
  102. itemLua.contentTxt.text.text = string.formatbykey('GuildWarBattle18', guildName, itemData.playerName, challengeGuildName, itemData.challengePlayerName, tostring(itemData.winSteak), guildColor, challengeGuildColor)
  103. end
  104. elseif logType == 2 then
  105. if itemData.winSteak > 0 then
  106. itemLua.contentTxt.text.text = string.formatbykey('GuildWarBattle22', guildName, itemData.playerName, challengeGuildName, itemData.challengePlayerName, tostring(itemData.winSteak), guildColor, challengeGuildColor)
  107. else
  108. itemLua.contentTxt.text.text = string.formatbykey('GuildWarBattle17', guildName, itemData.playerName, challengeGuildName, itemData.challengePlayerName, tostring(itemData.winSteak), guildColor, challengeGuildColor)
  109. end
  110. else
  111. itemLua.contentTxt.text.text = ''
  112. end
  113. end
  114. ManagerContainer.LuaUIMgr:ForceRebuildLayoutImmediate(item.CachedRectTransform)
  115. return item
  116. end
  117. function UIGuildWarLogView:OnBeginLoad(isBegin)
  118. local errorCode = self.controller:SendGetLogInfoReq(isBegin)
  119. if errorCode ~= 0 then
  120. self:RefreshList(isBegin)
  121. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  122. end
  123. end
  124. function UIGuildWarLogView:RefreshList(isBegin)
  125. local whole = self.controller:GetLogWhole()
  126. local dataLength = self.controller:GetLogNum()
  127. self.loadStatusLoopListCtr:SetHasBegin(true)
  128. self.loadStatusLoopListCtr:OnAllLoaded()
  129. self.loadStatusLoopListCtr:RefreshMaxDataLength((whole and dataLength or (dataLength + 1)))
  130. self.loadStatusLoopListCtr:RefreshDataLength(dataLength)
  131. end
  132. return UIGuildWarLogView