Merge pull request #3 from DFHack/develop

Resyncing
develop
scamtank 2015-06-11 23:33:42 +03:00
commit 435178807f
11 changed files with 77 additions and 25 deletions

@ -28,6 +28,7 @@ DFHack Future
- Note: Existing stuck jobs must be cancelled and re-added - Note: Existing stuck jobs must be cancelled and re-added
Misc Improvements Misc Improvements
dwarfmonitor date format can be modified (see Readme) dwarfmonitor date format can be modified (see Readme)
dwarfmonitor weather display can be configured separately
"keybinding list" accepts a context "keybinding list" accepts a context
nyan: Can now be stopped with dfhack-run nyan: Can now be stopped with dfhack-run
quicksave: Restricted to fortress mode quicksave: Restricted to fortress mode

@ -1692,7 +1692,7 @@ Records dwarf activity to measure fort efficiency.
Options: Options:
``dwarfmonitor enable <mode>``: ``dwarfmonitor enable <mode>``:
Start monitoring ``mode``. ``mode`` can be "work", "misery", or "all". Start monitoring ``mode``. ``mode`` can be "work", "misery", "weather", or "all".
``dwarfmonitor disable <mode>``: ``dwarfmonitor disable <mode>``:
Stop monitoring ``mode`` (see above) Stop monitoring ``mode`` (see above)
``dwarfmonitor stats``: ``dwarfmonitor stats``:

@ -334,6 +334,7 @@ namespace DFHack
static int do_notify(lua_State *L); static int do_notify(lua_State *L);
static int do_input(lua_State *L); static int do_input(lua_State *L);
bool allow_options;
public: public:
dfhack_lua_viewscreen(lua_State *L, int table_idx); dfhack_lua_viewscreen(lua_State *L, int table_idx);
virtual ~dfhack_lua_viewscreen(); virtual ~dfhack_lua_viewscreen();
@ -348,6 +349,7 @@ namespace DFHack
virtual void help(); virtual void help();
virtual void resize(int w, int h); virtual void resize(int w, int h);
virtual void feed(std::set<df::interface_key> *keys); virtual void feed(std::set<df::interface_key> *keys);
virtual bool key_conflict(df::interface_key key);
virtual void onShow(); virtual void onShow();
virtual void onDismiss(); virtual void onDismiss();

@ -392,6 +392,9 @@ function Script:init(path)
self.mtime = dfhack.filesystem.mtime(path) self.mtime = dfhack.filesystem.mtime(path)
self._flags = {} self._flags = {}
end end
function Script:needs_update()
return (not self.env) or self.mtime ~= dfhack.filesystem.mtime(self.path)
end
function Script:get_flags() function Script:get_flags()
if self.flags_mtime ~= dfhack.filesystem.mtime(self.path) then if self.flags_mtime ~= dfhack.filesystem.mtime(self.path) then
self.flags_mtime = dfhack.filesystem.mtime(self.path) self.flags_mtime = dfhack.filesystem.mtime(self.path)
@ -463,14 +466,24 @@ function dfhack.enable_script(name, state)
end end
function dfhack.reqscript(name) function dfhack.reqscript(name)
_, env = dfhack.run_script_with_env(nil, name, {module=true}) return dfhack.script_environment(name, true)
return env
end end
reqscript = dfhack.reqscript reqscript = dfhack.reqscript
function dfhack.script_environment(name) function dfhack.script_environment(name, strict)
_, env = dfhack.run_script_with_env(nil, name, {module=true, module_strict=false}) local path = dfhack.findScript(name)
return env if not scripts[path] or scripts[path]:needs_update() then
local _, env = dfhack.run_script_with_env(nil, name, {
module=true,
module_strict=strict and true or false -- ensure that this key is present if 'strict' is nil
})
return env
else
if strict and not scripts[path]:get_flags().module then
error(('%s: %s'):format(name, valid_script_flags.module.error))
end
return scripts[path].env
end
end end
function dfhack.run_script_with_env(envVars, name, flags, ...) function dfhack.run_script_with_env(envVars, name, flags, ...)

