2020-10-26 20:00:17 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
from flipper.app import App
|
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
import logging
|
|
|
|
import argparse
|
|
|
|
import subprocess
|
|
|
|
import io
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
ICONS_SUPPORTED_FORMATS = ["png"]
|
|
|
|
|
|
|
|
ICONS_TEMPLATE_H_HEADER = """#pragma once
|
|
|
|
#include <gui/icon.h>
|
|
|
|
|
|
|
|
"""
|
2021-07-07 11:57:49 +03:00
|
|
|
ICONS_TEMPLATE_H_ICON_NAME = "extern const Icon {name};\n"
|
2020-10-26 20:00:17 +03:00
|
|
|
|
2021-07-07 11:57:49 +03:00
|
|
|
ICONS_TEMPLATE_C_HEADER = """#include \"assets_icons.h\"
|
2021-01-08 07:42:48 +03:00
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
#include <gui/icon_i.h>
|
|
|
|
|
|
|
|
"""
|
|
|
|
ICONS_TEMPLATE_C_FRAME = "const uint8_t {name}[] = {data};\n"
|
2022-02-13 22:24:03 +03:00
|
|
|
ICONS_TEMPLATE_C_DATA = "const uint8_t* const {name}[] = {data};\n"
|
2021-07-07 11:57:49 +03:00
|
|
|
ICONS_TEMPLATE_C_ICONS = "const Icon {name} = {{.width={width},.height={height},.frame_count={frame_count},.frame_rate={frame_rate},.frames=_{name}}};\n"
|
2020-10-26 20:00:17 +03:00
|
|
|
|
|
|
|
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
class Main(App):
|
|
|
|
def init(self):
|
2020-10-26 20:00:17 +03:00
|
|
|
# command args
|
|
|
|
self.subparsers = self.parser.add_subparsers(help="sub-command help")
|
|
|
|
self.parser_icons = self.subparsers.add_parser(
|
|
|
|
"icons", help="Process icons and build icon registry"
|
|
|
|
)
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
self.parser_icons.add_argument("input_directory", help="Source directory")
|
2021-09-13 12:52:50 +03:00
|
|
|
self.parser_icons.add_argument("output_directory", help="Output directory")
|
|
|
|
self.parser_icons.set_defaults(func=self.icons)
|
|
|
|
|
|
|
|
self.parser_manifest = self.subparsers.add_parser(
|
|
|
|
"manifest", help="Create directory Manifest"
|
2020-10-26 20:00:17 +03:00
|
|
|
)
|
2021-09-13 12:52:50 +03:00
|
|
|
self.parser_manifest.add_argument("local_path", help="local_path")
|
|
|
|
self.parser_manifest.set_defaults(func=self.manifest)
|
|
|
|
|
|
|
|
self.parser_copro = self.subparsers.add_parser(
|
|
|
|
"copro", help="Gather copro binaries for packaging"
|
2020-10-26 20:00:17 +03:00
|
|
|
)
|
2021-09-13 12:52:50 +03:00
|
|
|
self.parser_copro.add_argument("cube_dir", help="Path to Cube folder")
|
|
|
|
self.parser_copro.add_argument("output_dir", help="Path to output folder")
|
|
|
|
self.parser_copro.add_argument("mcu", help="MCU series as in copro folder")
|
2022-04-27 18:53:48 +03:00
|
|
|
self.parser_copro.add_argument(
|
|
|
|
"--cube_ver", dest="cube_ver", help="Cube version", required=True
|
|
|
|
)
|
|
|
|
self.parser_copro.add_argument(
|
|
|
|
"--stack_type", dest="stack_type", help="Stack type", required=True
|
|
|
|
)
|
|
|
|
self.parser_copro.add_argument(
|
|
|
|
"--stack_file",
|
|
|
|
dest="stack_file",
|
|
|
|
help="Stack file name in copro folder",
|
|
|
|
required=True,
|
|
|
|
)
|
|
|
|
self.parser_copro.add_argument(
|
|
|
|
"--stack_addr",
|
|
|
|
dest="stack_addr",
|
|
|
|
help="Stack flash address, as per release_notes",
|
|
|
|
type=lambda x: int(x, 16),
|
|
|
|
default=0,
|
|
|
|
required=False,
|
|
|
|
)
|
2021-09-13 12:52:50 +03:00
|
|
|
self.parser_copro.set_defaults(func=self.copro)
|
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
self.parser_dolphin = self.subparsers.add_parser(
|
|
|
|
"dolphin", help="Assemble dolphin resources"
|
|
|
|
)
|
|
|
|
self.parser_dolphin.add_argument(
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
"-s",
|
|
|
|
"--symbol-name",
|
|
|
|
help="Symbol and file name in dolphin output directory",
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
self.parser_dolphin.add_argument(
|
|
|
|
"input_directory", help="Dolphin source directory"
|
2022-01-03 00:39:56 +03:00
|
|
|
)
|
|
|
|
self.parser_dolphin.add_argument(
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
"output_directory", help="Dolphin output directory"
|
2022-01-03 00:39:56 +03:00
|
|
|
)
|
|
|
|
self.parser_dolphin.set_defaults(func=self.dolphin)
|
|
|
|
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
def _icon2header(self, file):
|
|
|
|
output = subprocess.check_output(["convert", file, "xbm:-"])
|
|
|
|
assert output
|
|
|
|
f = io.StringIO(output.decode().strip())
|
|
|
|
width = int(f.readline().strip().split(" ")[2])
|
|
|
|
height = int(f.readline().strip().split(" ")[2])
|
|
|
|
data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1]
|
|
|
|
data_bin_str = data[1:-1].replace(",", " ").replace("0x", "")
|
|
|
|
data_bin = bytearray.fromhex(data_bin_str)
|
|
|
|
# Encode icon data with LZSS
|
|
|
|
data_encoded_str = subprocess.check_output(
|
|
|
|
["heatshrink", "-e", "-w8", "-l4"], input=data_bin
|
|
|
|
)
|
|
|
|
assert data_encoded_str
|
|
|
|
data_enc = bytearray(data_encoded_str)
|
|
|
|
data_enc = bytearray([len(data_enc) & 0xFF, len(data_enc) >> 8]) + data_enc
|
|
|
|
# Use encoded data only if its lenght less than original, including header
|
|
|
|
if len(data_enc) < len(data_bin) + 1:
|
|
|
|
data = (
|
|
|
|
"{0x01,0x00,"
|
|
|
|
+ "".join("0x{:02x},".format(byte) for byte in data_enc)
|
|
|
|
+ "}"
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
data = "{0x00," + data[1:]
|
|
|
|
return width, height, data
|
|
|
|
|
|
|
|
def _iconIsSupported(self, filename):
|
|
|
|
extension = filename.lower().split(".")[-1]
|
|
|
|
return extension in ICONS_SUPPORTED_FORMATS
|
2020-10-26 20:00:17 +03:00
|
|
|
|
|
|
|
def icons(self):
|
|
|
|
self.logger.debug(f"Converting icons")
|
|
|
|
icons_c = open(os.path.join(self.args.output_directory, "assets_icons.c"), "w")
|
|
|
|
icons_c.write(ICONS_TEMPLATE_C_HEADER)
|
|
|
|
icons = []
|
|
|
|
# Traverse icons tree, append image data to source file
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
for dirpath, dirnames, filenames in os.walk(self.args.input_directory):
|
2020-10-26 20:00:17 +03:00
|
|
|
self.logger.debug(f"Processing directory {dirpath}")
|
2021-07-07 11:57:49 +03:00
|
|
|
dirnames.sort()
|
2022-01-03 00:39:56 +03:00
|
|
|
filenames.sort()
|
2020-10-26 20:00:17 +03:00
|
|
|
if not filenames:
|
|
|
|
continue
|
|
|
|
if "frame_rate" in filenames:
|
|
|
|
self.logger.debug(f"Folder contatins animation")
|
|
|
|
icon_name = "A_" + os.path.split(dirpath)[1].replace("-", "_")
|
|
|
|
width = height = None
|
|
|
|
frame_count = 0
|
|
|
|
frame_rate = 0
|
|
|
|
frame_names = []
|
|
|
|
for filename in sorted(filenames):
|
|
|
|
fullfilename = os.path.join(dirpath, filename)
|
|
|
|
if filename == "frame_rate":
|
|
|
|
frame_rate = int(open(fullfilename, "r").read().strip())
|
|
|
|
continue
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
elif not self._iconIsSupported(filename):
|
2020-10-26 20:00:17 +03:00
|
|
|
continue
|
|
|
|
self.logger.debug(f"Processing animation frame {filename}")
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
temp_width, temp_height, data = self._icon2header(fullfilename)
|
2020-10-26 20:00:17 +03:00
|
|
|
if width is None:
|
|
|
|
width = temp_width
|
|
|
|
if height is None:
|
|
|
|
height = temp_height
|
|
|
|
assert width == temp_width
|
|
|
|
assert height == temp_height
|
|
|
|
frame_name = f"_{icon_name}_{frame_count}"
|
|
|
|
frame_names.append(frame_name)
|
|
|
|
icons_c.write(
|
|
|
|
ICONS_TEMPLATE_C_FRAME.format(name=frame_name, data=data)
|
|
|
|
)
|
|
|
|
frame_count += 1
|
|
|
|
assert frame_rate > 0
|
|
|
|
assert frame_count > 0
|
|
|
|
icons_c.write(
|
|
|
|
ICONS_TEMPLATE_C_DATA.format(
|
|
|
|
name=f"_{icon_name}", data=f'{{{",".join(frame_names)}}}'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
icons_c.write("\n")
|
|
|
|
icons.append((icon_name, width, height, frame_rate, frame_count))
|
|
|
|
else:
|
|
|
|
# process icons
|
|
|
|
for filename in filenames:
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
if not self._iconIsSupported(filename):
|
2020-10-26 20:00:17 +03:00
|
|
|
continue
|
|
|
|
self.logger.debug(f"Processing icon {filename}")
|
|
|
|
icon_name = "I_" + "_".join(filename.split(".")[:-1]).replace(
|
|
|
|
"-", "_"
|
|
|
|
)
|
|
|
|
fullfilename = os.path.join(dirpath, filename)
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
width, height, data = self._icon2header(fullfilename)
|
2020-10-26 20:00:17 +03:00
|
|
|
frame_name = f"_{icon_name}_0"
|
|
|
|
icons_c.write(
|
|
|
|
ICONS_TEMPLATE_C_FRAME.format(name=frame_name, data=data)
|
|
|
|
)
|
|
|
|
icons_c.write(
|
|
|
|
ICONS_TEMPLATE_C_DATA.format(
|
|
|
|
name=f"_{icon_name}", data=f"{{{frame_name}}}"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
icons_c.write("\n")
|
|
|
|
icons.append((icon_name, width, height, 0, 1))
|
|
|
|
# Create array of images:
|
|
|
|
self.logger.debug(f"Finalizing source file")
|
|
|
|
for name, width, height, frame_rate, frame_count in icons:
|
|
|
|
icons_c.write(
|
2021-07-07 11:57:49 +03:00
|
|
|
ICONS_TEMPLATE_C_ICONS.format(
|
2020-10-26 20:00:17 +03:00
|
|
|
name=name,
|
|
|
|
width=width,
|
|
|
|
height=height,
|
|
|
|
frame_rate=frame_rate,
|
|
|
|
frame_count=frame_count,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
icons_c.write("\n")
|
2021-01-08 07:42:48 +03:00
|
|
|
# Create Public Header
|
2020-10-26 20:00:17 +03:00
|
|
|
self.logger.debug(f"Creating header")
|
|
|
|
icons_h = open(os.path.join(self.args.output_directory, "assets_icons.h"), "w")
|
|
|
|
icons_h.write(ICONS_TEMPLATE_H_HEADER)
|
|
|
|
for name, width, height, frame_rate, frame_count in icons:
|
|
|
|
icons_h.write(ICONS_TEMPLATE_H_ICON_NAME.format(name=name))
|
|
|
|
self.logger.debug(f"Done")
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
return 0
|
2020-10-26 20:00:17 +03:00
|
|
|
|
2021-09-13 12:52:50 +03:00
|
|
|
def manifest(self):
|
2022-01-03 00:39:56 +03:00
|
|
|
from flipper.assets.manifest import Manifest
|
2021-09-13 12:52:50 +03:00
|
|
|
|
|
|
|
directory_path = os.path.normpath(self.args.local_path)
|
|
|
|
if not os.path.isdir(directory_path):
|
|
|
|
self.logger.error(f'"{directory_path}" is not a directory')
|
|
|
|
exit(255)
|
|
|
|
manifest_file = os.path.join(directory_path, "Manifest")
|
|
|
|
old_manifest = Manifest()
|
|
|
|
if os.path.exists(manifest_file):
|
2022-04-27 18:53:48 +03:00
|
|
|
self.logger.info("Manifest is present, loading to compare")
|
2021-09-13 12:52:50 +03:00
|
|
|
old_manifest.load(manifest_file)
|
2022-04-27 18:53:48 +03:00
|
|
|
self.logger.info(
|
|
|
|
f'Creating temporary Manifest for directory "{directory_path}"'
|
|
|
|
)
|
2021-09-13 12:52:50 +03:00
|
|
|
new_manifest = Manifest()
|
|
|
|
new_manifest.create(directory_path)
|
2022-04-19 22:02:37 +03:00
|
|
|
|
2022-04-27 18:53:48 +03:00
|
|
|
self.logger.info(f"Comparing new manifest with existing")
|
2021-09-13 12:52:50 +03:00
|
|
|
only_in_old, changed, only_in_new = Manifest.compare(old_manifest, new_manifest)
|
|
|
|
for record in only_in_old:
|
|
|
|
self.logger.info(f"Only in old: {record}")
|
|
|
|
for record in changed:
|
|
|
|
self.logger.info(f"Changed: {record}")
|
|
|
|
for record in only_in_new:
|
|
|
|
self.logger.info(f"Only in new: {record}")
|
2022-04-19 22:02:37 +03:00
|
|
|
if any((only_in_old, changed, only_in_new)):
|
|
|
|
self.logger.warning("Manifests are different, updating")
|
|
|
|
new_manifest.save(manifest_file)
|
|
|
|
else:
|
|
|
|
self.logger.info("Manifest is up-to-date!")
|
|
|
|
|
2021-09-13 12:52:50 +03:00
|
|
|
self.logger.info(f"Complete")
|
|
|
|
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
return 0
|
|
|
|
|
2021-09-13 12:52:50 +03:00
|
|
|
def copro(self):
|
2022-01-03 00:39:56 +03:00
|
|
|
from flipper.assets.copro import Copro
|
2021-09-13 12:52:50 +03:00
|
|
|
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
self.logger.info(f"Bundling coprocessor binaries")
|
2021-09-13 12:52:50 +03:00
|
|
|
copro = Copro(self.args.mcu)
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
self.logger.info(f"Loading CUBE info")
|
2022-04-27 18:53:48 +03:00
|
|
|
copro.loadCubeInfo(self.args.cube_dir, self.args.cube_ver)
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
self.logger.info(f"Bundling")
|
2022-04-27 18:53:48 +03:00
|
|
|
copro.bundle(
|
|
|
|
self.args.output_dir,
|
|
|
|
self.args.stack_file,
|
|
|
|
self.args.stack_type,
|
|
|
|
self.args.stack_addr,
|
|
|
|
)
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
self.logger.info(f"Complete")
|
|
|
|
|
|
|
|
return 0
|
2021-09-13 12:52:50 +03:00
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
def dolphin(self):
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
from flipper.assets.dolphin import Dolphin
|
|
|
|
|
|
|
|
self.logger.info(f"Processing Dolphin sources")
|
|
|
|
dolphin = Dolphin()
|
|
|
|
self.logger.info(f"Loading data")
|
|
|
|
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")
|
2022-01-03 00:39:56 +03:00
|
|
|
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
return 0
|
2022-01-03 00:39:56 +03:00
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-06-23 17:58:44 +03:00
|
|
|
Main()()
|