animation_storage_i.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #pragma once
  2. #include "animation_storage.h"
  3. #include "assets_icons.h"
  4. #include "animation_manager.h"
  5. #include "gui/canvas.h"
  6. struct StorageAnimation {
  7. const BubbleAnimation* animation;
  8. bool external;
  9. StorageAnimationMeta meta;
  10. };
  11. // Hard-coded, always available idle animation
  12. FrameBubble tv_bubble1 = {
  13. .bubble =
  14. {.x = 1,
  15. .y = 23,
  16. .str = "Take the red pill",
  17. .horizontal = AlignRight,
  18. .vertical = AlignBottom},
  19. .starts_at_frame = 7,
  20. .ends_at_frame = 9,
  21. .next_bubble = NULL,
  22. };
  23. FrameBubble tv_bubble2 = {
  24. .bubble =
  25. {.x = 1,
  26. .y = 23,
  27. .str = "I can joke better",
  28. .horizontal = AlignRight,
  29. .vertical = AlignBottom},
  30. .starts_at_frame = 7,
  31. .ends_at_frame = 9,
  32. .next_bubble = NULL,
  33. };
  34. FrameBubble* tv_bubbles[] = {&tv_bubble1, &tv_bubble2};
  35. const Icon* tv_icons[] = {
  36. &I_tv1,
  37. &I_tv2,
  38. &I_tv3,
  39. &I_tv4,
  40. &I_tv5,
  41. &I_tv6,
  42. &I_tv7,
  43. &I_tv8,
  44. };
  45. const BubbleAnimation tv_bubble_animation = {
  46. .icons = tv_icons,
  47. .frame_bubbles = tv_bubbles,
  48. .frame_bubbles_count = COUNT_OF(tv_bubbles),
  49. .passive_frames = 6,
  50. .active_frames = 2,
  51. .active_cycles = 2,
  52. .frame_rate = 2,
  53. .duration = 3600,
  54. .active_cooldown = 5,
  55. };
  56. // System animation - no SD card
  57. const Icon* no_sd_icons[] = {
  58. &I_no_sd1,
  59. &I_no_sd2,
  60. &I_no_sd1,
  61. &I_no_sd2,
  62. &I_no_sd1,
  63. &I_no_sd3,
  64. &I_no_sd4,
  65. &I_no_sd5,
  66. &I_no_sd4,
  67. &I_no_sd6,
  68. };
  69. FrameBubble no_sd_bubble = {
  70. .bubble =
  71. {.x = 40,
  72. .y = 18,
  73. .str = "Need an\nSD card",
  74. .horizontal = AlignRight,
  75. .vertical = AlignBottom},
  76. .starts_at_frame = 0,
  77. .ends_at_frame = 9,
  78. .next_bubble = NULL,
  79. };
  80. FrameBubble* no_sd_bubbles[] = {&no_sd_bubble};
  81. const BubbleAnimation no_sd_bubble_animation = {
  82. .icons = no_sd_icons,
  83. .frame_bubbles = no_sd_bubbles,
  84. .frame_bubbles_count = COUNT_OF(no_sd_bubbles),
  85. .passive_frames = 10,
  86. .active_frames = 0,
  87. .frame_rate = 2,
  88. .duration = 3600,
  89. .active_cooldown = 0,
  90. .active_cycles = 0,
  91. };
  92. // BLOCKING ANIMATION - no_db, bad_sd, sd_ok, url
  93. const Icon* no_db_icons[] = {
  94. &I_no_databases1,
  95. &I_no_databases2,
  96. &I_no_databases3,
  97. &I_no_databases4,
  98. };
  99. const BubbleAnimation no_db_bubble_animation = {
  100. .icons = no_db_icons,
  101. .passive_frames = COUNT_OF(no_db_icons),
  102. .frame_rate = 2,
  103. };
  104. const Icon* bad_sd_icons[] = {
  105. &I_card_bad1,
  106. &I_card_bad2,
  107. };
  108. const BubbleAnimation bad_sd_bubble_animation = {
  109. .icons = bad_sd_icons,
  110. .passive_frames = COUNT_OF(bad_sd_icons),
  111. .frame_rate = 2,
  112. };
  113. const Icon* url_icons[] = {
  114. &I_url1,
  115. &I_url2,
  116. &I_url3,
  117. &I_url4,
  118. };
  119. const BubbleAnimation url_bubble_animation = {
  120. .icons = url_icons,
  121. .passive_frames = COUNT_OF(url_icons),
  122. .frame_rate = 2,
  123. };
  124. const Icon* sd_ok_icons[] = {
  125. &I_card_ok1,
  126. &I_card_ok2,
  127. &I_card_ok3,
  128. &I_card_ok4,
  129. };
  130. const BubbleAnimation sd_ok_bubble_animation = {
  131. .icons = sd_ok_icons,
  132. .passive_frames = COUNT_OF(sd_ok_icons),
  133. .frame_rate = 2,
  134. };
  135. static StorageAnimation StorageAnimationInternal[] = {
  136. {.animation = &tv_bubble_animation,
  137. .external = false,
  138. .meta =
  139. {
  140. .min_butthurt = 0,
  141. .max_butthurt = 11,
  142. .min_level = 1,
  143. .max_level = 3,
  144. .weight = 3,
  145. }},
  146. {.animation = &no_sd_bubble_animation,
  147. .external = false,
  148. .meta =
  149. {
  150. .min_butthurt = 0,
  151. .max_butthurt = 14,
  152. .min_level = 1,
  153. .max_level = 3,
  154. .weight = 6,
  155. }},
  156. {
  157. .animation = &no_db_bubble_animation,
  158. .external = false,
  159. },
  160. {
  161. .animation = &bad_sd_bubble_animation,
  162. .external = false,
  163. },
  164. {
  165. .animation = &sd_ok_bubble_animation,
  166. .external = false,
  167. },
  168. {
  169. .animation = &url_bubble_animation,
  170. .external = false,
  171. },
  172. };
  173. void animation_storage_initialize_internal_animations(void) {
  174. /* not in constructor - no memory pool yet */
  175. /* called in 1 thread - no need in double check */
  176. static bool initialized = false;
  177. if(!initialized) {
  178. initialized = true;
  179. string_init_set_str(StorageAnimationInternal[0].meta.name, HARDCODED_ANIMATION_NAME);
  180. string_init_set_str(StorageAnimationInternal[1].meta.name, NO_SD_ANIMATION_NAME);
  181. string_init_set_str(StorageAnimationInternal[2].meta.name, NO_DB_ANIMATION_NAME);
  182. string_init_set_str(StorageAnimationInternal[3].meta.name, BAD_SD_ANIMATION_NAME);
  183. string_init_set_str(StorageAnimationInternal[4].meta.name, SD_OK_ANIMATION_NAME);
  184. string_init_set_str(StorageAnimationInternal[5].meta.name, URL_ANIMATION_NAME);
  185. }
  186. }