From abe027c940ec3efcea7955d45708d2c7e8916295 Mon Sep 17 00:00:00 2001
From: Anuradha Dissanayake
Date: Fri, 30 Nov 2012 22:44:05 +1300
Subject: [PATCH 01/22] Copy changes from ag fork
---
plugins/search.cpp | 154 +++++++++++++++++++++++++++++++++++----------
1 file changed, 120 insertions(+), 34 deletions(-)
diff --git a/plugins/search.cpp b/plugins/search.cpp
index fdc788955..a14397fba 100644
--- a/plugins/search.cpp
+++ b/plugins/search.cpp
@@ -10,6 +10,7 @@
#include "df/viewscreen_tradegoodsst.h"
#include "df/viewscreen_unitlistst.h"
#include "df/interface_key.h"
+#include "df/interfacest.h"
using std::set;
using std::vector;
@@ -19,6 +20,7 @@ using namespace DFHack;
using namespace df::enums;
using df::global::gps;
+using df::global::gview;
/*
Search Plugin
@@ -39,6 +41,14 @@ void OutputString(int8_t color, int &x, int y, const std::string &text)
x += text.length();
}
+static bool is_live_screen(const df::viewscreen *screen)
+{
+ for (df::viewscreen *cur = &gview->view; cur; cur = cur->child)
+ if (cur == screen)
+ return true;
+ return false;
+}
+
//
// START: Base Search functionality
//
@@ -60,6 +70,15 @@ public:
track_secondary_values = false;
}
+ bool reset_on_change()
+ {
+ if (valid && is_live_screen(viewscreen))
+ return false;
+
+ reset_all();
+ return true;
+ }
+
// A new keystroke is received in a searchable screen
virtual bool process_input(set *input)
{
@@ -206,12 +225,12 @@ protected:
bool list_has_been_sorted = (sort_list1->size() == reference_list.size()
&& *sort_list1 != reference_list);
- for (int i = 0; i < saved_indexes.size(); i++)
+ for (size_t i = 0; i < saved_indexes.size(); i++)
{
int adjusted_item_index = i;
if (list_has_been_sorted)
{
- for (int j = 0; j < sort_list1->size(); j++)
+ for (size_t j = 0; j < sort_list1->size(); j++)
{
if ((*sort_list1)[j] == reference_list[i])
{
@@ -245,6 +264,9 @@ protected:
update_secondary_values();
*sort_list2 = saved_list2;
}
+
+ saved_list1.clear();
+ saved_list2.clear();
}
store_reference_values();
search_string = "";
@@ -278,7 +300,7 @@ protected:
}
string search_string_l = toLower(search_string);
- for (int i = 0; i < saved_list1.size(); i++ )
+ for (size_t i = 0; i < saved_list1.size(); i++ )
{
T element = saved_list1[i];
string desc = toLower(get_element_description(element));
@@ -307,8 +329,9 @@ protected:
// Display hotkey message
void print_search_option(int x, int y = -1) const
{
+ auto dim = Screen::getWindowSize();
if (y == -1)
- y = gps->dimy - 2;
+ y = dim.y - 2;
OutputString((entry_mode) ? 4 : 12, x, y, string(1, select_key));
OutputString((entry_mode) ? 10 : 15, x, y, ": Search");
@@ -346,7 +369,12 @@ struct search_hook : T
DEFINE_VMETHOD_INTERPOSE(void, feed, (set *input))
{
- module.init(this);
+ if (!module.init(this))
+ {
+ INTERPOSE_NEXT(feed)(input);
+ return;
+ }
+
if (!module.process_input(input))
{
INTERPOSE_NEXT(feed)(input);
@@ -357,9 +385,10 @@ struct search_hook : T
DEFINE_VMETHOD_INTERPOSE(void, render, ())
{
- module.init(this);
+ bool ok = module.init(this);
INTERPOSE_NEXT(render)();
- module.render();
+ if (ok)
+ module.render();
}
};
@@ -382,11 +411,12 @@ public:
virtual void render() const
{
if (!viewscreen->in_group_mode)
- print_search_option(1);
+ print_search_option(2);
else
{
- int x = 1;
- OutputString(15, x, gps->dimy - 2, "Tab to enable Search");
+ auto dim = Screen::getWindowSize();
+ int x = 2, y = dim.y - 2;
+ OutputString(15, x, y, "Tab to enable Search");
}
}
@@ -402,13 +432,18 @@ public:
search_parent::do_post_update_check();
}
- virtual void init(df::viewscreen_storesst *screen)
+ bool init(df::viewscreen_storesst *screen)
{
+ if (screen != viewscreen && !reset_on_change())
+ return false;
+
if (!valid)
{
viewscreen = screen;
search_parent::init(&screen->item_cursor, &screen->items);
}
+
+ return true;
}
@@ -440,8 +475,8 @@ private:
typedef search_hook stocks_search_hook;
-IMPLEMENT_VMETHOD_INTERPOSE(stocks_search_hook, feed);
-IMPLEMENT_VMETHOD_INTERPOSE(stocks_search_hook, render);
+template<> IMPLEMENT_VMETHOD_INTERPOSE(stocks_search_hook, feed);
+template<> IMPLEMENT_VMETHOD_INTERPOSE(stocks_search_hook, render);
//
// END: Stocks screen search
@@ -461,28 +496,33 @@ public:
print_search_option(28);
}
- virtual void init(df::viewscreen_unitlistst *screen)
+ bool init(df::viewscreen_unitlistst *screen)
{
+ if (screen != viewscreen && !reset_on_change())
+ return false;
+
if (!valid)
{
viewscreen = screen;
search_parent::init(&screen->cursor_pos[viewscreen->page], &screen->units[viewscreen->page], &screen->jobs[viewscreen->page]);
}
+
+ return true;
}
private:
virtual string get_element_description(df::unit *element) const
{
string desc = Translation::TranslateName(Units::getVisibleName(element), false);
- if (viewscreen->page == 1)
- desc += Units::getProfessionName(element); // Check animal type too
+ desc += ", " + Units::getProfessionName(element); // Check animal type too
return desc;
}
virtual bool should_check_input(set *input)
{
- if (input->count(interface_key::CURSOR_LEFT) || input->count(interface_key::CURSOR_RIGHT) || input->count(interface_key::CUSTOM_L))
+ if (input->count(interface_key::CURSOR_LEFT) || input->count(interface_key::CURSOR_RIGHT) ||
+ (!is_entry_mode() && input->count(interface_key::UNITVIEW_PRF_PROF)))
{
if (!is_entry_mode())
{
@@ -502,8 +542,8 @@ private:
};
typedef search_hook unitlist_search_hook;
-IMPLEMENT_VMETHOD_INTERPOSE_PRIO(unitlist_search_hook, feed, 100);
-IMPLEMENT_VMETHOD_INTERPOSE_PRIO(unitlist_search_hook, render, 100);
+template<> IMPLEMENT_VMETHOD_INTERPOSE_PRIO(unitlist_search_hook, feed, 100);
+template<> IMPLEMENT_VMETHOD_INTERPOSE_PRIO(unitlist_search_hook, render, 100);
//
// END: Unit screen search
@@ -529,6 +569,29 @@ private:
{
return Items::getDescription(element, 0, true);
}
+
+ virtual bool should_check_input(set *input)
+ {
+ if (is_entry_mode())
+ return true;
+
+ if (input->count(interface_key::TRADE_TRADE) ||
+ input->count(interface_key::TRADE_OFFER) ||
+ input->count(interface_key::TRADE_SEIZE))
+ {
+ // Block the keys if were searching
+ if (!search_string.empty())
+ input->clear();
+
+ // Trying to trade, reset search
+ clear_search();
+ reset_all();
+
+ return false;
+ }
+
+ return true;
+ }
};
@@ -540,20 +603,25 @@ public:
print_search_option(2, 26);
}
- virtual void init(df::viewscreen_tradegoodsst *screen)
+ bool init(df::viewscreen_tradegoodsst *screen)
{
+ if (screen != viewscreen && !reset_on_change())
+ return false;
+
if (!valid)
{
viewscreen = screen;
search_parent::init(&screen->trader_cursor, &screen->trader_items, &screen->trader_selected, 'q');
track_secondary_values = true;
}
+
+ return true;
}
};
typedef search_hook trade_search_merc_hook;
-IMPLEMENT_VMETHOD_INTERPOSE(trade_search_merc_hook, feed);
-IMPLEMENT_VMETHOD_INTERPOSE(trade_search_merc_hook, render);
+template<> IMPLEMENT_VMETHOD_INTERPOSE(trade_search_merc_hook, feed);
+template<> IMPLEMENT_VMETHOD_INTERPOSE(trade_search_merc_hook, render);
class trade_search_fort : public trade_search_base
@@ -564,20 +632,25 @@ public:
print_search_option(42, 26);
}
- virtual void init(df::viewscreen_tradegoodsst *screen)
+ bool init(df::viewscreen_tradegoodsst *screen)
{
+ if (screen != viewscreen && !reset_on_change())
+ return false;
+
if (!valid)
{
viewscreen = screen;
search_parent::init(&screen->broker_cursor, &screen->broker_items, &screen->broker_selected, 'w');
track_secondary_values = true;
}
+
+ return true;
}
};
typedef search_hook trade_search_fort_hook;
-IMPLEMENT_VMETHOD_INTERPOSE(trade_search_fort_hook, feed);
-IMPLEMENT_VMETHOD_INTERPOSE(trade_search_fort_hook, render);
+template<> IMPLEMENT_VMETHOD_INTERPOSE(trade_search_fort_hook, feed);
+template<> IMPLEMENT_VMETHOD_INTERPOSE(trade_search_fort_hook, render);
//
// END: Trade screen search
@@ -589,10 +662,15 @@ DFHACK_PLUGIN("search");
DFhackCExport command_result plugin_init ( color_ostream &out, vector &commands)
{
- if (!gps || !INTERPOSE_HOOK(unitlist_search_hook, feed).apply() || !INTERPOSE_HOOK(unitlist_search_hook, render).apply()
- || !INTERPOSE_HOOK(trade_search_merc_hook, feed).apply() || !INTERPOSE_HOOK(trade_search_merc_hook, render).apply()
- || !INTERPOSE_HOOK(trade_search_fort_hook, feed).apply() || !INTERPOSE_HOOK(trade_search_fort_hook, render).apply()
- || !INTERPOSE_HOOK(stocks_search_hook, feed).apply() || !INTERPOSE_HOOK(stocks_search_hook, render).apply())
+ if (!gps || !gview ||
+ !INTERPOSE_HOOK(unitlist_search_hook, feed).apply() ||
+ !INTERPOSE_HOOK(unitlist_search_hook, render).apply() ||
+ !INTERPOSE_HOOK(trade_search_merc_hook, feed).apply() ||
+ !INTERPOSE_HOOK(trade_search_merc_hook, render).apply() ||
+ !INTERPOSE_HOOK(trade_search_fort_hook, feed).apply() ||
+ !INTERPOSE_HOOK(trade_search_fort_hook, render).apply() ||
+ !INTERPOSE_HOOK(stocks_search_hook, feed).apply() ||
+ !INTERPOSE_HOOK(stocks_search_hook, render).apply())
out.printerr("Could not insert Search hooks!\n");
return CR_OK;
@@ -613,9 +691,17 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
DFhackCExport command_result plugin_onstatechange ( color_ostream &out, state_change_event event )
{
- unitlist_search_hook::module.reset_all();
- trade_search_merc_hook::module.reset_all();
- trade_search_fort_hook::module.reset_all();
- stocks_search_hook::module.reset_all();
+ switch (event) {
+ case SC_VIEWSCREEN_CHANGED:
+ unitlist_search_hook::module.reset_on_change();
+ trade_search_merc_hook::module.reset_on_change();
+ trade_search_fort_hook::module.reset_on_change();
+ stocks_search_hook::module.reset_on_change();
+ break;
+
+ default:
+ break;
+ }
+
return CR_OK;
-}
\ No newline at end of file
+}
From 210c1650ecb19a9407779b37ff334f28dca859a7 Mon Sep 17 00:00:00 2001
From: Anuradha Dissanayake
Date: Sat, 1 Dec 2012 01:01:04 +1300
Subject: [PATCH 02/22] Add stockpile screen searching capability
---
plugins/search.cpp | 122 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 109 insertions(+), 13 deletions(-)
diff --git a/plugins/search.cpp b/plugins/search.cpp
index a14397fba..cf1798dcf 100644
--- a/plugins/search.cpp
+++ b/plugins/search.cpp
@@ -7,10 +7,12 @@
//#include "df/viewscreen_petst.h"
#include "df/viewscreen_storesst.h"
+#include "df/viewscreen_layer_stockpilest.h"
#include "df/viewscreen_tradegoodsst.h"
#include "df/viewscreen_unitlistst.h"
#include "df/interface_key.h"
#include "df/interfacest.h"
+#include "df/layer_object_listst.h"
using std::set;
using std::vector;
@@ -79,6 +81,11 @@ public:
return true;
}
+ bool is_valid()
+ {
+ return valid;
+ }
+
// A new keystroke is received in a searchable screen
virtual bool process_input(set *input)
{
@@ -164,9 +171,9 @@ protected:
const S *viewscreen;
vector saved_list1, reference_list;
vector saved_list2;
+ vector *sort_list2;
vector saved_indexes;
- bool valid;
bool redo_search;
bool track_secondary_values;
string search_string;
@@ -240,12 +247,17 @@ protected:
}
}
- saved_list2[saved_indexes[i]] = (*sort_list2)[adjusted_item_index];
+ update_saved_secondary_list_item(saved_indexes[i], adjusted_item_index);
}
saved_indexes.clear();
}
}
+ virtual void update_saved_secondary_list_item(size_t i, size_t j)
+ {
+ saved_list2[i] = (*sort_list2)[j];
+ }
+
// Store a copy of filtered list, used later to work out if filtered list has been sorted after filtering
void store_reference_values()
{
@@ -254,7 +266,7 @@ protected:
}
// Shortcut to clear the search immediately
- void clear_search()
+ virtual void clear_search()
{
if (saved_list1.size() > 0)
{
@@ -273,7 +285,7 @@ protected:
}
// The actual sort
- void do_search()
+ virtual void do_search()
{
if (search_string.length() == 0)
{
@@ -318,7 +330,8 @@ protected:
store_reference_values(); //Keep a copy, in case user sorts new list
- *cursor_pos = 0;
+ if (cursor_pos)
+ *cursor_pos = 0;
}
virtual bool should_check_input(set *input)
@@ -346,10 +359,9 @@ protected:
private:
vector *sort_list1;
- vector *sort_list2;
int *cursor_pos;
char select_key;
-
+ bool valid;
bool entry_mode;
df::interface_key select_token;
@@ -359,7 +371,8 @@ private:
};
template search_parent *search_parent ::lock = NULL;
-// Parent struct for the hooks
+// Parent struct for the hooks, use optional param D to generate multiple classes with same T & V
+// but different static modules
template
struct search_hook : T
{
@@ -437,7 +450,7 @@ public:
if (screen != viewscreen && !reset_on_change())
return false;
- if (!valid)
+ if (!is_valid())
{
viewscreen = screen;
search_parent::init(&screen->item_cursor, &screen->items);
@@ -501,7 +514,7 @@ public:
if (screen != viewscreen && !reset_on_change())
return false;
- if (!valid)
+ if (!is_valid())
{
viewscreen = screen;
search_parent::init(&screen->cursor_pos[viewscreen->page], &screen->units[viewscreen->page], &screen->jobs[viewscreen->page]);
@@ -608,7 +621,7 @@ public:
if (screen != viewscreen && !reset_on_change())
return false;
- if (!valid)
+ if (!is_valid())
{
viewscreen = screen;
search_parent::init(&screen->trader_cursor, &screen->trader_items, &screen->trader_selected, 'q');
@@ -637,7 +650,7 @@ public:
if (screen != viewscreen && !reset_on_change())
return false;
- if (!valid)
+ if (!is_valid())
{
viewscreen = screen;
search_parent::init(&screen->broker_cursor, &screen->broker_items, &screen->broker_selected, 'w');
@@ -657,6 +670,84 @@ template<> IMPLEMENT_VMETHOD_INTERPOSE(trade_search_fort_hook, render);
//
+//
+// START: Stockpile screen search
+//
+
+class stockpile_search : public search_parent
+{
+public:
+ void update_saved_secondary_list_item(size_t i, size_t j)
+ {
+ *saved_list2[i] = *(*sort_list2)[j];
+ }
+
+ string get_element_description(string *element) const
+ {
+ return *element;
+ }
+
+ void render() const
+ {
+ print_search_option(2, 25);
+ }
+
+ static df::layer_object_listst *getLayerList(const df::viewscreen_layer *layer, int idx)
+ {
+ return virtual_cast(vector_get(layer->layer_objects,idx));
+ }
+
+ bool init(df::viewscreen_layer_stockpilest *screen)
+ {
+ if (screen != viewscreen && !reset_on_change())
+ return false;
+
+ auto list3 = getLayerList(screen, 2);
+ if (!list3->active)
+ {
+ if (is_valid())
+ {
+ clear_search();
+ reset_all();
+ }
+
+ return false;
+ }
+
+ if (!is_valid())
+ {
+ viewscreen = screen;
+ search_parent::init(&list3->cursor, &screen->item_names, &screen->item_status);
+ track_secondary_values = true;
+ }
+
+ return true;
+ }
+
+ void do_search()
+ {
+ search_parent::do_search();
+ auto list3 = getLayerList(viewscreen, 2);
+ list3->num_entries = viewscreen->item_names.size();
+ }
+
+ void clear_search()
+ {
+ search_parent::clear_search();
+ auto list3 = getLayerList(viewscreen, 2);
+ list3->num_entries = viewscreen->item_names.size();
+ }
+};
+
+typedef search_hook stockpile_search_hook;
+template<> IMPLEMENT_VMETHOD_INTERPOSE(stockpile_search_hook, feed);
+template<> IMPLEMENT_VMETHOD_INTERPOSE(stockpile_search_hook, render);
+
+//
+// END: Stockpile screen search
+//
+
+
DFHACK_PLUGIN("search");
@@ -670,7 +761,9 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector
Date: Sat, 1 Dec 2012 16:50:03 +0400
Subject: [PATCH 03/22] Implement the history graph in the workflow status
screen.
---
Lua API.html | 14 +-
Lua API.rst | 2 +
Readme.html | 27 +++-
Readme.rst | 33 ++++-
dfhack.init-example | 1 +
images/workflow-new1.png | Bin 6674 -> 6775 bytes
images/workflow-new2.png | Bin 6862 -> 7793 bytes
images/workflow-status.png | Bin 0 -> 5118 bytes
images/workflow.png | Bin 4931 -> 5779 bytes
library/lua/gui/widgets.lua | 19 ++-
scripts/gui/workflow.lua | 248 ++++++++++++++++++++++++------------
11 files changed, 248 insertions(+), 96 deletions(-)
create mode 100644 images/workflow-status.png
diff --git a/Lua API.html b/Lua API.html
index f42905d01..f14239a10 100644
--- a/Lua API.html
+++ b/Lua API.html
@@ -2787,6 +2787,14 @@ before rendering the token.
token.tile = pen
Specifies a pen to paint as one tile before the main part of the token.
+token.width = ...
+If specified either as a value or a callback, the text field is padded
+or truncated to the specified number.
+
+token.pad_char = '?'
+If specified together with width, the padding area is filled with
+this character instead of just being skipped over.
+
token.key = '...'
Specifies the keycode associated with the token. The string description
of the key binding is added to the text content of the token.
@@ -2848,7 +2856,9 @@ this may be extended with mouse click support.
icon_pen: | Default pen for icons. |
-on_select: | Selection change callback; called as on_select(index,choice). |
+
---|
on_select: | Selection change callback; called as on_select(index,choice).
+This is also called with nil arguments if setChoices is called
+with an empty list. |
on_submit: | Enter key callback; if specified, the list reacts to the key
and calls it as on_submit(index,choice). |
@@ -2928,6 +2938,8 @@ supports:
edit_pen: | If specified, used instead of cursor_pen for the edit field. |
+edit_below: | If true, the edit field is placed below the list instead of above. |
+
not_found_label: |
| Specifies the text of the label shown when no items match the filter. |
diff --git a/Lua API.rst b/Lua API.rst
index 714a41bfb..cedc36441 100644
--- a/Lua API.rst
+++ b/Lua API.rst
@@ -2785,6 +2785,8 @@ It has the following attributes:
:inactive_pen: If specified, used for the cursor when the widget is not active.
:icon_pen: Default pen for icons.
:on_select: Selection change callback; called as ``on_select(index,choice)``.
+ This is also called with *nil* arguments if ``setChoices`` is called
+ with an empty list.
:on_submit: Enter key callback; if specified, the list reacts to the key
and calls it as ``on_submit(index,choice)``.
:on_submit2: Shift-Enter key callback; if specified, the list reacts to the key
diff --git a/Readme.html b/Readme.html
index deea72bef..d75be99f4 100644
--- a/Readme.html
+++ b/Readme.html
@@ -3034,11 +3034,11 @@ current job, and their current status.
current count is below the lower bound of the range, the job is resumed; if it
is above or equal to the top bound, it will be suspended. Within the range, the
specific constraint has no effect on the job; others may still affect it.
-Pressing 'c' switches the current constraint between counting stacks or items.
-Pressing 'm' lets you input the range directly; 'e', 'r', 'd', 'f' adjust the
-bounds by 1, 5, or 25 depending on the direction and the 'c' setting (counting
-items and expanding the range each gives a 5x bonus).
-Pressing 'n' produces a list of possible outputs of this job as guessed by
+
Pressing 'I' switches the current constraint between counting stacks or items.
+Pressing 'R' lets you input the range directly; 'e', 'r', 'd', 'f' adjust the
+bounds by 5, 10, or 20 depending on the direction and the 'I' setting (counting
+items and expanding the range each gives a 2x bonus).
+Pressing 'A' produces a list of possible outputs of this job as guessed by
workflow, and lets you create a new constraint by choosing one as template. If you
don't see the choice you want in the list, it likely means you have to adjust
the job material first using job item-material or gui/workshop-job,
@@ -3050,6 +3050,23 @@ added to the list. If you use Shift-Enter, the interface proceeds to the
next dialog, which allows you to edit the suggested constraint parameters to
suit your need, and set the item count range.
+Pressing 'S' (or, with the example config, Alt-W in the 'z' stocks screen)
+opens the overall status screen, which was copied from the C++ implementation
+by falconne for better integration with the rest of the lua script:
+
+This screen shows all currently existing workflow constraints, and allows
+monitoring and/or changing them from one screen. The constraint list can
+be filtered by typing text in the field below.
+The color of the stock level number indicates how "healthy" the stock level
+is, based on current count and trend. Bright green is very good, green is good,
+red is bad, bright red is very bad.
+The limit number is also color-coded. Red means that there are currently no
+workshops producing that item (i.e. no jobs). If it's yellow, that means the
+production has been delayed, possibly due to lack of input materials.
+The chart on the right is a plot of the last 14 days (28 half day plots) worth
+of stock history for the selected item, with the rightmost point representing
+the current stock value. The bright green dashed line is the target
+limit (maximum) and the dark green line is that minus the gap (minimum).
diff --git a/Readme.rst b/Readme.rst
index a214a6ecb..a84691b05 100644
--- a/Readme.rst
+++ b/Readme.rst
@@ -2295,12 +2295,12 @@ current count is below the lower bound of the range, the job is resumed; if it
is above or equal to the top bound, it will be suspended. Within the range, the
specific constraint has no effect on the job; others may still affect it.
-Pressing 'c' switches the current constraint between counting stacks or items.
-Pressing 'm' lets you input the range directly; 'e', 'r', 'd', 'f' adjust the
-bounds by 1, 5, or 25 depending on the direction and the 'c' setting (counting
-items and expanding the range each gives a 5x bonus).
+Pressing 'I' switches the current constraint between counting stacks or items.
+Pressing 'R' lets you input the range directly; 'e', 'r', 'd', 'f' adjust the
+bounds by 5, 10, or 20 depending on the direction and the 'I' setting (counting
+items and expanding the range each gives a 2x bonus).
-Pressing 'n' produces a list of possible outputs of this job as guessed by
+Pressing 'A' produces a list of possible outputs of this job as guessed by
workflow, and lets you create a new constraint by choosing one as template. If you
don't see the choice you want in the list, it likely means you have to adjust
the job material first using ``job item-material`` or ``gui/workshop-job``,
@@ -2316,6 +2316,29 @@ suit your need, and set the item count range.
.. image:: images/workflow-new2.png
+Pressing 'S' (or, with the example config, Alt-W in the 'z' stocks screen)
+opens the overall status screen, which was copied from the C++ implementation
+by falconne for better integration with the rest of the lua script:
+
+.. image:: images/workflow-status.png
+
+This screen shows all currently existing workflow constraints, and allows
+monitoring and/or changing them from one screen. The constraint list can
+be filtered by typing text in the field below.
+
+The color of the stock level number indicates how "healthy" the stock level
+is, based on current count and trend. Bright green is very good, green is good,
+red is bad, bright red is very bad.
+
+The limit number is also color-coded. Red means that there are currently no
+workshops producing that item (i.e. no jobs). If it's yellow, that means the
+production has been delayed, possibly due to lack of input materials.
+
+The chart on the right is a plot of the last 14 days (28 half day plots) worth
+of stock history for the selected item, with the rightmost point representing
+the current stock value. The bright green dashed line is the target
+limit (maximum) and the dark green line is that minus the gap (minimum).
+
gui/assign-rack
===============
diff --git a/dfhack.init-example b/dfhack.init-example
index 8fafa4cf4..7617b9f6e 100644
--- a/dfhack.init-example
+++ b/dfhack.init-example
@@ -91,6 +91,7 @@ keybinding add Alt-A@dwarfmode/QueryBuilding/Some/Workshop/Job gui/workshop-job
# workflow front-end
keybinding add Alt-W@dwarfmode/QueryBuilding/Some/Workshop/Job gui/workflow
+keybinding add Alt-W@overallstatus "gui/workflow status"
# assign weapon racks to squads so that they can be used
keybinding add P@dwarfmode/QueryBuilding/Some/Weaponrack gui/assign-rack
diff --git a/images/workflow-new1.png b/images/workflow-new1.png
index 50d0e1f421ac9de1abf87545c8d7ade31bd4cd4a..498fc4e80b4eb9736a00429195a9eee6dbd17d14 100644
GIT binary patch
literal 6775
zcmZ`-c{r5O_n!@8A4Jy7*q0$o){3!D*6fWv&B)qfNtQIDkwIz
_F&jhz03bm;WohPib@V5#`Sy4H&z&46F0JN_O@knO
zWxl9IE@s^#N8Pb^52*0xR(QUedYYT2HW5}XIaNoy
zQ(3|c#nABm#QoGCq!Pw0YHXU~TF%}$CB;_z4C|)Ky-(>zz_W_FsH7(qUl$4v&c(Q|
zZmM}$;m2KU*Bat`*5co)t$WvxuRfV*yp|(sdbbRS5$RtV)YDF2h2y2~H0_twnOm)J
zpm?O1jTQS&0RbolYOLvi=op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$-X-&2mc$|GjZOh5%
z&1AUDlGtqaU_&23F7GUnZSH|()N7F0f=fxEz
z5;peTX}C`n)k!JBQPrwzy#F;EqrS|e6laP=WRG$u*|iqB-b0eaWy@Ez#Tjdgc`YEx
zh3|iWKEIKb8p7uu8yh~*pF)d^{YLsju{O$I;>P|2?smgrH42a4k+w4xPr<_atUZ3v
zF;!oKY81*ePGoqzMsp9Gwmuk=+I}n)@hm|65oM7J{)tP!bR_xOzE*ZPJ9^EAcm?-1
zaUq+%w*IN-^<|_3rxK>uZ?yyhvD#-FO;(p$_*%(k{rWd(>2ZPZx|X)HeSrk-cqT%?
z>~c0LotAH>Ow@f)zH{!)y$?iVG_G8~gl94C5+Q}c%O5Pr`@ovscc7Oe{$OFFCN3k&
zKqhQd-U1*e2%h^u;(Y4EzNwpHkEPlszSGU7vd7(+p}
zy+7#eZcrg*1(*t(jdV1KEUsED`bp3v@IpbE?MHxptuZ}|VmW7&`Z==Bw9Sovt?E`=
zzDn$RqB&>_Y}}$z8XSS}
z8^bQp)u`5pRo%S7O>Uk(Bl0Wf_fw>Pt_|d#EsRKh>Hg%!bm6Ua6>e`uHR?y3u)st+
z7t}I(Q&7j0@XR6dFO0@~hu+(x;&&z2*yr+wXweJ+V%7bL8(s920DD|F<2tV3V#$Tj
z;EuD8h3wJF*VASvrM7uc$JB
-
The search plugin adds search to the Stocks, Trading and Unit List screens.
+
The search plugin adds search to the Stocks, Trading, Stockpile and Unit List screens.
Searching works the same way as the search option in "Move to Depot" does.
You will see the Search option displayed on screen with a hotkey (usually 's').
@@ -2890,6 +2890,13 @@ filter).
are actually visible in the list; the same effect applies to the Trade
Value numbers displayed by the screen. Because of this, pressing the 't'
key while search is active clears the search instead of executing the trade.
+
In the stockpile screen the option only appears if the cursor is in the
+rightmost list:
+

+
Note that the 'Permit XXX'/'Forbid XXX' keys conveniently operate only
+on items actually shown in the rightmost list, so it is possible to select
+only fat or tallow by forbidding fats, then searching for fat/tallow, and
+using Permit Fats again while the list is filtered.
diff --git a/Readme.rst b/Readme.rst
index a84691b05..afad3ef4c 100644
--- a/Readme.rst
+++ b/Readme.rst
@@ -2074,7 +2074,7 @@ directly to the main dwarf mode screen.
Search
======
-The search plugin adds search to the Stocks, Trading and Unit List screens.
+The search plugin adds search to the Stocks, Trading, Stockpile and Unit List screens.
.. image:: images/search.png
@@ -2097,6 +2097,16 @@ are actually visible in the list; the same effect applies to the Trade
Value numbers displayed by the screen. Because of this, pressing the 't'
key while search is active clears the search instead of executing the trade.
+In the stockpile screen the option only appears if the cursor is in the
+rightmost list:
+
+.. image:: images/search-stockpile.png
+
+Note that the 'Permit XXX'/'Forbid XXX' keys conveniently operate only
+on items actually shown in the rightmost list, so it is possible to select
+only fat or tallow by forbidding fats, then searching for fat/tallow, and
+using Permit Fats again while the list is filtered.
+
AutoMaterial
============
diff --git a/images/search-stockpile.png b/images/search-stockpile.png
new file mode 100644
index 0000000000000000000000000000000000000000..37a0e57cd3a74a4f4f7b80d76dcd996cc92da1fa
GIT binary patch
literal 5971
zcmZ`-2{@E*wExB!yD^b9G1g?6P}VGyLH3Ys$`WP
L
z)XoDo%3$zJ>PfUcvF+>tW11N006M+>uH+<02mGc
zAZ1$csl-e>A?mc^F*UN#!Q=4&9^cv7d2(`cDg*EUaPrSXe|e8`%7UB>uWN(Puo&%}
zGK^k&XkP$;=A7Onkl*j9Z~)-)(bv9a@#xEjo#FjottEP6>KEazzlasisSAvPC1X}i_c(utSevO(H3GnR%DK*?B^qSr
zAF5AN6!$E7d3LrN+_~fvE(sqLV}69X(X=a*b>m>4DuhIMg;O91uYjPiAo8QuHV1^~
zPwp+YYx6!$w)5((hZ}7)eH-3Ewp9%atIe1?>V@OHv2H=yMON^RVkPxl>pytUdBN%k
zBfRY$E|_)4j3K^JMI!Vv{HF+9fc}jT@E0W2H$~ew6~szd+Y9vFJY$p+*4VtZA*X(Q
zBO|uEX{+YobN0!4w|CiZDNt4`Ei91}2%tZKfwpZPb(n(}R|OnxKEqJOFpcg@t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~!k-=3^l~RJ(!A5O0*b3Qunu>aLr-mWdD3AdybKuaP%4rL9->o8wAMDoLt6#
z;*y!|0QXUT@o1coPIR0(NH1<|U}ki4_sCvn31727q$W}QyT5#nkFJA+6vy+PpJd{o
zS9on3qilEG<&BgmouTEjhZzIePM19!VpB?jp+%Eksgz;I#JaQnFL&ln{vHXcWM&ra
z_sAkh?s^sPdb^?%uZYqtOf1&15LnSc8bp?TT%&Pbw`}om@WODG6}~a7)Qyi-yYYDY
zy*aWTim+WkRmWhAT+pa`)zL0TBmq*SL3`nz0*FL44AxWDaEQ~YG`B{+NGo{PoC>D>
z!29_wk)RpI9+^TPm9lAU#6`cDRWrjv;EH67Fq|TE6!{yv1@r$>PAaloC`m~5OaBX=TeiFC%d9$MD`S$0y`{X95s6Ho8)$0DnzGK%*~Kz
zVVn@{e-`OKiIE;tq{Ug-Y4R=um;65$Ir9YER#Bqee0Khy^J=jNIyMh5jt{V^&OX@F
z3XqqTlb1OyvT_!3N~*HTs
Date: Sun, 2 Dec 2012 14:43:23 +0400
Subject: [PATCH 05/22] Detect mouse press events for lua.
---
Lua API.html | 5 ++++-
Lua API.rst | 5 ++++-
library/lua/gui.lua | 2 ++
library/modules/Screen.cpp | 14 ++++++++++++--
4 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/Lua API.html b/Lua API.html
index f14239a10..aa41b8b63 100644
--- a/Lua API.html
+++ b/Lua API.html
@@ -1749,7 +1749,10 @@ options; if multiple interpretations exist, the table will contain multiple keys
Maps to an integer in range 0-255. Duplicates a separate "STRING_A???" code for convenience.
_MOUSE_L, _MOUSE_R
-If the left or right mouse button is pressed.
+If the left or right mouse button is being pressed.
+
+_MOUSE_L_DOWN, _MOUSE_R_DOWN
+If the left or right mouse button was just pressed.
If this method is omitted, the screen is dismissed on receival of the LEAVESCREEN key.
diff --git a/Lua API.rst b/Lua API.rst
index cedc36441..eaef74997 100644
--- a/Lua API.rst
+++ b/Lua API.rst
@@ -1610,7 +1610,10 @@ Supported callbacks and fields are:
Maps to an integer in range 0-255. Duplicates a separate "STRING_A???" code for convenience.
``_MOUSE_L, _MOUSE_R``
- If the left or right mouse button is pressed.
+ If the left or right mouse button is being pressed.
+
+ ``_MOUSE_L_DOWN, _MOUSE_R_DOWN``
+ If the left or right mouse button was just pressed.
If this method is omitted, the screen is dismissed on receival of the ``LEAVESCREEN`` key.
diff --git a/library/lua/gui.lua b/library/lua/gui.lua
index 99bf9263c..603c7ab44 100644
--- a/library/lua/gui.lua
+++ b/library/lua/gui.lua
@@ -13,6 +13,8 @@ CLEAR_PEN = to_pen{ch=32,fg=0,bg=0}
local FAKE_INPUT_KEYS = {
_MOUSE_L = true,
_MOUSE_R = true,
+ _MOUSE_L_DOWN = true,
+ _MOUSE_R_DOWN = true,
_STRING = true,
}
diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp
index cd20bc25e..782bb317d 100644
--- a/library/modules/Screen.cpp
+++ b/library/modules/Screen.cpp
@@ -664,14 +664,24 @@ int dfhack_lua_viewscreen::do_input(lua_State *L)
if (enabler && enabler->tracking_on)
{
- if (enabler->mouse_lbut) {
+ if (enabler->mouse_lbut_down) {
lua_pushboolean(L, true);
lua_setfield(L, -2, "_MOUSE_L");
}
- if (enabler->mouse_rbut) {
+ if (enabler->mouse_rbut_down) {
lua_pushboolean(L, true);
lua_setfield(L, -2, "_MOUSE_R");
}
+ if (enabler->mouse_lbut) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "_MOUSE_L_DOWN");
+ enabler->mouse_lbut = 0;
+ }
+ if (enabler->mouse_rbut) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "_MOUSE_R_DOWN");
+ enabler->mouse_rbut = 0;
+ }
}
lua_call(L, 2, 0);
From dc7f9f56cd9d9ac6ebda4b59027841458ecbf82c Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov
Date: Sun, 2 Dec 2012 15:31:43 +0400
Subject: [PATCH 06/22] Implement a low stock level announcement as suggested
by falconne.
---
NEWS | 1 +
plugins/workflow.cpp | 21 +++++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 4856b06c3..b8ad53830 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ DFHack future
- logic fix: collecting webs produces silk, and ungathered webs are not thread.
- items assigned to squads are considered busy, even if not in inventory.
- shearing and milking jobs are supported, but only with generic MILK or YARN outputs.
+ - workflow announces when the stock level gets very low once a season.
New Fix Armory plugin:
Together with a couple of binary patches and the gui/assign-rack script,
this plugin makes weapon racks, armor stands, chests and cabinets in
diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp
index 12174af5c..b70fd8b0c 100644
--- a/plugins/workflow.cpp
+++ b/plugins/workflow.cpp
@@ -322,6 +322,7 @@ struct ItemConstraint {
bool request_suspend, request_resume;
bool is_active, cant_resume_reported;
+ int low_stock_reported;
TMaterialCache material_cache;
@@ -329,7 +330,7 @@ public:
ItemConstraint()
: is_craft(false), min_quality(item_quality::Ordinary), is_local(false),
weight(0), item_amount(0), item_count(0), item_inuse_amount(0), item_inuse_count(0),
- is_active(false), cant_resume_reported(false)
+ is_active(false), cant_resume_reported(false), low_stock_reported(-1)
{}
int goalCount() { return config.ival(0); }
@@ -349,6 +350,8 @@ public:
config.ival(2) &= ~1;
}
+ int curItemStock() { return goalByCount() ? item_count : item_amount; }
+
void init(const std::string &str)
{
config.val() = str;
@@ -358,7 +361,7 @@ public:
void computeRequest()
{
- int size = goalByCount() ? item_count : item_amount;
+ int size = curItemStock();
request_resume = (size <= goalCount()-goalGap());
request_suspend = (size >= goalCount());
}
@@ -1323,6 +1326,20 @@ static void update_jobs_by_constraints(color_ostream &out)
else if (ct->mat_mask.whole)
info = bitfield_to_string(ct->mat_mask) + " " + info;
+ if (ct->low_stock_reported != DF_GLOBAL_VALUE(cur_season,-1))
+ {
+ int count = ct->goalCount(), gap = ct->goalGap();
+
+ if (count >= gap*3 && ct->curItemStock() < std::min(gap*2, (count-gap)/2))
+ {
+ ct->low_stock_reported = DF_GLOBAL_VALUE(cur_season,-1);
+
+ Gui::showAnnouncement("Stock level is low: " + info, COLOR_BROWN, true);
+ }
+ else
+ ct->low_stock_reported = -1;
+ }
+
if (is_running != ct->is_active)
{
if (is_running && ct->request_resume)
From 3953112eb936e7afddea09413bf6dfcefa795566 Mon Sep 17 00:00:00 2001
From: jj
Date: Mon, 3 Dec 2012 19:03:07 +0100
Subject: [PATCH 07/22] dump Vegetation::t_plant, fix plant.is_burning
---
library/include/modules/Vegetation.h | 22 ----------------------
library/modules/Vegetation.cpp | 25 -------------------------
plugins/plants.cpp | 4 ++--
3 files changed, 2 insertions(+), 49 deletions(-)
diff --git a/library/include/modules/Vegetation.h b/library/include/modules/Vegetation.h
index 89ba5ff6c..f293ec52c 100644
--- a/library/include/modules/Vegetation.h
+++ b/library/include/modules/Vegetation.h
@@ -40,31 +40,9 @@ namespace Vegetation
{
const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3; // 3 years
-// "Simplified" copy of plant
-struct t_plant {
- df::language_name name;
- df::plant_flags flags;
- int16_t material;
- df::coord pos;
- int32_t grow_counter;
- uint16_t temperature_1;
- uint16_t temperature_2;
- int32_t is_burning;
- int32_t hitpoints;
- int16_t update_order;
- //std::vector unk1;
- //int32_t unk2;
- //uint16_t temperature_3;
- //uint16_t temperature_4;
- //uint16_t temperature_5;
- // Pointer to original object, in case you want to modify it
- df::plant *origin;
-};
-
DFHACK_EXPORT bool isValid();
DFHACK_EXPORT uint32_t getCount();
DFHACK_EXPORT df::plant * getPlant(const int32_t index);
-DFHACK_EXPORT bool copyPlant (const int32_t index, t_plant &out);
}
}
#endif
diff --git a/library/modules/Vegetation.cpp b/library/modules/Vegetation.cpp
index f7c4c9b0c..9b14a3cc0 100644
--- a/library/modules/Vegetation.cpp
+++ b/library/modules/Vegetation.cpp
@@ -58,28 +58,3 @@ df::plant * Vegetation::getPlant(const int32_t index)
return NULL;
return world->plants.all[index];
}
-
-bool Vegetation::copyPlant(const int32_t index, t_plant &out)
-{
- if (uint32_t(index) >= getCount())
- return false;
-
- out.origin = world->plants.all[index];
-
- out.name = out.origin->name;
- out.flags = out.origin->flags;
- out.material = out.origin->material;
- out.pos = out.origin->pos;
- out.grow_counter = out.origin->grow_counter;
- out.temperature_1 = out.origin->temperature.whole;
- out.temperature_2 = out.origin->temperature.fraction;
- out.is_burning = out.origin->is_burning;
- out.hitpoints = out.origin->hitpoints;
- out.update_order = out.origin->update_order;
- //out.unk1 = out.origin->anon_1;
- //out.unk2 = out.origin->anon_2;
- //out.temperature_3 = out.origin->temperature_unk;
- //out.temperature_4 = out.origin->min_safe_temp;
- //out.temperature_5 = out.origin->max_safe_temp;
- return true;
-}
diff --git a/plugins/plants.cpp b/plugins/plants.cpp
index 5ab09868f..22e60c0d0 100644
--- a/plugins/plants.cpp
+++ b/plugins/plants.cpp
@@ -113,7 +113,7 @@ static command_result immolations (color_ostream &out, do_what what, bool shrubs
if(shrubs && p->flags.bits.is_shrub || trees && !p->flags.bits.is_shrub)
{
if (what == do_immolate)
- p->is_burning = true;
+ p->damage_flags.bits.is_burning = true;
p->hitpoints = 0;
destroyed ++;
}
@@ -136,7 +136,7 @@ static command_result immolations (color_ostream &out, do_what what, bool shrubs
if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z)
{
if(what == do_immolate)
- tree->is_burning = true;
+ tree->damage_flags.bits.is_burning = true;
tree->hitpoints = 0;
didit = true;
break;
From 0b80dff09d0c0dbb6dacd469249e738e1cf25978 Mon Sep 17 00:00:00 2001
From: jj
Date: Tue, 4 Dec 2012 17:18:09 +0100
Subject: [PATCH 08/22] ruby: add d-float support
---
plugins/ruby/codegen.pl | 3 +++
plugins/ruby/ruby-autogen-defs.rb | 16 ++++++++++++++++
plugins/ruby/ruby.cpp | 13 +++++++++++++
3 files changed, 32 insertions(+)
diff --git a/plugins/ruby/codegen.pl b/plugins/ruby/codegen.pl
index ff69853af..9d76c6872 100755
--- a/plugins/ruby/codegen.pl
+++ b/plugins/ruby/codegen.pl
@@ -849,6 +849,9 @@ sub render_item_number {
} elsif ($subtype eq 's-float') {
push @lines_rb, 'float';
return;
+ } elsif ($subtype eq 'd-float') {
+ push @lines_rb, 'double';
+ return;
} else {
print "no render number $subtype\n";
return;
diff --git a/plugins/ruby/ruby-autogen-defs.rb b/plugins/ruby/ruby-autogen-defs.rb
index a3e810178..e657962d5 100644
--- a/plugins/ruby/ruby-autogen-defs.rb
+++ b/plugins/ruby/ruby-autogen-defs.rb
@@ -35,6 +35,9 @@ module DFHack
def float
Float.new
end
+ def double
+ Double.new
+ end
def bit(shift, enum=nil)
BitField.new(shift, 1, enum)
end
@@ -237,6 +240,19 @@ module DFHack
_set(0.0)
end
end
+ class Double < MemStruct
+ def _get
+ DFHack.memory_read_double(@_memaddr)
+ end
+
+ def _set(v)
+ DFHack.memory_write_double(@_memaddr, v)
+ end
+
+ def _cpp_init
+ _set(0.0)
+ end
+ end
class BitField < MemStruct
attr_accessor :_shift, :_len, :_enum
def initialize(shift, len, enum=nil)
diff --git a/plugins/ruby/ruby.cpp b/plugins/ruby/ruby.cpp
index db94ad650..d75fa2402 100644
--- a/plugins/ruby/ruby.cpp
+++ b/plugins/ruby/ruby.cpp
@@ -578,6 +578,11 @@ static VALUE rb_dfmemory_read_float(VALUE self, VALUE addr)
return rb_float_new(*(float*)rb_num2ulong(addr));
}
+static VALUE rb_dfmemory_read_double(VALUE self, VALUE addr)
+{
+ return rb_float_new(*(double*)rb_num2ulong(addr));
+}
+
// memory writing (buffer)
static VALUE rb_dfmemory_write(VALUE self, VALUE addr, VALUE raw)
@@ -613,6 +618,12 @@ static VALUE rb_dfmemory_write_float(VALUE self, VALUE addr, VALUE val)
return Qtrue;
}
+static VALUE rb_dfmemory_write_double(VALUE self, VALUE addr, VALUE val)
+{
+ *(double*)rb_num2ulong(addr) = rb_num2dbl(val);
+ return Qtrue;
+}
+
// return memory permissions at address (eg "rx", nil if unmapped)
static VALUE rb_dfmemory_check(VALUE self, VALUE addr)
{
@@ -968,12 +979,14 @@ static void ruby_bind_dfhack(void) {
rb_define_singleton_method(rb_cDFHack, "memory_read_int16", RUBY_METHOD_FUNC(rb_dfmemory_read_int16), 1);
rb_define_singleton_method(rb_cDFHack, "memory_read_int32", RUBY_METHOD_FUNC(rb_dfmemory_read_int32), 1);
rb_define_singleton_method(rb_cDFHack, "memory_read_float", RUBY_METHOD_FUNC(rb_dfmemory_read_float), 1);
+ rb_define_singleton_method(rb_cDFHack, "memory_read_double", RUBY_METHOD_FUNC(rb_dfmemory_read_double), 1);
rb_define_singleton_method(rb_cDFHack, "memory_write", RUBY_METHOD_FUNC(rb_dfmemory_write), 2);
rb_define_singleton_method(rb_cDFHack, "memory_write_int8", RUBY_METHOD_FUNC(rb_dfmemory_write_int8), 2);
rb_define_singleton_method(rb_cDFHack, "memory_write_int16", RUBY_METHOD_FUNC(rb_dfmemory_write_int16), 2);
rb_define_singleton_method(rb_cDFHack, "memory_write_int32", RUBY_METHOD_FUNC(rb_dfmemory_write_int32), 2);
rb_define_singleton_method(rb_cDFHack, "memory_write_float", RUBY_METHOD_FUNC(rb_dfmemory_write_float), 2);
+ rb_define_singleton_method(rb_cDFHack, "memory_write_double", RUBY_METHOD_FUNC(rb_dfmemory_write_double), 2);
rb_define_singleton_method(rb_cDFHack, "memory_check", RUBY_METHOD_FUNC(rb_dfmemory_check), 1);
rb_define_singleton_method(rb_cDFHack, "memory_patch", RUBY_METHOD_FUNC(rb_dfmemory_patch), 2);
From 74ebe7d2070a4487f9f47377a1a992254167e298 Mon Sep 17 00:00:00 2001
From: jj
Date: Tue, 4 Dec 2012 17:46:13 +0100
Subject: [PATCH 09/22] ruby: add df-static-flagarray
---
plugins/ruby/codegen.pl | 15 +++++++++--
plugins/ruby/ruby-autogen-defs.rb | 45 +++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/plugins/ruby/codegen.pl b/plugins/ruby/codegen.pl
index 9d76c6872..03017a0f5 100755
--- a/plugins/ruby/codegen.pl
+++ b/plugins/ruby/codegen.pl
@@ -698,6 +698,8 @@ sub sizeof {
return 12;
} elsif ($subtype eq 'df-flagarray') {
return 8;
+ } elsif ($subtype eq 'df-static-flagarray') {
+ return $field->getAttribute('count');
} elsif ($subtype eq 'df-array') {
return 8; # XXX 6 ?
} else {
@@ -913,6 +915,7 @@ sub render_item_container {
my $rbmethod = join('_', split('-', $subtype));
my $tg = $item->findnodes('child::ld:item')->[0];
my $indexenum = $item->getAttribute('index-enum');
+ my $count = $item->getAttribute('count');
if ($tg)
{
if ($rbmethod eq 'df_linked_list') {
@@ -929,11 +932,19 @@ sub render_item_container {
elsif ($indexenum)
{
$indexenum = rb_ucase($indexenum);
- push @lines_rb, "$rbmethod($indexenum)";
+ if ($count) {
+ push @lines_rb, "$rbmethod($count, $indexenum)";
+ } else {
+ push @lines_rb, "$rbmethod($indexenum)";
+ }
}
else
{
- push @lines_rb, "$rbmethod";
+ if ($count) {
+ push @lines_rb, "$rbmethod($count)";
+ } else {
+ push @lines_rb, "$rbmethod";
+ }
}
}
diff --git a/plugins/ruby/ruby-autogen-defs.rb b/plugins/ruby/ruby-autogen-defs.rb
index e657962d5..ffd68bf1e 100644
--- a/plugins/ruby/ruby-autogen-defs.rb
+++ b/plugins/ruby/ruby-autogen-defs.rb
@@ -78,6 +78,9 @@ module DFHack
def df_flagarray(indexenum=nil)
DfFlagarray.new(indexenum)
end
+ def df_static_flagarray(len, indexenum=nil)
+ DfStaticFlagarray.new(len, indexenum)
+ end
def df_array(tglen)
DfArray.new(tglen, yield)
end
@@ -680,6 +683,48 @@ module DFHack
include Enumerable
end
+ class DfStaticFlagarray < MemStruct
+ attr_accessor :_indexenum
+ def initialize(len, indexenum)
+ @len = len*8
+ @_indexenum = indexenum
+ end
+ def length
+ @len
+ end
+ def size ; length ; end
+ def [](idx)
+ idx = _indexenum.int(idx) if _indexenum
+ idx += length if idx < 0
+ return if idx < 0 or idx >= length
+ byte = DFHack.memory_read_int8(@_memaddr + idx/8)
+ (byte & (1 << (idx%8))) > 0
+ end
+ def []=(idx, v)
+ idx = _indexenum.int(idx) if _indexenum
+ idx += length if idx < 0
+ if idx >= length or idx < 0
+ raise 'index out of bounds'
+ else
+ byte = DFHack.memory_read_int8(@_memaddr + idx/8)
+ if (v == nil or v == false or v == 0)
+ byte &= 0xff ^ (1 << (idx%8))
+ else
+ byte |= (1 << (idx%8))
+ end
+ DFHack.memory_write_int8(@_memaddr + idx/8, byte)
+ end
+ end
+ def inspect
+ out = "#'
+ end
+
+ include Enumerable
+ end
class DfArray < Compound
attr_accessor :_tglen, :_tg
def initialize(tglen, tg)
From cd6eb9edd38cf919ba07b158a56656731494a6e7 Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov
Date: Thu, 6 Dec 2012 12:00:18 +0400
Subject: [PATCH 10/22] If training ammo is forbidden for all use, don't move
it to combat chests.
---
plugins/fix-armory.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/plugins/fix-armory.cpp b/plugins/fix-armory.cpp
index efa9350ff..5a4821b4b 100644
--- a/plugins/fix-armory.cpp
+++ b/plugins/fix-armory.cpp
@@ -110,7 +110,8 @@ DFhackCExport command_result plugin_shutdown (color_ostream &out)
* 1. Combat ammo and ammo without any allowed use can be stored
* in BOXes marked for Squad Equipment, either directly or via
* containing room. No-allowed-use ammo is assumed to be reserved
- * for emergency combat use, or something like that.
+ * for emergency combat use, or something like that; however if
+ * it is already stored in a training chest, it won't be moved.
* 1a. If assigned to a squad position, that box can be used _only_
* for ammo assigned to that specific _squad_. Otherwise, if
* multiple squads can use this room, they will store their
@@ -158,8 +159,8 @@ static bool is_squad_ammo(df::item *item, df::squad *squad, bool combat, bool tr
bool cs = spec->flags.bits.use_combat;
bool ts = spec->flags.bits.use_training;
- // no-use ammo assumed to be combat
- if (((cs || !ts) && combat) || (ts && train))
+ // no-use ammo assumed to fit any category
+ if (((cs || !ts) && combat) || ((ts || !cs) && train))
{
if (binsearch_index(spec->assigned, item->id) >= 0)
return true;
From e1b70d171cacc74a58bbf94b0f1febe8b8cdc85d Mon Sep 17 00:00:00 2001
From: jj
Date: Thu, 6 Dec 2012 11:00:19 +0100
Subject: [PATCH 11/22] ruby: tweak is_citizen test
---
plugins/ruby/unit.rb | 52 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 47 insertions(+), 5 deletions(-)
diff --git a/plugins/ruby/unit.rb b/plugins/ruby/unit.rb
index 4c638b1a9..13c3711b0 100644
--- a/plugins/ruby/unit.rb
+++ b/plugins/ruby/unit.rb
@@ -63,12 +63,54 @@ module DFHack
}
end
+ def unit_testflagcurse(u, flag)
+ return false if u.curse.rem_tags1.send(flag)
+ return true if u.curse.add_tags1.send(flag)
+ return false if u.caste < 0
+ u.race_tg.caste[u.caste].flags[flag]
+ end
+
+ def unit_isfortmember(u)
+ # RE from viewscreen_unitlistst ctor
+ return false if df.gamemode != :DWARF or
+ u.mood == :Berserk or
+ unit_testflagcurse(u, :CRAZED) or
+ unit_testflagcurse(u, :OPPOSED_TO_LIFE) or
+ u.unknown8.unk2 or
+ u.flags3.ghostly or
+ u.flags1.marauder or u.flags1.active_invader or u.flags1.invader_origin or
+ u.flags1.forest or
+ u.flags1.merchant or u.flags1.diplomat
+ return true if u.flags1.tame
+ return false if u.flags2.underworld or u.flags2.resident or
+ u.flags2.visitor_uninvited or u.flags2.visitor or
+ u.civ_id == -1 or
+ u.civ_id != df.ui.civ_id
+ true
+ end
+
+ # return the page in viewscreen_unitlist where the unit would appear
+ def unit_category(u)
+ return if u.flags1.left or u.flags1.incoming
+ # return if hostile & unit_invisible(u) (hidden_in_ambush or caged+mapblock.hidden or caged+holder.ambush
+ return :Dead if u.flags1.dead
+ return :Dead if u.flags3.ghostly # hostile ?
+ return :Others if !unit_isfortmember(u)
+ casteflags = u.race_tg.caste[u.caste].flags if u.caste >= 0
+ return :Livestock if casteflags and (casteflags[:PET] or casteflags[:PET_EXOTIC])
+ return :Citizens if unit_testflagcurse(u, :CAN_SPEAK)
+ :Livestock
+ # some other stuff with ui.race_id ? (jobs only?)
+ end
+
def unit_iscitizen(u)
- u.race == ui.race_id and u.civ_id == ui.civ_id and !u.flags1.dead and !u.flags1.merchant and !u.flags1.forest and
- !u.flags1.diplomat and !u.flags2.resident and !u.flags3.ghostly and
- !u.curse.add_tags1.OPPOSED_TO_LIFE and !u.curse.add_tags1.CRAZED and
- u.mood != :Berserk
- # TODO check curse ; currently this should keep vampires, but may include werebeasts
+ unit_category(u) == :Citizens
+ end
+
+ def unit_ishostile(u)
+ unit_category(u) == :Others and
+ # TODO
+ true
end
# list workers (citizen, not crazy / child / inmood / noble)
From 9a6eff0370b623f36ae4e4d5f428dc9bbbe20fe0 Mon Sep 17 00:00:00 2001
From: jj
Date: Thu, 6 Dec 2012 13:00:33 +0100
Subject: [PATCH 12/22] deathcause: allow selection from unitlist screen
---
NEWS | 1 +
scripts/deathcause.rb | 31 +++++++++++++++++++------------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/NEWS b/NEWS
index b8ad53830..9cb34fcb8 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ DFHack future
- removebadthoughts: add --dry-run option
- superdwarf: work in adventure mode too
- tweak stable-cursor: carries cursor location from/to Build menu.
+ - deathcause: allow selection from the unitlist screen
New tweaks:
- tweak military-training: speed up melee squad training up to 10x (normally 3-5x).
New scripts:
diff --git a/scripts/deathcause.rb b/scripts/deathcause.rb
index ab3e44a39..b85a85ac2 100644
--- a/scripts/deathcause.rb
+++ b/scripts/deathcause.rb
@@ -11,33 +11,40 @@ def display_death_event(e)
end
item = df.item_find(:selected)
+unit = df.unit_find(:selected)
if !item or !item.kind_of?(DFHack::ItemBodyComponent)
item = df.world.items.other[:ANY_CORPSE].find { |i| df.at_cursor?(i) }
end
-if !item or !item.kind_of?(DFHack::ItemBodyComponent)
- puts "Please select a corpse in the loo'k' menu"
-else
+if item and item.kind_of?(DFHack::ItemBodyComponent)
hf = item.hist_figure_id
- if hf == -1
- # TODO try to retrieve info from the unit (u = item.unit_tg)
- puts "Not a historical figure, cannot death find info"
+elsif unit
+ hf = unit.hist_figure_id
+end
+
+if not hf
+ puts "Please select a corpse in the loo'k' menu, or an unit in the 'u'nitlist screen"
+
+elsif hf == -1
+ # TODO try to retrieve info from the unit (u = item.unit_tg)
+ puts "Not a historical figure, cannot death find info"
+
+else
+ histfig = df.world.history.figures.binsearch(hf)
+ unit = histfig ? df.unit_find(histfig.unit_id) : nil
+ if unit and not unit.flags1.dead
+ puts "#{unit.name} is not dead yet !"
+
else
events = df.world.history.events
- found = false
(0...events.length).reverse_each { |i|
e = events[i]
if e.kind_of?(DFHack::HistoryEventHistFigureDiedst) and e.victim_hf == hf
display_death_event(e)
- found = true
break
end
}
- if not found
- u = item.unit_tg
- puts "#{u.name} is not dead yet !" if u and not u.flags1.dead
- end
end
end
From 126c31684ec70e149436b3799326cd8aab5891fe Mon Sep 17 00:00:00 2001
From: jj
Date: Thu, 6 Dec 2012 13:43:58 +0100
Subject: [PATCH 13/22] deathcause: ghosts are dead
---
scripts/deathcause.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/deathcause.rb b/scripts/deathcause.rb
index b85a85ac2..73e29c890 100644
--- a/scripts/deathcause.rb
+++ b/scripts/deathcause.rb
@@ -33,7 +33,7 @@ elsif hf == -1
else
histfig = df.world.history.figures.binsearch(hf)
unit = histfig ? df.unit_find(histfig.unit_id) : nil
- if unit and not unit.flags1.dead
+ if unit and not unit.flags1.dead and not unit.flags3.ghostly
puts "#{unit.name} is not dead yet !"
else
From 885059c887c0da9b8d56b7e5fadc7740f505873f Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov
Date: Thu, 6 Dec 2012 19:00:48 +0400
Subject: [PATCH 14/22] Add a script to expose the correct season to soundsense
on world load.
---
NEWS | 1 +
dfhack.init-example | 7 +++++++
scripts/soundsense-season.lua | 26 ++++++++++++++++++++++++++
3 files changed, 34 insertions(+)
create mode 100644 scripts/soundsense-season.lua
diff --git a/NEWS b/NEWS
index 9cb34fcb8..a0e01dba1 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,7 @@ DFHack future
- embark: lets you embark anywhere.
- lever: list and pull fort levers from the dfhack console.
- stripcaged: mark items inside cages for dumping, eg caged goblin weapons.
+ - soundsense-season: writes the correct season to gamelog.txt on world load.
New GUI scripts:
- gui/guide-path: displays the cached path for minecart Guide orders.
- gui/workshop-job: displays inputs of a workshop job and allows tweaking them.
diff --git a/dfhack.init-example b/dfhack.init-example
index 7617b9f6e..1a5aee48f 100644
--- a/dfhack.init-example
+++ b/dfhack.init-example
@@ -137,6 +137,13 @@ tweak military-color-assigned
# remove inverse dependency of squad training speed on unit list size and use more sparring
tweak military-training
+###########
+# Scripts #
+###########
+
+# write the correct season to gamelog on world load
+soundsense-season
+
#######################################################
# Apply binary patches at runtime #
# #
diff --git a/scripts/soundsense-season.lua b/scripts/soundsense-season.lua
new file mode 100644
index 000000000..6b7d43cfa
--- /dev/null
+++ b/scripts/soundsense-season.lua
@@ -0,0 +1,26 @@
+-- On map load writes the current season to gamelog.txt
+
+local seasons = {
+ [0] = 'Spring',
+ [1] = 'Summer',
+ [2] = 'Autumn',
+ [3] = 'Winter',
+}
+
+local args = {...}
+
+local function write_gamelog(msg)
+ local log = io.open('gamelog.txt', 'a')
+ log:write(msg.."\n")
+ log:close()
+end
+
+if args[1] == 'disable' then
+ dfhack.onStateChange[_ENV] = nil
+else
+ dfhack.onStateChange[_ENV] = function(op)
+ if op == SC_WORLD_LOADED then
+ write_gamelog(seasons[df.global.cur_season]..' has arrived on the calendar.')
+ end
+ end
+end
From ebc2625d970eb0ff6ec871ba9b3301a7004f00c5 Mon Sep 17 00:00:00 2001
From: jj
Date: Thu, 6 Dec 2012 23:46:59 +0100
Subject: [PATCH 15/22] ditch the unused Vegetation module
---
library/CMakeLists.txt | 2 -
library/include/DFHack.h | 1 -
library/include/ModuleFactory.h | 1 -
library/include/modules/Maps.h | 1 -
library/include/modules/Vegetation.h | 48 ----------------------
library/modules/Maps.cpp | 1 +
library/modules/Vegetation.cpp | 60 ----------------------------
plugins/cleaners.cpp | 1 +
plugins/devel/tiles.cpp | 1 -
plugins/getplants.cpp | 2 +-
plugins/liquids.cpp | 1 -
plugins/mapexport/mapexport.cpp | 1 +
plugins/plants.cpp | 8 ++--
plugins/prospector.cpp | 1 +
plugins/tiletypes.cpp | 1 -
15 files changed, 10 insertions(+), 120 deletions(-)
delete mode 100644 library/include/modules/Vegetation.h
delete mode 100644 library/modules/Vegetation.cpp
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index f67b6fe44..784b54c90 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -121,7 +121,6 @@ include/modules/Materials.h
include/modules/Notes.h
include/modules/Screen.h
include/modules/Translation.h
-include/modules/Vegetation.h
include/modules/Vermin.h
include/modules/World.h
include/modules/Graphic.h
@@ -142,7 +141,6 @@ modules/Materials.cpp
modules/Notes.cpp
modules/Screen.cpp
modules/Translation.cpp
-modules/Vegetation.cpp
modules/Vermin.cpp
modules/World.cpp
modules/Graphic.cpp
diff --git a/library/include/DFHack.h b/library/include/DFHack.h
index d606df94b..8a094cf86 100644
--- a/library/include/DFHack.h
+++ b/library/include/DFHack.h
@@ -61,7 +61,6 @@ distribution.
#include "modules/Translation.h"
#include "modules/World.h"
#include "modules/Items.h"
-#include "modules/Vegetation.h"
#include "modules/Maps.h"
#include "modules/Gui.h"
diff --git a/library/include/ModuleFactory.h b/library/include/ModuleFactory.h
index 1f3d4222a..87c9a726f 100644
--- a/library/include/ModuleFactory.h
+++ b/library/include/ModuleFactory.h
@@ -33,7 +33,6 @@ namespace DFHack
Module* createGui();
Module* createWorld();
Module* createMaterials();
- Module* createVegetation();
Module* createNotes();
Module* createGraphic();
}
diff --git a/library/include/modules/Maps.h b/library/include/modules/Maps.h
index 632e8ec13..82f79e94b 100644
--- a/library/include/modules/Maps.h
+++ b/library/include/modules/Maps.h
@@ -32,7 +32,6 @@ distribution.
#include "Export.h"
#include "Module.h"
-#include "modules/Vegetation.h"
#include
#include "BitArray.h"
#include "modules/Materials.h"
diff --git a/library/include/modules/Vegetation.h b/library/include/modules/Vegetation.h
deleted file mode 100644
index f293ec52c..000000000
--- a/library/include/modules/Vegetation.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-https://github.com/peterix/dfhack
-Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#pragma once
-#ifndef CL_MOD_VEGETATION
-#define CL_MOD_VEGETATION
-/**
- * \defgroup grp_vegetation Vegetation : stuff that grows and gets cut down or trampled by dwarves
- * @ingroup grp_modules
- */
-
-#include "Export.h"
-#include "DataDefs.h"
-#include "df/plant.h"
-
-namespace DFHack
-{
-namespace Vegetation
-{
-const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3; // 3 years
-
-DFHACK_EXPORT bool isValid();
-DFHACK_EXPORT uint32_t getCount();
-DFHACK_EXPORT df::plant * getPlant(const int32_t index);
-}
-}
-#endif
diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp
index 363de8064..38f8bfb9f 100644
--- a/library/modules/Maps.cpp
+++ b/library/modules/Maps.cpp
@@ -59,6 +59,7 @@ using namespace std;
#include "df/z_level_flags.h"
#include "df/region_map_entry.h"
#include "df/flow_info.h"
+#include "df/plant.h"
using namespace DFHack;
using namespace df::enums;
diff --git a/library/modules/Vegetation.cpp b/library/modules/Vegetation.cpp
deleted file mode 100644
index 9b14a3cc0..000000000
--- a/library/modules/Vegetation.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-https://github.com/peterix/dfhack
-Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-
-#include "Internal.h"
-
-#include
-#include
-#include