[FL-2150] Dolphin animation refactoring (#938)
* Dolphin Animation Refactoring, part 1 * Remove animations from desktop * Remove excess, first start * Split animation_manager with callbacks * allocate view inside animation_view * Work on ViewComposed * Draw white rectangles under bubble corners * Fix bubbles sequence * RPC: remove obsolete include "status.pb.h" * Add animations manifest decoding * Flipper file: add strict mode * FFF: Animation structures parsing * Assembling structure of animation * Lot of view fixes: Add multi-line bubbles Add support for passive bubbles (frame_order values starts from passive now) Add hard-coded delay (active_shift) for active state enabling Fix active state handling Fix leaks Fix parsing uncorrect bubble_animation meta file Fix bubble rules of showing * Animation load/unload & view freeze/unfreeze * Blocking & system animations, fixes: View correct activation Refactoring + blocking animation Freeze first passive/active frames Many insert/eject SD tests fixes Add system animations Add Loader events app started/finished Add system no_sd animation * Assets: dolphin packer. Scripts: minor refactoring. * Desktop: update logging tags. Scripts: add metadata to dolphin bundling process, extra sorting for fs traversing. Make: phony assets rules. * Github: rebuild assets on build * Docker: add missing dependencies for assets compilation * Docker: fix run command syntax * ReadMe: update naming rules with link to source * Assets: recompile icons * Loader: add loader event * Desktop, Gui, Furi Core: const shenanigans macros Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
		| @@ -12,6 +12,7 @@ FlipperFile* flipper_file_alloc(Storage* storage) { | ||||
|     FlipperFile* flipper_file = malloc(sizeof(FlipperFile)); | ||||
|     flipper_file->storage = storage; | ||||
|     flipper_file->file = storage_file_alloc(flipper_file->storage); | ||||
|     flipper_file->strict_mode = false; | ||||
|  | ||||
|     return flipper_file; | ||||
| } | ||||
| @@ -25,6 +26,11 @@ void flipper_file_free(FlipperFile* flipper_file) { | ||||
|     free(flipper_file); | ||||
| } | ||||
|  | ||||
| void flipper_file_set_strict_mode(FlipperFile* flipper_file, bool strict_mode) { | ||||
|     furi_assert(flipper_file); | ||||
|     flipper_file->strict_mode = strict_mode; | ||||
| } | ||||
|  | ||||
| bool flipper_file_open_existing(FlipperFile* flipper_file, const char* filename) { | ||||
|     furi_assert(flipper_file); | ||||
|     bool result = storage_file_open( | ||||
| @@ -136,7 +142,7 @@ bool flipper_file_get_value_count(FlipperFile* flipper_file, const char* key, ui | ||||
|  | ||||
|     uint32_t position = storage_file_tell(flipper_file->file); | ||||
|     do { | ||||
|         if(!flipper_file_seek_to_key(flipper_file->file, key)) break; | ||||
|         if(!flipper_file_seek_to_key(flipper_file->file, key, flipper_file->strict_mode)) break; | ||||
|  | ||||
|         // Balance between speed and memory consumption | ||||
|         // I prefer lower speed but less memory consumption | ||||
| @@ -208,7 +214,7 @@ bool flipper_file_delete_key_and_call( | ||||
|         if(!storage_file_seek(flipper_file->file, 0, true)) break; | ||||
|  | ||||
|         // find key | ||||
|         if(!flipper_file_seek_to_key(flipper_file->file, key)) break; | ||||
|         if(!flipper_file_seek_to_key(flipper_file->file, key, flipper_file->strict_mode)) break; | ||||
|         // get key start position | ||||
|         uint64_t start_position = storage_file_tell(flipper_file->file) - strlen(key); | ||||
|         if(start_position >= 2) { | ||||
| @@ -326,12 +332,13 @@ bool flipper_file_read_internal( | ||||
|     const char* key, | ||||
|     void* _data, | ||||
|     const uint16_t data_size, | ||||
|     bool strict_mode, | ||||
|     FlipperFileValueType type) { | ||||
|     bool result = false; | ||||
|     string_t value; | ||||
|     string_init(value); | ||||
|  | ||||
|     if(flipper_file_seek_to_key(file, key)) { | ||||
|     if(flipper_file_seek_to_key(file, key, strict_mode)) { | ||||
|         result = true; | ||||
|         for(uint16_t i = 0; i < data_size; i++) { | ||||
|             bool last = false; | ||||
| @@ -392,4 +399,4 @@ File* flipper_file_get_file(FlipperFile* flipper_file) { | ||||
|     furi_assert(flipper_file->file); | ||||
|  | ||||
|     return flipper_file->file; | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -119,6 +119,13 @@ FlipperFile* flipper_file_alloc(Storage* storage); | ||||
|  */ | ||||
| void flipper_file_free(FlipperFile* flipper_file); | ||||
|  | ||||
| /** | ||||
|  * Free FlipperFile. | ||||
|  * @param flipper_file Pointer to a FlipperFile instance | ||||
|  * @param strict_mode True obligates not to skip valid fields. False by default. | ||||
|  */ | ||||
| void flipper_file_set_strict_mode(FlipperFile* flipper_file, bool strict_mode); | ||||
|  | ||||
| /** | ||||
|  * Open existing file. | ||||
|  * @param flipper_file Pointer to a FlipperFile instance | ||||
| @@ -455,4 +462,4 @@ File* flipper_file_get_file(FlipperFile* flipper_file); | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| #endif | ||||
|   | ||||
| @@ -19,7 +19,7 @@ bool flipper_file_read_float( | ||||
|     const uint16_t data_size) { | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_read_internal( | ||||
|         flipper_file->file, key, data, data_size, FlipperFileValueFloat); | ||||
|         flipper_file->file, key, data, data_size, flipper_file->strict_mode, FlipperFileValueFloat); | ||||
| } | ||||
|  | ||||
| bool flipper_file_write_float( | ||||
| @@ -39,4 +39,4 @@ bool flipper_file_update_float( | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_delete_key_and_call( | ||||
|         flipper_file, key, flipper_file_write_float_internal, key, data, data_size); | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -76,7 +76,7 @@ bool flipper_file_read_valid_key(File* file, string_t key) { | ||||
|     return found; | ||||
| } | ||||
|  | ||||
| bool flipper_file_seek_to_key(File* file, const char* key) { | ||||
| bool flipper_file_seek_to_key(File* file, const char* key, bool strict_mode) { | ||||
|     bool found = false; | ||||
|     string_t readed_key; | ||||
|  | ||||
| @@ -89,6 +89,9 @@ bool flipper_file_seek_to_key(File* file, const char* key) { | ||||
|  | ||||
|                 found = true; | ||||
|                 break; | ||||
|             } else if (strict_mode) { | ||||
|                 found = false; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @@ -115,4 +118,4 @@ bool flipper_file_get_scratchpad_name(const char** name) { | ||||
|     // TODO do not rewrite existing file | ||||
|     *name = flipper_file_scratchpad; | ||||
|     return true; | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -27,9 +27,10 @@ bool flipper_file_read_valid_key(File* file, string_t key); | ||||
|  * Sets rw pointer to the data after the key | ||||
|  * @param file  | ||||
|  * @param key  | ||||
|  * @param strict | ||||
|  * @return true if key was found  | ||||
|  */ | ||||
| bool flipper_file_seek_to_key(File* file, const char* key); | ||||
| bool flipper_file_seek_to_key(File* file, const char* key, bool strict); | ||||
|  | ||||
| /** | ||||
|  * Write key and key delimiter | ||||
| @@ -48,4 +49,4 @@ bool flipper_file_get_scratchpad_name(const char** name); | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| #endif | ||||
|   | ||||
| @@ -28,7 +28,7 @@ bool flipper_file_read_hex( | ||||
|     const uint16_t data_size) { | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_read_internal( | ||||
|         flipper_file->file, key, data, data_size, FlipperFileValueHex); | ||||
|         flipper_file->file, key, data, data_size, flipper_file->strict_mode, FlipperFileValueHex); | ||||
| } | ||||
|  | ||||
| bool flipper_file_update_hex( | ||||
| @@ -39,4 +39,4 @@ bool flipper_file_update_hex( | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_delete_key_and_call( | ||||
|         flipper_file, key, flipper_file_write_hex_internal, key, data, data_size); | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| struct FlipperFile { | ||||
|     File* file; | ||||
|     Storage* storage; | ||||
|     bool strict_mode; | ||||
| }; | ||||
|  | ||||
| /** | ||||
| @@ -69,4 +70,5 @@ bool flipper_file_read_internal( | ||||
|     const char* key, | ||||
|     void* _data, | ||||
|     const uint16_t data_size, | ||||
|     FlipperFileValueType type); | ||||
|     bool strict_mode, | ||||
|     FlipperFileValueType type); | ||||
|   | ||||
| @@ -19,7 +19,7 @@ bool flipper_file_read_int32( | ||||
|     const uint16_t data_size) { | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_read_internal( | ||||
|         flipper_file->file, key, data, data_size, FlipperFileValueInt32); | ||||
|         flipper_file->file, key, data, data_size, flipper_file->strict_mode, FlipperFileValueInt32); | ||||
| } | ||||
|  | ||||
| bool flipper_file_write_int32( | ||||
| @@ -39,4 +39,4 @@ bool flipper_file_update_int32( | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_delete_key_and_call( | ||||
|         flipper_file, key, flipper_file_write_int32_internal, key, data, data_size); | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -29,7 +29,7 @@ bool flipper_file_read_string(FlipperFile* flipper_file, const char* key, string | ||||
|     furi_assert(flipper_file); | ||||
|  | ||||
|     bool result = false; | ||||
|     if(flipper_file_seek_to_key(flipper_file->file, key)) { | ||||
|     if(flipper_file_seek_to_key(flipper_file->file, key, flipper_file->strict_mode)) { | ||||
|         if(file_helper_read_line(flipper_file->file, data)) { | ||||
|             result = true; | ||||
|         } | ||||
|   | ||||
| @@ -19,7 +19,7 @@ bool flipper_file_read_uint32( | ||||
|     const uint16_t data_size) { | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_read_internal( | ||||
|         flipper_file->file, key, data, data_size, FlipperFileValueUint32); | ||||
|         flipper_file->file, key, data, data_size, flipper_file->strict_mode, FlipperFileValueUint32); | ||||
| } | ||||
|  | ||||
| bool flipper_file_write_uint32( | ||||
| @@ -39,4 +39,4 @@ bool flipper_file_update_uint32( | ||||
|     furi_assert(flipper_file); | ||||
|     return flipper_file_delete_key_and_call( | ||||
|         flipper_file, key, flipper_file_write_uint32_internal, key, data, data_size); | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user