allow filtering by yarn

develop
Myk Taylor 2023-04-21 11:54:38 -07:00
parent 1a2d5dfc8d
commit 6d9a07355b
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
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 ## Misc Improvements
- `buildingplan`: minimized planner panel stays minimized until you change it again - `buildingplan`: minimized planner panel stays minimized until you change it again
- `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) - ``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 the terminal console on startup
- `gui/control-panel`: add preference option for hiding "armok" tools in command lists - `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 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 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 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) { static void cache_matched(int16_t type, int32_t index) {
MaterialInfo mi; MaterialInfo mi;
@ -182,6 +183,9 @@ static void cache_matched(int16_t type, int32_t index) {
} else if (mi.matches(silk_cat)) { } else if (mi.matches(silk_cat)) {
DEBUG(status).print("cached silk material: %s (%d, %d)\n", mi.toString().c_str(), type, index); 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")); 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 else
TRACE(status).print("not matched: %s\n", mi.toString().c_str()); 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::Wood);
load_organic_material_cache(df::organic_mat_category::PlantFiber); 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::Silk);
load_organic_material_cache(df::organic_mat_category::Yarn);
} }
static HeatSafety get_heat_safety_filter(const BuildingTypeKey &key) { static HeatSafety get_heat_safety_filter(const BuildingTypeKey &key) {
@ -812,6 +817,8 @@ static int setMaterialMaskFilter(lua_State *L) {
mask |= cloth_cat.whole; mask |= cloth_cat.whole;
else if (cat == "silk") else if (cat == "silk")
mask |= silk_cat.whole; mask |= silk_cat.whole;
else if (cat == "yarn")
mask |= yarn_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",
@ -860,6 +867,7 @@ static int getMaterialMaskFilter(lua_State *L) {
ret.emplace("clay", !bits || bits & clay_cat.whole); ret.emplace("clay", !bits || bits & clay_cat.whole);
ret.emplace("cloth", !bits || bits & cloth_cat.whole); ret.emplace("cloth", !bits || bits & cloth_cat.whole);
ret.emplace("silk", !bits || bits & silk_cat.whole); ret.emplace("silk", !bits || bits & silk_cat.whole);
ret.emplace("yarn", !bits || bits & yarn_cat.whole);
Lua::Push(L, ret); Lua::Push(L, ret);
return 1; return 1;
} }
@ -912,6 +920,8 @@ static int setMaterialFilter(lua_State *L) {
mask.whole |= cloth_cat.whole; mask.whole |= cloth_cat.whole;
else if (mat.matches(silk_cat)) else if (mat.matches(silk_cat))
mask.whole |= silk_cat.whole; mask.whole |= silk_cat.whole;
else if (mat.matches(yarn_cat))
mask.whole |= yarn_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);

@ -456,6 +456,7 @@ function QualityAndMaterialsPage:refresh()
make_cat_choice('Clay', 'clay', 'CUSTOM_SHIFT_C', cats), make_cat_choice('Clay', 'clay', 'CUSTOM_SHIFT_C', cats),
make_cat_choice('Cloth', 'cloth', 'CUSTOM_SHIFT_L', cats), make_cat_choice('Cloth', 'cloth', 'CUSTOM_SHIFT_L', cats),
make_cat_choice('Silk', 'silk', 'CUSTOM_SHIFT_K', 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) self.subviews.materials_categories:setChoices(category_choices)