This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_export_pipeline.py
144 lines (114 loc) · 5.8 KB
/
script_export_pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import argparse
import os
from configparser import ConfigParser
from typing import Sequence, TypeVar
from dlparse.enums import (
BuffValueUnit, Element, SkillCancelAction, Status, TranslatableEnumMixin, Weapon, cond_afflictions, cond_elements,
)
from dlparse.export import (
collect_chained_ex_ability_buff_param, collect_ex_ability_buff_param, export_advanced_info_as_json,
export_atk_skill_as_json, export_chara_info_as_json, export_condition_as_json, export_dragon_info_as_json,
export_elem_bonus_as_json, export_enums_json, export_ex_abilities_as_json, export_normal_attack_info_as_json,
export_simple_info_as_json, export_skill_identifiers_as_json, export_unit_story_as_json,
)
from dlparse.mono.manager import AssetManager
from dlparse.transformer import AbilityTransformer
from dlparse.utils import time_exec
T = TypeVar("T", bound=TranslatableEnumMixin)
class FileExporter:
"""Class for the asset exporting procedure."""
@time_exec(title="Loading time")
def __init__(self, config_path: str):
config = ConfigParser()
config.read(config_path)
dir_resource = config.get("Asset", "Resource")
dir_custom = config.get("Asset", "Custom")
dir_export = config.get("Export", "Dir")
print(f"Resource Root Path: {dir_resource}")
print(f"Custom Asset Path: {dir_custom}")
print()
print(f"Export directory: {dir_export}")
print()
self._asset_manager: AssetManager = AssetManager(dir_resource, custom_asset_dir=dir_custom)
self._transformer_ability: AbilityTransformer = AbilityTransformer(self._asset_manager)
self._dir_export: str = dir_export
@time_exec(title="Enums exporting time")
def _export_enums(self, enums: dict[str, Sequence[T]], name: str):
export_enums_json(self._asset_manager, enums, os.path.join(self._dir_export, "enums", f"{name}.json"))
@time_exec(title="Condition enums exporting time")
def _export_enums_condition(self, name: str):
export_condition_as_json(self._asset_manager, os.path.join(self._dir_export, "enums", f"{name}.json"))
@time_exec(title="EX/CEX enums exporting time")
def _export_enums_ex(self):
enums_ex = collect_ex_ability_buff_param(self._transformer_ability, self._asset_manager)
enums_cex = collect_chained_ex_ability_buff_param(self._transformer_ability, self._asset_manager)
self._export_enums({"exBuffParam": enums_ex, "chainedExBuffParam": enums_cex}, "exParam")
@time_exec(title="Element bonus exporting time")
def _export_elem_bonus(self):
export_elem_bonus_as_json(os.path.join(self._dir_export, "misc", "elementBonus.json"))
@time_exec(title="Skill identifiers exporting time")
def _export_skill_identifiers(self, name: str):
export_skill_identifiers_as_json(
self._asset_manager,
os.path.join(self._dir_export, "skills", f"{name}.json")
)
@time_exec(title="ATK skill exporting time")
def _export_atk_skill(self):
export_atk_skill_as_json(
os.path.join(self._dir_export, "skills", "attacking.json"), self._asset_manager
)
@time_exec(title="EX/CEX ability exporting time")
def _export_ex_abilities(self):
export_ex_abilities_as_json(
os.path.join(self._dir_export, "abilities", "ex.json"), self._asset_manager,
skip_unparsable=True
)
@time_exec(title="Unit info exporting time")
def _export_unit_info(self):
export_simple_info_as_json(os.path.join(self._dir_export, "info", "simple.json"), self._asset_manager)
export_chara_info_as_json(os.path.join(self._dir_export, "info", "chara.json"), self._asset_manager)
export_dragon_info_as_json(os.path.join(self._dir_export, "info", "dragon.json"), self._asset_manager)
export_advanced_info_as_json(os.path.join(self._dir_export, "info", "advanced"), self._asset_manager)
@time_exec(title="Normal attack info exporting time")
def _export_normal_attack(self):
export_normal_attack_info_as_json(
os.path.join(self._dir_export, "atk", "combo"), self._asset_manager,
skip_unparsable=True
)
@time_exec(title="Story exporting time")
def _export_story(self):
export_unit_story_as_json(
os.path.join(self._dir_export, "story"), self._asset_manager,
skip_unparsable=True
)
@time_exec(title="Total exporting time")
def export(self):
"""Export the parsed assets."""
# Enums
self._export_enums({"afflictions": cond_afflictions, "elements": cond_elements}, "conditions")
self._export_enums_ex()
self._export_enums({"weapon": Weapon.get_all_translatable_members()}, "weaponType")
self._export_enums({"elemental": Element.get_all_translatable_members()}, "elements")
self._export_enums({"unit": BuffValueUnit.get_all_translatable_members()}, "buffParam")
self._export_enums({"status": Status.get_all_translatable_members()}, "status")
self._export_enums({"cancel": SkillCancelAction.get_all_translatable_members()}, "skill")
self._export_enums_condition("allCondition")
# Skill
self._export_atk_skill()
self._export_skill_identifiers("identifiers")
# Abilties
self._export_ex_abilities()
# Info
self._export_unit_info()
self._export_normal_attack()
# Story
self._export_story()
# Misc
self._export_elem_bonus()
# region Parser
parser = argparse.ArgumentParser(description="Process the assets and export it as website resources.")
parser.add_argument("--config", type=str, help="Location of the config file.",
dest="config_path", default="export.ini")
# endregion
if __name__ == '__main__':
FileExporter(parser.parse_args().config_path).export()