@ -3267,8 +3274,8 @@ Implements a trivial single-inheritance class system.
1. An empty instance table is created, and its metatable set.
1. An empty instance table is created, and its metatable set.
2. The ``preinit`` methods are called via ``invoke_before`` (see below)
2. The ``preinit`` methods are called via ``invoke_before`` (see below)
with the table used as argument to the class. These methods are intended
with the table used as the argument to the class. These methods are
for validating and tweaking that argument table.
intended for validating and tweaking that argument table.
3. Declared ATTRS are initialized from the argument table or their default values.
3. Declared ATTRS are initialized from the argument table or their default values.
4. The ``init`` methods are called via ``invoke_after`` with the argument table.
4. The ``init`` methods are called via ``invoke_after`` with the argument table.
This is the main constructor method.
This is the main constructor method.
@ -3339,7 +3346,7 @@ A module for reading custom tokens added to the raws by mods.
Where ``typeInstance`` is a unit, entity, item, job, projectile, building, plant, or interaction
Where ``typeInstance`` is a unit, entity, item, job, projectile, building, plant, or interaction
instance. Gets ``typeDefinition`` and then returns the same as ``getToken(typeDefinition, token)``.
instance. Gets ``typeDefinition`` and then returns the same as ``getToken(typeDefinition, token)``.
For units, it gets the token from the race or caste instead if appplicable. For plants growth items,
For units, it gets the token from the race or caste instead if applicable. For plants growth items,
it gets the token from the plant or plant growth instead if applicable. For plants it does the same
it gets the token from the plant or plant growth instead if applicable. For plants it does the same
but with growth number -1.
but with growth number -1.
@ -3661,7 +3668,7 @@ It also always has the following fields:
These fields are computed by the layout process:
These fields are computed by the layout process:
:frame_parent_rect:The ViewRect represeting the client area of the parent view.
:frame_parent_rect:The ViewRect representing the client area of the parent view.
:frame_rect:The ``mkdims`` rect of the outer frame in parent-local coordinates.
:frame_rect:The ``mkdims`` rect of the outer frame in parent-local coordinates.
:frame_body:The ViewRect representing the body part of the View's own frame.
:frame_body:The ViewRect representing the body part of the View's own frame.
@ -3897,13 +3904,13 @@ Base of all the widgets. Inherits from View and has the following attributes:
:r:gap between the right edges of the frame and the parent.
:r:gap between the right edges of the frame and the parent.
:b:gap between the bottom edges of the frame and the parent.
:b:gap between the bottom edges of the frame and the parent.
:w:maximum width of the frame.
:w:maximum width of the frame.
:h:maximum heigth of the frame.
:h:maximum height of the frame.
:xalign:X alignment of the frame.
:xalign:X alignment of the frame.
:yalign:Y alignment of the frame.
:yalign:Y alignment of the frame.
First the ``l,t,r,b`` fields restrict the available area for
First the ``l,t,r,b`` fields restrict the available area for
placing the frame. If ``w`` and ``h`` are not specified or
placing the frame. If ``w`` and ``h`` are not specified or
larger then the computed area, it becomes the frame. Otherwise
larger than the computed area, it becomes the frame. Otherwise
the smaller frame is placed within the are based on the
the smaller frame is placed within the are based on the
``xalign/yalign`` fields. If the align hints are omitted, they
``xalign/yalign`` fields. If the align hints are omitted, they
are assumed to be 0, 1, or 0.5 based on which of the ``l/r/t/b``
are assumed to be 0, 1, or 0.5 based on which of the ``l/r/t/b``
@ -4025,6 +4032,52 @@ following keyboard hotkeys:
- Ctrl-Left/Right arrow: move the cursor one word to the left or right.
- Ctrl-Left/Right arrow: move the cursor one word to the left or right.
- Alt-Left/Right arrow: move the cursor to the beginning/end of the text.
- Alt-Left/Right arrow: move the cursor to the beginning/end of the text.
Scrollbar class
---------------
This Widget subclass implements mouse-interactive scrollbars whose bar sizes
represent the amount of content currently visible in an associated display
widget (like a `Label class`_ or a `List class`_). By default they are styled
like scrollbars used in the vanilla DF help screens, but they are configurable.
Scrollbars have the following attributes:
:fg:Specifies the pen for the scroll icons and the active part of the bar. Default is ``COLOR_LIGHTGREEN``.
:bg:Specifies the pen for the background part of the scrollbar. Default is ``COLOR_CYAN``.
:on_scroll:A callback called when the scrollbar is scrolled. It will be called with a single string parameter with a value of "up_large", "down_large", "up_small", or "down_small".
The Scrollbar widget implements the following methods:
Updates the info about the widget that the scrollbar is paired with.
The ``top_elem`` param is the (one-based) index of the first visible element.
The ``elems_per_page`` param is the maximum number of elements that can be
shown at one time. The ``num_elems`` param is the total number of elements
that the paried widget can scroll through. The scrollbar will adjust its
scrollbar size and position accordingly.
Clicking on the arrows at the top or the bottom of a scrollbar will scroll an
associated widget by a small amount. Clicking on the unfilled portion of the
scrollbar above or below the filled area will scroll by a larger amount in that
direction. The amount of scrolling done in each case in determined by the
associated widget, and after scrolling is complete, the associated widget must
call ``scrollbar:update()`` with updated new display info.
You can click and drag the scrollbar to scroll to a specific spot, or you can
click and hold on the end arrows or in the unfilled portion of the scrollbar to
scroll multiple times, just like in a normal browser scrollbar. The speed of
scroll events when the mouse button is held down is controlled by two global
variables:
:``SCROLL_INITIAL_DELAY_MS``:The delay before the second scroll event.
:``SCROLL_DELAY_MS``:The delay between further scroll events.
The defaults are 300 and 20, respectively, but they can be overridden by the
user in their :file:`dfhack-config/init/dfhack.init` file, for example::
:lua require('gui.widgets').SCROLL_DELAY_MS = 100
Label class
Label class
-----------
-----------
@ -4045,17 +4098,6 @@ It has the following attributes:
keys to the number of lines to scroll as positive or negative integers or one of the keywords
keys to the number of lines to scroll as positive or negative integers or one of the keywords
supported by the ``scroll`` method. The default is up/down arrows scrolling by one line and page
supported by the ``scroll`` method. The default is up/down arrows scrolling by one line and page
up/down scrolling by one page.
up/down scrolling by one page.
:show_scrollbar:Controls scrollbar display: ``false`` for no scrollbar, ``'right'`` or ``'left'`` for
icons next to the text in an additional column (``frame_inset`` is adjusted to have ``.r`` or ``.l`` greater than ``0``),
``nil`` same as ``'right'`` but changes ``frame_inset`` only if a scroll icon is actually necessary
(if ``getTextHeight()`` is greater than ``frame_body.height``). Default is ``nil``.
:scrollbar_fg:Specifies the pen for the scroll icons and the active part of the bar. Default is ``COLOR_LIGHTGREEN`` (the same as the native DF help screens).
:scrollbar_bg:Specifies the pen for the background part of the scrollbar. Default is ``COLOR_CYAN`` (the same as the native DF help screens).
If the scrollbar is shown, it will react to mouse clicks on the scrollbar itself.
Clicking on the arrows at the top or the bottom will scroll by one line, and
clicking on the unfilled portion of the scrollbar will scroll by a half page in
that direction.
The text itself is represented as a complex structure, and passed
The text itself is represented as a complex structure, and passed
to the object via the ``text`` argument of the constructor, or via
to the object via the ``text`` argument of the constructor, or via
@ -4148,7 +4190,8 @@ The Label widget implements the following methods:
This method takes the number of lines to scroll as positive or negative
This method takes the number of lines to scroll as positive or negative
integers or one of the following keywords: ``+page``, ``-page``,
integers or one of the following keywords: ``+page``, ``-page``,
``+halfpage``, or ``-halfpage``.
``+halfpage``, or ``-halfpage``. It returns the number of lines that were
actually scrolled (negative for scrolling up).
WrappedLabel class
WrappedLabel class
------------------
------------------
@ -4276,7 +4319,6 @@ Every list item may be specified either as a string, or as a lua table
with the following fields:
with the following fields:
:text:Specifies the label text in the same format as the Label text.
:text:Specifies the label text in the same format as the Label text.
:caption, [1]:Deprecated legacy aliases for **text**.
:text_*:Reserved for internal use.
:text_*:Reserved for internal use.
:key:Specifies a keybinding that acts as a shortcut for the specified item.
:key:Specifies a keybinding that acts as a shortcut for the specified item.
:icon:Specifies an icon string, or a pen to paint a single character. May be a callback.
:icon:Specifies an icon string, or a pen to paint a single character. May be a callback.
@ -4437,7 +4479,7 @@ Functions
..note:: this is the only mandatory field.
..note:: this is the only mandatory field.
:fix_impassible:
:fix_impassible:
if true make impassible tiles impassible to liquids too
if true make impassable tiles impassable to liquids too
:consume:
:consume:
how much machine power is needed to work.
how much machine power is needed to work.
Disables reactions if not supplied enough and ``needs_power==1``
Disables reactions if not supplied enough and ``needs_power==1``
@ -4461,7 +4503,7 @@ Functions
:canBeRoomSubset:
:canBeRoomSubset:
a flag if this building can be counted in room. 1 means it can, 0 means it can't and -1 default building behaviour
a flag if this building can be counted in room. 1 means it can, 0 means it can't and -1 default building behaviour
:auto_gears:
:auto_gears:
a flag that automatically fills up gears and animate. It looks over building definition for gear icons and maps them.
a flag that automatically fills up gears and animations. It looks over the building definition for gear icons and maps them.
Animate table also might contain:
Animate table also might contain:
@ -4472,7 +4514,7 @@ Functions
``getPower(building)`` returns two number - produced and consumed power if building can be modified and returns nothing otherwise
``getPower(building)`` returns two number - produced and consumed power if building can be modified and returns nothing otherwise
``setPower(building,produced,consumed)`` sets current productiona and consumption for a building.
``setPower(building,produced,consumed)`` sets current power production and consumption for a building.
Examples
Examples
--------
--------
@ -4506,7 +4548,7 @@ Native functions provided by the `buildingplan` plugin:
* ``bool isPlanModeEnabled(df::building_type type, int16_t subtype, int32_t custom)`` returns whether the buildingplan UI is enabled for the specified building type.
* ``bool isPlanModeEnabled(df::building_type type, int16_t subtype, int32_t custom)`` returns whether the buildingplan UI is enabled for the specified building type.
* ``bool isPlannedBuilding(df::building *bld)`` returns whether the given building is managed by buildingplan.
* ``bool isPlannedBuilding(df::building *bld)`` returns whether the given building is managed by buildingplan.
* ``void addPlannedBuilding(df::building *bld)`` suspends the building jobs and adds the building to the monitor list.
* ``void addPlannedBuilding(df::building *bld)`` suspends the building jobs and adds the building to the monitor list.
* ``void doCycle()`` runs a check for whether buildlings in the monitor list can be assigned items and unsuspended. This method runs automatically twice a game day, so you only need to call it directly if you want buildingplan to do a check right now.
* ``void doCycle()`` runs a check for whether buildings in the monitor list can be assigned items and unsuspended. This method runs automatically twice a game day, so you only need to call it directly if you want buildingplan to do a check right now.
* ``void scheduleCycle()`` schedules a cycle to be run during the next non-paused game frame. Can be called multiple times while the game is paused and only one cycle will be scheduled.
* ``void scheduleCycle()`` schedules a cycle to be run during the next non-paused game frame. Can be called multiple times while the game is paused and only one cycle will be scheduled.
@ -4796,7 +4838,7 @@ These events are straight from EventManager module. Each of them first needs to
4. ``onJobCompleted(job)``
4. ``onJobCompleted(job)``
Gets called when job is finished. The job that is passed to this function is a copy. Requires a frequency of 0 in order to distinguish between workshop jobs that were cancelled by the user and workshop jobs that completed successfully.
Gets called when job is finished. The job that is passed to this function is a copy. Requires a frequency of 0 in order to distinguish between workshop jobs that were canceled by the user and workshop jobs that completed successfully.
5. ``onUnitDeath(unit_id)``
5. ``onUnitDeath(unit_id)``
@ -4855,7 +4897,7 @@ Functions
5. ``registerSidebar(shop_name,callback)``
5. ``registerSidebar(shop_name,callback)``
Enable callback when sidebar for ``shop_name`` is drawn. Usefull for custom workshop views e.g. using gui.dwarfmode lib. Also accepts a ``class`` instead of function
Enable callback when sidebar for ``shop_name`` is drawn. Useful for custom workshop views e.g. using gui.dwarfmode lib. Also accepts a ``class`` instead of function
as callback. Best used with ``gui.dwarfmode`` class ``WorkshopOverlay``.
as callback. Best used with ``gui.dwarfmode`` class ``WorkshopOverlay``.
Examples
Examples
@ -4898,7 +4940,7 @@ luasocket
=========
=========
A way to access csocket from lua. The usage is made similar to luasocket in vanilla lua distributions. Currently
A way to access csocket from lua. The usage is made similar to luasocket in vanilla lua distributions. Currently
only subset of functions exist and only tcp mode is implemented.
only a subset of the functions exist and only tcp mode is implemented.
..contents::
..contents::
:local:
:local:
@ -4977,7 +5019,7 @@ Functions
- ``render_map_rect(x,y,z,w,h)``
- ``render_map_rect(x,y,z,w,h)``
returns a table with w*h*4 entries of rendered tiles. The format is same as ``df.global.gps.screen`` (tile,foreground,bright,background).
returns a table with w*h*4 entries of rendered tiles. The format is the same as ``df.global.gps.screen`` (tile,foreground,bright,background).
.._pathable-api:
.._pathable-api:
@ -5094,7 +5136,7 @@ Scripts
:local:
:local:
Any files with the ``.lua`` extension placed into the :file:`hack/scripts` folder
Any files with the ``.lua`` extension placed into the :file:`hack/scripts` folder
are automatically made avaiable as DFHack commands. The command corresponding to
are automatically made available as DFHack commands. The command corresponding to
a script is simply the script's filename, relative to the scripts folder, with
a script is simply the script's filename, relative to the scripts folder, with
@ -13,36 +13,36 @@ for the tag assignment spreadsheet.
"when" tags
"when" tags
-----------
-----------
- `tag/adventure`: Tools that are useful while in adventure mode. Note that some tools only tagged with "fort" might also work in adventure mode, but not always in expected ways. Feel free to experiment, though!
- `adventure <adventure-tag-index>`: Tools that are useful while in adventure mode. Note that some tools only tagged with "fort" might also work in adventure mode, but not always in expected ways. Feel free to experiment, though!
- `tag/dfhack`: Tools that you use to run DFHack commands or interact with the DFHack library. This tag also includes tools that help you manage the DF game itself (e.g. settings, saving, etc.)
- `dfhack <dfhack-tag-index>`: Tools that you use to run DFHack commands or interact with the DFHack library. This tag also includes tools that help you manage the DF game itself (e.g. settings, saving, etc.)
- `tag/embark`: Tools that are useful while on the fort embark screen or while creating an adventurer.
- `embark <embark-tag-index>`: Tools that are useful while on the fort embark screen or while creating an adventurer.
- `tag/fort`: Tools that are useful while in fort mode.
- `fort <fort-tag-index>`: Tools that are useful while in fort mode.
- `tag/legends`: Tools that are useful while in legends mode.
- `legends <legends-tag-index>`: Tools that are useful while in legends mode.
"why" tags
"why" tags
----------
----------
- `tag/armok`: Tools that give you complete control over an aspect of the game or provide access to information that the game intentionally keeps hidden.
- `armok <armok-tag-index>`: Tools that give you complete control over an aspect of the game or provide access to information that the game intentionally keeps hidden.
- `tag/auto`: Tools that run in the background and automatically manage routine, toilsome aspects of your fortress.
- `auto <auto-tag-index>`: Tools that run in the background and automatically manage routine, toilsome aspects of your fortress.
- `tag/bugfix`: Tools that fix specific bugs, either permanently or on-demand.
- `bugfix <bugfix-tag-index>`: Tools that fix specific bugs, either permanently or on-demand.
- `tag/design`: Tools that help you design your fort.
- `design <design-tag-index>`: Tools that help you design your fort.
- `tag/dev`: Tools that are useful when developing scripts or mods.
- `dev <dev-tag-index>`: Tools that are useful when developing scripts or mods.
- `tag/fps`: Tools that help you manage FPS drop.
- `fps <fps-tag-index>`: Tools that help you manage FPS drop.
- `tag/gameplay`: Tools that introduce new gameplay elements.
- `gameplay <gameplay-tag-index>`: Tools that introduce new gameplay elements.
- `tag/inspection`: Tools that let you view information that is otherwise difficult to find.
- `inspection <inspection-tag-index>`: Tools that let you view information that is otherwise difficult to find.
- `tag/productivity`: Tools that help you do things that you could do manually, but using the tool is better and faster.
- `productivity <productivity-tag-index>`: Tools that help you do things that you could do manually, but using the tool is better and faster.
"what" tags
"what" tags
-----------
-----------
- `tag/animals`: Tools that interact with animals.
- `animals <animals-tag-index>`: Tools that interact with animals.
- `tag/buildings`: Tools that interact with buildings and furniture.
- `buildings <buildings-tag-index>`: Tools that interact with buildings and furniture.
- `tag/graphics`: Tools that interact with game graphics.
- `graphics <graphics-tag-index>`: Tools that interact with game graphics.
- `tag/interface`: Tools that interact with or extend the DF user interface.
- `interface <interface-tag-index>`: Tools that interact with or extend the DF user interface.
- `tag/items`: Tools that interact with in-game items.
- `items <items-tag-index>`: Tools that interact with in-game items.
- `tag/jobs`: Tools that interact with jobs.
- `jobs <jobs-tag-index>`: Tools that interact with jobs.
- `tag/labors`: Tools that deal with labor assignment.
- `labors <labors-tag-index>`: Tools that deal with labor assignment.
- `tag/map`: Tools that interact with the game map.
- `map <map-tag-index>`: Tools that interact with the game map.
- `tag/military`: Tools that interact with the military.
- `military <military-tag-index>`: Tools that interact with the military.
- `tag/plants`: Tools that interact with trees, shrubs, and crops.
- `plants <plants-tag-index>`: Tools that interact with trees, shrubs, and crops.
- `tag/stockpiles`: Tools that interact wtih stockpiles.
- `stockpiles <stockpiles-tag-index>`: Tools that interact with stockpiles.
- `tag/units`: Tools that interact with units.
- `units <units-tag-index>`: Tools that interact with units.
- `tag/workorders`: Tools that interact with workorders.
- `workorders <workorders-tag-index>`: Tools that interact with workorders.
@ -33,12 +33,31 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future
# Future
## New Plugins
## Fixes
## Misc Improvements
- `ls`: indent tag listings and wrap them in the right column for better readability
- `ls`: new ``--exclude`` option for hiding matched scripts from the output. this can be especially useful for modders who don't want their mod scripts to be included in ``ls`` output.
- `digtype`: new ``-z`` option for digtype to restrict designations to the current z-level and down
- UX: List widgets now have mouse-interactive scrollbars
- UX: You can now hold down the mouse button on a scrollbar to make it scroll multiple times.
- UX: You can now drag the scrollbar to scroll to a specific spot
## Documentation
## API
## Lua
- ``widgets.Scrollbar``: new scrollbar widget that can be paired with an associated scrollable widget. Integrated with ``widgets.Label`` and ``widgets.List``.
# 0.47.05-r7
## New Plugins
## New Plugins
- `autonestbox`: split off from `zone` into its own plugin. Note that to enable, the command has changed from ``autonestbox start`` to ``enable autonestbox``.
- `autonestbox`: split off from `zone` into its own plugin. Note that to enable, the command has changed from ``autonestbox start`` to ``enable autonestbox``.
- `autobutcher`: split off from `zone` into its own plugin. Note that to enable, the command has changed from ``autobutcher start`` to ``enable autobutcher``.
- `autobutcher`: split off from `zone` into its own plugin. Note that to enable, the command has changed from ``autobutcher start`` to ``enable autobutcher``.
- `overlay`: display a "DFHack" button in the lower left corner that you can click to start the new GUI command launcher.
- `overlay`: display a "DFHack" button in the lower left corner that you can click to start the new GUI command launcher. The `dwarfmonitor` weather display had to be moved to make room for the button. If you are seeing the weather indicator rendered over the overlay button, please remove the ``dfhack-config/dwarfmonitor.json`` file to fix the weather indicator display offset.
## New Tweaks
## New Internal Commands
## New Internal Commands
- `tags`: new built-in command to list the tool category tags and their definitions. tags associated with each tool are visible in the tool help and in the output of `ls`.
- `tags`: new built-in command to list the tool category tags and their definitions. tags associated with each tool are visible in the tool help and in the output of `ls`.
@ -49,6 +68,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `dig-now`: Fix direction of smoothed walls when adjacent to a door or floodgate
- `dig-now`: Fix direction of smoothed walls when adjacent to a door or floodgate
- ``job.removeJob()``: ensure jobs are removed from the world list when they are canceled
- ``job.removeJob()``: ensure jobs are removed from the world list when they are canceled
- `quickfort`: `Dreamfort <quickfort-blueprint-guide>` blueprint set: declare the hospital zone before building the coffer; otherwise DF fails to stock the hospital with materials
- `quickfort`: `Dreamfort <quickfort-blueprint-guide>` blueprint set: declare the hospital zone before building the coffer; otherwise DF fails to stock the hospital with materials
- ``dfhack.buildings.findCivzonesAt``: no longer return duplicate civzones after loading a save with existing civzones
## Misc Improvements
## Misc Improvements
- Init scripts: ``dfhack.init`` and other init scripts have moved to ``dfhack-config/init/``. If you have customized your ``dfhack.init`` file and want to keep your changes, please move the part that you have customized to the new location at ``dfhack-config/init/dfhack.init``. If you do not have changes that you want to keep, do not copy anything, and the new defaults will be used automatically.
- Init scripts: ``dfhack.init`` and other init scripts have moved to ``dfhack-config/init/``. If you have customized your ``dfhack.init`` file and want to keep your changes, please move the part that you have customized to the new location at ``dfhack-config/init/dfhack.init``. If you do not have changes that you want to keep, do not copy anything, and the new defaults will be used automatically.
@ -86,6 +106,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- ``Gui::getSelectedItem()``, ``Gui::getAnyItem()``: added support for the artifacts screen
- ``Gui::getSelectedItem()``, ``Gui::getAnyItem()``: added support for the artifacts screen
- ``Units::teleport()``: now sets ``unit.idle_area`` to discourage units from walking back to their original location (or teleporting back, if using `fastdwarf`)
## Lua
## Lua
- History: added ``dfhack.getCommandHistory(history_id, history_filename)`` and ``dfhack.addCommandToHistory(history_id, history_filename, command)`` so gui scripts can access a commandline history without requiring a terminal.
- History: added ``dfhack.getCommandHistory(history_id, history_filename)`` and ``dfhack.addCommandToHistory(history_id, history_filename, command)`` so gui scripts can access a commandline history without requiring a terminal.