|  |  |  | @ -92,6 +92,8 @@ static void debug(const string &msg) | 
		
	
		
			
				|  |  |  |  |  * Material Choice Screen | 
		
	
		
			
				|  |  |  |  |  */ | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | static string material_to_string_fn(MaterialInfo m) { return m.toString(); } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | struct ItemFilter | 
		
	
		
			
				|  |  |  |  | { | 
		
	
		
			
				|  |  |  |  |     df::dfhack_material_category mat_mask; | 
		
	
	
		
			
				
					|  |  |  | @ -114,8 +116,10 @@ struct ItemFilter | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     bool matches(MaterialInfo &material) const | 
		
	
		
			
				|  |  |  |  |     { | 
		
	
		
			
				|  |  |  |  |         return any_of(materials.begin(), materials.end(),  | 
		
	
		
			
				|  |  |  |  |             [&] (const MaterialInfo &m) { return material.matches(m); }); | 
		
	
		
			
				|  |  |  |  |         for (auto it = materials.begin(); it != materials.end(); ++it) | 
		
	
		
			
				|  |  |  |  |             if (material.matches(*it)) | 
		
	
		
			
				|  |  |  |  |                 return true; | 
		
	
		
			
				|  |  |  |  |         return false; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     bool matches(df::item *item) | 
		
	
	
		
			
				
					|  |  |  | @ -137,8 +141,7 @@ struct ItemFilter | 
		
	
		
			
				|  |  |  |  |     { | 
		
	
		
			
				|  |  |  |  |         vector<string> descriptions; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         transform_(materials, descriptions, | 
		
	
		
			
				|  |  |  |  |             [] (MaterialInfo m) { return m.toString(); }); | 
		
	
		
			
				|  |  |  |  |         transform_(materials, descriptions, material_to_string_fn); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if (descriptions.size() == 0) | 
		
	
		
			
				|  |  |  |  |             bitfield_to_string(&descriptions, mat_mask); | 
		
	
	
		
			
				
					|  |  |  | @ -157,8 +160,8 @@ struct ItemFilter | 
		
	
		
			
				|  |  |  |  |         str.append("/"); | 
		
	
		
			
				|  |  |  |  |         if (materials.size() > 0) | 
		
	
		
			
				|  |  |  |  |         { | 
		
	
		
			
				|  |  |  |  |             for_each_(materials, | 
		
	
		
			
				|  |  |  |  |                 [&] (MaterialInfo &m) { str.append(m.getToken() + ","); }); | 
		
	
		
			
				|  |  |  |  |             for (size_t i = 0; i < materials.size(); i++) | 
		
	
		
			
				|  |  |  |  |                 str.append(materials[i].getToken() + ","); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             if (str[str.size()-1] == ',') | 
		
	
		
			
				|  |  |  |  |                 str.resize(str.size () - 1); | 
		
	
	
		
			
				
					|  |  |  | @ -217,6 +220,7 @@ private: | 
		
	
		
			
				|  |  |  |  |     bool valid; | 
		
	
		
			
				|  |  |  |  | }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | static MaterialInfo &material_info_identity_fn(MaterialInfo &m) { return m; } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class ViewscreenChooseMaterial : public dfhack_viewscreen | 
		
	
		
			
				|  |  |  |  | { | 
		
	
	
		
			
				
					|  |  |  | @ -284,13 +288,12 @@ public: | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             // Category masks
 | 
		
	
		
			
				|  |  |  |  |             auto masks = masks_column.getSelectedElems(); | 
		
	
		
			
				|  |  |  |  |             for_each_(masks, | 
		
	
		
			
				|  |  |  |  |                 [&] (df::dfhack_material_category &m) { filter->mat_mask.whole |= m.whole; }); | 
		
	
		
			
				|  |  |  |  |             for (auto it = masks.begin(); it != masks.end(); ++it) | 
		
	
		
			
				|  |  |  |  |                 filter->mat_mask.whole |= it->whole; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             // Specific materials
 | 
		
	
		
			
				|  |  |  |  |             auto materials = materials_column.getSelectedElems(); | 
		
	
		
			
				|  |  |  |  |             transform_(materials, filter->materials, | 
		
	
		
			
				|  |  |  |  |                 [] (MaterialInfo &m) { return m; }); | 
		
	
		
			
				|  |  |  |  |             transform_(materials, filter->materials, material_info_identity_fn); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             Screen::dismiss(this); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
	
		
			
				
					|  |  |  | @ -465,6 +468,7 @@ private: | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | static void delete_item_fn(df::job_item *x) { delete x; } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | // START Planning 
 | 
		
	
		
			
				|  |  |  |  | class PlannedBuilding | 
		
	
	
		
			
				
					|  |  |  | @ -555,7 +559,7 @@ public: | 
		
	
		
			
				|  |  |  |  |          | 
		
	
		
			
				|  |  |  |  |         auto job = building->jobs[0]; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         for_each_(job->job_items, [] (df::job_item *x) { delete x; }); | 
		
	
		
			
				|  |  |  |  |         for_each_(job->job_items, delete_item_fn); | 
		
	
		
			
				|  |  |  |  |         job->job_items.clear(); | 
		
	
		
			
				|  |  |  |  |         job->flags.bits.suspend = false; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -613,9 +617,10 @@ private: | 
		
	
		
			
				|  |  |  |  |     ItemFilter filter; | 
		
	
		
			
				|  |  |  |  | }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | static map<df::building_type, bool> planmode_enabled, saved_planmodes; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | static void enable_quickfort_fn(pair<const df::building_type, bool>& pair) { pair.second = true; } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class Planner | 
		
	
		
			
				|  |  |  |  | { | 
		
	
		
			
				|  |  |  |  | public: | 
		
	
	
		
			
				
					|  |  |  | @ -804,8 +809,7 @@ public: | 
		
	
		
			
				|  |  |  |  |     void enableQuickfortMode() | 
		
	
		
			
				|  |  |  |  |     { | 
		
	
		
			
				|  |  |  |  |         saved_planmodes = planmode_enabled; | 
		
	
		
			
				|  |  |  |  |         for_each_(planmode_enabled,  | 
		
	
		
			
				|  |  |  |  |             [] (pair<const df::building_type, bool>& pair) { pair.second = true; } ); | 
		
	
		
			
				|  |  |  |  |         for_each_(planmode_enabled, enable_quickfort_fn); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         quickfort_mode = true; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
	
		
			
				
					|  |  |  | @ -1093,8 +1097,8 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |                     OutputHotkeyString(x, y, "Material Filter:", "m", true, left_margin); | 
		
	
		
			
				|  |  |  |  |                     auto filter_descriptions = filter->getMaterialFilterAsVector(); | 
		
	
		
			
				|  |  |  |  |                     for_each_(filter_descriptions,  | 
		
	
		
			
				|  |  |  |  |                         [&](string d) { OutputString(COLOR_BROWN, x, y, "   *" + d, true, left_margin); }); | 
		
	
		
			
				|  |  |  |  |                     for (auto it = filter_descriptions.begin(); it != filter_descriptions.end(); ++it) | 
		
	
		
			
				|  |  |  |  |                         OutputString(COLOR_BROWN, x, y, "   *" + *it, true, left_margin); | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  |                 else | 
		
	
		
			
				|  |  |  |  |                 { | 
		
	
	
		
			
				
					|  |  |  | @ -1121,8 +1125,8 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             OutputString(COLOR_BROWN, x, y, "Materials:", true, left_margin); | 
		
	
		
			
				|  |  |  |  |             auto filters = filter->getMaterialFilterAsVector(); | 
		
	
		
			
				|  |  |  |  |             for_each_(filters, | 
		
	
		
			
				|  |  |  |  |                 [&](string d) { OutputString(COLOR_BLUE, x, y, "*" + d, true, left_margin); }); | 
		
	
		
			
				|  |  |  |  |             for (auto it = filters.begin(); it != filters.end(); ++it) | 
		
	
		
			
				|  |  |  |  |                 OutputString(COLOR_BLUE, x, y, "*" + *it, true, left_margin); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         else | 
		
	
		
			
				|  |  |  |  |         { | 
		
	
	
		
			
				
					|  |  |  | 
 |