Merge branch 'develop' into myk_click_logo

develop
Myk 2023-01-22 17:10:27 -08:00 committed by GitHub
commit f2c2fffac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 121 additions and 28 deletions

@ -4,8 +4,8 @@
# temporarily overridden in the active session with the `quickfort set` command.
#
# If you have edited this file but want to revert to "factory defaults", delete
# this file and a fresh one will be copied from
# dfhack-config/default/quickfort/quickfort.txt the next time you start DFHack.
# this file and a default one will be regenerated for you the next time you
# start DFHack.
# Directory tree to search for blueprints. Can be set to an absolute or relative
# path. If set to a relative path, resolves to a directory under the DF folder.
@ -30,8 +30,8 @@ query_unsafe=false
# Set to the maximum number of resources you want assigned to stockpiles of the
# relevant types. Set to -1 for DF defaults (number of stockpile tiles for
# stockpiles that take barrels and bins, 1 wheelbarrow for stone stockpiles).
# The default here for wheelbarrows is 0 since using wheelbarrows normally
# *decreases* the efficiency of your fort.
# The default here for wheelbarrows is 0 since restricting stockpiles to a
# single wheelbarrow can drastically *decrease* the efficiency of your fort.
stockpiles_max_barrels=-1
stockpiles_max_bins=-1
stockpiles_max_wheelbarrows=0

@ -39,6 +39,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements
- `hotkeys`: clicking on the DFHack logo no longer closes the popup menu
- `orders`: orders plugin functionality is now offered via an overlay widget when the manager orders screen is open
## Documentation

@ -125,10 +125,6 @@ The ``overlay.OverlayWidget`` superclass defines the following class attributes:
not annoy the player. Set to 0 to be called at the maximum rate. Be aware
that running more often than you really need to will impact game FPS,
especially if your widget can run while the game is unpaused.
- ``always_enabled`` (default: ``false``)
Set this to ``true`` if you don't want to let the user disable the widget.
This is useful for widgets that are controlled purely through their
triggers. See `gui/pathable` for an example.
Registering a widget with the overlay framework
***********************************************

@ -40,6 +40,17 @@ Examples
Import manager orders from the library that keep your fort stocked with
basic essentials.
Overlay
-------
Orders plugin functionality is directly available when the manager orders screen
is open via an `overlay` widget. There are hotkeys assigned to export, import,
sort, and clear. You can also click on the hotkey hints as if they were buttons.
Clearing will ask for confirmation before acting.
If you want to change where the hotkey hints appear, you can move them via
`gui/overlay`.
The orders library
------------------

@ -218,9 +218,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):key('SEC_SELECT'):string(': '..self.select2_hint,COLOR_GREY)
--end
end
function ListBox:getWantedFrameSize()

@ -134,7 +134,7 @@ dfhack_plugin(misery misery.cpp)
#dfhack_plugin(mode mode.cpp)
#dfhack_plugin(mousequery mousequery.cpp)
dfhack_plugin(nestboxes nestboxes.cpp)
dfhack_plugin(orders orders.cpp LINK_LIBRARIES jsoncpp_static)
dfhack_plugin(orders orders.cpp LINK_LIBRARIES jsoncpp_static lua)
dfhack_plugin(overlay overlay.cpp LINK_LIBRARIES lua)
dfhack_plugin(pathable pathable.cpp LINK_LIBRARIES lua)
#dfhack_plugin(petcapRemover petcapRemover.cpp)

@ -1,13 +0,0 @@
local _ENV = mkmodule('plugins.fortplan')
require('dfhack.buildings')
function construct_building_from_params(building_type, x, y, z)
local pos = xyz2pos(x, y, z)
local bld, err =
dfhack.buildings.constructBuilding{type=building_type, pos=pos}
if err then error(err) end
return bld
end
return _ENV

@ -0,0 +1,100 @@
local _ENV = mkmodule('plugins.orders')
local dialogs = require('gui.dialogs')
local gui = require('gui')
local overlay = require('plugins.overlay')
local widgets = require('gui.widgets')
--
-- OrdersOverlay
--
local function is_orders_panel_visible()
local info = df.global.game.main_interface.info
return info.open and info.current_mode == df.info_interface_mode_type.WORK_ORDERS
end
local function do_sort()
dfhack.run_command('orders', 'sort')
end
local function do_clear()
dialogs.showYesNoPrompt('Clear manager orders?',
'Are you sure you want to clear the manager orders?', nil,
function() dfhack.run_command('orders', 'clear') end)
end
local function do_import()
local output = dfhack.run_command_silent('orders', 'list')
dialogs.ListBox{
frame_title='Import Manager Orders',
with_filter=true,
choices=output:split('\n'),
on_select=function(idx, choice)
dfhack.run_command('orders', 'import', choice.text)
end,
}:show()
end
local function do_export()
dialogs.InputBox{
frame_title='Export Manager Orders',
on_input=function(text)
dfhack.run_command('orders', 'export', text)
end
}:show()
end
OrdersOverlay = defclass(OrdersOverlay, overlay.OverlayWidget)
OrdersOverlay.ATTRS{
default_pos={x=61,y=-6},
viewscreens='dwarfmode',
frame={w=30, h=4},
frame_style=gui.GREY_LINE_FRAME,
frame_background=gui.CLEAR_PEN,
}
function OrdersOverlay:init()
self:addviews{
widgets.HotkeyLabel{
frame={t=0, l=0},
label='import',
key='CUSTOM_CTRL_I',
on_activate=do_import,
},
widgets.HotkeyLabel{
frame={t=1, l=0},
label='export',
key='CUSTOM_CTRL_E',
on_activate=do_export,
},
widgets.HotkeyLabel{
frame={t=0, l=15},
label='sort',
key='CUSTOM_CTRL_O',
on_activate=do_sort,
},
widgets.HotkeyLabel{
frame={t=1, l=15},
label='clear',
key='CUSTOM_CTRL_C',
on_activate=do_clear,
},
}
end
function OrdersOverlay:render(dc)
if not is_orders_panel_visible() then return false end
OrdersOverlay.super.render(self, dc)
end
function OrdersOverlay:onInput(keys)
if not is_orders_panel_visible() then return false end
OrdersOverlay.super.onInput(self, keys)
end
OVERLAY_WIDGETS = {
overlay=OrdersOverlay,
}
return _ENV

@ -184,7 +184,6 @@ end
local function do_disable(args, quiet)
local disable_fn = function(name, db_entry)
if db_entry.widget.always_enabled then return end
overlay_config[name].enabled = false
if db_entry.widget.hotspot then
active_hotspot_widgets[name] = nil
@ -252,7 +251,7 @@ local function load_widget(name, widget_class)
local config = overlay_config[name]
config.pos = sanitize_pos(config.pos or widget.default_pos)
widget.frame = make_frame(config.pos, widget.frame)
if config.enabled or widget.always_enabled then
if config.enabled then
do_enable(name, true, true)
else
config.enabled = false
@ -492,7 +491,6 @@ OverlayWidget.ATTRS{
hotspot=false, -- whether to call overlay_onupdate on all screens
viewscreens={}, -- override with associated viewscreen or list of viewscrens
overlay_onupdate_max_freq_seconds=5, -- throttle calls to overlay_onupdate
always_enabled=false, -- for overlays that should never be disabled
}
function OverlayWidget:init()