Merge branch 'develop' into myk_buildingplan_suspendmanager

develop
Myk 2023-03-28 06:52:42 -07:00 committed by GitHub
commit 921e08e97a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 16 deletions

@ -53,6 +53,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements ## Misc Improvements
- `buildingplan`: filters and global settings are now ignored when manually choosing items for a building - `buildingplan`: filters and global settings are now ignored when manually choosing items for a building
- `buildingplan`: if `suspendmanager` is running, then planned buildings will be left suspended when their items are all attached. `suspendmanager` will unsuspsend them for construction when it is safe to do so. - `buildingplan`: if `suspendmanager` is running, then planned buildings will be left suspended when their items are all attached. `suspendmanager` will unsuspsend them for construction when it is safe to do so.
- `confirm`: adds confirmation for removing burrows via the repaint menu
- `stockpiles`: support applying stockpile configurations with fully enabled categories to stockpiles in worlds other than the one where the configuration was exported from - `stockpiles`: support applying stockpile configurations with fully enabled categories to stockpiles in worlds other than the one where the configuration was exported from
- `stockpiles`: support partial application of a saved config based on dynamic filtering - `stockpiles`: support partial application of a saved config based on dynamic filtering
- `stockpiles`: additive and subtractive modes when applying a second stockpile configuration on top of a first - `stockpiles`: additive and subtractive modes when applying a second stockpile configuration on top of a first
@ -60,6 +61,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `stockpiles`: now includes a library of useful stockpile configs (see docs for details) - `stockpiles`: now includes a library of useful stockpile configs (see docs for details)
- `automelt`: now allows metal chests to be melted (workaround for DF bug 2493 is no longer needed) - `automelt`: now allows metal chests to be melted (workaround for DF bug 2493 is no longer needed)
- `orders`: add minimize button to overlay panel so you can get it out of the way to read long statue descriptions when choosing a subject in the details screen - `orders`: add minimize button to overlay panel so you can get it out of the way to read long statue descriptions when choosing a subject in the details screen
- `orders`: add option to delete exported files from the import dialog
- `enable`: can now interpret aliases defined with the `alias` command - `enable`: can now interpret aliases defined with the `alias` command
- scripts in installed mods are now automatically added to the DFHack script path. DFHack recognizes two directories in a mod's folder: ``scripts_modinstalled/`` and ``scripts_modactive/``. ``scripts_modinstalled/`` folders will always be added the script path, regardless of whether the mod is active in a world. ``scripts_modactive/`` folders will only be added to the script path when the mod is active in the current loaded world. - scripts in installed mods are now automatically added to the DFHack script path. DFHack recognizes two directories in a mod's folder: ``scripts_modinstalled/`` and ``scripts_modactive/``. ``scripts_modinstalled/`` folders will always be added the script path, regardless of whether the mod is active in a world. ``scripts_modactive/`` folders will only be added to the script path when the mod is active in the current loaded world.

@ -457,6 +457,8 @@ Ok, you're all set up! Now, let's take a look at an example
enabled = enabled or false enabled = enabled or false
function isEnabled() function isEnabled()
-- this function is for the enabled API, the script won't show up on the
-- control panel without it
return enabled return enabled
end end
@ -473,6 +475,10 @@ Ok, you're all set up! Now, let's take a look at an example
dfhack.run_command('enable', 'example-mod') dfhack.run_command('enable', 'example-mod')
end end
if dfhack_flags.module then
return
end
if not dfhack_flags.enable then if not dfhack_flags.enable then
print(dfhack.script_help()) print(dfhack.script_help())
print() print()

@ -5,8 +5,9 @@ confirm
:summary: Adds confirmation dialogs for destructive actions. :summary: Adds confirmation dialogs for destructive actions.
:tags: fort interface :tags: fort interface
Now you can get the chance to avoid accidentally disbanding a squad or deleting a In the base game, it is frightenly easy to destroy hours of work with a single
hauling route in case you hit the key accidentally. misclick. Now you can avoid the consequences of accidentally disbanding a squad
(for example), or deleting a hauling route.
Usage Usage
----- -----

@ -4,9 +4,6 @@ local _ENV = mkmodule('gui.dialogs')
local gui = require('gui') local gui = require('gui')
local widgets = require('gui.widgets') local widgets = require('gui.widgets')
local utils = require('utils')
local dscreen = dfhack.screen
MessageBox = defclass(MessageBox, gui.FramedScreen) MessageBox = defclass(MessageBox, gui.FramedScreen)
@ -66,6 +63,7 @@ function MessageBox:onInput(keys)
elseif (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) and self.on_cancel then elseif (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) and self.on_cancel then
self.on_cancel() self.on_cancel()
end end
gui.markMouseClicksHandled(keys)
return true return true
end end
return self:inputToSubviews(keys) return self:inputToSubviews(keys)
@ -135,6 +133,7 @@ function InputBox:onInput(keys)
if self.on_cancel then if self.on_cancel then
self.on_cancel() self.on_cancel()
end end
gui.markMouseClicksHandled(keys)
return true return true
end end
return self:inputToSubviews(keys) return self:inputToSubviews(keys)
@ -218,9 +217,9 @@ end
function ListBox:onRenderFrame(dc,rect) function ListBox:onRenderFrame(dc,rect)
ListBox.super.onRenderFrame(self,dc,rect) ListBox.super.onRenderFrame(self,dc,rect)
--if self.select2_hint then if self.select2_hint then
-- dc:seek(rect.x1+2,rect.y2):key('SEC_SELECT'):string(': '..self.select2_hint,COLOR_GREY) dc:seek(rect.x1+2,rect.y2):string('Shift-Click', COLOR_LIGHTGREEN):string(': '..self.select2_hint, COLOR_GREY)
--end end
end end
function ListBox:getWantedFrameSize() function ListBox:getWantedFrameSize()
@ -236,6 +235,7 @@ function ListBox:onInput(keys)
if self.on_cancel then if self.on_cancel then
self.on_cancel() self.on_cancel()
end end
gui.markMouseClicksHandled(keys)
return true return true
end end
return self:inputToSubviews(keys) return self:inputToSubviews(keys)

