From dc2a14c0c2d05ba1be2bc823312a0c875dfe523a Mon Sep 17 00:00:00 2001 From: Quietust Date: Tue, 26 Apr 2022 20:52:24 -0600 Subject: [PATCH] Add "partial-items" tweak. When active, the displayed names of partially-consumed items (e.g. hospital cloth) will display a percentage indicator at the end. Also re-sort a few Tweaks so they're in alphabetical order again. --- docs/Plugins.rst | 1 + docs/changelog.txt | 3 +++ plugins/tweak/tweak.cpp | 24 ++++++++++++++++++++---- plugins/tweak/tweaks/partial-items.h | 23 +++++++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 plugins/tweak/tweaks/partial-items.h diff --git a/docs/Plugins.rst b/docs/Plugins.rst index b068e3c95..3b42bc16a 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -159,6 +159,7 @@ Subcommands that persist until disabled or DF quits: i.e. stop the rightmost list of the Positions page of the military screen from constantly resetting to the top. :nestbox-color: Fixes the color of built nestboxes +:partial-items: Displays percentages on partially-consumed items such as hospital cloth :reaction-gloves: Fixes reactions to produce gloves in sets with correct handedness (:bug:`6273`) :shift-8-scroll: Gives Shift-8 (or :kbd:`*`) priority when scrolling menus, instead of scrolling the map :stable-cursor: Saves the exact cursor position between t/q/k/d/b/etc menus of fortress mode, if the diff --git a/docs/changelog.txt b/docs/changelog.txt index 1a3bf64b4..05fe533ba 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,6 +38,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Removed +## New Tweaks +- `tweak` partial-items: displays percentages on partially-consumed items such as hospital cloth + ## Fixes - `autofarm` removed restriction on only planting 'discovered' plants - `luasocket` (and others): return correct status code when closing socket connections diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 1ea958f5b..38ece6970 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -49,11 +49,14 @@ #include "df/item_glovesst.h" #include "df/item_shoesst.h" #include "df/item_pantsst.h" +#include "df/item_drinkst.h" +#include "df/item_globst.h" #include "df/item_liquid_miscst.h" #include "df/item_powder_miscst.h" #include "df/item_barst.h" #include "df/item_threadst.h" #include "df/item_clothst.h" +#include "df/item_sheetst.h" #include "df/spatter.h" #include "df/layer_object.h" #include "df/reaction.h" @@ -68,6 +71,7 @@ #include "df/job.h" #include "df/general_ref_building_holderst.h" #include "df/unit_health_info.h" +#include "df/caste_body_info.h" #include "df/activity_entry.h" #include "df/activity_event_combat_trainingst.h" #include "df/activity_event_individual_skill_drillst.h" @@ -101,14 +105,15 @@ #include "tweaks/kitchen-prefs-empty.h" #include "tweaks/max-wheelbarrow.h" #include "tweaks/military-assign.h" -#include "tweaks/pausing-fps-counter.h" #include "tweaks/nestbox-color.h" +#include "tweaks/partial-items.h" +#include "tweaks/pausing-fps-counter.h" +#include "tweaks/reaction-gloves.h" #include "tweaks/shift-8-scroll.h" #include "tweaks/stable-cursor.h" #include "tweaks/stone-status-all.h" #include "tweaks/title-start-rename.h" #include "tweaks/tradereq-pet-gender.h" -#include "tweaks/reaction-gloves.h" using std::set; using std::vector; @@ -244,6 +249,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector append(stl_sprintf(" (%i%%)", std::max(1, dimension * 100 / DIM))); \ + } \ +}; \ +IMPLEMENT_VMETHOD_INTERPOSE(partial_items_hook_##TYPE, getItemDescription); + +DEFINE_PARTIAL_ITEM_TWEAK(bar, 150) +DEFINE_PARTIAL_ITEM_TWEAK(drink, 150) +DEFINE_PARTIAL_ITEM_TWEAK(glob, 150) +DEFINE_PARTIAL_ITEM_TWEAK(liquid_misc, 150) +DEFINE_PARTIAL_ITEM_TWEAK(powder_misc, 150) +DEFINE_PARTIAL_ITEM_TWEAK(cloth, 10000) +DEFINE_PARTIAL_ITEM_TWEAK(sheet, 10000) +DEFINE_PARTIAL_ITEM_TWEAK(thread, 15000)