Willy-JL 1 год назад
Родитель
Сommit
44bf7d27a7
2 измененных файлов с 15 добавлено и 9 удалено
  1. 6 6
      air_labyrinth/application.fam
  2. 9 3
      air_labyrinth/engine/scripts/sprite_builder.py

+ 6 - 6
air_labyrinth/application.fam

@@ -11,10 +11,10 @@ App(
     fap_author="@CodeAllNight (MrDerekJamison)",
     fap_author="@CodeAllNight (MrDerekJamison)",
     fap_version="0.1",
     fap_version="0.1",
     fap_file_assets="assets",  # Do not touch this and the next line, it is needed to generate sprites
     fap_file_assets="assets",  # Do not touch this and the next line, it is needed to generate sprites
-#    fap_extbuild=(
-#        ExtFile(
-#            path="${FAP_SRC_DIR}/assets",
-#            command="python3 ${FAP_SRC_DIR}/engine/scripts/sprite_builder.py ${FAP_SRC_DIR.abspath}/sprites ${TARGET.abspath}/sprites",
-#        ),
-#    ),
+    #    fap_extbuild=(
+    #        ExtFile(
+    #            path="${FAP_SRC_DIR}/assets",
+    #            command="python3 ${FAP_SRC_DIR}/engine/scripts/sprite_builder.py ${FAP_SRC_DIR.abspath}/sprites ${TARGET.abspath}/sprites",
+    #        ),
+    #    ),
 )
 )

+ 9 - 3
air_labyrinth/engine/scripts/sprite_builder.py

@@ -14,6 +14,7 @@ from PIL import Image, ImageOps
 #   uint32 height in px
 #   uint32 height in px
 #   uint8[] pixel data, every row is padded to 8 bits (like XBM)
 #   uint8[] pixel data, every row is padded to 8 bits (like XBM)
 
 
+
 def image2xbm(input_file_path):
 def image2xbm(input_file_path):
     with Image.open(input_file_path) as im:
     with Image.open(input_file_path) as im:
         with io.BytesIO() as output:
         with io.BytesIO() as output:
@@ -22,6 +23,7 @@ def image2xbm(input_file_path):
             bw.save(output, format="XBM")
             bw.save(output, format="XBM")
             return output.getvalue()
             return output.getvalue()
 
 
+
 def xbm2fxbm(data):
 def xbm2fxbm(data):
     # hell as it is, but it works
     # hell as it is, but it works
     f = io.StringIO(data.decode().strip())
     f = io.StringIO(data.decode().strip())
@@ -36,12 +38,13 @@ def xbm2fxbm(data):
     output += image_bin
     output += image_bin
     return output
     return output
 
 
+
 def process_sprites(input_dir, output_dir):
 def process_sprites(input_dir, output_dir):
     for root, dirs, files in os.walk(input_dir):
     for root, dirs, files in os.walk(input_dir):
         for file in files:
         for file in files:
-            if file.startswith('.'):
+            if file.startswith("."):
                 continue
                 continue
-            
+
             try:
             try:
                 input_file_path = os.path.join(root, file)
                 input_file_path = os.path.join(root, file)
                 rel_path = os.path.relpath(input_file_path, input_dir)
                 rel_path = os.path.relpath(input_file_path, input_dir)
@@ -58,6 +61,7 @@ def process_sprites(input_dir, output_dir):
             except Exception as e:
             except Exception as e:
                 print(f"Cannot convert '{rel_path}': {e}")
                 print(f"Cannot convert '{rel_path}': {e}")
 
 
+
 def clear_directory(directory):
 def clear_directory(directory):
     for root, dirs, files in os.walk(directory, topdown=False):
     for root, dirs, files in os.walk(directory, topdown=False):
         for name in files:
         for name in files:
@@ -65,6 +69,7 @@ def clear_directory(directory):
         for name in dirs:
         for name in dirs:
             os.rmdir(os.path.join(root, name))
             os.rmdir(os.path.join(root, name))
 
 
+
 def main():
 def main():
     parser = argparse.ArgumentParser()
     parser = argparse.ArgumentParser()
     parser.add_argument("source", help="Source directory")
     parser.add_argument("source", help="Source directory")
@@ -80,5 +85,6 @@ def main():
 
 
     return 0
     return 0
 
 
+
 if __name__ == "__main__":
 if __name__ == "__main__":
-    main()
+    main()