From a5e2d79e39f0fbaad03e70d16eae7e95be146bbe Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 15 Apr 2023 21:05:05 -0700 Subject: [PATCH 01/32] remove stubs for deprecated travis scripts --- travis/authors-rst.py | 14 -------------- travis/buildmaster-rebuild-pr.py | 14 -------------- travis/check-rpc.py | 14 -------------- travis/download-df.sh | 9 --------- travis/get-df-version.sh | 9 --------- travis/lint.py | 14 -------------- travis/run-tests.py | 14 -------------- travis/script-docs.py | 14 -------------- travis/script-syntax.py | 14 -------------- 9 files changed, 116 deletions(-) delete mode 100755 travis/authors-rst.py delete mode 100755 travis/buildmaster-rebuild-pr.py delete mode 100755 travis/check-rpc.py delete mode 100755 travis/download-df.sh delete mode 100755 travis/get-df-version.sh delete mode 100755 travis/lint.py delete mode 100755 travis/run-tests.py delete mode 100755 travis/script-docs.py delete mode 100755 travis/script-syntax.py diff --git a/travis/authors-rst.py b/travis/authors-rst.py deleted file mode 100755 index cf52385b5..000000000 --- a/travis/authors-rst.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -script_name = os.path.basename(__file__) -new_script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ci', script_name) - -sys.stderr.write('\nNote: travis/{script_name} is deprecated. Use ci/{script_name} instead.\n\n'.format(script_name=script_name)) -sys.stderr.flush() - -p = subprocess.run([sys.executable, new_script_path] + sys.argv[1:]) -sys.exit(p.returncode) diff --git a/travis/buildmaster-rebuild-pr.py b/travis/buildmaster-rebuild-pr.py deleted file mode 100755 index cf52385b5..000000000 --- a/travis/buildmaster-rebuild-pr.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -script_name = os.path.basename(__file__) -new_script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ci', script_name) - -sys.stderr.write('\nNote: travis/{script_name} is deprecated. Use ci/{script_name} instead.\n\n'.format(script_name=script_name)) -sys.stderr.flush() - -p = subprocess.run([sys.executable, new_script_path] + sys.argv[1:]) -sys.exit(p.returncode) diff --git a/travis/check-rpc.py b/travis/check-rpc.py deleted file mode 100755 index cf52385b5..000000000 --- a/travis/check-rpc.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -script_name = os.path.basename(__file__) -new_script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ci', script_name) - -sys.stderr.write('\nNote: travis/{script_name} is deprecated. Use ci/{script_name} instead.\n\n'.format(script_name=script_name)) -sys.stderr.flush() - -p = subprocess.run([sys.executable, new_script_path] + sys.argv[1:]) -sys.exit(p.returncode) diff --git a/travis/download-df.sh b/travis/download-df.sh deleted file mode 100755 index aec2d6d99..000000000 --- a/travis/download-df.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -script_name="$(basename "$0")" -new_script_path="$(dirname "$0")/../ci/${script_name}" - -printf >&2 "\nNote: travis/%s is deprecated. Use ci/%s instead.\n\n" "${script_name}" "${script_name}" - -"${new_script_path}" "$@" -exit $? diff --git a/travis/get-df-version.sh b/travis/get-df-version.sh deleted file mode 100755 index aec2d6d99..000000000 --- a/travis/get-df-version.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -script_name="$(basename "$0")" -new_script_path="$(dirname "$0")/../ci/${script_name}" - -printf >&2 "\nNote: travis/%s is deprecated. Use ci/%s instead.\n\n" "${script_name}" "${script_name}" - -"${new_script_path}" "$@" -exit $? diff --git a/travis/lint.py b/travis/lint.py deleted file mode 100755 index cf52385b5..000000000 --- a/travis/lint.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -script_name = os.path.basename(__file__) -new_script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ci', script_name) - -sys.stderr.write('\nNote: travis/{script_name} is deprecated. Use ci/{script_name} instead.\n\n'.format(script_name=script_name)) -sys.stderr.flush() - -p = subprocess.run([sys.executable, new_script_path] + sys.argv[1:]) -sys.exit(p.returncode) diff --git a/travis/run-tests.py b/travis/run-tests.py deleted file mode 100755 index cf52385b5..000000000 --- a/travis/run-tests.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -script_name = os.path.basename(__file__) -new_script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ci', script_name) - -sys.stderr.write('\nNote: travis/{script_name} is deprecated. Use ci/{script_name} instead.\n\n'.format(script_name=script_name)) -sys.stderr.flush() - -p = subprocess.run([sys.executable, new_script_path] + sys.argv[1:]) -sys.exit(p.returncode) diff --git a/travis/script-docs.py b/travis/script-docs.py deleted file mode 100755 index cf52385b5..000000000 --- a/travis/script-docs.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -script_name = os.path.basename(__file__) -new_script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ci', script_name) - -sys.stderr.write('\nNote: travis/{script_name} is deprecated. Use ci/{script_name} instead.\n\n'.format(script_name=script_name)) -sys.stderr.flush() - -p = subprocess.run([sys.executable, new_script_path] + sys.argv[1:]) -sys.exit(p.returncode) diff --git a/travis/script-syntax.py b/travis/script-syntax.py deleted file mode 100755 index cf52385b5..000000000 --- a/travis/script-syntax.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -script_name = os.path.basename(__file__) -new_script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ci', script_name) - -sys.stderr.write('\nNote: travis/{script_name} is deprecated. Use ci/{script_name} instead.\n\n'.format(script_name=script_name)) -sys.stderr.flush() - -p = subprocess.run([sys.executable, new_script_path] + sys.argv[1:]) -sys.exit(p.returncode) From 250f05667b70e20a7e7c55fcfd8704477c0fe487 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 18 Apr 2023 15:50:59 -0700 Subject: [PATCH 02/32] add a warning when DT appears to be running --- docs/changelog.txt | 1 + plugins/lua/autolabor.lua | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 553fb3362..af0f208dc 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -42,6 +42,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - ``toggle-kbd-cursor``: add hotkey for toggling the keyboard cursor (Alt-K) - `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). ## Documentation diff --git a/plugins/lua/autolabor.lua b/plugins/lua/autolabor.lua index 6ef4d7279..50f39b225 100644 --- a/plugins/lua/autolabor.lua +++ b/plugins/lua/autolabor.lua @@ -10,7 +10,7 @@ AutolaborOverlay.ATTRS{ default_enabled=true, viewscreens='dwarfmode/Info/LABOR', frame={w=29, h=5}, - frame_style=gui.MEDIUM_FRAME, + frame_style=gui.THIN_FRAME, frame_background=gui.CLEAR_PEN, } @@ -18,9 +18,20 @@ function AutolaborOverlay:init() self:addviews{ widgets.Label{ frame={t=0, l=0}, - text_pen=COLOR_RED, + text_pen=COLOR_LIGHTRED, + text='DFHack autolabor is active!', + visible=isEnabled, + }, + widgets.Label{ + frame={t=0, l=0}, + text_pen=COLOR_LIGHTRED, + text='Dwarf Therapist is active!', + visible=function() return not isEnabled() end, + }, + widgets.Label{ + frame={t=1, l=0}, + text_pen=COLOR_WHITE, text={ - 'DFHack autolabor is active!', NEWLINE, 'Any changes made on this', NEWLINE, 'screen will have no effect.' }, @@ -29,7 +40,7 @@ function AutolaborOverlay:init() end function AutolaborOverlay:render(dc) - if not isEnabled() then return false end + if df.global.game_extra.external_flag ~= 1 then return end AutolaborOverlay.super.render(self, dc) end From 93aaa5d19f1d74cf602744b5ad2dbc9bec42d19f Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 18 Apr 2023 21:01:49 -0700 Subject: [PATCH 03/32] bump beta version to 50.07-r2rc2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fca548ccf..caf597088 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,7 +192,7 @@ endif() # set up versioning. set(DF_VERSION "50.07") -set(DFHACK_RELEASE "r2rc1") +set(DFHACK_RELEASE "r2rc2") set(DFHACK_PRERELEASE TRUE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") From ac4a068007055426d96ba64f6c4f3b0f96115ab0 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 18 Apr 2023 21:08:50 -0700 Subject: [PATCH 04/32] add missing changelog for buildingplan --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 553fb3362..5110e24ab 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -39,6 +39,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Misc Improvements - `buildingplan`: minimized planner panel stays minimized until you change it again +- `buildingplan`: can now filter by gems (for gem windows) - ``toggle-kbd-cursor``: add hotkey for toggling the keyboard cursor (Alt-K) - `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 From ae2bdfad5ff8fb4f9d530f9f1458415a45ed755e Mon Sep 17 00:00:00 2001 From: Taxi Service Date: Wed, 19 Apr 2023 11:28:57 +0200 Subject: [PATCH 05/32] moved Slider class from filterselection.lua to widgets.lua --- library/lua/gui/widgets.lua | 137 ++++++++++++++++++ plugins/lua/buildingplan/filterselection.lua | 139 +------------------ 2 files changed, 138 insertions(+), 138 deletions(-) diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index b33076cdc..eb4d53757 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -2293,4 +2293,141 @@ function TabBar:onInput(keys) end end +-------------------------------- +-- Slider +-- + +Slider = defclass(Slider, Widget) +Slider.ATTRS{ + num_stops=DEFAULT_NIL, + get_left_idx_fn=DEFAULT_NIL, + get_right_idx_fn=DEFAULT_NIL, + on_left_change=DEFAULT_NIL, + on_right_change=DEFAULT_NIL, +} + +function Slider:preinit(init_table) + init_table.frame = init_table.frame or {} + init_table.frame.h = init_table.frame.h or 1 +end + +function Slider:init() + if self.num_stops < 2 then error('too few Slider stops') end + self.is_dragging_target = nil -- 'left', 'right', or 'both' + self.is_dragging_idx = nil -- offset from leftmost dragged tile +end + +local function slider_get_width_per_idx(self) + return math.max(5, (self.frame_body.width-7) // (self.num_stops-1)) +end + +function Slider:onInput(keys) + if not keys._MOUSE_L_DOWN then return false end + local x = self:getMousePos() + if not x then return false end + local left_idx, right_idx = self.get_left_idx_fn(), self.get_right_idx_fn() + local width_per_idx = slider_get_width_per_idx(self) + local left_pos = width_per_idx*(left_idx-1) + local right_pos = width_per_idx*(right_idx-1) + 4 + if x < left_pos then + self.on_left_change(self.get_left_idx_fn() - 1) + elseif x < left_pos+3 then + self.is_dragging_target = 'left' + self.is_dragging_idx = x - left_pos + elseif x < right_pos then + self.is_dragging_target = 'both' + self.is_dragging_idx = x - left_pos + elseif x < right_pos+3 then + self.is_dragging_target = 'right' + self.is_dragging_idx = x - right_pos + else + self.on_right_change(self.get_right_idx_fn() + 1) + end + return true +end + +local function slider_do_drag(self, width_per_idx) + local x = self.frame_body:localXY(dfhack.screen.getMousePos()) + local cur_pos = x - self.is_dragging_idx + cur_pos = math.max(0, cur_pos) + cur_pos = math.min(width_per_idx*(self.num_stops-1)+7, cur_pos) + local offset = self.is_dragging_target == 'right' and -2 or 1 + local new_idx = math.max(0, cur_pos+offset)//width_per_idx + 1 + local new_left_idx, new_right_idx + if self.is_dragging_target == 'right' then + new_right_idx = new_idx + else + new_left_idx = new_idx + if self.is_dragging_target == 'both' then + new_right_idx = new_left_idx + self.get_right_idx_fn() - self.get_left_idx_fn() + if new_right_idx > self.num_stops then + return + end + end + end + if new_left_idx and new_left_idx ~= self.get_left_idx_fn() then + self.on_left_change(new_left_idx) + end + if new_right_idx and new_right_idx ~= self.get_right_idx_fn() then + self.on_right_change(new_right_idx) + end +end + +local SLIDER_LEFT_END = to_pen{ch=198, fg=COLOR_GREY, bg=COLOR_BLACK} +local SLIDER_TRACK = to_pen{ch=205, fg=COLOR_GREY, bg=COLOR_BLACK} +local SLIDER_TRACK_SELECTED = to_pen{ch=205, fg=COLOR_LIGHTGREEN, bg=COLOR_BLACK} +local SLIDER_TRACK_STOP = to_pen{ch=216, fg=COLOR_GREY, bg=COLOR_BLACK} +local SLIDER_TRACK_STOP_SELECTED = to_pen{ch=216, fg=COLOR_LIGHTGREEN, bg=COLOR_BLACK} +local SLIDER_RIGHT_END = to_pen{ch=181, fg=COLOR_GREY, bg=COLOR_BLACK} +local SLIDER_TAB_LEFT = to_pen{ch=60, fg=COLOR_BLACK, bg=COLOR_YELLOW} +local SLIDER_TAB_CENTER = to_pen{ch=9, fg=COLOR_BLACK, bg=COLOR_YELLOW} +local SLIDER_TAB_RIGHT = to_pen{ch=62, fg=COLOR_BLACK, bg=COLOR_YELLOW} + +function Slider:onRenderBody(dc, rect) + local left_idx, right_idx = self.get_left_idx_fn(), self.get_right_idx_fn() + local width_per_idx = slider_get_width_per_idx(self) + -- draw track + dc:seek(1,0) + dc:char(nil, SLIDER_LEFT_END) + dc:char(nil, SLIDER_TRACK) + for stop_idx=1,self.num_stops-1 do + local track_stop_pen = SLIDER_TRACK_STOP_SELECTED + local track_pen = SLIDER_TRACK_SELECTED + if left_idx > stop_idx or right_idx < stop_idx then + track_stop_pen = SLIDER_TRACK_STOP + track_pen = SLIDER_TRACK + elseif right_idx == stop_idx then + track_pen = SLIDER_TRACK + end + dc:char(nil, track_stop_pen) + for i=2,width_per_idx do + dc:char(nil, track_pen) + end + end + if right_idx >= self.num_stops then + dc:char(nil, SLIDER_TRACK_STOP_SELECTED) + else + dc:char(nil, SLIDER_TRACK_STOP) + end + dc:char(nil, SLIDER_TRACK) + dc:char(nil, SLIDER_RIGHT_END) + -- draw tabs + dc:seek(width_per_idx*(left_idx-1)) + dc:char(nil, SLIDER_TAB_LEFT) + dc:char(nil, SLIDER_TAB_CENTER) + dc:char(nil, SLIDER_TAB_RIGHT) + dc:seek(width_per_idx*(right_idx-1)+4) + dc:char(nil, SLIDER_TAB_LEFT) + dc:char(nil, SLIDER_TAB_CENTER) + dc:char(nil, SLIDER_TAB_RIGHT) + -- manage dragging + if self.is_dragging_target then + slider_do_drag(self, width_per_idx) + end + if df.global.enabler.mouse_lbut == 0 then + self.is_dragging_target = nil + self.is_dragging_idx = nil + end +end + return _ENV diff --git a/plugins/lua/buildingplan/filterselection.lua b/plugins/lua/buildingplan/filterselection.lua index 968ad88d9..fde80d4c8 100644 --- a/plugins/lua/buildingplan/filterselection.lua +++ b/plugins/lua/buildingplan/filterselection.lua @@ -12,143 +12,6 @@ local function get_cur_filters() uibs.building_subtype, uibs.custom_type) end --------------------------------- --- Slider --- - -Slider = defclass(Slider, widgets.Widget) -Slider.ATTRS{ - num_stops=DEFAULT_NIL, - get_left_idx_fn=DEFAULT_NIL, - get_right_idx_fn=DEFAULT_NIL, - on_left_change=DEFAULT_NIL, - on_right_change=DEFAULT_NIL, -} - -function Slider:preinit(init_table) - init_table.frame = init_table.frame or {} - init_table.frame.h = init_table.frame.h or 1 -end - -function Slider:init() - if self.num_stops < 2 then error('too few Slider stops') end - self.is_dragging_target = nil -- 'left', 'right', or 'both' - self.is_dragging_idx = nil -- offset from leftmost dragged tile -end - -local function slider_get_width_per_idx(self) - return math.max(5, (self.frame_body.width-7) // (self.num_stops-1)) -end - -function Slider:onInput(keys) - if not keys._MOUSE_L_DOWN then return false end - local x = self:getMousePos() - if not x then return false end - local left_idx, right_idx = self.get_left_idx_fn(), self.get_right_idx_fn() - local width_per_idx = slider_get_width_per_idx(self) - local left_pos = width_per_idx*(left_idx-1) - local right_pos = width_per_idx*(right_idx-1) + 4 - if x < left_pos then - self.on_left_change(self.get_left_idx_fn() - 1) - elseif x < left_pos+3 then - self.is_dragging_target = 'left' - self.is_dragging_idx = x - left_pos - elseif x < right_pos then - self.is_dragging_target = 'both' - self.is_dragging_idx = x - left_pos - elseif x < right_pos+3 then - self.is_dragging_target = 'right' - self.is_dragging_idx = x - right_pos - else - self.on_right_change(self.get_right_idx_fn() + 1) - end - return true -end - -local function slider_do_drag(self, width_per_idx) - local x = self.frame_body:localXY(dfhack.screen.getMousePos()) - local cur_pos = x - self.is_dragging_idx - cur_pos = math.max(0, cur_pos) - cur_pos = math.min(width_per_idx*(self.num_stops-1)+7, cur_pos) - local offset = self.is_dragging_target == 'right' and -2 or 1 - local new_idx = math.max(0, cur_pos+offset)//width_per_idx + 1 - local new_left_idx, new_right_idx - if self.is_dragging_target == 'right' then - new_right_idx = new_idx - else - new_left_idx = new_idx - if self.is_dragging_target == 'both' then - new_right_idx = new_left_idx + self.get_right_idx_fn() - self.get_left_idx_fn() - if new_right_idx > self.num_stops then - return - end - end - end - if new_left_idx and new_left_idx ~= self.get_left_idx_fn() then - self.on_left_change(new_left_idx) - end - if new_right_idx and new_right_idx ~= self.get_right_idx_fn() then - self.on_right_change(new_right_idx) - end -end - -local SLIDER_LEFT_END = to_pen{ch=198, fg=COLOR_GREY, bg=COLOR_BLACK} -local SLIDER_TRACK = to_pen{ch=205, fg=COLOR_GREY, bg=COLOR_BLACK} -local SLIDER_TRACK_SELECTED = to_pen{ch=205, fg=COLOR_LIGHTGREEN, bg=COLOR_BLACK} -local SLIDER_TRACK_STOP = to_pen{ch=216, fg=COLOR_GREY, bg=COLOR_BLACK} -local SLIDER_TRACK_STOP_SELECTED = to_pen{ch=216, fg=COLOR_LIGHTGREEN, bg=COLOR_BLACK} -local SLIDER_RIGHT_END = to_pen{ch=181, fg=COLOR_GREY, bg=COLOR_BLACK} -local SLIDER_TAB_LEFT = to_pen{ch=60, fg=COLOR_BLACK, bg=COLOR_YELLOW} -local SLIDER_TAB_CENTER = to_pen{ch=9, fg=COLOR_BLACK, bg=COLOR_YELLOW} -local SLIDER_TAB_RIGHT = to_pen{ch=62, fg=COLOR_BLACK, bg=COLOR_YELLOW} - -function Slider:onRenderBody(dc, rect) - local left_idx, right_idx = self.get_left_idx_fn(), self.get_right_idx_fn() - local width_per_idx = slider_get_width_per_idx(self) - -- draw track - dc:seek(1,0) - dc:char(nil, SLIDER_LEFT_END) - dc:char(nil, SLIDER_TRACK) - for stop_idx=1,self.num_stops-1 do - local track_stop_pen = SLIDER_TRACK_STOP_SELECTED - local track_pen = SLIDER_TRACK_SELECTED - if left_idx > stop_idx or right_idx < stop_idx then - track_stop_pen = SLIDER_TRACK_STOP - track_pen = SLIDER_TRACK - elseif right_idx == stop_idx then - track_pen = SLIDER_TRACK - end - dc:char(nil, track_stop_pen) - for i=2,width_per_idx do - dc:char(nil, track_pen) - end - end - if right_idx >= self.num_stops then - dc:char(nil, SLIDER_TRACK_STOP_SELECTED) - else - dc:char(nil, SLIDER_TRACK_STOP) - end - dc:char(nil, SLIDER_TRACK) - dc:char(nil, SLIDER_RIGHT_END) - -- draw tabs - dc:seek(width_per_idx*(left_idx-1)) - dc:char(nil, SLIDER_TAB_LEFT) - dc:char(nil, SLIDER_TAB_CENTER) - dc:char(nil, SLIDER_TAB_RIGHT) - dc:seek(width_per_idx*(right_idx-1)+4) - dc:char(nil, SLIDER_TAB_LEFT) - dc:char(nil, SLIDER_TAB_CENTER) - dc:char(nil, SLIDER_TAB_RIGHT) - -- manage dragging - if self.is_dragging_target then - slider_do_drag(self, width_per_idx) - end - if df.global.enabler.mouse_lbut == 0 then - self.is_dragging_target = nil - self.is_dragging_idx = nil - end -end - -------------------------------- -- QualityAndMaterialsPage -- @@ -328,7 +191,7 @@ function QualityAndMaterialsPage:init() enabled=enable_item_quality, on_change=function(val) self:set_max_quality(val+1) end, }, - Slider{ + widgets.Slider{ frame={l=0, t=6}, num_stops=7, get_left_idx_fn=function() From 1620604a8e0d73dd5e0b7528df284aedd11b8572 Mon Sep 17 00:00:00 2001 From: Taxi Service Date: Wed, 19 Apr 2023 11:38:22 +0200 Subject: [PATCH 06/32] added changelog entry --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 5110e24ab..809223e25 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -49,6 +49,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## API ## Lua +- `widgets`: "Slider" class has been moved from ``filterselection.lua`` into ``widgets.lua`` ## Removed From a0b259bb676f2000eff4e160ae14f4772ab2c82f Mon Sep 17 00:00:00 2001 From: Taxi Service Date: Wed, 19 Apr 2023 11:44:27 +0200 Subject: [PATCH 07/32] attempt to fix changelog entry... --- docs/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 809223e25..1ad220b0d 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -49,7 +49,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## API ## Lua -- `widgets`: "Slider" class has been moved from ``filterselection.lua`` into ``widgets.lua`` +- ``widgets``: "Slider" class has been moved from ``filterselection.lua`` into ``widgets.lua`` ## Removed From 98a252eab4ca6418b344ac8cbbc05a3273f056e5 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:13:34 +0000 Subject: [PATCH 08/32] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 6fba9905a..ad2bd2f60 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 6fba9905a71f626ecc640fd3de988e147d16cb4e +Subproject commit ad2bd2f60d1760db8ffb80cfa57f8fb868613e81 From 8371aa0b8b0b4bbb2716f22c649b2123e2680f41 Mon Sep 17 00:00:00 2001 From: Taxi Service Date: Thu, 20 Apr 2023 13:24:47 +0200 Subject: [PATCH 09/32] renamed Slider to RangeSlider, and added draft of Lua API.rst entry --- docs/changelog.txt | 2 +- docs/dev/Lua API.rst | 11 +++++++++ library/lua/gui/widgets.lua | 26 ++++++++++---------- plugins/lua/buildingplan/filterselection.lua | 2 +- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 1ad220b0d..c6e4386b8 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -49,7 +49,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## API ## Lua -- ``widgets``: "Slider" class has been moved from ``filterselection.lua`` into ``widgets.lua`` +- ``widgets``: "Slider" class has been moved from ``filterselection.lua`` into ``widgets.lua`` and renamed to "RangeSlider" ## Removed diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index e63bc8a61..212a6e891 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -5130,6 +5130,17 @@ widget does not require direct usage of ``Tab``. usage of ``Tab`` in ``TabBar:init()`` for an example. See the default value of ``active_tab_pens`` or ``inactive_tab_pens`` in ``TabBar`` for an example of how to construct pens. +RangeSlider class +----------------- + +This widget implements a mouse-interactable range-slider. The user can move its two handles to set minimum and maximum values to define a range. + +:num_stops: Specifies the amount of "notches" in the range slider, the places where handles can stop. +:get_left_idx_fn: The function used by the RangeSlider to determine what value to display on its left handle. +:get_right_idx_fn: The function used by the RangeSlider to determine what value to display on its right handle. +:on_left_change: Callback executed when a handle is moved leftwards. +:on_right_change: Callback executed when a handle is moved rightwards. + .. _lua-plugins: ======= diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index eb4d53757..a778df639 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -2294,11 +2294,11 @@ function TabBar:onInput(keys) end -------------------------------- --- Slider +-- RangeSlider -- -Slider = defclass(Slider, Widget) -Slider.ATTRS{ +RangeSlider = defclass(RangeSlider, Widget) +RangeSlider.ATTRS{ num_stops=DEFAULT_NIL, get_left_idx_fn=DEFAULT_NIL, get_right_idx_fn=DEFAULT_NIL, @@ -2306,27 +2306,27 @@ Slider.ATTRS{ on_right_change=DEFAULT_NIL, } -function Slider:preinit(init_table) +function RangeSlider:preinit(init_table) init_table.frame = init_table.frame or {} init_table.frame.h = init_table.frame.h or 1 end -function Slider:init() - if self.num_stops < 2 then error('too few Slider stops') end +function RangeSlider:init() + if self.num_stops < 2 then error('too few RangeSlider stops') end self.is_dragging_target = nil -- 'left', 'right', or 'both' self.is_dragging_idx = nil -- offset from leftmost dragged tile end -local function slider_get_width_per_idx(self) +local function rangeslider_get_width_per_idx(self) return math.max(5, (self.frame_body.width-7) // (self.num_stops-1)) end -function Slider:onInput(keys) +function RangeSlider:onInput(keys) if not keys._MOUSE_L_DOWN then return false end local x = self:getMousePos() if not x then return false end local left_idx, right_idx = self.get_left_idx_fn(), self.get_right_idx_fn() - local width_per_idx = slider_get_width_per_idx(self) + local width_per_idx = rangeslider_get_width_per_idx(self) local left_pos = width_per_idx*(left_idx-1) local right_pos = width_per_idx*(right_idx-1) + 4 if x < left_pos then @@ -2346,7 +2346,7 @@ function Slider:onInput(keys) return true end -local function slider_do_drag(self, width_per_idx) +local function rangeslider_do_drag(self, width_per_idx) local x = self.frame_body:localXY(dfhack.screen.getMousePos()) local cur_pos = x - self.is_dragging_idx cur_pos = math.max(0, cur_pos) @@ -2383,9 +2383,9 @@ local SLIDER_TAB_LEFT = to_pen{ch=60, fg=COLOR_BLACK, bg=COLOR_YELLOW} local SLIDER_TAB_CENTER = to_pen{ch=9, fg=COLOR_BLACK, bg=COLOR_YELLOW} local SLIDER_TAB_RIGHT = to_pen{ch=62, fg=COLOR_BLACK, bg=COLOR_YELLOW} -function Slider:onRenderBody(dc, rect) +function RangeSlider:onRenderBody(dc, rect) local left_idx, right_idx = self.get_left_idx_fn(), self.get_right_idx_fn() - local width_per_idx = slider_get_width_per_idx(self) + local width_per_idx = rangeslider_get_width_per_idx(self) -- draw track dc:seek(1,0) dc:char(nil, SLIDER_LEFT_END) @@ -2422,7 +2422,7 @@ function Slider:onRenderBody(dc, rect) dc:char(nil, SLIDER_TAB_RIGHT) -- manage dragging if self.is_dragging_target then - slider_do_drag(self, width_per_idx) + rangeslider_do_drag(self, width_per_idx) end if df.global.enabler.mouse_lbut == 0 then self.is_dragging_target = nil diff --git a/plugins/lua/buildingplan/filterselection.lua b/plugins/lua/buildingplan/filterselection.lua index fde80d4c8..4e8b98073 100644 --- a/plugins/lua/buildingplan/filterselection.lua +++ b/plugins/lua/buildingplan/filterselection.lua @@ -191,7 +191,7 @@ function QualityAndMaterialsPage:init() enabled=enable_item_quality, on_change=function(val) self:set_max_quality(val+1) end, }, - widgets.Slider{ + widgets.RangeSlider{ frame={l=0, t=6}, num_stops=7, get_left_idx_fn=function() From 1a2d5dfc8d34df66eb2a76cc1cb97ee79c17c43b Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Fri, 21 Apr 2023 07:13:33 +0000 Subject: [PATCH 10/32] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index ad2bd2f60..5da969fce 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit ad2bd2f60d1760db8ffb80cfa57f8fb868613e81 +Subproject commit 5da969fce69a5b9330f183cc0629798bf9907b69 From 6b86f7c69128e69dc03d07b735da5c68967759d9 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 21 Apr 2023 11:20:28 -0700 Subject: [PATCH 11/32] planner panel is minimized by default and minimized state is now persisted across reloads --- data/dfhack-config/buildingplan.json | 5 +++ docs/changelog.txt | 2 +- plugins/lua/buildingplan/planneroverlay.lua | 40 ++++++++++++++------- 3 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 data/dfhack-config/buildingplan.json diff --git a/data/dfhack-config/buildingplan.json b/data/dfhack-config/buildingplan.json new file mode 100644 index 000000000..9bb3052b7 --- /dev/null +++ b/data/dfhack-config/buildingplan.json @@ -0,0 +1,5 @@ +{ + "planner": { + "minimized": true + } +} \ No newline at end of file diff --git a/docs/changelog.txt b/docs/changelog.txt index 4794122f6..b53717dd0 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,7 +38,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes ## Misc Improvements -- `buildingplan`: minimized planner panel stays minimized until you change it again +- `buildingplan`: planner panel is minimized by default and now remembers minimized state - `buildingplan`: can now filter by gems (for gem windows) - ``toggle-kbd-cursor``: add hotkey for toggling the keyboard cursor (Alt-K) - `gui/control-panel`: add preference option for hiding the terminal console on startup diff --git a/plugins/lua/buildingplan/planneroverlay.lua b/plugins/lua/buildingplan/planneroverlay.lua index 8f12c695f..83a58ebd8 100644 --- a/plugins/lua/buildingplan/planneroverlay.lua +++ b/plugins/lua/buildingplan/planneroverlay.lua @@ -4,12 +4,15 @@ local itemselection = require('plugins.buildingplan.itemselection') local filterselection = require('plugins.buildingplan.filterselection') local gui = require('gui') local guidm = require('gui.dwarfmode') +local json = require('json') local overlay = require('plugins.overlay') local pens = require('plugins.buildingplan.pens') local utils = require('utils') local widgets = require('gui.widgets') require('dfhack.buildings') +config = config or json.open('dfhack-config/buildingplan.json') + local uibs = df.global.buildreq reset_counts_flag = false @@ -336,14 +339,14 @@ PlannerOverlay.ATTRS{ function PlannerOverlay:init() self.selected = 1 - self.minimized = false + self.state = ensure_key(config.data, 'planner') local main_panel = widgets.Panel{ view_id='main', frame={t=1, l=0, r=0, h=14}, frame_style=gui.INTERIOR_MEDIUM_FRAME, frame_background=gui.CLEAR_PEN, - visible=function() return not self.minimized end, + visible=self:callback('is_not_minimized'), } local minimized_panel = widgets.Panel{ @@ -355,8 +358,8 @@ function PlannerOverlay:init() {text=' show Planner ', pen=pens.MINI_TEXT_PEN, hpen=pens.MINI_TEXT_HPEN}, {text='['..string.char(31)..']', pen=pens.MINI_BUTT_PEN, hpen=pens.MINI_BUTT_HPEN}, }, - visible=function() return self.minimized end, - on_click=function() self.minimized = not self.minimized end, + visible=self:callback('is_minimized'), + on_click=self:callback('toggle_minimized'), }, widgets.Label{ frame={t=0, r=0, h=1}, @@ -364,8 +367,8 @@ function PlannerOverlay:init() {text=' hide Planner ', pen=pens.MINI_TEXT_PEN, hpen=pens.MINI_TEXT_HPEN}, {text='['..string.char(30)..']', pen=pens.MINI_BUTT_PEN, hpen=pens.MINI_BUTT_HPEN}, }, - visible=function() return not self.minimized end, - on_click=function() self.minimized = not self.minimized end, + visible=self:callback('is_not_minimized'), + on_click=self:callback('toggle_minimized'), }, }, } @@ -554,7 +557,7 @@ function PlannerOverlay:init() view_id='divider', frame={t=10, l=0, r=0, h=1}, on_render=self:callback('draw_divider_h'), - visible=function() return not self.minimized end, + visible=self:callback('is_not_minimized'), } local error_panel = widgets.ResizingPanel{ @@ -562,7 +565,7 @@ function PlannerOverlay:init() frame={t=15, l=0, r=0}, frame_style=gui.BOLD_FRAME, frame_background=gui.CLEAR_PEN, - visible=function() return not self.minimized end, + visible=self:callback('is_not_minimized'), } error_panel:addviews{ @@ -609,7 +612,7 @@ function PlannerOverlay:init() frame={t=0, l=1, w=37, h=1}, frame_inset=0, frame_background=gui.CLEAR_PEN, - visible=function() return not self.minimized end, + visible=self:callback('is_not_minimized'), subviews={ prev_next_selector, }, @@ -624,6 +627,19 @@ function PlannerOverlay:init() } end +function PlannerOverlay:is_minimized() + return self.state.minimized +end + +function PlannerOverlay:is_not_minimized() + return not self.state.minimized +end + +function PlannerOverlay:toggle_minimized() + self.state.minimized = not self.state.minimized + config:write() +end + function PlannerOverlay:draw_divider_h(dc) local x2 = dc.width -1 for x=0,x2 do @@ -735,13 +751,13 @@ function PlannerOverlay:onInput(keys) return false end if keys.CUSTOM_ALT_M then - self.minimized = not self.minimized + self:toggle_minimized() return true end if PlannerOverlay.super.onInput(self, keys) then return true end - if self.minimized then return false end + if self:is_minimized() then return false end if keys._MOUSE_L_DOWN then if is_over_options_panel() then return false end local detect_rect = copyall(self.frame_rect) @@ -837,7 +853,7 @@ function PlannerOverlay:onRenderFrame(dc, rect) uibs.building_type, uibs.building_subtype, uibs.custom_type)) end - if self.minimized then return end + if self:is_minimized() then return end local bounds = get_selected_bounds(self.saved_selection_pos, self.saved_pos) if not bounds then return end From 6d9a07355bde4816939177bd70086231398f3564 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 21 Apr 2023 11:54:38 -0700 Subject: [PATCH 12/32] allow filtering by yarn --- docs/changelog.txt | 2 +- plugins/buildingplan/buildingplan.cpp | 10 ++++++++++ plugins/lua/buildingplan/filterselection.lua | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 4794122f6..935b376b2 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -39,7 +39,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Misc Improvements - `buildingplan`: minimized planner panel stays minimized until you change it again -- `buildingplan`: can now filter by gems (for gem windows) +- `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) - `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 diff --git a/plugins/buildingplan/buildingplan.cpp b/plugins/buildingplan/buildingplan.cpp index e2f964a44..05b2c0af6 100644 --- a/plugins/buildingplan/buildingplan.cpp +++ b/plugins/buildingplan/buildingplan.cpp @@ -154,6 +154,7 @@ static const df::dfhack_material_category gem_cat(df::dfhack_material_category:: static const df::dfhack_material_category clay_cat(df::dfhack_material_category::mask_clay); static const df::dfhack_material_category cloth_cat(df::dfhack_material_category::mask_cloth); static const df::dfhack_material_category silk_cat(df::dfhack_material_category::mask_silk); +static const df::dfhack_material_category yarn_cat(df::dfhack_material_category::mask_yarn); static void cache_matched(int16_t type, int32_t index) { MaterialInfo mi; @@ -182,6 +183,9 @@ static void cache_matched(int16_t type, int32_t index) { } else if (mi.matches(silk_cat)) { DEBUG(status).print("cached silk material: %s (%d, %d)\n", mi.toString().c_str(), type, index); mat_cache.emplace(mi.toString(), std::make_pair(mi, "silk")); + } else if (mi.matches(yarn_cat)) { + DEBUG(status).print("cached yarn material: %s (%d, %d)\n", mi.toString().c_str(), type, index); + mat_cache.emplace(mi.toString(), std::make_pair(mi, "yarn")); } else TRACE(status).print("not matched: %s\n", mi.toString().c_str()); @@ -208,6 +212,7 @@ static void load_material_cache() { load_organic_material_cache(df::organic_mat_category::Wood); load_organic_material_cache(df::organic_mat_category::PlantFiber); load_organic_material_cache(df::organic_mat_category::Silk); + load_organic_material_cache(df::organic_mat_category::Yarn); } static HeatSafety get_heat_safety_filter(const BuildingTypeKey &key) { @@ -812,6 +817,8 @@ static int setMaterialMaskFilter(lua_State *L) { mask |= cloth_cat.whole; else if (cat == "silk") mask |= silk_cat.whole; + else if (cat == "yarn") + mask |= yarn_cat.whole; } DEBUG(status,*out).print( "setting material mask filter for building_type=%d subtype=%d custom=%d index=%d to %x\n", @@ -860,6 +867,7 @@ static int getMaterialMaskFilter(lua_State *L) { ret.emplace("clay", !bits || bits & clay_cat.whole); ret.emplace("cloth", !bits || bits & cloth_cat.whole); ret.emplace("silk", !bits || bits & silk_cat.whole); + ret.emplace("yarn", !bits || bits & yarn_cat.whole); Lua::Push(L, ret); return 1; } @@ -912,6 +920,8 @@ static int setMaterialFilter(lua_State *L) { mask.whole |= cloth_cat.whole; else if (mat.matches(silk_cat)) mask.whole |= silk_cat.whole; + else if (mat.matches(yarn_cat)) + mask.whole |= yarn_cat.whole; } filter.setMaterialMask(mask.whole); get_item_filters(*out, key).setItemFilter(*out, filter, index); diff --git a/plugins/lua/buildingplan/filterselection.lua b/plugins/lua/buildingplan/filterselection.lua index 968ad88d9..eb364870d 100644 --- a/plugins/lua/buildingplan/filterselection.lua +++ b/plugins/lua/buildingplan/filterselection.lua @@ -456,6 +456,7 @@ function QualityAndMaterialsPage:refresh() make_cat_choice('Clay', 'clay', 'CUSTOM_SHIFT_C', cats), make_cat_choice('Cloth', 'cloth', 'CUSTOM_SHIFT_L', cats), make_cat_choice('Silk', 'silk', 'CUSTOM_SHIFT_K', cats), + make_cat_choice('Yarn', 'yarn', 'CUSTOM_SHIFT_Y', cats), } self.subviews.materials_categories:setChoices(category_choices) From adeb872725cb6bfdcedbd4265a9c17e5d73d9745 Mon Sep 17 00:00:00 2001 From: Taxi Service Date: Sat, 22 Apr 2023 09:44:37 +0200 Subject: [PATCH 13/32] modified 's RangeSlider entry --- docs/dev/Lua API.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 212a6e891..02484c745 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -5133,13 +5133,16 @@ widget does not require direct usage of ``Tab``. RangeSlider class ----------------- -This widget implements a mouse-interactable range-slider. The user can move its two handles to set minimum and maximum values to define a range. - -:num_stops: Specifies the amount of "notches" in the range slider, the places where handles can stop. -:get_left_idx_fn: The function used by the RangeSlider to determine what value to display on its left handle. -:get_right_idx_fn: The function used by the RangeSlider to determine what value to display on its right handle. -:on_left_change: Callback executed when a handle is moved leftwards. -:on_right_change: Callback executed when a handle is moved rightwards. +This widget implements a mouse-interactable range-slider. The user can move its two handles to set minimum and maximum values +to define a range, or they can drag the bar itself to move both handles at once. +The handles mirror the state of its two parent ``CycleHotkeyLabels``. + +:num_stops: Used to specify the number of "notches" in the range slider, the places where handles can stop. + (this should match the parents' number of options) +:get_left_idx_fn: The function used by the RangeSlider to get the notch index on which to display the left handle. +:get_right_idx_fn: The function used by the RangeSlider to get the notch index on which to display the right handle. +:on_left_change: Callback executed when moving the left handle. +:on_right_change: Callback executed when moving the right handle. .. _lua-plugins: From 29741dff4b012a7a5bdbda8c9dc6f797bb56f2dc Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 16:31:41 -0700 Subject: [PATCH 14/32] 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 15/32] 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 b59bf72cd21c32cf551404ad87ac8a0b4c3d70c4 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 17:31:29 -0700 Subject: [PATCH 16/32] turn down the title-version plugin --- docs/about/Removed.rst | 6 ++ docs/changelog.txt | 1 + docs/plugins/title-version.rst | 14 ----- plugins/CMakeLists.txt | 1 - plugins/title-version.cpp | 109 --------------------------------- 5 files changed, 7 insertions(+), 124 deletions(-) delete mode 100644 docs/plugins/title-version.rst delete mode 100644 plugins/title-version.cpp diff --git a/docs/about/Removed.rst b/docs/about/Removed.rst index a0365e621..174fc56c4 100644 --- a/docs/about/Removed.rst +++ b/docs/about/Removed.rst @@ -206,6 +206,12 @@ stocksettings Along with ``copystock``, ``loadstock`` and ``savestock``, replaced with the new `stockpiles` API. +.. _title-version: + +title-version +============= +Replaced with an `overlay`. + .. _warn-stuck-trees: warn-stuck-trees diff --git a/docs/changelog.txt b/docs/changelog.txt index 76b9ab301..fa5c15fde 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -52,6 +52,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Lua ## Removed +- `title-version`: replaced by an `overlay` widget # 50.07-r1 diff --git a/docs/plugins/title-version.rst b/docs/plugins/title-version.rst deleted file mode 100644 index 4d0ef0c0b..000000000 --- a/docs/plugins/title-version.rst +++ /dev/null @@ -1,14 +0,0 @@ -title-version -============= - -.. dfhack-tool:: - :summary: Displays the DFHack version on DF's title screen. - :tags: unavailable interface - :no-command: - -Usage ------ - -:: - - enable title-version diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 53d0296c7..97216ad50 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -162,7 +162,6 @@ dfhack_plugin(strangemood strangemood.cpp) dfhack_plugin(tailor tailor.cpp LINK_LIBRARIES lua) dfhack_plugin(tiletypes tiletypes.cpp Brushes.h LINK_LIBRARIES lua) #dfhack_plugin(title-folder title-folder.cpp) -#dfhack_plugin(title-version title-version.cpp) #dfhack_plugin(trackstop trackstop.cpp) #dfhack_plugin(tubefill tubefill.cpp) #add_subdirectory(tweak) diff --git a/plugins/title-version.cpp b/plugins/title-version.cpp deleted file mode 100644 index 66bb159ad..000000000 --- a/plugins/title-version.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "Core.h" -#include "Console.h" -#include "Export.h" -#include "PluginManager.h" -#include "modules/Gui.h" -#include "modules/Screen.h" -#include "VTableInterpose.h" -#include "DFHackVersion.h" - -#include "df/graphic.h" -#include "df/viewscreen_optionst.h" -#include "df/viewscreen_titlest.h" -#include "uicommon.h" - -using std::vector; -using std::string; -using namespace DFHack; - -DFHACK_PLUGIN("title-version"); -DFHACK_PLUGIN_IS_ENABLED(is_enabled); -REQUIRE_GLOBAL(gps); - -void draw_version(int start_x, int start_y) { - int x = start_x, - y = start_y; - - OutputString(COLOR_WHITE, x, y, string("DFHack ") + DFHACK_VERSION); - if (!DFHACK_IS_RELEASE) - { - OutputString(COLOR_WHITE, x, y, " (dev)"); - x = start_x; y++; - OutputString(COLOR_WHITE, x, y, "Git: "); - OutputString(COLOR_WHITE, x, y, DFHACK_GIT_DESCRIPTION); - } - if (strlen(DFHACK_BUILD_ID)) - { - x = start_x; y++; - OutputString(COLOR_WHITE, x, y, "Build ID: "); - OutputString(COLOR_WHITE, x, y, DFHACK_BUILD_ID); - } - if (DFHACK_IS_PRERELEASE) - { - x = start_x; y++; - OutputString(COLOR_LIGHTRED, x, y, "Pre-release build"); - } -} - -struct title_version_hook : df::viewscreen_titlest { - typedef df::viewscreen_titlest interpose_base; - - DEFINE_VMETHOD_INTERPOSE(void, render, ()) - { - INTERPOSE_NEXT(render)(); - if (!loading) - draw_version(0, 0); - } -}; - -IMPLEMENT_VMETHOD_INTERPOSE(title_version_hook, render); - -struct options_version_hook : df::viewscreen_optionst { - typedef df::viewscreen_optionst interpose_base; - - DEFINE_VMETHOD_INTERPOSE(void, render, ()) - { - INTERPOSE_NEXT(render)(); - if (!msg_quit && !in_retire_adv && !msg_peasant && - !in_retire_dwf_abandon_adv && !in_abandon_dwf && !ending_game) - draw_version(2, gps->dimy - 6); - } -}; - -IMPLEMENT_VMETHOD_INTERPOSE(options_version_hook, render); - -DFhackCExport command_result plugin_enable (color_ostream &out, bool enable) -{ - if (!gps) - return CR_FAILURE; - - if (enable != is_enabled) - { - if (!INTERPOSE_HOOK(title_version_hook, render).apply(enable) || - !INTERPOSE_HOOK(options_version_hook, render).apply(enable)) - return CR_FAILURE; - - is_enabled = enable; - } - - return CR_OK; -} - -DFhackCExport command_result plugin_init (color_ostream &out, vector &commands) -{ - return CR_OK; -} - -DFhackCExport command_result plugin_shutdown (color_ostream &out) -{ - INTERPOSE_HOOK(title_version_hook, render).remove(); - INTERPOSE_HOOK(options_version_hook, render).remove(); - return CR_OK; -} From 87e67987a926dab0fbe98f06541717d2214eb8d3 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 17:41:38 -0700 Subject: [PATCH 17/32] 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 18/32] 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 276efc981302646e2cee7b3d5c63dba245cdeeef Mon Sep 17 00:00:00 2001 From: Myk Date: Sun, 23 Apr 2023 18:40:24 -0700 Subject: [PATCH 19/32] Apply suggestions from code review --- docs/changelog.txt | 2 +- docs/dev/Lua API.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index c6e4386b8..e05227e0d 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -49,7 +49,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## API ## Lua -- ``widgets``: "Slider" class has been moved from ``filterselection.lua`` into ``widgets.lua`` and renamed to "RangeSlider" +- ``widgets.RangeSlider``: new mouse-controlled two-headed slider widget ## Removed diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 02484c745..078cec828 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -5133,9 +5133,9 @@ widget does not require direct usage of ``Tab``. RangeSlider class ----------------- -This widget implements a mouse-interactable range-slider. The user can move its two handles to set minimum and maximum values +This widget implements a mouse-interactable range-slider. The player can move its two handles to set minimum and maximum values to define a range, or they can drag the bar itself to move both handles at once. -The handles mirror the state of its two parent ``CycleHotkeyLabels``. +The parent widget owns the range values, and can control them independently (e.g. with ``CycleHotkeyLabels``). If the range values change, the ``RangeSlider`` appearance will adjust automatically. :num_stops: Used to specify the number of "notches" in the range slider, the places where handles can stop. (this should match the parents' number of options) From 74e1aa70d9aea0bea57573b95797a659d236c1b1 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 23 Apr 2023 23:28:50 -0700 Subject: [PATCH 20/32] 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 21/32] 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 22/32] 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 ab047af1633ed386edef49c7e329d1d34e6b4a92 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 00:31:20 -0700 Subject: [PATCH 23/32] demote chatty WARN messages to DEBUG --- docs/changelog.txt | 1 + plugins/autoclothing.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 3c1ed7e8f..54d002f3e 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 +- `autoclothing`: eliminate game lag when there are many inventory items in the fort ## Misc Improvements - `buildingplan`: planner panel is minimized by default and now remembers minimized state diff --git a/plugins/autoclothing.cpp b/plugins/autoclothing.cpp index aa114cb84..d404960b4 100644 --- a/plugins/autoclothing.cpp +++ b/plugins/autoclothing.cpp @@ -565,7 +565,7 @@ static void find_needed_clothing_items() if (!item) { - WARN(cycle).print("autoclothing: Invalid inventory item ID: %d\n", ownedItem); + DEBUG(cycle).print("autoclothing: Invalid inventory item ID: %d\n", ownedItem); continue; } @@ -818,7 +818,7 @@ static void generate_report(color_ostream& out) auto item = Items::findItemByID(itemId); if (!item) { - WARN(cycle,out).print("autoclothing: Invalid inventory item ID: %d\n", itemId); + DEBUG(cycle, out).print("autoclothing: Invalid inventory item ID: %d\n", itemId); continue; } if (item->getWear() >= 1) From 6203894c998aef9f9aa3de7c6b85833719032618 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 08:03:11 -0700 Subject: [PATCH 24/32] 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 25/32] 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 26/32] 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 27/32] 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 From 4ecf125a1aa2eb1c4efe513ba1cca5bbe37278d7 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 21:19:02 +0000 Subject: [PATCH 28/32] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 68f6d354b..6b4001dc2 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 68f6d354b0d815ad0985dbe9b5faa140c980af14 +Subproject commit 6b4001dc2f9d0e662bb7d06d8ba6fcf343a656aa From 5a4dec35f1a28ad9838a951d3049924622c81166 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 14:28:21 -0700 Subject: [PATCH 29/32] reorder template declarations so we can push vectors of maps --- library/include/LuaTools.h | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/library/include/LuaTools.h b/library/include/LuaTools.h index b19fc31de..cab3ee9cc 100644 --- a/library/include/LuaTools.h +++ b/library/include/LuaTools.h @@ -342,26 +342,6 @@ namespace DFHack {namespace Lua { DFHACK_EXPORT void PushInterfaceKeys(lua_State *L, const std::set &keys); - template - void PushVector(lua_State *state, const T &pvec, bool addn = false) - { - lua_createtable(state,pvec.size(), addn?1:0); - - if (addn) - { - lua_pushinteger(state, pvec.size()); - lua_setfield(state, -2, "n"); - } - - for (size_t i = 0; i < pvec.size(); i++) - { - Push(state, pvec[i]); - lua_rawseti(state, -2, i+1); - } - } - - DFHACK_EXPORT void GetVector(lua_State *state, std::vector &pvec, int idx = 1); - DFHACK_EXPORT int PushPosXYZ(lua_State *state, const df::coord &pos); DFHACK_EXPORT int PushPosXY(lua_State *state, const df::coord2d &pos); @@ -412,6 +392,26 @@ namespace DFHack {namespace Lua { lua_settable(state, -3); } + template + void PushVector(lua_State *state, const T &pvec, bool addn = false) + { + lua_createtable(state,pvec.size(), addn?1:0); + + if (addn) + { + lua_pushinteger(state, pvec.size()); + lua_setfield(state, -2, "n"); + } + + for (size_t i = 0; i < pvec.size(); i++) + { + Push(state, pvec[i]); + lua_rawseti(state, -2, i+1); + } + } + + DFHACK_EXPORT void GetVector(lua_State *state, std::vector &pvec, int idx = 1); + DFHACK_EXPORT void CheckPen(lua_State *L, Screen::Pen *pen, int index, bool allow_nil = false, bool allow_color = true); DFHACK_EXPORT bool IsCoreContext(lua_State *state); From 73b5e37f678719c7f4473ebfa5263e8c743484d9 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 14:28:47 -0700 Subject: [PATCH 30/32] simplify loops with foreach syntax --- library/modules/Buildings.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 7694a696b..b9e61c863 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -1115,31 +1115,17 @@ static void createDesign(df::building *bld, bool rough) static int getMaxStockpileId() { - auto &vec = world->buildings.other[buildings_other_id::STOCKPILE]; int max_id = 0; - - for (size_t i = 0; i < vec.size(); i++) - { - auto bld = strict_virtual_cast(vec[i]); - if (bld) - max_id = std::max(max_id, bld->stockpile_number); - } - + for (auto bld : world->buildings.other.STOCKPILE) + max_id = std::max(max_id, bld->stockpile_number); return max_id; } static int getMaxCivzoneId() { - auto &vec = world->buildings.other[buildings_other_id::ANY_ZONE]; int max_id = 0; - - for (size_t i = 0; i < vec.size(); i++) - { - auto bld = strict_virtual_cast(vec[i]); - if (bld) - max_id = std::max(max_id, bld->zone_num); - } - + for (auto bld : world->buildings.other.ANY_ZONE) + max_id = std::max(max_id, bld->zone_num); return max_id; } From 65d7b290a3f7a859d2a75fa44e4c3109684f63b1 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 14:32:33 -0700 Subject: [PATCH 31/32] add ZScreenModal class for modal dialogs --- docs/changelog.txt | 1 + docs/dev/Lua API.rst | 7 +++++++ library/lua/gui.lua | 13 +++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index a3e9c6f6c..2b3438cc5 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -55,6 +55,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Lua - ``widgets.RangeSlider``: new mouse-controlled two-headed slider widget +- ``gui.ZScreenModal``: ZScreen subclass for modal dialogs ## Removed - `title-version`: replaced by an `overlay` widget diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 078cec828..9c320fc98 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -4323,6 +4323,13 @@ Here is an example skeleton for a ZScreen tool window:: view = view and view:raise() or MyScreen{}:show() +ZScreenModal class +------------------ + +A ZScreen convenience subclass that sets the attributes to something +appropriate for modal dialogs. The game is force paused, and no input is passed +through to the underlying viewscreens. + FramedScreen class ------------------ diff --git a/library/lua/gui.lua b/library/lua/gui.lua index e425dbcf1..b2c90d076 100644 --- a/library/lua/gui.lua +++ b/library/lua/gui.lua @@ -867,8 +867,17 @@ function ZScreen:onGetSelectedPlant() return zscreen_get_any(self, 'Plant') end --------------------------- --- Framed screen object -- +-- convenience subclass for modal dialogs +ZScreenModal = defclass(ZScreenModal, ZScreen) +ZScreenModal.ATTRS{ + defocusable = false, + force_pause = true, + pass_pause = false, + pass_movement_keys = false, + pass_mouse_clicks = false, +} + +-- Framed screen object -------------------------- -- Plain grey-colored frame. From 54ea391b1daf7059eef570add6e327a2eebaa3b0 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Apr 2023 15:26:33 -0700 Subject: [PATCH 32/32] bump to 50.07-r2rc3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index caf597088..72314ee6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,7 +192,7 @@ endif() # set up versioning. set(DF_VERSION "50.07") -set(DFHACK_RELEASE "r2rc2") +set(DFHACK_RELEASE "r2rc3") set(DFHACK_PRERELEASE TRUE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")