哪位大神能看懂这个源码???

–region *.lua
–Date
–此文件由[BabeLua]插件自动生成
local Singleton = require “app.Singleton”
local layerBase = require “app.comm.layerBase”
local sceneMgr = class(“sceneMgr”,Singleton)

local panelWrapper = class(“panelWrapper”,function()
return display.newNode()
end)

function panelWrapper:ctor(panel,alpha,bHaveUiAni)
self._node = panel
self._isBlock = alpha>0
if self._isBlock then

    local bg = display.newColorLayer(cc.c4b(0, 0, 0, alpha))
                :addTo(self)

    bg:addNodeEventListener(cc.NODE_TOUCH_EVENT,function(event)
         local f = function(eventName,x,y)
            if event == "began"then
                 return true
            end
         end
         return f(event.name,event.x,event.y)

– printf(“touch event, .2f, .2f”, event.x, event.y)
– return true
end)

else  
     self._node:setTouchEnabled(false)
end
self:addChild(panel)

self._bHaveUiAni=bHaveUiAni
if self._bHaveUiAni==nil then
   self._bHaveUiAni=true
end

end

function panelWrapper:setPause(bPause)
if self._node and self._node.setPause then
self._node:setPause(bPause)
end
end

function panelWrapper:showThis(callBack)
if callBack~=nil and type(callBack) == “function” then
callBack()
end
return self
end

function panelWrapper:showAction()
if self._node then
if self._node.showAction then
self._node:showAction()
elseif self._bHaveUiAni then
local x,y=self._node:getPosition()
self._node:setAnchorPoint(cc.p(0.5,0.5))
self._node:setPosition(cc.p(display.width/2,display.height/2))
self._node:setScale(1)
–self._node:setScale(0.1)
–self._node:runAction(transition.newEasing(cc.ScaleTo:create(0.7,1.0),“CCEASEELASTICOUT”,0.4))
uMacro.am:getInstance():playEffectByTag(“popwindow”)
end
end
return self
end

function panelWrapper:hideAction(cb)
if self._node then
if self._node.hideAction then
self._node:hideAction(cb)
elseif self._bHaveUiAni then
local x,y=self._node:getPosition()

  self._node:runAction(transition.sequence{
  --transition.newEasing(cc.ScaleTo:create(0.2,0.0),"CCEASEIN", 0.4),
   cc.CallFunc:create(cb)
  })
  uMacro.am:getInstance():playEffectByTag("closewindow")

else
cb()
end
end
return self
end

function sceneMgr:getContainer()
return self._container
end
function sceneMgr:ctor()
self._layerTable = {}
self._popQueue = {}
self._wrappers = {}
self._blockCount = 0
self._container = display.newScene()
self._sceneContainer = display.newNode()
self._sceneContainer:setPosition(display.cx,display.cy)
self._popContainer = display.newNode()
self._staticContainer = display.newNode()

self._sceneContainer
        :addTo(self._container)

self._middleContainer = display.newNode()
self._middleContainer:addTo(self._container)

self._popContainer
        :addTo(self._container)
self._staticContainer
        :addTo(self._container)
self._isLayerCache = false
self._escList={}
self._waitPopArr={}

end

function sceneMgr:getCurrentScene()
return self._currentScene
end

function sceneMgr:setCurrentLayer(layertype)
self.currentLayerType=layertype
end

function sceneMgr:getCurrentLayer()
return self._layerTable[self.currentLayerType]
end

–获取最后打开的layer
function sceneMgr:getLastLayer()
return self._layerTable[self._lastLayer]
end

–获取最后打开的layerName
function sceneMgr:getLastLayerNameStr()
return self._lastLayer
end

