From aee4fcd1a6fd708f706e03bee01d4287e0d656f9 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 20 Jun 2020 12:02:13 -0400 Subject: [PATCH] Add confirmation for convicting dwarves of crimes Closes #1593 --- docs/changelog.txt | 3 +++ plugins/confirm.cpp | 2 ++ plugins/lua/confirm.lua | 15 +++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 90492cdfc..c165ff855 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -44,6 +44,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `labormanager`: fixed handling of new jobs in 0.47 - Fixed ``Units::isEggLayer``, ``Units::isGrazer``, ``Units::isMilkable``, ``Units::isTrainableHunting``, ``Units::isTrainableWar``, and ``Units::isTamable`` ignoring the unit's caste +## Misc Improvements +- `confirm`: added a confirmation dialog for convicting dwarves of crimes + ## Ruby - Updated ``item_find`` and ``building_find`` to use centralized logic that works on more screens diff --git a/plugins/confirm.cpp b/plugins/confirm.cpp index c616ac493..07aee4640 100644 --- a/plugins/confirm.cpp +++ b/plugins/confirm.cpp @@ -18,6 +18,7 @@ #include "df/general_ref.h" #include "df/general_ref_contained_in_itemst.h" #include "df/viewscreen_dwarfmodest.h" +#include "df/viewscreen_justicest.h" #include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_locationsst.h" #include "df/viewscreen_tradegoodsst.h" @@ -479,6 +480,7 @@ DEFINE_CONFIRMATION(uniform_delete, viewscreen_layer_militaryst); DEFINE_CONFIRMATION(note_delete, viewscreen_dwarfmodest); DEFINE_CONFIRMATION(route_delete, viewscreen_dwarfmodest); DEFINE_CONFIRMATION(location_retire, viewscreen_locationsst); +DEFINE_CONFIRMATION(convict, viewscreen_justicest); DFhackCExport command_result plugin_init (color_ostream &out, vector &commands) { diff --git a/plugins/lua/confirm.lua b/plugins/lua/confirm.lua index 4312ab4be..b8a815662 100644 --- a/plugins/lua/confirm.lua +++ b/plugins/lua/confirm.lua @@ -204,6 +204,21 @@ end location_retire.title = "Retire location" location_retire.message = "Are you sure you want to retire this location?" +convict = defconf('convict') +convict.title = "Confirm conviction" +function convict.intercept_key(key) + return key == keys.SELECT and + screen.cur_column == df.viewscreen_justicest.T_cur_column.ConvictChoices +end +function convict.get_message() + name = dfhack.TranslateName(screen.convict_choices[screen.cursor_right].name) + if name == "" then + name = "this creature" + end + return "Are you sure you want to convict " .. name .. "?\n" .. + "This action is irreversible." +end + -- End of confirmation definitions function check()