|
|
- GameSettingView = GameSettingView or BaseClass(BaseView)
-
- GameSettingView.TabData = {
- {id = GameSettingModel.TabData.SYSYTEM, name = "系统",module_id = 102, sub_id = 0},
- {id = GameSettingModel.TabData.BLOCK, name = "屏蔽",module_id = 102, sub_id = 0},
- {id = GameSettingModel.TabData.AUTO, name = "挂机",module_id = 102, sub_id = 0},
- {id = GameSettingModel.TabData.CUSTOM, name = "客服",module_id = 102, sub_id = 0},
- }
-
- function GameSettingView:__init()
- self.base_file = "setting" --资源目录
- self.layout_file = "SettingView" --资源名称
- self.layer_name = "UI" --弹出目录
- self.model = GameSettingModel:GetInstance()
-
- self.blur_activity_bg = true
- self.use_show_anim = true
- self.use_hide_anim = true
-
- self.open_guide_close = true
- --初始化面板的基本属性
- self.close_mode = CloseMode.CloseDestroy --关闭模式为销毁
- self.destroy_imm = true; --销毁窗口模式为立即销毁
- self.use_background = true --使用背景
- self.hide_maincancas = false
- -- --背景透明度
- self.append_to_ctl_queue = true --添加到控制队列
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:InitEvent()
- end
-
- self.open_callback = function()
- self.tabWindowComponent:SetTabBarIndex(self.cur_index)
- end
-
- self.close_callback = function()
- lua_settingM:ApplyMonsterVisibleState()
- lua_settingM:ApplyPlayerCounts()
- lua_settingM:ApplySceneEffect()
- CookieWrapper.Instance:WriteAll()
- end
-
- self.destroy_callback = function ()
- self:Remove()
- end
- end
-
- function GameSettingView:Open(index)
- self.cur_index = index or 1
- BaseView.Open(self)
- end
-
- function GameSettingView:LoadSuccess()
- self.sub_conta = self:GetChild("sub_conta")
-
- self.nodes = {
- "btn_con:obj",
- "btn_con/hook_btn:obj",
- "btn_con/account_btn:obj",
- "btn_con/backToLogin_btn:obj",
- "btn_con/fix_btn:obj",
- "btn_con/restore_btn:obj",
- }
- self:GetChildren(self.nodes)
-
- local select_callback = function(index)
- self:SwitchView(index)
- end
- local close_callback = function()
- self:Close()
- end
-
- self.tabWindowComponent = UITabWindow.New(self.transform,GameSettingView.TabData,select_callback,close_callback,self.background_wnd,
- nil,UITabWindow.SizeSmall,nil,nil,true)
- self.tabWindowComponent:SetTitleText("设置")
- end
-
- function GameSettingView:SwitchView(index)
- self.cur_index = index
- if self.cur_index == GameSettingModel.TabData.SYSYTEM then
- self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg")
- if self.basicSettingView == nil then
- self.basicSettingView = BasicSettingView.New(self.sub_conta)
- end
- self:PopUpChild(self.basicSettingView)
- self.basicSettingView:SetData()
- self.btn_con_obj:SetActive(true)
- elseif self.cur_index == GameSettingModel.TabData.BLOCK then
- self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg")
- if self.blockSettingView == nil then
- self.blockSettingView = BlockSettingView.New(self.sub_conta)
- end
- self:PopUpChild(self.blockSettingView)
- self.blockSettingView:SetData()
- self.btn_con_obj:SetActive(true)
- elseif self.cur_index == GameSettingModel.TabData.AUTO then
- self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg")
- if self.autoSettingView == nil then
- self.autoSettingView = AutoSettingView.New(self.sub_conta)
- end
- self:PopUpChild(self.autoSettingView)
- self.autoSettingView:SetData()
- self.btn_con_obj:SetActive(true)
- elseif self.cur_index == GameSettingModel.TabData.CUSTOM then
- self.tabWindowComponent:SetBackgroundRes("game_setting_bg_1")
- if self.serviceView == nil then
- self.serviceView = ServiceView.New(self.sub_conta)
- end
- self:PopUpChild(self.serviceView)
- self.serviceView:SetData()
- self.btn_con_obj:SetActive(false)
- end
- end
-
- function GameSettingView:InitEvent()
- local function onBtnClickHandler(target)
- if target == self.hook_btn_obj then
- self:Close()
- GlobalEventSystem:Fire(SceneEventType.SCREEN_BRIGHT_DEL_EVENT)
- elseif target == self.restore_btn_obj then
- local function Return()
- GameSettingModel:GetInstance():Fire(GameSettingModel.RETURN_ALL_DEFAULT,self.cur_index)
- end
- Alert.show("是否还原设置?",Alert.Type.Two,Return)
- elseif target == self.fix_btn_obj then
- -- local skill_state = MainUIModel:getInstance().state_right_bottom
- -- local skill_value = skill_state and skill_state.value or "nil"
- -- local task_state = MainUIModel:getInstance().state_task
- -- local task_value = task_state and task_state.value or "nil"
- -- local str = "skill_value = "..tostring(skill_value) .. ", task_value = ".. tostring(task_value)
- -- print("tanar: [GameSettingView 131]=> str: ",str)
- -- GameError.Instance:SendErrorMsg(str)
- local function ExitGameServer()
- if not SceneManager:getInstance():IsMainCityorYieldScene() then
- Message.show("请先退出副本再操作")
- return
- end
- LoginModel:getInstance():Fire(LoginModel.FORCE_EXIT_GAME_SERVER)
- end
- Alert.show("修复异常后,需要重新启动游戏才能生效", Alert.Type.Two, ExitGameServer, nil,"确定重启", "放弃修复")
- elseif target == self.backToLogin_btn_obj then
- if Scene.Instance.main_role:IsInState(PoseState.JUMP) or Scene.Instance.main_role:IsInState(PoseState.FLY)
- or Scene.Instance.main_role:IsInState(PoseState.JUMP_UP_HORSE) then
- return
- end
- local function ChangeRole()
- GlobalEventSystem:Fire(EventName.CHANGE_ROLE)
- end
- GlobalEventSystem:Fire(EventName.WANT_TO_CHANGE_ROLE)
- Alert.show("是否返回角色选择界面?",Alert.Type.Two,ChangeRole)
- elseif target == self.account_btn_obj then
- local function ChangeAccount()
- GlobalEventSystem:Fire(EventName.CHANGE_ACCOUNT)
- PlatformMgr:getInstance():LoginOut()
- end
- Alert.show("是否切换游戏账号?", Alert.Type.Two, ChangeAccount)
- end
- end
- AddClickEvent(self.hook_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
- AddClickEvent(self.restore_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
- AddClickEvent(self.fix_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
- AddClickEvent(self.backToLogin_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
- AddClickEvent(self.account_btn_obj,onBtnClickHandler,LuaSoundManager.SOUND_UI.NONE)
- end
-
- function GameSettingView:Remove()
- if self.basicSettingView then
- self.basicSettingView:DeleteMe()
- self.basicSettingView = nil
- end
-
- if self.blockSettingView then
- self.blockSettingView:DeleteMe()
- self.blockSettingView = nil
- end
-
- if self.autoSettingView then
- self.autoSettingView:DeleteMe()
- self.autoSettingView = nil
- end
-
- if self.serviceView then
- self.serviceView:DeleteMe()
- self.serviceView = nil
- end
-
- if self.tabWindowComponent then
- self.tabWindowComponent:DeleteMe()
- self.tabWindowComponent = nil
- end
- end
-
|