From d010dba0efaba8f5be2191bd52c8a40705a9ec28 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 9 Jan 2019 05:49:31 -0500 Subject: add reset --- src/text/action.c | 2 ++ src/text/action.h | 1 + src/text/main.c | 7 +++++++ 3 files changed, 10 insertions(+) (limited to 'src/text') diff --git a/src/text/action.c b/src/text/action.c index 3d63bce..3381c0a 100644 --- a/src/text/action.c +++ b/src/text/action.c @@ -56,6 +56,8 @@ get_action(void) { .type = ACTION_WARP, .data = atoi(buf), }; + case 'r': + return (action_t) { .type = ACTION_RESET }; case 's': return (action_t) { .type = ACTION_SOLVE }; default: diff --git a/src/text/action.h b/src/text/action.h index d77b3ef..77f0e9c 100644 --- a/src/text/action.h +++ b/src/text/action.h @@ -11,6 +11,7 @@ typedef enum { ACTION_UNDO, ACTION_NEXT, ACTION_SOLVE, + ACTION_RESET, ACTION_LAST, } action_type_t; diff --git a/src/text/main.c b/src/text/main.c index db4a48c..7d6f144 100644 --- a/src/text/main.c +++ b/src/text/main.c @@ -81,6 +81,13 @@ int main(int argc, char *argv[]) { warn("cannot advance to next level"); } + break; + case ACTION_RESET: + // reset level + if (!sok_ctx_set_level(&ctx, level->data)) { + die("Couldn't load level %zu", level_num); + } + break; case ACTION_WARP: level_num = action.data; -- cgit v1.2.3