KLUnionJoinPanel.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ---@class KLUnionJoinPanel:UIKmlLuaPanelBase
  2. ---@field view KLUnionJoinPanelView
  3. ---@field clickChild KLJoinInfoItem
  4. local KLUnionJoinPanel = class(UIKmlLuaPanelBase)
  5. local this =KLUnionJoinPanel
  6. ---创建时调用一次
  7. function this:Init()
  8. self.unionList = {}
  9. self.unionPanel = {}
  10. self.clickChild = nil
  11. end
  12. ---创建或者刷新界面数据时调用
  13. function this:Refresh()
  14. SL:ReqAllUnionMessage()
  15. end
  16. ---注册UI事件和服务器消息
  17. function this:RegistEvents()
  18. GUI:AddOnClickEvent(self.view.closeBtn, self, self.closeBtn)
  19. SL:RegisterLUAEvent(LUA_EVENT_UNION_ALL_INFO, self.ResAllUnionMessage, self)
  20. SL:RegisterLUAEvent(LUA_EVENT_ENTER_UNION, self.ResEnterUnionMessage, self)
  21. SL:RegisterLUAEvent(LUA_EVENT_APPLY_JOIN_UNION, self.ResApplyJoinUnionMessage, self)
  22. GUI:AddOnClickEvent(self.view.one_key_apply_to_join, self, self.one_key_apply_to_join)
  23. end
  24. function this:closeBtn()
  25. GUI:UIPanel_Close("dev/ui/Union/Panel/KLUnionJoin/KLUnionJoinPanel")
  26. GUI:UIPanel_Close("dev/ui/Union/Panel/KLUnionToggleList/KLUnionToggleListPanel")
  27. GUI:UIPanel_Close("dev/ui/Union/Panel/KLUnionSummaryInfo/KLUnionSummaryInfoPanel")
  28. end
  29. function this:one_key_apply_to_join()
  30. if InfoManager.loranSiegeInfo:GetIsOpen() then
  31. SL:TipMessage(SL:GetConfig("cfg_string",16005).text ,1, NoticeType.NoticeMid)
  32. return
  33. end
  34. SL:ReqAllApplyMessage()
  35. end
  36. ---@param message UnionProto.AllUnionRes
  37. function this:ResAllUnionMessage(id, message)
  38. if self.unionPanel then
  39. for unionId, panel in pairs(self.unionPanel) do
  40. GUI:UIPanel_Close(nil, panel)
  41. end
  42. end
  43. self.unionPanel = {}
  44. self.unionList = message.unionListInfo
  45. for index, unionInfo in pairs(self.unionList) do
  46. local item = GUI:UIPanel_Open("dev/ui/Union/Item/KLJoinInfo/KLJoinInfoItem", self.view.union_list_view, self, {info=unionInfo, parent=self}, true)
  47. if index == 1 then
  48. item:datalist_panel_btn_()
  49. end
  50. self.unionPanel[unionInfo.unionId] = item
  51. end
  52. end
  53. ---@param message UnionProto.ViewUnionRes
  54. function this:ResEnterUnionMessage(_, message)
  55. self:closeBtn()
  56. GUI:UIPanel_Open("dev/ui/Union/Panel/KLUnionToggleList/KLUnionToggleListPanel",nil,nil,{unionId = message.unionInfo.unionId})
  57. end
  58. function this:ChildOnClick(nowClickChild)
  59. if self.clickChild then
  60. self.clickChild:SetChoiceBg(false)
  61. end
  62. self.clickChild = nowClickChild
  63. end
  64. ---@param message UnionProto.ApplyJoinUnionRes
  65. function this:ResApplyJoinUnionMessage(id,message)
  66. local unionId = message.unionId
  67. local status = message.applyStatus
  68. ---@type KLJoinInfoItem
  69. local panel = self.unionPanel[unionId]
  70. if panel then
  71. panel:SetStatus(status)
  72. end
  73. end
  74. function this:Close()
  75. end
  76. return this