flipchess_scene_scene_1.c 1.9 KB

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