Support including material value in the prospector output.

develop
Alexander Gavrilov 2012-01-17 19:56:52 +04:00
parent 43476b2ea7
commit 1aec9649c5
1 changed files with 29 additions and 11 deletions

@ -88,7 +88,7 @@ struct compare_pair_second
} }
}; };
void printMatdata(DFHack::Console & con, const matdata &data) static void printMatdata(DFHack::Console & con, const matdata &data)
{ {
con << std::setw(9) << data.count; con << std::setw(9) << data.count;
@ -98,10 +98,20 @@ void printMatdata(DFHack::Console & con, const matdata &data)
con <<" Z:" << std::setw(4) << data.lower_z << std::endl; con <<" Z:" << std::setw(4) << data.lower_z << std::endl;
} }
static int getValue(const df_inorganic_type &info)
{
return info.mat.MATERIAL_VALUE;
}
static int getValue(const df_plant_type &info)
{
return info.value;
}
// printMats() accepts a vector of pointers to t_matgloss so that it can // printMats() accepts a vector of pointers to t_matgloss so that it can
// deal t_matgloss and all subclasses. // deal t_matgloss and all subclasses.
template <typename T> template <typename T>
void printMats(DFHack::Console & con, MatMap &mat, std::vector<T*> &materials) void printMats(DFHack::Console & con, MatMap &mat, std::vector<T*> &materials, bool show_value)
{ {
unsigned int total = 0; unsigned int total = 0;
MatSorter sorting_vector; MatSorter sorting_vector;
@ -122,6 +132,8 @@ void printMats(DFHack::Console & con, MatMap &mat, std::vector<T*> &materials)
} }
T* mat = materials[it->first]; T* mat = materials[it->first];
con << std::setw(25) << mat->ID << " : "; con << std::setw(25) << mat->ID << " : ";
if (show_value)
con << std::setw(3) << getValue(*mat) << " : ";
printMatdata(con, it->second); printMatdata(con, it->second);
total += it->second.count; total += it->second.count;
} }
@ -130,7 +142,7 @@ void printMats(DFHack::Console & con, MatMap &mat, std::vector<T*> &materials)
} }
void printVeins(DFHack::Console & con, MatMap &mat_map, void printVeins(DFHack::Console & con, MatMap &mat_map,
DFHack::Materials* mats) DFHack::Materials* mats, bool show_value)
{ {
MatMap ores; MatMap ores;
MatMap gems; MatMap gems;
@ -149,13 +161,13 @@ void printVeins(DFHack::Console & con, MatMap &mat_map,
} }
con << "Ores:" << std::endl; con << "Ores:" << std::endl;
printMats(con, ores, *mats->df_inorganic); printMats(con, ores, *mats->df_inorganic, show_value);
con << "Gems:" << std::endl; con << "Gems:" << std::endl;
printMats(con, gems, *mats->df_inorganic); printMats(con, gems, *mats->df_inorganic, show_value);
con << "Other vein stone:" << std::endl; con << "Other vein stone:" << std::endl;
printMats(con, rest, *mats->df_inorganic); printMats(con, rest, *mats->df_inorganic, show_value);
} }
DFhackCExport command_result prospector (Core * c, vector <string> & parameters); DFhackCExport command_result prospector (Core * c, vector <string> & parameters);
@ -183,13 +195,18 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
bool showPlants = true; bool showPlants = true;
bool showSlade = true; bool showSlade = true;
bool showTemple = true; bool showTemple = true;
bool showValue = false;
Console & con = c->con; Console & con = c->con;
for(int i = 0; i < parameters.size();i++) for(int i = 0; i < parameters.size();i++)
{ {
if (parameters[0] == "all") if (parameters[i] == "all")
{ {
showHidden = true; showHidden = true;
} }
if (parameters[i] == "value")
{
showValue = true;
}
else if(parameters[i] == "help" || parameters[i] == "?") else if(parameters[i] == "help" || parameters[i] == "?")
{ {
c->con.print("Prints a big list of all the present minerals.\n" c->con.print("Prints a big list of all the present minerals.\n"
@ -197,6 +214,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
"\n" "\n"
"Options:\n" "Options:\n"
"all - Scan the whole map, as if it was revealed.\n" "all - Scan the whole map, as if it was revealed.\n"
"value - Show material value in the output.\n"
); );
return CR_OK; return CR_OK;
} }
@ -450,16 +468,16 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
} }
con << std::endl << "Layer materials:" << std::endl; con << std::endl << "Layer materials:" << std::endl;
printMats(con, layerMats, *mats->df_inorganic); printMats(con, layerMats, *mats->df_inorganic, showValue);
printVeins(con, veinMats, mats); printVeins(con, veinMats, mats, showValue);
if (showPlants) if (showPlants)
{ {
con << "Shrubs:" << std::endl; con << "Shrubs:" << std::endl;
printMats(con, plantMats, *mats->df_organic); printMats(con, plantMats, *mats->df_organic, showValue);
con << "Wood in trees:" << std::endl; con << "Wood in trees:" << std::endl;
printMats(con, treeMats, *mats->df_organic); printMats(con, treeMats, *mats->df_organic, showValue);
} }
if (hasAquifer) if (hasAquifer)