function sceneMgr:escLayer()
if self:removeTopPop() then
return
end
if #self._escList>0 then
local clayer=self._layerTable[self.currentLayerType]
if clayer and clayer._back then
clayer:_back()
return
end
local name=self._escList[#self._escList]
local arrs=string.split(name,’.’)
if arrs[2]==“layers” then
self:getPanel(arrs[3],true)
:addTo(uMacro.sm:getInstance():getCurrentScene())
else
self:getPanel(arrs[3],true,arrs[2])
:addTo(uMacro.sm:getInstance():getCurrentScene())
end
table.remove(self._escList,#self._escList)
else
—退出
end
end

function sceneMgr:insertEscList(layerName)
table.insert(self._escList,layerName)
end

function sceneMgr:getPanel(layerType,bChange,gamename,bNotNeedCreate,bBigFrame)
if bChange and self.currentLayerType~=nil then
table.insert(self._escList,self._layerTable[self.currentLayerType]:getLayerName())
self:removePanel(self.currentLayerType)
self.currentLayerType=nil
end
if not bNotNeedCreate and self._layerTable[layerType]==nil then
if gamename~=nil then
local layerName =“app.”…gamename…"."…layerType
print(“getPanel”,layerName)
local l = require(layerName)
self._layerTable[layerType] = l:new()
self._layerTable[layerType]:setLayerName(layerName)
else
local layerName =“app.layers.”…layerType
print(“getPanel”,layerName)
local l = require(layerName)
self._layerTable[layerType] = l:new()
self._layerTable[layerType]:setLayerName(layerName)
if layerType ~= “ProgressLayer” and bBigFrame then
self._lastLayer = layerType
end
end

    local gm= require("app.models.GuideMgr")
    gm:getInstance():checkUi()
end

if self._layerTable[layerType] and self._layerTable[layerType].enterLayer then
    self._layerTable[layerType]:enterLayer()
end

if bChange then
	self:setCurrentLayer(layerType)
end
return self._layerTable[layerType]

end

function sceneMgr:addGuide(layer)
layer:addTo(self._staticContainer)
end

function sceneMgr:removePanel(layerType)
if self._layerTable[layerType] then
if self._layerTable[layerType].exitLayer then
self._layerTable[layerType]:exitLayer()
end
self._layerTable[layerType]:remove()
self._layerTable[layerType] = nil

end

end

function sceneMgr:getPos(layerType)
for key, value in ipairs( self._layerTable) do
if value == self._layerTable[layerType] then
return key
end
end
return 0
end

function sceneMgr:runWithScene(newScene,bNeedClear)
if bNeedClear then
self:clearAllLayers()
end
if self._currentScene~=nil then
self._sceneContainer:removeChild(self._currentScene)
self._currentScene = nil
end
if newScene~=nil then
newScene:setPosition(-display.cx,-display.cy)
self._currentScene = newScene
self._sceneContainer:addChild(newScene)
newScene:onEnter()
end
end

function sceneMgr:clearAllLayers()

local i = 1
self._popQueue:clear();
local v = self._popContainer:getChildren()
while i < #v do
    self:removePop(v[i]:getPanel())
end
--
self._staticQueue:clear();
v = self._staticContainer:getChildren()
while i < #v do
    self:removeStatic(v[i]:getPanel())
end

end

function sceneMgr:addPop(layer,block,callback,bHaveUiAni)
if layer:getParent()~=nil then
print(string.format(“error,layer %s has parent”,layer:getLayerType()))
return
end
local p = panelWrapper.new(layer,block,bHaveUiAni)
:addTo(self._popContainer)
:showThis(callback)
:showAction()
p:setName(layer:getLayerType())
self._wrappers[layer:getLayerType()] = p
table.insert(self._popQueue,layer:getLayerType())
if self._currentPop~=nil then
self._currentPop._node:setPause(true)
end
self._currentPop = p
self:addBlockCount()
end

function sceneMgr:checkWaitPop()
if #self._waitPopArr >0 then
local top=self._waitPopArr[1]
table.remove(self._waitPopArr,1)

  self:addPop(top.layer,top.block,top.callback,top.bHaveUiAni)
  top.layer:release()

end
end

function sceneMgr:addWaitPop(layer,block,callback,bHaveUiAni)
if self._currentPop~=nil then
layer:retain()
table.insert(self._waitPopArr,{layer=layer,block=block,callback=callback,bHaveUiAni=bHaveUiAni})
else
self:addPop(layer,block,callback,bHaveUiAni)
end
end

function sceneMgr:removeTopPop()
if self._currentPop then
if self._currentPop._node._back then
self._currentPop._node:_back()
else
self:removePop(self._currentPop._node)
end

  return true

end
return false
end

function sceneMgr:removeAllPop()
for i,v in pairs(self._wrappers) do
if self._layerTable[i] then
self:removePop(self._layerTable[i])
end
end
end

function sceneMgr:removeAllPopBut(layerType)

for i,v in pairs(self._wrappers) do
if self._layerTable[i] and layerType~=i then
self:removePop(self._layerTable[i])
end
end
end

function sceneMgr:removePop(layer,bclear)

if not layer.getLayerType then
print("layer.getLayerType not exist ")
end
if not layer or not layer.getLayerType then
return
end
local lType = layer:getLayerType()
local wrapper =self._wrappers[lType]
local func=function()

     if bclear or self._isLayerCache == false or layer:getUseDefaultCachePlot() then
        self._layerTable[lType]=nil
    end
    for i=1,#self._popQueue do
        if self._popQueue[i] == lType then
            table.remove(self._popQueue,i)
            break
        end
    end

    if #self._popQueue == 0 then
        self._currentPop = nil
        ---waitqueue
        self:checkWaitPop()
    else
        local  f = self._popQueue[#self._popQueue]
        if self._wrappers[f]~=nil and self._wrappers[f].setPause then
		    self._wrappers[f]:setPause(false)
	    end
	    self._currentPop = self._wrappers[f]
    end
end
if wrapper~=nil then
    
    wrapper:hideAction(function()
        self:reduceBlockCount()
         layer:remove()
        self._popContainer:removeChild(wrapper)
        self._wrappers[lType] = nil
        
        func()
    end)
else
    func()
end

end

function sceneMgr:addBlockCount()
self._blockCount = self._blockCount+1
if self._blockCount>0 then
if self._currentScene and self._currentScene:getPause() == false then
self._currentScene:setPause(true)
end
end
end

function sceneMgr:reduceBlockCount()
self._blockCount=self._blockCount-1
if self._blockCount == 0 then
if self._currentScene and self._currentScene:getPause() == false then
self._currentScene:setPause(false)
end
end
end

function sceneMgr:addTipLayer(str ,m_type,callback)
local node = cc.uiloader:load(“res/ccui/Tip.ExportJson”)

local Scalenode =  cc.uiloader:seekNodeByName(node, "Panel_middle")

-- 适配整个 屏幕
local visibleRect = cc.Director:getInstance():getWinSize()
local scaleX =  visibleRect.width/960
local scaleY =  visibleRect.height/640
Scalenode:setScaleX(scaleX)
Scalenode:setScaleY(scaleY)
Scalenode:setTouchEnabled(true)
Scalenode:setTouchSwallowEnabled(true)

self._container:addChild(node,1000)

local labtext = cc.uiloader:seekNodeByName(node, "lab_text")
labtext:setString(str)

local btn_sure_1 = cc.uiloader:seekNodeByName(node, "btn_sure_1")
btn_sure_1:onButtonClicked(function(event)
    callback()
    node:removeFromParent()
end)


local btn_sure_2 = cc.uiloader:seekNodeByName(node, "btn_sure_2")
 btn_sure_2:onButtonClicked(
 function(event)
    callback()
	node:removeFromParent()
end)

local btn_cancel = cc.uiloader:seekNodeByName(node, "btn_cancel")
btn_cancel:onButtonClicked(function(event)
     node:removeFromParent()
end)
if m_type == 1 then
    btn_sure_1:setVisible(false)
    btn_cancel:setVisible(false)
else
    btn_sure_2:setVisible(false)
end

end

function sceneMgr:setMainLayer(layerType)
self.mainLayerType=layerType
end

function sceneMgr:createMainLayer()
local layer=uMacro.sm:getInstance():getPanel(self.mainLayerType,true)
:addTo(uMacro.sm:getInstance():getCurrentScene())
:setPosition(0,0)
:setLocalZOrder(0)
uMacro.sm:getInstance():setCurrentLayer(layer:getLayerType())
return layer
end

return sceneMgr
–endregion