Merge branch 'develop' into automelt

develop
Eamon Bode 2023-01-23 14:20:48 -05:00 committed by GitHub
commit fc861f1328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 113 additions and 46 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

@ -40,6 +40,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements
- A new cross-compile build script was added for building the Windows files from a Linux Docker builder (see the Compile instructions in the docs)
- `hotkeys`: clicking on the DFHack logo no longer closes the popup menu
- `gui/launcher`: sped up initialization time for faster load of the UI
- `orders`: orders plugin functionality is now offered via an overlay widget when the manager orders screen is open
## Documentation
@ -47,6 +48,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## API
## Lua
- `helpdb`: new function: ``helpdb.refresh()`` to force a refresh of the database. Call if you are a developer adding new scripts, loading new plugins, or changing help text during play
- `helpdb`: changed from auto-refreshing every 60 seconds to only refreshing on explicit call to ``helpdb.refresh()``. docs very rarely change during a play session, and the automatic database refreshes were slowing down the startup of `gui/launcher`
- ``widgets.Label``: ``label.scroll()`` now understands ``home`` and ``end`` keywords for scrolling to the top or bottom
## Removed

@ -3319,17 +3319,20 @@ function:
argument specifies the indentation step size in spaces. For
the other arguments see the original documentation link above.
.. _helpdb:
helpdb
======
Unified interface for DFHack tool help text. Help text is read from the rendered
text in ``hack/docs/docs/``. If no rendered text exists, help is read from the
script sources (for scripts) or the string passed to the ``PluginCommand``
text in ``hack/docs/docs/tools``. If no rendered text exists, help is read from
the script sources (for scripts) or the string passed to the ``PluginCommand``
initializer (for plugins). See `documentation` for details on how DFHack's help
system works.
The database is lazy-loaded when an API method is called. It rechecks its help
sources for updates if an API method has not been called in the last 60 seconds.
The database is loaded when DFHack initializes, but can be explicitly refreshed
with a call to ``helpdb.refresh()`` if docs are added/changed during a play
session.
Each entry has several properties associated with it:
@ -3345,6 +3348,10 @@ Each entry has several properties associated with it:
- Long help, the entire contents of the associated help file.
- A list of tags that define the groups that the entry belongs to.
* ``helpdb.refresh()``
Scan for changes in available commands and their documentation.
* ``helpdb.is_entry(str)``, ``helpdb.is_entry(list)``
Returns whether the given string (or list of strings) is an entry (are all
@ -4224,18 +4231,21 @@ A framed screen has the following attributes:
There are the following predefined frame style tables:
* ``GREY_FRAME``
* ``WINDOW_FRAME``
A frame suitable for a draggable, optionally resizable window.
A plain grey-colored frame.
* ``PANEL_FRAME``
* ``BOUNDARY_FRAME``
A frame suitable for a static (non-draggable, non-resizable) panel.
The same frame as used by the usual full-screen DF views, like dwarfmode.
* ``MEDIUM_FRAME``
* ``GREY_LINE_FRAME``
A frame suitable for overlay widget panels.
A frame consisting of grey lines, similar to the one used by titan announcements.
* ``THIN_FRAME``
A frame suitable for light accent elements.
gui.widgets
===========

@ -2114,6 +2114,7 @@ void Core::onStateChange(color_ostream &out, state_change_event event)
{
auto L = Lua::Core::State;
Lua::StackUnwinder top(L);
Lua::CallLuaModuleFunction(con, L, "helpdb", "refresh");
Lua::CallLuaModuleFunction(con, L, "script-manager", "reload");
}
break;

@ -1693,6 +1693,10 @@ static const LuaWrapper::FunctionReg dfhack_textures_module[] = {
WRAPM(Textures, getGreenPinTexposStart),
WRAPM(Textures, getRedPinTexposStart),
WRAPM(Textures, getIconsTexposStart),
WRAPM(Textures, getThinBordersTexposStart),
WRAPM(Textures, getMediumBordersTexposStart),
WRAPM(Textures, getPanelBordersTexposStart),
WRAPM(Textures, getWindowBordersTexposStart),
{ NULL, NULL }
};

@ -41,5 +41,13 @@ DFHACK_EXPORT long getRedPinTexposStart();
*/
DFHACK_EXPORT long getIconsTexposStart();
/**
* Get the first texpos for the DFHack borders. Each is a 7x3 grid.
*/
DFHACK_EXPORT long getThinBordersTexposStart();
DFHACK_EXPORT long getMediumBordersTexposStart();
DFHACK_EXPORT long getPanelBordersTexposStart();
DFHACK_EXPORT long getWindowBordersTexposStart();
}
}

