--设置窗口对象 local LobbySettingView = {} local M = LobbySettingView setmetatable(M, { __index = BaseWindow }) function LobbySettingView.new() local self = setmetatable({}, { __index = M }) self.class = 'SettingView' self._close_destroy = true self:init('ui://Lobby/Setting') return self end function M:init(url) BaseWindow.init(self, url) local view = self._view local slider_sound = view:GetChild('slider_vedio_sound') local slider_music = view:GetChild('slider_vedio_music') local btn_music = view:GetChild('btn_vedio_music') local btn_sound = view:GetChild('btn_vedio_sound') slider_sound.value = GameApplication.Instance.SoundValue slider_music.value = GameApplication.Instance.MusicValue btn_sound.selected = GameApplication.Instance.SoundMute btn_music.selected = GameApplication.Instance.MusicMute slider_music.onChanged:Add(function() local value = math.floor(slider_music.value) if value > 0 then btn_music.selected = false GameApplication.Instance.MusicMute = false; else btn_music.selected = true GameApplication.Instance.MusicMute = true; end GameApplication.Instance.MusicValue = value end) slider_sound.onChanged:Add(function() local value = math.floor(slider_sound.value) if value > 0 then btn_sound.selected = false GameApplication.Instance.SoundMute = false; else btn_sound.selected = true GameApplication.Instance.SoundMute = true; end GameApplication.Instance.SoundValue = value end) btn_sound.onClick:Add(function() if btn_sound.selected then local v = GameApplication.Instance.SoundValue slider_sound.value = 0 GameApplication.Instance.SoundValue = 0 PlayerPrefs.SetInt('sound', v) else local v = PlayerPrefs.GetInt('sound') slider_sound.value = v GameApplication.Instance.SoundValue = v end GameApplication.Instance.SoundMute = btn_sound.selected; end) btn_music.onClick:Add(function() GameApplication.Instance.MusicMute = btn_music.selected; end) local _btn_logout = self._view:GetChild('btn_switchAccount') _btn_logout.onClick:Set(function() local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel) _curren_msg.onOk:Add(function() -- PlayerPrefs.DeleteKey('session_id') -- PlayerPrefs.Save() local phone = "11" if DataManager.SelfUser.phone and #DataManager.SelfUser.phone == 11 then phone = DataManager.SelfUser.phone end PlayerPrefs.SetString("session_phone", phone) PlayerPrefs.Save() print("lingmeng log", phone) RestartGame() end) _curren_msg:Show() end) local btn_quit = view:GetChild('btn_exitAccount') btn_quit.onClick:Set( function() Application.Quit() end ) end return M