源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

128 行
4.1 KiB

  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 社团修改公告界面
  4. -- *>
  5. GuildEditAnnounceView = GuildEditAnnounceView or BaseClass(BaseView)
  6. local GuildEditAnnounceView = GuildEditAnnounceView
  7. function GuildEditAnnounceView:__init()
  8. self.base_file = "guild"
  9. self.layout_file = "GuildEditAnnounceView"
  10. self.layer_name = "Activity"
  11. self.destroy_imm = true
  12. self.use_background = true
  13. self.blur_activity_bg = true
  14. self.use_show_anim = true
  15. self.use_hide_anim = true
  16. self.model = GuildModel:getInstance()
  17. -- 除以2是因为中文编码算2个字符,就直接按照全中文来,海外版本需要移除
  18. self.send_limit = stringtotable(self.model:GetGuildKvByKey("announce_len").val)[2] / 2
  19. self.load_callback = function ()
  20. self:LoadSuccess()
  21. self:AddEvent()
  22. end
  23. self.open_callback = function ( )
  24. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 40019) --获取社团修改信息界面信息
  25. self:UpdateView()
  26. self:UpdateBasicAnnounce()
  27. end
  28. self.switch_callback = function(index)
  29. self:SwitchTab(index)
  30. end
  31. self.destroy_callback = function ( )
  32. self:DestroySuccess()
  33. end
  34. end
  35. function GuildEditAnnounceView:Open( )
  36. --self.data = data
  37. BaseView.Open(self)
  38. end
  39. function GuildEditAnnounceView:LoadSuccess()
  40. local nodes = {
  41. "window:raw",
  42. "window/close:obj", "save_btn:obj", "cancel_btn:obj",
  43. "announce:tmpInput", "cur_text_num:tmp",
  44. "free_tips:tmp", "change_tips:tmp",
  45. }
  46. self:GetChildren(nodes)
  47. lua_resM:setOutsideRawImage(self, self.window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"))
  48. end
  49. function GuildEditAnnounceView:AddEvent()
  50. local function click_event(target)
  51. if target == self.close_obj or target == self.cancel_btn_obj then
  52. self:Close()
  53. elseif target == self.save_btn_obj then
  54. self:OnClickSaveAnnounceBtn()
  55. end
  56. end
  57. AddClickEvent(self.close_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  58. AddClickEvent(self.cancel_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  59. AddClickEvent(self.save_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  60. local function update_view()
  61. self:UpdateView()
  62. end
  63. self:BindEvent(self.model, GuildModel.UPDATE_GUILD_ANNOUNCE_TIMES, update_view)
  64. self.announce_tmpInput.onValueChanged:AddListener(function()
  65. local len = utf8len(self.announce_tmpInput.text)
  66. if len > self.send_limit then
  67. self.announce_tmpInput.text = GetInputLimitResultStr(self.announce_tmpInput.text, self.send_limit) --减去多出来的字符
  68. self.tip_time = self.tip_time or 0
  69. if Status.NowTime-self.tip_time > 0.2 then
  70. Message.show(string.format("最多可输入%d个字符", self.send_limit))
  71. self.tip_time = Status.NowTime
  72. self:SetFontNum(self.send_limit)
  73. end
  74. else
  75. self:SetFontNum(len)
  76. end
  77. end)
  78. end
  79. function GuildEditAnnounceView:UpdateView()
  80. local times_data = self.model:GetGuildAnnounceTimesData()
  81. self.change_tips_tmp.text = string.format("<color=%s>%s以上</color>才可修改社团公告",
  82. ColorUtil.PURPLE_DARK, Trim(Config.Guildpos[GuildModel.GuildPosition.ViceLeader].name))
  83. if times_data then
  84. self.free_tips_tmp.text = string.format("每天可免费修改%s次(<color=%s>%s</color>/%s)", times_data.free_times,
  85. times_data.remain_times > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
  86. times_data.remain_times, times_data.free_times)
  87. else
  88. self.free_tips_tmp.text = ""
  89. end
  90. end
  91. function GuildEditAnnounceView:UpdateBasicAnnounce( )
  92. self.announce_tmpInput.text = self.model:GetGuildAnnounce()
  93. end
  94. function GuildEditAnnounceView:SetFontNum( num )
  95. self.cur_text_num_tmp.text = string.format("字数:<color=%s>%s</color>/%s",
  96. num < self.send_limit and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK, num, self.send_limit)
  97. end
  98. function GuildEditAnnounceView:OnClickSaveAnnounceBtn( )
  99. local _, title_filter = LanguageFilter.FilterMsg(self.announce_tmpInput.text)
  100. if title_filter == false then
  101. Message.show("社团公告有敏感词")
  102. return
  103. end
  104. if self.announce_tmpInput.text ~= "" then
  105. self.model:Fire(GuildModel.RequestSetAnnounceEvt, self.announce_tmpInput.text, 1)
  106. else
  107. Message.show("请输入公告~")
  108. end
  109. end
  110. function GuildEditAnnounceView:DestroySuccess( )
  111. end