aboutsummaryrefslogtreecommitdiff
path: root/bts.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-11-16 11:22:16 +0000
committerrodri <rgl@antares-labs.eu>2024-11-16 11:22:16 +0000
commitccd149a329f9a33195c2c6216158e283f8993076 (patch)
tree75d86a89402c424c23593ae31413c3db79dfab57 /bts.c
parentb555a1ad730994a42cfecf88bba15ece20d1e6f9 (diff)
downloadbattleship-ccd149a329f9a33195c2c6216158e283f8993076.tar.gz
battleship-ccd149a329f9a33195c2c6216158e283f8993076.tar.bz2
battleship-ccd149a329f9a33195c2c6216158e283f8993076.zip
fix the menulist (make it play nice with periodic refreshing).
before the addition of the timer for periodic matches updates the menulist was supposed to be refreshed manually by the user, and we didn't take into account the fact that every time you clear it and refill it loses its navigational parameters, i.e. which entry was selected and what's the offset if there are more entries than the visible window (Maxvisitems). so now we store those and reconfigure the menulist, adapting to its new state, so that the user experiences as little disruption as possible.
Diffstat (limited to 'bts.c')
-rw-r--r--bts.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/bts.c b/bts.c
index aa63a4b..1f72a14 100644
--- a/bts.c
+++ b/bts.c
@@ -955,6 +955,9 @@ processcmd(char *cmd)
Point2 cell;
uchar buf[BY2MAP];
int i, idx;
+ struct {
+ int high, off;
+ } menuparams;
if(debug)
fprint(2, "rcvd '%s'\n", cmd);
@@ -987,6 +990,8 @@ processcmd(char *cmd)
break;
case CMmatches:
if(!matches->filling){
+ menuparams.high = matches->high;
+ menuparams.off = matches->off;
matches->clear(matches);
matches->filling = 1;
}
@@ -997,8 +1002,12 @@ processcmd(char *cmd)
smprint("%s vs %s", cb->f[2], cb->f[3]));
break;
case CMendmatches:
- if(matches->filling)
+ if(matches->filling){
+ matches->high = min(menuparams.high, matches->nentries-1);
+ matches->off = menuparams.off > matches->nentries - matches->maxvis?
+ 0: menuparams.off;
matches->filling = 0;
+ }
break;
case CMwatching:
match.id = strtoul(cb->f[1], nil, 10);