Merge pull request #3015 from myk002/myk_buildingplan_clay

[buildingplan] support clay as a filter material
develop
Myk 2023-03-12 16:01:40 -07:00 committed by GitHub
commit acfcc2ee1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

@ -38,6 +38,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Fixes ## Fixes
## Misc Improvements ## Misc Improvements
-@ `buildingplan`: can now filter by clay materials
- `blueprint`: now writes blueprints to the ``dfhack-config/blueprints`` directory - `blueprint`: now writes blueprints to the ``dfhack-config/blueprints`` directory
- `blueprint-library-guide`: library blueprints have moved from ``blueprints`` to ``hack/data/blueprints`` - `blueprint-library-guide`: library blueprints have moved from ``blueprints`` to ``hack/data/blueprints``
- player-created blueprints should now go in the ``dfhack-config/blueprints`` folder. please move your existing blueprints from ``blueprints`` to ``dfhack-config/blueprints``. you don't need to move the library blueprints -- those can be safely deleted from the old ``blueprints`` directory. - player-created blueprints should now go in the ``dfhack-config/blueprints`` folder. please move your existing blueprints from ``blueprints`` to ``dfhack-config/blueprints``. you don't need to move the library blueprints -- those can be safely deleted from the old ``blueprints`` directory.

@ -148,22 +148,26 @@ static const df::dfhack_material_category stone_cat(df::dfhack_material_category
static const df::dfhack_material_category wood_cat(df::dfhack_material_category::mask_wood); static const df::dfhack_material_category wood_cat(df::dfhack_material_category::mask_wood);
static const df::dfhack_material_category metal_cat(df::dfhack_material_category::mask_metal); static const df::dfhack_material_category metal_cat(df::dfhack_material_category::mask_metal);
static const df::dfhack_material_category glass_cat(df::dfhack_material_category::mask_glass); static const df::dfhack_material_category glass_cat(df::dfhack_material_category::mask_glass);
static const df::dfhack_material_category clay_cat(df::dfhack_material_category::mask_clay);
static void cache_matched(int16_t type, int32_t index) { static void cache_matched(int16_t type, int32_t index) {
MaterialInfo mi; MaterialInfo mi;
mi.decode(type, index); mi.decode(type, index);
if (mi.matches(stone_cat)) { if (mi.matches(stone_cat)) {
DEBUG(status).print("cached stone material: %s\n", mi.toString().c_str()); DEBUG(status).print("cached stone material: %s (%d, %d)\n", mi.toString().c_str(), type, index);
mat_cache.emplace(mi.toString(), std::make_pair(mi, "stone")); mat_cache.emplace(mi.toString(), std::make_pair(mi, "stone"));
} else if (mi.matches(wood_cat)) { } else if (mi.matches(wood_cat)) {
DEBUG(status).print("cached wood material: %s\n", mi.toString().c_str()); DEBUG(status).print("cached wood material: %s (%d, %d)\n", mi.toString().c_str(), type, index);
mat_cache.emplace(mi.toString(), std::make_pair(mi, "wood")); mat_cache.emplace(mi.toString(), std::make_pair(mi, "wood"));
} else if (mi.matches(metal_cat)) { } else if (mi.matches(metal_cat)) {
DEBUG(status).print("cached metal material: %s\n", mi.toString().c_str()); DEBUG(status).print("cached metal material: %s (%d, %d)\n", mi.toString().c_str(), type, index);
mat_cache.emplace(mi.toString(), std::make_pair(mi, "metal")); mat_cache.emplace(mi.toString(), std::make_pair(mi, "metal"));
} else if (mi.matches(glass_cat)) { } else if (mi.matches(glass_cat)) {
DEBUG(status).print("cached glass material: %s\n", mi.toString().c_str()); DEBUG(status).print("cached glass material: %s (%d, %d)\n", mi.toString().c_str(), type, index);
mat_cache.emplace(mi.toString(), std::make_pair(mi, "glass")); mat_cache.emplace(mi.toString(), std::make_pair(mi, "glass"));
} else if (mi.matches(clay_cat)) {
DEBUG(status).print("cached clay material: %s (%d, %d)\n", mi.toString().c_str(), type, index);
mat_cache.emplace(mi.toString(), std::make_pair(mi, "clay"));
} }
else else
TRACE(status).print("not matched: %s\n", mi.toString().c_str()); TRACE(status).print("not matched: %s\n", mi.toString().c_str());
@ -734,6 +738,8 @@ static int setMaterialMaskFilter(lua_State *L) {
mask |= metal_cat.whole; mask |= metal_cat.whole;
else if (cat == "glass") else if (cat == "glass")
mask |= glass_cat.whole; mask |= glass_cat.whole;
else if (cat == "clay")
mask |= clay_cat.whole;
} }
DEBUG(status,*out).print( DEBUG(status,*out).print(
"setting material mask filter for building_type=%d subtype=%d custom=%d index=%d to %x\n", "setting material mask filter for building_type=%d subtype=%d custom=%d index=%d to %x\n",
@ -778,6 +784,7 @@ static int getMaterialMaskFilter(lua_State *L) {
ret.emplace("wood", !bits || bits & wood_cat.whole); ret.emplace("wood", !bits || bits & wood_cat.whole);
ret.emplace("metal", !bits || bits & metal_cat.whole); ret.emplace("metal", !bits || bits & metal_cat.whole);
ret.emplace("glass", !bits || bits & glass_cat.whole); ret.emplace("glass", !bits || bits & glass_cat.whole);
ret.emplace("clay", !bits || bits & clay_cat.whole);
Lua::Push(L, ret); Lua::Push(L, ret);
return 1; return 1;
} }
@ -822,6 +829,8 @@ static int setMaterialFilter(lua_State *L) {
mask.whole |= metal_cat.whole; mask.whole |= metal_cat.whole;
else if (mat.matches(glass_cat)) else if (mat.matches(glass_cat))
mask.whole |= glass_cat.whole; mask.whole |= glass_cat.whole;
else if (mat.matches(clay_cat))
mask.whole |= clay_cat.whole;
} }
filter.setMaterialMask(mask.whole); filter.setMaterialMask(mask.whole);
get_item_filters(*out, key).setItemFilter(*out, filter, index); get_item_filters(*out, key).setItemFilter(*out, filter, index);

@ -443,6 +443,7 @@ function QualityAndMaterialsPage:refresh()
make_cat_choice('Wood', 'wood', 'CUSTOM_SHIFT_O', cats), make_cat_choice('Wood', 'wood', 'CUSTOM_SHIFT_O', cats),
make_cat_choice('Metal', 'metal', 'CUSTOM_SHIFT_M', cats), make_cat_choice('Metal', 'metal', 'CUSTOM_SHIFT_M', cats),
make_cat_choice('Glass', 'glass', 'CUSTOM_SHIFT_G', cats), make_cat_choice('Glass', 'glass', 'CUSTOM_SHIFT_G', cats),
make_cat_choice('Clay', 'clay', 'CUSTOM_SHIFT_C', cats),
} }
self.subviews.materials_categories:setChoices(category_choices) self.subviews.materials_categories:setChoices(category_choices)