diff --git a/NEWS b/NEWS index 5c31f0587..3192913af 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ DFHack Future New plugins: New scripts: Misc improvements: + - cmd-prompt can now access selected items, units, and buildings DFHack 0.40.16-r1 Internals: diff --git a/library/include/modules/Gui.h b/library/include/modules/Gui.h index 6acb0ce08..e2b137e2a 100644 --- a/library/include/modules/Gui.h +++ b/library/include/modules/Gui.h @@ -86,6 +86,7 @@ namespace DFHack // A unit is selected via 'v', 'k', unitjobs, or // a full-screen item view of a cage or suchlike DFHACK_EXPORT bool any_unit_hotkey(df::viewscreen *top); + DFHACK_EXPORT df::unit *getAnyUnit(df::viewscreen *top); DFHACK_EXPORT df::unit *getSelectedUnit(color_ostream &out, bool quiet = false); // An item is selected via 'v'->inventory, 'k', 't', or @@ -93,10 +94,12 @@ namespace DFHack // last case, the highlighted contained item is returned, not // the container itself. DFHACK_EXPORT bool any_item_hotkey(df::viewscreen *top); + DFHACK_EXPORT df::item *getAnyItem(df::viewscreen *top); DFHACK_EXPORT df::item *getSelectedItem(color_ostream &out, bool quiet = false); // A building is selected via 'q', 't' or 'i' (civzone) DFHACK_EXPORT bool any_building_hotkey(df::viewscreen *top); + DFHACK_EXPORT df::building *getAnyBuilding(df::viewscreen *top); DFHACK_EXPORT df::building *getSelectedBuilding(color_ostream &out, bool quiet = false); // Low-level API that gives full control over announcements and reports diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index fedb95954..5e142c798 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -773,7 +773,7 @@ df::job *Gui::getSelectedJob(color_ostream &out, bool quiet) return getSelectedWorkshopJob(out, quiet); } -static df::unit *getAnyUnit(df::viewscreen *top) +df::unit *Gui::getAnyUnit(df::viewscreen *top) { using namespace ui_sidebar_mode; using df::global::ui; @@ -904,7 +904,7 @@ df::unit *Gui::getSelectedUnit(color_ostream &out, bool quiet) return unit; } -static df::item *getAnyItem(df::viewscreen *top) +df::item *Gui::getAnyItem(df::viewscreen *top) { using namespace ui_sidebar_mode; using df::global::ui; @@ -1017,7 +1017,7 @@ df::item *Gui::getSelectedItem(color_ostream &out, bool quiet) return item; } -static df::building *getAnyBuilding(df::viewscreen *top) +df::building *Gui::getAnyBuilding(df::viewscreen *top) { using namespace ui_sidebar_mode; using df::global::ui; diff --git a/package/darwin/dfhack b/package/darwin/dfhack index 55aa81a98..814ecd013 100755 --- a/package/darwin/dfhack +++ b/package/darwin/dfhack @@ -12,6 +12,6 @@ fi old_tty_settings=$(stty -g) cd "${PWD}" -DYLD_INSERT_LIBRARIES=./hack/libdfhack.dylib ./dwarfort.exe "$@" +DYLD_INSERT_LIBRARIES=./hack/libdfhack.dylib ./dwarfort.exe "$@" 2>&1 | tee dfhack.log stty "$old_tty_settings" echo "" diff --git a/package/linux/dfhack b/package/linux/dfhack index 4fa3e20e7..44677d87e 100755 --- a/package/linux/dfhack +++ b/package/linux/dfhack @@ -65,7 +65,7 @@ case "$1" in ret=$? ;; *) - setarch i386 -R env LD_PRELOAD=$PRELOAD_LIB ./libs/Dwarf_Fortress "$@" + setarch i386 -R env LD_PRELOAD=$PRELOAD_LIB ./libs/Dwarf_Fortress "$@" 2>&1 | tee dfhack.log ret=$? ;; esac diff --git a/plugins/command-prompt.cpp b/plugins/command-prompt.cpp index 36df35cd6..cf1e78763 100644 --- a/plugins/command-prompt.cpp +++ b/plugins/command-prompt.cpp @@ -50,6 +50,10 @@ public: void help() { } int8_t movies_okay() { return 0; } + df::unit* getSelectedUnit() { return Gui::getAnyUnit(parent); } + df::item* getSelectedItem() { return Gui::getAnyItem(parent); } + df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); } + std::string getFocusString() { return "commandprompt"; } viewscreen_commandpromptst(std::string entry):is_response(false) {