ruyi/fk101/lua_probject/base_project/Game/View/NewGroup/GroupManagerView.lua

249 lines
8.5 KiB
Lua
Raw Normal View History

2025-11-17 18:55:00 +08:00
-- 牌友圈管理界面
local MngPageConfig = import(".MngView.MngPageConfig")
local GroupManagerView = {}
local M = GroupManagerView
function GroupManagerView.new(blur_view, gid, btn_type, callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "GroupManagerView"
-- self._close_destroy = true
self._put_map = false
self._new_hide = false
self._queue = false
self._full = true
self._animation = false
self._blur_view = blur_view
self.group_id = gid
self.partnerList = {}
self.callback = callback
self:init("ui://NewGroup/Win_ManagerView", btn_type)
return self
end
-- 获取界面配置
local function getPageConfig(id)
--pt(MngPageConfig.PageList)
for i=1,#MngPageConfig.PageList do
local tem = MngPageConfig.PageList[i]
if tem.id == id then
return tem
end
end
end
function M:init(url, btn_type)
BaseWindow.init(self,url)
self.titleTxt = self._view:GetChild("n79")
-- if btn_type == 2 then
-- self._view:GetChild("n0"):GetChild("icon").url = "ui://m7iejg46p41ohx8"
-- elseif btn_type == 3 then
-- self._view:GetChild("n0"):GetChild("icon").url = "ui://m7iejg46p41ohx7"
-- elseif btn_type == 4 then
-- self._view:GetChild("n0"):GetChild("icon").url = "ui://m7iejg46p41ohx9"
-- end
local lst_index = self._view:GetChild("lst_index")
lst_index:RemoveChildrenToPool()
local group = DataManager.groups:get(self.group_id)
--根据玩家权限,加载不同的界面配置
local lev = group.lev
if lev == 3 and group.partnerLev == 0 then
lev = 4
end
self.page_config = MngPageConfig.Config[btn_type][lev]
-- 初始化标题列表
for i = 1, #self.page_config do
-- print("page_config:"..self.page_config[i])
local page = getPageConfig(self.page_config[i])
--如果界面无show_key或圈子中对应的key为true才显示界面
if not page.show_key or (page.show_key and group[page.show_key]) then
--如果allicance为ture则只有大联盟才显示界面
if (page.alliance and group.type == 2) or not page.alliance then
local item = lst_index:AddItemFromPool()
local title = page.title
item:GetChild("title").text = title
if i == 1 then
item.selected = true
end
end
end
end
-- coroutine.start(function()
-- coroutine.wait(0)
-- local anchor = self._view:GetChild("anchor")
-- -- 初始界面
-- local first_page_config = getPageConfig(self.page_config[1])
-- local gmsv = first_page_config.view.new(self.group_id, self._root_view)
-- self._view_map = {}
-- self._view_map[1] = gmsv
-- gmsv.id = first_page_config.id
-- anchor:AddChild(gmsv._view)
-- printlog("tttttttttttttttttttttt :" , gmsv._view.displayObject.gameObject.name," ",gmsv._view.parent.displayObject.gameObject.name)
-- -- gmsv._view:AddRelation(anchor, RelationType.Size)
-- local offset = get_offset(self._full_offset)
-- gmsv._view.width = GRoot.inst.width -300 - 2 * offset
-- gmsv._view.height = GRoot.inst.height
-- gmsv._view.x = offset
-- end)
-- 所有子界面加载点
local anchor = self._view:GetChild("anchor")
-- 初始界面
local first_page_config = getPageConfig(self.page_config[1])
local gmsv = first_page_config.view.new(self.group_id, self._root_view)
self._view_map = {}
self._view_map[1] = gmsv
gmsv.id = first_page_config.id
anchor:AddChild(gmsv._view)
--printlog("tttttttttttttttttttttt :" , gmsv._view.displayObject.gameObject.name," ",gmsv._view.parent.displayObject.gameObject.name)
--gmsv._view:AddRelation(anchor, RelationType.Size)
local offset = get_offset(self._full_offset)
gmsv._view.width = GRoot.inst.width - 2 * offset - first_page_config.anchorOffset
gmsv._view.height = GRoot.inst.height
gmsv._view.x = 0--offset
-- first_page_config = getPageConfig(self.page_config[2])
-- gmsv = first_page_config.view.new(self.group_id, self._root_view)
-- self._view_map[2] = gmsv
-- gmsv.id = first_page_config.id
-- gmsv._view.visible = false
-- anchor:AddChild(gmsv._view)
-- gmsv._view:AddRelation(anchor, RelationType.Size)
-- if first_page_config.refresh then gmsv:initData() end
-- if #self.page_config == 1 then
-- self._view:GetController("single").selectedIndex = 1
-- lst_index.visible = false
-- self._view:GetChild("n0"):GetController("v_menu").selectedIndex = 1
-- end
-- 切换界面
self.ctr_index = self._view:GetController("index")
self.ctr_index.onChanged:Set(function(pas)
local anchor = self._view:GetChild("anchor")
anchor:RemoveChildren()
local index = self.ctr_index.selectedIndex
local page_info = getPageConfig(self.page_config[index + 1])
if not self._view_map[index + 1] then
local tem = page_info.view.new(self.group_id, self._root_view)
-- anchor:AddRelation(self._root_view, RelationType.Size,true)
--tem._view:Center(true)
--print("222222222222222",anchor._view)
anchor:AddChild(tem._view)
-- tem._view.parent = anchor
local offset = get_offset(self._full_offset)
tem._view.width = GRoot.inst.width - 2 * offset - page_info.anchorOffset
tem._view.height = GRoot.inst.height
tem._view.x = 0--offset
--tem._view:AddRelation(self._root_view, RelationType.Size)
-- tem._view:MakeFullScreen()
tem.id = page_info.id
self._view_map[index + 1] = tem
--
-- anchor:SetBoundsChangedFlag()
-- anchor:EnsureBoundsCorrect()
-- tem._view:RemoveRelation(anchor, RelationType.Size)
--tem._view:AddRelation(anchor, RelationType.Size)
else
--self._view_map[index + 1]._view:AddRelation(anchor, RelationType.Size)
anchor:AddChild(self._view_map[index + 1]._view)
end
--self._view:AddRelation(anchor, RelationType.Size)
-- 如果refresh为true重新加载界面时执行初始化数据方法initData
if page_info.refresh then
self._view_map[index + 1]:initData()
end
self.titleTxt.text = page_info.title
end)
end
function M:SetCurrentGroupInfoViewIns(groupInfoViewCallBack)
self.groupInfoViewCallBack=groupInfoViewCallBack
end
-- 获取指定ID的页面
function M:GetPageByID(id)
for i, v in pairs(self._view_map) do
if v.id == id then
return v
end
end
return nil
end
-- 根据ID刷新页面
function M:RefreshPage(id)
local page = self:GetPageByID(id)
if not page then
return
end
page:initData()
end
function M:Close()
if self.callback then self.callback() end
BaseWindow.Close(self)
end
function M:Destroy()
for i = 1, #self.page_config do
if self._view_map[i] then
self._view_map[i]._view:Dispose()
if self._view_map[i].clear_image then
ImageLoad.Clear(self._view_map[i].class)
end
end
end
BaseWindow.Destroy(self)
end
-- quick_access_id 是快速访问标志打开对应id的页面
function M:Show(quick_access_id)
local index = self.ctr_index.selectedIndex
printlog("index+1index+1index+1index+1 ",index+1)
if not quick_access_id then
local page_info = getPageConfig(self.page_config[index + 1])
if page_info.refresh then self._view_map[index + 1]:initData() end
self.titleTxt.text = page_info.title
else
-- 如果是 快速访问
for i, v in pairs(self.page_config) do
if getPageConfig(v).id == quick_access_id then
self.ctr_index.selectedIndex = i - 1
if not self._view_map[i] then
local tem = page_info.view.new(self.group_id, self._root_view)
self._view_map[i] = tem
end
local anchor = self._view:GetChild("anchor")
anchor:AddChild(self._view_map[i]._view)
self._view_map[i]:navigation()
--self._view:AddRelation(anchor, RelationType.Size)
break
end
end
end
BaseWindow.Show(self)
end
return M