master
parent
c1c3d3ca76
commit
78057035d4
|
|
@ -2,31 +2,33 @@
|
|||
--author:--
|
||||
|
||||
BaseWindow = {
|
||||
--view description
|
||||
_view = nil,
|
||||
--view description
|
||||
_view = nil,
|
||||
|
||||
--View 是否被销毁
|
||||
_is_destroy = false,
|
||||
--是否播放动画
|
||||
_animation = true,
|
||||
--弹出动画,0关闭,1左边,2右边
|
||||
_anim_pop = 0,
|
||||
--关闭摧毁
|
||||
_close_destroy = false,
|
||||
--View 是否被销毁
|
||||
_is_destroy = false,
|
||||
--是否播放动画
|
||||
_animation = true,
|
||||
--弹出动画,0关闭,1左边,2右边
|
||||
_anim_pop = 0,
|
||||
--关闭摧毁
|
||||
_close_destroy = false,
|
||||
|
||||
--点击窗口以外关闭
|
||||
_close_zone = true,
|
||||
--点击窗口以外关闭
|
||||
_close_zone = true,
|
||||
|
||||
--队列
|
||||
_queue = true,
|
||||
--全屏
|
||||
_full = false,
|
||||
--全屏偏移
|
||||
_full_offset = true,
|
||||
--新窗口隐藏队列
|
||||
_new_hide = true,
|
||||
--模糊组件对象
|
||||
_put_map = true
|
||||
--队列
|
||||
_queue = true,
|
||||
--全屏
|
||||
_full = false,
|
||||
--缩放全屏
|
||||
_scale = false,
|
||||
--全屏偏移
|
||||
_full_offset = true,
|
||||
--新窗口隐藏队列
|
||||
_new_hide = true,
|
||||
--模糊组件对象
|
||||
_put_map = true
|
||||
}
|
||||
|
||||
--window 列表
|
||||
|
|
@ -41,216 +43,223 @@ local WindowQueue = {
|
|||
local M = BaseWindow
|
||||
|
||||
function BaseWindow.new(url, blur_view)
|
||||
local self = setmetatable({}, { __index = M })
|
||||
self.class = "BaseWindow"
|
||||
-- self._blur_view = blur_view
|
||||
self:init(url)
|
||||
return self
|
||||
local self = setmetatable({}, { __index = M })
|
||||
self.class = "BaseWindow"
|
||||
-- self._blur_view = blur_view
|
||||
self:init(url)
|
||||
return self
|
||||
end
|
||||
|
||||
local win_url = {
|
||||
"ui://Common/Gcm_Window",
|
||||
"ui://Common/Gcm_Window_Full"
|
||||
"ui://Common/Gcm_Window",
|
||||
"ui://Common/Gcm_Window_Full"
|
||||
}
|
||||
|
||||
function M:init(url)
|
||||
self._root_view = UIPackage.CreateObjectFromURL(self._full and win_url[2] or win_url[1])
|
||||
local contentPane = self._root_view:GetChild("contentPane")
|
||||
local ctr_hide_bg = self._root_view:GetController("hide_bg")
|
||||
if self._anim_pop ~= 0 then
|
||||
ctr_hide_bg.selectedIndex = 1
|
||||
PopPanel = contentPane:GetChild("PopPanel")
|
||||
else
|
||||
ctr_hide_bg.selectedIndex = 0
|
||||
end
|
||||
printlog(url)
|
||||
self._view = UIPackage.CreateObjectFromURL(url)
|
||||
printlog(self._view)
|
||||
-- self._view.fairyBatching = true
|
||||
local btn_close = self._view:GetChild("btn_close")
|
||||
if (btn_close) then
|
||||
btn_close.onClick:Set(function()
|
||||
self:CloseEvent()
|
||||
end)
|
||||
end
|
||||
self._root_view = UIPackage.CreateObjectFromURL(self._full and win_url[2] or win_url[1])
|
||||
local contentPane = self._root_view:GetChild("contentPane")
|
||||
local ctr_hide_bg = self._root_view:GetController("hide_bg")
|
||||
if self._anim_pop ~= 0 then
|
||||
ctr_hide_bg.selectedIndex = 1
|
||||
PopPanel = contentPane:GetChild("PopPanel")
|
||||
else
|
||||
ctr_hide_bg.selectedIndex = 0
|
||||
end
|
||||
printlog(url)
|
||||
self._view = UIPackage.CreateObjectFromURL(url)
|
||||
printlog(self._view)
|
||||
-- self._view.fairyBatching = true
|
||||
local btn_close = self._view:GetChild("btn_close")
|
||||
if (btn_close) then
|
||||
btn_close.onClick:Set(function()
|
||||
self:CloseEvent()
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local win_mode = self._root_view:GetChild("win_mode")
|
||||
win_mode.onClick:Set(function()
|
||||
if not self._close_zone then
|
||||
return
|
||||
end
|
||||
win_mode.touchable = false
|
||||
self:CloseEvent()
|
||||
end)
|
||||
printlog("======================================", self._full)
|
||||
if self._full then
|
||||
local offset = get_offset(self._full_offset)
|
||||
if self._anim_pop == 0 then
|
||||
self._view:AddRelation(contentPane, RelationType.Size)
|
||||
contentPane:AddChild(self._view)
|
||||
else
|
||||
contentPane:RemoveRelation(self._root_view, RelationType.Center_Center)
|
||||
contentPane:AddRelation(self._root_view, RelationType.Middle_Middle)
|
||||
PopPanel:AddChild(self._view)
|
||||
local click_item = PopPanel:GetChild("click_item")
|
||||
if self._anim_pop == 1 then
|
||||
contentPane:AddRelation(self._root_view, RelationType.Left_Left)
|
||||
self._view.x = 0
|
||||
elseif self._anim_pop == 2 then
|
||||
contentPane:AddRelation(self._root_view, RelationType.Right_Right)
|
||||
self._view.x = GRoot.inst.width - self._view.width - offset
|
||||
end
|
||||
print("lingmeng", PopPanel.height, self._view.height)
|
||||
self._view.y = (PopPanel.height - self._view.height) * 0.5
|
||||
click_item.xy = self._view.xy
|
||||
click_item.width = self._view.width
|
||||
click_item.height = self._view.height
|
||||
end
|
||||
else
|
||||
contentPane:AddChild(self._view)
|
||||
contentPane.height = self._view.height
|
||||
contentPane.width = self._view.width
|
||||
contentPane:Center()
|
||||
end
|
||||
self._contentPane = contentPane
|
||||
if self._put_map then
|
||||
WindowMap[#WindowMap + 1] = self
|
||||
end
|
||||
local win_mode = self._root_view:GetChild("win_mode")
|
||||
win_mode.onClick:Set(function()
|
||||
if not self._close_zone then
|
||||
return
|
||||
end
|
||||
win_mode.touchable = false
|
||||
self:CloseEvent()
|
||||
end)
|
||||
printlog("======================================", self._full)
|
||||
if self._full then
|
||||
local offset = get_offset(self._full_offset)
|
||||
if self._anim_pop == 0 then
|
||||
self._view:AddRelation(contentPane, RelationType.Size)
|
||||
contentPane:AddChild(self._view)
|
||||
else
|
||||
contentPane:RemoveRelation(self._root_view, RelationType.Center_Center)
|
||||
contentPane:AddRelation(self._root_view, RelationType.Middle_Middle)
|
||||
PopPanel:AddChild(self._view)
|
||||
local click_item = PopPanel:GetChild("click_item")
|
||||
if self._anim_pop == 1 then
|
||||
contentPane:AddRelation(self._root_view, RelationType.Left_Left)
|
||||
self._view.x = 0
|
||||
elseif self._anim_pop == 2 then
|
||||
contentPane:AddRelation(self._root_view, RelationType.Right_Right)
|
||||
self._view.x = GRoot.inst.width - self._view.width - offset
|
||||
end
|
||||
print("lingmeng", PopPanel.height, self._view.height)
|
||||
self._view.y = (PopPanel.height - self._view.height) * 0.5
|
||||
click_item.xy = self._view.xy
|
||||
click_item.width = self._view.width
|
||||
click_item.height = self._view.height
|
||||
end
|
||||
else
|
||||
contentPane:AddChild(self._view)
|
||||
contentPane.height = self._view.height
|
||||
contentPane.width = self._view.width
|
||||
contentPane:Center()
|
||||
end
|
||||
self._contentPane = contentPane
|
||||
if self._put_map then
|
||||
WindowMap[#WindowMap + 1] = self
|
||||
end
|
||||
end
|
||||
|
||||
-- 显示窗口
|
||||
function M:Show()
|
||||
-- print("===========================================entershow",M.class)
|
||||
local contentPane = self._root_view:GetChild("contentPane")
|
||||
if self._anim_pop == 1 then
|
||||
contentPane:GetTransition("left_pop"):Play()
|
||||
elseif self._anim_pop == 2 then
|
||||
contentPane:GetTransition("right_pop"):Play()
|
||||
elseif self._animation then
|
||||
local ani_in = self._root_view:GetTransition("in")
|
||||
if ani_in then
|
||||
ani_in:Play()
|
||||
end
|
||||
end
|
||||
-- if self._blur_view then
|
||||
-- BlurView(self._blur_view,true)
|
||||
-- end
|
||||
-- print("===========================================entershow",M.class)
|
||||
local contentPane = self._root_view:GetChild("contentPane")
|
||||
if self._anim_pop == 1 then
|
||||
contentPane:GetTransition("left_pop"):Play()
|
||||
elseif self._anim_pop == 2 then
|
||||
contentPane:GetTransition("right_pop"):Play()
|
||||
elseif self._animation then
|
||||
local ani_in = self._root_view:GetTransition("in")
|
||||
if ani_in then
|
||||
ani_in:Play()
|
||||
end
|
||||
end
|
||||
-- if self._blur_view then
|
||||
-- BlurView(self._blur_view,true)
|
||||
-- end
|
||||
|
||||
-- 判断当前窗口是否已经在队列中,如果在就不重复添加
|
||||
local _inQueue = false
|
||||
-- 判断当前窗口是否已经在队列中,如果在就不重复添加
|
||||
local _inQueue = false
|
||||
|
||||
if self._new_hide then
|
||||
for i = 1, #WindowQueue do
|
||||
local win = WindowQueue[i]
|
||||
if win == self then
|
||||
_inQueue = true
|
||||
end
|
||||
if win._queue then
|
||||
win._root_view:RemoveFromParent()
|
||||
end
|
||||
end
|
||||
end
|
||||
if self._queue and not _inQueue then
|
||||
WindowQueue[#WindowQueue + 1] = self
|
||||
end
|
||||
AddPanel(self._root_view)
|
||||
if self._full then
|
||||
local offset = get_offset(self._full_offset)
|
||||
self._contentPane.width = GRoot.inst.width - 2 * offset
|
||||
self._contentPane.height = GRoot.inst.height
|
||||
self._contentPane.x = offset
|
||||
end
|
||||
if self._new_hide then
|
||||
for i = 1, #WindowQueue do
|
||||
local win = WindowQueue[i]
|
||||
if win == self then
|
||||
_inQueue = true
|
||||
end
|
||||
if win._queue then
|
||||
win._root_view:RemoveFromParent()
|
||||
end
|
||||
end
|
||||
end
|
||||
if self._queue and not _inQueue then
|
||||
WindowQueue[#WindowQueue + 1] = self
|
||||
end
|
||||
AddPanel(self._root_view)
|
||||
|
||||
if self._scale then
|
||||
local scaleY = GRoot.inst.height / self._contentPane.height
|
||||
local scaleX = GRoot.inst.width / self._contentPane.width
|
||||
self._contentPane:SetScale(scaleX, scaleY)
|
||||
end
|
||||
|
||||
if self._full then
|
||||
local offset = get_offset(self._full_offset)
|
||||
self._contentPane.width = GRoot.inst.width - 2 * offset
|
||||
self._contentPane.height = GRoot.inst.height
|
||||
self._contentPane.x = offset
|
||||
end
|
||||
end
|
||||
|
||||
-- 关闭窗口
|
||||
function M:Close()
|
||||
-- if self._blur_view then
|
||||
-- BlurView(self._blur_view,false)
|
||||
-- end
|
||||
if self._queue then
|
||||
for i, v in ipairs(WindowQueue) do
|
||||
if v == self then
|
||||
table.remove(WindowQueue, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
-- if self._blur_view then
|
||||
-- BlurView(self._blur_view,false)
|
||||
-- end
|
||||
if self._queue then
|
||||
for i, v in ipairs(WindowQueue) do
|
||||
if v == self then
|
||||
table.remove(WindowQueue, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self._new_hide then
|
||||
local win = WindowQueue[#WindowQueue]
|
||||
if win and win._queue then
|
||||
AddPanel(win._root_view)
|
||||
end
|
||||
end
|
||||
self._root_view:RemoveFromParent()
|
||||
if self._new_hide then
|
||||
local win = WindowQueue[#WindowQueue]
|
||||
if win and win._queue then
|
||||
AddPanel(win._root_view)
|
||||
end
|
||||
end
|
||||
self._root_view:RemoveFromParent()
|
||||
end
|
||||
|
||||
local _destroy_all = false
|
||||
-- 销毁窗口
|
||||
function M:Destroy()
|
||||
if self._is_destroy then
|
||||
return
|
||||
end
|
||||
if not _destroy_all then
|
||||
self:Close()
|
||||
if self._put_map then
|
||||
for i, v in ipairs(WindowMap) do
|
||||
if v == self then
|
||||
table.remove(WindowMap, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self._is_destroy = true
|
||||
self._root_view:Dispose()
|
||||
if self._is_destroy then
|
||||
return
|
||||
end
|
||||
if not _destroy_all then
|
||||
self:Close()
|
||||
if self._put_map then
|
||||
for i, v in ipairs(WindowMap) do
|
||||
if v == self then
|
||||
table.remove(WindowMap, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self._is_destroy = true
|
||||
self._root_view:Dispose()
|
||||
end
|
||||
|
||||
function M:CloseEvent()
|
||||
local win_mode = self._root_view:GetChild("win_mode")
|
||||
if self._anim_pop == 0 then
|
||||
if self._close_destroy then
|
||||
self:Destroy()
|
||||
else
|
||||
self:Close()
|
||||
win_mode.touchable = true
|
||||
end
|
||||
else
|
||||
self:ActionWithAnim(function()
|
||||
if self._close_destroy then
|
||||
self:Destroy()
|
||||
else
|
||||
self:Close()
|
||||
win_mode.touchable = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
local win_mode = self._root_view:GetChild("win_mode")
|
||||
if self._anim_pop == 0 then
|
||||
if self._close_destroy then
|
||||
self:Destroy()
|
||||
else
|
||||
self:Close()
|
||||
win_mode.touchable = true
|
||||
end
|
||||
else
|
||||
self:ActionWithAnim(function()
|
||||
if self._close_destroy then
|
||||
self:Destroy()
|
||||
else
|
||||
self:Close()
|
||||
win_mode.touchable = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function M:ActionWithAnim(callback)
|
||||
local contentPane = self._root_view:GetChild("contentPane")
|
||||
if self._anim_pop == 1 then
|
||||
contentPane:GetTransition("left_pop_back"):Play()
|
||||
elseif self._anim_pop == 2 then
|
||||
contentPane:GetTransition("right_pop_back"):Play()
|
||||
end
|
||||
if callback then
|
||||
coroutine.start(function()
|
||||
coroutine.wait(0.3)
|
||||
callback()
|
||||
end)
|
||||
end
|
||||
local contentPane = self._root_view:GetChild("contentPane")
|
||||
if self._anim_pop == 1 then
|
||||
contentPane:GetTransition("left_pop_back"):Play()
|
||||
elseif self._anim_pop == 2 then
|
||||
contentPane:GetTransition("right_pop_back"):Play()
|
||||
end
|
||||
if callback then
|
||||
coroutine.start(function()
|
||||
coroutine.wait(0.3)
|
||||
callback()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function BaseWindow.DestroyAll()
|
||||
_destroy_all = true
|
||||
local list = WindowMap
|
||||
for i = 1, #list do
|
||||
local win = list[i]
|
||||
win:Destroy()
|
||||
end
|
||||
_destroy_all = false
|
||||
WindowQueue = {}
|
||||
WindowMap = {}
|
||||
_destroy_all = true
|
||||
local list = WindowMap
|
||||
for i = 1, #list do
|
||||
local win = list[i]
|
||||
win:Destroy()
|
||||
end
|
||||
_destroy_all = false
|
||||
WindowQueue = {}
|
||||
WindowMap = {}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,15 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<component size="1980,234">
|
||||
<displayList>
|
||||
<image id="n0_yk1o" name="n0" src="yk1o7d3r" fileName="MyFamily/Image/Rectangle 259.png" xy="0,0" size="1980,249"/>
|
||||
<loader id="n1_yk1o" name="loader_icon" xy="30,24" size="186,186" align="center" vAlign="middle" fill="scaleMatchHeight"/>
|
||||
<image id="n2_yk1o" name="n2" src="yk1o7d3s" fileName="MyFamily/Image/Rectangle 260.png" xy="246,24" size="1710,186"/>
|
||||
<component id="n3_yk1o" name="btn_rank" src="yk1o7d3x" fileName="MyFamily/Component/btn_familyRank.xml" xy="912,57"/>
|
||||
<component id="n4_yk1o" name="btn_record" src="yk1o7d3y" fileName="MyFamily/Component/btn_familyRecord.xml" xy="1299,57"/>
|
||||
<component id="n5_yk1o" name="btn_familyManage" src="yk1o7d3z" fileName="MyFamily/Component/btn_familyManage.xml" xy="1623,57"/>
|
||||
<image id="n6_yk1o" name="n6" src="yk1o7d40" fileName="MyFamily/Image/hall_club_common_club_liebiao_icon_renshu.png" xy="555,54"/>
|
||||
<text id="n7_yk1o" name="tex_familyId" xy="282,52" size="243,49" font="ui://27vd145bg2mo7ij0" fontSize="36" color="#940f0e" vAlign="middle" autoSize="none" text="940F0E"/>
|
||||
<text id="n8_yk1o" name="tex_familyName" xy="282,112" size="292,64" font="ui://27vd145bg2mo7ij0" fontSize="48" color="#333333" vAlign="middle" autoSize="none" text="333333"/>
|
||||
<text id="n9_yk1o" name="tex_familyNumber" xy="595,43" size="272,56" font="ui://27vd145bg2mo7ij0" fontSize="42" color="#333333" vAlign="middle" autoSize="none" text="333333"/>
|
||||
<image id="n0_yk1o" name="n0" src="yk1o7d3r" fileName="MyFamily/Image/Rectangle 259.png" xy="0,0" size="1980,249">
|
||||
<relation target="" sidePair="width-width,height-height"/>
|
||||
</image>
|
||||
<image id="n2_yk1o" name="n2" src="yk1o7d3s" fileName="MyFamily/Image/Rectangle 260.png" xy="246,24" size="1710,186">
|
||||
<relation target="" sidePair="width-width,height-height"/>
|
||||
</image>
|
||||
<loader id="n1_yk1o" name="loader_icon" xy="30,24" size="186,186" group="n10_q3uh" align="center" vAlign="middle" fill="scaleMatchHeight"/>
|
||||
<image id="n6_yk1o" name="n6" src="yk1o7d40" fileName="MyFamily/Image/hall_club_common_club_liebiao_icon_renshu.png" xy="555,54" group="n10_q3uh"/>
|
||||
<text id="n7_yk1o" name="tex_familyId" xy="282,52" size="243,49" group="n10_q3uh" font="ui://27vd145bg2mo7ij0" fontSize="36" color="#940f0e" vAlign="middle" autoSize="none" text="940F0E"/>
|
||||
<text id="n8_yk1o" name="tex_familyName" xy="282,112" size="292,64" group="n10_q3uh" font="ui://27vd145bg2mo7ij0" fontSize="48" color="#333333" vAlign="middle" autoSize="none" text="333333"/>
|
||||
<text id="n9_yk1o" name="tex_familyNumber" xy="595,43" size="272,56" group="n10_q3uh" font="ui://27vd145bg2mo7ij0" fontSize="42" color="#333333" vAlign="middle" autoSize="none" text="333333"/>
|
||||
<group id="n10_q3uh" name="n10" xy="30,24" size="837,186" advanced="true">
|
||||
<relation target="" sidePair="left-left"/>
|
||||
</group>
|
||||
<component id="n3_yk1o" name="btn_rank" src="yk1o7d3x" fileName="MyFamily/Component/btn_familyRank.xml" xy="912,57" group="n11_q3uh"/>
|
||||
<component id="n4_yk1o" name="btn_record" src="yk1o7d3y" fileName="MyFamily/Component/btn_familyRecord.xml" xy="1299,57" group="n11_q3uh"/>
|
||||
<component id="n5_yk1o" name="btn_familyManage" src="yk1o7d3z" fileName="MyFamily/Component/btn_familyManage.xml" xy="1623,57" group="n11_q3uh"/>
|
||||
<group id="n11_q3uh" name="n11" xy="912,57" size="1021,120" advanced="true">
|
||||
<relation target="" sidePair="right-right"/>
|
||||
</group>
|
||||
</displayList>
|
||||
</component>
|
||||
|
|
@ -11,13 +11,18 @@
|
|||
<relation target="n2_yk1o" sidePair="right-right"/>
|
||||
</image>
|
||||
<group id="n1_yk1o" name="n1" xy="967,27" size="598,99"/>
|
||||
<image id="n5_yk1o" name="n5" src="mc627d05" fileName="Main/Image/Rectangle 91.png" xy="228,186" size="2076,960"/>
|
||||
<image id="n6_yk1o" name="n6" src="ieus7d1e" fileName="Main/Image/Rectangle 121.png" xy="246,204" size="2040,924"/>
|
||||
<component id="n4_yk1o" name="btn_close" src="in3i7cu9" fileName="Main/Component/btn_close.xml" xy="54,6"/>
|
||||
<list id="n7_yk1o" name="list_familys" xy="246,234" size="2040,865" layout="flow_vt" overflow="scroll" lineGap="36" defaultItem="ui://htcn7v3ryk1o7d3q" align="center" autoClearItems="true">
|
||||
<image id="n5_yk1o" name="n5" src="mc627d05" fileName="Main/Image/Rectangle 91.png" xy="228,186" size="2076,960">
|
||||
<relation target="" sidePair="width-width,height-height"/>
|
||||
</image>
|
||||
<image id="n6_yk1o" name="n6" src="ieus7d1e" fileName="Main/Image/Rectangle 121.png" xy="246,204" size="2040,924">
|
||||
<relation target="" sidePair="width-width,height-height"/>
|
||||
</image>
|
||||
<list id="n7_yk1o" name="list_familys" xy="276,234" size="1980,865" overflow="scroll" lineGap="36" defaultItem="ui://htcn7v3ryk1o7d3q" align="center" autoClearItems="true">
|
||||
<relation target="" sidePair="width-width,height-height"/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
</list>
|
||||
<component id="n4_yk1o" name="btn_close" src="in3i7cu9" fileName="Main/Component/btn_close.xml" xy="54,6"/>
|
||||
</displayList>
|
||||
</component>
|
||||
Binary file not shown.
Loading…
Reference in New Issue