Skip to content

Commit

Permalink
Added code for start screen scene, using the custom StartScreen view.
Browse files Browse the repository at this point in the history
Added enumeration for start screen event.
Added custom input, draw callbacks
Added on_enter/event/exit code that handles switching to the view and
next appropriate scene
  • Loading branch information
squee72564 committed Dec 31, 2023
1 parent bdedb79 commit 0949b14
Showing 1 changed file with 59 additions and 6 deletions.
65 changes: 59 additions & 6 deletions scenes/start_screen_scene.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,57 @@
#include "../minesweeper.h"
#include "../views/start_screen.h"

typedef enum {
MineSweeperSceneStartScreenContinueEvent,
} MineSweeperSceneStartScreenEvent;

//void minesweeper_scene_start_screen_timer_callback(void* context) {
// furi_assert(context);
// UNUSED(context);
//}

bool minesweeper_scene_start_screen_input_callback(InputEvent* event, void* context) {
furi_assert(event);
furi_assert(context);

App* app = context;
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);
}

return consumed;
}

void minesweeper_scene_start_screen_secondary_draw_callback(Canvas* canvas, void* _model) {
furi_assert(canvas);
furi_assert(_model);
UNUSED(_model);
UNUSED(canvas);
}

void minesweeper_scene_start_screen_on_enter(void* context) {
furi_assert(context);
UNUSED(context);
App* app = context;

furi_assert(app->start_screen);

// Set callbacks
//start_screen_set_timer_callback(app->start_screen, minesweeper_scene_start_screen_timer_callback);
start_screen_set_input_callback(
app->start_screen,
minesweeper_scene_start_screen_input_callback);
start_screen_set_secondary_draw_callback(
app->start_screen,
minesweeper_scene_start_screen_secondary_draw_callback);

start_screen_set_context(app->start_screen, app);

start_screen_set_icon_animation(app->start_screen, 0, 0);

view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperStartScreenView);
}

bool minesweeper_scene_start_screen_on_event(void* context, SceneManagerEvent event) {
Expand All @@ -12,10 +60,13 @@ bool minesweeper_scene_start_screen_on_event(void* context, SceneManagerEvent ev
App* app = context;
bool consumed = false;

UNUSED(app);

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

Expand All @@ -24,5 +75,7 @@ bool minesweeper_scene_start_screen_on_event(void* context, SceneManagerEvent ev

void minesweeper_scene_start_screen_on_exit(void* context) {
furi_assert(context);
UNUSED(context);

App* app = context;
start_screen_reset(app->start_screen);
}

0 comments on commit 0949b14

Please sign in to comment.