77 lines
2.3 KiB
Lua
77 lines
2.3 KiB
Lua
local SettingView = require("Game.View.SettingView")
|
|
local TableBG = import(".MJTableBG")
|
|
|
|
local M = {}
|
|
|
|
function M.new(blur_view)
|
|
setmetatable(M, {__index = SettingView})
|
|
local self = setmetatable({}, {__index = M})
|
|
self.class = "MJSettingView"
|
|
self._blur_view = blur_view
|
|
self.onCallback = event("onCallback",true)
|
|
self.onChangeCardCallback = event("onCallback",true)
|
|
self._btn_dismiss_room_enable = true
|
|
self._close_destroy = true
|
|
self:init("ui://Main_Majiang/SettingWindow1")
|
|
return self
|
|
end
|
|
|
|
function M:init(url)
|
|
SettingView.init(self,url)
|
|
local ctr_card = self._view:GetController("card")
|
|
ctr_card.onChanged:Set(function ()
|
|
if self.onChangeCardCallback then
|
|
DataManager.CurrenRoom.card_type = ctr_card.selectedIndex
|
|
self.onChangeCardCallback()
|
|
|
|
local cardtype = ctr_card.selectedIndex
|
|
local list_cardtype = DataManager.CardTypeList
|
|
if DataManager.CurrenRoom then
|
|
local game_id = tostring(DataManager.CurrenRoom.game_id)
|
|
if not list_cardtype[game_id] or list_cardtype[game_id] ~= cardtype then
|
|
list_cardtype[game_id] = cardtype
|
|
Utils.SaveLocalFile("CardTypeData",json.encode(list_cardtype))
|
|
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:Show()
|
|
self:UpdateIndex()
|
|
SettingView.Show(self)
|
|
end
|
|
|
|
function M:Close()
|
|
-- local cardtype = self._view:GetController("card").selectedIndex
|
|
-- local list_cardtype = DataManager.CardTypeList
|
|
-- if DataManager.CurrenRoom then
|
|
-- local game_id = tostring(DataManager.CurrenRoom.game_id)
|
|
-- if not list_cardtype[game_id] or list_cardtype[game_id] ~= cardtype then
|
|
-- list_cardtype[game_id] = cardtype
|
|
-- Utils.SaveLocalFile("CardTypeData",json.encode(list_cardtype))
|
|
-- end
|
|
-- end
|
|
BaseWindow.Close(self)
|
|
end
|
|
|
|
function M:Destroy(remove_map)
|
|
BaseWindow.Destroy(self,remove_map)
|
|
end
|
|
|
|
function M:UpdateIndex()
|
|
local room = DataManager.CurrenRoom
|
|
local ctr_card = self._view:GetController("card")
|
|
ctr_card.selectedIndex = room.card_type
|
|
end
|
|
return M
|