@ -1336,6 +1336,7 @@ int Items::getValue(df::item *item)
int32_t Items::createItem(df::item_type item_type, int16_t item_subtype, int16_t mat_type, int32_t mat_index, df::unit* unit) { int32_t Items::createItem(df::item_type item_type, int16_t item_subtype, int16_t mat_type, int32_t mat_index, df::unit* unit) {
//based on Quietust's plugins/createitem.cpp //based on Quietust's plugins/createitem.cpp
CHECK_NULL_POINTER(unit);
df::map_block* block = Maps::getTileBlock(unit->pos.x, unit->pos.y, unit->pos.z); df::map_block* block = Maps::getTileBlock(unit->pos.x, unit->pos.y, unit->pos.z);
CHECK_NULL_POINTER(block); CHECK_NULL_POINTER(block);
df::reaction_product_itemst* prod = df::allocate<df::reaction_product_itemst>(); df::reaction_product_itemst* prod = df::allocate<df::reaction_product_itemst>();

@ -659,6 +659,9 @@ void dfhack_lua_viewscreen::update_focus(lua_State *L, int idx)
lua_getfield(L, idx, "text_input_mode"); lua_getfield(L, idx, "text_input_mode");
text_input_mode = lua_toboolean(L, -1); text_input_mode = lua_toboolean(L, -1);
lua_pop(L, 1); lua_pop(L, 1);
lua_getfield(L, idx, "allow_options");
allow_options = lua_toboolean(L, -1);
lua_pop(L, 1);
lua_getfield(L, idx, "focus_path"); lua_getfield(L, idx, "focus_path");
auto str = lua_tostring(L, -1); auto str = lua_tostring(L, -1);
@ -824,6 +827,13 @@ void dfhack_lua_viewscreen::logic()
safe_call_lua(do_notify, 1, 0); safe_call_lua(do_notify, 1, 0);
} }
bool dfhack_lua_viewscreen::key_conflict(df::interface_key key)
{
if (key == df::interface_key::OPTIONS)
return !allow_options;
return dfhack_viewscreen::key_conflict(key);
}
void dfhack_lua_viewscreen::help() void dfhack_lua_viewscreen::help()
{ {
if (Screen::isDismissed(this)) return; if (Screen::isDismissed(this)) return;

@ -77,6 +77,7 @@ static dwarfmonitor_configst dwarfmonitor_config;
static bool monitor_jobs = false; static bool monitor_jobs = false;
static bool monitor_misery = true; static bool monitor_misery = true;
static bool monitor_date = true; static bool monitor_date = true;
static bool monitor_weather = true;
static map<df::unit *, deque<activity_type>> work_history; static map<df::unit *, deque<activity_type>> work_history;
static int misery[] = { 0, 0, 0, 0, 0, 0, 0 }; static int misery[] = { 0, 0, 0, 0, 0, 0, 0 };
@ -1753,10 +1754,12 @@ struct dwarf_monitor_hook : public df::viewscreen_dwarfmodest
OutputString(COLOR_GREY, x, y, date_str.str()); OutputString(COLOR_GREY, x, y, date_str.str());
x = 1; }
y = gps->dimy - 1; if (monitor_weather)
bool clear = false, {
rain = false, int x = 1;
int y = gps->dimy - 1;
bool rain = false,
snow = false; snow = false;
if (current_weather) if (current_weather)
{ {
@ -1767,24 +1770,18 @@ struct dwarf_monitor_hook : public df::viewscreen_dwarfmodest
{ {
switch ((*current_weather)[i][j]) switch ((*current_weather)[i][j])
{ {
case weather_type::None:
clear = true;
break;
case weather_type::Rain: case weather_type::Rain:
rain = true; rain = true;
break; break;
case weather_type::Snow: case weather_type::Snow:
snow = true; snow = true;
break; break;
default:
break;
} }
} }
} }
} }
if (clear && (rain || snow))
{
OutputString(COLOR_YELLOW, x, y, "Clear");
++x;
}
if (rain) if (rain)
{ {
OutputString(COLOR_LIGHTBLUE, x, y, "Rain"); OutputString(COLOR_LIGHTBLUE, x, y, "Rain");
@ -1824,6 +1821,11 @@ static bool set_monitoring_mode(const string &mode, const bool &state)
mode_recognized = true; mode_recognized = true;
monitor_date = state; monitor_date = state;
} }
else if (mode == "weather" || mode == "all")
{
mode_recognized = true;
monitor_weather = state;
}
return mode_recognized; return mode_recognized;
} }
@ -1952,7 +1954,7 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector <Plugin
dwarfmonitor_cmd, false, dwarfmonitor_cmd, false,
"dwarfmonitor enable <mode>\n" "dwarfmonitor enable <mode>\n"
" Start monitoring <mode>\n" " Start monitoring <mode>\n"
" <mode> can be \"work\", \"misery\", or \"all\"\n" " <mode> can be \"work\", \"misery\", \"weather\", or \"all\"\n"
"dwarfmonitor disable <mode>\n" "dwarfmonitor disable <mode>\n"
" <mode> as above\n\n" " <mode> as above\n\n"
"dwarfmonitor stats\n" "dwarfmonitor stats\n"

