From d412897b67af8e3e449a71622d0e60aaf93c47bf Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 10:32:56 +0300 Subject: [PATCH 1/8] gui/autobutcher changes - Add a warning to enable autobutcher to make changes - Add features to butcher and unbutcher all animals --- gui/autobutcher.lua | 67 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/gui/autobutcher.lua b/gui/autobutcher.lua index fdfffd688d..2402221922 100644 --- a/gui/autobutcher.lua +++ b/gui/autobutcher.lua @@ -152,7 +152,7 @@ function WatchList:init() local window = widgets.Window{ frame_title='Autobutcher', - frame={w=97, h=30}, + frame={w=97, h=31}, resizable=true, subviews={ widgets.CycleHotkeyLabel{ @@ -306,6 +306,18 @@ function WatchList:init() frame={t=1, l=82}, text='ordered' }, + widgets.Panel{ + view_id='disabled_warning', + frame={t=3, h=1}, + visible=not plugin.isEnabled, + subviews={ + widgets.Label{ + frame={l=8}, + text={"Enable autobutcher to change settings"}, + text_pen=COLOR_YELLOW + } + } + }, widgets.List{ view_id='list', frame={t=3, b=0}, @@ -316,7 +328,7 @@ function WatchList:init() }, widgets.Panel{ view_id='footer', - frame={l=0, r=0, b=0, h=6}, + frame={l=0, r=0, b=0, h=7}, subviews={ widgets.Label{ frame={t=0, l=0}, @@ -402,9 +414,25 @@ function WatchList:init() auto_width=true, on_activate=self:callback('onSetRow'), }, + widgets.HotkeyLabel{ + view_id='butcher_all', + frame={t=5, l=0}, + key='CUSTOM_E', + label='Butcher all', + auto_width=true, + on_activate=self:callback('onButcherAll'), + }, + widgets.HotkeyLabel{ + view_id='unbutcher_all', + frame={t=5, l=16}, + key='CUSTOM_SHIFT_E', + label='Unbutcher all', + auto_width=true, + on_activate=self:callback('onUnbutcherAll'), + }, widgets.ToggleHotkeyLabel{ view_id='enable_toggle', - frame={t=5, l=0, w=26}, + frame={t=6, l=0, w=26}, label='Autobutcher is', key='CUSTOM_SHIFT_A', options={{value=true, label='Enabled', pen=COLOR_GREEN}, @@ -416,7 +444,7 @@ function WatchList:init() }, widgets.ToggleHotkeyLabel{ view_id='autowatch_toggle', - frame={t=5, l=43, w=24}, + frame={t=6, l=43, w=24}, label='Autowatch is', key='CUSTOM_SHIFT_W', options={{value=true, label='Enabled', pen=COLOR_GREEN}, @@ -508,6 +536,14 @@ function WatchList:refresh(sort_widget, sort_fn) -- first two rows are for "edit all races" and "edit new races" local settings = plugin.autobutcher_getSettings() + + self.subviews.disabled_warning.visible = not plugin.isEnabled() + + if not plugin.isEnabled() then + self.subviews.list:setChoices(table) + return + end + table.insert(choices, { text=make_row_text('!! ALL RACES PLUS NEW', settings), race=1, @@ -709,6 +745,29 @@ function WatchList:onButcherRace() self:refresh() end +function WatchList:onUnbutcherAll() + for _, data in ipairs(plugin.autobutcher_getWatchList()) do + plugin.autobutcher_unbutcherRace(data.id) + end + + self:refresh() +end + +function WatchList:onButcherAll() + dlg.showYesNoPrompt( + 'Butcher all animals', + 'Warning! This will mark ALL animals for butchering.'..NEWLINE..'Proceed with caution.', + COLOR_YELLOW, + function() + for _, data in ipairs(plugin.autobutcher_getWatchList()) do + plugin.autobutcher_butcherRace(data.id) + end + + self:refresh() + end + ) +end + function WatchList:onDismiss() view = nil end From 442bbb9bf79d70bf7234cfe011530a6da0c6d358 Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 10:41:00 +0300 Subject: [PATCH 2/8] Update changelog.txt --- changelog.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.txt b/changelog.txt index c4cf1a2135..9d3d7e8671 100644 --- a/changelog.txt +++ b/changelog.txt @@ -37,11 +37,16 @@ Template for new versions: ## Removed # 50.13-r1.1 +## New Features +- `gui/autobutcher`: add functionality to butcher and unbutcher all animals ## Fixes - `gui/quantum`: accept all item types in the output stockpile as intended - `deathcause`: fix error on run +## Misc Improvements +- `gui/autobutcher`: add warning if autobutcher is disabled + # 50.13-r1 ## New Tools From 3440943e07b8c6aaf854fd528a1663b4be9495bf Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 10:44:28 +0300 Subject: [PATCH 3/8] Remove useless panel --- gui/autobutcher.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gui/autobutcher.lua b/gui/autobutcher.lua index 2402221922..bf6b56bccf 100644 --- a/gui/autobutcher.lua +++ b/gui/autobutcher.lua @@ -306,17 +306,12 @@ function WatchList:init() frame={t=1, l=82}, text='ordered' }, - widgets.Panel{ + widgets.Label{ view_id='disabled_warning', - frame={t=3, h=1}, visible=not plugin.isEnabled, - subviews={ - widgets.Label{ - frame={l=8}, - text={"Enable autobutcher to change settings"}, - text_pen=COLOR_YELLOW - } - } + frame={t=3, l=8, h=1}, + text={"Enable autobutcher to change settings"}, + text_pen=COLOR_YELLOW }, widgets.List{ view_id='list', From 38a90af4d3a6bb33108575d94989a9628079e4a6 Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 10:46:12 +0300 Subject: [PATCH 4/8] Small fixes --- gui/autobutcher.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/autobutcher.lua b/gui/autobutcher.lua index bf6b56bccf..1f85c21f96 100644 --- a/gui/autobutcher.lua +++ b/gui/autobutcher.lua @@ -529,16 +529,16 @@ function WatchList:refresh(sort_widget, sort_fn) local choices = {} - -- first two rows are for "edit all races" and "edit new races" local settings = plugin.autobutcher_getSettings() self.subviews.disabled_warning.visible = not plugin.isEnabled() if not plugin.isEnabled() then - self.subviews.list:setChoices(table) + self.subviews.list:setChoices(choices) return end - + + -- first two rows are for "edit all races" and "edit new races" table.insert(choices, { text=make_row_text('!! ALL RACES PLUS NEW', settings), race=1, From ce61f9d3090e2e13c2605f1c15697968239a3614 Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 10:53:10 +0300 Subject: [PATCH 5/8] Move changes to correct version --- changelog.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 9d3d7e8671..03fe29a54a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -36,17 +36,20 @@ Template for new versions: ## Removed -# 50.13-r1.1 +# 50.13-r2 + ## New Features - `gui/autobutcher`: add functionality to butcher and unbutcher all animals +## Misc Improvements +- `gui/autobutcher`: add warning if autobutcher is disabled + +# 50.13-r1.1 + ## Fixes - `gui/quantum`: accept all item types in the output stockpile as intended - `deathcause`: fix error on run -## Misc Improvements -- `gui/autobutcher`: add warning if autobutcher is disabled - # 50.13-r1 ## New Tools From 42c3fbefbc7b62dde56df91a848c16a4a6f1decd Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 10:54:59 +0300 Subject: [PATCH 6/8] Fix whitespace --- gui/autobutcher.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/autobutcher.lua b/gui/autobutcher.lua index 1f85c21f96..d701d950e0 100644 --- a/gui/autobutcher.lua +++ b/gui/autobutcher.lua @@ -537,7 +537,7 @@ function WatchList:refresh(sort_widget, sort_fn) self.subviews.list:setChoices(choices) return end - + -- first two rows are for "edit all races" and "edit new races" table.insert(choices, { text=make_row_text('!! ALL RACES PLUS NEW', settings), @@ -757,7 +757,7 @@ function WatchList:onButcherAll() for _, data in ipairs(plugin.autobutcher_getWatchList()) do plugin.autobutcher_butcherRace(data.id) end - + self:refresh() end ) From 26cb34baf01d4002f8d27d378f87a2e1c5ab7609 Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 14:39:28 +0300 Subject: [PATCH 7/8] Simplify message visibility, reorder command labels --- gui/autobutcher.lua | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/gui/autobutcher.lua b/gui/autobutcher.lua index d701d950e0..f82d6969b6 100644 --- a/gui/autobutcher.lua +++ b/gui/autobutcher.lua @@ -190,7 +190,7 @@ function WatchList:init() }, widgets.Panel{ view_id='list_panel', - frame={t=2, l=0, r=0, b=7}, + frame={t=2, l=0, r=0, b=8}, frame_style=gui.FRAME_INTERIOR, subviews={ widgets.CycleHotkeyLabel{ @@ -308,7 +308,7 @@ function WatchList:init() }, widgets.Label{ view_id='disabled_warning', - visible=not plugin.isEnabled, + visible=function() return not plugin.isEnabled() end, frame={t=3, l=8, h=1}, text={"Enable autobutcher to change settings"}, text_pen=COLOR_YELLOW @@ -316,6 +316,7 @@ function WatchList:init() widgets.List{ view_id='list', frame={t=3, b=0}, + visible=plugin.isEnabled, on_double_click = self:callback('onDoubleClick'), on_double_click2 = self:callback('zeroOut'), }, @@ -350,7 +351,7 @@ function WatchList:init() }, widgets.HotkeyLabel{ view_id='fa', - frame={t=3, l=11}, + frame={t=3, l=17}, key='CUSTOM_SHIFT_F', label='F adults', auto_width=true, @@ -358,7 +359,7 @@ function WatchList:init() }, widgets.HotkeyLabel{ view_id='ma', - frame={t=4, l=11}, + frame={t=4, l=17}, key='CUSTOM_SHIFT_M', label='M adults', auto_width=true, @@ -366,7 +367,7 @@ function WatchList:init() }, widgets.HotkeyLabel{ view_id='butcher', - frame={t=3, l=24}, + frame={t=5, l=0}, key='CUSTOM_B', label='Butcher race', auto_width=true, @@ -374,7 +375,7 @@ function WatchList:init() }, widgets.HotkeyLabel{ view_id='unbutcher', - frame={t=4, l=24}, + frame={t=5, l=17}, key='CUSTOM_SHIFT_B', label='Unbutcher race', auto_width=true, @@ -382,28 +383,28 @@ function WatchList:init() }, widgets.HotkeyLabel{ view_id='watch', - frame={t=3, l=43}, + frame={t=3, l=36}, key='CUSTOM_W', label='Toggle watch', auto_width=true, on_activate=self:callback('onToggleWatching'), }, widgets.HotkeyLabel{ - frame={t=4, l=43}, + frame={t=4, l=36}, key='CUSTOM_X', label='Delete row', auto_width=true, on_activate=self:callback('onDeleteEntry'), }, widgets.HotkeyLabel{ - frame={t=3, l=60}, + frame={t=3, l=54}, key='CUSTOM_R', label='Set row targets to 0', auto_width=true, on_activate=self:callback('zeroOut'), }, widgets.HotkeyLabel{ - frame={t=4, l=60}, + frame={t=4, l=54}, key='CUSTOM_SHIFT_R', label='Set row targets to N', auto_width=true, @@ -411,7 +412,7 @@ function WatchList:init() }, widgets.HotkeyLabel{ view_id='butcher_all', - frame={t=5, l=0}, + frame={t=5, l=36}, key='CUSTOM_E', label='Butcher all', auto_width=true, @@ -419,7 +420,7 @@ function WatchList:init() }, widgets.HotkeyLabel{ view_id='unbutcher_all', - frame={t=5, l=16}, + frame={t=5, l=54}, key='CUSTOM_SHIFT_E', label='Unbutcher all', auto_width=true, @@ -439,7 +440,7 @@ function WatchList:init() }, widgets.ToggleHotkeyLabel{ view_id='autowatch_toggle', - frame={t=6, l=43, w=24}, + frame={t=6, l=36, w=24}, label='Autowatch is', key='CUSTOM_SHIFT_W', options={{value=true, label='Enabled', pen=COLOR_GREEN}, @@ -531,13 +532,6 @@ function WatchList:refresh(sort_widget, sort_fn) local settings = plugin.autobutcher_getSettings() - self.subviews.disabled_warning.visible = not plugin.isEnabled() - - if not plugin.isEnabled() then - self.subviews.list:setChoices(choices) - return - end - -- first two rows are for "edit all races" and "edit new races" table.insert(choices, { text=make_row_text('!! ALL RACES PLUS NEW', settings), From 3598c5d44b61e7e84118ba6c4cd3d0f2580a469c Mon Sep 17 00:00:00 2001 From: Atte Haarni Date: Thu, 25 Apr 2024 19:06:45 +0300 Subject: [PATCH 8/8] Update changelog.txt --- changelog.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/changelog.txt b/changelog.txt index 03fe29a54a..23b21a155f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,17 +33,11 @@ Template for new versions: ## Fixes ## Misc Improvements - -## Removed - -# 50.13-r2 - -## New Features - `gui/autobutcher`: add functionality to butcher and unbutcher all animals - -## Misc Improvements - `gui/autobutcher`: add warning if autobutcher is disabled +## Removed + # 50.13-r1.1 ## Fixes