scene_file_select.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. {
  18. furi_assert(app);
  19. furi_string_set(app->file_path, MALVEKE_APP_FOLDER_RAMS);
  20. DialogsFileBrowserOptions browser_options;
  21. dialog_file_browser_set_basic_options(
  22. &browser_options, MALVEKE_APP_RAM_EXTENSION, &I_icon_10px);
  23. browser_options.base_path = MALVEKE_APP_FOLDER_RAMS;
  24. browser_options.skip_assets = true;
  25. // Input events and views are managed by file_browser
  26. bool res = dialog_file_browser_show(
  27. app->dialogs, app->file_path, app->file_path, &browser_options);
  28. return res;
  29. }
  30. void boilerplate_scene_fileselect_on_enter(void *context)
  31. {
  32. Boilerplate *app = context;
  33. // if(app->script) {
  34. // script_close(app->script);
  35. // app->script = NULL;
  36. // }
  37. // if(app->camera_ram_sav && storage_file_is_open(app->camera_ram_sav)) {
  38. // storage_file_close(app->camera_ram_sav);
  39. // }
  40. // app->camera_ram_sav = storage_file_alloc(app->storage);
  41. if (file_select(app))
  42. {
  43. if (storage_file_open(
  44. app->camera_ram_sav,
  45. furi_string_get_cstr(app->file_path),
  46. FSAM_READ,
  47. FSOM_OPEN_EXISTING))
  48. {
  49. storage_file_read(app->camera_ram_sav, app->scratchpad1, sizeof(app->scratchpad1));
  50. scene_manager_next_scene(app->scene_manager, BoilerplateSceneMenu);
  51. }
  52. }
  53. else
  54. {
  55. view_dispatcher_stop(app->view_dispatcher);
  56. }
  57. }
  58. bool boilerplate_scene_fileselect_on_event(void *context, SceneManagerEvent event)
  59. {
  60. UNUSED(context);
  61. UNUSED(event);
  62. // Boilerplate* app = context;
  63. return false;
  64. }
  65. void boilerplate_scene_fileselect_on_exit(void *context)
  66. {
  67. UNUSED(context);
  68. // Boilerplate* app = context;
  69. }