feat(config): clean up
This commit is contained in:
45
config.yaml
45
config.yaml
@@ -1,16 +1,5 @@
|
|||||||
operators:
|
operators:
|
||||||
chen:
|
chen:
|
||||||
common_name: dyn_illust_char_1013_chen2
|
|
||||||
fallback_name: char_1013_chen2_2
|
|
||||||
logo_name: logo_rhodes_override
|
|
||||||
preview: preview.jpg
|
|
||||||
project_json: project.json
|
|
||||||
release_folder: ./release/{name}/
|
|
||||||
source_folder: ./operator/{name}/extracted/
|
|
||||||
target_folder: ./operator/{name}/processed/
|
|
||||||
title: Ch'en the Holungday
|
|
||||||
use_skel: true
|
|
||||||
config:
|
|
||||||
index.html:
|
index.html:
|
||||||
operator_logo: logo_rhodes_override
|
operator_logo: logo_rhodes_override
|
||||||
title: Ch'en the Holungday
|
title: Ch'en the Holungday
|
||||||
@@ -22,33 +11,22 @@ operators:
|
|||||||
filename: dyn_illust_char_1013_chen2
|
filename: dyn_illust_char_1013_chen2
|
||||||
fps: 60
|
fps: 60
|
||||||
opacity: 100
|
opacity: 100
|
||||||
viewport_bottom: 1
|
|
||||||
viewport_left: 0
|
viewport_left: 0
|
||||||
viewport_right: 0
|
viewport_right: 0
|
||||||
viewport_top: 1
|
viewport_top: 1
|
||||||
|
viewport_bottom: 1
|
||||||
project.json:
|
project.json:
|
||||||
description: 'Arknights: Ch''en/Chen the Holungday Live 2D\n明日方舟:假日威龙陈 Live 2D\nThe model is extracted from game with Spine support.\n模型来自游戏内提取,支持Spine\nPlease set your FPS target in Wallpaper Engine > Settings > Performance > FPS\n请在 Wallpaper Engine > 设置 > 性能 > FPS 下设置FPS\n\nLive preview on: https://arknights.halyul.dev/chen\nGithub: https://github.com/Halyul/aklive2d'
|
description: 'Arknights: Ch''en/Chen the Holungday Live 2D\n明日方舟:假日威龙陈 Live 2D\nThe model is extracted from game with Spine support.\n模型来自游戏内提取,支持Spine\nPlease set your FPS target in Wallpaper Engine > Settings > Performance > FPS\n请在 Wallpaper Engine > 设置 > 性能 > FPS 下设置FPS\n\nLive preview on: https://arknights.halyul.dev/chen\nGithub: https://github.com/Halyul/aklive2d'
|
||||||
title: 'Arknights: Ch''en/Chen the Holungday - 明日方舟:假日威龙陈'
|
title: 'Arknights: Ch''en/Chen the Holungday - 明日方舟:假日威龙陈'
|
||||||
ui_logo_opacity: 100
|
ui_logo_opacity: 100
|
||||||
ui_logo_ratio: 61.8
|
ui_logo_ratio: 61.8
|
||||||
ui_operator_logo: 'true'
|
ui_operator_logo: 'true'
|
||||||
ui_position_padding_bottom: 1
|
|
||||||
ui_position_padding_left: 0
|
ui_position_padding_left: 0
|
||||||
ui_position_padding_right: 0
|
ui_position_padding_right: 0
|
||||||
ui_position_padding_top: 1
|
ui_position_padding_top: 1
|
||||||
|
ui_position_padding_bottom: 1
|
||||||
workshopid: 2564643862
|
workshopid: 2564643862
|
||||||
nian:
|
nian:
|
||||||
common_name: dyn_illust_char_2014_nian
|
|
||||||
fallback_name: char_2014_nian_2
|
|
||||||
logo_name: logo_sui
|
|
||||||
preview: preview.jpg
|
|
||||||
project_json: project.json
|
|
||||||
release_folder: ./release/{name}/
|
|
||||||
source_folder: ./operator/{name}/extracted/
|
|
||||||
target_folder: ./operator/{name}/processed/
|
|
||||||
title: Nian
|
|
||||||
use_skel: true
|
|
||||||
config:
|
|
||||||
index.html:
|
index.html:
|
||||||
operator_logo: logo_sui
|
operator_logo: logo_sui
|
||||||
title: Nian
|
title: Nian
|
||||||
@@ -69,23 +47,12 @@ operators:
|
|||||||
ui_logo_opacity: 30
|
ui_logo_opacity: 30
|
||||||
ui_logo_ratio: 61.8
|
ui_logo_ratio: 61.8
|
||||||
ui_operator_logo: 'true'
|
ui_operator_logo: 'true'
|
||||||
ui_position_padding_left: 02
|
ui_position_padding_left: 2
|
||||||
ui_position_padding_right: 2
|
ui_position_padding_right: 2
|
||||||
ui_position_padding_top: 3
|
ui_position_padding_top: 3
|
||||||
ui_position_padding_bottom: 5
|
ui_position_padding_bottom: 5
|
||||||
workshopid: 2564642594
|
workshopid: 2564642594
|
||||||
skadi:
|
skadi:
|
||||||
common_name: dyn_illust_char_1012_skadi2
|
|
||||||
fallback_name: char_1012_skadi2_2
|
|
||||||
logo_name: logo_egir
|
|
||||||
preview: preview.jpg
|
|
||||||
project_json: project.json
|
|
||||||
release_folder: ./release/{name}/
|
|
||||||
source_folder: ./operator/{name}/extracted/
|
|
||||||
target_folder: ./operator/{name}/processed/
|
|
||||||
title: Skadi the Corrupting Heart
|
|
||||||
use_skel: true
|
|
||||||
config:
|
|
||||||
index.html:
|
index.html:
|
||||||
operator_logo: logo_egir
|
operator_logo: logo_egir
|
||||||
title: Skadi the Corrupting Heart
|
title: Skadi the Corrupting Heart
|
||||||
@@ -115,3 +82,9 @@ server:
|
|||||||
operator_folder: ./operator/
|
operator_folder: ./operator/
|
||||||
release_folder: ./release/
|
release_folder: ./release/
|
||||||
template_folder: ./template/
|
template_folder: ./template/
|
||||||
|
operator:
|
||||||
|
use_skel: true
|
||||||
|
preview: preview.jpg
|
||||||
|
project_json: project.json
|
||||||
|
source_folder: ./operator/{name}/extracted/
|
||||||
|
target_folder: ./operator/{name}/processed/
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ class Builder:
|
|||||||
|
|
||||||
def __build_assets(self, operator_name):
|
def __build_assets(self, operator_name):
|
||||||
|
|
||||||
use_skel = self.config["operators"][operator_name]["use_skel"]
|
use_skel = self.config["operator"]["use_skel"]
|
||||||
source_path = self.config["operators"][operator_name]["source_folder"].format(name=operator_name)
|
source_path = self.config["operator"]["source_folder"].format(name=operator_name)
|
||||||
target_path = self.config["operators"][operator_name]["target_folder"].format(name=operator_name)
|
target_path = self.config["operator"]["target_folder"].format(name=operator_name)
|
||||||
common_name = self.config["operators"][operator_name]["common_name"]
|
common_name = self.config["operators"][operator_name]["operator_settings.js"]["filename"]
|
||||||
fallback_name = self.config["operators"][operator_name]["fallback_name"]
|
fallback_name = self.config["operators"][operator_name]["index.html"]["fallback_name"]
|
||||||
file_paths = dict(
|
file_paths = dict(
|
||||||
json=target_path + common_name + ".json",
|
json=target_path + common_name + ".json",
|
||||||
atlas=target_path + common_name + ".atlas",
|
atlas=target_path + common_name + ".atlas",
|
||||||
@@ -219,7 +219,7 @@ class Builder:
|
|||||||
target_path = self.config["server"]["release_folder"]
|
target_path = self.config["server"]["release_folder"]
|
||||||
operator_release_path = pathlib.Path.cwd().joinpath(target_path, operator_name)
|
operator_release_path = pathlib.Path.cwd().joinpath(target_path, operator_name)
|
||||||
release_operator_assets_path = pathlib.Path.cwd().joinpath(operator_release_path, self.config["server"]["operator_folder"])
|
release_operator_assets_path = pathlib.Path.cwd().joinpath(operator_release_path, self.config["server"]["operator_folder"])
|
||||||
operator_assets_path = pathlib.Path.cwd().joinpath(self.config["operators"][operator_name]["target_folder"].format(name=operator_name), "..")
|
operator_assets_path = pathlib.Path.cwd().joinpath(self.config["operator"]["target_folder"].format(name=operator_name), "..")
|
||||||
template_path = pathlib.Path.cwd().joinpath(self.config["server"]["template_folder"])
|
template_path = pathlib.Path.cwd().joinpath(self.config["server"]["template_folder"])
|
||||||
|
|
||||||
if operator_release_path.exists() is True:
|
if operator_release_path.exists() is True:
|
||||||
@@ -230,7 +230,7 @@ class Builder:
|
|||||||
for file in operator_assets_path.iterdir():
|
for file in operator_assets_path.iterdir():
|
||||||
if file.is_file() is True:
|
if file.is_file() is True:
|
||||||
filename = file.name
|
filename = file.name
|
||||||
if filename == self.config["operators"][operator_name]["project_json"] or filename == self.config["operators"][operator_name]["preview"]:
|
if filename == self.config["operator"]["project_json"] or filename == self.config["operator"]["preview"]:
|
||||||
file_path = pathlib.Path.cwd().joinpath(operator_release_path, filename)
|
file_path = pathlib.Path.cwd().joinpath(operator_release_path, filename)
|
||||||
else:
|
else:
|
||||||
file_path = pathlib.Path.cwd().joinpath(release_operator_assets_path, filename)
|
file_path = pathlib.Path.cwd().joinpath(release_operator_assets_path, filename)
|
||||||
|
|||||||
@@ -8,25 +8,55 @@ class Config:
|
|||||||
config=dict(
|
config=dict(
|
||||||
server=dict,
|
server=dict,
|
||||||
operators=dict,
|
operators=dict,
|
||||||
|
operator=dict,
|
||||||
),
|
),
|
||||||
server=dict(
|
server=dict(
|
||||||
template_folder=str,
|
template_folder=str,
|
||||||
release_folder=str,
|
release_folder=str,
|
||||||
operator_folder=str,
|
operator_folder=str,
|
||||||
),
|
),
|
||||||
operators=dict(
|
operators={
|
||||||
|
"index.html": dict,
|
||||||
|
"operator_settings.js": dict,
|
||||||
|
"project.json": dict
|
||||||
|
},
|
||||||
|
operator=dict(
|
||||||
|
use_skel=bool,
|
||||||
|
preview=str,
|
||||||
|
project_json=str,
|
||||||
source_folder=str,
|
source_folder=str,
|
||||||
target_folder=str,
|
target_folder=str,
|
||||||
common_name=str,
|
),
|
||||||
fallback_name=str,
|
operator_config={
|
||||||
release_folder=str,
|
"index.html": dict(
|
||||||
logo_name=str,
|
operator_logo=str,
|
||||||
project_json=str,
|
|
||||||
preview=str,
|
|
||||||
use_skel=bool,
|
|
||||||
title=str,
|
title=str,
|
||||||
config=dict,
|
version=str,
|
||||||
|
fallback_name=str,
|
||||||
|
),
|
||||||
|
"operator_settings.js": dict(
|
||||||
|
fallbackImage_height=int,
|
||||||
|
fallbackImage_width=int,
|
||||||
|
filename=str,
|
||||||
|
fps=int,
|
||||||
|
viewport_left=int,
|
||||||
|
viewport_right=int,
|
||||||
|
viewport_top=int,
|
||||||
|
viewport_bottom=int,
|
||||||
|
),
|
||||||
|
"project.json": dict(
|
||||||
|
description=str,
|
||||||
|
title=str,
|
||||||
|
ui_logo_opacity=int,
|
||||||
|
ui_logo_ratio=float,
|
||||||
|
ui_operator_logo=str,
|
||||||
|
ui_position_padding_left=int,
|
||||||
|
ui_position_padding_right=int,
|
||||||
|
ui_position_padding_top=int,
|
||||||
|
ui_position_padding_bottom=int,
|
||||||
|
workshopid=int,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
self.__read_config()
|
self.__read_config()
|
||||||
|
|
||||||
@@ -45,9 +75,14 @@ class Config:
|
|||||||
key = "server"
|
key = "server"
|
||||||
self.__config_check(key, self.config[key], self.valid_keys[key])
|
self.__config_check(key, self.config[key], self.valid_keys[key])
|
||||||
|
|
||||||
|
key = "operator"
|
||||||
|
self.__config_check(key, self.config[key], self.valid_keys[key])
|
||||||
|
|
||||||
key = "operators"
|
key = "operators"
|
||||||
for operator_name, operator_content in self.config[key].items():
|
for operator_name, operator_content in self.config[key].items():
|
||||||
self.__config_check(operator_name, operator_content, self.valid_keys[key])
|
self.__config_check(operator_name, operator_content, self.valid_keys[key])
|
||||||
|
for filename, filetype in self.config[key][operator_name].items():
|
||||||
|
self.__config_check(filename, filetype, self.valid_keys["operator_config"][filename])
|
||||||
|
|
||||||
# with open(self.config_path, 'w') as f:
|
# with open(self.config_path, 'w') as f:
|
||||||
# yaml.safe_dump(self.config, f, allow_unicode=True)
|
# yaml.safe_dump(self.config, f, allow_unicode=True)
|
||||||
@@ -60,7 +95,7 @@ class Config:
|
|||||||
if key in checklist:
|
if key in checklist:
|
||||||
required_type = required_keys[key]
|
required_type = required_keys[key]
|
||||||
else:
|
else:
|
||||||
break
|
continue
|
||||||
if value_type != required_type:
|
if value_type != required_type:
|
||||||
raise TypeError("Item {key} in config.yaml is not set up correctly. Type {value_type} is detected, but type {required_type} is required.".format(key=key, value_type=value_type.__name__, required_type=required_type.__name__))
|
raise TypeError("Item {key} in config.yaml is not set up correctly. Type {value_type} is detected, but type {required_type} is required.".format(key=key, value_type=value_type.__name__, required_type=required_type.__name__))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ class ContentProcessor:
|
|||||||
|
|
||||||
def __init__(self, config, operator_name):
|
def __init__(self, config, operator_name):
|
||||||
self.config = config["operators"][operator_name]
|
self.config = config["operators"][operator_name]
|
||||||
self.file_to_process = [key for key, value in self.config["config"].items()]
|
self.file_to_process = [key for key, value in self.config.items()]
|
||||||
self.settings = self.config["config"]
|
self.settings = self.config
|
||||||
self.evalable = [
|
self.evalable = [
|
||||||
"__get_version"
|
"__get_version"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user