UIGuildSettingsCtr.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. local UIGuildSettingsCtr = class("UIGuildSettingsCtr", require("UICtrBase"))
  2. function UIGuildSettingsCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIGuildSettingsCtr:SetData(data)
  6. self.asyncIdx = 0
  7. self.data = data
  8. self:InitData()
  9. end
  10. function UIGuildSettingsCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIGuildSettingsCtr:GetData()
  15. return self.data
  16. end
  17. function UIGuildSettingsCtr:OnDispose()
  18. self.data = nil
  19. self.view = nil
  20. self.guildData = nil
  21. self.changeBadge = nil
  22. self.minRecuritLevel = nil
  23. self.maxRecuritLevel = nil
  24. self.changeRecuritLevel = nil
  25. self.changeRecuritNotice = nil
  26. self.recuritNoticeMaxLength = nil
  27. self.costItemCfgId = nil
  28. self.costNum = nil
  29. end
  30. function UIGuildSettingsCtr:InitData()
  31. self.guildData = ManagerContainer.DataMgr.GuildDataMgr:GetCurGuildData()
  32. self.changeBadge = nil
  33. self.changeRecuritType = nil
  34. self.changeRecuritLevel = nil
  35. self.changeRecuritNotice = nil
  36. if self.guildData then
  37. local briefData = self.guildData:GetBriefData()
  38. if briefData then
  39. self.changeBadge = briefData.badge
  40. end
  41. local baseData = self.guildData:GetBaseData()
  42. if baseData then
  43. self.changeRecuritType = baseData.recuritType
  44. self.changeRecuritLevel = baseData.recuritLevel
  45. self.changeRecuritNotice = baseData.recruitNotice
  46. end
  47. end
  48. self.minRecuritLevel = 0
  49. self.maxRecuritLevel = 0
  50. local cfgStr = GlobalConfig.Instance:GetConfigStrValue(195)
  51. if cfgStr then
  52. local arr = string.split(cfgStr, ':')
  53. if arr then
  54. self.minRecuritLevel = (arr[1] and tonumber(arr[1]) or 0)
  55. self.maxRecuritLevel = (arr[2] and tonumber(arr[2]) or 0)
  56. end
  57. end
  58. if not self.changeBadge then
  59. self.changeBadge = GlobalConfig.Instance:GetConfigIntValue(217)
  60. end
  61. if not self.changeRecuritType then
  62. self.changeRecuritType = Enum.GuildEnterVerifyType.NeedVerify
  63. end
  64. if not self.changeRecuritLevel then
  65. self.changeRecuritLevel = self.minRecuritLevel
  66. end
  67. if not self.changeRecuritNotice then
  68. self.changeRecuritNotice = ''
  69. end
  70. self.recuritNoticeMaxLength = GlobalConfig.Instance:GetConfigIntValue(216)
  71. self.costItemCfgId = 2
  72. self.costNum = 100
  73. local costStr = GlobalConfig.Instance:GetConfigStrValue(220)
  74. if costStr then
  75. local costStrArr = string.split(costStr, ':')
  76. if costStrArr then
  77. if costStrArr[1] then
  78. self.costItemCfgId = tonumber(costStrArr[1])
  79. end
  80. if costStrArr[2] then
  81. self.costNum = tonumber(costStrArr[2])
  82. end
  83. end
  84. end
  85. end
  86. function UIGuildSettingsCtr:GetRecuritNoticeMaxLength()
  87. return self.recuritNoticeMaxLength
  88. end
  89. function UIGuildSettingsCtr:GetRecuritNotice()
  90. return self.changeRecuritNotice
  91. end
  92. function UIGuildSettingsCtr:SetRecuritNotice(newNotice)
  93. self.changeRecuritNotice = newNotice
  94. end
  95. function UIGuildSettingsCtr:GetCurName()
  96. if self.guildData then
  97. local briefData = self.guildData:GetBriefData()
  98. return briefData and briefData.name or ''
  99. end
  100. return ''
  101. end
  102. function UIGuildSettingsCtr:GetCurBadgeResPath()
  103. if self.changeBadge then
  104. local badgeCfgData = ManagerContainer.CfgMgr:GetGuildBadgeCfgById(self.changeBadge)
  105. if badgeCfgData then
  106. return badgeCfgData.Pic
  107. end
  108. end
  109. return ''
  110. end
  111. function UIGuildSettingsCtr:GetBadge()
  112. return self.changeBadge
  113. end
  114. function UIGuildSettingsCtr:SetBadge(badge)
  115. if self.changeBadge == badge then
  116. return false
  117. end
  118. self.changeBadge = badge
  119. return true
  120. end
  121. function UIGuildSettingsCtr:GetRecuritType()
  122. return self.changeRecuritType
  123. end
  124. function UIGuildSettingsCtr:SetRecuritType(recuritType)
  125. if self.changeRecuritType == recuritType then
  126. return false
  127. end
  128. self.changeRecuritType = recuritType
  129. return true
  130. end
  131. function UIGuildSettingsCtr:GetRecuritLevel()
  132. return self.changeRecuritLevel
  133. end
  134. function UIGuildSettingsCtr:SetRecuritLevel(recuritLevel)
  135. self.changeRecuritLevel = recuritLevel
  136. end
  137. function UIGuildSettingsCtr:GetRecuritLevelLimit()
  138. return self.minRecuritLevel, self.maxRecuritLevel
  139. end
  140. function UIGuildSettingsCtr:GetCostInfo()
  141. return self.costItemCfgId, self.costNum
  142. end
  143. function UIGuildSettingsCtr:HasChanged()
  144. local isChanged = false
  145. if self.guildData then
  146. local briefData = self.guildData:GetBriefData()
  147. if briefData then
  148. if self.changeBadge ~= briefData.badge then
  149. isChanged = true
  150. end
  151. end
  152. local baseData = self.guildData:GetBaseData()
  153. if baseData then
  154. if self.changeRecuritType ~= baseData.recuritType then
  155. isChanged = true
  156. end
  157. if self.changeRecuritLevel ~= baseData.recuritLevel then
  158. isChanged = true
  159. end
  160. if self.changeRecuritNotice ~= baseData.recruitNotice then
  161. isChanged = true
  162. end
  163. end
  164. end
  165. return isChanged
  166. end
  167. function UIGuildSettingsCtr:SendGuildSettingsReq()
  168. if not self:HasChanged() then
  169. return 0
  170. end
  171. local level = ManagerContainer.DataMgr.UserData:GetRoleLv()
  172. if not SDKMgr.Instance:CheckSpeech(level, ChannelType.GUILD_RECRUIT, self.changeRecuritNotice) then
  173. return 'ShieldTips01'
  174. end
  175. if not ManagerContainer.DataMgr.GuildDataMgr:SendSetGuildInfoReq(self.changeBadge, self.changeRecuritType, self.changeRecuritLevel, self.changeRecuritNotice) then
  176. return 100007
  177. end
  178. return 0
  179. end
  180. return UIGuildSettingsCtr