Merge branch 'develop' into ea_refactoring

develop
bseiller 2021-02-01 23:36:04 +01:00
commit 56335977ab
12 changed files with 161 additions and 86 deletions

@ -184,9 +184,9 @@ if(NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhack
endif()
# set up versioning.
set(DF_VERSION "0.47.04")
set(DFHACK_RELEASE "r4")
set(DFHACK_PRERELEASE FALSE)
set(DF_VERSION "0.47.05")
set(DFHACK_RELEASE "alpha0")
set(DFHACK_PRERELEASE TRUE)
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")

@ -104,7 +104,7 @@ plants: {foodprefix}b{Right}{Down 4}p^
booze: {foodprefix}b{Right}{Down 5}p{Down}p^
seeds: {foodprefix}b{Right}{Down 9}p^
dye: {foodprefix}b{Right}{Down 11}{Right}{Down 28}{togglesequence 4}^
tallow: {foodprefix}b{Right}{Down 13}{Right}{Down}{togglesequence2 811}^
tallow: {foodprefix}b{Right}{Down 13}{Right}stallow&p^
miscliquid: {foodprefix}b{Right}{Down 18}p^
forbidpreparedfood: {foodprefix}u^
@ -113,7 +113,7 @@ forbidplants: {foodprefix}{Right}{Down 4}f^
forbidbooze: {foodprefix}{Right}{Down 5}f{Down}f^
forbidseeds: {foodprefix}{Right}{Down 9}f^
forbiddye: {foodprefix}{Right}{Down 11}{Right}{Down 28}{togglesequence 4}^
forbidtallow: {foodprefix}{Right}{Down 13}{Right}{Down}{togglesequence2 811}^
forbidtallow: {foodprefix}{Right}{Down 13}{Right}stallow&f^
forbidmiscliquid: {foodprefix}{Right}{Down 18}f^
permitpreparedfood: {forbidpreparedfood}
@ -122,7 +122,7 @@ permitplants: {foodprefix}{Right}{Down 4}p^
permitbooze: {foodprefix}{Right}{Down 5}p{Down}p^
permitseeds: {foodprefix}{Right}{Down 9}p^
permitdye: {forbiddye}
permittallow: {forbidtallow}
permittallow: {foodprefix}{Right}{Down 13}{Right}stallow&p^
permitmiscliquid: {foodprefix}{Right}{Down 18}p^
# the next two aliases are for compatibility with previous implementations of
@ -312,7 +312,12 @@ finishedgoodsprefix: {enter_sp_config}{Down 10}
enablefinishedgoods: {finishedgoodsprefix}e^
disablefinishedgoods: {finishedgoodsprefix}d^
jugs: {finishedgoodsprefix}{Right}f{Right}{Up 2}&{Left}{Down 2}f{Down}f{Down}f^
crafts: {finishedgoodsprefix}{Right}f{Right}{Down 9}{togglesequence 9}^
jugs: {finishedgoodsprefix}{Right}f{Right}{Up 2}&{Left}{Down 2}f{Down}f{Down}f^
forbidcrafts: {finishedgoodsprefix}{Right 2}{Down 9}{togglesequence 9}^
permitcrafts: {forbidcrafts}
##################################
@ -338,9 +343,10 @@ enableweapons: {weaponsprefix}e^
disableweapons: {weaponsprefix}d^
metalweapons: {forbidtrapcomponents}{forbidstoneweapons}{forbidotherweapons}
ironweapons: {metalweapons}{forbidweapons}{permitironweapons}
copperweapons: {metalweapons}{forbidweapons}{permitcopperweapons}
steelweapons: {metalweapons}{forbidweapons}{permitsteelweapons}
ironweapons: {metalweapons}{forbidmetalweapons}{permitironweapons}
bronzeweapons: {metalweapons}{forbidmetalweapons}{permitbronzeweapons}
copperweapons: {metalweapons}{forbidmetalweapons}{permitcopperweapons}
steelweapons: {metalweapons}{forbidmetalweapons}{permitsteelweapons}
forbidweapons: {weaponsprefix}{Right}f^
forbidtrapcomponents: {weaponsprefix}{Right}{Down}f^
@ -348,6 +354,7 @@ forbidmetalweapons: {weaponsprefix}{Right}{Down 2}f^
forbidstoneweapons: {weaponsprefix}{Right}{Down 3}f^
forbidotherweapons: {weaponsprefix}{Right}{Down 4}f^
forbidironweapons: {weaponsprefix}{Right}{Down 2}{Right}&^
forbidbronzeweapons: {weaponsprefix}{Right}{Down 2}{Right}{Down 6}&^
forbidcopperweapons: {weaponsprefix}{Right}{Down 2}{Right}{Down 3}&^
forbidsteelweapons: {weaponsprefix}{Right}{Down 2}{Right}{Down 8}&^
@ -357,6 +364,7 @@ permitmetalweapons: {weaponsprefix}{Right}{Down 2}p^
permitstoneweapons: {weaponsprefix}{Right}{Down 3}p^
permitotherweapons: {weaponsprefix}{Right}{Down 4}p^
permitironweapons: {forbidironweapons}
permitbronzeweapons: {forbidbronzeweapons}
permitcopperweapons: {forbidcopperweapons}
permitsteelweapons: {forbidsteelweapons}
@ -381,18 +389,21 @@ disablearmor: {armorprefix}d^
metalarmor: {forbidotherarmor}
otherarmor: {forbidmetalarmor}
ironarmor: {metalarmor}{forbidmetalarmor}{permitironarmor}
bronzearmor: {metalarmor}{forbidmetalarmor}{permitbronzearmor}
copperarmor: {metalarmor}{forbidmetalarmor}{permitcopperarmor}
steelarmor: {metalarmor}{forbidmetalarmor}{permitsteelarmor}
forbidmetalarmor: {armorprefix}{Right}{Down 6}f^
forbidotherarmor: {armorprefix}{Right}{Down 7}f^
forbidironarmor: {armorprefix}{Right}{Down 6}{Right}&^
forbidbronzearmor: {armorprefix}{Right}{Down 6}{Right}{Down 6}&^
forbidcopperarmor: {armorprefix}{Right}{Down 6}{Right}{Down 3}&^
forbidsteelarmor: {armorprefix}{Right}{Down 6}{Right}{Down 8}&^
permitmetalarmor: {armorprefix}{Right}{Down 6}p^
permitotherarmor: {armorprefix}{Right}{Down 7}p^
permitironarmor: {forbidironarmor}
permitbronzearmor: {forbidbronzearmor}
permitcopperarmor: {forbidcopperarmor}
permitsteelarmor: {forbidsteelarmor}

@ -10,6 +10,7 @@ or make a pull request!
Name Github Other
======================= ======================= ===========================
8Z 8Z
Abel abstern
acwatkins acwatkins
Alexander Gavrilov angavrilov ag
Amostubal Amostubal
@ -158,6 +159,7 @@ simon
Simon Jackson sizeak
stolencatkarma
Stoyan Gaydarov sgayda2
Su Moth-Tolias
suokko suokko shrieker
sv-esk sv-esk
Tachytaenius wolfboyft

@ -33,18 +33,27 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future
# 0.47.04-r5
## Fixes
- `embark-assistant`: fixed order of factors when calculating min temperature
- `embark-assistant`: improved performance of surveying
- `quickfort`: creating zones no longer causes eventual crashes
- `quickfort`: fixed eventual crashes when creating zones
- `quickfort`: fixed library aliases for tallow and iron, copper, and steel weapons
- `seedwatch`: fixed an issue where the plugin would disable itself on map load
- `search`: fixed crash when searching the ``k`` sidebar and navigating to another tile with certain keys, like ``<`` or ``>``
- `stockflow`: fixed ``j`` character being intercepted when naming stockpiles
- `stockpiles`: no longer outputs hotkey help text beneath `stockflow` hotkey help text
## Misc Improvements
- `buildingplan`: set global settings from the ``DFHack#`` prompt: e.g. ``buildingplan set boulders false``
- `buildingplan`: add 'enable all' option for buildingplan (so you don't have to enable all building types individually). this setting is not persisted (just like quickfort_mode is not persisted), but it can be set from onMapLoad.init
- `buildingplan`: modified ``Planning Mode`` status in the UI to show whether we're in quickfort mode, enable all mode, or whether just the building type is enabled.
- `quickfort`: Dreamfort blueprint set improvements: add a streamlined checklist for all required dreamfort commands and give names to stockpiles, levers, bridges, and zones
- Lua label widgets (used in all standard message boxes) are now scrollable with Up/Down/PgUp/PgDn keys
- `autofarm`: now fallows farms if all plants have reached the desired count
- `buildingplan`: added ability to set global settings from the console, e.g. ``buildingplan set boulders false``
- `buildingplan`: added "enable all" option for buildingplan (so you don't have to enable all building types individually). This setting is not persisted (just like quickfort_mode is not persisted), but it can be set from onMapLoad.init
- `buildingplan`: modified ``Planning Mode`` status in the UI to show whether the plugin is in quickfort mode, "enable all" mode, or whether just the building type is enabled.
- `quickfort`: Dreamfort blueprint set improvements: added a streamlined checklist for all required dreamfort commands and gave names to stockpiles, levers, bridges, and zones
- `quickfort`: added aliases for bronze weapons and armor
- `quickfort`: added alias for tradeable crafts
## Lua
- ``dfhack.run_command()``: changed to interface directly with the console when possible, which allows interactive commands and commands that detect the console encoding to work properly

@ -282,14 +282,18 @@ library, discussing their intended usage and detailing sub-aliases that you
can define to customize their behavior.
If you do define your own custom aliases in
``dfhack-config/quickfort/aliases.txt``, try to build on the library aliases.
For example, if you create an alias to modify particular furniture stockpile
settings, start your alias with ``{furnitureprefix}`` instead of
``s{Down 2}``. Using library prefixes will allow sub-aliases to work with your
aliases just like they do with library aliases. In this case, using
``dfhack-config/quickfort/aliases.txt``, try to build on library alias
components. For example, if you create an alias to modify particular furniture
stockpile settings, start your alias with ``{furnitureprefix}`` instead of
``s{Down 2}``. Using library prefixes will allow library sub-aliases to work
with your aliases just like they do with library aliases. In this case, using
``{furnitureprefix}`` will allow your stockpile customization alias to work
with both stockpiles and hauling routes.
Note that some aliases use the DFHack-provided search prompts. If you get errors
while running ``#query`` blueprints, ensure the DFHack `search-plugin` plugin is
enabled.
Naming aliases
~~~~~~~~~~~~~~
@ -760,11 +764,12 @@ cutstone forbidcutstone
Finished goods stockpile adjustments
````````````````````````````````````
+-----------+
| Exclusive |
+===========+
| jugs |
+-----------+
========= ============ ============
Exclusive Forbid Permit
========= ============ ============
jugs
crafts forbidcrafts permitcrafts
========= ============ ============
Cloth stockpile adjustments
```````````````````````````
@ -793,6 +798,7 @@ metalweapons forbidmetalweapons permitmetalweapons
\ forbidstoneweapons permitstoneweapons
\ forbidotherweapons permitotherweapons
ironweapons forbidironweapons permitironweapons
bronzeweapons forbidbronzeweapons permitbronzeweapons
copperweapons forbidcopperweapons permitcopperweapons
steelweapons forbidsteelweapons permitsteelweapons
masterworkweapons forbidmasterworkweapons permitmasterworkweapons
@ -808,6 +814,7 @@ Exclusive Forbid Permit
metalarmor forbidmetalarmor permitmetalarmor
otherarmor forbidotherarmor permitotherarmor
ironarmor forbidironarmor permitironarmor
bronzearmor forbidbronzearmor permitbronzearmor
copperarmor forbidcopperarmor permitcopperarmor
steelarmor forbidsteelarmor permitsteelarmor
masterworkarmor forbidmasterworkarmor permitmasterworkarmor

@ -29,6 +29,20 @@ local function map_opttab(tab,idx)
end
end
STANDARDSCROLL = {
STANDARDSCROLL_UP = -1,
STANDARDSCROLL_DOWN = 1,
STANDARDSCROLL_PAGEUP = '-page',
STANDARDSCROLL_PAGEDOWN = '+page',
}
SECONDSCROLL = {
SECONDSCROLL_UP = -1,
SECONDSCROLL_DOWN = 1,
SECONDSCROLL_PAGEUP = '-page',
SECONDSCROLL_PAGEDOWN = '+page',
}
------------
-- Widget --
------------
@ -234,10 +248,14 @@ end
function render_text(obj,dc,x0,y0,pen,dpen,disabled)
local width = 0
for iline,line in ipairs(obj.text_lines) do
local x = 0
for iline = dc and obj.start_line_num or 1, #obj.text_lines do
local x, line = 0, obj.text_lines[iline]
if dc then
dc:seek(x+x0,y0+iline-1)
local offset = (obj.start_line_num or 1) - 1
local y = y0 + iline - offset - 1
-- skip text outside of the containing frame
if y > dc.height - 1 then break end
dc:seek(x+x0, y)
end
for _,token in ipairs(line) do
token.line = iline
@ -350,9 +368,11 @@ Label.ATTRS{
auto_width = false,
on_click = DEFAULT_NIL,
on_rclick = DEFAULT_NIL,
scroll_keys = STANDARDSCROLL,
}
function Label:init(args)
self.start_line_num = 1
self:setText(args.text)
if not self.text_hpen then
self.text_hpen = ((tonumber(self.text_pen) or tonumber(self.text_pen.fg) or 0) + 8) % 16
@ -399,16 +419,33 @@ function Label:onRenderBody(dc)
render_text(self,dc,0,0,text_pen,self.text_dpen,is_disabled(self))
end
function Label:scroll(nlines)
local n = self.start_line_num + nlines
n = math.min(n, self:getTextHeight() - self.frame_body.height + 1)
n = math.max(n, 1)
self.start_line_num = n
end
function Label:onInput(keys)
if not is_disabled(self) then
if keys._MOUSE_L_DOWN and self:getMousePos() and self.on_click then
self:on_click()
end
if keys._MOUSE_R_DOWN and self:getMousePos() and self.on_rclick then
self:on_rclick()
if is_disabled(self) then return false end
if keys._MOUSE_L_DOWN and self:getMousePos() and self.on_click then
self:on_click()
end
if keys._MOUSE_R_DOWN and self:getMousePos() and self.on_rclick then
self:on_rclick()
end
for k,v in pairs(self.scroll_keys) do
if keys[k] then
if v == '+page' then
v = self.frame_body.height
elseif v == '-page' then
v = -self.frame_body.height
end
self:scroll(v)
return false
end
return check_text_keys(self, keys)
end
return check_text_keys(self, keys)
end
----------
@ -417,20 +454,6 @@ end
List = defclass(List, Widget)
STANDARDSCROLL = {
STANDARDSCROLL_UP = -1,
STANDARDSCROLL_DOWN = 1,
STANDARDSCROLL_PAGEUP = '-page',
STANDARDSCROLL_PAGEDOWN = '+page',
}
SECONDSCROLL = {
SECONDSCROLL_UP = -1,
SECONDSCROLL_DOWN = 1,
SECONDSCROLL_PAGEUP = '-page',
SECONDSCROLL_PAGEDOWN = '+page',
}
List.ATTRS{
text_pen = COLOR_CYAN,
cursor_pen = COLOR_LIGHTCYAN,

@ -1 +1 @@
Subproject commit 4b3b0f0046af33749bf3e5e61f1374c4c461d332
Subproject commit b7222848dbfd4391d8acafc926303bc4f6253d24

@ -197,16 +197,45 @@ public:
}
}
string get_plant_name(int plant_id)
{
df::plant_raw *raw = df::plant_raw::find(plant_id);
if (raw)
return raw->name;
else
return "NONE";
}
void set_farm(color_ostream& out, int new_plant_id, df::building_farmplotst* farm, int season)
{
int old_plant_id = farm->plant_id[season];
if (old_plant_id != new_plant_id)
{
farm->plant_id[season] = new_plant_id;
out << "autofarm: changing farm #" << farm->id <<
" from " << get_plant_name(old_plant_id) <<
" to " << get_plant_name(new_plant_id) << endl;
}
}
void set_farms(color_ostream& out, set<int> plants, vector<df::building_farmplotst*> farms)
{
// this algorithm attempts to change as few farms as possible, while ensuring that
// the number of farms planting each eligible plant is "as equal as possible"
if (farms.empty() || plants.empty())
return; // do nothing if there are no farms or no plantable plants
int season = *df::global::cur_season;
if (farms.empty() || plants.empty())
{
// if no more plants were requested, fallow all farms
// if there were no farms, do nothing
for (auto farm : farms)
{
set_farm(out, -1, farm, season);
}
return;
}
int min = farms.size() / plants.size(); // the number of farms that should plant each eligible plant, rounded down
int extra = farms.size() - min * plants.size(); // the remainder that cannot be evenly divided
@ -236,11 +265,7 @@ public:
{
// pick one of the excess farms and change it to plant this plant
df::building_farmplotst* farm = toChange.front();
int o = farm->plant_id[season];
farm->plant_id[season] = n;
out << "autofarm: changing farm #" << farm->id <<
" from " << ((o == -1) ? "NONE" : world->raws.plants.all[o]->name) <<
" to " << ((n == -1) ? "NONE" : world->raws.plants.all[n]->name) << endl;
set_farm(out, n, farm, season);
toChange.pop();
if (c++ == min)
extra--;

@ -1,4 +1,3 @@
// This does not work with Linux Dwarf Fortress
// With thanks to peterix for DFHack and Quietust for information http://www.bay12forums.com/smf/index.php?topic=91166.msg2605147#msg2605147
#include <map>
@ -101,7 +100,23 @@ string searchAbbreviations(string in)
DFhackCExport command_result plugin_enable(color_ostream &out, bool enable)
{
running = enable;
if(enable == true)
{
if(Core::getInstance().isWorldLoaded())
{
running = true;
out.print("seedwatch supervision started.\n");
} else {
out.printerr(
"This plugin needs a fortress to be loaded and will deactivate automatically otherwise.\n"
"Activate with 'seedwatch start' after you load the game.\n"
);
}
} else {
running = false;
out.print("seedwatch supervision stopped.\n");
}
return CR_OK;
}
@ -143,13 +158,12 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
}
else if(par == "start")
{
running = true;
out.print("seedwatch supervision started.\n");
plugin_enable(out, true);
}
else if(par == "stop")
{
running = false;
out.print("seedwatch supervision stopped.\n");
plugin_enable(out, false);
}
else if(par == "clear")
{
@ -282,15 +296,10 @@ DFhackCExport command_result plugin_init(color_ostream &out, vector<PluginComman
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event)
{
switch (event) {
case SC_MAP_LOADED:
case SC_MAP_UNLOADED:
if (event == SC_MAP_UNLOADED) {
if (running)
out.printerr("seedwatch deactivated due to game load/unload\n");
out.print("seedwatch deactivated due to game unload\n");
running = false;
break;
default:
break;
}
return CR_OK;

@ -212,7 +212,7 @@ public:
auto dims = Gui::getDwarfmodeViewDims();
int left_margin = dims.menu_x1 + 1;
int x = left_margin;
int y = dims.y2 - 3;
int y = dims.y2 - 2; // below autodump, automelt, autotrade, stocks, stockpiles
int links = 0;
links += sp->links.give_to_pile.size();

@ -409,18 +409,7 @@ struct stockpiles_import_hook : public df::viewscreen_dwarfmodest
auto dims = Gui::getDwarfmodeViewDims();
int left_margin = dims.menu_x1 + 1;
int x = left_margin;
int y = dims.y2 - 3;
int links = 0;
links += sp->links.give_to_pile.size();
links += sp->links.take_from_pile.size();
links += sp->links.give_to_workshop.size();
links += sp->links.take_from_workshop.size();
if ( links + 12 >= y )
{
y += 1;
}
int y = dims.y2 - 3; // below autodump, automelt, autotrade, stocks; above stockflow
OutputHotkeyString ( x, y, "Load/Save Settings", "l", true, left_margin, COLOR_WHITE, COLOR_LIGHTRED );
}
};

@ -1 +1 @@
Subproject commit e20fa9f5ca7707377477b3d9c032ec1f3a2e6414
Subproject commit 86788f5bf975da2506c61372ebfbe36ca47ed57c