Example #1
0
def HasReferenceNewUpdate(objNS):

    filename = objNS.ReferenceFilePath
    date = misc.GetFileLastWrite(filename)

    # check for xml last write
    xmlname, origFName = misc.DescriptionGetLocalFileName(objNS)

    if '' == xmlname:
        lOption = FBMessageBox(
            'Reference Tool',
            'Description Holder is missing for ' + objNS.LongName, 'Ok',
            'Create A New')

        if 2 == lOption:
            misc.DescriptionStore(objNS)

        return False

    xmldoc = minidom.parse(xmlname)
    shadersGraphElem = xmldoc.getElementsByTagName('ShadersGraph')
    if 0 == len(shadersGraphElem):
        return False

    xmlLastWrite = str(shadersGraphElem[0].getAttribute('LastWrite'))

    print date
    print xmlLastWrite

    return (date > xmlLastWrite)
Example #2
0
def RestoreShadersGraph(objNS):

    xmlname, origDescFile = misc.DescriptionGetLocalFileName(objNS)

    if xmlname == '' or False == os.path.isfile(xmlname):
        filename = objNS.ReferenceFilePath
        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'
        origDescFile = xmlname

    #DeleteShadersGraph(objNS)
    if os.path.isfile(xmlname):
        modelsMask = []
        LoadShaderGraphResources(xmlname, origDescFile, objNS, True, True)
        LoadShaderGraphConnections(xmlname, origDescFile, objNS, True)
Example #3
0
def ComputeShadersMask(objNS):

    mask = []

    importNS = objNS.LongName + ':'
    filename = objNS.ReferenceFilePath

    # look to description holder at first
    xmlname, origFName = misc.DescriptionGetLocalFileName(objNS)

    if xmlname == '' or False == os.path.isfile(xmlname):

        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'

    if os.path.isfile(xmlname):

        xmldoc = minidom.parse(xmlname)
        shadersGraphElem = xmldoc.getElementsByTagName('Shader')
Example #4
0
def CompareShadersGraph(objNS, sceneShaders):

    global gReferenceContent
    global gReferenceContentNames

    gReferenceContent = []
    gReferenceContentNames = []

    GlobalCollectReferenceContent(objNS)

    text = ''

    importNS = objNS.LongName + ':'
    filename = objNS.ReferenceFilePath

    # look to description holder at first
    xmlname, origFName = misc.DescriptionGetLocalFileName(objNS)

    if xmlname == '' or False == os.path.isfile(xmlname):

        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'

    if os.path.isfile(xmlname):

        numberOfExistShaders = 0
        existShaders = []
        for shader in sceneShaders:
            existShaders.append(False)

        xmldoc = minidom.parse(xmlname)
        shadersGraphElem = xmldoc.getElementsByTagName('Shader')

        text = text + '== Parsing Shaders Graph Description - ' + xmlname + '\n'

        if len(shadersGraphElem) > 0:
            for shader in shadersGraphElem:

                shaderClass = str(shader.getAttribute('ClassName'))
                xmlShaderName = str(shader.getAttribute('LongName'))
                strSystem = str(shader.getAttribute('System'))

                text = text + '\n  = Shader ' + xmlShaderName + ' (Class: ' + shaderClass + ') ... '

                # DONE: situation when scene shader has been renamed (I'm using RefOrigShader Property)

                isExists = False
                lSceneShader = None

                if 'True' == strSystem:

                    for lShader in lSystem.Scene.Shaders:
                        if lShader.HasObjectFlags(
                                FBObjectFlag.kFBFlagSystem
                        ) or 'Default Shader' == lShader.Name:
                            lSceneShader = lShader
                            isExists = True
                            break
                else:

                    for i, sceneShader in enumerate(sceneShaders):
                        mbShaderName = sceneShader.LongName
                        refOrigShader = sceneShader.PropertyList.Find(
                            'RefOrigShader')
                        if refOrigShader is not None:
                            mbShaderName = refOrigShader.Data

                        if xmlShaderName == mbShaderName:
                            lSceneShader = sceneShader
                            existShaders[i] = True
                            isExists = True
                            break

                if isExists:
                    numberOfExistShaders += 1

                    text = text + ' Ok!\n'
                else:
                    text = text + ' Missing!\n'

                allTheAttElems = shader.getElementsByTagName('Dst')
                allThePropElems = shader.getElementsByTagName('Property')

                # DONE: compare prop values

                if lSceneShader is not None:

                    # DONE: we could not have a scene load for retreiving mod state
                    xmlprops = []
                    xmlprops = GetXmlProps(allThePropElems)

                    # shared, edits, collisions
                    compareInfo = []
                    compareInfo = ComparePropsAndValues(lSceneShader, xmlprops)

                    text = text + '   > Checking Properties - total: ' + str(
                        len(lSceneShader.PropertyList))
                    text = text + '; shared: ' + str(
                        compareInfo[0]) + '; edits: ' + str(
                            compareInfo[1]) + '; collisions: ' + str(
                                compareInfo[2]) + '; \n'

                    # DONE: compare attachments

                    att = []
                    att = GetXmlAttachments(allTheAttElems, importNS)
                    mbAtt = []
                    mbAtt = GetMBAttachments(lSceneShader, objNS)

                    diff1 = list(set(mbAtt) - set(att))
                    diff2 = list(set(att) - set(mbAtt))

                    diff = diff1 + diff2

                    if lSceneShader.HasObjectFlags(FBObjectFlag.kFBFlagSystem):
                        diff = diff2

                    if len(diff) > 0:
                        text = text + '    > Different shader-model assignment - '
                        for elem in diff:
                            text = text + elem + '; '
                        text = text + '\n'
                    else:
                        text = text + '    > No differents in shader-model assignments!\n'

        if numberOfExistShaders == len(sceneShaders):

            if len(shadersGraphElem) == len(sceneShaders):
                text = text + '\nThere are no changes in shaders\n'
            else:
                text = text + '\nSome Source Description shaders are missing (Disconnected or Removed)\n'
        else:

            text = text + '\nSome Scene Shaders are missing (User Added or Connected)\n'

            for lFlag, lShader in zip(existShaders, sceneShaders):
                if False == lFlag:
                    text = text + '  * ' + lShader.LongName + '\n'

    return text