Use two keys for min/max

develop
Phillip Spiess 2018-05-20 20:50:42 -07:00
parent 385ac3f9f5
commit 3e54a136fd
3 changed files with 37 additions and 15 deletions

@ -654,20 +654,35 @@ PlannedBuilding *Planner::getSelectedPlannedBuilding()
return nullptr; return nullptr;
} }
void Planner::cycleMinQuality(df::building_type type) void Planner::adjustMinQuality(df::building_type type, int amount)
{ {
cycleItemQuality(&getDefaultItemFilterForType(type)->min_quality); auto min_quality = &getDefaultItemFilterForType(type)->min_quality;
*min_quality = static_cast<df::item_quality>(*min_quality + amount);
boundsCheckItemQuality(min_quality);
auto max_quality = &getDefaultItemFilterForType(type)->max_quality;
if (*min_quality > *max_quality)
(*max_quality) = *min_quality;
} }
void Planner::cycleMaxQuality(df::building_type type) void Planner::adjustMaxQuality(df::building_type type, int amount)
{ {
cycleItemQuality(&getDefaultItemFilterForType(type)->max_quality); auto max_quality = &getDefaultItemFilterForType(type)->max_quality;
} *max_quality = static_cast<df::item_quality>(*max_quality + amount);
boundsCheckItemQuality(max_quality);
auto min_quality = &getDefaultItemFilterForType(type)->min_quality;
if (*max_quality < *min_quality)
(*min_quality) = *max_quality;
}
void Planner::cycleItemQuality(item_quality::item_quality *quality) { void Planner::boundsCheckItemQuality(item_quality::item_quality *quality)
*quality = static_cast<df::item_quality>(*quality + 1); {
*quality = static_cast<df::item_quality>(*quality);
if (*quality > item_quality::Artifact) if (*quality > item_quality::Artifact)
(*quality) = item_quality::Artifact;
if (*quality < item_quality::Ordinary)
(*quality) = item_quality::Ordinary; (*quality) = item_quality::Ordinary;
} }

@ -417,8 +417,8 @@ public:
ItemFilter *getDefaultItemFilterForType(df::building_type type) { return &default_item_filters[type]; } ItemFilter *getDefaultItemFilterForType(df::building_type type) { return &default_item_filters[type]; }
void cycleMinQuality(df::building_type type); void adjustMinQuality(df::building_type type, int amount);
void cycleMaxQuality(df::building_type type); void adjustMaxQuality(df::building_type type, int amount);
void enableQuickfortMode() void enableQuickfortMode()
{ {
@ -445,7 +445,7 @@ private:
std::vector<PlannedBuilding> planned_buildings; std::vector<PlannedBuilding> planned_buildings;
void cycleItemQuality(item_quality::item_quality *quality); void boundsCheckItemQuality(item_quality::item_quality *quality);
void gather_available_items() void gather_available_items()
{ {

@ -112,7 +112,6 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
} }
else if (input->count(interface_key::CUSTOM_P) || else if (input->count(interface_key::CUSTOM_P) ||
input->count(interface_key::CUSTOM_F) || input->count(interface_key::CUSTOM_F) ||
input->count(interface_key::CUSTOM_Q) ||
input->count(interface_key::CUSTOM_D) || input->count(interface_key::CUSTOM_D) ||
input->count(interface_key::CUSTOM_N)) input->count(interface_key::CUSTOM_N))
{ {
@ -163,11 +162,19 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
} }
else if (input->count(interface_key::CUSTOM_SHIFT_Q)) else if (input->count(interface_key::CUSTOM_SHIFT_Q))
{ {
planner.cycleMinQuality(type); planner.adjustMinQuality(type, 1);
} }
else if (input->count(interface_key::CUSTOM_SHIFT_W)) else if (input->count(interface_key::CUSTOM_SHIFT_W))
{ {
planner.cycleMaxQuality(type); planner.adjustMaxQuality(type, 1);
}
else if (input->count(interface_key::CUSTOM_Q))
{
planner.adjustMinQuality(type, -1);
}
else if (input->count(interface_key::CUSTOM_W))
{
planner.adjustMaxQuality(type, -1);
} }
else if (input->count(interface_key::CUSTOM_SHIFT_D)) else if (input->count(interface_key::CUSTOM_SHIFT_D))
{ {
@ -275,10 +282,10 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
auto filter = planner.getDefaultItemFilterForType(type); auto filter = planner.getDefaultItemFilterForType(type);
OutputHotkeyString(x, y, "Min Quality: ", "Q"); OutputHotkeyString(x, y, "Min Quality: ", "qQ");
OutputString(COLOR_BROWN, x, y, filter->getMinQuality(), true, left_margin); OutputString(COLOR_BROWN, x, y, filter->getMinQuality(), true, left_margin);
OutputHotkeyString(x, y, "Max Quality: ", "W"); OutputHotkeyString(x, y, "Max Quality: ", "wW");
OutputString(COLOR_BROWN, x, y, filter->getMaxQuality(), true, left_margin); OutputString(COLOR_BROWN, x, y, filter->getMaxQuality(), true, left_margin);
OutputToggleString(x, y, "Decorated Only: ", "D", filter->decorated_only, true, left_margin); OutputToggleString(x, y, "Decorated Only: ", "D", filter->decorated_only, true, left_margin);