scene_file_select.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "../malveke_gb_photo.h"
  2. #include <storage/storage.h>
  3. // static int32_t game_boy_camera_worker(void* context) {
  4. // Boilerplate* app = context;
  5. // if(!storage_file_open(
  6. // app->camera_ram_sav,
  7. // furi_string_get_cstr(app->file_path),
  8. // FSAM_READ,
  9. // FSOM_OPEN_EXISTING)) {
  10. // return 1;
  11. // }
  12. // storage_file_read(app->camera_ram_sav, app->scratchpad1, sizeof(app->scratchpad1));
  13. // scene_manager_next_scene(app->scene_manager, BoilerplateSceneMenu);
  14. // return 0;
  15. // }
  16. static bool file_select(Boilerplate* app) {
  17. furi_assert(app);
  18. furi_string_set(app->file_path, MALVEKE_APP_FOLDER_RAMS);
  19. DialogsFileBrowserOptions browser_options;
  20. dialog_file_browser_set_basic_options(
  21. &browser_options, MALVEKE_APP_RAM_EXTENSION, &I_icon_10px);
  22. browser_options.base_path = MALVEKE_APP_FOLDER_RAMS;
  23. browser_options.skip_assets = true;
  24. // Input events and views are managed by file_browser
  25. bool res =
  26. dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options);
  27. return res;
  28. }
  29. void boilerplate_scene_fileselect_on_enter(void* context) {
  30. Boilerplate* app = context;
  31. // if(app->script) {
  32. // script_close(app->script);
  33. // app->script = NULL;
  34. // }
  35. // if(app->camera_ram_sav && storage_file_is_open(app->camera_ram_sav)) {
  36. // storage_file_close(app->camera_ram_sav);
  37. // }
  38. // app->camera_ram_sav = storage_file_alloc(app->storage);
  39. if(file_select(app)) {
  40. if(storage_file_open(
  41. app->camera_ram_sav,
  42. furi_string_get_cstr(app->file_path),
  43. FSAM_READ,
  44. FSOM_OPEN_EXISTING)) {
  45. storage_file_read(app->camera_ram_sav, app->scratchpad1, sizeof(app->scratchpad1));
  46. scene_manager_next_scene(app->scene_manager, BoilerplateSceneMenu);
  47. }
  48. } else {
  49. view_dispatcher_stop(app->view_dispatcher);
  50. }
  51. }
  52. bool boilerplate_scene_fileselect_on_event(void* context, SceneManagerEvent event) {
  53. UNUSED(context);
  54. UNUSED(event);
  55. // Boilerplate* app = context;
  56. return false;
  57. }
  58. void boilerplate_scene_fileselect_on_exit(void* context) {
  59. UNUSED(context);
  60. // Boilerplate* app = context;
  61. }