Skip to content

Commit

Permalink
Added ExitEvent to Event enum and added code to input_callback / on_e…
Browse files Browse the repository at this point in the history
…vent for new Event enum
  • Loading branch information
squee72564 committed Dec 31, 2023
1 parent 71bf36d commit 3687741
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions scenes/start_screen_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../views/start_screen.h"

typedef enum {
MineSweeperSceneStartScreenExitEvent,
MineSweeperSceneStartScreenContinueEvent,
} MineSweeperSceneStartScreenEvent;

Expand All @@ -18,8 +19,10 @@ bool minesweeper_scene_start_screen_input_callback(InputEvent* event, void* cont
bool consumed = false;

// right now we continue if back is not pressed
if (event->key != InputKeyBack) {
return scene_manager_handle_custom_event(app->scene_manager, MineSweeperSceneStartScreenContinueEvent);
if (event->key == InputKeyBack) {
consumed = scene_manager_handle_custom_event(app->scene_manager, MineSweeperSceneStartScreenExitEvent);
} else {
consumed = scene_manager_handle_custom_event(app->scene_manager, MineSweeperSceneStartScreenContinueEvent);
}

return consumed;
Expand Down Expand Up @@ -62,15 +65,17 @@ bool minesweeper_scene_start_screen_on_event(void* context, SceneManagerEvent ev
App* app = context;
bool consumed = false;

//if (event.type == SceneManagerEventTypeBack) {
// //exit app
// scene_manager_stop(app->scene_manager);
// view_dispatcher_stop(app->view_dispatcher);
// consumed = true;
//}
if (event.type == SceneManagerEventTypeCustom && event.event == MineSweeperSceneStartScreenContinueEvent) {
scene_manager_next_scene(app->scene_manager, MineSweeperSceneMenu);
consumed = true;
if (event.type == SceneManagerEventTypeCustom) {
if (event.event == MineSweeperSceneStartScreenContinueEvent) {
scene_manager_set_scene_state(app->scene_manager, MineSweeperSceneStartScreen, MineSweeperSceneMenu);
scene_manager_next_scene(app->scene_manager, MineSweeperSceneMenu);
consumed = true;
} else if (event.event == MineSweeperSceneStartScreenExitEvent) {
//exit app
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
consumed = true;
}
}

return consumed;
Expand Down

0 comments on commit 3687741

Please sign in to comment.