animation_storage.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #pragma once
  2. #include <stdint.h>
  3. #include <m-list.h>
  4. #include "views/bubble_animation_view.h"
  5. #include <m-string.h>
  6. #define HARDCODED_ANIMATION_NAME "tv"
  7. #define NO_SD_ANIMATION_NAME "no_sd"
  8. #define BAD_BATTERY_ANIMATION_NAME "bad_battery"
  9. #define NO_DB_ANIMATION_NAME "no_db"
  10. #define BAD_SD_ANIMATION_NAME "bad_sd"
  11. #define SD_OK_ANIMATION_NAME "sd_ok"
  12. #define URL_ANIMATION_NAME "url"
  13. #define LEVELUP_ANIMATION_NAME "level"
  14. /** Main structure to handle animation data.
  15. * Contains all, including animation playing data (BubbleAnimation),
  16. * data for random animation selection (StorageAnimationMeta) and
  17. * flag of location internal/external */
  18. typedef struct StorageAnimation StorageAnimation;
  19. typedef struct {
  20. string_t name;
  21. uint8_t min_butthurt;
  22. uint8_t max_butthurt;
  23. uint8_t min_level;
  24. uint8_t max_level;
  25. uint8_t weight;
  26. } StorageAnimationMeta;
  27. /** Container to return available animations list */
  28. LIST_DEF(StorageAnimationList, StorageAnimation*, M_PTR_OPLIST)
  29. #define M_OPL_StorageAnimationList_t() LIST_OPLIST(StorageAnimationList)
  30. /**
  31. * Fill list of available animations.
  32. * List will contain all idle animations on inner flash
  33. * and all available on SD-card, mentioned in manifest.txt.
  34. * Performs caching of animation. If fail - falls back to
  35. * inner animation.
  36. * List has to be initialized.
  37. *
  38. * @list list to fill with animations data
  39. */
  40. void animation_storage_fill_animation_list(StorageAnimationList_t* list);
  41. /**
  42. * Get bubble animation of storage animation.
  43. * Bubble Animation is a structure which describes animation
  44. * independent of it's place of storage and meta data.
  45. * It contain all what is need to be played.
  46. * If storage_animation is not cached - caches it.
  47. *
  48. * @storage_animation animation from which extract bubble animation
  49. * @return bubble_animation, NULL if failed to cache data.
  50. */
  51. const BubbleAnimation* animation_storage_get_bubble_animation(StorageAnimation* storage_animation);
  52. /**
  53. * Performs caching animation data (Bubble Animation)
  54. * if this is not done yet.
  55. *
  56. * @storage_animation animation to cache
  57. */
  58. void animation_storage_cache_animation(StorageAnimation* storage_animation);
  59. /**
  60. * Find animation by name.
  61. * Search through the inner flash, and SD-card if has.
  62. *
  63. * @name name of animation
  64. * @return found animation. NULL if nothing found.
  65. */
  66. StorageAnimation* animation_storage_find_animation(const char* name);
  67. /**
  68. * Get meta information of storage animation.
  69. * This information allows to randomly select animation.
  70. * Also it contains name. Never returns NULL.
  71. *
  72. * @storage_animation item of whom we have to extract meta.
  73. * @return meta itself
  74. */
  75. StorageAnimationMeta* animation_storage_get_meta(StorageAnimation* storage_animation);
  76. /**
  77. * Free storage_animation, which previously acquired
  78. * by Animation Storage.
  79. *
  80. * @storage_animation item to free. NULL-ed after all.
  81. */
  82. void animation_storage_free_storage_animation(StorageAnimation** storage_animation);
  83. /**
  84. * Has to be called at least 1 time to initialize runtime structures
  85. * of animations in inner flash.
  86. */
  87. void animation_storage_initialize_internal_animations(void);