2025-12-29 20:14:45 +08:00
|
|
|
local FamilyGamePlayView = {}
|
|
|
|
|
|
|
|
|
|
local M = FamilyGamePlayView
|
|
|
|
|
|
|
|
|
|
function FamilyGamePlayView.new(data, callback)
|
|
|
|
|
setmetatable(M, { __index = BaseWindow })
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
|
self.class = "FamilyGamePlayView"
|
|
|
|
|
self._data = data or {}
|
|
|
|
|
self._callback = callback
|
|
|
|
|
self._close_destroy = true
|
|
|
|
|
self._full = true
|
|
|
|
|
self._full_offset = false
|
|
|
|
|
self:init("ui://Family/FamilyGamePlay")
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:init(url)
|
|
|
|
|
getmetatable(M).__index.init(self, url)
|
|
|
|
|
|
|
|
|
|
local view = self._view
|
|
|
|
|
self._viewList_left = view:GetChild('list_left')
|
|
|
|
|
self._viewList_left.itemRenderer = handler(self, self.GameTypeRenderer)
|
|
|
|
|
self._viewList_left.onClickItem:Set(handler(self, self.GameTypeClick))
|
|
|
|
|
|
|
|
|
|
self._viewComp_GameList = view:GetChild('page').component
|
|
|
|
|
self._viewList_GameList = self._viewComp_GameList:GetChild('list_left')
|
|
|
|
|
self._viewList_GameList.itemRenderer = handler(self, self.GameListRenderer)
|
|
|
|
|
self._viewList_GameList.onClickItem:Set(handler(self, self.GameListClick))
|
|
|
|
|
|
|
|
|
|
self.orderList = { { name = "麻将", list = {} }, { name = "扑克", list = {} }, { name = "字牌", list = {} } }
|
|
|
|
|
|
|
|
|
|
self._viewComp_GameList:GetChild('btn_confirm').onClick:Set(handler(self, self.ClickCreate))
|
|
|
|
|
|
|
|
|
|
self:FillData()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--创建玩法大分类--
|
|
|
|
|
function M:GameTypeRenderer(index, obj)
|
|
|
|
|
local info = self.orderList[index + 1]
|
|
|
|
|
obj:GetChild('text_down').text = info.name
|
|
|
|
|
obj:GetChild('text_up').text = info.name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:GameTypeClick(context)
|
|
|
|
|
self._viewList_GameList.numItems = #self.orderList[context.sender.selectedIndex + 1].list
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--玩法列表--
|
|
|
|
|
function M:GameListRenderer(index, obj)
|
|
|
|
|
local info = self.orderList[self._viewList_left.selectedIndex + 1].list[index + 1]
|
|
|
|
|
obj.text = info.name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:GameListClick(context)
|
|
|
|
|
local info = self.orderList[self._viewList_left.selectedIndex + 1].list[context.sender.selectedIndex + 1]
|
|
|
|
|
local mode = ExtendManager.GetExtendConfig(info.game_id):GetGameInfo()
|
|
|
|
|
ViewUtil.LoadPage(self._viewComp_GameList:GetChild('page'), mode:GetPageURL(), function(view)
|
|
|
|
|
mode._config = view
|
|
|
|
|
mode:FillData()
|
|
|
|
|
if self._data.playInfo then
|
|
|
|
|
mode:LoadConfigData(json.decode(self._data.playInfo.config))
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
--点击创建玩法
|
|
|
|
|
function M:ClickCreate()
|
|
|
|
|
ViewUtil.ShowModalWait2(self._root_view)
|
|
|
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
|
|
|
local group = DataManager.CurrenGroup
|
|
|
|
|
local info = self.orderList[self._viewList_left.selectedIndex + 1].list[self._viewList_GameList.selectedIndex + 1]
|
|
|
|
|
local mod = ExtendManager.GetExtendConfig(info.game_id):GetGameInfo()
|
|
|
|
|
local _data = mod:SelectedConfigData()
|
|
|
|
|
local hpData = mod:GetHpData()
|
|
|
|
|
_data.game_id = info.game_id
|
|
|
|
|
self.table_color = 0
|
|
|
|
|
local functionName = self._data.playInfo and fgCtr.FG_UpdatePlay or fgCtr.FG_AddPlay
|
2026-01-06 22:33:16 +08:00
|
|
|
local pid = self._data.playInfo and self._data.playInfo.id or 0
|
|
|
|
|
functionName(fgCtr, group.id, info.game_id, _data, info.name, hpData, 1,pid, group.type, self.table_color,
|
2025-12-29 20:14:45 +08:00
|
|
|
function(res)
|
|
|
|
|
if self._is_destroy then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
ViewUtil.CloseModalWait2()
|
|
|
|
|
|
|
|
|
|
if res.ReturnCode == 0 then
|
|
|
|
|
ViewUtil.ErrorTip(-1, "添加玩法成功")
|
|
|
|
|
if self._callback then
|
|
|
|
|
self._callback()
|
|
|
|
|
end
|
|
|
|
|
self:Destroy()
|
|
|
|
|
else
|
|
|
|
|
ViewUtil.ErrorTip(res.ReturnCode, "添加玩法失败!")
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:FillData()
|
|
|
|
|
local games = DataManager.SelfUser.games
|
|
|
|
|
local playInfo = self._data.playInfo
|
|
|
|
|
local selectType = 0
|
|
|
|
|
local selectGame = 0
|
|
|
|
|
local chooseGameId
|
|
|
|
|
if playInfo then
|
|
|
|
|
selectType = playInfo.gameType - 1
|
|
|
|
|
chooseGameId = playInfo.gameId
|
|
|
|
|
end
|
|
|
|
|
for i, v in ipairs(games) do
|
|
|
|
|
if chooseGameId == v.game_id then
|
|
|
|
|
selectGame = #self.orderList[v.gameType].list
|
|
|
|
|
end
|
|
|
|
|
table.insert(self.orderList[v.gameType].list, v)
|
|
|
|
|
end
|
|
|
|
|
self._viewList_left.numItems = #self.orderList
|
|
|
|
|
self._viewList_left.selectedIndex = selectType
|
|
|
|
|
self._viewList_GameList.numItems = #self.orderList[selectType + 1].list
|
|
|
|
|
self._viewList_GameList.selectedIndex = selectGame
|
|
|
|
|
if #self.orderList[selectType + 1].list > 0 then
|
|
|
|
|
self:GameListClick({ sender = { selectedIndex = selectGame } })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self:Show()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 打开窗口
|
|
|
|
|
function M:Show()
|
|
|
|
|
getmetatable(M).__index.Show(self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 关闭窗口
|
|
|
|
|
function M:Close()
|
|
|
|
|
getmetatable(M).__index.Close(self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 销毁窗口
|
|
|
|
|
function M:Destroy()
|
|
|
|
|
getmetatable(M).__index.Destroy(self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|