animation_storage.h 2.9 KB

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