@ -113,6 +113,13 @@ message MapBlock
repeated MatPair base_materials = 8; repeated MatPair base_materials = 8;
repeated int32 magma = 9; repeated int32 magma = 9;
repeated int32 water = 10; repeated int32 water = 10;
repeated bool hidden = 11;
repeated bool light = 12;
repeated bool subterranean = 13;
repeated bool outside = 14;
repeated bool aquifer = 15;
repeated bool water_stagnant = 16;
repeated bool water_salt = 17;
} }
message MatPair { message MatPair {
@ -205,4 +212,4 @@ message MapInfo
optional string world_name = 7; optional string world_name = 7;
optional string world_name_english = 8; optional string world_name_english = 8;
optional string save_name = 9; optional string save_name = 9;
} }

@ -649,6 +649,13 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
water = designation.bits.flow_size; water = designation.bits.flow_size;
NetBlock->add_magma(lava); NetBlock->add_magma(lava);
NetBlock->add_water(water); NetBlock->add_water(water);
NetBlock->add_aquifer(designation.bits.water_table);
NetBlock->add_hidden(designation.bits.hidden);
NetBlock->add_light(designation.bits.light);
NetBlock->add_outside(designation.bits.outside);
NetBlock->add_subterranean(designation.bits.subterranean);
NetBlock->add_water_salt(designation.bits.water_salt);
NetBlock->add_water_stagnant(designation.bits.water_stagnant);
} }
} }

@ -1,6 +1,15 @@
-- Holds custom descriptions for view-item-info -- Holds custom descriptions for view-item-info
-- By PeridexisErrant -- By PeridexisErrant
-- Each line near the bottom has 53 characters of room until
-- it starts clipping over the UI in an ugly fashion.
-- For proper spacing, 50 characters is the maximum.
-- Descriptions which aren't pushed down the page by
-- barrel contents or such line up with the UI on the
-- 11th line down. There is room for a 10th long line
-- without clipping, but stopping at 9 leaves enough space
-- for ideal legibility.
-- The following people contributed descriptions: -- The following people contributed descriptions:
-- Raideau, PeridexisErrant, /u/Puffin4Tom, /u/KroyMortlach -- Raideau, PeridexisErrant, /u/Puffin4Tom, /u/KroyMortlach
-- /u/genieus, /u/TeamsOnlyMedic, /u/johny5w, /u/DerTanni -- /u/genieus, /u/TeamsOnlyMedic, /u/johny5w, /u/DerTanni

@ -72,12 +72,12 @@ function GetMatPropertiesStringList (item)
append(list,"Temperature: "..deg_C.."\248C ("..deg_U.."U)") append(list,"Temperature: "..deg_C.."\248C ("..deg_U.."U)")
append(list,"Color: "..df.global.world.raws.language.colors[mat.state_color.Solid].name) append(list,"Color: "..df.global.world.raws.language.colors[mat.state_color.Solid].name)
local function GetStrainDescription (number) local function GetStrainDescription (number)
if tonumber(number) >= 50000 then return "very elastic" if tonumber(number) < 1 then return "crystalline"
elseif tonumber(number) < 50000 then return "elastic"
elseif tonumber(number) < 15001 then return "medium"
elseif tonumber(number) < 5001 then return "stiff"
elseif tonumber(number) < 1000 then return "very stiff" elseif tonumber(number) < 1000 then return "very stiff"
elseif tonumber(number) < 1 then return "crystalline" elseif tonumber(number) < 5001 then return "stiff"
elseif tonumber(number) < 15001 then return "medium"
elseif tonumber(number) < 50000 then return "elastic"
elseif tonumber(number) >= 50000 then return "very elastic"
else return "unknown" end else return "unknown" end
end end
local mat_properties_for = {"BAR", "SMALLGEM", "BOULDER", "ROUGH", local mat_properties_for = {"BAR", "SMALLGEM", "BOULDER", "ROUGH",