foru(i, NUM_COKES) { int r = H - 10 - 5*is_lifted[i]; int c = 10 + i*10; buffer[r][c] = cokes[i] >= 0 ? cokes[i]+'0' : 'X'; if(coke_is_empty(i)) { draw_text_centered("EMPTY", r-2, c); } if(coke_is_recycled(i)) { draw_text_centered("RECYCLED", r-2, c); } char buf[100]; sprintf(buf, "COKE %i", i+1); draw_text_centered(buf, r-5, c); if(is_lifted[i]) { draw_text_centered("LIFTED", r-7, c); } }
const char *drawtext(rect r, int alignment, const char *s) { int h; int nlines; int line_height; int u = 0; rect clip; const char *remains; char line[256]; initapp(0,0); if (! s) return (char *) NULL; if (! current->fnt) current->fnt = SystemFont; clip = getcliprect(); setcliprect(r); line_height = getheight(current->fnt); if ((alignment & VCenter) == VCenter) { h = textheight(r.width, s); if (h < r.height) r.y += (r.height-h)/2; } else if ((alignment & VJustify) == VJustify) { h = textheight(r.width, s); if (h < r.height) { nlines = h / line_height; if (nlines > 1) line_height += ((r.height-h) / (nlines-1)); } } else if ((alignment & AlignBottom) == AlignBottom) { h = textheight(r.width, s); if (h < r.height) r.y += (r.height-h); } u = (alignment & Underline); if ((alignment & Center) == Center) remains = draw_text_centered(line, r, line_height, u, s); else if ((alignment & Justify) == Justify) remains = draw_text_justified(line, r, line_height, u, s); else if ((alignment & AlignRight) == AlignRight) remains = draw_text_right(line, r, line_height, u, s); else remains = draw_text_left(line, r, line_height, u, s); setcliprect(clip); return remains; }