86 Commits

Author SHA1 Message Date
luk3yx
710a380d46 Do not add empty style elements 2024-12-30 11:08:13 +13:00
luk3yx
f306f01f57 Luanti rename, add ButtonURL support 2024-11-08 15:52:39 +13:00
luk3yx
136f2b1637 Explain why string.len is used 2024-09-14 20:23:12 +12:00
luk3yx
4563382551 Prevent crash when using numbers as labels
Closes https://gitlab.com/luk3yx/minetest-flow/-/merge_requests/1
2024-09-14 20:17:03 +12:00
luk3yx
e0626bdb42 Relicense to LGPL 2.1+
I think it's unlikely that flow will be used in the main menu, but now
licensing (hopefully) won't be an issue
2024-08-28 17:47:06 +12:00
Jo5629
38f09bedf3
Add pwdfield to default_value_fields (#17)
`pwdfield[]` doesn't actually have a "default" value, but flow uses default_value_fields for form input handling, and this seems better than adding a special case for it.
2024-08-17 12:01:33 +12:00
luk3yx
4a185105c3 Fix logic 2024-08-13 18:50:41 +12:00
luk3yx
e27b34700a Remove unused code, add missing check 2024-08-13 18:49:29 +12:00
luk3yx
d990864834 Fix tests 2024-08-13 10:27:34 +12:00
luk3yx
150cef9399 Change prefix of auto-generated field names
Fixes behaviour with https://github.com/minetest/minetest/pull/14878

I've also added a workaround to preserve the current behaviour of
dropdowns that don't have index_event set.
2024-08-13 10:22:47 +12:00
Lazerbeak12345
1528e87864
feat: Embed support (#15)
Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>
2024-07-25 19:40:18 +12:00
luk3yx
da87496e26 Add listcolors to invisible_elems 2024-06-30 21:32:35 +12:00
luk3yx
13136ab2dc Add enter_after_edit parameter to Field
Closes https://gitlab.com/luk3yx/minetest-flow/-/issues/3
2024-06-18 15:02:14 +12:00
luk3yx
a3523c7073 The example form doesn't show a field by default 2024-05-18 19:25:56 +12:00
luk3yx
45363ee461 Minor performance improvement
It turns out that formspec_ast.find is quite slow, moving the
field_close_on_enter code to the new shorthand elements insertion
improves performance (at least on my rudimentary benchmarks of the
example form) and probably negates the overhead added by the inline
styles/tooltips code.
2024-05-18 19:24:12 +12:00
luk3yx
b42a9dc1be Make luacheck happy 2024-05-15 10:52:13 +12:00
luk3yx
5215229d8c Add inline styles and tooltips 2024-05-15 10:49:36 +12:00
luk3yx
6c48ccd446 Fix crash 2023-08-12 10:57:13 +12:00
luk3yx
918002d505 Even more input validation 2023-08-08 21:55:09 +12:00
luk3yx
6745777bfc Make __newindex a table 2023-08-05 14:27:08 +12:00
luk3yx
f5b7bc796a Add additional input validation
This makes it harder to crash mods that aren't expecting malicious
formspec input.

I don't like the large amount of unit tests but I don't see how to avoid
them and arguably those tests should have been there beforehand anyway.
2023-08-04 19:05:53 +12:00
luk3yx
57c1e20ace Reset bgimg style when centering labels 2023-07-08 12:17:30 +12:00
luk3yx
eb7cd77a23 Fix tabheader positioning when both width and height specified
Tabheaders without both a width and height specified still won't work properly.
2023-07-05 14:30:53 +12:00
luk3yx
18538ffd46 Always centre labels with align_h = "centre"
Previously flow wouldn't correctly centre labels that it thought were
already as wide as the box they were in.
2023-07-04 09:38:10 +12:00
luk3yx
8a924bbc7c Bugfix 2023-06-16 14:08:51 +12:00
luk3yx
4046fed55f Translate labels before calculating their size
I've made a new naive_str_width function that tries to estimate the
width of UTF-8 text and is faster than strip_escape_sequences on LuaJIT
(I guess because there isn't an intermediate string being created).

Closes #4
2023-06-16 14:06:32 +12:00
Lazerbeak12345
5bb5dba625
feat: add locale support (#9)
Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>
2023-06-11 22:10:19 +12:00
luk3yx
4ccabcef0f Bugfix 2023-06-07 22:46:32 +12:00
luk3yx
a1e7eff2ff Replace background[] with image[] in gui.Stack 2023-06-07 22:39:57 +12:00
luk3yx
c336abde7e Fix bgimg in embedded render_to_formspec_string 2023-06-07 21:51:09 +12:00
luk3yx
20b99efaf3 Fix comment 2023-06-01 17:09:19 +12:00
luk3yx
c32ea53fd1 Fix compatibility hack 2023-06-01 17:08:33 +12:00
luk3yx
b4a72ade99 Add compatibility hack 2023-06-01 17:05:25 +12:00
Lazerbeak12345
35fa361f8d
fix: bgcolor settings for root node (#7) 2023-06-01 16:56:03 +12:00
luk3yx
238e432251 Don't save fields with an empty name 2023-05-30 16:26:45 +12:00
Lazerbeak12345
435efd014e
feat(flow.widgets): Add nil gui object (#6)
Skipped over by rendering library, and not included in output formspec.
2023-04-19 16:54:04 +12:00
luk3yx
7b25bc6083 Remove outdated comment 2023-04-12 20:14:17 +12:00
luk3yx
000bd976c2 Fix license comment 2023-04-12 20:11:36 +12:00
luk3yx
cdb4e61ca9 Remove unused debug code 2023-04-08 13:29:10 +12:00
Lazerbeak12345
60d2674a45
feat: Add render_to_formspec_string function (#5)
Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>
2023-04-08 13:13:44 +12:00
luk3yx
fa13e188f9 Increase formspec version to 6
This should mean that older clients still show images that have the
"middle" parameter set
2023-04-07 08:49:15 +12:00
luk3yx
d0b1825281 Fix label offset when using a fixed field size 2023-04-02 20:35:58 +12:00
luk3yx
49fd7ec541 Fix 2023-04-02 14:50:51 +12:00
luk3yx
7987799f44 Fix bug with non index_event dropdowns
Translated strings in dropdowns would previously have had the escape
code stripped which would break things.
2023-04-02 14:48:48 +12:00
luk3yx
272fa1ecfa Make luacheck happy 2023-04-02 08:49:15 +12:00
luk3yx
3a8fd8765e Remove undocumented parameter, lower limit again 2023-04-02 08:29:33 +12:00
luk3yx
2efe09c2c3 Strip control characters (subject to change) 2023-03-31 21:11:20 +13:00
luk3yx
1f754aac83 Lower length limit 2023-03-28 14:58:57 +13:00
luk3yx
353d8c7a0b Improve field handling 2023-03-28 14:53:28 +13:00
Lazerbeak12345
bba30cc267
feat: Add set_as_inventory_for API function (#2)
Adds the `Form:set_as_inventory_for(player, [ctx])` API.

Also includes:

 • `Form:unset_as_inventory_for(player)`
 • Extends private `show_form` to account for inv edge cases
 • Extends private `on_fs_input` to account for inv edge cases
 • Adds several abstraction functions
 • Add feature to `on_leaveplayer` to delete the inv formspec state as well
 • Add a few unit tests for related features
2023-03-26 15:44:31 +13:00