flipperzero-firmware/applications/desktop/animations/animation_storage_i.h

196 lines
4.7 KiB
C
Raw Normal View History

[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>
2022-01-02 21:39:56 +00:00
#pragma once
#include "animation_storage.h"
#include "assets_icons.h"
#include "animation_manager.h"
#include "gui/canvas.h"
struct StorageAnimation {
const BubbleAnimation* animation;
bool external;
StorageAnimationMeta meta;
};
// Hard-coded, always available idle animation
FrameBubble tv_bubble1 = {
.bubble =
{.x = 1,
.y = 23,
.str = "Take the red pill",
.horizontal = AlignRight,
.vertical = AlignBottom},
.starts_at_frame = 7,
.ends_at_frame = 9,
.next_bubble = NULL,
};
FrameBubble tv_bubble2 = {
.bubble =
{.x = 1,
.y = 23,
.str = "I can joke better",
.horizontal = AlignRight,
.vertical = AlignBottom},
.starts_at_frame = 7,
.ends_at_frame = 9,
.next_bubble = NULL,
};
FrameBubble* tv_bubbles[] = {&tv_bubble1, &tv_bubble2};
const Icon* tv_icons[] = {
&I_tv1,
&I_tv2,
&I_tv3,
&I_tv4,
&I_tv5,
&I_tv6,
&I_tv7,
&I_tv8,
};
const BubbleAnimation tv_bubble_animation = {
.icons = tv_icons,
.frame_bubbles = tv_bubbles,
.frame_bubbles_count = COUNT_OF(tv_bubbles),
.passive_frames = 6,
.active_frames = 2,
.active_cycles = 2,
.frame_rate = 2,
.duration = 3600,
.active_cooldown = 5,
};
// System animation - no SD card
const Icon* no_sd_icons[] = {
&I_no_sd1,
&I_no_sd2,
&I_no_sd1,
&I_no_sd2,
&I_no_sd1,
&I_no_sd3,
&I_no_sd4,
&I_no_sd5,
&I_no_sd4,
&I_no_sd6,
};
FrameBubble no_sd_bubble = {
.bubble =
{.x = 40,
.y = 18,
.str = "Need an\nSD card",
.horizontal = AlignRight,
.vertical = AlignBottom},
.starts_at_frame = 0,
.ends_at_frame = 9,
.next_bubble = NULL,
};
FrameBubble* no_sd_bubbles[] = {&no_sd_bubble};
const BubbleAnimation no_sd_bubble_animation = {
.icons = no_sd_icons,
.frame_bubbles = no_sd_bubbles,
.frame_bubbles_count = COUNT_OF(no_sd_bubbles),
.passive_frames = 10,
.active_frames = 0,
.frame_rate = 2,
.duration = 3600,
.active_cooldown = 0,
.active_cycles = 0,
};
// BLOCKING ANIMATION - no_db, bad_sd, sd_ok, url
const Icon* no_db_icons[] = {
&I_no_databases1,
&I_no_databases2,
&I_no_databases3,
&I_no_databases4,
};
const BubbleAnimation no_db_bubble_animation = {
.icons = no_db_icons,
.passive_frames = COUNT_OF(no_db_icons),
.frame_rate = 2,
};
const Icon* bad_sd_icons[] = {
&I_card_bad1,
&I_card_bad2,
};
const BubbleAnimation bad_sd_bubble_animation = {
.icons = bad_sd_icons,
.passive_frames = COUNT_OF(bad_sd_icons),
.frame_rate = 2,
};
const Icon* url_icons[] = {
&I_url1,
&I_url2,
&I_url3,
&I_url4,
};
const BubbleAnimation url_bubble_animation = {
.icons = url_icons,
.passive_frames = COUNT_OF(url_icons),
.frame_rate = 2,
};
const Icon* sd_ok_icons[] = {
&I_card_ok1,
&I_card_ok2,
&I_card_ok3,
&I_card_ok4,
};
const BubbleAnimation sd_ok_bubble_animation = {
.icons = sd_ok_icons,
.passive_frames = COUNT_OF(sd_ok_icons),
.frame_rate = 2,
};
static StorageAnimation StorageAnimationInternal[] = {
{.animation = &tv_bubble_animation,
.external = false,
.meta =
{
.min_butthurt = 0,
.max_butthurt = 11,
.min_level = 1,
.max_level = 3,
.weight = 3,
}},
{.animation = &no_sd_bubble_animation,
.external = false,
.meta =
{
.min_butthurt = 0,
.max_butthurt = 14,
.min_level = 1,
.max_level = 3,
.weight = 6,
}},
{
.animation = &no_db_bubble_animation,
.external = false,
},
{
.animation = &bad_sd_bubble_animation,
.external = false,
},
{
.animation = &sd_ok_bubble_animation,
.external = false,
},
{
.animation = &url_bubble_animation,
.external = false,
},
};
void animation_storage_initialize_internal_animations(void) {
/* not in constructor - no memory pool yet */
/* called in 1 thread - no need in double check */
static bool initialized = false;
if(!initialized) {
initialized = true;
string_init_set_str(StorageAnimationInternal[0].meta.name, HARDCODED_ANIMATION_NAME);
string_init_set_str(StorageAnimationInternal[1].meta.name, NO_SD_ANIMATION_NAME);
string_init_set_str(StorageAnimationInternal[2].meta.name, NO_DB_ANIMATION_NAME);
string_init_set_str(StorageAnimationInternal[3].meta.name, BAD_SD_ANIMATION_NAME);
string_init_set_str(StorageAnimationInternal[4].meta.name, SD_OK_ANIMATION_NAME);
string_init_set_str(StorageAnimationInternal[5].meta.name, URL_ANIMATION_NAME);
}
}