Commit Graph

211 Commits (92537bc4596392188863b15b38e1119bc575467b)

Author SHA1 Message Date
myk002 43b1abcdcf support submit2 for EditFields 2022-08-15 16:24:34 -07:00
myk002 a4c8535977 add argparse int checking methods, more docs 2022-08-15 16:15:41 -07:00
myk002 a8d0cc7980
support scrolling by half pages in Label 2022-08-06 23:48:25 -07:00
myk002 e677e8098d
add docs for plugins that only provide Lua apis 2022-07-27 15:48:11 -07:00
myk002 6b1c0b5308
rename building-hacks section 2022-07-25 06:53:08 -07:00
myk002 629c22b148
update docs for building-hacks 2022-07-18 16:38:28 -07:00
myk002 f354200728
update widget docs 2022-07-16 22:23:22 -07:00
myk002 27425e47f6
support cursor movement in EditFields 2022-07-15 22:22:51 -07:00
myk002 9b340a7630
support submit2 for EditFields 2022-07-15 13:46:01 -07:00
Tachytaenius 0e704f39f7 Got the really big part of the guide done 2022-07-15 19:28:59 +01:00
myk002 c9a87511bd
add dfhack history repository and expose to lua 2022-07-15 09:18:27 -07:00
Tachytaenius 063e4897a8 Forgot to stage a change 2022-06-20 20:31:19 +01:00
Warmist fc384fd1a2
Update eventful.lua (#2203)
* Update eventful.lua

Had wrong function. Fixes https://github.com/DFHack/dfhack/issues/2202

* Update Lua API.rst

Update docs to add onReactionCompleting and remove outdated info

* Update Lua API.rst

Some more minor doc fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add changelog entry

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-12 07:12:49 -07:00
Ryan Williams f993c23d75
fix whitespace 2022-06-04 12:22:19 -07:00
Ryan Williams 23e85a0d24 Fetch and merge 2022-06-04 12:17:28 -07:00
Ryan Williams b0b601cf0f
Remove recenterViewscreen, update revealInDwarfmodeMap 2022-06-04 11:59:04 -07:00
Myk 89d3d45e87
Allow EditField widgets to manage their own activation and keyboard focus (#2147)
* use new focus subsystem in widgets.EditField

* always eat the enter key if we have an on_submit

* add modal attribute

* give EditFields a default height of 1

so they can be autoarranged
2022-06-01 21:48:21 -07:00
Myk ad2d9cad03
[lua] implement keyboard focus subsystem (#2160)
* implement keyboard focus subsystem

* Fix error in focus group combining

* documentation for the inputToSubviews decision

* modify unit tests to catch that last bug
2022-06-01 17:42:13 -07:00
Ryan Williams 1c3ea000e1
Trim trailing whitespace 2022-05-28 15:56:49 -07:00
Ryan Williams 2b29431806
More fixes
* Use word_wrap()

* add_proper_report utility fn; have addCombatReportAuto use this

* Update Lua API.rst

* Update Gui.cpp
2022-05-28 12:35:49 -07:00
Ryan Williams 4b21e7afb4
Remove parseReportString from API (now utility fn)
Implementations using `word_wrap()` are commented out pending changes to that function.
2022-05-24 03:52:33 -07:00
myk002 18628ff5b8 make key_sep more configurable
and add more configuration to HotkeyLabel and EditField to take
advantage of it
2022-05-18 16:46:33 -07:00
Ryan Williams ce34ac8f33
Use debugfilter; remove redundant changelog entries 2022-05-16 18:41:47 -07:00
Ryan Williams 5be0fe2a44
Fix issues, update changelog and docs
Initialize variables in LuaApi.cpp, solve changelog conflicts, hyperlink and escape char info in docs
2022-05-02 23:52:47 -07:00
Ryan Williams 621ccef996
Merge branch 'develop' into Bumber64-patch-2 2022-05-01 23:42:21 -07:00
Ryan Williams f565de88e8
Fix stuff (#4)
* Update Lua API.rst

* Update Gui.h

* Update Gui.cpp

* Update LuaApi.cpp
2022-05-01 22:53:53 -07:00
Josh Cooper fe29bff845
Adds cxxrandom unit test and fixes interface problems (#2099)
* Adds cxxrandom unit test and fixes interface problems

* Tightens braces

* Adds detection code for Shuffle's seqID/engID

* Adds usage examples for cxxrandom

* Gives cxxrandom objects id ranges, sort of

* Updates changelog

* Updates changelog.txt

* Increases id space for cxxrandom

* Fixes bool distribution error message and improves check

* Adds comment explaining the seeded RNG tests for cxxrandom

* Fixes type problem for 32bit builds

* Reduces loop count a few magnitudes

* Fixes a mistake in test.cxxrandom_seed
2022-04-30 21:46:47 -07:00
Tachytaenius b9c36c1e63
Added custom-raw-tokens utility (#2038)
* Added (chain) for [CHAIN_METAL_TEXT] armours in gui/materials.lua used by gui/create-item-- again (oops)

* Added customRawData utility

* Oops, whitespace

* Revised rawStringsFieldNames

* Dialed down on lua trickery and fixed wrongly formatted changelog entry

* Fixed changelog in wrong place and made customRawData a proper module

* Fixed not caching not-present tags, revised examples and fixed error

* Fixed whitespace. Changing settings in editor!

* customRawData docs

* Added getCreatureTag for respecting caste tags, "fixed" bizarre caching error (quotes because I don't even know what was causing it) and updated docs

* Added line limiting for docs, I guess

* Added missing string convert argument

* docs indent fix, code block fix, and revision

* Major revision

* gdi, docs error

* Another? But... huh.

* ...

* Made requested changes

* Whoops

* Rearrange docs lines

* Followed example, should fix linter issues

* fix typo. linted offline this time......

* Make it so that last instance of tag is what is read from

* Added requested change

* eventful key change

* i to lenArgs

* change eventful key

* add test for broken caste selection

* Major redesign

* tags --> tokens

* Added plant growth behaviour and did some requested changes

* More error handling

* fix docs

* Added basic error suppression

* Docs clarification.

* Docs registering example and fix error

* Strip errors on frame after onWorldLoad, not on map load

* Revert "Strip errors on frame after onWorldLoad, not on map load"

This reverts commit e20a0ef8d3743f79d961077f46910b77b16f36b9.

* Revert "Docs registering example and fix error"

This reverts commit 9c848c54c3f84e0ecc1dc421137c8a8b4a52280d.

* Revert "Docs clarification."

This reverts commit 6b4b6a1aa40c50398504f37ecf1ff0f93d6459b1.

* Revert "Added basic error suppression"

This reverts commit d11cb1438cf1e56ff700469e944f0b9af64651d7.

* Use more eventful key more consistent with other files

* use onStateChange instead of eventful and remove redundant utils require

* Code review stuff

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update docs/Lua API.rst

committing a suggestion

Co-authored-by: Alan <lethosor@users.noreply.github.com>

* Prepend examples with DFHACK_

* Remove unused parameters

* Use new ensure_key global

* Named a couple of unnamed arguments (untested)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alan <lethosor@users.noreply.github.com>
2022-04-29 08:39:59 -07:00
Timur Kelman f08a268e8a
add scroll icons to Label widget (#2101)
* WIP: add scroll icons to Label widget

It's an opt-out. The icons are rendered in the right-most column of the 1st and last row. They are only rendered when text can actually be scrolled in the corresponding direction.

WIP: Currently, the icons might overlay text characters, there is no mechanism preventing it

* gui.lua: expose the `parse_inset()` function

* refactor Label's scroll icon code

* since `render_scroll_icons` only works with a label, it's now a class function
* `update_scroll_inset` ensures `frame_inset.r` or `.l` is at least 1, according to `show_scroll_icons`
* `show_scroll_icons` has 4 possible values: `false` for no icons, `left` for icons on the first column on the left (also ensuring `frame_inset.l >= 1`), `right` - last column on the right, `DEFAULT_NIL` - same as `right` if text height greater than `frame_body.height`, else same as `false`.

* make `render_scroll_icons` always draw icons

The check now happens in `onRenderFrame`

* draw frame's background

calling `Label.super.onRenderFrame(self, dc, rect)` makes frame's background invisible for some reason

* remove trailing spaces

* fix scroll icons placed far above/below text

 With `Label.frame_inset = 1` the text could be vertically centered with plenty of space below and above,
but not all rendered. Before this change, the scroll icons would be at the very top and bottom of the frame
instead of near the first and last rendered text line.

* always `update_scroll_inset` to react to resized window

* draw scroll icons next to text

* update `Lua API.rst` with new `Label` parameters

* move comment separator up

This way every scroll related parameter is in one group

* list default values for new parameters in docs

* add missing description of `Label.scroll_keys`
2022-04-29 06:55:08 -07:00
Ryan Williams c89baa5e33
Update Lua API.rst 2022-04-28 22:40:36 -07:00
myk002 dcadde38d7 add new global function: ensure_key 2022-04-27 17:35:49 -07:00
Ryan Williams ad9a08f1e7
Update Lua API.rst
Fix formatting (again)
2022-04-25 00:10:26 -07:00
Ryan Williams 709adda968
Update Lua API.rst
Fix formatting
2022-04-25 00:06:53 -07:00
Ryan Williams c66448015e
Update Lua API.rst
Document autoDFAnnouncement, pauseRecenter, and recenterViewscreen.
2022-04-25 00:02:37 -07:00
myk002 ed5523152c
factor text wrapping out of TooltipLabel into WrappedLabel 2022-04-22 09:53:10 -07:00
myk002 07761e1d5d add some more handy widgets to the library
TooltipLabel
HotkeyLabel
CycleHotkeyLabel
ToggleHotkeyLabel
2022-04-18 17:37:11 -07:00
Timur Kelman cb123e5076
default unset `frame_inset` values to 0 (#2100)
* default unset `frame_inset` values to 0

This change allows writing `frame_inset = {r=1}` instead of `frame_inset = {l=0, r=1, t=0, b=0}`
2022-04-16 08:17:35 -07:00
Myk fd1ee233a2
automatically manage sidebar modes in MenuOverlay (#2083) 2022-04-11 20:58:54 -07:00
Myk 10f22ecc27
add ResizingPanel class and autolayout for Panels (#2086)
* add autolayout for Panels and new ResizingPanel
2022-04-11 18:25:00 -07:00
Myk 4f9608da13
Document and update argparse module (#2089)
also add unit tests and use new string fns in processArgs and allow it to recognize parameters with two dashes instead of just one
2022-04-11 16:16:55 -07:00
Myk 96b5b4420b
Add string:escape_pattern() utility function (#2082)
* add string:escape_pattern() to dfhack.lua

stolen from devel/query.lua. will migrate scripts to use the common implementation later
2022-04-10 21:18:01 -07:00
Myk c603d6a9f3 Move docs for include_prefix param to correct function
It was listed under listdir, but it only appears in listdir_recursive
2022-04-08 23:13:10 -07:00
Ryan Williams 88b403ec7a
Add functions reverse-engineered from ambushing unit code (#1992)
* Add functions reverse-engineered from ambushing unit code

* Fix whitespace

* Fix debug_showambush check

* Remove getOuterContainerRef from Lua API

Don't think this works properly without allocating a new specific_ref. More trouble that it's worth.

* Fixed tile visibility check

* I don't think gamemode or gametype are ever NULL

* Minor tweaks to documentation

* Reimplement getOuterContainerRef for Lua; fix some comments

* Update Units.cpp and changelog

* Update Units.cpp
* Update changelog.txt
2022-03-13 17:19:35 -07:00
Ryan Williams bc042bc7df
Use copyall instead of nesting pos2xyz and xyz2pos 2021-12-18 02:05:16 -08:00
myk002 7f0c3cc7e4
document dig-now lua api 2021-07-30 13:09:19 -07:00
Ryan Williams a67a5d8283
Rename getPlantAtCoords to getPlantAtTile 2021-06-23 22:58:24 -07:00
Ryan Williams 60fe864426
Update Lua API.rst 2021-06-22 20:10:25 -07:00
lethosor 2fc5fbacb5
Merge remote-tracking branch 'myk002/myk_reveal_unhideFlood' into develop 2021-06-19 01:08:05 -04:00
myk002 fc860478e4
move fastdwarf's teleport code to Units module
and expose in Lua API
2021-06-06 08:48:32 -07:00
myk002 fb8d6614c7
expose core flood unhide logic to Lua
refactor is a straight copy-paste. this code could really stand some
cleanup (unused vars, unnecessary use of the MapCache layer, forced
allocation of all blocks even if they are not being unhidden, etc.), but
that can come in a later PR.
2021-06-02 14:49:19 -07:00
lethosor 4f976a5909
Merge remote-tracking branch 'myk002/myk_blueprint' into develop 2021-05-24 23:48:21 -04:00
lethosor 001e608aa7
Fix invalid role name
Resolves #1851

See https://github.com/sphinx-doc/sphinx/pull/8345 for details
2021-05-11 19:46:01 -04:00
myk002 265f17a53f
update blueprint docs 2021-05-10 21:11:13 -07:00
lethosor d61c4aa234
Merge remote-tracking branch 'myk002/myk_xlsxreader_classes' into develop 2021-03-27 00:10:03 -04:00
myk002 222feff342
expand docs for open and close functions 2021-03-22 10:44:32 -07:00
myk002 4ef0ff2a24
fix formatting errors 2021-03-22 10:40:29 -07:00
myk002 aac958aa50
add open() wrapper fn and document class methods 2021-03-22 09:38:20 -07:00
Gabe Rau 81b6d93701 Minor grammer fixes. 2021-03-20 15:51:35 -06:00
Gabe Rau cc376eeb55 Fixed a number of spelling and grammatical errors. Should be set now. Added better examples and removed redundant words. 2021-03-20 15:49:53 -06:00
Gabe Rau 374fc763eb Fixed whitespace issues that cause a failed build on lint. 2021-03-20 01:55:45 -06:00
Gabe Rau e6639180db Fixed merge conflicts, expanded upon provided examples, added more detail. 2021-03-20 01:47:36 -06:00
Gabe Rau 5aa3c6bfc6 Revised Lua API.rst to better explain command. Added proper examples and explantion of difference between run_command and run_script. 2021-03-19 21:58:24 -06:00
Gabe Rau a77353b2e6
Update Lua API.rst
Corrected the dfhack.run_script documentation and added an example.
2021-03-17 23:17:01 -06:00
myk002 69a2f44020
Lua class wrappers for the xlsxreader plugin API 2021-03-08 15:04:50 -08:00
lethosor 4a7fcc6118
Fix plugin name in error, add link in docs
Ref #1769
2021-02-25 00:41:13 -05:00
myk002 9e17bc938c
only set labor validity for the player civ 2021-02-17 09:16:49 -08:00
myk002 09d91dcae1
move alchemist-enabling logic to autohauler 2021-02-06 14:14:08 -08:00
myk002 6819ee9928
make alchemist flag valid for controllable civs 2021-02-05 16:45:39 -08:00
lethosor 614ea739d0
Merge branch 'develop' into lua-runcommand 2021-01-08 20:45:23 -05:00
Timur Kelman a69c4b9b6d
fix example in Lua API.rst
Whitespace in the wrong place.
2021-01-04 17:05:55 +01:00
myk002 3ba984c22c
only reset extents if they are unusable
this allows callers of Buildings::setSize() to "pre-initialize" the
extents to declare non-rectangular structures. this allows quickfort to
create non-rectangular stockpiles, farm plots, zones, etc. the extents
are still reset as before if the size of the building doesn't match the
caller's expectations.

this commit also fixes a memory leak when setSize() allocates memory for
extents, but the memory is not deallocated if the building is ultimately
invalid for some reason.
2020-12-16 11:10:47 -08:00
lethosor b4c040291f
Document dfhack.run_command() and related functions/constants 2020-11-20 22:23:29 -05:00
lethosor 8319d71dff
Improve documentation of reqscript, dfhack_flags, etc. 2020-11-15 18:42:14 -05:00
lethosor 2e4f23d49f
Merge remote-tracking branch 'myk002/myk_isplannedbuilding' into develop 2020-11-13 14:09:36 -05:00
lethosor 8cb38ecf5b
Merge remote-tracking branch 'myk002/myk_metalhead_mario' into develop 2020-11-13 14:04:30 -05:00
myk002 efdba8b596
add buildingplan.isPlannedBuilding 2020-11-13 10:18:54 -08:00
myk002 93d9ac76be
update docs 2020-11-12 23:08:22 -08:00
lethosor 913d860ae4
Use initial working directory as process path on Linux, and expose to Lua 2020-11-12 19:07:51 -05:00
lethosor 23b230495e
Merge branch 'develop' into cwd-handling 2020-11-12 18:44:05 -05:00
lethosor 9c13b497bf
Merge remote-tracking branch 'myk002/myk_automaterial_buildingplan_fix' into develop 2020-11-11 23:36:42 -05:00
lethosor 0958fdbf4b
Document script paths
Ref #1690
2020-11-10 00:48:27 -05:00
Myk Taylor 22ac163d55 improve UX between automaterial and buildingplan
solves the confusing behavior when both automaterial and buildingplan
are enabled for constructions. the two plugins now communicate with each
other over the Lua layer to negotiate consistent behavior.

if neither plugin is enabled, the standard DF UI acts as normal

if automaterial is enabled but buildingplan is not, then automaterial
behavior is unchanged.

if buildingplan is enabled and automaterial is not then behavior is
the same as other buildings with buildingplan (no material selection
screen, screen stays on building placement screen after placement).
this commit fixes a bug, though, where buildingplan would only lay
down a single tile of contruction instead of a solid block when a
block is requested.

if both plugins are enabled but buildingplan is not enabled for the
building type then automaterial is unchanged from previous behavior,
execpt for an additional header showing the separation between
automaterial hotkeys and buildingplan hotkeys.

finally, if both plugins are enabled and buildingplan is enabled for the
building type then buildingplan behavior prevails, but the box select and
hollow designations features of automaterial are still usable and
useful. the 'Auto Mat-select', 'Reselect Type', and "Open Placement"
automaterial hotkeys are hidden in the UI and ignored in the feed. This
is because buildingplan takes over material selection, so 'Auto
Mat-select' doesn't make sense. Buildingplan also already stays on the
placement screen after placement, so 'Reselect Type' is not necessary.
And all buildingplan-placed buildings have relaxed placement
restrictions (e.g. they can be built in mid-air) so 'Open Placement' is
also not necessary. The missing options are replaced with blank lines so
the vertical alignment of all other options stays constant.

we also remove a few extra lua_pop() calls that are made superfluous by
the StackUnwinder.
2020-10-29 11:00:49 -07:00
lethosor 4301252ddf
Merge remote-tracking branch 'myk002/buildingplan_refactor2_squashed' into develop 2020-10-23 13:51:54 -04:00
lethosor 26505acb70
Add some cross-references and clean up 2020-10-20 01:18:25 -04:00
lethosor 2bd0e938ad
Move pathable to Lua API docs 2020-10-20 01:11:01 -04:00
lethosor 84973d1fb8
Sort plugins in Lua API.rst 2020-10-20 01:06:47 -04:00
lethosor ce7772a1c2
Add Filesystem::restorecwd()
This allows restoring the working directory to its original value, which may not actually be the DF root. See #1671, dfhack/scripts#152
2020-10-14 21:22:53 -04:00
Myk Taylor 9d2abafefc Merge branch 'buildingplan_refactor' into buildingplan_refactor2_squashed 2020-10-11 12:11:51 -07:00
lethosor 9c8098b4f0
Expose to_search_normalized to Lua, add test, and use in ListColumn (most useful for the `stocks` plugin) 2020-10-10 01:40:00 -04:00
lethosor 2382247398
Update some docs links to use HTTPS 2020-10-09 19:17:59 -04:00
lethosor 28efe1d2a7
Add local TOCs to Lua API plugin sections 2020-10-09 12:20:13 -04:00
lethosor c2280356cb
Set language of some code blocks to enable syntax highlighting 2020-10-09 01:15:42 -04:00
Myk Taylor 4d7f4d80ad prep buildingplan for core algorithm changes
player-visible changes
- removed text that showed up if you used the wrong hotkeys. no other
  dfhack screen does this, and it seems unneeded. can add back if others
  think otherwise, though

internal changes
- changed signature of lua-exported isPlannableBuilding to take subtype
  and custom type in addition to building type. this is only used by
  quickfort, and it already sends all three params in preparation for
  this change
- added lua-exported scheduleCycle(), which is like doCycle(), but only
  takes effect on the next non-paused frame. this lets quickfort
  run only one buildingplan cycle regardless of how many #build
  blueprints were run
- declared a few dfhack library methods and params const so buildingplan
  could call them from const methods
- converted buildingplan internal debug logging fn to have a printf api
- reshaped buildingplan-planner API and refactored implementation in
  preparation for upcoming core algorithm changes for supporing all
  building types (no externally-visible functionality changes)
  - changed df::building_type params to type, subtype, custom tuple keys
  - introduced capability to return multiple filters per building type
    (though the current buildings all only have one filter per)
- split monolith hook functions in buildingplan.cpp into one per scope.
  this significantly cleans up the code and preps the hooks to handle
  iterating through multiple item filters.
- got rid of send_key function and replaced with better reporting of
  whether keys have been handled
2020-10-04 20:05:08 -07:00
lethosor 3c037ef52a
Clean up plugin mkmodule/require explanation 2020-09-24 00:16:32 -04:00
Myk Taylor 72fb6d09d6 Merge remote-tracking branch 'upstream/develop' into buildingplan_isenabled 2020-09-23 19:21:16 -07:00
lethosor dfac5bc143
Update gui.Painter docs, add sections to dfhack.screen, add more links, etc 2020-09-23 22:00:39 -04:00
Myk Taylor 12769de232 revert dup isEnabled and document real isEnabled 2020-09-22 23:24:20 -07:00
Myk Taylor c6111ba017 expose if buildingplan is enabled to lua 2020-09-20 16:38:26 -07:00
lethosor 8779ca0659
Merge remote-tracking branch 'myk002/quickfort_civzones' into develop 2020-08-21 00:34:26 -04:00
lethosor 7bac4c89c4
Update API docs for setJobCooldown and removeWorker, use "cooldown" for consistency with C++
Ref http://www.bay12forums.com/smf/index.php?topic=164123.msg8180385#msg8180385
2020-08-19 17:12:40 -04:00