hengyang_client/lua_probject/base_project/Game/View/NewGroup/GroupSetDefaultGameView.lua

110 lines
2.8 KiB
Lua

-- 牌友圈默认玩法设置界面
local GroupSetDefaultGameView = {}
local M = GroupSetDefaultGameView
function GroupSetDefaultGameView.new(gid, blur_view, callback)
setmetatable(M, { __index = BaseWindow })
local self = setmetatable({}, { __index = M })
self.class = "GroupSetDefaultGameView"
self._close_destroy = true
self.group_id = gid
self._blur_view = blur_view
self._callback = callback
local url = "ui://NewGroup/Win_SetDefaultGame"
self:init(url)
return self
end
function M:init(url)
BaseWindow.init(self, url)
end
function M:FillData(list, index, callbackFill)
self.callbackFill = callbackFill
self._index = index
local lst_game = self._view:GetChild("lst_game")
lst_game:RemoveChildrenToPool()
local playName = "playfaconfig" .. self.group_id
local json_data = Utils.LoadLocalFile(playName)
local localDataPlay = nil
if json_data then
localDataPlay = json.decode(json_data)
end
for i = 1, #list do
local tem = list[i]
local item = lst_game:AddItemFromPool()
item.title = tem.name
item.selected = index == i
local group = DataManager.groups:get(self.group_id)
local MarkSelect = item:GetChild("btn_select")
--if group.lev==1 then
-- MarkSelect.visible=true
--else
-- MarkSelect.visible=false
--end
MarkSelect.visible = true
if localDataPlay and localDataPlay[tostring(tem.id)] then
MarkSelect.selected = localDataPlay[tostring(tem.id)]
else
MarkSelect.selected = false
end
MarkSelect.onClick:Set(function()
self:MarkPlay(MarkSelect, tem.id, MarkSelect.selected)
end)
end
local btn_confirm = self._view:GetChild("btn_confirm")
btn_confirm.onClick:Set(function()
if self._callback then
self._callback(lst_game.selectedIndex + 1)
end
self:Destroy()
end)
end
function M:MarkPlay(markS, pid, isMark)
--[[local fgCtr = ControllerManager.GetController(NewGroupController)
ViewUtil.ShowModalWait2()
fgCtr:FG_MarkPlay(self.group_id, pid, isMark, function(res)
if self._is_destroy then
return
end
ViewUtil.CloseModalWait2()
if res.ReturnCode == 0 then
local group = DataManager.groups:get(self.group_id)
group:markPlay(pid, isMark)
if self.callbackFill then
self.callbackFill()
end
else
markS.selected=not isMark
ViewUtil.ErrorTip(res.ReturnCode,"设置失败,或已达设置上限")
end
end)--]]
if DataManager.SelfUser.PlayLocalList == nil then
DataManager.SelfUser.PlayLocalList = {}
end
DataManager.SelfUser.PlayLocalList[tostring(pid)] = isMark
--printlog("111111111122222222222223333333333333")
--pt(DataManager.SelfUser.PlayLocalList)
local playName = "playfaconfig" .. self.group_id
Utils.SaveLocalFile(playName, json.encode(DataManager.SelfUser.PlayLocalList))
if self.callbackFill then
self.callbackFill()
end
end
return M