@ -60,6 +60,8 @@ DefaultItemFilters::DefaultItemFilters(color_ostream &out, PersistentDataItem &f
auto &serialized = filter_config.val(); auto &serialized = filter_config.val();
DEBUG(status,out).print("deserializing default item filters for key %d,%d,%d: %s\n", DEBUG(status,out).print("deserializing default item filters for key %d,%d,%d: %s\n",
std::get<0>(key), std::get<1>(key), std::get<2>(key), serialized.c_str()); std::get<0>(key), std::get<1>(key), std::get<2>(key), serialized.c_str());
if (!jitems.size())
return;
std::vector<std::string> elems; std::vector<std::string> elems;
split_string(&elems, serialized, "|"); split_string(&elems, serialized, "|");
std::vector<ItemFilter> filters = deserialize_item_filters(out, elems[0]); std::vector<ItemFilter> filters = deserialize_item_filters(out, elems[0]);

@ -12,10 +12,11 @@ setmetatable(keys, {
-- Mouse keys will be sent as a string instead of interface_key -- Mouse keys will be sent as a string instead of interface_key
local MOUSE_LEFT = "MOUSE_LEFT" local MOUSE_LEFT = "MOUSE_LEFT"
local MOUSE_RIGHT = "MOUSE_RIGHT" local MOUSE_RIGHT = "MOUSE_RIGHT"
--[[ The screen where a confirmation has been triggered --[[ The screen where a confirmation has been triggered
Note that this is *not* necessarily the topmost viewscreen, so do not use Note that this is *not* necessarily the topmost viewscreen, so do not use
gui.getCurViewscreen() or related functions. ]] gui.getCurViewscreen() or related functions. ]]
screen = nil --screen = nil
function if_nil(obj, default) function if_nil(obj, default)
if obj == nil then if obj == nil then
@ -118,7 +119,9 @@ zone_remove.message = "Are you sure you want to remove this zone?"
burrow_remove = defconf('burrow-remove') burrow_remove = defconf('burrow-remove')
function burrow_remove.intercept_key(key) function burrow_remove.intercept_key(key)
return key == MOUSE_LEFT and df.global.game.main_interface.current_hover == 171 return key == MOUSE_LEFT and
(df.global.game.main_interface.current_hover == 171 or
df.global.game.main_interface.current_hover == 168)
end end
burrow_remove.title = "Remove burrow" burrow_remove.title = "Remove burrow"
burrow_remove.message = "Are you sure you want to remove this burrow?" burrow_remove.message = "Are you sure you want to remove this burrow?"

@ -19,15 +19,37 @@ local function do_clear()
function() dfhack.run_command('orders', 'clear') end) function() dfhack.run_command('orders', 'clear') end)
end end
local function get_import_choices()
return dfhack.run_command_silent('orders', 'list'):split('\n')
end
local function do_import() local function do_import()
local output = dfhack.run_command_silent('orders', 'list') local dlg
dialogs.ListBox{ local function get_dlg() return dlg end
frame_title='Import Manager Orders', dlg = dialogs.ListBox{
frame_title='Import/Delete Manager Orders',
with_filter=true, with_filter=true,
choices=output:split('\n'), choices=get_import_choices(),
on_select=function(idx, choice) on_select=function(_, choice)
dfhack.run_command('orders', 'import', choice.text) dfhack.run_command('orders', 'import', choice.text)
end, end,
dismiss_on_select2=false,
on_select2=function(_, choice)
if choice.text:startswith('library/') then return end
local fname = 'dfhack-config/orders/'..choice.text..'.json'
if not dfhack.filesystem.isfile(fname) then return end
dialogs.showYesNoPrompt('Delete orders file?',
'Are you sure you want to delete "' .. fname .. '"?', nil,
function()
print('deleting ' .. fname)
os.remove(fname)
local list = get_dlg().subviews.list
local filter = list:getFilter()
list:setChoices(get_import_choices(), list:getSelected())
list:setFilter(filter)
end)
end,
select2_hint='Delete file',
}:show() }:show()
end end

@ -1 +1 @@
Subproject commit bb3dfc0d3e2bdebc4ba6fd814371662457b18917 Subproject commit 27089b81be6f9de9486118a97a15be4dde09b1b3