simon-git: puzzles (main): Ben Harris

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Fri Dec 9 21:06:36 GMT 2022


TL;DR:
  a3310ab New backend function: current_key_label()

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: main
Committer:      Ben Harris <bjh21 at bjh21.me.uk>
Date:           2022-12-09 21:06:36

commit a3310ab857f088489b35ebf10733ba284a24d27f
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=a3310ab857f088489b35ebf10733ba284a24d27f;hp=1d91522babe41fcf7cbfb06633ae6bc5606db367
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Mon Dec 5 01:13:26 2022 +0000

    New backend function: current_key_label()
    
    This provides a way for the front end to ask how a particular key should
    be labelled right now (specifically, for a given game_state and
    game_ui).  This is useful on feature phones where it's conventional to
    put a small caption above each soft key indicating what it currently
    does.
    
    The function currently provides labels only for CURSOR_SELECT and
    CURSOR_SELECT2.  This is because these are the only keys that need
    labelling on KaiOS.
    
    The concept of labelling keys also turns up in the request_keys() call,
    but there are quite a few differences.  The labels returned by
    current_key_label() are dynamic and likely to vary with each move, while
    the labels provided by request_keys() are constant for a given
    game_params.  Also, the keys returned by request_keys() don't generally
    include CURSOR_SELECT and CURSOR_SELECT2, because those aren't necessary
    on platforms with pointing devices.  It might be possible to provide a
    unified API covering both of this, but I think it would be quite
    difficult to work with.
    
    Where a key is to be unlabelled, current_key_label() is expected to
    return an empty string.  This leaves open the possibility of NULL
    indicating a fallback to button2label or the label specified by
    request_keys() in the future.
    
    It's tempting to try to implement current_key_label() by calling
    interpret_move() and parsing its output.  This doesn't work for two
    reasons.  One is that interpret_move() is entitled to modify the
    game_ui, and there isn't really a practical way to back those changes
    out.  The other is that the information returned by interpret_move()
    isn't sufficient to generate a label.  For instance, in many puzzles it
    generates moves that toggle the state of a square, but we want the label
    to reflect which state the square will be toggled to.  The result is
    that I've generally ended up pulling bits of code from interpret_move()
    and execute_move() together to implement current_key_label().
    
    Alongside the back-end function, there's a midend_current_key_label()
    that's a thin wrapper around the back-end function.  It just adds an
    assertion about which key's being requested and a default null
    implementation so that back-ends can avoid defining the function if it
    will do nothing useful.

 blackbox.c            | 36 ++++++++++++++++++++++++++++++++++++
 bridges.c             | 15 +++++++++++++++
 cube.c                |  1 +
 devel.but             | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 dominosa.c            | 28 ++++++++++++++++++++++++++++
 fifteen.c             |  1 +
 filling.c             | 18 ++++++++++++++++++
 flip.c                |  8 ++++++++
 flood.c               | 13 +++++++++++++
 galaxies.c            | 32 ++++++++++++++++++++++++++++++++
 guess.c               | 14 ++++++++++++++
 inertia.c             | 10 ++++++++++
 keen.c                |  9 +++++++++
 lightup.c             | 21 +++++++++++++++++++++
 loopy.c               |  1 +
 magnets.c             | 31 +++++++++++++++++++++++++++++++
 map.c                 | 21 +++++++++++++++++++++
 midend.c              |  9 +++++++++
 mines.c               | 30 ++++++++++++++++++++++++++++++
 mosaic.c              | 21 +++++++++++++++++++++
 net.c                 | 13 +++++++++++++
 netslide.c            |  9 +++++++++
 nullgame.c            |  1 +
 palisade.c            |  1 +
 pattern.c             | 18 ++++++++++++++++++
 pearl.c               | 15 +++++++++++++++
 pegs.c                | 14 ++++++++++++++
 puzzles.h             |  3 +++
 range.c               | 22 ++++++++++++++++++++++
 rect.c                | 16 ++++++++++++++++
 samegame.c            | 20 ++++++++++++++++++++
 signpost.c            | 21 +++++++++++++++++++++
 singles.c             | 13 +++++++++++++
 sixteen.c             | 16 ++++++++++++++++
 slant.c               | 17 +++++++++++++++++
 solo.c                |  9 +++++++++
 tents.c               | 17 +++++++++++++++++
 towers.c              |  9 +++++++++
 tracks.c              | 30 ++++++++++++++++++++++++++++++
 twiddle.c             | 12 ++++++++++++
 undead.c              | 15 +++++++++++++++
 unequal.c             |  9 +++++++++
 unfinished/group.c    | 21 +++++++++++++++++++++
 unfinished/separate.c |  1 +
 unfinished/slide.c    |  1 +
 unfinished/sokoban.c  |  1 +
 unruly.c              | 22 ++++++++++++++++++++++
 untangle.c            |  1 +
 48 files changed, 717 insertions(+)



More information about the tartarus-commits mailing list