Merge pull request #3278 from myk002/myk_troll_Fur

[buildingplan] allow filtering by yarn
develop
Myk 2023-04-21 17:55:58 -07:00 committed by GitHub
commit 35468e3f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

@ -39,7 +39,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements
- `buildingplan`: planner panel is minimized by default and now remembers minimized state
- `buildingplan`: can now filter by gems (for gem windows)
- `buildingplan`: can now filter by gems (for gem windows) and yarn (for ropes in wells)
- ``toggle-kbd-cursor``: add hotkey for toggling the keyboard cursor (Alt-K)
- `gui/control-panel`: add preference option for hiding the terminal console on startup
- `gui/control-panel`: add preference option for hiding "armok" tools in command lists

@ -154,6 +154,7 @@ static const df::dfhack_material_category gem_cat(df::dfhack_material_category::
static const df::dfhack_material_category clay_cat(df::dfhack_material_category::mask_clay);
static const df::dfhack_material_category cloth_cat(df::dfhack_material_category::mask_cloth);
static const df::dfhack_material_category silk_cat(df::dfhack_material_category::mask_silk);
static const df::dfhack_material_category yarn_cat(df::dfhack_material_category::mask_yarn);
static void cache_matched(int16_t type, int32_t index) {
MaterialInfo mi;
@ -182,6 +183,9 @@ static void cache_matched(int16_t type, int32_t index) {
} else if (mi.matches(silk_cat)) {
DEBUG(status).print("cached silk material: %s (%d, %d)\n", mi.toString().c_str(), type, index);
mat_cache.emplace(mi.toString(), std::make_pair(mi, "silk"));
} else if (mi.matches(yarn_cat)) {
DEBUG(status).print("cached yarn material: %s (%d, %d)\n", mi.toString().c_str(), type, index);
mat_cache.emplace(mi.toString(), std::make_pair(mi, "yarn"));
}
else
TRACE(status).print("not matched: %s\n", mi.toString().c_str());
@ -208,6 +212,7 @@ static void load_material_cache() {
load_organic_material_cache(df::organic_mat_category::Wood);
load_organic_material_cache(df::organic_mat_category::PlantFiber);
load_organic_material_cache(df::organic_mat_category::Silk);
load_organic_material_cache(df::organic_mat_category::Yarn);
}
static HeatSafety get_heat_safety_filter(const BuildingTypeKey &key) {
@ -812,6 +817,8 @@ static int setMaterialMaskFilter(lua_State *L) {
mask |= cloth_cat.whole;
else if (cat == "silk")
mask |= silk_cat.whole;
else if (cat == "yarn")
mask |= yarn_cat.whole;
}
DEBUG(status,*out).print(
"setting material mask filter for building_type=%d subtype=%d custom=%d index=%d to %x\n",
@ -860,6 +867,7 @@ static int getMaterialMaskFilter(lua_State *L) {
ret.emplace("clay", !bits || bits & clay_cat.whole);
ret.emplace("cloth", !bits || bits & cloth_cat.whole);
ret.emplace("silk", !bits || bits & silk_cat.whole);
ret.emplace("yarn", !bits || bits & yarn_cat.whole);
Lua::Push(L, ret);
return 1;
}
@ -912,6 +920,8 @@ static int setMaterialFilter(lua_State *L) {
mask.whole |= cloth_cat.whole;
else if (mat.matches(silk_cat))
mask.whole |= silk_cat.whole;
else if (mat.matches(yarn_cat))
mask.whole |= yarn_cat.whole;
}
filter.setMaterialMask(mask.whole);
get_item_filters(*out, key).setItemFilter(*out, filter, index);

@ -456,6 +456,7 @@ function QualityAndMaterialsPage:refresh()
make_cat_choice('Clay', 'clay', 'CUSTOM_SHIFT_C', cats),
make_cat_choice('Cloth', 'cloth', 'CUSTOM_SHIFT_L', cats),
make_cat_choice('Silk', 'silk', 'CUSTOM_SHIFT_K', cats),
make_cat_choice('Yarn', 'yarn', 'CUSTOM_SHIFT_Y', cats),
}
self.subviews.materials_categories:setChoices(category_choices)