From 29741dff4b012a7a5bdbda8c9dc6f797bb56f2dc Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 16:31:41 -0700 Subject: [PATCH 01/11] remove toggle-kbd-cursor alias (it's a script now) --- data/init/dfhack.tools.init | 1 - 1 file changed, 1 deletion(-) diff --git a/data/init/dfhack.tools.init b/data/init/dfhack.tools.init index 8fd815559..aaf0cf277 100644 --- a/data/init/dfhack.tools.init +++ b/data/init/dfhack.tools.init @@ -144,4 +144,3 @@ enable \ alias add autounsuspend suspendmanager alias add gui/dig gui/design -alias add toggle-kbd-cursor lua "local flags4 = df.global.d_init.flags4 if flags4.KEYBOARD_CURSOR then flags4.KEYBOARD_CURSOR = false else local guidm = require('gui.dwarfmode') guidm.setCursorPos(guidm.Viewport.get():getCenter()) flags4.KEYBOARD_CURSOR = true end" From 33142a5dfc6a0cf279570da298b62659b8ce3e07 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 17:26:45 -0700 Subject: [PATCH 02/11] add DFHack title version overlay --- docs/changelog.txt | 1 + plugins/lua/overlay.lua | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 76b9ab301..7d95d810a 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -44,6 +44,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `gui/control-panel`: add preference option for hiding the terminal console on startup - `gui/control-panel`: add preference option for hiding "armok" tools in command lists - ``Dwarf Therapist``: add a warning to the Labors screen when Dwarf Therapist is active so players know that changes they make to that screen will have no effect. If you're starting a new embark and nobody seems to be doing anything, check your Labors tab for this warning to see if Dwarf Therapist thinks it is in control (even if it's not running). +- `overlay`: add the DFHack version string to the DF title screen ## Documentation diff --git a/plugins/lua/overlay.lua b/plugins/lua/overlay.lua index ff8bf7c98..75dc301ad 100644 --- a/plugins/lua/overlay.lua +++ b/plugins/lua/overlay.lua @@ -562,4 +562,42 @@ function OverlayWidget:init() self.frame.h = self.frame.h or 1 end +-- ------------------- -- +-- TitleVersionOverlay -- +-- ------------------- -- + +TitleVersionOverlay = defclass(TitleVersionOverlay, OverlayWidget) +TitleVersionOverlay.ATTRS{ + default_pos={x=50, y=-2}, + default_enabled=true, + viewscreens='title', + frame={w=30, h=3}, +} + +function TitleVersionOverlay:init() + local text = {} + table.insert(text, 'DFHack ' .. dfhack.getDFHackVersion() .. + (dfhack.isPrerelease() and (' (%s)'):format(dfhack.getGitCommit():sub(1,7)) or '')) + if #dfhack.getDFHackBuildID() > 0 then + table.insert(text, NEWLINE) + table.insert(text, 'Build ID: ' .. dfhack.getDFHackBuildID()) + end + if dfhack.isPrerelease() then + table.insert(text, NEWLINE) + table.insert(text, {text='Pre-release build', pen=COLOR_LIGHTRED}) + end + + self:addviews{ + widgets.Label{ + frame={b=0, l=0}, + text=text, + text_pen=COLOR_WHITE, + }, + } +end + +OVERLAY_WIDGETS = { + title_version = TitleVersionOverlay, +} + return _ENV From 87e67987a926dab0fbe98f06541717d2214eb8d3 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 17:41:38 -0700 Subject: [PATCH 03/11] add "version" alias to run the help --- data/init/dfhack.tools.init | 1 + docs/changelog.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/data/init/dfhack.tools.init b/data/init/dfhack.tools.init index 8fd815559..cdd2a63a0 100644 --- a/data/init/dfhack.tools.init +++ b/data/init/dfhack.tools.init @@ -145,3 +145,4 @@ enable \ alias add autounsuspend suspendmanager alias add gui/dig gui/design alias add toggle-kbd-cursor lua "local flags4 = df.global.d_init.flags4 if flags4.KEYBOARD_CURSOR then flags4.KEYBOARD_CURSOR = false else local guidm = require('gui.dwarfmode') guidm.setCursorPos(guidm.Viewport.get():getCenter()) flags4.KEYBOARD_CURSOR = true end" +alias add version help diff --git a/docs/changelog.txt b/docs/changelog.txt index fa5c15fde..ecc616669 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -41,6 +41,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `buildingplan`: planner panel is minimized by default and now remembers minimized state - `buildingplan`: can now filter by gems (for gem windows) and yarn (for ropes in wells) - ``toggle-kbd-cursor``: add hotkey for toggling the keyboard cursor (Alt-K) +- ``version``: add alias to display the DFHack help (including the version number) so something happens when players try to run "version" - `gui/control-panel`: add preference option for hiding the terminal console on startup - `gui/control-panel`: add preference option for hiding "armok" tools in command lists - ``Dwarf Therapist``: add a warning to the Labors screen when Dwarf Therapist is active so players know that changes they make to that screen will have no effect. If you're starting a new embark and nobody seems to be doing anything, check your Labors tab for this warning to see if Dwarf Therapist thinks it is in control (even if it's not running). From b5459faffea36a6b579f6e7fe957f29d0d7aac72 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 18:20:50 -0700 Subject: [PATCH 04/11] format version string in help the same way --- library/Core.cpp | 2 +- library/DFHackVersion.cpp | 7 +++++-- library/include/DFHackVersion.h | 2 +- plugins/lua/overlay.lua | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index 4f06c3d62..a1e3b60e5 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -273,7 +273,7 @@ static std::string dfhack_version_desc() if (Version::is_release()) s << "(release)"; else - s << "(development build " << Version::git_description() << ")"; + s << "(git: " << Version::git_commit(true) << ")"; s << " on " << (sizeof(void*) == 8 ? "x86_64" : "x86"); if (strlen(Version::dfhack_build_id())) s << " [build ID: " << Version::dfhack_build_id() << "]"; diff --git a/library/DFHackVersion.cpp b/library/DFHackVersion.cpp index 7746ebece..42aac251e 100644 --- a/library/DFHackVersion.cpp +++ b/library/DFHackVersion.cpp @@ -1,6 +1,8 @@ #define NO_DFHACK_VERSION_MACROS #include "DFHackVersion.h" #include "git-describe.h" +#include + namespace DFHack { namespace Version { int dfhack_abi_version() @@ -27,9 +29,10 @@ namespace DFHack { { return DFHACK_GIT_DESCRIPTION; } - const char *git_commit() + const char* git_commit(bool short_hash) { - return DFHACK_GIT_COMMIT; + static std::string shorty(DFHACK_GIT_COMMIT, 0, 7); + return short_hash ? shorty.c_str() : DFHACK_GIT_COMMIT; } const char *git_xml_commit() { diff --git a/library/include/DFHackVersion.h b/library/include/DFHackVersion.h index 1b69dfe55..fbf2539bf 100644 --- a/library/include/DFHackVersion.h +++ b/library/include/DFHackVersion.h @@ -8,7 +8,7 @@ namespace DFHack { int dfhack_abi_version(); const char *git_description(); - const char *git_commit(); + const char* git_commit(bool short_hash = false); const char *git_xml_commit(); const char *git_xml_expected_commit(); bool git_xml_match(); diff --git a/plugins/lua/overlay.lua b/plugins/lua/overlay.lua index 75dc301ad..6a568fb85 100644 --- a/plugins/lua/overlay.lua +++ b/plugins/lua/overlay.lua @@ -571,13 +571,13 @@ TitleVersionOverlay.ATTRS{ default_pos={x=50, y=-2}, default_enabled=true, viewscreens='title', - frame={w=30, h=3}, + frame={w=35, h=3}, } function TitleVersionOverlay:init() local text = {} table.insert(text, 'DFHack ' .. dfhack.getDFHackVersion() .. - (dfhack.isPrerelease() and (' (%s)'):format(dfhack.getGitCommit():sub(1,7)) or '')) + (dfhack.isPrerelease() and (' (git: %s)'):format(dfhack.getGitCommit(true)) or '')) if #dfhack.getDFHackBuildID() > 0 then table.insert(text, NEWLINE) table.insert(text, 'Build ID: ' .. dfhack.getDFHackBuildID()) From 74e1aa70d9aea0bea57573b95797a659d236c1b1 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 23:28:50 -0700 Subject: [PATCH 05/11] fix smoothing job detection --- docs/changelog.txt | 1 + plugins/dig-now.cpp | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 3c1ed7e8f..588c1a6be 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## New Plugins ## Fixes +- `dig-now`: properly detect and complete smoothing designations that have been converted into active jobs ## Misc Improvements - `buildingplan`: planner panel is minimized by default and now remembers minimized state diff --git a/plugins/dig-now.cpp b/plugins/dig-now.cpp index be431722b..b2af2dbca 100644 --- a/plugins/dig-now.cpp +++ b/plugins/dig-now.cpp @@ -113,14 +113,10 @@ public: case job_type::CarveUpDownStaircase: td.bits.dig = tile_dig_designation::UpDownStair; break; - case job_type::DetailWall: - case job_type::DetailFloor: { - df::tiletype tt = map.tiletypeAt(job->pos); - if (tileSpecial(tt) != df::tiletype_special::SMOOTH) { - td.bits.smooth = 1; - } + case job_type::SmoothWall: + case job_type::SmoothFloor: + td.bits.smooth = 1; break; - } case job_type::CarveTrack: to.bits.carve_track_north = (job->item_category.whole >> 18) & 1; to.bits.carve_track_south = (job->item_category.whole >> 19) & 1; From 31401b2e199d31027be4fd155c4c91dc88805190 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 23:48:10 -0700 Subject: [PATCH 06/11] fixed size limit calculations for rollers --- docs/changelog.txt | 1 + plugins/lua/buildingplan/planneroverlay.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 3c1ed7e8f..0080ab9c3 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## New Plugins ## Fixes +- `buildingplan`: fixed size limit calculations for rollers ## Misc Improvements - `buildingplan`: planner panel is minimized by default and now remembers minimized state diff --git a/plugins/lua/buildingplan/planneroverlay.lua b/plugins/lua/buildingplan/planneroverlay.lua index 83a58ebd8..803e9ae99 100644 --- a/plugins/lua/buildingplan/planneroverlay.lua +++ b/plugins/lua/buildingplan/planneroverlay.lua @@ -34,9 +34,10 @@ local function get_selection_size_limits() or btype == df.building_type.RoadPaved or btype == df.building_type.RoadDirt then return {w=31, h=31} - elseif btype == df.building_type.AxleHorizontal - or btype == df.building_type.Rollers then + elseif btype == df.building_type.AxleHorizontal then return uibs.direction == 1 and {w=1, h=31} or {w=31, h=1} + elseif btype == df.building_type.Rollers then + return (uibs.direction == 1 or uibs.direction == 3) and {w=31, h=1} or {w=1, h=31} end end From 5e1117473ae577e009ba4825f81dfcd981105cfd Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Mon, 24 Apr 2023 07:14:36 +0000 Subject: [PATCH 07/11] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 5da969fce..68f6d354b 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 5da969fce69a5b9330f183cc0629798bf9907b69 +Subproject commit 68f6d354b0d815ad0985dbe9b5faa140c980af14 From 6203894c998aef9f9aa3de7c6b85833719032618 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 08:03:11 -0700 Subject: [PATCH 08/11] add title screen focus string detection --- library/modules/Gui.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 6ea0a5ff0..44642b5fa 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -84,6 +84,7 @@ using namespace DFHack; #include "df/unit.h" #include "df/unit_inventory_item.h" #include "df/viewscreen_dwarfmodest.h" +#include "df/viewscreen_titlest.h" #include "df/world.h" const size_t MAX_REPORTS_SIZE = 3000; // DF clears old reports to maintain this vector size @@ -144,6 +145,17 @@ static std::map getFocusStringsHandle ); \ static void getFocusStrings_##screen_type(std::string &baseFocus, std::vector &focusStrings, VIEWSCREEN(screen_type) *screen) +DEFINE_GET_FOCUS_STRING_HANDLER(title) +{ + if (screen->managing_mods) + focusStrings.push_back(baseFocus + "/Mods"); + else if (game->main_interface.settings.open) + focusStrings.push_back(baseFocus + "/Settings"); + + if (focusStrings.empty()) + focusStrings.push_back(baseFocus + "/Default"); +} + DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) { std::string newFocusString; From 65da8ef3c97e9c7b819c0cabf77292c69249dcfc Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 08:03:31 -0700 Subject: [PATCH 09/11] only display dfhack logo on base title screen to avoid overlapping important widgets on subscreens --- plugins/lua/hotkeys.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lua/hotkeys.lua b/plugins/lua/hotkeys.lua index b162f0c08..fca0f1f27 100644 --- a/plugins/lua/hotkeys.lua +++ b/plugins/lua/hotkeys.lua @@ -39,7 +39,7 @@ HotspotMenuWidget.ATTRS{ -- 'new_region', -- conflicts with vanilla panel layouts 'savegame', 'setupdwarfgame', - 'title', + 'title/Default', 'update_region', 'world' }, From 2686c8f08441088cb6d008c4728c66533e4a2f51 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 08:04:08 -0700 Subject: [PATCH 10/11] move DFHack version next to logo and only display on the base title screen --- plugins/lua/overlay.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/lua/overlay.lua b/plugins/lua/overlay.lua index 6a568fb85..81dde32b6 100644 --- a/plugins/lua/overlay.lua +++ b/plugins/lua/overlay.lua @@ -570,7 +570,7 @@ TitleVersionOverlay = defclass(TitleVersionOverlay, OverlayWidget) TitleVersionOverlay.ATTRS{ default_pos={x=50, y=-2}, default_enabled=true, - viewscreens='title', + viewscreens='title/Default', frame={w=35, h=3}, } @@ -589,7 +589,7 @@ function TitleVersionOverlay:init() self:addviews{ widgets.Label{ - frame={b=0, l=0}, + frame={t=0, l=0}, text=text, text_pen=COLOR_WHITE, }, From 300e891f8aa8d97fcef4493cc3ac9a0d7bfd7a0c Mon Sep 17 00:00:00 2001 From: Myk Date: Mon, 24 Apr 2023 14:15:09 -0700 Subject: [PATCH 11/11] Update changelog.txt --- docs/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 4429e40be..49723ab27 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -37,7 +37,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - `buildingplan`: fixed size limit calculations for rollers -`- `dig-now`: properly detect and complete smoothing designations that have been converted into active jobs +- `dig-now`: properly detect and complete smoothing designations that have been converted into active jobs ## Misc Improvements - `buildingplan`: planner panel is minimized by default and now remembers minimized state