KLUnionApplyListPanel.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ---@class KLUnionApplyListPanel:UIKmlLuaPanelBase
  2. ---@field view KLUnionApplyListPanelView
  3. local KLUnionApplyListPanel = class(UIKmlLuaPanelBase)
  4. local this =KLUnionApplyListPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. function this:Refresh()
  10. self:RefreshUnionApplicationList()
  11. self:SetMemberList()
  12. end
  13. ---注册UI事件和服务器消息
  14. function this:RegistEvents()
  15. GUI:AddOnClickEvent(self.view.btn_close, self, self.btn_close)
  16. GUI:AddOnClickEvent(self.view.btn_allAgree, self, self.btn_allAgree)
  17. GUI:AddOnClickEvent(self.view.btn_allRefuse, self, self.btn_allRefuse)
  18. GUI:AddOnClickEvent(self.view.mask, self, self.mask)
  19. GUI:SetToggleOnValueChange(self.view.AutoPass, self, self.AutoPassChange)
  20. SL:RegisterLUAEvent(LUA_EVENT_UNION_APPLICATION_LIST, self.UnionApplicationList, self)
  21. end
  22. function this:mask()
  23. self:btn_close()
  24. end
  25. function this:UnionApplicationList()
  26. self:SetMemberList()
  27. end
  28. function this:AutoPassChange(_,_, systemData)
  29. if systemData[1] then
  30. self.AutoPass = 1
  31. else
  32. self.AutoPass = 0
  33. end
  34. end
  35. function this:btn_close()
  36. SL.Union:ReqUnionSettingMessage(self.AutoPass,GUI:Text_getString(self.view.InputField_level), 0)
  37. GUI:UIPanel_Close("dev/ui/Union/Panel/KLUnionApplyList/KLUnionApplyListPanel")
  38. end
  39. function this:btn_allAgree()
  40. if InfoManager.loranSiegeInfo:GetIsOpen() then
  41. SL:TipMessage(SL:GetConfig("cfg_string",16005).text ,1, NoticeType.NoticeMid)
  42. return
  43. end
  44. SL.Union:ReqAllAgreeMessage()
  45. end
  46. function this:btn_allRefuse()
  47. SL.Union:ReqAllRejectMessage()
  48. end
  49. function this:Close()
  50. end
  51. -- 刷新
  52. function this:RefreshUnionApplicationList()
  53. --[[ self.AutoPass = PlayerPrefs.GetInt(RoleManager.meData.id.."unionAutoPass",0)
  54. self.InputField_level = PlayerPrefs.GetInt(RoleManager.meData.id.."unionInputField_level",0)]]
  55. local applyListInfo = SL.Union:GetApplyListInfo()
  56. if applyListInfo then
  57. --if unionInfo.ServerApplyListInfo.unionSetting.autoAccept ~= 0 then
  58. self.AutoPass = applyListInfo.unionSetting.autoAccept
  59. --end
  60. --if unionInfo.ServerApplyListInfo.unionSetting.needLevel ~= 0 then
  61. self.InputField_level = applyListInfo.unionSetting.needLevel
  62. else
  63. self.AutoPass = 1
  64. self.InputField_level = 0
  65. self.InputFieldMark= 0
  66. end
  67. if self.AutoPass == 1 then
  68. GUI:Toggle_setIsOn(self.view.AutoPass, true)
  69. else
  70. GUI:Toggle_setIsOn(self.view.AutoPass, false)
  71. end
  72. GUI:Text_setString(self.view.InputField_level, tostring(self.InputField_level))
  73. end
  74. function this:SetMemberList()
  75. GUI:DataListInitData(self.view.union_data_list, function()
  76. return table.count(SL.Union:GetApplyListInfo().applyInfo)
  77. end,
  78. function()
  79. end,
  80. function()
  81. end,
  82. function(realIndex)
  83. local unionInfo = SL.Union:GetApplyListInfo().applyInfo[realIndex + 1]
  84. local name = GUI:GetChildControl(self.view.union_data_list, realIndex, 'name')
  85. local level = GUI:GetChildControl(self.view.union_data_list, realIndex, 'level')
  86. local career = GUI:GetChildControl(self.view.union_data_list, realIndex, 'career')
  87. GUI:Text_setString(name, unionInfo.name)
  88. GUI:Text_setString(level, tostring(unionInfo.level))
  89. if unionInfo.career == 1 then
  90. GUI:Text_setString(career, "战士")
  91. elseif unionInfo.career == 2 then
  92. GUI:Text_setString(career, "法师")
  93. elseif unionInfo.career == 3 then
  94. GUI:Text_setString(career, "弓箭手")
  95. end
  96. local refuse_btn = GUI:GetChildControl(self.view.union_data_list, realIndex, 'refuse_btn')
  97. local agree_btn = GUI:GetChildControl(self.view.union_data_list, realIndex, 'agree_btn')
  98. GUI:AddOnClickEvent(refuse_btn, self, self.refuse_btn, {playerInfo = unionInfo})
  99. GUI:AddOnClickEvent(agree_btn, self, self.agree_btn, {playerInfo = unionInfo})
  100. end)
  101. GUI:DataListUpdateData(self.view.union_data_list)
  102. end
  103. function this:refuse_btn(_, eventData)
  104. local playerInfo = eventData.playerInfo
  105. SL.Union:ReqAgreeUnionApplyMessage(playerInfo.rid,0)
  106. end
  107. function this:agree_btn(_, eventData)
  108. if InfoManager.loranSiegeInfo:GetIsOpen() then
  109. SL:TipMessage(SL:GetConfig("cfg_string",16005).text ,1, NoticeType.NoticeMid)
  110. return
  111. end
  112. local playerInfo = eventData.playerInfo
  113. SL.Union:ReqAgreeUnionApplyMessage(playerInfo.rid,1)
  114. end
  115. return this