jxlast/lua_probject/extend_project/extend/majiang/lichuan/EXSettingView.lua

99 lines
3.0 KiB
Lua
Raw Normal View History

2025-11-14 23:38:35 +08:00
--设置窗口对象
local EXSettingView = {}
local M = EXSettingView
setmetatable(M, { __index = BaseWindow })
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)
local self = setmetatable({}, { __index = M })
self.class = 'EXSettingView'
self._close_destroy = true
self._mainView = main_view
self._flag_witness = flag_witness
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')
self.cBtn = self._view:GetController('cBtn')
slider_sound.value = GameApplication.Instance.SoundValue
slider_music.value = GameApplication.Instance.MusicValue
slider_music.onChanged:Add(function()
GameApplication.Instance.MusicValue = slider_music.value
btn_music.selected = false
GameApplication.Instance.MusicMute = false;
end)
slider_sound.onChanged:Add(function()
GameApplication.Instance.SoundValue = slider_sound.value
btn_sound.selected = false
GameApplication.Instance.SoundMute = false;
end)
btn_sound.onClick:Add(function()
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_cancelRoom')
_btn_logout.onClick:Set(function()
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)
else
if self._mainView.dismiss_room_cd_time > 0 then
ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!")
else
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:AskDismissRoom()
end
end
end)
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)
end
return M