flipchess_scene_scene_1.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "../flipchess.h"
  2. #include "../helpers/flipchess_file.h"
  3. #include "../helpers/flipchess_voice.h"
  4. #include "../helpers/flipchess_custom_event.h"
  5. #include "../views/flipchess_scene_1.h"
  6. void flipchess_scene_1_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_scene_1_on_enter(void* context) {
  12. furi_assert(context);
  13. FlipChess* app = context;
  14. if(app->sound == 1) {
  15. flipchess_voice_how_about_chess();
  16. }
  17. flipchess_scene_1_set_callback(app->flipchess_scene_1, flipchess_scene_1_callback, app);
  18. view_dispatcher_switch_to_view(app->view_dispatcher, FlipChessViewIdScene1);
  19. }
  20. bool flipchess_scene_scene_1_on_event(void* context, SceneManagerEvent event) {
  21. FlipChess* app = context;
  22. bool consumed = false;
  23. if(event.type == SceneManagerEventTypeCustom) {
  24. switch(event.event) {
  25. case FlipChessCustomEventScene1Left:
  26. case FlipChessCustomEventScene1Right:
  27. break;
  28. case FlipChessCustomEventScene1Up:
  29. case FlipChessCustomEventScene1Down:
  30. break;
  31. case FlipChessCustomEventScene1Back:
  32. notification_message(app->notification, &sequence_reset_red);
  33. notification_message(app->notification, &sequence_reset_green);
  34. notification_message(app->notification, &sequence_reset_blue);
  35. if(!scene_manager_search_and_switch_to_previous_scene(
  36. app->scene_manager, FlipChessSceneMenu)) {
  37. scene_manager_stop(app->scene_manager);
  38. view_dispatcher_stop(app->view_dispatcher);
  39. }
  40. consumed = true;
  41. break;
  42. }
  43. }
  44. return consumed;
  45. }
  46. void flipchess_scene_scene_1_on_exit(void* context) {
  47. FlipChess* app = context;
  48. if(app->import_game == 1 && strlen(app->import_game_text) > 0) {
  49. flipchess_save_file(app->import_game_text, FlipChessFileBoard, NULL, false);
  50. }
  51. }