mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Reworked draw_path_hint
This commit is contained in:

committed by
Simon Tatham

parent
9def49ae9a
commit
c3285318e6
47
undead.c
47
undead.c
@ -2316,22 +2316,35 @@ static void draw_monster_count(drawing *dr, game_drawstate *ds,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void draw_path_hint(drawing *dr, game_drawstate *ds,
|
static void draw_path_hint(drawing *dr, game_drawstate *ds,
|
||||||
const game_state *state,
|
const struct game_params *params,
|
||||||
int i, int hflash, int start) {
|
int hint_index, int hflash, int hint) {
|
||||||
int dx,dy,x,y;
|
int x, y, color, dx, dy, text_dx, text_dy, text_size;
|
||||||
int p,error;
|
char buf[4];
|
||||||
char buf[80];
|
|
||||||
|
|
||||||
p = start ? state->common->paths[i].grid_start : state->common->paths[i].grid_end;
|
if (ds->hint_errors[hint_index])
|
||||||
range2grid(p,state->common->params.w,state->common->params.h,&x,&y);
|
color = COL_ERROR;
|
||||||
error = ds->hint_errors[p];
|
else if (hflash)
|
||||||
|
color = COL_FLASH;
|
||||||
|
else
|
||||||
|
color = COL_TEXT;
|
||||||
|
|
||||||
dx = BORDER+(x* ds->tilesize)+(TILESIZE/2);
|
range2grid(hint_index, params->w, params->h, &x, &y);
|
||||||
dy = BORDER+(y* ds->tilesize)+(TILESIZE/2)+TILESIZE;
|
/* Upper-left corner of the "tile" */
|
||||||
sprintf(buf,"%d", start ? state->common->paths[i].sightings_start : state->common->paths[i].sightings_end);
|
dx = BORDER + x * TILESIZE;
|
||||||
draw_rect(dr,dx-(TILESIZE/2)+2,dy-(TILESIZE/2)+2,TILESIZE-3,TILESIZE-3,COL_BACKGROUND);
|
dy = BORDER + y * TILESIZE + TILESIZE;
|
||||||
draw_text(dr,dx,dy,FONT_FIXED,TILESIZE/2,ALIGN_HCENTRE|ALIGN_VCENTRE, error ? COL_ERROR : hflash ? COL_FLASH : COL_TEXT,buf);
|
/* Center of the "tile" */
|
||||||
draw_update(dr,dx-(TILESIZE/2)+2,dy-(TILESIZE/2)+2,TILESIZE-3,TILESIZE-3);
|
text_dx = dx + TILESIZE / 2;
|
||||||
|
text_dy = dy + TILESIZE / 2;
|
||||||
|
/* Avoid wiping out the borders of the puzzle */
|
||||||
|
dx += 2;
|
||||||
|
dy += 2;
|
||||||
|
text_size = TILESIZE - 3;
|
||||||
|
|
||||||
|
sprintf(buf,"%d", hint);
|
||||||
|
draw_rect(dr, dx, dy, text_size, text_size, COL_BACKGROUND);
|
||||||
|
draw_text(dr, text_dx, text_dy, FONT_FIXED, TILESIZE / 2,
|
||||||
|
ALIGN_HCENTRE | ALIGN_VCENTRE, color, buf);
|
||||||
|
draw_update(dr, dx, dy, text_size, text_size);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2501,11 +2514,13 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
|
|||||||
struct path *path = &state->common->paths[i];
|
struct path *path = &state->common->paths[i];
|
||||||
|
|
||||||
if (is_hint_stale(ds, hflash, state, path->grid_start)) {
|
if (is_hint_stale(ds, hflash, state, path->grid_start)) {
|
||||||
draw_path_hint(dr, ds, state, i, hflash, TRUE);
|
draw_path_hint(dr, ds, &state->common->params, path->grid_start,
|
||||||
|
hflash, path->sightings_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_hint_stale(ds, hflash, state, path->grid_end)) {
|
if (is_hint_stale(ds, hflash, state, path->grid_end)) {
|
||||||
draw_path_hint(dr, ds, state, i, hflash, FALSE);
|
draw_path_hint(dr, ds, &state->common->params, path->grid_end,
|
||||||
|
hflash, path->sightings_end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user