예제 #1
0
def main():
    desktop = GetDesktopPath()
    test_belt_npk = '//sprite_character_swordman_atequipment_avatar_belt.npk'

    test_belt = NPK()
    test_belt.open(desktop + test_belt_npk)

    index_layer = {}

    for index, ana in test_belt.dictAna.items():
        img_name = ana[-1]

        simple_name = img_name.split('/')[-1]

        if 'mask' in simple_name or '(tn)' in simple_name or 'belt' not in simple_name:
            continue

        else:

            result = re.findall(r'([0-9]+)(.*)\.img', simple_name)
            if result:

                a = result[0]

                if a[0] in list(index_layer.keys()):
                    index_layer[a[0]].append(a[1])
                else:
                    index_layer[a[0]] = [a[1]]

    print(index_layer)
예제 #2
0
파일: npkFunc.py 프로젝트: zihunyeyu/dosDnf
def getImgContent(img2Dir, imgNameList, imgDict):
    """
    获取IMG名称与内容
    :param img2Dir: IMG2文件夹
    :param imgNameList: IMG名称列表
    :param imgDict: IMG词典
    :return: imgNameConDict[imgName] = imgContent
    """
    npkImgIndex = {}
    imgNameConDict = {}
    for imgName in imgNameList:
        npkName, imgIndex = imgDict[imgName]
        if npkName in list(npkImgIndex.keys()):
            npkImgIndex[npkName].append(imgIndex)
        else:
            npkImgIndex[npkName] = [imgIndex]

    for npkName, impIndexes in npkImgIndex.items():
        npkImgIndex[npkName] = list(set(impIndexes))
        npkObject = NPK()
        npkObject.open(img2Dir + '\\' + npkName)
        extractResult = npkObject.extractImg(npkImgIndex[npkName])
        # print(extractResult)
        if len(extractResult[1]) > 0:
            continue
        for dictV in extractResult[0].values():
            imgNameConDict[dictV[3]] = dictV[-1]

    return imgNameConDict
예제 #3
0
파일: npkFunc.py 프로젝트: zihunyeyu/dosDnf
def newImgNpkDict(img2Path, repeatFlag=False):
    npkFilePathList = lafed(img2Path)
    singleImgList = []  # ["1.img", "2.img", ~]
    img2NpkDict = {}  # {imgName: npkName}
    repeatImgNpk = {}  # {npkPath: [repeatImgIndex1,   repeatImgIndex2~]}
    errorImg = []

    def falseRepeatImg(npkDictA):
        for key in npkDictA.keys():
            name = npkDictA[key][-1]
            if name not in singleImgList and "(tn)" not in name:
                singleImgList.append(name)
                img2NpkDict[name] = [npkName, key]

    def trueRepeatImg(npkDictA):
        repeatImgIndex = []
        # -----------遍历NPK字典
        for key in npkDictA.keys():
            name = npkDictA[key][-1]
            index_ = key
            if name not in singleImgList and "(tn)" not in name:
                singleImgList.append(name)
                img2NpkDict[name] = [npkName, key]
            else:
                repeatImgIndex.append(index_)
        if len(repeatImgIndex) > 0:
            repeatImgNpk[npkName] = repeatImgIndex

    # 创建进度条······
    pBar = tqdm(npkFilePathList)
    for npkFile in pBar:
        pBar.set_description("构建IMG2NPK词典中>>>")
        if npkFile.split(".")[-1].lower() != "npk":
            continue
        # ---------------npkName----------------
        npkName = npkFile.split('\\')[-1]
        # --------------------------------
        npk = NPK()
        if npk.open(npkFile):
            dictAna_ = npk.dictAna
        else:
            errorImg.append(npkName)
            continue
        if repeatFlag:
            trueRepeatImg(dictAna_)
        else:
            falseRepeatImg(dictAna_)
    if len(errorImg) > 0:
        print("-----错误的NPK文件列表-------------------")
        for error in errorImg:
            print(error)
        print("-----错误的NPK文件列表-------------------\n")

    if repeatFlag:
        return repeatImgNpk

    else:
        return img2NpkDict
예제 #4
0
파일: npkFunc.py 프로젝트: zihunyeyu/dosDnf
def delRepeatImg(repeatImgNpkDict, img2Dir):
    if len(repeatImgNpkDict.keys()) <= 0:
        return False

    for npkPath, imgIndexes in repeatImgNpkDict.items():
        truePath = img2Dir + '\\\\' + npkPath
        obj = NPK()
        try:
            obj.open(truePath)
            obj.delImg(imgIndexes)
        except:
            print(truePath + "{}\t处理失败".format(imgIndexes))
            continue
        imgCount = toInt(obj.allContent[16:20])
        obj.save(mode=False)
        if imgCount == 0:
            remove(truePath)
            print("已删除空NPK文件:\t" + npkPath.split("\\")[-1])
예제 #5
0
파일: npkFunc.py 프로젝트: zihunyeyu/dosDnf
def imgMerge(imgList, imgDict, npkSavePath, img2Path):
    npk = NPK()
    npk.new()
    notExistNpk = []
    keys = imgDict.keys()
    notInDictImg = []
    waitOpenNpk = {}
    # 创建进度条······

    for img in imgList:
        if img not in keys:
            notInDictImg.append(img)
            continue

        npkName, imgIndex = imgDict[img]
        try:
            waitOpenNpk[npkName].append(imgIndex)
            waitOpenNpk[npkName] = list(set(waitOpenNpk[npkName]))
        except:
            waitOpenNpk[npkName] = [imgIndex]
    pBar = tqdm(waitOpenNpk.items())

    for key, value in pBar:
        pBar.set_description("拼合NPK中>>>\r")
        extractedNpk = NPK()
        npkPath = img2Path + "\\" + key
        if ife(npkPath):
            extractedNpk.open(npkPath)
        else:
            notExistNpk.append(npkPath)
            continue

        extractImg_, errorIndex = extractedNpk.extractImg(value)
        npk.addDictImg(extractImg_)

        for key in errorIndex:
            notExistNpk.append(key + "\t第{index}号IMG不存在".format(index=key))

    npk.save(npkSavePath, mode=False)
    return notInDictImg, notExistNpk