animation_storage.h 2.8 KB

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