Add do-job-now tweak

Forum thread: http://www.bay12forums.com/smf/index.php?topic=176700
Original source: https://github.com/dlmarquis/dfhack/blob/dojobnow-r1/plugins/dojobnow.cpp

Co-authored-by: dlmarquis <dlmarquis@users.noreply.github.com>
develop
lethosor 2020-08-06 22:30:29 -04:00
parent bdb9433822
commit 0c53b2b6c5
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
5 changed files with 52 additions and 0 deletions

@ -110,6 +110,7 @@ Nikolay Amiantov abbradar
nocico nocico
Omniclasm
OwnageIsMagic OwnageIsMagic
palenerd dlmarquis
Patrik Lundell PatrikLundell
Paul Fenwick pjf
PeridexisErrant PeridexisErrant

@ -305,6 +305,7 @@ Subcommands that persist until disabled or DF quits:
:craft-age-wear: Fixes the behavior of crafted items wearing out over time (:bug:`6003`).
With this tweak, items made from cloth and leather will gain a level of
wear every 20 years.
:do-job-now: Adds a job priority toggle to the jobs list
:embark-profile-name: Allows the use of lowercase letters when saving embark profiles
:eggs-fertile: Displays a fertility indicator on nestboxes
:farm-plot-select: Adds "Select all" and "Deselect all" options to farm plot menus

@ -34,6 +34,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future
## New Tweaks
- `tweak` do-job-now: adds a job priority toggle to the jobs list
- `tweak` reaction-gloves: adds an option to make reactions produce gloves in sets with correct handedness
## Fixes

@ -86,6 +86,7 @@
#include "tweaks/civ-agreement-ui.h"
#include "tweaks/condition-material.h"
#include "tweaks/craft-age-wear.h"
#include "tweaks/do-job-now.h"
#include "tweaks/eggs-fertile.h"
#include "tweaks/embark-profile-name.h"
#include "tweaks/farm-plot-select.h"
@ -200,6 +201,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Fixes a crash in the work order contition material list (bug 9905).\n"
" tweak craft-age-wear [disable]\n"
" Makes cloth and leather items wear out at the correct rate (bug 6003).\n"
" tweak do-job-now [disable]\n"
" Adds a job priority toggle to the jobs list.\n"
" tweak embark-profile-name [disable]\n"
" Allows the use of lowercase letters when saving embark profiles\n"
" tweak eggs-fertile [disable]\n"
@ -280,6 +283,9 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
TWEAK_HOOK("craft-age-wear", craft_age_wear_hook, ageItem);
TWEAK_HOOK("do-job-now", do_job_now_hook, feed);
TWEAK_HOOK("do-job-now", do_job_now_hook, render);
TWEAK_HOOK("eggs-fertile", egg_fertile_hook, render);
TWEAK_HOOK("embark-profile-name", embark_profile_name_hook, feed);

@ -0,0 +1,43 @@
#include "df/viewscreen_joblistst.h"
struct do_job_now_hook : public df::viewscreen_joblistst {
typedef df::viewscreen_joblistst interpose_base;
bool handleInput(std::set<df::interface_key> *input) {
if (input->count(interface_key::CUSTOM_N)) {
df::job *job = vector_get(jobs, cursor_pos);
if (job) {
job->flags.bits.do_now = !job->flags.bits.do_now;
}
return true;
}
return false;
}
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input)) {
if (!handleInput(input)) {
INTERPOSE_NEXT(feed)(input);
}
}
DEFINE_VMETHOD_INTERPOSE(void, render, ()) {
INTERPOSE_NEXT(render)();
int x = 32;
auto dim = Screen::getWindowSize();
int y = dim.y - 2;
bool do_now = false;
df::job *job = vector_get(jobs, cursor_pos);
if (job) {
do_now = job->flags.bits.do_now;
}
OutputHotkeyString(x, y, (!do_now ? "Do job now!" : "Normal priority"),
interface_key::CUSTOM_N, false, x, COLOR_WHITE, COLOR_LIGHTRED);
}
};
IMPLEMENT_VMETHOD_INTERPOSE(do_job_now_hook, feed);
IMPLEMENT_VMETHOD_INTERPOSE(do_job_now_hook, render);