Skip to content

Commit

Permalink
Merge pull request #4674 from yobbobanana/less_red
Browse files Browse the repository at this point in the history
Display crafting components as grey not red if another is available.
  • Loading branch information
Rivet-the-Zombie committed Nov 25, 2013
2 parents c4845ac + 966bd9a commit f8dd64b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,18 @@ craft_cat game::prev_craft_cat(craft_cat cat)
return NULL;
}

// return whether any of the listed components have been flagged as available
bool any_marked_available(const std::vector<component> &comps)
{
for (std::vector<component>::const_iterator it = comps.begin();
it != comps.end(); ++it) {
if (it->available == 1) {
return true;
}
}
return false;
}

recipe* game::select_crafting_recipe()
{
const int headHeight = 3;
Expand Down Expand Up @@ -632,7 +644,7 @@ recipe* game::select_crafting_recipe()
}
if (!current.empty())
{
nc_color col = (available[line] ? c_white : c_dkgray);
nc_color col = (available[line] ? c_white : c_ltgray);
mvwprintz(w_data, 0, 30, col, _("Skills used: %s"),
(current[line]->skill_used == NULL ? "N/A" :
current[line]->skill_used->name().c_str()));
Expand Down Expand Up @@ -691,11 +703,12 @@ recipe* game::select_crafting_recipe()
ypos++;
xpos = 32;
mvwputch(w_data, ypos, 30, col, '>');
bool has_one = any_marked_available(current[line]->tools[i]);
for (unsigned j = 0; j < current[line]->tools[i].size(); j++)
{
itype_id type = current[line]->tools[i][j].type;
int charges = current[line]->tools[i][j].count;
nc_color toolcol = c_red;
nc_color toolcol = has_one ? c_dkgray : c_red;

if (current[line]->tools[i][j].available == 0)
{
Expand Down Expand Up @@ -749,11 +762,12 @@ recipe* game::select_crafting_recipe()
mvwputch(w_data, ypos, 30, col, '>');
}
xpos = 32;
bool has_one = any_marked_available(current[line]->components[i]);
for (unsigned j = 0; j < current[line]->components[i].size(); j++)
{
int count = current[line]->components[i][j].count;
itype_id type = current[line]->components[i][j].type;
nc_color compcol = c_red;
nc_color compcol = has_one ? c_dkgray : c_red;
if (current[line]->components[i][j].available == 0)
{
compcol = c_brown;
Expand Down

0 comments on commit f8dd64b

Please sign in to comment.