mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 16:38:35 -07:00
fix bug with return to main menu when choice file
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#include <lib/subghz/protocols/registry.h>
|
||||
#include "../subbrute_i.h"
|
||||
#include "../subbrute_custom_event.h"
|
||||
#include "../views/subbrute_main_view.h"
|
||||
#include <lib/subghz/protocols/registry.h>
|
||||
|
||||
#define TAG "SubBruteSceneLoadFile"
|
||||
|
||||
//void subbrute_scene_load_file_callback(SubBruteCustomEvent event, void* context) {
|
||||
//// furi_assert(context);
|
||||
@@ -13,41 +14,56 @@
|
||||
void subbrute_scene_load_file_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
SubBruteState* instance = (SubBruteState*)context;
|
||||
string_t file_path;
|
||||
string_init(file_path);
|
||||
|
||||
// Input events and views are managed by file_browser
|
||||
string_t app_folder;
|
||||
string_t load_path;
|
||||
string_init(load_path);
|
||||
string_init_set_str(app_folder, SUBBRUTE_PATH);
|
||||
|
||||
DialogsFileBrowserOptions browser_options;
|
||||
dialog_file_browser_set_basic_options(&browser_options, SUBBRUTE_FILE_EXT, &I_sub1_10px);
|
||||
|
||||
// Input events and views are managed by file_select
|
||||
bool res = dialog_file_browser_show(
|
||||
instance->dialogs,
|
||||
instance->device->load_path,
|
||||
instance->device->load_path,
|
||||
&browser_options);
|
||||
|
||||
SubBruteFileResult load_result = SubBruteFileResultUnknown;
|
||||
bool res =
|
||||
dialog_file_browser_show(instance->dialogs, load_path, app_folder, &browser_options);
|
||||
#ifdef FURI_DEBUG
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"load_path: %s, app_folder: %s",
|
||||
string_get_cstr(load_path),
|
||||
string_get_cstr(app_folder));
|
||||
#endif
|
||||
if(res) {
|
||||
SubBruteFileResult load_result = subbrute_device_load_protocol_from_file(instance->device);
|
||||
load_result = subbrute_device_load_from_file(instance->device, load_path);
|
||||
if(load_result == SubBruteFileResultOk) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
instance->scene_manager, SubBruteSceneSetupAttack);
|
||||
} else {
|
||||
string_t dialog_msg;
|
||||
string_init(dialog_msg);
|
||||
string_cat_printf(
|
||||
dialog_msg, "Cannot parse\nfile: %s", subbrute_device_error_get_desc(load_result));
|
||||
dialog_message_show_storage_error(instance->dialogs, string_get_cstr(dialog_msg));
|
||||
string_clear(dialog_msg);
|
||||
res = false;
|
||||
load_result = subbrute_device_attack_set(instance->device, SubBruteAttackLoadFile);
|
||||
if(load_result == SubBruteFileResultOk) {
|
||||
// Ready to run!
|
||||
instance->device->state = SubBruteDeviceStateReady;
|
||||
FURI_LOG_I(TAG, "Ready to run");
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string_clear(file_path);
|
||||
if(load_result == SubBruteFileResultOk) {
|
||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Returned error: %d", load_result);
|
||||
|
||||
if(!res) {
|
||||
string_t dialog_msg;
|
||||
string_init(dialog_msg);
|
||||
string_cat_printf(
|
||||
dialog_msg, "Cannot parse\nfile: %s", subbrute_device_error_get_desc(load_result));
|
||||
dialog_message_show_storage_error(instance->dialogs, string_get_cstr(dialog_msg));
|
||||
string_clear(dialog_msg);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
instance->scene_manager, SubBruteSceneLoadFile);
|
||||
instance->scene_manager, SubBruteSceneStart);
|
||||
}
|
||||
|
||||
string_clear(app_folder);
|
||||
string_clear(load_path);
|
||||
}
|
||||
|
||||
void subbrute_scene_load_file_on_exit(void* context) {
|
||||
|
||||
Reference in New Issue
Block a user