2022-09-24 17:47:21 +00:00
|
|
|
#include "../subbrute_i.h"
|
|
|
|
#include "../subbrute_custom_event.h"
|
|
|
|
#include "../views/subbrute_main_view.h"
|
|
|
|
|
2022-09-24 20:46:43 +00:00
|
|
|
#define TAG "SubBruteSceneStart"
|
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
void subbrute_scene_start_callback(SubBruteCustomEvent event, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
SubBruteState* instance = (SubBruteState*)context;
|
2022-09-24 20:46:43 +00:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_D(TAG, "subbrute_scene_start_callback");
|
|
|
|
#endif
|
2022-09-24 17:47:21 +00:00
|
|
|
view_dispatcher_send_custom_event(instance->view_dispatcher, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void subbrute_scene_start_on_enter(void* context) {
|
|
|
|
furi_assert(context);
|
2022-09-24 20:46:43 +00:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_I(TAG, "subbrute_scene_start_on_enter");
|
|
|
|
#endif
|
2022-09-24 17:47:21 +00:00
|
|
|
SubBruteState* instance = (SubBruteState*)context;
|
|
|
|
SubBruteMainView* view = instance->view_main;
|
|
|
|
|
|
|
|
instance->current_view = SubBruteViewMain;
|
2022-09-24 20:46:43 +00:00
|
|
|
subbrute_main_view_set_callback(view, subbrute_scene_start_callback, instance);
|
2022-09-24 18:15:09 +00:00
|
|
|
subbrute_main_view_set_index(view, (uint8_t)instance->device->attack);
|
2022-09-24 20:46:43 +00:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_I(TAG, "view_dispatcher_switch_to_view");
|
|
|
|
#endif
|
2022-09-24 17:47:21 +00:00
|
|
|
view_dispatcher_switch_to_view(instance->view_dispatcher, instance->current_view);
|
|
|
|
}
|
|
|
|
|
|
|
|
void subbrute_scene_start_on_exit(void* context) {
|
|
|
|
UNUSED(context);
|
2022-09-24 20:46:43 +00:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_I(TAG, "subbrute_scene_start_on_exit");
|
|
|
|
#endif
|
2022-09-24 17:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool subbrute_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
SubBruteState* instance = (SubBruteState*)context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
2022-09-24 20:46:43 +00:00
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_D(TAG, "Event: %d", event.event);
|
|
|
|
#endif
|
|
|
|
if(event.event == SubBruteCustomEventTypeMenuSelected) {
|
|
|
|
SubBruteAttacks attack = subbrute_main_view_get_index(instance->view_main);
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
subbrute_device_attack_set(instance->device, attack, NULL);
|
|
|
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
|
|
|
|
2022-09-24 20:46:43 +00:00
|
|
|
consumed = true;
|
|
|
|
} else if(event.event == SubBruteCustomEventTypeLoadFile) {
|
|
|
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneLoadFile);
|
|
|
|
consumed = true;
|
|
|
|
}
|
2022-09-25 13:05:52 +00:00
|
|
|
} else if (event.type == SceneManagerEventTypeBack) {
|
|
|
|
//exit app
|
|
|
|
scene_manager_stop(instance->scene_manager);
|
|
|
|
view_dispatcher_stop(instance->view_dispatcher);
|
|
|
|
consumed = true;
|
2022-09-24 17:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|