2025-04-21 18:55:46 +08:00
|
|
|
--设置窗口对象
|
|
|
|
|
|
|
|
|
|
local EXSettingView = {}
|
|
|
|
|
|
|
|
|
|
local M = EXSettingView
|
|
|
|
|
setmetatable(M, { __index = BaseWindow })
|
|
|
|
|
|
2025-07-21 21:44:50 +08:00
|
|
|
function EXSettingView:Show(room)
|
|
|
|
|
self._room = room
|
|
|
|
|
|
|
|
|
|
-- 房主,第一个进房间的人
|
|
|
|
|
local roomOwner = self._room.player_list[1].self_user.account_id
|
|
|
|
|
|
|
|
|
|
if roomOwner == DataManager.SelfUser.account_id then
|
|
|
|
|
self.cBtn.selectedIndex = 1
|
|
|
|
|
else
|
|
|
|
|
self.cBtn.selectedIndex = 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
BaseWindow.Show(self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EXSettingView.new(main_view, flag_witness)
|
2025-04-21 18:55:46 +08:00
|
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
|
self.class = 'EXSettingView'
|
|
|
|
|
self._close_destroy = true
|
|
|
|
|
self._mainView = main_view
|
2025-07-21 21:44:50 +08:00
|
|
|
self._flag_witness = flag_witness
|
2025-04-21 18:55:46 +08:00
|
|
|
self:init('ui://Main_Majiang/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')
|
|
|
|
|
|
2025-07-21 21:44:50 +08:00
|
|
|
self.cBtn = self._view:GetController('cBtn')
|
|
|
|
|
|
2025-09-09 14:58:47 +08:00
|
|
|
slider_sound.value = GameApplication.Instance.SoundValue
|
|
|
|
|
slider_music.value = GameApplication.Instance.MusicValue
|
2025-04-21 18:55:46 +08:00
|
|
|
|
|
|
|
|
slider_music.onChanged:Add(function()
|
2025-09-09 14:58:47 +08:00
|
|
|
GameApplication.Instance.MusicValue = slider_music.value
|
|
|
|
|
btn_music.selected = false
|
|
|
|
|
GameApplication.Instance.MusicMute = false;
|
2025-04-21 18:55:46 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
slider_sound.onChanged:Add(function()
|
2025-09-09 14:58:47 +08:00
|
|
|
GameApplication.Instance.SoundValue = slider_sound.value
|
|
|
|
|
btn_sound.selected = false
|
|
|
|
|
GameApplication.Instance.SoundMute = false;
|
2025-04-21 18:55:46 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
btn_sound.onClick:Add(function()
|
2025-09-09 14:58:47 +08:00
|
|
|
GameApplication.Instance.SoundMute = btn_sound.selected;
|
2025-04-21 18:55:46 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
btn_music.onClick:Add(function()
|
2025-09-09 14:58:47 +08:00
|
|
|
GameApplication.Instance.MusicMute = btn_music.selected;
|
2025-04-21 18:55:46 +08:00
|
|
|
end)
|
|
|
|
|
|
2025-07-21 21:44:50 +08:00
|
|
|
local _btn_logout = self._view:GetChild('btn_cancelRoom')
|
2025-04-21 18:55:46 +08:00
|
|
|
_btn_logout.onClick:Set(function()
|
2025-07-21 21:44:50 +08:00
|
|
|
if self._flag_witness then
|
|
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
pt(_room)
|
|
|
|
|
self._mainView._gamectr:ExitWitnessGame(_room.play_id, _room.game_id,
|
|
|
|
|
_room.room_id)
|
|
|
|
|
ViewManager.ChangeView(ViewManager.View_Family)
|
2025-04-21 18:55:46 +08:00
|
|
|
else
|
2025-07-21 21:44:50 +08:00
|
|
|
if self._mainView.dismiss_room_cd_time > 0 then
|
|
|
|
|
ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!")
|
|
|
|
|
else
|
|
|
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
|
|
|
_gamectr:AskDismissRoom()
|
|
|
|
|
end
|
2025-04-21 18:55:46 +08:00
|
|
|
end
|
|
|
|
|
end)
|
2025-07-21 21:44:50 +08:00
|
|
|
|
|
|
|
|
self._view:GetChild("btn_closeRoom").onClick:Set(function()
|
|
|
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
|
|
|
_gamectr:LevelRoom(function(res)
|
|
|
|
|
print("退出房间")
|
|
|
|
|
if res.ReturnCode ~= 0 then
|
|
|
|
|
ViewUtil.ErrorTip(res.ReturnCode)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
ViewManager.ChangeView(ViewManager.View_Family)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
2025-04-21 18:55:46 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|