error* program__get_build_info(clobj_t _prog, clobj_t _dev, cl_program_build_info param, generic_info *out) { auto prog = static_cast<program*>(_prog); auto dev = static_cast<device*>(_dev); return c_handle_error([&] { *out = prog->get_build_info(dev, param); }); }
int huddraw_build() { build_info * bi = get_build_info(hud_build_plan); int pages = C(bi->mat)/MATS_PER_PAGE + ((C(bi->mat)%MATS_PER_PAGE) > 0); if (pages < 1) pages = 1; if (hud_build_page > pages) hud_build_page = pages; int poff = (hud_build_page-1)*MATS_PER_PAGE; char buf[256]; // placed/total blocks if (hud_build_plan) sprintf(buf, "Plan:%d", bi->total); else sprintf(buf, "%d/%d", bi->placed, bi->total); fg_color = B3(COLOR_BLACK); draw_text(1, 1, buf); // available total material sprintf(buf, "%d", bi->available); int remain = bi->total-bi->placed; if (hud_build_plan) { fg_color = B0(COLOR_BLACK); } else { if (bi->available >= remain) fg_color = B3(COLOR_EMERALD_GREEN); else if (bi->available >= remain/2) fg_color = B3(COLOR_GOLD_YELLOW); else if (bi->available >= remain/4) fg_color = B3(COLOR_ORANGE); else fg_color = B3(COLOR_REDSTONE_RED); } draw_text(48, 1, buf); // build limit if (!hud_build_plan && bi->limit > 0) { sprintf(buf, "%3d", bi->limit); fg_color = B3(COLOR_YELLOW); bg_color = B2(COLOR_BLUE); draw_text(72, 1, buf); bg_color = 0; } // current page sprintf(buf, "%d/%d", hud_build_page, pages); bg_color = B0(COLOR_NETHER_RED); fg_color = B3(COLOR_YELLOW); draw_text(115, 1, buf); bg_color = 0; int i; for(i=0; i<MATS_PER_PAGE; i++) { int mi = i+poff; if (mi>=C(bi->mat)) break; build_info_material * m = P(bi->mat)+mi; char name[256]; get_bid_name(name, m->material); name[22] = 0; int toplace = m->total-m->placed; int stacksize = STACKSIZE(m->material.bid); if (hud_build_plan) { int stacks = toplace/stacksize + ((toplace%stacksize)>0); sprintf(buf, "%4d $%-3d %s", toplace, stacks, name); fg_color = B0(COLOR_BLACK); } else { sprintf(buf, "%4d/%4d %s", toplace, m->available, name); if (m->available >= toplace) fg_color = B3(COLOR_EMERALD_GREEN); else if (m->available >= toplace/2) fg_color = B3(COLOR_GOLD_YELLOW); else if (m->available >= toplace/4) fg_color = B3(COLOR_ORANGE); else fg_color = B3(COLOR_REDSTONE_RED); } draw_text(0, 6*i+8, buf); } return 1; }