diff --git a/config.yaml b/config.yaml index 5b8ee4c..47f51d8 100644 --- a/config.yaml +++ b/config.yaml @@ -1,117 +1,90 @@ operators: 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: - operator_logo: logo_rhodes_override - title: Ch'en the Holungday - version: __get_version - fallback_name: char_1013_chen2_2 - operator_settings.js: - fallbackImage_height: 2048 - fallbackImage_width: 2048 - filename: dyn_illust_char_1013_chen2 - fps: 60 - opacity: 100 - viewport_bottom: 1 - viewport_left: 0 - viewport_right: 0 - viewport_top: 1 - 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' - title: 'Arknights: Ch''en/Chen the Holungday - 明日方舟:假日威龙陈' - ui_logo_opacity: 100 - ui_logo_ratio: 61.8 - ui_operator_logo: 'true' - ui_position_padding_bottom: 1 - ui_position_padding_left: 0 - ui_position_padding_right: 0 - ui_position_padding_top: 1 - workshopid: 2564643862 + index.html: + operator_logo: logo_rhodes_override + title: Ch'en the Holungday + version: __get_version + fallback_name: char_1013_chen2_2 + operator_settings.js: + fallbackImage_height: 2048 + fallbackImage_width: 2048 + filename: dyn_illust_char_1013_chen2 + fps: 60 + opacity: 100 + viewport_left: 0 + viewport_right: 0 + viewport_top: 1 + viewport_bottom: 1 + 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' + title: 'Arknights: Ch''en/Chen the Holungday - 明日方舟:假日威龙陈' + ui_logo_opacity: 100 + ui_logo_ratio: 61.8 + ui_operator_logo: 'true' + ui_position_padding_left: 0 + ui_position_padding_right: 0 + ui_position_padding_top: 1 + ui_position_padding_bottom: 1 + workshopid: 2564643862 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: - operator_logo: logo_sui - title: Nian - version: __get_version - fallback_name: char_2014_nian_2 - operator_settings.js: - fallbackImage_height: 2048 - fallbackImage_width: 2048 - filename: dyn_illust_char_2014_nian - fps: 60 - viewport_left: 2 - viewport_right: 2 - viewport_top: 3 - viewport_bottom: 5 - project.json: - description: 'Arknights: Nian 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/nian\nGithub: https://github.com/Halyul/aklive2d' - title: 'Arknights: Nian - 明日方舟:年' - ui_logo_opacity: 30 - ui_logo_ratio: 61.8 - ui_operator_logo: 'true' - ui_position_padding_left: 02 - ui_position_padding_right: 2 - ui_position_padding_top: 3 - ui_position_padding_bottom: 5 - workshopid: 2564642594 + index.html: + operator_logo: logo_sui + title: Nian + version: __get_version + fallback_name: char_2014_nian_2 + operator_settings.js: + fallbackImage_height: 2048 + fallbackImage_width: 2048 + filename: dyn_illust_char_2014_nian + fps: 60 + viewport_left: 2 + viewport_right: 2 + viewport_top: 3 + viewport_bottom: 5 + project.json: + description: 'Arknights: Nian 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/nian\nGithub: https://github.com/Halyul/aklive2d' + title: 'Arknights: Nian - 明日方舟:年' + ui_logo_opacity: 30 + ui_logo_ratio: 61.8 + ui_operator_logo: 'true' + ui_position_padding_left: 2 + ui_position_padding_right: 2 + ui_position_padding_top: 3 + ui_position_padding_bottom: 5 + workshopid: 2564642594 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: - operator_logo: logo_egir - title: Skadi the Corrupting Heart - version: __get_version - fallback_name: char_1012_skadi2_2 - operator_settings.js: - fallbackImage_height: 2048 - fallbackImage_width: 2048 - filename: dyn_illust_char_1012_skadi2 - fps: 60 - viewport_left: -5 - viewport_right: -10 - viewport_top: 0 - viewport_bottom: -12 - project.json: - description: 'Arknights: Skadi the Corrupting Heart Live 2Di\r\n明日方舟:浊心斯卡蒂 Live 2Di\r\nThe model is extracted from game with Spine support.\r\n模型来自游戏内提取,支持Spine\r\nPlease set your FPS target in Wallpaper Engine > Settings > Performance > FPS\r\n请在 Wallpaper Engine > 设置 > 性能 > FPS 下设置FPS\r\n\r\nLive preview on: https://arknights.halyul.dev/skadi\r\nGithub: https://github.com/Halyul/aklive2d' - title: 'Arknights: Skadi the Corrupting Heart - 明日方舟:浊心斯卡蒂' - ui_logo_opacity: 30 - ui_logo_ratio: 61.8 - ui_operator_logo: 'true' - ui_position_padding_left: -5 - ui_position_padding_right: -10 - ui_position_padding_top: 0 - ui_position_padding_bottom: -12 - workshopid: 2492307783 + index.html: + operator_logo: logo_egir + title: Skadi the Corrupting Heart + version: __get_version + fallback_name: char_1012_skadi2_2 + operator_settings.js: + fallbackImage_height: 2048 + fallbackImage_width: 2048 + filename: dyn_illust_char_1012_skadi2 + fps: 60 + viewport_left: -5 + viewport_right: -10 + viewport_top: 0 + viewport_bottom: -12 + project.json: + description: 'Arknights: Skadi the Corrupting Heart Live 2Di\r\n明日方舟:浊心斯卡蒂 Live 2Di\r\nThe model is extracted from game with Spine support.\r\n模型来自游戏内提取,支持Spine\r\nPlease set your FPS target in Wallpaper Engine > Settings > Performance > FPS\r\n请在 Wallpaper Engine > 设置 > 性能 > FPS 下设置FPS\r\n\r\nLive preview on: https://arknights.halyul.dev/skadi\r\nGithub: https://github.com/Halyul/aklive2d' + title: 'Arknights: Skadi the Corrupting Heart - 明日方舟:浊心斯卡蒂' + ui_logo_opacity: 30 + ui_logo_ratio: 61.8 + ui_operator_logo: 'true' + ui_position_padding_left: -5 + ui_position_padding_right: -10 + ui_position_padding_top: 0 + ui_position_padding_bottom: -12 + workshopid: 2492307783 server: operator_folder: ./operator/ release_folder: ./release/ template_folder: ./template/ +operator: + use_skel: true + preview: preview.jpg + project_json: project.json + source_folder: ./operator/{name}/extracted/ + target_folder: ./operator/{name}/processed/ diff --git a/lib/builder.py b/lib/builder.py index 5c65fb6..e265e92 100644 --- a/lib/builder.py +++ b/lib/builder.py @@ -57,11 +57,11 @@ class Builder: def __build_assets(self, operator_name): - use_skel = self.config["operators"][operator_name]["use_skel"] - source_path = self.config["operators"][operator_name]["source_folder"].format(name=operator_name) - target_path = self.config["operators"][operator_name]["target_folder"].format(name=operator_name) - common_name = self.config["operators"][operator_name]["common_name"] - fallback_name = self.config["operators"][operator_name]["fallback_name"] + use_skel = self.config["operator"]["use_skel"] + source_path = self.config["operator"]["source_folder"].format(name=operator_name) + target_path = self.config["operator"]["target_folder"].format(name=operator_name) + common_name = self.config["operators"][operator_name]["operator_settings.js"]["filename"] + fallback_name = self.config["operators"][operator_name]["index.html"]["fallback_name"] file_paths = dict( json=target_path + common_name + ".json", atlas=target_path + common_name + ".atlas", @@ -219,7 +219,7 @@ class Builder: target_path = self.config["server"]["release_folder"] 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"]) - 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"]) if operator_release_path.exists() is True: @@ -230,7 +230,7 @@ class Builder: for file in operator_assets_path.iterdir(): if file.is_file() is True: 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) else: file_path = pathlib.Path.cwd().joinpath(release_operator_assets_path, filename) diff --git a/lib/config.py b/lib/config.py index fe30b05..10c2683 100644 --- a/lib/config.py +++ b/lib/config.py @@ -8,25 +8,55 @@ class Config: config=dict( server=dict, operators=dict, + operator=dict, ), server=dict( template_folder=str, release_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, target_folder=str, - common_name=str, - fallback_name=str, - release_folder=str, - logo_name=str, - project_json=str, - preview=str, - use_skel=bool, - title=str, - config=dict, - ) + ), + operator_config={ + "index.html": dict( + operator_logo=str, + title=str, + 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() @@ -45,9 +75,14 @@ class Config: key = "server" 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" for operator_name, operator_content in self.config[key].items(): 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: # yaml.safe_dump(self.config, f, allow_unicode=True) @@ -60,7 +95,7 @@ class Config: if key in checklist: required_type = required_keys[key] else: - break + continue 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__)) else: diff --git a/lib/content_processor.py b/lib/content_processor.py index f92764a..9dd32a6 100644 --- a/lib/content_processor.py +++ b/lib/content_processor.py @@ -5,8 +5,8 @@ class ContentProcessor: def __init__(self, config, operator_name): self.config = config["operators"][operator_name] - self.file_to_process = [key for key, value in self.config["config"].items()] - self.settings = self.config["config"] + self.file_to_process = [key for key, value in self.config.items()] + self.settings = self.config self.evalable = [ "__get_version" ]