mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-15 00:08:11 -07:00
Fix animation pathing
This commit is contained in:
+4
-3
@@ -260,6 +260,7 @@ class Main(App):
|
||||
# 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()
|
||||
|
||||
@@ -291,10 +292,10 @@ class Main(App):
|
||||
self.logger.info(f"Processing Dolphin sources")
|
||||
dolphin = Dolphin()
|
||||
self.logger.info(f"Loading data")
|
||||
if not 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])
|
||||
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(valid_dirs)
|
||||
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")
|
||||
|
||||
@@ -3,6 +3,7 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import pathlib
|
||||
from collections import Counter
|
||||
|
||||
from flipper.utils.fff import *
|
||||
@@ -34,6 +35,7 @@ class DolphinBubbleAnimation:
|
||||
min_level: int,
|
||||
max_level: int,
|
||||
weight: int,
|
||||
subpath: str = None
|
||||
):
|
||||
# Manifest
|
||||
self.name = name
|
||||
@@ -42,6 +44,7 @@ class DolphinBubbleAnimation:
|
||||
self.min_level = min_level
|
||||
self.max_level = max_level
|
||||
self.weight = weight
|
||||
self.subpath = subpath
|
||||
# Meta and data
|
||||
self.meta = {}
|
||||
self.frames = []
|
||||
@@ -184,7 +187,10 @@ class DolphinBubbleAnimation:
|
||||
bubble["_NextBubbleIndex"] = bubble_index + 1
|
||||
|
||||
def save(self, output_directory: str):
|
||||
animation_directory = os.path.join(output_directory, self.name)
|
||||
if self.subpath:
|
||||
animation_directory = os.path.join(output_directory, self.subpath, self.name)
|
||||
else:
|
||||
animation_directory = os.path.join(output_directory, self.name)
|
||||
os.makedirs(animation_directory, exist_ok=True)
|
||||
meta_filename = os.path.join(animation_directory, "meta.txt")
|
||||
|
||||
@@ -257,7 +263,7 @@ class DolphinManifest:
|
||||
self.animations = []
|
||||
self.logger = logging.getLogger("DolphinManifest")
|
||||
|
||||
def load(self, loc: str):
|
||||
def load(self, loc: str, subpath: str = None):
|
||||
manifest_filename = os.path.join(loc, "manifest.txt")
|
||||
|
||||
file = FlipperFormatFile()
|
||||
@@ -288,19 +294,11 @@ class DolphinManifest:
|
||||
|
||||
# Initialize animation
|
||||
animation = DolphinBubbleAnimation(
|
||||
name, min_butthurt, max_butthurt, min_level, max_level, weight
|
||||
name, min_butthurt, max_butthurt, min_level, max_level, weight, subpath
|
||||
)
|
||||
|
||||
# Load Animation meta and frames
|
||||
|
||||
# handle both slash types bc we can
|
||||
newname = name.split("\\")
|
||||
if len(newname) < 2:
|
||||
newname = name.split("/")
|
||||
|
||||
newname = str(newname[-1])
|
||||
|
||||
animation.load(os.path.join(loc, newname))
|
||||
animation.load(os.path.join(loc, name))
|
||||
|
||||
# Add to array
|
||||
self.animations.append(animation)
|
||||
@@ -369,12 +367,20 @@ class Dolphin:
|
||||
self.manifest = DolphinManifest()
|
||||
self.logger = logging.getLogger("Dolphin")
|
||||
|
||||
def load(self, valid_dirs: list):
|
||||
for path in valid_dirs:
|
||||
assert os.path.isdir(path)
|
||||
def load(self, input_directory, dirs: list = None):
|
||||
if dirs:
|
||||
input = str(pathlib.Path(input_directory).absolute())
|
||||
for path in dirs:
|
||||
path = str(pathlib.Path(path).absolute())
|
||||
assert os.path.isdir(path)
|
||||
# Load Manifest
|
||||
self.logger.info(f"Loading directory {path}")
|
||||
self.manifest.load(path, subpath=path.removeprefix(input + os.sep))
|
||||
else:
|
||||
assert os.path.isdir(input_directory)
|
||||
# Load Manifest
|
||||
self.logger.info(f"Loading directory {path}")
|
||||
self.manifest.load(path)
|
||||
self.logger.info(f"Loading directory {input_directory}")
|
||||
self.manifest.load(input_directory)
|
||||
|
||||
def pack(self, output_directory: str, symbol_name: str = None):
|
||||
self.manifest.save(output_directory, symbol_name)
|
||||
|
||||
Reference in New Issue
Block a user