mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Pattern: Pack clues for each row more closely together
Rather than centring each clue in an imaginary box, put equal amounts of space between them (using space characters) and then right-align the whole string. This makes for more efficient use of space, and I think it also looks better when there are two-digit clues. This does introduce a rather grotty (if large) fixed-size buffer for row clues. Probably the row clues should be pre-formatted into a string when the puzzle is set up.
This commit is contained in:
30
pattern.c
30
pattern.c
@ -1790,23 +1790,31 @@ static void draw_numbers(
|
|||||||
nfit = max(rowlen, nfit) - 1;
|
nfit = max(rowlen, nfit) - 1;
|
||||||
assert(nfit > 0);
|
assert(nfit > 0);
|
||||||
|
|
||||||
for (j = 0; j < rowlen; j++) {
|
if (i < state->common->w) {
|
||||||
int x, y;
|
for (j = 0; j < rowlen; j++) {
|
||||||
char str[80];
|
int x, y;
|
||||||
|
char str[80];
|
||||||
|
|
||||||
if (i < state->common->w) {
|
|
||||||
x = rx;
|
x = rx;
|
||||||
y = BORDER + TILE_SIZE * (TLBORDER(state->common->h)-1);
|
y = BORDER + TILE_SIZE * (TLBORDER(state->common->h)-1);
|
||||||
y -= ((rowlen-j-1)*TILE_SIZE) * (TLBORDER(state->common->h)-1) / nfit;
|
y -= ((rowlen-j-1)*TILE_SIZE) * (TLBORDER(state->common->h)-1) / nfit;
|
||||||
} else {
|
sprintf(str, "%d", rowdata[j]);
|
||||||
y = ry;
|
draw_text(dr, x+TILE_SIZE/2, y+TILE_SIZE/2, FONT_VARIABLE,
|
||||||
x = BORDER + TILE_SIZE * (TLBORDER(state->common->w)-1);
|
TILE_SIZE/2, ALIGN_HCENTRE | ALIGN_VCENTRE, colour, str);
|
||||||
x -= ((rowlen-j-1)*TILE_SIZE) * (TLBORDER(state->common->w)-1) / nfit;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
int x, y;
|
||||||
|
char str[280];
|
||||||
|
size_t off = 0;
|
||||||
|
|
||||||
sprintf(str, "%d", rowdata[j]);
|
for (j = 0; j < rowlen; j++) {
|
||||||
draw_text(dr, x+TILE_SIZE/2, y+TILE_SIZE/2, FONT_VARIABLE,
|
assert(off < 260);
|
||||||
TILE_SIZE/2, ALIGN_HCENTRE | ALIGN_VCENTRE, colour, str);
|
off += sprintf(str + off, "%s%d", j ? " " : "", rowdata[j]);
|
||||||
|
}
|
||||||
|
y = ry;
|
||||||
|
x = BORDER + TILE_SIZE * (TLBORDER(state->common->w)-1);
|
||||||
|
draw_text(dr, x+TILE_SIZE, y+TILE_SIZE/2, FONT_VARIABLE,
|
||||||
|
TILE_SIZE/2, ALIGN_HRIGHT | ALIGN_VCENTRE, colour, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
unclip(dr);
|
unclip(dr);
|
||||||
|
Reference in New Issue
Block a user