update autodump, only commands, add hotkeys

develop
Myk Taylor 2023-01-18 13:38:23 -08:00
parent d201cf0182
commit 4183bace4d
No known key found for this signature in database
5 changed files with 51 additions and 62 deletions

@ -27,8 +27,8 @@ keybinding add Ctrl-Shift-K gui/cp437-table
# dwarfmode bindings # # dwarfmode bindings #
###################### ######################
# quicksave, only in main dwarfmode screen and menu page # quicksave
#keybinding add Ctrl-Alt-S@dwarfmode/Default quicksave keybinding add Ctrl-Alt-S@dwarfmode quicksave
# toggle the display of water level as 1-7 tiles # toggle the display of water level as 1-7 tiles
#keybinding add Ctrl-W@dwarfmode|dungeonmode twaterlvl #keybinding add Ctrl-W@dwarfmode|dungeonmode twaterlvl
@ -40,14 +40,15 @@ keybinding add Ctrl-Shift-K gui/cp437-table
# clean the selected tile of blood etc # clean the selected tile of blood etc
#keybinding add Ctrl-C spotclean #keybinding add Ctrl-C spotclean
# destroy the selected item # teleport all unforbidden items marked for dumping to the tile under the keyboard cursor
#keybinding add Ctrl-K@dwarfmode autodump-destroy-item keybinding add Ctrl-Alt-D autodump
# destroy items designated for dump in the selected tile # destroy the selected unit or items that are marked for dump under
#keybinding add Ctrl-Shift-K@dwarfmode autodump-destroy-here keybinding add Ctrl-Alt-K autodump-destroy-here
#keybinding add Ctrl-Alt-K@dwarfmode "exterminate this"
# apply blueprints to the map (Alt-F for compatibility with LNP Quickfort) # apply blueprints to the map
#keybinding add Ctrl-Shift-Q@dwarfmode gui/quickfort keybinding add Ctrl-Shift-Q@dwarfmode gui/quickfort
#keybinding add Alt-F@dwarfmode gui/quickfort #keybinding add Alt-F@dwarfmode gui/quickfort
# show information collected by dwarfmonitor # show information collected by dwarfmonitor

@ -2,48 +2,32 @@ autodump
======== ========
.. dfhack-tool:: .. dfhack-tool::
:summary: Automatically set items in a stockpile to be dumped. :summary: Instantly gather or destroy items marked for dumping.
:tags: untested fort armok fps productivity items stockpiles :tags: fort armok fps items
:no-command:
.. dfhack-command:: autodump
:summary: Teleports items marked for dumping to the cursor position.
.. dfhack-command:: autodump-destroy-here .. dfhack-command:: autodump-destroy-here
:summary: Destroy items marked for dumping under the cursor. :summary: Destroy items marked for dumping under the keyboard cursor.
.. dfhack-command:: autodump-destroy-item
:summary: Destroys the selected item.
When `enabled <enable>`, this plugin adds an option to the :kbd:`q` menu for This tool can instantly move all unforbidden items marked for dumping to the
stockpiles. When the ``autodump`` option is selected for the stockpile, any tile under the keyboard cursor. After moving the items, the dump flag is unset
items placed in the stockpile will automatically be designated to be dumped. and the forbid flag is set, just as if it had been dumped normally. Be aware
that dwarves that are en route to pick up the item for dumping may still come
and move the item to your dump zone.
When invoked as a command, it can instantly move all unforbidden items marked The keyboard cursor must be placed on a floor tile so the items can be dumped
for dumping to the tile under the cursor. After moving the items, the dump flag there.
is unset and the forbid flag is set, just as if it had been dumped normally. Be
aware that dwarves that are en route to pick up the item for dumping may still
come and move the item to your dump zone.
The cursor must be placed on a floor tile so the items can be dumped there.
Usage Usage
----- -----
:: ::
enable autodump
autodump [<options>] autodump [<options>]
autodump-destroy-here autodump-destroy-here
autodump-destroy-item
``autodump-destroy-here`` is an alias for ``autodump destroy-here`` and is ``autodump-destroy-here`` is an alias for ``autodump destroy-here`` and is
intended for use as a keybinding. intended for use as a keybinding.
``autodump-destroy-item`` destroys only the selected item. The item may be
selected in the :kbd:`k` list or in the container item list. If called again
before the game is resumed, cancels destruction of the item.
Options Options
------- -------
@ -67,5 +51,5 @@ Examples
Teleports items marked for dumping to the cursor position. Teleports items marked for dumping to the cursor position.
``autodump destroy`` ``autodump destroy``
Destroys all unforbidden items marked for dumping Destroys all unforbidden items marked for dumping
``autodump-destroy-item`` ``autodump-destroy-here``
Destroys the selected item. Destroys items on the selected tile that are marked for dumping.

@ -46,6 +46,7 @@ using namespace DFHack;
#include "modules/Screen.h" #include "modules/Screen.h"
#include "modules/Maps.h" #include "modules/Maps.h"
#include "modules/Units.h" #include "modules/Units.h"
#include "modules/World.h"
#include "DataDefs.h" #include "DataDefs.h"
@ -625,10 +626,8 @@ bool Gui::anywhere_hotkey(df::viewscreen *) {
return true; return true;
} }
bool Gui::dwarfmode_hotkey(df::viewscreen *top) bool Gui::dwarfmode_hotkey(df::viewscreen *top) {
{ return World::isFortressMode();
// Require the main dwarf mode screen
return !!strict_virtual_cast<df::viewscreen_dwarfmodest>(top);
} }
bool Gui::unitjobs_hotkey(df::viewscreen *top) bool Gui::unitjobs_hotkey(df::viewscreen *top)

