|
@@ -1,5 +1,6 @@
|
|
|
#include <callback/callback.h>
|
|
#include <callback/callback.h>
|
|
|
#include <callback/loader.h>
|
|
#include <callback/loader.h>
|
|
|
|
|
+#include <callback/free.h>
|
|
|
#include "engine/engine.h"
|
|
#include "engine/engine.h"
|
|
|
#include "engine/game_engine.h"
|
|
#include "engine/game_engine.h"
|
|
|
#include "engine/game_manager_i.h"
|
|
#include "engine/game_manager_i.h"
|
|
@@ -7,6 +8,7 @@
|
|
|
#include "engine/entity_i.h"
|
|
#include "engine/entity_i.h"
|
|
|
#include "game/storage.h"
|
|
#include "game/storage.h"
|
|
|
#include "alloc/alloc.h"
|
|
#include "alloc/alloc.h"
|
|
|
|
|
+#include <flip_storage/storage.h>
|
|
|
|
|
|
|
|
static void frame_cb(GameEngine *engine, Canvas *canvas, InputState input, void *context)
|
|
static void frame_cb(GameEngine *engine, Canvas *canvas, InputState input, void *context)
|
|
|
{
|
|
{
|
|
@@ -125,22 +127,6 @@ static bool message_input_callback(InputEvent *event, void *context)
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-uint32_t callback_to_submenu(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- UNUSED(context);
|
|
|
|
|
- return FlipWorldViewSubmenu;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static uint32_t callback_to_wifi_settings(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- UNUSED(context);
|
|
|
|
|
- return FlipWorldViewVariableItemList;
|
|
|
|
|
-}
|
|
|
|
|
-static uint32_t callback_to_settings(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- UNUSED(context);
|
|
|
|
|
- return FlipWorldViewSubmenuOther;
|
|
|
|
|
-}
|
|
|
|
|
static int32_t waiting_app_callback(void *p)
|
|
static int32_t waiting_app_callback(void *p)
|
|
|
{
|
|
{
|
|
|
FlipWorldApp *app = (FlipWorldApp *)p;
|
|
FlipWorldApp *app = (FlipWorldApp *)p;
|
|
@@ -616,159 +602,6 @@ static bool alloc_game_submenu(void *context)
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void free_game_submenu(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- FlipWorldApp *app = (FlipWorldApp *)context;
|
|
|
|
|
- if (!app)
|
|
|
|
|
- {
|
|
|
|
|
- FURI_LOG_E(TAG, "FlipWorldApp is NULL");
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->submenu_game)
|
|
|
|
|
- {
|
|
|
|
|
- view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewGameSubmenu);
|
|
|
|
|
- submenu_free(app->submenu_game);
|
|
|
|
|
- app->submenu_game = NULL;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void free_submenu_other(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- FlipWorldApp *app = (FlipWorldApp *)context;
|
|
|
|
|
- furi_check(app);
|
|
|
|
|
- if (app->submenu_other)
|
|
|
|
|
- {
|
|
|
|
|
- view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewSubmenuOther);
|
|
|
|
|
- submenu_free(app->submenu_other);
|
|
|
|
|
- app->submenu_other = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- for (int i = 0; i < 10; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (lobby_list[i])
|
|
|
|
|
- {
|
|
|
|
|
- free(lobby_list[i]);
|
|
|
|
|
- lobby_list[i] = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-// free
|
|
|
|
|
-static void free_message_view(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- FlipWorldApp *app = (FlipWorldApp *)context;
|
|
|
|
|
- if (!app)
|
|
|
|
|
- {
|
|
|
|
|
- FURI_LOG_E(TAG, "FlipWorldApp is NULL");
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->view_message)
|
|
|
|
|
- {
|
|
|
|
|
- view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewMessage);
|
|
|
|
|
- view_free(app->view_message);
|
|
|
|
|
- app->view_message = NULL;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void free_text_input_view(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- FlipWorldApp *app = (FlipWorldApp *)context;
|
|
|
|
|
- if (!app)
|
|
|
|
|
- {
|
|
|
|
|
- FURI_LOG_E(TAG, "FlipWorldApp is NULL");
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->text_input)
|
|
|
|
|
- {
|
|
|
|
|
- view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewTextInput);
|
|
|
|
|
- uart_text_input_free(app->text_input);
|
|
|
|
|
- app->text_input = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->text_input_buffer)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->text_input_buffer);
|
|
|
|
|
- app->text_input_buffer = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->text_input_temp_buffer)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->text_input_temp_buffer);
|
|
|
|
|
- app->text_input_temp_buffer = NULL;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-static void free_variable_item_list(void *context)
|
|
|
|
|
-{
|
|
|
|
|
- FlipWorldApp *app = (FlipWorldApp *)context;
|
|
|
|
|
- if (!app)
|
|
|
|
|
- {
|
|
|
|
|
- FURI_LOG_E(TAG, "FlipWorldApp is NULL");
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_list)
|
|
|
|
|
- {
|
|
|
|
|
- view_dispatcher_remove_view(app->view_dispatcher, FlipWorldViewVariableItemList);
|
|
|
|
|
- variable_item_list_free(app->variable_item_list);
|
|
|
|
|
- app->variable_item_list = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_wifi_ssid)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_wifi_ssid);
|
|
|
|
|
- app->variable_item_wifi_ssid = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_wifi_pass)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_wifi_pass);
|
|
|
|
|
- app->variable_item_wifi_pass = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_fps)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_fps);
|
|
|
|
|
- app->variable_item_game_fps = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_screen_always_on)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_screen_always_on);
|
|
|
|
|
- app->variable_item_game_screen_always_on = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_download_world)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_download_world);
|
|
|
|
|
- app->variable_item_game_download_world = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_sound_on)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_sound_on);
|
|
|
|
|
- app->variable_item_game_sound_on = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_vibration_on)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_vibration_on);
|
|
|
|
|
- app->variable_item_game_vibration_on = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_player_sprite)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_player_sprite);
|
|
|
|
|
- app->variable_item_game_player_sprite = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_vgm_x)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_vgm_x);
|
|
|
|
|
- app->variable_item_game_vgm_x = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_game_vgm_y)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_game_vgm_y);
|
|
|
|
|
- app->variable_item_game_vgm_y = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_user_username)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_user_username);
|
|
|
|
|
- app->variable_item_user_username = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (app->variable_item_user_password)
|
|
|
|
|
- {
|
|
|
|
|
- free(app->variable_item_user_password);
|
|
|
|
|
- app->variable_item_user_password = NULL;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static FuriThread *game_thread;
|
|
static FuriThread *game_thread;
|
|
|
static FuriThread *waiting_thread;
|
|
static FuriThread *waiting_thread;
|
|
|
static bool game_thread_running = false;
|
|
static bool game_thread_running = false;
|
|
@@ -801,56 +634,7 @@ static bool start_waiting_thread(void *context)
|
|
|
waiting_thread_running = true;
|
|
waiting_thread_running = true;
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-void free_all_views(void *context, bool free_variable_list, bool free_settings_other, bool free_submenu_game)
|
|
|
|
|
-{
|
|
|
|
|
- FlipWorldApp *app = (FlipWorldApp *)context;
|
|
|
|
|
- furi_check(app);
|
|
|
|
|
- if (free_variable_list)
|
|
|
|
|
- {
|
|
|
|
|
- free_variable_item_list(app);
|
|
|
|
|
- }
|
|
|
|
|
- free_message_view(app);
|
|
|
|
|
- free_text_input_view(app);
|
|
|
|
|
-
|
|
|
|
|
- // free game thread
|
|
|
|
|
- if (game_thread_running)
|
|
|
|
|
- {
|
|
|
|
|
- game_thread_running = false;
|
|
|
|
|
- if (game_thread)
|
|
|
|
|
- {
|
|
|
|
|
- furi_thread_flags_set(furi_thread_get_id(game_thread), WorkerEvtStop);
|
|
|
|
|
- furi_thread_join(game_thread);
|
|
|
|
|
- furi_thread_free(game_thread);
|
|
|
|
|
- game_thread = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (free_settings_other)
|
|
|
|
|
- {
|
|
|
|
|
- free_submenu_other(app);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // free Derek's loader
|
|
|
|
|
- free_view_loader(app);
|
|
|
|
|
-
|
|
|
|
|
- if (free_submenu_game)
|
|
|
|
|
- {
|
|
|
|
|
- free_game_submenu(app);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- // free waiting thread
|
|
|
|
|
- if (waiting_thread_running)
|
|
|
|
|
- {
|
|
|
|
|
- waiting_thread_running = false;
|
|
|
|
|
- if (waiting_thread)
|
|
|
|
|
- {
|
|
|
|
|
- furi_thread_flags_set(furi_thread_get_id(waiting_thread), WorkerEvtStop);
|
|
|
|
|
- furi_thread_join(waiting_thread);
|
|
|
|
|
- furi_thread_free(waiting_thread);
|
|
|
|
|
- waiting_thread = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
static bool fetch_world_list(FlipperHTTP *fhttp)
|
|
static bool fetch_world_list(FlipperHTTP *fhttp)
|
|
|
{
|
|
{
|
|
|
if (!fhttp)
|
|
if (!fhttp)
|
|
@@ -979,7 +763,7 @@ static bool start_game_thread(void *context)
|
|
|
free_variable_item_list(app);
|
|
free_variable_item_list(app);
|
|
|
free_text_input_view(app);
|
|
free_text_input_view(app);
|
|
|
// free_submenu_other(app); // free lobby list or settings
|
|
// free_submenu_other(app); // free lobby list or settings
|
|
|
- free_view_loader(app);
|
|
|
|
|
|
|
+ loader_view_free(app);
|
|
|
free_game_submenu(app);
|
|
free_game_submenu(app);
|
|
|
|
|
|
|
|
// free game thread
|
|
// free game thread
|
|
@@ -1294,7 +1078,7 @@ static char *_parse_game(DataLoaderModel *model)
|
|
|
}
|
|
}
|
|
|
static void switch_to_view_get_game(FlipWorldApp *app)
|
|
static void switch_to_view_get_game(FlipWorldApp *app)
|
|
|
{
|
|
{
|
|
|
- if (!alloc_view_loader(app))
|
|
|
|
|
|
|
+ if (!loader_view_alloc(app))
|
|
|
{
|
|
{
|
|
|
FURI_LOG_E(TAG, "Failed to allocate view loader");
|
|
FURI_LOG_E(TAG, "Failed to allocate view loader");
|
|
|
return;
|
|
return;
|
|
@@ -2334,7 +2118,7 @@ static char *_parse_worlds(DataLoaderModel *model)
|
|
|
}
|
|
}
|
|
|
static void switch_to_view_get_worlds(FlipWorldApp *app)
|
|
static void switch_to_view_get_worlds(FlipWorldApp *app)
|
|
|
{
|
|
{
|
|
|
- if (!alloc_view_loader(app))
|
|
|
|
|
|
|
+ if (!loader_view_alloc(app))
|
|
|
{
|
|
{
|
|
|
FURI_LOG_E(TAG, "Failed to allocate view loader");
|
|
FURI_LOG_E(TAG, "Failed to allocate view loader");
|
|
|
return;
|
|
return;
|