yunque9/lua_probject/base_project/Game/View/NewGroup/GroupManagerView.lua

277 lines
9.6 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 牌友圈管理界面
local MngPageConfig = import(".MngView.MngPageConfig")
--做一个子类用来控制初始的统计界面
local GroupManagerStagView = import(".GroupManagerStagView")
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 = false
self._animation = false
self._blur_view = blur_view
self.group_id = gid
self.partnerList = {}
self.callback = callback
self._data_btn_type = btn_type
self:init(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(btn_type)
local url
if btn_type == 2 then
url = "ui://NewGroup/Win_ManagerView"
else
url = "ui://NewGroup/Win_ManagerView_old"
end
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.ctr_index = self._view:GetController("index")
self._ctr_tongji = self._view:GetController('tongji')
self.page_config = MngPageConfig.Config[btn_type][lev]
local gmsv
if btn_type == 2 then
--绑定统计代码
self._child_statView = GroupManagerStagView.new(self)
-- 初始界面 --战况是用新界面
local first_page_config = getPageConfig(19)
gmsv = first_page_config.view.new(self.group_id, self._root_view, self._child_statView._data_choosePlayer)
self._view_map = {}
self._view_map[#self.page_config + 1] = gmsv
gmsv.id = first_page_config.id
else
-- 初始界面
local first_page_config = getPageConfig(self.page_config[1])
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
end
-- 初始化标题列表
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
item:GetChild("title2").text = title
if i == 1 and btn_type ~= 2 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")
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.onChanged:Set(function(pas)
self._ctr_tongji.selectedIndex = 0
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 then
self.titleTxt.text = page_info.title
end
self._view_map[index + 1]:initData()
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
if self._data_btn_type == 2 then
self._child_statView:InitInfo()
end
printlog("index+1index+1index+1index+1 ", index + 1, self.page_config[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
if page_info then
self.titleTxt.text = page_info.title
end
self._view_map[index + 1]:initData()
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