源战役客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

120 řádky
4.1 KiB

před 4 týdny
  1. ChildRenameView = ChildRenameView or BaseClass(BaseView)
  2. function ChildRenameView:__init()
  3. self.base_file = "child"
  4. self.layout_file = "ChildRenameView"
  5. self.layer_name = "Activity"
  6. self.use_background = true
  7. -- self.use_local_view = true
  8. self.is_set_zdepth = true
  9. --self.blur_activity_bg = true
  10. self.model = ChildModel:GetInstance()
  11. self.mainVo = RoleManager.Instance.mainRoleInfo
  12. self.load_callback = function()
  13. self:LoadSuccess()
  14. self:InitEvent()
  15. end
  16. self.open_callback = function()
  17. end
  18. self.destroy_callback = function()
  19. self:Remove()
  20. end
  21. end
  22. function ChildRenameView:Open()
  23. BaseView.Open(self)
  24. end
  25. function ChildRenameView:Remove()
  26. if self.goods_change_id then
  27. self.model:UnBind(self.goods_change_id)
  28. self.goods_change_id = nil
  29. end
  30. if self.check_free_id then
  31. self.model:UnBind(self.check_free_id)
  32. self.check_free_id = nil
  33. end
  34. if self.rename_success_id then
  35. self.model:UnBind(self.rename_success_id)
  36. self.rename_success_id = nil
  37. end
  38. if self.rename_guild_success_id then
  39. self.model:UnBind(self.rename_guild_success_id)
  40. self.rename_guild_success_id = nil
  41. end
  42. if self.award_item then
  43. UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.award_item)
  44. self.award_item = nil
  45. end
  46. if self.refresh_renamecard_id then
  47. GoodsModel:getInstance():UnBind(self.refresh_renamecard_id)
  48. self.refresh_renamecard_id = nil
  49. end
  50. end
  51. function ChildRenameView:LoadSuccess()
  52. self.inputFiled = self:GetChild("input"):GetComponent("TMP_InputField")
  53. local node = {
  54. "Window:raw", "confirmBtn:obj", "name:txt", "input/Text Area/Placeholder:tmp",
  55. "Window/windowTitleText:txt", --"consumable:txt",
  56. -- "tip1_cont:txt","tip2_cont:txt",
  57. "girl_img:raw",
  58. "money_bg/num:tmp",
  59. }
  60. self:GetChildren(node)
  61. lua_resM:setOutsideRawImage(self, self.Window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"), false)
  62. lua_resM:setOutsideRawImage(self, self.girl_img_raw, GameResPath.GetRoleBg("girl_234_225"), false)
  63. -- self.tip1_cont_txt.text = "昵称支持2~6位汉字、英文、数字"
  64. -- self.tip2_cont_txt.text = "修改后,昵称10分钟内不得再次修改"
  65. self.num_tmp.text = stringtotable(self.model:GetConfigChildKvVal("rename_cost"))[1][3]
  66. end
  67. function ChildRenameView:InitEvent()
  68. local function onBtnClickHandler(target)
  69. if target == self.confirmBtn_obj then
  70. if HasLimitChar(self.inputFiled.text) then
  71. Message.show("角色名存在非法字符,请重新输入")
  72. return
  73. end
  74. local _, filter = LanguageFilter.FilterMsg(self.inputFiled.text)
  75. if filter == false then
  76. Message.show("内容有敏感词")
  77. return
  78. end
  79. if Trim(self.inputFiled.text) == "" then
  80. -- Message.show("名字不能为空")
  81. -- return
  82. -- self.inputFiled.text = "宝宝"
  83. end
  84. local filter = LanguageFilter.NameFilter(self.inputFiled.text)
  85. if filter == nil then
  86. Message.show("角色名存在敏感词,请重新输入")
  87. self.inputFiled.text = ""
  88. return
  89. end
  90. if string.find(self.inputFiled.text, "(<#f_%d>)") then
  91. Message.show("该名字含有非法字符 ")
  92. return
  93. end
  94. if EnglineVersion and AppConst_EnglineVer > 30 then
  95. self.inputFiled.text = Util.SetNonBreakSpaceText(self.inputFiled.text)
  96. end
  97. local change_name = Trim(self.inputFiled.text)
  98. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16503,change_name)
  99. -- Message.show("change_name:",change_name)
  100. end
  101. end
  102. AddClickEvent(self.confirmBtn_obj, onBtnClickHandler, 2)
  103. end
  104. function ChildRenameView:SetViewInfo()
  105. self.name_txt.text = "请输入新的昵称"
  106. self.windowTitleText_tmp.text = "昵称修改"
  107. self.Placeholder_tmp.text = "请输入新昵称"
  108. end