From 50765dd60f99d7d53507e5b050319eca69289721 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 22 Nov 2014 10:08:38 -0500 Subject: [PATCH 1/3] Log output of "dfhack" script to dfhack.log --- package/darwin/dfhack | 2 +- package/linux/dfhack | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From 445640f80c77f34f1eb3a6bf739c5cab5764ded0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 25 Nov 2014 20:22:26 -0500 Subject: [PATCH 2/3] Allow commands invoked through command-prompt to access selected items/units/buildings Fixes #273 --- library/include/modules/Gui.h | 3 +++ library/modules/Gui.cpp | 6 +++--- plugins/command-prompt.cpp | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) 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/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) { From 4e69046c72e307050cbbb369d7146301c2bdb374 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 25 Nov 2014 20:26:54 -0500 Subject: [PATCH 3/3] Update NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 5bd968839..8492a6cec 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,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: