Skip to content

Commit

Permalink
Merge branch 'develop' into myk_buildingplan_suspendmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 authored Mar 28, 2023
2 parents 8da7e21 + ab2f3b1 commit 921e08e
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 16 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements
- `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.
- `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 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`: write player-exported stockpile configurations to the ``dfhack-config/stockpiles`` folder. If you have any stockpile configs in other directories, please move them to that folder.
- `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)
- `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
- 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.

Expand Down
6 changes: 6 additions & 0 deletions docs/guides/modding-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ Ok, you're all set up! Now, let's take a look at an example
enabled = enabled or false

function isEnabled()
-- this function is for the enabled API, the script won't show up on the
-- control panel without it
return enabled
end

Expand All @@ -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')
end

if dfhack_flags.module then
return
end

if not dfhack_flags.enable then
print(dfhack.script_help())
print()
Expand Down
5 changes: 3 additions & 2 deletions docs/plugins/confirm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ confirm
:summary: Adds confirmation dialogs for destructive actions.
:tags: fort interface

Now you can get the chance to avoid accidentally disbanding a squad or deleting a
hauling route in case you hit the key accidentally.
In the base game, it is frightenly easy to destroy hours of work with a single
misclick. Now you can avoid the consequences of accidentally disbanding a squad
(for example), or deleting a hauling route.

Usage
-----
Expand Down
12 changes: 6 additions & 6 deletions library/lua/gui/dialogs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ local _ENV = mkmodule('gui.dialogs')

local gui = require('gui')
local widgets = require('gui.widgets')
local utils = require('utils')

local dscreen = dfhack.screen

MessageBox = defclass(MessageBox, gui.FramedScreen)

Expand Down Expand Up @@ -66,6 +63,7 @@ function MessageBox:onInput(keys)
elseif (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) and self.on_cancel then
self.on_cancel()
end
gui.markMouseClicksHandled(keys)
return true
end
return self:inputToSubviews(keys)
Expand Down Expand Up @@ -135,6 +133,7 @@ function InputBox:onInput(keys)
if self.on_cancel then
self.on_cancel()
end
gui.markMouseClicksHandled(keys)
return true
end
return self:inputToSubviews(keys)
Expand Down Expand Up @@ -218,9 +217,9 @@ end

function ListBox:onRenderFrame(dc,rect)
ListBox.super.onRenderFrame(self,dc,rect)
--if self.select2_hint then
-- dc:seek(rect.x1+2,rect.y2):key('SEC_SELECT'):string(': '..self.select2_hint,COLOR_GREY)
--end
if self.select2_hint then
dc:seek(rect.x1+2,rect.y2):string('Shift-Click', COLOR_LIGHTGREEN):string(': '..self.select2_hint, COLOR_GREY)
end
end

function ListBox:getWantedFrameSize()
Expand All @@ -236,6 +235,7 @@ function ListBox:onInput(keys)
if self.on_cancel then
self.on_cancel()
end
gui.markMouseClicksHandled(keys)
return true
end
return self:inputToSubviews(keys)
Expand Down
2 changes: 2 additions & 0 deletions plugins/buildingplan/defaultitemfilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ DefaultItemFilters::DefaultItemFilters(color_ostream &out, PersistentDataItem &f
auto &serialized = filter_config.val();
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());
if (!jitems.size())
return;
std::vector<std::string> elems;
split_string(&elems, serialized, "|");
std::vector<ItemFilter> filters = deserialize_item_filters(out, elems[0]);
Expand Down
7 changes: 5 additions & 2 deletions plugins/lua/confirm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ setmetatable(keys, {
-- Mouse keys will be sent as a string instead of interface_key
local MOUSE_LEFT = "MOUSE_LEFT"
local MOUSE_RIGHT = "MOUSE_RIGHT"

--[[ The screen where a confirmation has been triggered
Note that this is *not* necessarily the topmost viewscreen, so do not use
gui.getCurViewscreen() or related functions. ]]
screen = nil
--screen = nil

function if_nil(obj, default)
if obj == nil then
Expand Down Expand Up @@ -118,7 +119,9 @@ zone_remove.message = "Are you sure you want to remove this zone?"

burrow_remove = defconf('burrow-remove')
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
burrow_remove.title = "Remove burrow"
burrow_remove.message = "Are you sure you want to remove this burrow?"
Expand Down
32 changes: 27 additions & 5 deletions plugins/lua/orders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,37 @@ local function do_clear()
function() dfhack.run_command('orders', 'clear') end)
end

local function get_import_choices()
return dfhack.run_command_silent('orders', 'list'):split('\n')
end

local function do_import()
local output = dfhack.run_command_silent('orders', 'list')
dialogs.ListBox{
frame_title='Import Manager Orders',
local dlg
local function get_dlg() return dlg end
dlg = dialogs.ListBox{
frame_title='Import/Delete Manager Orders',
with_filter=true,
choices=output:split('\n'),
on_select=function(idx, choice)
choices=get_import_choices(),
on_select=function(_, choice)
dfhack.run_command('orders', 'import', choice.text)
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()
end

Expand Down
2 changes: 1 addition & 1 deletion scripts

0 comments on commit 921e08e

Please sign in to comment.