hengyang_client/lua_probject/extend_project/extend/majiang/jinxi/EXSettingView.lua

99 lines
3.0 KiB
Lua
Raw Normal View History

2025-04-21 18:55:46 +08:00
--设置窗口对象
local EXSettingView = {}
local M = EXSettingView
setmetatable(M, { __index = BaseWindow })
2025-07-10 01:52:55 +08:00
function EXSettingView:Show(room)
self._room = room
2025-07-10 03:14:40 +08:00
-- 房主,第一个进房间的人
local roomOwner = self._room.player_list[1].self_user.account_id
2025-07-10 01:52:55 +08:00
if roomOwner == DataManager.SelfUser.account_id then
self.cBtn.selectedIndex = 1
else
self.cBtn.selectedIndex = 0
end
BaseWindow.Show(self)
end
2025-08-28 19:15:06 +08:00
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-08-28 19:15:06 +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-10 01:52:55 +08:00
self.cBtn = self._view:GetController('cBtn')
2025-04-21 18:55:46 +08:00
-- 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)
2025-07-10 03:14:40 +08:00
local _btn_logout = self._view:GetChild('btn_cancelRoom')
2025-04-21 18:55:46 +08:00
_btn_logout.onClick:Set(function()
2025-08-28 19:15:06 +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-08-28 19:15:06 +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-10 01:52:55 +08:00
2025-08-28 19:15:06 +08:00
self._view:GetChild("btn_closeRoom").onClick:Set(function()
2025-07-10 01:52:55 +08:00
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:LevelRoom(function(res)
print("退出房间")
2025-07-10 03:14:40 +08:00
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode)
return
end
ViewManager.ChangeView(ViewManager.View_Family)
2025-07-10 01:52:55 +08:00
end)
end)
2025-04-21 18:55:46 +08:00
end
return M