feat(builder): finish builder
This commit is contained in:
@@ -53,7 +53,8 @@ class AkLive2D:
|
|||||||
dest="operator_name",
|
dest="operator_name",
|
||||||
type=str,
|
type=str,
|
||||||
required=True,
|
required=True,
|
||||||
help="<Required> Operatro to develop"
|
help="<Required> Operatro to develop",
|
||||||
|
choices=[key for key in self.config["operators"]]
|
||||||
)
|
)
|
||||||
|
|
||||||
build = subprasers.add_parser(
|
build = subprasers.add_parser(
|
||||||
@@ -67,7 +68,7 @@ class AkLive2D:
|
|||||||
"--operator",
|
"--operator",
|
||||||
dest="operator_names",
|
dest="operator_names",
|
||||||
type=str,
|
type=str,
|
||||||
default="all",
|
default=["all"],
|
||||||
nargs='+',
|
nargs='+',
|
||||||
help="Operatro to build",
|
help="Operatro to build",
|
||||||
choices=["all"] + [key for key in self.config["operators"]]
|
choices=["all"] + [key for key in self.config["operators"]]
|
||||||
@@ -78,7 +79,7 @@ class AkLive2D:
|
|||||||
self.running = Server(self.args.port, self.args.operator_name, self.config)
|
self.running = Server(self.args.port, self.args.operator_name, self.config)
|
||||||
|
|
||||||
if self.args.command == "build" or self.args.command == "b":
|
if self.args.command == "build" or self.args.command == "b":
|
||||||
self.running = Builder(self.args.operator_names, self.config["operators"])
|
self.running = Builder(self.config, self.args.operator_names)
|
||||||
|
|
||||||
self.running.start()
|
self.running.start()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
operators:
|
operators:
|
||||||
skadi:
|
skadi:
|
||||||
common_name: dyn_illust_char_1012_skadi2
|
common_name: dyn_illust_char_1012_skadi2
|
||||||
|
preview: preview.jpg
|
||||||
|
project_json: project.json
|
||||||
release_folder: ./release/{name}/
|
release_folder: ./release/{name}/
|
||||||
source_folder: ./operator/{name}/extracted/
|
source_folder: ./operator/{name}/extracted/
|
||||||
target_folder: ./operator/{name}/
|
target_folder: ./operator/{name}/
|
||||||
|
|||||||
@@ -27,4 +27,4 @@ class AtlasReader:
|
|||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
self.file_path,
|
self.file_path,
|
||||||
self.save_path
|
self.save_path
|
||||||
)
|
)
|
||||||
|
|||||||
122
lib/builder.py
122
lib/builder.py
@@ -1,4 +1,5 @@
|
|||||||
import threading
|
import threading
|
||||||
|
import shutil
|
||||||
from lib.skeleton_binary import SkeletonBinary
|
from lib.skeleton_binary import SkeletonBinary
|
||||||
from lib.alpha_composite import AlphaComposite
|
from lib.alpha_composite import AlphaComposite
|
||||||
from lib.atlas_reader import AtlasReader
|
from lib.atlas_reader import AtlasReader
|
||||||
@@ -6,48 +7,44 @@ from lib.base64_util import *
|
|||||||
|
|
||||||
class Builder:
|
class Builder:
|
||||||
|
|
||||||
def __init__(self, operator_name, config) -> None:
|
def __init__(self, config, operator_names=list()) -> None:
|
||||||
self.operator_name = operator_name
|
self.operator_names = operator_names
|
||||||
self.config = config
|
self.config = config
|
||||||
self.use_skel = config["operators"][operator_name]["use_skel"]
|
|
||||||
self.source_path = config["operators"][operator_name]["source_folder"].format(name=operator_name)
|
|
||||||
self.target_path = config["operators"][operator_name]["target_folder"].format(name=operator_name)
|
|
||||||
self.common_name = config["operators"][operator_name]["common_name"]
|
|
||||||
self.file_paths = dict(
|
|
||||||
json=self.target_path + self.common_name + ".json",
|
|
||||||
atlas=self.target_path + self.common_name + ".atlas",
|
|
||||||
skel=self.target_path + self.common_name + ".skel",
|
|
||||||
)
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
# self.__build_assets()
|
if "all" in self.operator_names:
|
||||||
# self.__set_version()
|
self.operator_names = [operator_name for operator_name in self.config["operators"]]
|
||||||
# name = "skadi"
|
for operator_name in self.operator_names:
|
||||||
# print(self.config[name]["source_folder"].format(name=name))
|
self.build_assets(operator_name)
|
||||||
source = "./operator/skadi/extracted/"
|
self.__release_file(operator_name)
|
||||||
target = "./operator/skadi/"
|
|
||||||
name = "dyn_illust_char_1012_skadi2"
|
|
||||||
print("build")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def stop(self):
|
def build_assets(self, operator_name):
|
||||||
return
|
|
||||||
|
|
||||||
def build_assets(self):
|
use_skel = self.config["operators"][operator_name]["use_skel"]
|
||||||
operator_file = pathlib.Path.cwd().joinpath(self.target_path, "operator.js")
|
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"]
|
||||||
|
file_paths = dict(
|
||||||
|
json=target_path + common_name + ".json",
|
||||||
|
atlas=target_path + common_name + ".atlas",
|
||||||
|
skel=target_path + common_name + ".skel",
|
||||||
|
)
|
||||||
|
|
||||||
|
operator_file = pathlib.Path.cwd().joinpath(target_path, "operator.js")
|
||||||
if operator_file.exists() is False:
|
if operator_file.exists() is False:
|
||||||
print("Building operaotr data...")
|
print("Building operaotr data for {}...".format(operator_name))
|
||||||
|
|
||||||
alpha_composite_threads = list()
|
alpha_composite_threads = list()
|
||||||
png_to_base64_threads = list()
|
png_to_base64_threads = list()
|
||||||
prefix = "window.operator = "
|
prefix = "window.operator = "
|
||||||
data = dict()
|
data = dict()
|
||||||
|
|
||||||
ar = AtlasReader(self.source_path + self.common_name, self.target_path + self.common_name)
|
ar = AtlasReader(source_path + common_name, target_path + common_name)
|
||||||
|
|
||||||
skeleton_binary_thread = threading.Thread(
|
skeleton_binary_thread = threading.Thread(
|
||||||
target=SkeletonBinary,
|
target=SkeletonBinary,
|
||||||
args=(self.source_path + self.common_name, self.target_path + self.common_name, self.use_skel),
|
args=(source_path + common_name, target_path + common_name, use_skel),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
)
|
)
|
||||||
ar_thread = threading.Thread(
|
ar_thread = threading.Thread(
|
||||||
@@ -57,9 +54,9 @@ class Builder:
|
|||||||
atlas_base64_thread = threading.Thread(
|
atlas_base64_thread = threading.Thread(
|
||||||
target=self.__atlas_to_base64,
|
target=self.__atlas_to_base64,
|
||||||
args=(
|
args=(
|
||||||
self.file_paths["atlas"],
|
file_paths["atlas"],
|
||||||
data,
|
data,
|
||||||
".{}".format(self.config["server"]["operator_folder"]) + self.common_name + ".atlas",
|
".{}".format(self.config["server"]["operator_folder"]) + common_name + ".atlas",
|
||||||
),
|
),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
)
|
)
|
||||||
@@ -73,7 +70,7 @@ class Builder:
|
|||||||
for item in ar.images:
|
for item in ar.images:
|
||||||
alpha_composite_thread = threading.Thread(
|
alpha_composite_thread = threading.Thread(
|
||||||
target=AlphaComposite,
|
target=AlphaComposite,
|
||||||
args=(self.source_path + item, self.target_path + item),
|
args=(source_path + item, target_path + item),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
)
|
)
|
||||||
alpha_composite_threads.append(alpha_composite_thread)
|
alpha_composite_threads.append(alpha_composite_thread)
|
||||||
@@ -86,7 +83,7 @@ class Builder:
|
|||||||
png_to_base64_thread = threading.Thread(
|
png_to_base64_thread = threading.Thread(
|
||||||
target=self.__png_to_base64,
|
target=self.__png_to_base64,
|
||||||
args=(
|
args=(
|
||||||
self.target_path + item,
|
target_path + item,
|
||||||
data,
|
data,
|
||||||
".{}".format(self.config["server"]["operator_folder"]) + item,
|
".{}".format(self.config["server"]["operator_folder"]) + item,
|
||||||
),
|
),
|
||||||
@@ -97,13 +94,13 @@ class Builder:
|
|||||||
png_to_base64_thread.start()
|
png_to_base64_thread.start()
|
||||||
|
|
||||||
skeleton_binary_thread.join()
|
skeleton_binary_thread.join()
|
||||||
if self.use_skel is True:
|
if use_skel is True:
|
||||||
skel_base64_thread =threading.Thread(
|
skel_base64_thread =threading.Thread(
|
||||||
target=self.__skel_to_base64,
|
target=self.__skel_to_base64,
|
||||||
args=(
|
args=(
|
||||||
self.file_paths["skel"],
|
file_paths["skel"],
|
||||||
data,
|
data,
|
||||||
".{}".format(self.config["server"]["operator_folder"]) + self.common_name + ".skel",
|
".{}".format(self.config["server"]["operator_folder"]) + common_name + ".skel",
|
||||||
),
|
),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
)
|
)
|
||||||
@@ -113,9 +110,9 @@ class Builder:
|
|||||||
json_base64_thread =threading.Thread(
|
json_base64_thread =threading.Thread(
|
||||||
target=self.__json_to_base64,
|
target=self.__json_to_base64,
|
||||||
args=(
|
args=(
|
||||||
self.file_paths["json"],
|
file_paths["json"],
|
||||||
data,
|
data,
|
||||||
".{}".format(self.config["server"]["operator_folder"]) + self.common_name + ".json",
|
".{}".format(self.config["server"]["operator_folder"]) + common_name + ".json",
|
||||||
),
|
),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
)
|
)
|
||||||
@@ -131,12 +128,9 @@ class Builder:
|
|||||||
with open(operator_file, "w") as f:
|
with open(operator_file, "w") as f:
|
||||||
f.write(jsonContent)
|
f.write(jsonContent)
|
||||||
|
|
||||||
print("Finished building operaotr data")
|
print("Finished building operaotr data for {}.".format(operator_name))
|
||||||
return
|
else:
|
||||||
|
print("Operaotr data for {} has been built.".format(operator_name))
|
||||||
def __set_version(self):
|
|
||||||
version = input("Enter build version: ")
|
|
||||||
print(version)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def __json_to_base64(self, path, dict=None, key=None):
|
def __json_to_base64(self, path, dict=None, key=None):
|
||||||
@@ -175,3 +169,49 @@ class Builder:
|
|||||||
dict[key] = result
|
dict[key] = result
|
||||||
else:
|
else:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def __release_file(self, operator_name):
|
||||||
|
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, ".{}".format(self.config["server"]["operator_folder"]))
|
||||||
|
operator_assets_path = pathlib.Path.cwd().joinpath(self.config["operators"][operator_name]["target_folder"].format(name=operator_name))
|
||||||
|
template_path = pathlib.Path.cwd().joinpath(".{}".format(self.config["server"]["template_folder"]))
|
||||||
|
|
||||||
|
if operator_release_path.exists() is True:
|
||||||
|
shutil.rmtree(operator_release_path)
|
||||||
|
operator_release_path.mkdir()
|
||||||
|
release_operator_assets_path.mkdir()
|
||||||
|
|
||||||
|
|
||||||
|
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"]:
|
||||||
|
file_path = pathlib.Path.cwd().joinpath(operator_release_path, filename)
|
||||||
|
else:
|
||||||
|
file_path = pathlib.Path.cwd().joinpath(release_operator_assets_path, filename)
|
||||||
|
|
||||||
|
shutil.copyfile(
|
||||||
|
file,
|
||||||
|
file_path
|
||||||
|
)
|
||||||
|
|
||||||
|
for file in template_path.iterdir():
|
||||||
|
if file.is_file() is True:
|
||||||
|
filename = file.name
|
||||||
|
file_path = pathlib.Path.cwd().joinpath(operator_release_path, filename)
|
||||||
|
|
||||||
|
shutil.copyfile(
|
||||||
|
file,
|
||||||
|
file_path
|
||||||
|
)
|
||||||
|
elif file.is_dir() is True:
|
||||||
|
filename = file.name
|
||||||
|
file_path = pathlib.Path.cwd().joinpath(operator_release_path, filename)
|
||||||
|
|
||||||
|
shutil.copytree(
|
||||||
|
file,
|
||||||
|
file_path
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class Config:
|
|||||||
target_folder=str,
|
target_folder=str,
|
||||||
common_name=str,
|
common_name=str,
|
||||||
release_folder=str,
|
release_folder=str,
|
||||||
|
project_json=str,
|
||||||
|
preview=str,
|
||||||
use_skel=bool,
|
use_skel=bool,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Server:
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
# build assets first
|
# build assets first
|
||||||
Builder(self.operator, self.config).build_assets()
|
Builder(self.config).build_assets(self.operator)
|
||||||
print("Server is up at 0.0.0.0:{port}".format(port=self.port))
|
print("Server is up at 0.0.0.0:{port}".format(port=self.port))
|
||||||
self.httpd.serve_forever()
|
self.httpd.serve_forever()
|
||||||
return
|
return
|
||||||
|
|||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Pillow==8.2.0
|
||||||
|
PyYAML==5.4.1
|
||||||
@@ -4244,6 +4244,7 @@ var spine;
|
|||||||
mesh.height = height * scale;
|
mesh.height = height * scale;
|
||||||
}
|
}
|
||||||
mesh.inheritDeform = inheritDeform;
|
mesh.inheritDeform = inheritDeform;
|
||||||
|
// this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform));
|
||||||
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4));
|
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4));
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
@@ -4741,6 +4742,13 @@ var spine;
|
|||||||
return BinaryInput;
|
return BinaryInput;
|
||||||
}());
|
}());
|
||||||
var LinkedMesh = (function () {
|
var LinkedMesh = (function () {
|
||||||
|
// function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||||
|
// this.mesh = mesh;
|
||||||
|
// this.skin = skin;
|
||||||
|
// this.slotIndex = slotIndex;
|
||||||
|
// this.parent = parent;
|
||||||
|
// this.inheritDeform = inheritDeform;
|
||||||
|
// }
|
||||||
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
||||||
this.mesh = mesh;
|
this.mesh = mesh;
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script src="./assets/spine-player.js"></script>
|
<script type="text/javascript" src="./assets/spine-player.js"></script>
|
||||||
<script type="text/javascript" src="./operator/operator.js"></script>
|
<script type="text/javascript" src="./operator/operator.js"></script>
|
||||||
<script type="text/javascript" src="./operator/settings.js"></script>
|
<script type="text/javascript" src="./operator/settings.js"></script>
|
||||||
<script type="text/javascript" src="./assets/runner.js"></script>
|
<script type="text/javascript" src="./assets/runner.js"></script>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 734 KiB |
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"contentrating" : "Everyone",
|
|
||||||
"description" : "Live 2Di - Skadi the Corrupting Heart/浊心斯卡蒂 Live 2D",
|
|
||||||
"file" : "index.html",
|
|
||||||
"general" :
|
|
||||||
{
|
|
||||||
"properties" :
|
|
||||||
{
|
|
||||||
"schemecolor" :
|
|
||||||
{
|
|
||||||
"order" : 0,
|
|
||||||
"text" : "ui_browse_properties_scheme_color",
|
|
||||||
"type" : "color",
|
|
||||||
"value" : "0 0 0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"preview" : "preview.jpg",
|
|
||||||
"tags" : [ "Game" ],
|
|
||||||
"title" : "Skadi the Corrupting Heart - 浊心斯卡蒂",
|
|
||||||
"type" : "web",
|
|
||||||
"version" : 1,
|
|
||||||
"workshopid" : "2492307783",
|
|
||||||
"workshopurl" : "steam://url/CommunityFilePage/2492307783"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user