75 lines
2.4 KiB
Lua
75 lines
2.4 KiB
Lua
--设置窗口对象
|
|
|
|
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/SettingWindow1')
|
|
return self
|
|
end
|
|
|
|
function M:init(url)
|
|
BaseWindow.init(self, url)
|
|
|
|
local view = self._view
|
|
local slider_sound = view:GetChild('slider_sound')
|
|
local slider_music = view:GetChild('slider_music')
|
|
local btn_music = view:GetChild('btn_music')
|
|
local btn_sound = view:GetChild('btn_sound')
|
|
|
|
|
|
btn_music.selected = (GameApplication.Instance.MusicValue < 5 and false or true)
|
|
slider_sound.value = GameApplication.Instance.SoundValue
|
|
slider_music.value = GameApplication.Instance.MusicValue
|
|
btn_sound.selected = GameApplication.Instance.SoundValue < 5 and false or true
|
|
|
|
btn_sound.icon = btn_sound.selected and 'ui://Common/on' or 'ui://Common/off'
|
|
btn_music.icon = btn_music.selected and 'ui://Common/on' or 'ui://Common/off'
|
|
slider_music.onChanged:Add(function()
|
|
GameApplication.Instance.MusicValue = slider_music.value
|
|
btn_music.selected = GameApplication.Instance.MusicValue < 5 and false or true
|
|
end)
|
|
|
|
slider_sound.onChanged:Add(function()
|
|
GameApplication.Instance.SoundValue = slider_sound.value
|
|
btn_sound.selected = GameApplication.Instance.SoundValue < 5 and false or true
|
|
end)
|
|
|
|
btn_sound.onChanged:Add(function()
|
|
GameApplication.Instance.SoundValue = btn_sound.selected and 50 or 0
|
|
slider_sound.value = GameApplication.Instance.SoundValue
|
|
btn_sound.icon = btn_sound.selected and 'ui://Common/on' or 'ui://Common/off'
|
|
end)
|
|
|
|
btn_music.onChanged:Add(function()
|
|
GameApplication.Instance.MusicValue = btn_music.selected and 50 or 0
|
|
slider_music.value = GameApplication.Instance.MusicValue
|
|
btn_music.icon = btn_music.selected and 'ui://Common/on' or 'ui://Common/off'
|
|
end)
|
|
|
|
|
|
local _btn_logout = self._view:GetChild('btn_del')
|
|
_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()
|
|
RestartGame()
|
|
end)
|
|
_curren_msg:Show()
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|