aboutsummaryrefslogtreecommitdiff
path: root/blackbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'blackbox.c')
-rw-r--r--blackbox.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/blackbox.c b/blackbox.c
index 1478943..f8d6b27 100644
--- a/blackbox.c
+++ b/blackbox.c
@@ -532,6 +532,41 @@ static void game_changed_state(game_ui *ui, const game_state *oldstate,
ui->newmove = false;
}
+static const char *current_key_label(const game_ui *ui,
+ const game_state *state, int button)
+{
+ if (IS_CURSOR_SELECT(button) && ui->cur_visible && !state->reveal) {
+ int gx = ui->cur_x, gy = ui->cur_y, rangeno = -1;
+ if (gx == 0 && gy == 0 && button == CURSOR_SELECT) return "Check";
+ if (gx >= 1 && gx <= state->w && gy >= 1 && gy <= state->h) {
+ /* Cursor somewhere in the arena. */
+ if (button == CURSOR_SELECT && !(GRID(state, gx,gy) & BALL_LOCK))
+ return (GRID(state, gx, gy) & BALL_GUESS) ? "Clear" : "Ball";
+ if (button == CURSOR_SELECT2)
+ return (GRID(state, gx, gy) & BALL_LOCK) ? "Unlock" : "Lock";
+ }
+ if (grid2range(state, gx, gy, &rangeno)) {
+ if (button == CURSOR_SELECT &&
+ state->exits[rangeno] == LASER_EMPTY)
+ return "Fire";
+ if (button == CURSOR_SELECT2) {
+ int n = 0;
+ /* Row or column lock or unlock. */
+ if (gy == 0 || gy > state->h) { /* Column lock */
+ for (gy = 1; gy <= state->h; gy++)
+ n += !!(GRID(state, gx, gy) & BALL_LOCK);
+ return n > state->h/2 ? "Unlock" : "Lock";
+ } else { /* Row lock */
+ for (gx = 1; gx <= state->w; gx++)
+ n += !!(GRID(state, gx, gy) & BALL_LOCK);
+ return n > state->w/2 ? "Unlock" : "Lock";
+ }
+ }
+ }
+ }
+ return "";
+}
+
#define OFFSET(gx,gy,o) do { \
int off = (4 + (o) % 4) % 4; \
(gx) += offsets[off].x; \
@@ -1543,6 +1578,7 @@ const struct game thegame = {
decode_ui,
NULL, /* game_request_keys */
game_changed_state,
+ current_key_label,
interpret_move,
execute_move,
PREFERRED_TILE_SIZE, game_compute_size, game_set_size,