mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-11 19:33:30 -07:00
Revert "Merge branch 'dev' of https://github.com/ClaraCrazy/Flipper-Xtreme into dev"
This reverts commit 708dd167c8.
This commit is contained in:
+49
-21
@@ -43,12 +43,51 @@ def convert_bmx(img: "Image.Image | pathlib.Path") -> bytes:
|
||||
return data
|
||||
|
||||
|
||||
def pack_anim(src: pathlib.Path, dst: pathlib.Path):
|
||||
if not (src / "meta.txt").is_file():
|
||||
return
|
||||
dst.mkdir(parents=True, exist_ok=True)
|
||||
for frame in src.iterdir():
|
||||
if not frame.is_file():
|
||||
continue
|
||||
if frame.name == "meta.txt":
|
||||
shutil.copyfile(src / "meta.txt", dst / "meta.txt")
|
||||
continue
|
||||
elif frame.name.startswith("frame_"):
|
||||
(dst / frame.with_suffix(".bm").name).write_bytes(convert_bm(frame))
|
||||
|
||||
|
||||
def pack_icon_animated(src: pathlib.Path, dst: pathlib.Path):
|
||||
if not (src / "frame_rate").is_file():
|
||||
return
|
||||
dst.mkdir(parents=True, exist_ok=True)
|
||||
frame_count = 0
|
||||
frame_rate = None
|
||||
size = None
|
||||
for frame in src.iterdir():
|
||||
if not frame.is_file():
|
||||
continue
|
||||
if frame.name == "frame_rate":
|
||||
frame_rate = int((src / "frame_rate").read_text())
|
||||
continue
|
||||
elif frame.name.startswith("frame_"):
|
||||
frame_count += 1
|
||||
if not size:
|
||||
size = Image.open(frame).size
|
||||
(dst / frame.with_suffix(".bm").name).write_bytes(convert_bm(frame))
|
||||
(dst / "meta").write_bytes(struct.pack("<IIII", *size, frame_rate, frame_count))
|
||||
|
||||
|
||||
def pack_icon_static(src: pathlib.Path, dst: pathlib.Path):
|
||||
dst.parent.mkdir(parents=True, exist_ok=True)
|
||||
dst.with_suffix(".bmx").write_bytes(convert_bmx(src))
|
||||
|
||||
|
||||
def pack(
|
||||
input: "str | pathlib.Path", output: "str | pathlib.Path", logger: typing.Callable
|
||||
):
|
||||
input = pathlib.Path(input)
|
||||
output = pathlib.Path(output)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
for source in input.iterdir():
|
||||
if source == output:
|
||||
continue
|
||||
@@ -66,8 +105,6 @@ def pack(
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
packed.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if (source / "Anims/manifest.txt").exists():
|
||||
(packed / "Anims").mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(
|
||||
@@ -76,30 +113,21 @@ def pack(
|
||||
for anim in (source / "Anims").iterdir():
|
||||
if not anim.is_dir():
|
||||
continue
|
||||
(packed / "Anims" / anim.name).mkdir(parents=True, exist_ok=True)
|
||||
for frame in anim.iterdir():
|
||||
if not frame.is_file():
|
||||
continue
|
||||
if frame.name == "meta.txt":
|
||||
shutil.copyfile(
|
||||
frame, packed / "Anims" / anim.name / "meta.txt"
|
||||
)
|
||||
elif frame.name.startswith("frame_"):
|
||||
(
|
||||
packed / "Anims" / anim.name / frame.with_suffix(".bm").name
|
||||
).write_bytes(convert_bm(frame))
|
||||
pack_anim(anim, packed / "Anims" / anim.name)
|
||||
|
||||
if (source / "Icons").is_dir():
|
||||
for icons in (source / "Icons").iterdir():
|
||||
if not icons.is_dir():
|
||||
continue
|
||||
(packed / "Icons" / icons.name).mkdir(parents=True, exist_ok=True)
|
||||
for icon in icons.iterdir():
|
||||
if not icon.is_file():
|
||||
continue
|
||||
(
|
||||
packed / "Icons" / icons.name / icon.with_suffix(".bmx").name
|
||||
).write_bytes(convert_bmx(icon))
|
||||
if icon.is_dir():
|
||||
pack_icon_animated(
|
||||
icon, packed / "Icons" / icons.name / icon.name
|
||||
)
|
||||
elif icon.is_file():
|
||||
pack_icon_static(
|
||||
icon, packed / "Icons" / icons.name / icon.name
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+2
-33
@@ -26,20 +26,6 @@ ICONS_TEMPLATE_C_FRAME = "const uint8_t {name}[] = {data};\n"
|
||||
ICONS_TEMPLATE_C_DATA = "const uint8_t* const {name}[] = {data};\n"
|
||||
ICONS_TEMPLATE_C_ICONS = "const Icon {name} = {{.width={width},.height={height},.frame_count={frame_count},.frame_rate={frame_rate},.frames=_{name}}};\n"
|
||||
|
||||
valid_dirs = list()
|
||||
# This will not stay, dont worry! This is temp code until we got time to rewrite this all
|
||||
root_dir = pathlib.Path(__file__).absolute().parent.parent
|
||||
dolphin_external = root_dir / "assets/dolphin/external/"
|
||||
potential_directories = [
|
||||
item for item in dolphin_external.iterdir() if item.is_dir()
|
||||
] # Get all animation directories
|
||||
|
||||
for directory in potential_directories: # loop through all of them
|
||||
if (
|
||||
directory / "manifest.txt"
|
||||
).exists(): # check if they contain a manifest.txt TODO: This code should be moved to wherever manifest.txt files are validated!
|
||||
valid_dirs.append(directory) # append valid directory to list
|
||||
|
||||
|
||||
class Main(App):
|
||||
def init(self):
|
||||
@@ -263,20 +249,8 @@ class Main(App):
|
||||
else:
|
||||
self.logger.info("Manifest is up-to-date!")
|
||||
|
||||
# This will not stay, dont worry! This is temp code until we got time to rewrite this all
|
||||
global valid_dirs # access our global variable
|
||||
for (
|
||||
valid_dir
|
||||
) in valid_dirs: # We can copy the manifest for all of the valid dirs!
|
||||
(root_dir / f"assets/resources/dolphin/{valid_dir.name}").mkdir(
|
||||
parents=True, exist_ok=True
|
||||
)
|
||||
shutil.copyfile(
|
||||
valid_dir / "manifest.txt",
|
||||
root_dir / f"assets/resources/dolphin/{valid_dir.name}/manifest.txt",
|
||||
)
|
||||
(root_dir / "assets/resources/dolphin/manifest.txt").unlink()
|
||||
self.logger.info("Packing custom asset packs")
|
||||
root_dir = pathlib.Path(__file__).absolute().parent.parent
|
||||
asset_packer.pack(
|
||||
root_dir / "assets/dolphin/custom",
|
||||
root_dir / f"assets/resources/dolphin_custom",
|
||||
@@ -311,12 +285,7 @@ class Main(App):
|
||||
self.logger.info(f"Processing Dolphin sources")
|
||||
dolphin = Dolphin()
|
||||
self.logger.info(f"Loading data")
|
||||
if f"dolphin{os.sep}external" in str(
|
||||
self.args.input_directory
|
||||
): # AHEM... oopsie. This script apparently just loads all assets, not only external assets, lol.
|
||||
dolphin.load(self.args.input_directory, valid_dirs)
|
||||
else:
|
||||
dolphin.load(self.args.input_directory)
|
||||
dolphin.load(self.args.input_directory)
|
||||
self.logger.info(f"Packing")
|
||||
dolphin.pack(self.args.output_directory, self.args.symbol_name)
|
||||
self.logger.info(f"Complete")
|
||||
|
||||
Reference in New Issue
Block a user