Merge pull request #3027 from myk002/myk_buildingplan_reset

[buildingplan] add reset command for resetting all filters
develop
Myk 2023-03-15 14:13:09 -07:00 committed by GitHub
commit f191334d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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`: 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 ``buildingplan reset`` command for resetting all filters to defaults
- `blueprint`: now writes blueprints to the ``dfhack-config/blueprints`` directory
- `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.

@ -60,6 +60,7 @@ Usage
buildingplan [status]
buildingplan set <setting> (true|false)
buildingplan reset
Examples
--------
@ -72,6 +73,10 @@ Examples
When finding items to satisfy "building materials" requirements, don't
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:
Global settings

@ -261,13 +261,15 @@ static void validate_config(color_ostream &out, bool verbose = 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, "reload_pens");
}
static void clear_state(color_ostream &out) {
planned_buildings.clear();
tasks.clear();
cur_heat_safety.clear();
cur_item_filters.clear();
for (auto &entry : job_item_cache ) {
for (auto &jitem : entry.second) {
delete jitem;
@ -275,6 +277,8 @@ static void clear_state(color_ostream &out) {
}
job_item_cache.clear();
mat_cache.clear();
reset_filters(out);
call_buildingplan_lua(&out, "reload_pens");
}
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;
}
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) {
DEBUG(status,out).print("entering isPlannableBuilding\n");
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_LUA_FUNCTION(printStatus),
DFHACK_LUA_FUNCTION(setSetting),
DFHACK_LUA_FUNCTION(resetFilters),
DFHACK_LUA_FUNCTION(isPlannableBuilding),
DFHACK_LUA_FUNCTION(isPlannedBuilding),
DFHACK_LUA_FUNCTION(addPlannedBuilding),

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