Exemple #1
0
    def save_processed_resource(self, output_dir, path_id, cnt):
        # split path
        path, name = os.path.split(cnt)
        name, ext = os.path.splitext(name)
        # resource get
        res = self.get_resource(path_id)

        if use_object_name:
            name = res.obj_name

        # Resources::Text::table
        if eq_path(path, "assets/resources/dabao/table"):
            if name == "tableconfig":
                res.set_path("text/table", "tableconfig")
            else:
                res.table()
                res.set_path(cf_dir["assets/resources/dabao/table"], name)

        # Resources::Text::profilesconfig (인형 대사 등등)
        elif eq_path(path, "assets/resources/dabao/profilesconfig"):
            res.profilesconfig(name)
            res.set_path(cf_dir["assets/resources/dabao/profilesconfig"], name)

        # Resources::icon::equip (장비 아이콘)
        elif eq_path(path, "assets/resources/dabao/pics/icons/equip"):
            new_path = cf_dir["assets/resources/dabao/pics/icons/equip"]
            if rn_equip:
                # 장비 이름 변경
                rn = rename.Equip(name)
                name = rn.get_name()
                # 이름 변경 오류시(한자 포함 등등) 더미폴더로 이동
                if rn.flag == 'E':
                    new_path = os.path.join(new_path, "dummy")
            res.set_path(new_path, name)

        # Character::pic (인형 일러스트)
        elif eq_path(path, "assets/characters//pic"):
            new_path = cf_dir["assets/characters//pic"]
            char_name = path.split('/')[2]
            if rn_doll:
                # 인형 이름 바꾸기 + 옵션 전달
                rn = rename.Doll(name, rn_doll_id, rn_doll_skin_id,
                                 rn_remove_n)
                name = rn.get_name()
                if rn.flag == 'E':
                    # Flag가 E(오류)면 더미 폴더 이동. 필요에 따라 인형별 폴더 분리
                    new_path = f"pic/dummy/{char_name}" if split_dummy_image_folder else "pic/dummy"
                if rn.flag == 'N' and rn_remove_n:
                    # 옵션에 따라 _N이 붙은 이미지들의 _N을 지우고 별도 폴더 이동
                    new_path = "pic/portraits"
                if rn.flag == 'N' and make_doll_icon:
                    # 옵션값 참이면 _N 이미지 기반으로 아이콘 생섣
                    res.make_icon(rn.rank, name,
                                  cf_dir["_etc"]["characters/pic/icon"],
                                  output_dir)
            elif name_normalize:
                name = rename.normalize(name)
            res.set_path(new_path, name)
        elif eq_path(path, "assets/characters//pic_he"):
            res.set_path(cf_dir["assets/characters//pic_he"], name)

        # Character::spine (인형 SD)
        elif eq_path(path, "assets/characters//spine"):
            new_path = path.split('/')[2]
            if sp_remove_type_ext and res.ext in ["bytes", "txt"]:
                # 필요없는 확장자 제거 옵션
                res.ext = ""
            if sp_folder_skin_id_remove:
                # 폴더 이름에 (찾을 수 있으면) 대문자 포함된 이름 사용
                new_path = rename.path_rename(
                    path, original_name=sp_folder_original_name)
            res.set_path(f"{cf_dir['assets/characters//spine']}/{new_path}",
                         name)

        # Sprites::skilicon (스킬 아이콘)
        elif eq_path(path, "assets/sprites/ui/icon/skillicon"):
            if force_alpha_channel_remove and isinstance(res, ResImage):
                # 알파 채널 이미지 강제 제거 여부에 따른 결과
                res.remove_alpha_channel()
            res.set_path(cf_dir["assets/sprites/ui/icon/skillicon"], name)

        else:
            # 기타 단순 저장 목록들
            for n, m in cf_dir["_extra"].items():
                if eq_path(path, n):
                    res.set_path(m, name)
                    break
                else:
                    continue
            # 예외처리
            else:
                logger.info("-> Pass(file not in config_dir list)")

        # 저장
        res.save(output_dir)
        return
    def save_processed_resources(self):
        """리소스를 처리한 후 저장. 모든 옵션(이름 바꾸기 등) 사용 가능
        """
        for path_id, cnt in self.container.items():
            # split path
            path, name = os.path.split(cnt)
            name, ext = os.path.splitext(name)
            logger.info(f"{path}/{name}")
            # resource get
            res = self.get_resource(path_id)

            if use_object_name:
                name = res.obj_name

            # Resources::Text::table
            if eq_path(path, "assets/resources/dabao/table"):
                if name == "tableconfig":
                    res.set_path("text/table", "tableconfig")
                else:
                    res.table()
                    res.set_path("text/table", name)
                logger.info("-> Text::table")

            # Resources::Text::profilesconfig (인형 대사 등등)
            elif eq_path(path, "assets/resources/dabao/profilesconfig"):
                res.profilesconfig(name)
                res.set_path("text/profilesconfig", name)
                logger.info("-> Text::profilesconfig")

            # Resources::Text::avgtxt (일반 전역 대사)
            elif eq_path(path, "assets/resources/dabao/avgtxt"):
                res.set_path("text/avgtxt", name)
                logger.info("-> Text::avgtxt")

            # Resources::Text::avgtxt (전투중 전역 대사?)
            elif eq_path(path, "assets/resources/dabao/avgtxt/battleavg"):
                res.set_path("text/avgtxt/battleavg", name)
                logger.info("-> Text::avgtxt::battleavg")

            # Resources::Text::avgtxt (개조 스토리)
            elif eq_path(path, "assets/resources/dabao/avgtxt/memoir"):
                res.set_path("text/avgtxt/memoir", name)
                logger.info("-> Text::avgtxt::memoir")

            # Resources::Text::avgtxt (스킨 스토리)
            elif eq_path(path, "assets/resources/dabao/avgtxt/skin"):
                res.set_path("text/avgtxt/skin", name)
                logger.info("-> Text::avgtxt::skin")

            # Resources::Text::avglang (스토리 언어별 텍스트)
            elif eq_path(path, "assets/resources/dabao/avglanguage"):
                res.set_path("text/avglang", name)
                logger.info("-> Text::avglang")

            # Resources::Text::avgtxt (튜토리얼?)
            elif eq_path(path, "assets/resources/dabao/avgtxt/startavg"):
                res.set_path("text/avgtxt/startavg", name)
                logger.info("-> Text::avgtxt::startavg")

            # Resources::fairy (요정 대형)
            elif eq_path(path, "assets/resources/dabao/pics/fairy"):
                res.set_path("fairy", name)
                logger.info("-> Resources::fairy")

            # Resources::fairy::battle (요정 소형)
            elif eq_path(path, "assets/resources/dabao/pics/fairy/battle"):
                res.set_path("fairy/battle", name)
                logger.info("-> Resources::fairy::battle")

            # Resources::icon::equip (장비 아이콘)
            elif eq_path(path, "assets/resources/dabao/pics/icons/equip"):
                new_path = "icon/equip"
                if rn_equip:
                    # 장비 이름 변경
                    rn = rename.Equip(name)
                    name = rn.get_name()
                    # 이름 변경 오류시(한자 포함 등등) 더미폴더로 이동
                    if rn.flag == 'E':
                        new_path = "icon/equip/dummy"
                res.set_path(new_path, name)
                logger.info("-> Resources::icon::equip")

            # Resources::pic::squads (지원소대)
            elif eq_path(path, "assets/resources/dabao/pics/squads"):
                res.set_path("res/pic/squads", name)
                logger.info("-> Resources::pic::squads")

            # Character::pic (인형 일러스트)
            elif eq_path(path, "assets/characters//pic"):
                new_path = "pic"
                char_name = path.split('/')[2]
                if rn_doll:
                    # 인형 이름 바꾸기 + 옵션 전달
                    rn = rename.Doll(name, rn_doll_id, rn_doll_skin_id,
                                     rn_remove_n)
                    name = rn.get_name()
                    if rn.flag == 'E':
                        # Flag가 E(오류)면 더미 폴더 이동. 필요에 따라 인형별 폴더 분리
                        new_path = f"pic/dummy/{char_name}" if split_dummy_image_folder else "pic/dummy"
                    if rn.flag == 'N' and rn_remove_n:
                        # 옵션에 따라 _N이 붙은 이미지들의 _N을 지우고 별도 폴더 이동
                        new_path = "pic/portraits"
                    if rn.flag == 'N' and make_doll_icon:
                        # 옵션값 참이면 _N 이미지 기반으로 아이콘 생섣
                        res.make_icon(rn.rank, "icon/doll", name)
                res.set_path(new_path, name)
                logger.info("-> Character::pic")
            elif eq_path(path, "assets/characters//pic_he"):
                res.set_path("pic_he", name)

            # Character::spine (인형 SD)
            elif eq_path(path, "assets/characters//spine"):
                new_path = path.split('/')[2]
                if sp_remove_type_ext and res.ext in ["bytes", "txt"]:
                    # 필요없는 확장자 제거 옵션
                    res.ext = ""
                if sp_folder_skin_id_remove:
                    # 폴더 이름에 (찾을 수 있으면) 대문자 포함된 이름 사용
                    new_path = rename.path_rename(
                        path, original_name=sp_folder_original_name)
                res.set_path(f"spine/{new_path}", name)
                logger.info("-> Character::spine")

            # Sprites::skilicon (스킬 아이콘)
            elif eq_path(path, "assets/sprites/ui/icon/skillicon"):
                if force_alpha_channel_remove and isinstance(res, ResImage):
                    # 알파 채널 이미지 강제 제거 여부에 따른 결과
                    res.remove_alpha_channel()
                res.set_path("icon/skilicon", name)
                logger.info("-> Sprites::skilicon")

            # 예외처리
            else:
                logger.info("-> Pass")
                continue

            # 저장
            res.save()