mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-22 00:15:46 -07:00
Patch from Chris Boyle to fix Signpost's labelling when you have more
than 26 separate linked chains of unnumbered squares: we now wrap from 'z' to an Excel-like 'aa', 'ab', ..., instead of falling off z into punctuation and control characters. [originally from svn r9304]
This commit is contained in:
23
signpost.c
23
signpost.c
@ -1930,19 +1930,30 @@ static void tile_redraw(drawing *dr, game_drawstate *ds, int tx, int ty,
|
|||||||
if (!empty) {
|
if (!empty) {
|
||||||
int set = (num <= 0) ? 0 : num / (ds->n+1);
|
int set = (num <= 0) ? 0 : num / (ds->n+1);
|
||||||
|
|
||||||
|
char *p = buf;
|
||||||
if (set == 0 || num <= 0) {
|
if (set == 0 || num <= 0) {
|
||||||
sprintf(buf, "%d", num);
|
sprintf(buf, "%d", num);
|
||||||
} else {
|
} else {
|
||||||
int n = num % (ds->n+1);
|
int n = num % (ds->n+1);
|
||||||
|
p += sizeof(buf) - 1;
|
||||||
|
|
||||||
if (n == 0)
|
if (n != 0) {
|
||||||
sprintf(buf, "%c", (int)(set+'a'-1));
|
sprintf(buf, "+%d", n); /* Just to get the length... */
|
||||||
else
|
p -= strlen(buf);
|
||||||
sprintf(buf, "%c+%d", (int)(set+'a'-1), n);
|
sprintf(p, "+%d", n);
|
||||||
|
} else {
|
||||||
|
*p = '\0';
|
||||||
}
|
}
|
||||||
textsz = min(2*asz, (TILE_SIZE - 2 * cb) / (int)strlen(buf));
|
do {
|
||||||
|
set--;
|
||||||
|
p--;
|
||||||
|
*p = (char)((set % 26)+'a');
|
||||||
|
set /= 26;
|
||||||
|
} while (set);
|
||||||
|
}
|
||||||
|
textsz = min(2*asz, (TILE_SIZE - 2 * cb) / (int)strlen(p));
|
||||||
draw_text(dr, tx + cb, ty + TILE_SIZE/4, FONT_VARIABLE, textsz,
|
draw_text(dr, tx + cb, ty + TILE_SIZE/4, FONT_VARIABLE, textsz,
|
||||||
ALIGN_VCENTRE | ALIGN_HLEFT, textcol, buf);
|
ALIGN_VCENTRE | ALIGN_HLEFT, textcol, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_ink < 0) {
|
if (print_ink < 0) {
|
||||||
|
Reference in New Issue
Block a user