add buildingplan reset for resetting all filters

develop
Myk Taylor 2023-03-15 14:02:59 -07:00
parent 73e65f2d94
commit b0f9ad6449
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
4 changed files with 22 additions and 4 deletions

@ -45,6 +45,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
-@ `buildingplan`: you can now attach multiple weapons to spike traps -@ `buildingplan`: you can now attach multiple weapons to spike traps
-@ `buildingplan`: can now filter by whether a slab is engraved -@ `buildingplan`: can now filter by whether a slab is engraved
-@ `buildingplan`: add "minimize" button to temporarily get the planner overlay out of the way if you would rather use the vanilla UI for placing the current building -@ `buildingplan`: add "minimize" button to temporarily get the planner overlay out of the way if you would rather use the vanilla UI for placing the current building
-@ `buildingplan`: add ``buildingplan reset`` command for resetting all filters to defaults
- `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.

@ -60,6 +60,7 @@ Usage
buildingplan [status] buildingplan [status]
buildingplan set <setting> (true|false) buildingplan set <setting> (true|false)
buildingplan reset
Examples Examples
-------- --------
@ -72,6 +73,10 @@ Examples
When finding items to satisfy "building materials" requirements, don't When finding items to satisfy "building materials" requirements, don't
select boulders. Use blocks or logs (if enabled) instead. select boulders. Use blocks or logs (if enabled) instead.
``buildingplan reset``
Reset all settings and filters to their defaults. This command does not affect
existing planned buildings.
.. _buildingplan-settings: .. _buildingplan-settings:
Global settings Global settings

@ -261,13 +261,15 @@ static void validate_config(color_ostream &out, bool verbose = false) {
set_config_bool(config, CONFIG_BARS, false); set_config_bool(config, CONFIG_BARS, false);
} }
static void clear_state(color_ostream &out) { static void reset_filters(color_ostream &out) {
cur_heat_safety.clear();
cur_item_filters.clear();
call_buildingplan_lua(&out, "signal_reset"); call_buildingplan_lua(&out, "signal_reset");
call_buildingplan_lua(&out, "reload_pens"); }
static void clear_state(color_ostream &out) {
planned_buildings.clear(); planned_buildings.clear();
tasks.clear(); tasks.clear();
cur_heat_safety.clear();
cur_item_filters.clear();
for (auto &entry : job_item_cache ) { for (auto &entry : job_item_cache ) {
for (auto &jitem : entry.second) { for (auto &jitem : entry.second) {
delete jitem; delete jitem;
@ -275,6 +277,8 @@ static void clear_state(color_ostream &out) {
} }
job_item_cache.clear(); job_item_cache.clear();
mat_cache.clear(); mat_cache.clear();
reset_filters(out);
call_buildingplan_lua(&out, "reload_pens");
} }
DFhackCExport command_result plugin_load_data (color_ostream &out) { DFhackCExport command_result plugin_load_data (color_ostream &out) {
@ -582,6 +586,11 @@ static bool setSetting(color_ostream &out, string name, bool value) {
return true; return true;
} }
static void resetFilters(color_ostream &out) {
DEBUG(status,out).print("entering resetFilters\n");
reset_filters(out);
}
static bool isPlannableBuilding(color_ostream &out, df::building_type type, int16_t subtype, int32_t custom) { static bool isPlannableBuilding(color_ostream &out, df::building_type type, int16_t subtype, int32_t custom) {
DEBUG(status,out).print("entering isPlannableBuilding\n"); DEBUG(status,out).print("entering isPlannableBuilding\n");
return get_num_filters(out, BuildingTypeKey(type, subtype, custom)) >= 1; return get_num_filters(out, BuildingTypeKey(type, subtype, custom)) >= 1;
@ -1104,6 +1113,7 @@ static void makeTopPriority(color_ostream &out, df::building *bld) {
DFHACK_PLUGIN_LUA_FUNCTIONS { DFHACK_PLUGIN_LUA_FUNCTIONS {
DFHACK_LUA_FUNCTION(printStatus), DFHACK_LUA_FUNCTION(printStatus),
DFHACK_LUA_FUNCTION(setSetting), DFHACK_LUA_FUNCTION(setSetting),
DFHACK_LUA_FUNCTION(resetFilters),
DFHACK_LUA_FUNCTION(isPlannableBuilding), DFHACK_LUA_FUNCTION(isPlannableBuilding),
DFHACK_LUA_FUNCTION(isPlannedBuilding), DFHACK_LUA_FUNCTION(isPlannedBuilding),
DFHACK_LUA_FUNCTION(addPlannedBuilding), DFHACK_LUA_FUNCTION(addPlannedBuilding),

@ -42,6 +42,8 @@ function parse_commandline(...)
printStatus() printStatus()
elseif command == 'set' and positionals then elseif command == 'set' and positionals then
setSetting(positionals[1], positionals[2] == 'true') setSetting(positionals[1], positionals[2] == 'true')
elseif command == 'reset' then
resetFilters()
else else
return false return false
end end