diff --git a/changelog.txt b/changelog.txt index 4e53f12d9b..15df963806 100644 --- a/changelog.txt +++ b/changelog.txt @@ -40,6 +40,7 @@ Template for new versions: - `hide-tutorials`: if enabled, also hide tutorial popups for adventure mode - `hide-tutorials`: new ``reset`` command that will re-enable popups in the current game - `gui/notify`: moody dwarf notification turns red when they can't find workshop or items +- `gui/confirm`: in the delete manager order confirmation dialog, show a description of which order you have selected to delete ## Removed diff --git a/internal/confirm/specs.lua b/internal/confirm/specs.lua index 67628222aa..056dd84172 100644 --- a/internal/confirm/specs.lua +++ b/internal/confirm/specs.lua @@ -432,10 +432,60 @@ ConfirmSpec{ end, } +local function make_order_desc(order, noun) + local desc = '' + if order.mat_type >= 0 then + local matinfo = dfhack.matinfo.decode(order.mat_type, order.mat_index) + if matinfo then + desc = desc .. ' ' .. matinfo:toString() + end + else + for k,v in pairs(order.material_category) do + if v then + desc = desc .. ' ' .. k + break + end + end + end + return desc .. ' ' .. noun +end + +local orders = df.global.world.manager_orders.all +local itemdefs = df.global.world.raws.itemdefs +local reactions = df.global.world.raws.reactions.reactions ConfirmSpec{ id='order-remove', title='Remove manger order', - message='Are you sure you want to remove this manager order?', + message=function() + local order_desc = '' + local scroll_pos = mi.info.work_orders.scroll_position_work_orders + local y_offset = dfhack.screen.getWindowSize() > 154 and 8 or 10 + local _, y = dfhack.screen.getMousePos() + if y then + local order_idx = scroll_pos + (y - y_offset) // 3 + local order = orders[order_idx] + if order.job_type == df.job_type.CustomReaction then + for _, reaction in ipairs(reactions) do + if reaction.code == order.reaction_name then + order_desc = reaction.name + end + end + elseif order.job_type == df.job_type.MakeArmor then + order_desc = make_order_desc(order, itemdefs.armor[order.item_subtype].name) + elseif order.job_type == df.job_type.MakeWeapon then + order_desc = make_order_desc(order, itemdefs.weapons[order.item_subtype].name) + elseif order.job_type == df.job_type.MakePants then + order_desc = make_order_desc(order, itemdefs.pants[order.item_subtype].name) + elseif order.job_type == df.job_type.SmeltOre then + order_desc = make_order_desc(order, 'ore') + elseif order.job_type == df.job_type.MakeTool then + order_desc = make_order_desc(order, itemdefs.tools[order.item_subtype].name) + else + order_desc = make_order_desc(order, df.job_type.attrs[order.job_type].caption) + end + end + return ('Are you sure you want to remove this manager order?\n\n%s'):format(dfhack.capitalizeStringWords(order_desc)) + end, intercept_keys='_MOUSE_L', context='dwarfmode/Info/WORK_ORDERS/Default', predicate=function() return mi.current_hover == df.main_hover_instruction.WORK_ORDERS_REMOVE end,