2025-04-01 10:48:36 +08:00
|
|
|
local SettingView = require("Game.View.SettingView")
|
|
|
|
|
local TableBG = require("Game.Data.TableBG")
|
|
|
|
|
local MJSettingViewNew = {
|
2025-07-25 22:17:17 +08:00
|
|
|
-- 修改牌
|
|
|
|
|
onUpdataCardCallback = nil
|
2025-04-01 10:48:36 +08:00
|
|
|
}
|
|
|
|
|
local M = MJSettingViewNew
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
local function IsRoomOwer()
|
|
|
|
|
--local roomOwner = self._room.player_list[1].self_user.account_id
|
|
|
|
|
local roomOwner = DataManager.CurrenRoom.player_list[1].self_user.account_id
|
|
|
|
|
return roomOwner == DataManager.SelfUser.account_id
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-31 16:54:29 +08:00
|
|
|
local function SaveClickMode(self)
|
|
|
|
|
Utils.SaveLocalFile("clickMode", json.encode(self._mainView.clickMode))
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
function M:Reflash()
|
|
|
|
|
if IsRoomOwer() then
|
|
|
|
|
self.cBtn.selectedIndex = 1
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-10 20:32:26 +08:00
|
|
|
if DataManager.CurrenRoom.playing or DataManager.CurrenRoom.curren_round > 0 then
|
2025-07-25 22:17:17 +08:00
|
|
|
self.cBtn.selectedIndex = 1
|
|
|
|
|
end
|
|
|
|
|
|
2025-08-28 15:02:07 +08:00
|
|
|
if self._flag_witness then
|
2025-07-25 22:17:17 +08:00
|
|
|
self.cBtn.selectedIndex = 0
|
|
|
|
|
end
|
2025-07-31 16:54:29 +08:00
|
|
|
|
|
|
|
|
if self._mainView.clickMode == "single" then
|
|
|
|
|
self.cBtnSelect.selectedIndex = 0
|
|
|
|
|
elseif self._mainView.clickMode == "double" then
|
|
|
|
|
self.cBtnSelect.selectedIndex = 1
|
|
|
|
|
end
|
2025-07-25 22:17:17 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Show()
|
|
|
|
|
BaseWindow.Show(self)
|
|
|
|
|
self:Reflash()
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-31 16:54:29 +08:00
|
|
|
function M:Close()
|
|
|
|
|
SaveClickMode(self)
|
|
|
|
|
BaseWindow.Close(self)
|
|
|
|
|
end
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
-- show_dialect是否显示'切换方言'选项
|
2025-07-25 22:17:17 +08:00
|
|
|
function MJSettingViewNew.new(blur_view, flag_witness)
|
|
|
|
|
setmetatable(SettingView, { __index = BaseWindow })
|
|
|
|
|
setmetatable(M, { __index = SettingView })
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
2025-04-01 10:48:36 +08:00
|
|
|
self.class = "MJSettingViewNew"
|
|
|
|
|
self._blur_view = blur_view
|
2025-07-25 22:17:17 +08:00
|
|
|
self._flag_witness = flag_witness
|
2025-04-01 10:48:36 +08:00
|
|
|
self.onCallback = event("onCallback", true)
|
2025-07-25 22:17:17 +08:00
|
|
|
self.onChangeCardCallback = event("onCallback", true)
|
2025-04-01 10:48:36 +08:00
|
|
|
self.onChangeLanguageCallback = event("onCallback", true)
|
2025-07-25 22:17:17 +08:00
|
|
|
self._mainView = blur_view
|
2025-09-10 20:32:26 +08:00
|
|
|
self._close_destroy = true
|
2025-07-25 22:17:17 +08:00
|
|
|
--[[
|
|
|
|
|
self._currenIndex = 0
|
2025-04-01 10:48:36 +08:00
|
|
|
self.stateIndex = 0
|
|
|
|
|
self.cd_time = 0
|
|
|
|
|
self._btn_dismiss_room_enable = true
|
|
|
|
|
self._full = true
|
|
|
|
|
self._anim_pop = 2
|
|
|
|
|
self._close_zone = true
|
|
|
|
|
self._show_dialect = show_dialect
|
|
|
|
|
self:init("ui://Main_Majiang/SettingWindow2")
|
2025-07-25 22:17:17 +08:00
|
|
|
]]
|
|
|
|
|
self._scale = true
|
|
|
|
|
self:init("ui://Main_Majiang/Setting")
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
return self
|
|
|
|
|
end
|
2025-07-25 22:17:17 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
function M:init(url)
|
2025-07-25 22:17:17 +08:00
|
|
|
BaseWindow.init(self, url)
|
|
|
|
|
|
2025-07-28 20:42:56 +08:00
|
|
|
self.btn_singleClick = self._view:GetChild("btn_singleClick")
|
|
|
|
|
self.btn_doubleClick = self._view:GetChild("btn_doubleClick")
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
self.slider_sound = self._view:GetChild('slider_vedio_sound')
|
|
|
|
|
self.slider_music = self._view:GetChild('slider_vedio_music')
|
|
|
|
|
|
|
|
|
|
self.btn_music = self._view:GetChild('btn_vedio_music')
|
|
|
|
|
self.btn_sound = self._view:GetChild('btn_vedio_sound')
|
|
|
|
|
self.btn_cancelRoom = self._view:GetChild("btn_cancelRoom")
|
|
|
|
|
self.btn_closeRoom = self._view:GetChild("btn_closeRoom")
|
|
|
|
|
|
2025-07-31 16:54:29 +08:00
|
|
|
self.cBtnSelect = self._view:GetController("cBtnSelect")
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
self.cBtn = self._view:GetController('cBtn')
|
|
|
|
|
|
2025-07-28 20:42:56 +08:00
|
|
|
|
|
|
|
|
self.btn_singleClick.onChanged:Set(function()
|
2025-07-31 16:54:29 +08:00
|
|
|
if self.btn_singleClick.selected then
|
|
|
|
|
self._mainView.clickMode = "single"
|
|
|
|
|
end
|
2025-07-28 20:42:56 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
self.btn_doubleClick.onChanged:Set(function()
|
2025-07-31 16:54:29 +08:00
|
|
|
if self.btn_doubleClick.selected then
|
|
|
|
|
self._mainView.clickMode = "double"
|
|
|
|
|
end
|
2025-07-28 20:42:56 +08:00
|
|
|
end)
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
self.slider_music.onChanged:Add(function()
|
2025-07-28 20:42:56 +08:00
|
|
|
GameApplication.Instance.MusicValue = self.slider_music.value
|
|
|
|
|
self.btn_music.selected = false
|
|
|
|
|
GameApplication.Instance.MusicMute = false;
|
2025-04-01 10:48:36 +08:00
|
|
|
end)
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
self.slider_sound.onChanged:Add(function()
|
2025-07-28 20:42:56 +08:00
|
|
|
GameApplication.Instance.SoundValue = self.slider_sound.value
|
|
|
|
|
self.btn_sound.selected = false
|
|
|
|
|
GameApplication.Instance.SoundMute = false;
|
2025-07-25 22:17:17 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
self.btn_sound.onClick:Add(function()
|
2025-07-28 20:42:56 +08:00
|
|
|
self.slider_sound.value = 0
|
|
|
|
|
GameApplication.Instance.SoundMute = self.btn_sound.selected;
|
2025-07-25 22:17:17 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
self.btn_music.onClick:Add(function()
|
2025-07-28 20:42:56 +08:00
|
|
|
self.slider_music.value = 0
|
|
|
|
|
GameApplication.Instance.MusicMute = self.btn_music.selected;
|
2025-07-25 22:17:17 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.btn_cancelRoom.onClick:Set(function()
|
|
|
|
|
if self._mainView.dismiss_room_cd_time > 0 then
|
|
|
|
|
ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!")
|
|
|
|
|
return
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
2025-07-25 22:17:17 +08:00
|
|
|
|
|
|
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
|
|
|
_gamectr:AskDismissRoom()
|
2025-04-01 10:48:36 +08:00
|
|
|
end)
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
self.btn_closeRoom.onClick:Set(function()
|
|
|
|
|
if self._flag_witness then
|
|
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
self._mainView._gamectr:ExitWitnessGame(_room.play_id, _room.game_id, _room.room_id)
|
2025-09-10 20:32:26 +08:00
|
|
|
self:Destroy()
|
2025-07-25 22:17:17 +08:00
|
|
|
ViewManager.ChangeView(ViewManager.View_Family)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
|
|
|
_gamectr:LevelRoom(function(res)
|
|
|
|
|
print("退出房间")
|
|
|
|
|
if res.ReturnCode ~= 0 then
|
|
|
|
|
ViewUtil.ErrorTip(res.ReturnCode)
|
|
|
|
|
return
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
2025-07-25 22:17:17 +08:00
|
|
|
ViewManager.ChangeView(ViewManager.View_Family)
|
2025-04-01 10:48:36 +08:00
|
|
|
end)
|
2025-07-25 22:17:17 +08:00
|
|
|
end)
|
2025-09-04 16:58:05 +08:00
|
|
|
|
2025-09-05 16:23:34 +08:00
|
|
|
local group = DataManager.groups:get(DataManager.CurrenRoom.group_id)
|
|
|
|
|
self._view:GetController('lev').selectedIndex = (group and group.lev and group.lev < 3) and 0 or 1
|
|
|
|
|
self._view:GetChild("btn_jiesan").onClick:Set(function()
|
|
|
|
|
local _curren_msg =
|
|
|
|
|
MsgWindow.new(
|
|
|
|
|
self._root_view,
|
|
|
|
|
'确定要解散该房间吗?',
|
|
|
|
|
MsgWindow.MsgMode.OkAndCancel
|
|
|
|
|
)
|
|
|
|
|
_curren_msg.onOk:Add(
|
|
|
|
|
function()
|
|
|
|
|
ViewUtil.ShowModalWait(self._root_view)
|
|
|
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
|
|
|
|
|
|
|
|
fgCtr:FG_RemoveRoom(
|
|
|
|
|
DataManager.CurrenRoom.group_id,
|
|
|
|
|
DataManager.CurrenRoom.room_id,
|
|
|
|
|
function(res)
|
|
|
|
|
if self._is_destroy then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
ViewUtil.CloseModalWait()
|
|
|
|
|
if res.ReturnCode ~= 0 then
|
|
|
|
|
ViewUtil.ErrorTip(res.ReturnCode, '删除房间失败!')
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
if self._flag_witness then
|
|
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
self._mainView._gamectr:ExitWitnessGame(_room.play_id, _room.game_id, _room.room_id)
|
|
|
|
|
ViewManager.ChangeView(ViewManager.View_Family)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
_curren_msg:Show()
|
2025-09-04 16:58:05 +08:00
|
|
|
end)
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
--[[
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
--赋值bg_config
|
|
|
|
|
function M:GetBGConfig()
|
|
|
|
|
return TableBG.GetBGConfig()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Change3d(mode,oldCardType)
|
|
|
|
|
|
|
|
|
|
local lst_bg = self._view:GetChild("lst_bg")
|
|
|
|
|
|
|
|
|
|
if mode == 2 then
|
|
|
|
|
|
|
|
|
|
local bg_id = self._view:GetController("bg").selectedIndex + 1
|
|
|
|
|
if self._bg ~= bg_id then
|
|
|
|
|
self._bg = bg_id
|
|
|
|
|
TableBG.SaveTableBG(self._game_id, self._bg)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i = 1, lst_bg.numChildren do
|
|
|
|
|
local item = lst_bg:GetChildAt(i - 1)
|
|
|
|
|
if item.data.id == 4 then
|
|
|
|
|
item.onClick:Call();
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
if oldCardType == 2 and DataManager.CurrenRoom.card_type ~= 2 then
|
|
|
|
|
for i = 1, lst_bg.numChildren do
|
|
|
|
|
local item = lst_bg:GetChildAt(i - 1)
|
|
|
|
|
if item.data.id == self._default_bg then
|
|
|
|
|
item.onClick:Call();
|
|
|
|
|
break
|
|
|
|
|
end
|
2025-07-25 22:17:17 +08:00
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local bg_id = self._view:GetController("bg").selectedIndex + 1
|
|
|
|
|
if self._bg ~= bg_id and bg_id ~= 4 then
|
|
|
|
|
self._bg = bg_id
|
|
|
|
|
TableBG.SaveTableBG(self._game_id, self._bg)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
bg_id = TableBG.GetTableBG(self._game_id)
|
|
|
|
|
if bg_id > 0 then
|
|
|
|
|
for i = 1, lst_bg.numChildren do
|
|
|
|
|
local item = lst_bg:GetChildAt(i - 1)
|
|
|
|
|
if item.data.id == bg_id then
|
|
|
|
|
item.onClick:Call();
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--赋值bg_config
|
|
|
|
|
function M:GetBGConfig()
|
|
|
|
|
return TableBG.GetBGConfig()
|
|
|
|
|
end
|
|
|
|
|
--获得背景方法
|
|
|
|
|
function M:GetBgByGameId(game_id)
|
|
|
|
|
return TableBG.GetTableBG(game_id)
|
|
|
|
|
end
|
|
|
|
|
--获得当前语言
|
|
|
|
|
function M:GetLanguage()
|
|
|
|
|
return PlayerPrefs.GetInt("Languauge" .. DataManager.CurrenRoom.game_id)
|
|
|
|
|
end
|
|
|
|
|
--保存选择的语言
|
|
|
|
|
function M:SaveLanguage(languauge)
|
|
|
|
|
PlayerPrefs.SetInt("Languauge" .. DataManager.CurrenRoom.game_id, languauge)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Show()
|
|
|
|
|
self:UpdateIndex()
|
|
|
|
|
SettingView.Show(self)
|
|
|
|
|
|
|
|
|
|
local ctr_card = self._view:GetController("card")
|
|
|
|
|
ctr_card.selectedIndex=0
|
|
|
|
|
|
|
|
|
|
local game_id = tostring(DataManager.CurrenRoom.game_id)
|
|
|
|
|
local ctr_cardIndex=0
|
|
|
|
|
|
|
|
|
|
local ct_data = nil
|
|
|
|
|
local json_data = Utils.LoadLocalFile("CardTypeData")
|
|
|
|
|
if json_data then
|
|
|
|
|
ct_data = json.decode(json_data)
|
|
|
|
|
if ct_data[game_id] then
|
|
|
|
|
ctr_cardIndex=ct_data[game_id]
|
|
|
|
|
else
|
|
|
|
|
ctr_cardIndex=0
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
ctr_cardIndex=0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ctr_card.selectedIndex=ctr_cardIndex
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
local list_cardtype = DataManager.CardTypeList
|
|
|
|
|
if DataManager.CurrenRoom then
|
2025-04-01 10:48:36 +08:00
|
|
|
list_cardtype[game_id] = ctr_cardIndex
|
|
|
|
|
Utils.SaveLocalFile("CardTypeData",json.encode(list_cardtype))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctr_card.onChanged:Set(function ()
|
|
|
|
|
|
|
|
|
|
if self.onChangeCardCallback then
|
|
|
|
|
local oldCardType = DataManager.CurrenRoom.card_type
|
|
|
|
|
DataManager.CurrenRoom.card_type = ctr_card.selectedIndex
|
|
|
|
|
self.onChangeCardCallback()
|
|
|
|
|
|
|
|
|
|
local cardtype = ctr_card.selectedIndex
|
2025-07-25 22:17:17 +08:00
|
|
|
local list_cardtype = DataManager.CardTypeList
|
|
|
|
|
if DataManager.CurrenRoom then
|
2025-04-01 10:48:36 +08:00
|
|
|
local game_id = tostring(DataManager.CurrenRoom.game_id)
|
2025-07-25 22:17:17 +08:00
|
|
|
if not list_cardtype[game_id] or list_cardtype[game_id] ~= cardtype then
|
2025-04-01 10:48:36 +08:00
|
|
|
list_cardtype[game_id] = cardtype
|
|
|
|
|
Utils.SaveLocalFile("CardTypeData",json.encode(list_cardtype))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self:Change3d(ctr_card.selectedIndex,oldCardType)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
local ctr_size = self._view:GetController("size")
|
|
|
|
|
local filename = 'mjsize' .. DataManager.SelfUser.account_id
|
|
|
|
|
local json_data = Utils.LoadLocalFile(filename)
|
|
|
|
|
if json_data then
|
|
|
|
|
local _data = json.decode(json_data)
|
|
|
|
|
if _data and _data.size then
|
|
|
|
|
ctr_size.selectedIndex=_data.size
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
ctr_size.selectedIndex=1
|
|
|
|
|
end
|
|
|
|
|
ctr_size.onChanged:Set(function ()
|
|
|
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
|
|
|
if _gamectr then
|
|
|
|
|
DispatchEvent(_gamectr._dispatcher,GameEvent.MJModifySzie,ctr_size.selectedIndex)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Change3DMode()
|
|
|
|
|
|
|
|
|
|
DataManager.CurrenRoom.card_type = 2
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
local list_cardtype = DataManager.CardTypeList
|
|
|
|
|
if DataManager.CurrenRoom then
|
2025-04-01 10:48:36 +08:00
|
|
|
local game_id = tostring(DataManager.CurrenRoom.game_id)
|
2025-07-25 22:17:17 +08:00
|
|
|
if not list_cardtype[game_id] or list_cardtype[game_id] ~= cardtype then
|
2025-04-01 10:48:36 +08:00
|
|
|
list_cardtype[game_id] = cardtype
|
|
|
|
|
Utils.SaveLocalFile("CardTypeData",json.encode(list_cardtype))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
TableBG.SaveTableBG(DataManager.CurrenRoom.game_id, 4)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function M:UpdateIndex()
|
|
|
|
|
local room = DataManager.CurrenRoom
|
|
|
|
|
local ctr_card = self._view:GetController("card")
|
|
|
|
|
ctr_card.selectedIndex = room.card_type
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
]]
|
|
|
|
|
|
|
|
|
|
return M
|