free.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #include "callback/free.h"
  2. #include "callback/loader.h"
  3. void free_game_submenu(void *context)
  4. {
  5. FlipWorldApp *app = (FlipWorldApp *)context;
  6. furi_check(app);
  7. if (app->submenu_game)
  8. {
  9. view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewGameSubmenu);
  10. submenu_free(app->submenu_game);
  11. app->submenu_game = NULL;
  12. }
  13. }
  14. void free_submenu_other(void *context)
  15. {
  16. FlipWorldApp *app = (FlipWorldApp *)context;
  17. furi_check(app);
  18. if (app->submenu_other)
  19. {
  20. view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewSubmenuOther);
  21. submenu_free(app->submenu_other);
  22. app->submenu_other = NULL;
  23. }
  24. // for (int i = 0; i < 10; i++)
  25. // {
  26. // if (lobby_list[i])
  27. // {
  28. // free(lobby_list[i]);
  29. // lobby_list[i] = NULL;
  30. // }
  31. // }
  32. }
  33. void free_message_view(void *context)
  34. {
  35. FlipWorldApp *app = (FlipWorldApp *)context;
  36. furi_check(app);
  37. if (app->view_message)
  38. {
  39. view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewMessage);
  40. view_free(app->view_message);
  41. app->view_message = NULL;
  42. }
  43. }
  44. void free_text_input_view(void *context)
  45. {
  46. FlipWorldApp *app = (FlipWorldApp *)context;
  47. furi_check(app);
  48. if (app->text_input)
  49. {
  50. view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewTextInput);
  51. uart_text_input_free(app->text_input);
  52. app->text_input = NULL;
  53. }
  54. if (app->text_input_buffer)
  55. {
  56. free(app->text_input_buffer);
  57. app->text_input_buffer = NULL;
  58. }
  59. if (app->text_input_temp_buffer)
  60. {
  61. free(app->text_input_temp_buffer);
  62. app->text_input_temp_buffer = NULL;
  63. }
  64. }
  65. void free_variable_item_list(void *context)
  66. {
  67. FlipWorldApp *app = (FlipWorldApp *)context;
  68. furi_check(app);
  69. if (app->variable_item_list)
  70. {
  71. view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewVariableItemList);
  72. variable_item_list_free(app->variable_item_list);
  73. app->variable_item_list = NULL;
  74. }
  75. if (app->variable_item_wifi_ssid)
  76. {
  77. free(app->variable_item_wifi_ssid);
  78. app->variable_item_wifi_ssid = NULL;
  79. }
  80. if (app->variable_item_wifi_pass)
  81. {
  82. free(app->variable_item_wifi_pass);
  83. app->variable_item_wifi_pass = NULL;
  84. }
  85. if (app->variable_item_game_fps)
  86. {
  87. free(app->variable_item_game_fps);
  88. app->variable_item_game_fps = NULL;
  89. }
  90. if (app->variable_item_game_screen_always_on)
  91. {
  92. free(app->variable_item_game_screen_always_on);
  93. app->variable_item_game_screen_always_on = NULL;
  94. }
  95. if (app->variable_item_game_download_world)
  96. {
  97. free(app->variable_item_game_download_world);
  98. app->variable_item_game_download_world = NULL;
  99. }
  100. if (app->variable_item_game_sound_on)
  101. {
  102. free(app->variable_item_game_sound_on);
  103. app->variable_item_game_sound_on = NULL;
  104. }
  105. if (app->variable_item_game_vibration_on)
  106. {
  107. free(app->variable_item_game_vibration_on);
  108. app->variable_item_game_vibration_on = NULL;
  109. }
  110. if (app->variable_item_game_player_sprite)
  111. {
  112. free(app->variable_item_game_player_sprite);
  113. app->variable_item_game_player_sprite = NULL;
  114. }
  115. if (app->variable_item_game_vgm_x)
  116. {
  117. free(app->variable_item_game_vgm_x);
  118. app->variable_item_game_vgm_x = NULL;
  119. }
  120. if (app->variable_item_game_vgm_y)
  121. {
  122. free(app->variable_item_game_vgm_y);
  123. app->variable_item_game_vgm_y = NULL;
  124. }
  125. if (app->variable_item_user_username)
  126. {
  127. free(app->variable_item_user_username);
  128. app->variable_item_user_username = NULL;
  129. }
  130. if (app->variable_item_user_password)
  131. {
  132. free(app->variable_item_user_password);
  133. app->variable_item_user_password = NULL;
  134. }
  135. }
  136. void free_all_views(void *context, bool free_variable_list, bool free_settings_other, bool free_submenu_game)
  137. {
  138. FlipWorldApp *app = (FlipWorldApp *)context;
  139. furi_check(app);
  140. if (free_variable_list)
  141. {
  142. free_variable_item_list(app);
  143. }
  144. free_message_view(app);
  145. free_text_input_view(app);
  146. // free game thread
  147. // if (game_thread_running)
  148. // {
  149. // game_thread_running = false;
  150. // if (game_thread)
  151. // {
  152. // furi_thread_flags_set(furi_thread_get_id(game_thread), WorkerEvtStop);
  153. // furi_thread_join(game_thread);
  154. // furi_thread_free(game_thread);
  155. // game_thread = NULL;
  156. // }
  157. // }
  158. if (free_settings_other)
  159. {
  160. free_submenu_other(app);
  161. }
  162. // free Derek's loader
  163. loader_view_free(app);
  164. if (free_submenu_game)
  165. {
  166. free_game_submenu(app);
  167. }
  168. // free waiting thread
  169. // if (waiting_thread_running)
  170. // {
  171. // waiting_thread_running = false;
  172. // if (waiting_thread)
  173. // {
  174. // furi_thread_flags_set(furi_thread_get_id(waiting_thread), WorkerEvtStop);
  175. // furi_thread_join(waiting_thread);
  176. // furi_thread_free(waiting_thread);
  177. // waiting_thread = NULL;
  178. // }
  179. // }
  180. }