121 lines
3.8 KiB
Lua
121 lines
3.8 KiB
Lua
|
|
--设置窗口对象
|
||
|
|
|
||
|
|
local CreatePlayView = {}
|
||
|
|
|
||
|
|
local M = CreatePlayView
|
||
|
|
setmetatable(M, { __index = BaseWindow })
|
||
|
|
|
||
|
|
local PlayInfo = {
|
||
|
|
{
|
||
|
|
gameName = "麻将",
|
||
|
|
playListInfo = {
|
||
|
|
|
||
|
|
},
|
||
|
|
playList = {
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function CreatePlayView.new()
|
||
|
|
UIPackage.AddPackage("base/Family/ui/Family")
|
||
|
|
|
||
|
|
local self = setmetatable({}, { __index = M })
|
||
|
|
self.class = 'CreatePlayView'
|
||
|
|
self._close_destroy = true
|
||
|
|
self:initePlayInfo()
|
||
|
|
self:init('ui://Family/CreatePlay')
|
||
|
|
return self
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:init(url)
|
||
|
|
BaseWindow.init(self, url)
|
||
|
|
|
||
|
|
local view = self._view
|
||
|
|
-----设置游戏类型------------
|
||
|
|
self.gameNameCtl = view:GetController('gameName')
|
||
|
|
local list_gameName = view:GetChild('list_gameName')
|
||
|
|
list_gameName:SetVirtual()
|
||
|
|
list_gameName.itemRenderer = function(index, obj)
|
||
|
|
obj:GetChild('title').text = PlayInfo[index + 1].gameName
|
||
|
|
end
|
||
|
|
-- list_gameName.onClickItem:Add()
|
||
|
|
list_gameName.numItems = #PlayInfo
|
||
|
|
list_gameName:GetChildAt(0):GetController('button').selectedIndex = 1
|
||
|
|
-----------设置游戏名称-------------------
|
||
|
|
self.playNameCtr = view:GetController('playName')
|
||
|
|
local list_playName = view:GetChild('list_playName')
|
||
|
|
list_playName:SetVirtual()
|
||
|
|
list_playName.itemRenderer = function(index, obj)
|
||
|
|
obj:GetChild('title').text = PlayInfo[1].playList[index + 1].playName
|
||
|
|
end
|
||
|
|
list_playName.onClickItem:Add(function()
|
||
|
|
self.showView.visible = false
|
||
|
|
local index = PlayInfo[1].playList[self.playNameCtr.selectedIndex + 1].playeId
|
||
|
|
local playDetail = view:GetChild(string.format("Label_Detail_%d",index))
|
||
|
|
local playView
|
||
|
|
if not playDetail then
|
||
|
|
playDetail = UIPackage.CreateObjectFromURL(string.format("ui//Family/Label_Detail_%d",index))
|
||
|
|
if playDetail then
|
||
|
|
playView = view:AddChild(playDetail)
|
||
|
|
playView.name = string.format("Label_Detail_%d",index)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
if not playDetail then
|
||
|
|
view:GetChild('buttom').visible = false
|
||
|
|
else
|
||
|
|
view:GetChild('buttom').visible = true
|
||
|
|
self.showView = playView and playView or playDetail
|
||
|
|
self.showView.visible = true
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
list_playName.numItems = #PlayInfo[1].playList
|
||
|
|
list_playName:GetChildAt(0):GetController('button').selectedIndex = 1
|
||
|
|
self.showView = view:GetChild(string.format("Label_Detail_%d",
|
||
|
|
PlayInfo[1].playList[self.playNameCtr.selectedIndex + 1].playeId))
|
||
|
|
-----------创建玩法----------
|
||
|
|
view:GetChild('btn_Create').onClick:Add(function()
|
||
|
|
self:CreatePlay()
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:CreatePlay()
|
||
|
|
ViewUtil.ShowModalWait(self._root_view,"正在创建房间...")
|
||
|
|
local loddyCtr = ControllerManager.GetController(LoddyController)
|
||
|
|
local gameId = PlayInfo[1].playList[self.playNameCtr.selectedIndex+1].playeId
|
||
|
|
local config = ExtendManager.GetExtendConfig(gameId)
|
||
|
|
print("==============================config")
|
||
|
|
pt(config)
|
||
|
|
local mode = config:GetGameInfo()
|
||
|
|
print("==============================mode")
|
||
|
|
pt(mode)
|
||
|
|
local _data = mode:SelectedConfigData()
|
||
|
|
print("==============================_data")
|
||
|
|
pt(_data)
|
||
|
|
-- loddyCtr:CreateRoom(gameId,_data, function (res)
|
||
|
|
-- self:__OnCreateRoomAction(res)
|
||
|
|
-- end)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:initePlayInfo()
|
||
|
|
--------测试
|
||
|
|
PlayInfo[1].playListInfo[10] = {
|
||
|
|
playeId = 10,
|
||
|
|
playName = "长沙麻将"
|
||
|
|
}
|
||
|
|
PlayInfo[1].playListInfo[86] = {
|
||
|
|
playeId = 86,
|
||
|
|
playName = "南城麻将"
|
||
|
|
}
|
||
|
|
local games = DataManager.SelfUser.games
|
||
|
|
for i = 1, #games do
|
||
|
|
if PlayInfo[1].playListInfo[games[i].game_id] then
|
||
|
|
table.insert(PlayInfo[1].playList,PlayInfo[1].playListInfo[games[i].game_id])
|
||
|
|
end
|
||
|
|
end
|
||
|
|
pt(PlayInfo)
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|