flipchess_scene_startscreen.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "../flipchess.h"
  2. #include "../helpers/flipchess_voice.h"
  3. #include "../helpers/flipchess_file.h"
  4. #include "../helpers/flipchess_custom_event.h"
  5. #include "../views/flipchess_startscreen.h"
  6. void flipchess_scene_startscreen_callback(FlipChessCustomEvent event, void* context) {
  7. furi_assert(context);
  8. FlipChess* app = context;
  9. view_dispatcher_send_custom_event(app->view_dispatcher, event);
  10. }
  11. void flipchess_scene_startscreen_on_enter(void* context) {
  12. furi_assert(context);
  13. FlipChess* app = context;
  14. if(flipchess_has_file(FlipChessFileBoard, NULL, false)) {
  15. if(flipchess_load_file(app->import_game_text, FlipChessFileBoard, NULL)) {
  16. app->import_game = 1;
  17. }
  18. }
  19. flipchess_startscreen_set_callback(
  20. app->flipchess_startscreen, flipchess_scene_startscreen_callback, app);
  21. view_dispatcher_switch_to_view(app->view_dispatcher, FlipChessViewIdStartscreen);
  22. }
  23. bool flipchess_scene_startscreen_on_event(void* context, SceneManagerEvent event) {
  24. FlipChess* app = context;
  25. bool consumed = false;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. switch(event.event) {
  28. case FlipChessCustomEventStartscreenLeft:
  29. case FlipChessCustomEventStartscreenRight:
  30. break;
  31. case FlipChessCustomEventStartscreenUp:
  32. case FlipChessCustomEventStartscreenDown:
  33. break;
  34. case FlipChessCustomEventStartscreenOk:
  35. scene_manager_next_scene(app->scene_manager, FlipChessSceneMenu);
  36. consumed = true;
  37. break;
  38. case FlipChessCustomEventStartscreenBack:
  39. notification_message(app->notification, &sequence_reset_red);
  40. notification_message(app->notification, &sequence_reset_green);
  41. notification_message(app->notification, &sequence_reset_blue);
  42. if(!scene_manager_search_and_switch_to_previous_scene(
  43. app->scene_manager, FlipChessSceneStartscreen)) {
  44. scene_manager_stop(app->scene_manager);
  45. view_dispatcher_stop(app->view_dispatcher);
  46. }
  47. consumed = true;
  48. break;
  49. }
  50. }
  51. return consumed;
  52. }
  53. void flipchess_scene_startscreen_on_exit(void* context) {
  54. FlipChess* app = context;
  55. if(app->sound == 1) {
  56. flipchess_voice_shall_we_play();
  57. }
  58. }