aboutsummaryrefslogtreecommitdiff
path: root/src/sdl/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdl/draw.c')
-rw-r--r--src/sdl/draw.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/sdl/draw.c b/src/sdl/draw.c
index 5bb8de7..322bd7a 100644
--- a/src/sdl/draw.c
+++ b/src/sdl/draw.c
@@ -230,12 +230,16 @@ draw_help_text(
// build text
char buf[256];
+ if (draw_ctx->state == GAME_STATE_SOLVE) {
+ snprintf(buf, sizeof(buf), " Space: Cancel ");
+ } else {
#define D " "
- snprintf(
- buf, sizeof(buf),
- " %sU: Undo" D "R: Reset" D "S: Solve" D "Q: Quit ",
- sok_ctx_is_done(draw_ctx->ctx) ? "Space: Next Level" D : ""
- );
+ snprintf(
+ buf, sizeof(buf),
+ " %sU: Undo" D "R: Reset" D "S: Solve" D "Q: Quit ",
+ sok_ctx_is_done(draw_ctx->ctx) ? "Space: Next Level" D : ""
+ );
+ }
#undef D
// draw text
@@ -243,6 +247,42 @@ draw_help_text(
}
static void
+draw_solve_wait_text(
+ draw_ctx_t * const draw_ctx
+) {
+ if (draw_ctx->state != GAME_STATE_SOLVE) {
+ return;
+ }
+
+ // get text style
+ const text_style_t *style = theme_get_text_style(draw_ctx->theme, TEXT_STYLE_SOLVE_WAIT);
+ const char *text = " Solving, Please Wait (press space to cancel) ";
+
+ // draw text
+ draw_text(draw_ctx->renderer, draw_ctx->font, style, text);
+}
+
+static void
+draw_solve_moves_text(
+ draw_ctx_t * const draw_ctx
+) {
+ if (draw_ctx->state != GAME_STATE_SOLVE) {
+ return;
+ }
+
+ // get text style
+ const text_style_t *style = theme_get_text_style(draw_ctx->theme, TEXT_STYLE_SOLVE_MOVES);
+ char buf[1024];
+
+ // fill buffer
+ snprintf(buf, sizeof(buf), " %lu attempts ", draw_ctx->solve_num_steps);
+
+ // draw text
+ draw_text(draw_ctx->renderer, draw_ctx->font, style, buf);
+}
+
+
+static void
draw_bg(
draw_ctx_t * const draw_ctx
) {
@@ -281,6 +321,8 @@ draw(
draw_title_text(draw_ctx);
draw_help_text(draw_ctx);
draw_moves_text(draw_ctx);
+ draw_solve_wait_text(draw_ctx);
+ draw_solve_moves_text(draw_ctx);
// flip
SDL_RenderPresent(draw_ctx->renderer);