源战役客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

194 rader
6.6 KiB

1 månad sedan
  1. GameSettingView = GameSettingView or BaseClass(BaseView)
  2. GameSettingView.TabData = {
  3. {id = GameSettingModel.TabData.SYSYTEM, name = "系统",module_id = 102, sub_id = 0},
  4. {id = GameSettingModel.TabData.BLOCK, name = "屏蔽",module_id = 102, sub_id = 0},
  5. {id = GameSettingModel.TabData.AUTO, name = "挂机",module_id = 102, sub_id = 0},
  6. {id = GameSettingModel.TabData.CUSTOM, name = "客服",module_id = 102, sub_id = 0},
  7. }
  8. function GameSettingView:__init()
  9. self.base_file = "setting" --资源目录
  10. self.layout_file = "SettingView" --资源名称
  11. self.layer_name = "UI" --弹出目录
  12. self.model = GameSettingModel:GetInstance()
  13. self.blur_activity_bg = true
  14. self.use_show_anim = true
  15. self.use_hide_anim = true
  16. self.open_guide_close = true
  17. --初始化面板的基本属性
  18. self.close_mode = CloseMode.CloseDestroy --关闭模式为销毁
  19. self.destroy_imm = true; --销毁窗口模式为立即销毁
  20. self.use_background = true --使用背景
  21. self.hide_maincancas = false
  22. -- --背景透明度
  23. self.append_to_ctl_queue = true --添加到控制队列
  24. self.load_callback = function ()
  25. self:LoadSuccess()
  26. self:InitEvent()
  27. end
  28. self.open_callback = function()
  29. self.tabWindowComponent:SetTabBarIndex(self.cur_index)
  30. end
  31. self.close_callback = function()
  32. lua_settingM:ApplyMonsterVisibleState()
  33. lua_settingM:ApplyPlayerCounts()
  34. lua_settingM:ApplySceneEffect()
  35. CookieWrapper.Instance:WriteAll()
  36. end
  37. self.destroy_callback = function ()
  38. self:Remove()
  39. end
  40. end
  41. function GameSettingView:Open(index)
  42. self.cur_index = index or 1
  43. BaseView.Open(self)
  44. end
  45. function GameSettingView:LoadSuccess()
  46. self.sub_conta = self:GetChild("sub_conta")
  47. self.nodes = {
  48. "btn_con:obj",
  49. "btn_con/hook_btn:obj",
  50. "btn_con/account_btn:obj",
  51. "btn_con/backToLogin_btn:obj",
  52. "btn_con/fix_btn:obj",
  53. "btn_con/restore_btn:obj",
  54. }
  55. self:GetChildren(self.nodes)
  56. local select_callback = function(index)
  57. self:SwitchView(index)
  58. end
  59. local close_callback = function()
  60. self:Close()
  61. end
  62. self.tabWindowComponent = UITabWindow.New(self.transform,GameSettingView.TabData,select_callback,close_callback,self.background_wnd,
  63. nil,UITabWindow.SizeSmall,nil,nil,true)
  64. self.tabWindowComponent:SetTitleText("设置")
  65. end
  66. function GameSettingView:SwitchView(index)
  67. self.cur_index = index
  68. if self.cur_index == GameSettingModel.TabData.SYSYTEM then
  69. self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg")
  70. if self.basicSettingView == nil then
  71. self.basicSettingView = BasicSettingView.New(self.sub_conta)
  72. end
  73. self:PopUpChild(self.basicSettingView)
  74. self.basicSettingView:SetData()
  75. self.btn_con_obj:SetActive(true)
  76. elseif self.cur_index == GameSettingModel.TabData.BLOCK then
  77. self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg")
  78. if self.blockSettingView == nil then
  79. self.blockSettingView = BlockSettingView.New(self.sub_conta)
  80. end
  81. self:PopUpChild(self.blockSettingView)
  82. self.blockSettingView:SetData()
  83. self.btn_con_obj:SetActive(true)
  84. elseif self.cur_index == GameSettingModel.TabData.AUTO then
  85. self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg")
  86. if self.autoSettingView == nil then
  87. self.autoSettingView = AutoSettingView.New(self.sub_conta)
  88. end
  89. self:PopUpChild(self.autoSettingView)
  90. self.autoSettingView:SetData()
  91. self.btn_con_obj:SetActive(true)
  92. elseif self.cur_index == GameSettingModel.TabData.CUSTOM then
  93. self.tabWindowComponent:SetBackgroundRes("game_setting_bg_1")
  94. if self.serviceView == nil then
  95. self.serviceView = ServiceView.New(self.sub_conta)
  96. end
  97. self:PopUpChild(self.serviceView)
  98. self.serviceView:SetData()
  99. self.btn_con_obj:SetActive(false)
  100. end
  101. end
  102. function GameSettingView:InitEvent()
  103. local function onBtnClickHandler(target)
  104. if target == self.hook_btn_obj then
  105. self:Close()
  106. GlobalEventSystem:Fire(SceneEventType.SCREEN_BRIGHT_DEL_EVENT)
  107. elseif target == self.restore_btn_obj then
  108. local function Return()
  109. GameSettingModel:GetInstance():Fire(GameSettingModel.RETURN_ALL_DEFAULT,self.cur_index)
  110. end
  111. Alert.show("是否还原设置?",Alert.Type.Two,Return)
  112. elseif target == self.fix_btn_obj then
  113. -- local skill_state = MainUIModel:getInstance().state_right_bottom
  114. -- local skill_value = skill_state and skill_state.value or "nil"
  115. -- local task_state = MainUIModel:getInstance().state_task
  116. -- local task_value = task_state and task_state.value or "nil"
  117. -- local str = "skill_value = "..tostring(skill_value) .. ", task_value = ".. tostring(task_value)
  118. -- print("tanar: [GameSettingView 131]=> str: ",str)
  119. -- GameError.Instance:SendErrorMsg(str)
  120. local function ExitGameServer()
  121. if not SceneManager:getInstance():IsMainCityorYieldScene() then
  122. Message.show("请先退出副本再操作")
  123. return
  124. end
  125. LoginModel:getInstance():Fire(LoginModel.FORCE_EXIT_GAME_SERVER)
  126. end
  127. Alert.show("修复异常后,需要重新启动游戏才能生效", Alert.Type.Two, ExitGameServer, nil,"确定重启", "放弃修复")
  128. elseif target == self.backToLogin_btn_obj then
  129. if Scene.Instance.main_role:IsInState(PoseState.JUMP) or Scene.Instance.main_role:IsInState(PoseState.FLY)
  130. or Scene.Instance.main_role:IsInState(PoseState.JUMP_UP_HORSE) then
  131. return
  132. end
  133. local function ChangeRole()
  134. GlobalEventSystem:Fire(EventName.CHANGE_ROLE)
  135. end
  136. GlobalEventSystem:Fire(EventName.WANT_TO_CHANGE_ROLE)
  137. Alert.show("是否返回角色选择界面?",Alert.Type.Two,ChangeRole)
  138. elseif target == self.account_btn_obj then
  139. local function ChangeAccount()
  140. GlobalEventSystem:Fire(EventName.CHANGE_ACCOUNT)
  141. PlatformMgr:getInstance():LoginOut()
  142. end
  143. Alert.show("是否切换游戏账号?", Alert.Type.Two, ChangeAccount)
  144. end
  145. end
  146. AddClickEvent(self.hook_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
  147. AddClickEvent(self.restore_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
  148. AddClickEvent(self.fix_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
  149. AddClickEvent(self.backToLogin_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
  150. AddClickEvent(self.account_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
  151. end
  152. function GameSettingView:Remove()
  153. if self.basicSettingView then
  154. self.basicSettingView:DeleteMe()
  155. self.basicSettingView = nil
  156. end
  157. if self.blockSettingView then
  158. self.blockSettingView:DeleteMe()
  159. self.blockSettingView = nil
  160. end
  161. if self.autoSettingView then
  162. self.autoSettingView:DeleteMe()
  163. self.autoSettingView = nil
  164. end
  165. if self.serviceView then
  166. self.serviceView:DeleteMe()
  167. self.serviceView = nil
  168. end
  169. if self.tabWindowComponent then
  170. self.tabWindowComponent:DeleteMe()
  171. self.tabWindowComponent = nil
  172. end
  173. end