@ -78,7 +78,7 @@ set_source_files_properties( Brushes.h PROPERTIES HEADER_FILE_ONLY TRUE )
dfhack_plugin(autobutcher autobutcher.cpp LINK_LIBRARIES lua) dfhack_plugin(autobutcher autobutcher.cpp LINK_LIBRARIES lua)
dfhack_plugin(autochop autochop.cpp LINK_LIBRARIES lua) dfhack_plugin(autochop autochop.cpp LINK_LIBRARIES lua)
#dfhack_plugin(autoclothing autoclothing.cpp) #dfhack_plugin(autoclothing autoclothing.cpp)
#dfhack_plugin(autodump autodump.cpp) dfhack_plugin(autodump autodump.cpp)
dfhack_plugin(autofarm autofarm.cpp) dfhack_plugin(autofarm autofarm.cpp)
#dfhack_plugin(autogems autogems.cpp LINK_LIBRARIES jsoncpp_static) #dfhack_plugin(autogems autogems.cpp LINK_LIBRARIES jsoncpp_static)
#add_subdirectory(autolabor) #add_subdirectory(autolabor)

@ -1,33 +1,34 @@
// Quick Dumper : Moves items marked as "dump" to cursor // Quick Dumper : Moves items marked as "dump" to cursor
// FIXME: local item cache in map blocks needs to be fixed after teleporting items // FIXME: local item cache in map blocks needs to be fixed after teleporting items
#include <iostream>
#include <iomanip>
#include <sstream>
#include <climits>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#include "Core.h" #include "Core.h"
#include "Console.h" #include "Console.h"
#include "DataDefs.h"
#include "Export.h" #include "Export.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "modules/Maps.h" #include "modules/Maps.h"
#include "modules/Gui.h" #include "modules/Gui.h"
#include "modules/Items.h" #include "modules/Items.h"
#include "modules/Materials.h" #include "modules/Materials.h"
#include "modules/MapCache.h" #include "modules/MapCache.h"
#include "DataDefs.h"
#include "df/item.h" #include "df/item.h"
#include "df/world.h" #include "df/world.h"
#include "df/general_ref.h" #include "df/general_ref.h"
#include "df/viewscreen_dwarfmodest.h" #include "df/viewscreen_dwarfmodest.h"
#include "df/building_stockpilest.h" #include "df/building_stockpilest.h"
#include "uicommon.h"
#include <iostream>
#include <iomanip>
#include <sstream>
#include <climits>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
@ -40,6 +41,7 @@ DFHACK_PLUGIN("autodump");
REQUIRE_GLOBAL(gps); REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(world); REQUIRE_GLOBAL(world);
/* TODO: merge with stockpiles plugin
// Stockpile interface START // Stockpile interface START
static const string PERSISTENCE_KEY = "autodump/stockpiles"; static const string PERSISTENCE_KEY = "autodump/stockpiles";
@ -267,6 +269,7 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable)
} }
// Stockpile interface END // Stockpile interface END
*/
command_result df_autodump(color_ostream &out, vector <string> & parameters); command_result df_autodump(color_ostream &out, vector <string> & parameters);
command_result df_autodump_destroy_here(color_ostream &out, vector <string> & parameters); command_result df_autodump_destroy_here(color_ostream &out, vector <string> & parameters);
@ -276,18 +279,21 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCom
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"autodump", "autodump",
"Teleport items marked for dumping to the cursor.", "Teleport items marked for dumping to the keyboard cursor.",
df_autodump)); df_autodump,
Gui::dwarfmode_hotkey));
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"autodump-destroy-here", "autodump-destroy-here",
"Destroy items marked for dumping under cursor.", "Destroy items marked for dumping under the keyboard cursor.",
df_autodump_destroy_here, df_autodump_destroy_here,
Gui::cursor_hotkey)); Gui::dwarfmode_hotkey));
/* you can no longer select items
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"autodump-destroy-item", "autodump-destroy-item",
"Destroy the selected item.", "Destroy the selected item.",
df_autodump_destroy_item, df_autodump_destroy_item,
Gui::any_item_hotkey)); Gui::any_item_hotkey));
*/
return CR_OK; return CR_OK;
} }
@ -340,16 +346,14 @@ static command_result autodump_main(color_ostream &out, vector <string> & parame
MapCache MC; MapCache MC;
int dumped_total = 0; int dumped_total = 0;
int cx, cy, cz;
DFCoord pos_cursor; DFCoord pos_cursor;
if(!destroy || here) if(!destroy || here)
{ {
if (!Gui::getCursorCoords(cx,cy,cz)) pos_cursor = Gui::getMousePos();
{ if (!pos_cursor.isValid()) {
out.printerr("Cursor position not found. Please enable the cursor.\n"); out.printerr("Mouse cursor must be over a suitable map tile.\n");
return CR_FAILURE; return CR_FAILURE;
} }
pos_cursor = DFCoord(cx,cy,cz);
} }
if (!destroy) if (!destroy)
{ {
@ -441,13 +445,14 @@ command_result df_autodump(color_ostream &out, vector <string> & parameters)
command_result df_autodump_destroy_here(color_ostream &out, vector <string> & parameters) command_result df_autodump_destroy_here(color_ostream &out, vector <string> & parameters)
{ {
// HOTKEY COMMAND; CORE ALREADY SUSPENDED
if (!parameters.empty()) if (!parameters.empty())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
vector<string> args; vector<string> args;
args.push_back("destroy-here"); args.push_back("destroy-here");
CoreSuspender suspend;
return autodump_main(out, args); return autodump_main(out, args);
} }