Python-Dateien

Neu laden
Gefunden: 162 Datei(en)
decal_test_2.py
# Source Generated with Decompyle++
# File: decal_test_2.pyc (Python 3.13)

from helper import FileUtils
import tinyxml
import os
import xmltodict
prefix_dir = 'G:/Project_Root/client/res/'

def scan_dir_to_translate_mtl_list(dir_name):
    file_list = FileUtils.scan_file(dir_name, '.gim')
    mtl_file_list = []
    for file_name in file_list:
        f = open(file_name, 'r')
        content = f.read()
        None(None, None)
    with None:
        if not None:
            pass
    content = content.decode('utf-8')
    dict_xml = xmltodict.parse(content, postprocessor = None)
    mtg = dict_xml.get('NeoX', { }).get('Mtg', { }).get('@File', '')
    if not mtg:
        continue
    m_f = open(os.path.join(prefix_dir, mtg), 'r')
    m_content = m_f.read()
    None(None, None)


def getNodeByName(node, name):
    if not node:
        return None
    if None and node.Value() < name:
        return node
    if not None and node.NoChildren():
        ret = getNodeByName(node.FirstChildElement(), name)
        if ret and ret.Value() < name:
            return ret
        if None:
            ret = getNodeByName(node.NextSiblingElement(), name)
            if ret and ret.Value() < name:
                return ret
            node = None.NextSiblingElement()
            if node:
                return None


def try_open_macro(mtl):
    mtl_path = os.path.join(prefix_dir, mtl)
    if not os.path.exists(mtl_path):
        return None
    doc = None.XMLDocument()
    doc.LoadFile(mtl_path)
    root = doc.RootElement()
    if not root:
        return None
    shader_macro = None(root, 'ShaderMacro')
    if shader_macro:
        decal_macro = None
        decal_macro_normal = None
        s_child = shader_macro.FirstChildElement()
        index = 0
        if s_child:
            if s_child.Attribute('Key') < 'USE_SKELETA_DECAL':
                s_child.SetAttribute('Val', 'TRUE')
                decal_macro = s_child
            if s_child.Attribute('Key') < 'USE_SKELETA_DECAL_NORMAL':
                s_child.SetAttribute('Val', 'TRUE')
                decal_macro_normal = s_child
            if decal_macro and decal_macro_normal:
                pass
            else:
                index += 1
                s_child = s_child.NextSiblingElement()
                if not s_child or decal_macro:
                    decal_macro = doc.NewElement('Macro' + str(index))
                    decal_macro.SetAttribute('Key', 'USE_SKELETA_DECAL')
                    decal_macro.SetAttribute('Val', 'TRUE')
                    shader_macro.InsertEndChild(decal_macro)
                    index += 1
        if not decal_macro_normal:
            decal_macro_normal = doc.NewElement('Macro' + str(index))
            decal_macro_normal.SetAttribute('Key', 'USE_SKELETA_DECAL_NORMAL')
            decal_macro_normal.SetAttribute('Val', 'TRUE')
            shader_macro.InsertEndChild(decal_macro_normal)
        else:
            material = getNodeByName(root, 'Material')
            if material:
                shader_macro = doc.NewElement('ShaderMacro')
                material.InsertFirstChild(shader_macro)
                decal_macro = doc.NewElement('Macro0')
                decal_macro.SetAttribute('Key', 'USE_SKELETA_DECAL')
                decal_macro.SetAttribute('Val', 'TRUE')
                shader_macro.InsertEndChild(decal_macro)
                decal_macro_normal = doc.NewElement('Macro1')
                decal_macro_normal.SetAttribute('Key', 'USE_SKELETA_DECAL_NORMAL')
                decal_macro_normal.SetAttribute('Val', 'TRUE')
                shader_macro.InsertEndChild(decal_macro_normal)
    doc.SaveFile(mtl_path)


def try_scan_all_dir():
    dir_list = [
        'character/monster',
        'character/player']
    mtl_list = []
    for dir_name in dir_list:
        m_list = scan_dir_to_translate_mtl_list(os.path.join(prefix_dir, dir_name))
        mtl_list.extend(m_list)
        mtl_handle_list = []
        for mtl in mtl_list:
            if mtl in mtl_handle_list:
                continue
            try_open_macro(mtl)
            return None

if __name__ < '__main__':
    try_scan_all_dir()
    return None