Commit Graph

192 Commits

Author SHA1 Message Date
haven1433
ae873de5bd improve command-show conditions
makes it more likely to show line completion for things like trainerbattle
2023-11-15 07:09:00 -06:00
haven1433
fa8def2e77 support <auto> for sprite templates 2023-10-28 22:54:39 -05:00
haven1433
545b3b316e add names for common variables
temps and vars
2023-10-28 20:36:07 -05:00
haven1433
b053c4e58c fix sort order of macro argument for autocomplete / help 2023-10-27 06:53:00 -05:00
haven1433
6366403e7c fix broken tests 2023-10-01 13:58:06 -05:00
haven1433
53b4ed35e0 allow scripts to see scripts before they start 2023-10-01 12:50:07 -05:00
haven1433
c12d15bb04 scripts should continue formatting after an early end 2023-10-01 12:12:46 -05:00
haven1433
5dc7eaecda refactor
ScriptParser.cs is getting too long
* move ScriptLine and related types to their own file
* move ScriptArg and related types to their own file
2023-10-01 12:12:10 -05:00
haven1433
55b3cfbbd4 allow value offsets for non-enum in scripts 2023-09-30 17:42:07 -05:00
haven1433
c50c42cdcd split tokens on tabs 2023-09-30 16:53:22 -05:00
haven1433
b37acb160c add autocomplete to script editor
* Autocomplete Overlay supports TextEditor
* Add Overlay to CodyBody's ControlTemplate
* Don't show help tip when autocomplete is showing
* 3 categories of autocomplete:
-> streams
-> arguments
-> commands
2023-09-30 16:49:12 -05:00
haven1433
3161bac7e4 better error when names contain quotes 2023-09-30 12:58:46 -05:00
haven1433
39d3c339dc watch for errors in script templates
fix error in tutor template
2023-09-30 12:47:17 -05:00
haven1433
d45bf408f1 guard against crash in content help for scripts 2023-09-30 12:32:31 -05:00
haven1433
5a4e49d0fb simplify message in script help -> command usage 2023-09-07 21:15:02 -05:00
haven1433
e04da2f899 documentation improvements
pull examples from actual code, semi-randomly. This takes a lot longer, but produces much better documentation, including realistic values and streams.
2023-09-07 20:58:00 -05:00
haven1433
27de9dc88b in a script, error if the user types something that doesn't parse when a number is expected 2023-09-06 21:55:51 -05:00
haven1433
5e5060f9ac prefer unique section names when multiple CodeBody objects are available 2023-08-24 21:07:03 -05:00
haven1433
ca41b67dd8 don't include keywords for other games 2023-08-23 07:33:18 -05:00
haven1433
554c0d1dd5 improve sorting order for elements
`IndexOfPartial` now uses improved sort order.
Improved sort order now prefers shorter tokens over longer tokens (PIDGEOT before PIDGEOTTO)
GetBestOptions now uses SortOptions
TrainerPokemonTeamRun now uses SortOptions for autocomplete
Update tests based on new expected sort orders
2023-08-22 23:23:25 -05:00
haven1433
1935411543 only allow a 2/3 byte gap if we're joining data.
Scripts still are limited to only a 1-byte gap.
2023-08-21 19:58:15 -05:00
haven1433
bf43d8bc40 ExtractLocalLabels should only consider commands that match the current game 2023-08-21 19:56:53 -05:00
haven1433
4d2675f564 support completion tips for mart content in scripts 2023-08-20 22:14:07 -05:00
haven1433
ac1f6dedc5 compile error on invalid command 2023-08-18 21:20:37 -05:00
haven1433
cc66577c01 implement autocomplete for script commands
when typing a script command, when you press space, it'll autocomplete to the 'best' match. So if you forget a period or capital letter, it'll still work the way you expect.
2023-08-16 22:25:27 -05:00
haven1433
2a57fb4c28 pokemart data needs to be 4-byte aligned
When creating pokemart data using <auto>, make sure the resulting data is 4-byte aligned.
2023-08-13 23:16:49 -05:00
haven1433
b8aa9ee781 smarter line splitting during scripts 2023-08-13 22:28:56 -05:00
haven1433
d32c0c2e1d count empty lines when adding error squiggles 2023-08-13 11:43:42 -05:00
haven1433
db232c9675 Improve hover help logic 2023-08-02 23:11:00 -05:00
haven1433
b6cfcb3577 hide filler arguments 2023-07-31 23:03:57 -05:00
haven1433
0914efdb62 improve matching algorithm
instead of just preferring to match the lowest possible ID that counts as a partial match, add some extra criteria to make it act closer to how people expect.
* prefer entries where no letters are skipped
* prefer entries where the start of the partial matches the start of the full
2023-07-31 22:35:22 -05:00
haven1433
788d343357 text warnings get orange underline, not red underline (warning, not error) 2023-07-31 20:48:08 -05:00
haven1433
a958748824 script improvements: double-click highlight and tips
double-click on a command should highlight the entire command, even if it's a macro with `.`s.
When selecting a command, show the help tip for it.
2023-07-31 20:40:52 -05:00
haven1433
435a36a535 Add human-readable documentation for scripts 2023-07-14 06:44:03 -05:00
haven1433
c7485c5275 bugfixes from testing
* pressing escape should close the script tip
* fix automatic inclusion of <auto> behavior
* Fix possible crash when looking for closing } when there isn't one
* Only update TextEditor layers if they've changed (performance)
* creating a new event script should include lock/faceplayer/release
* adjust focus when switching tabs (close open tips)
* only try to access list coments if the list isn't null
2023-07-12 21:32:44 -05:00
haven1433
cce2153c2b fix broken macro-arg-order conversion 2023-07-08 22:22:01 -05:00
haven1433
46f57a0a97 add error underlines for scripts 2023-07-08 00:05:34 -05:00
haven1433
daea25bd4e make it possible to add comments to list elements
right now the comments are only shown by the script editor. But they could be added to other things too, like maybe wild pokemon rates?
2023-07-07 08:58:16 -05:00
haven1433
f14b44eb5e decompiled scripts now have sections appearing in address order
instead of labeling sections based on what address calls them, label section based on what order they appear in memory.
2023-07-01 21:40:59 -05:00
haven1433
e095bace1e beef up insert missing closers
make the caret adjust correctly
insert a blank line between {}
move {} to newlines
2023-06-30 08:04:14 -05:00
haven1433
6fc0f568dc Basic implementation for flag/vars show&tell
Currently hidden
2023-06-29 19:31:08 -05:00
haven1433
348e1e5b96 don't combine scripts if an anchor has multiple pointers 2023-06-26 23:08:27 -05:00
haven1433
cc383f59a3 allow decompiled scripts to use anchor names 2023-06-26 22:22:21 -05:00
haven1433
d072b42e57 Track multi-pointer commands correctly when using multiple <auto> 2023-06-21 20:26:21 -05:00
haven1433
97f5bb7589 self-referential scripts should add script formatting 2023-06-19 21:53:24 -05:00
haven1433
f724f70cdb Improve memory allocation
* Avoid using foreach/enumorables in `MacroScriptLine.Matches` since it's called so often.
* Use Span<char> to reduce string allocations in `ArrayRun.ctor` and `ArrayRunEnumSegment.GetOptions`
2023-06-14 22:31:55 -05:00
haven1433
bd35c3deb3 decrease memory footprint
* don't store the delta object used for initial setup
* avoid making lambdas in `ScriptLine.Matches`, which is called very often.
* use use List<int> instead of SortedSpan<int> for building the initial DestinationToSource cache, since we're already guaranteed that they'll be added in order and without duplicates. This greatly reduces the number of int[] arrays created during startup.
* allow `ArrayRunPointerSegment` to cache the table content results from parsing its InnerFormat, so it doesn't have to re-parse each time. This greatly reduces the number of string allocations.
* Use `ThreadSafeDictionary` for `TryGetValueCaseInsensitive` so we don't need to create a new collection of keys each time we call the method. Also add key caching to `ThreadSafeDictionary` so we don't need to make a new collection each time it's requested.
* Make `GetOptions` return a readonly list. We already know it's unique, this means we don't have to make a new collection every time we parse segments.
* limit the number of undo tokens we store (default 100) to save memory
* Use `byte[]` and `Array.Copy` instead of `List<byte>` and `AddRange` to reduce byte array allocations when loading a file.
* Freeze geometries in the `Icons` collection.
* add option for running garbage collection from the developer menu
* use a custom `AutomationPeer` to prevent WPF from holding memory after controls have been closed.
2023-06-14 20:54:36 -05:00
haven1433
8f131f1bfa fix label resolution for data pointers
Only allow adding unresolved labels for script pointers
2023-06-14 00:18:35 -05:00
haven1433
e39ace9b7d script parser improvements
make it possible for a script edit to expand the rom, rather than running out of space.

make a leading `0x` work for commands that expect pointers
2023-06-04 21:39:11 -05:00
haven1433
ed4a6f755c allow script macros to be game-specific 2023-06-04 20:59:47 -05:00