@ -789,29 +789,23 @@ end
--------------------------
-- Plain grey-colored frame.
-- deprecated
GREY_FRAME = {
frame_pen = to_pen{ ch = ' ', fg = COLOR_BLACK, bg = COLOR_GREY },
title_pen = to_pen{ fg = COLOR_BLACK, bg = COLOR_WHITE },
signature_pen = to_pen{ fg = COLOR_BLACK, bg = COLOR_GREY },
}
-- The usual boundary used by the DF screens. Often has fancy pattern in tilesets.
-- The boundary used by the pre-steam DF screens.
-- deprecated
BOUNDARY_FRAME = {
frame_pen = to_pen{ ch = 0xDB, fg = COLOR_GREY, bg = COLOR_BLACK },
title_pen = to_pen{ fg = COLOR_BLACK, bg = COLOR_GREY },
signature_pen = to_pen{ fg = COLOR_BLACK, bg = COLOR_GREY },
}
GREY_LINE_FRAME = {
local BASE_FRAME = {
frame_pen = to_pen{ ch=206, fg=COLOR_GREY, bg=COLOR_BLACK },
t_frame_pen = to_pen{ tile=902, ch=205, fg=COLOR_GREY, bg=COLOR_BLACK },
l_frame_pen = to_pen{ tile=908, ch=186, fg=COLOR_GREY, bg=COLOR_BLACK },
b_frame_pen = to_pen{ tile=916, ch=205, fg=COLOR_GREY, bg=COLOR_BLACK },
r_frame_pen = to_pen{ tile=910, ch=186, fg=COLOR_GREY, bg=COLOR_BLACK },
lt_frame_pen = to_pen{ tile=901, ch=201, fg=COLOR_GREY, bg=COLOR_BLACK },
lb_frame_pen = to_pen{ tile=915, ch=200, fg=COLOR_GREY, bg=COLOR_BLACK },
rt_frame_pen = to_pen{ tile=903, ch=187, fg=COLOR_GREY, bg=COLOR_BLACK },
rb_frame_pen = to_pen{ tile=917, ch=188, fg=COLOR_GREY, bg=COLOR_BLACK },
title_pen = to_pen{ fg=COLOR_BLACK, bg=COLOR_GREY },
inactive_title_pen = to_pen{ fg=COLOR_GREY, bg=COLOR_BLACK },
signature_pen = to_pen{ fg=COLOR_GREY, bg=COLOR_BLACK },
@ -819,6 +813,35 @@ GREY_LINE_FRAME = {
unpinned_pen = to_pen{tile=782, ch=216, fg=COLOR_GREY, bg=COLOR_BLACK},
}
local function make_frame(name, double_line)
local texpos = dfhack.textures['get'..name..'BordersTexposStart']()
local tp = function(offset)
if texpos == -1 then return nil end
return texpos + offset
end
local frame = copyall(BASE_FRAME)
frame.t_frame_pen = to_pen{ tile=tp(1), ch=double_line and 205 or 196, fg=COLOR_GREY, bg=COLOR_BLACK }
frame.l_frame_pen = to_pen{ tile=tp(7), ch=double_line and 186 or 179, fg=COLOR_GREY, bg=COLOR_BLACK }
frame.b_frame_pen = to_pen{ tile=tp(15), ch=double_line and 205 or 196, fg=COLOR_GREY, bg=COLOR_BLACK }
frame.r_frame_pen = to_pen{ tile=tp(9), ch=double_line and 186 or 179, fg=COLOR_GREY, bg=COLOR_BLACK }
frame.lt_frame_pen = to_pen{ tile=tp(0), ch=double_line and 201 or 218, fg=COLOR_GREY, bg=COLOR_BLACK }
frame.lb_frame_pen = to_pen{ tile=tp(14), ch=double_line and 200 or 192, fg=COLOR_GREY, bg=COLOR_BLACK }
frame.rt_frame_pen = to_pen{ tile=tp(2), ch=double_line and 187 or 191, fg=COLOR_GREY, bg=COLOR_BLACK }
frame.rb_frame_pen = to_pen{ tile=tp(16), ch=double_line and 188 or 217, fg=COLOR_GREY, bg=COLOR_BLACK }
return frame
end
WINDOW_FRAME = make_frame('Window', true)
PANEL_FRAME = make_frame('Panel', false)
MEDIUM_FRAME = make_frame('Medium', false)
THIN_FRAME = make_frame('Thin', false)
-- for compatibility with pre-steam code
GREY_LINE_FRAME = WINDOW_FRAME
BOUNDARY_FRAME = PANEL_FRAME
GREY_FRAME = MEDIUM_FRAME
function paint_frame(dc,rect,style,title,show_pin,pinned,inactive)
local pen = style.frame_pen
local x1,y1,x2,y2 = dc.x1+rect.x1, dc.y1+rect.y1, dc.x1+rect.x2, dc.y1+rect.y2

@ -13,7 +13,7 @@ MessageBox = defclass(MessageBox, gui.FramedScreen)
MessageBox.focus_path = 'MessageBox'
MessageBox.ATTRS{
frame_style = gui.GREY_LINE_FRAME,
frame_style = gui.WINDOW_FRAME,
frame_inset = 1,
-- new attrs
on_accept = DEFAULT_NIL,

@ -531,7 +531,7 @@ end
Window = defclass(Window, Panel)
Window.ATTRS {
frame_style = gui.GREY_LINE_FRAME,
frame_style = gui.WINDOW_FRAME,
frame_background = gui.CLEAR_PEN,
frame_inset = 1,
draggable = true,

@ -1,23 +1,9 @@
-- The help text database and query interface.
--
-- Help text is read from the rendered text in hack/docs/docs/. If no rendered
-- text exists, it is read from the script sources (for scripts) or the string
-- passed to the PluginCommand initializer (for plugins).
--
-- There should be one help file for each plugin that contains a summary for the
-- plugin itself and help for all the commands that plugin provides (if any).
-- Each script should also have one documentation file.
--
-- The database is lazy-loaded when an API method is called. It rechecks its
-- help sources for updates if an API method has not been called in the last
-- 60 seconds.
local _ENV = mkmodule('helpdb')
local argparse = require('argparse')
local MAX_STALE_MS = 60000
-- paths
local RENDERED_PATH = 'hack/docs/docs/tools/'
local TAG_DEFINITIONS = 'hack/docs/docs/Tags.txt'
@ -415,13 +401,12 @@ local function index_tags()
end
end
-- ensures the db is up to date by scanning all help sources. does not do
-- anything if it has already been run within the last MAX_STALE_MS milliseconds
local last_refresh_ms = 0
local needs_refresh = true
-- ensures the db is loaded
local function ensure_db()
local now_ms = dfhack.getTickCount()
if now_ms - last_refresh_ms <= MAX_STALE_MS then return end
last_refresh_ms = now_ms
if not needs_refresh then return end
needs_refresh = false
local old_db = textdb
textdb, entrydb, tag_index = {}, {}, {}
@ -433,6 +418,11 @@ local function ensure_db()
index_tags()
end
function refresh()
needs_refresh = true
ensure_db()
end
local function parse_blocks(text)
local blocks = {}
for line in text:gmatch('[^\n]*') do

@ -22,6 +22,10 @@ static long g_dfhack_logo_texpos_start = -1;
static long g_green_pin_texpos_start = -1;
static long g_red_pin_texpos_start = -1;
static long g_icons_texpos_start = -1;
static long g_thin_borders_texpos_start = -1;
static long g_medium_borders_texpos_start = -1;
static long g_panel_borders_texpos_start = -1;
static long g_window_borders_texpos_start = -1;
// Converts an arbitrary Surface to something like the display format
// (32-bit RGBA), and converts magenta to transparency if convert_magenta is set
@ -120,6 +124,14 @@ void Textures::init(color_ostream &out) {
&g_red_pin_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/icons.png",
&g_icons_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-thin.png",
&g_thin_borders_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-medium.png",
&g_medium_borders_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-panel.png",
&g_panel_borders_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-window.png",
&g_window_borders_texpos_start);
DEBUG(textures,out).print("loaded %ld textures\n", g_num_dfhack_textures);
@ -167,3 +179,19 @@ long Textures::getRedPinTexposStart() {
long Textures::getIconsTexposStart() {
return g_icons_texpos_start;
}
long Textures::getThinBordersTexposStart() {
return g_thin_borders_texpos_start;
}
long Textures::getMediumBordersTexposStart() {
return g_medium_borders_texpos_start;
}
long Textures::getPanelBordersTexposStart() {
return g_panel_borders_texpos_start;
}
long Textures::getWindowBordersTexposStart() {
return g_window_borders_texpos_start;
}

@ -170,7 +170,7 @@ function Menu:init()
widgets.Panel{
view_id='list_panel',
frame=list_frame,
frame_style=gui.GREY_LINE_FRAME,
frame_style=gui.PANEL_FRAME,
frame_background=gui.CLEAR_PEN,
subviews={
widgets.List{
@ -197,7 +197,7 @@ function Menu:init()
view_id='help_panel',
autoarrange_subviews=true,
frame=help_frame,
frame_style=gui.GREY_LINE_FRAME,
frame_style=gui.PANEL_FRAME,
frame_background=gui.CLEAR_PEN,
subviews={
widgets.WrappedLabel{

@ -47,10 +47,10 @@ end
OrdersOverlay = defclass(OrdersOverlay, overlay.OverlayWidget)
OrdersOverlay.ATTRS{
default_pos={x=61,y=-6},
default_pos={x=53,y=-6},
viewscreens='dwarfmode',
frame={w=30, h=4},
frame_style=gui.GREY_LINE_FRAME,
frame_style=gui.MEDIUM_FRAME,
frame_background=gui.CLEAR_PEN,
}