Commit Graph

109 Commits

Author SHA1 Message Date
haven1433
5cc08ba4ea show errors when thumb is too large to compile 2025-12-14 10:20:37 -06:00
haven1433
1fb8ac7924 handle linux newlines during paste 2025-12-13 09:31:47 -06:00
haven1433
47d5aa830d new features
* squiggle errors for pokemon names / moves in trainer editor
* filtering for block behaviors
* image editor hover position and selection size displayed
* name hints for blocksets in the map header
2025-12-12 21:27:19 -06:00
haven1433
e4473d1a40 code tool fixes
the 'delay' logic is still in, but a few things happen instantly now rather than getting delayed. Specifically, HMA will run the "insert missing closers" bit immediately, which should reduce cursor jumps.
2025-12-01 20:27:38 -06:00
haven1433
a8716acd53 script compilation after delay
makes the script editor go faster if they're still typing.
2024-10-05 18:22:44 -05:00
haven1433
32bebb384b fix script selection bug
if the script start changes and the script end doesn't change, we still need to update the script shown in the code tool.
2024-06-02 15:52:42 -05:00
haven1433
9a4dcca602 fix autocomplete when changing script types
matters for when you jump directly from a battle script to an event script. Not only do we need the syntax highlighting to update, but also the auto-complete options
2024-05-30 19:37:36 -05:00
haven1433
55d8e861cc don't calculate code tool content unless it's in use 2023-12-11 07:35:02 -06:00
haven1433
80817b36a3 fix <auto> complete
the cursor-save system didn't always work correctly. Replace it with a "deferred cursor set" that happens only with auto. In other cases, the cursor is just set based on the changed text (such as adding {}).
2023-11-28 21:36:14 -06:00
haven1433
c12d15bb04 scripts should continue formatting after an early end 2023-10-01 12:12:46 -05:00
haven1433
5e5060f9ac prefer unique section names when multiple CodeBody objects are available 2023-08-24 21:07:03 -05:00
haven1433
daff211a62 fix script find uses
* find uses should show for flags
* find uses should select the entire command/event that uses the flag/var, instead of just the flag value
2023-08-21 20:53:48 -05:00
haven1433
4d2675f564 support completion tips for mart content in scripts 2023-08-20 22:14:07 -05:00
haven1433
90586953e4 attention to new codebody when added 2023-08-18 21:22:06 -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
81143627a7 fix bug with displaying errors 2023-07-31 22:57:46 -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
62a4e493b2 Text improvements
* Show error underline in both script editor and npc textbox in map editor.
* Let model calculate invalid length, so we can underscore the entire error length.
* Load error when first showing a code body, instead of waiting for an edit
2023-07-14 19:59:12 -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
556eb3627c fix possible crash when working at the end of a script 2023-07-08 22:05:45 -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
6880808551 add <auto> automatically after a space
turn this feature off if the user hits backspace after the insertion. Turn it back on if the user types auto themselves.
2023-07-02 14:42:07 -05:00
haven1433
c678ec7f7b goto source right-click option for scripts (prototype) 2023-07-01 22:42:55 -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
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
292935e152 improve performance
For script performance:
* call data.GetGameCode() less often, using a cached value for the ScriptParser
* use a 4-byte game code instead of string parsing for the game code

For map previews in the table tool performance
* Don't use dispatcher foreground/background thread swapping, it's safe to add the previews to the collection from the background thread.
* Check the exit condition more often

For drawing performance:
* Use Array.Copy when we don't need to worry about Transparency, since it's much faster.
* Make `Darken` faster, we call it a lot
* Reuse DarkenRect utility in HighlightCollision

Other performance changes
* Protototype for ObserableList<T> for a more configurable version of ObservableCollection
2023-05-21 20:34:12 -05:00
haven1433
675b124457 fix script length calculation bug
Situation:
* Script A refers to B and C. B and C occur right after eachother.
* Scirpt B does not refer to script C, so C doesn't get included in the same body.
-> when editing B, B needs to know that its length does not include C. So the script-length-cache that B uses shouldn't know about C, since B doesn't refer to C.
-> Therefore, B can't use the same cache as A.
* track length caches based on the code body start, not based on the entire model. This lets each code body have its own cache.
2023-05-12 08:05:38 -05:00
haven1433
d0f64db1fa update script keywords when address changes
otherwise it's possible to jump directly from a battle script to an event script and have the keywords not update
2023-05-10 07:36:28 -05:00
haven1433
fdc891bf0a script editor: don't add pointer formats to sources that have moved 2023-04-24 07:05:39 -05:00
haven1433
6ef8253e02 fix cursor when resolving ?????? addresses
doing <??????> auto-included a new {} block, which is cool. But that block needs to not be included when calculating the new cursor position, because the cursor position should remain _before_ the new {}, so it's still on the same line in case you're writing `trainerbattle` or something with multiple pointers in the line.
2023-03-18 21:47:00 -05:00
haven1433
60e8910578 in case of repoint, track the new code address correctly
useful to prevent the cursor from going crazy during a repoint operation
2023-03-18 21:25:32 -05:00
haven1433
f648df04cf script editor improvements
* when jumping to a script from a map, format the script. This gets us things like text/marts immediately, instead of needing to load, then edit, to see runs that the script points to.
* When editing a script, keep better track of the cursor, so it doesn't jump around when the script address changes or a pointer within the script changes.
2023-03-17 20:50:07 -05:00
haven1433
0e518c4c37
Get all tests passing (#122)
* submit failing tests

* Grab failing trainer test from remote branch (#121)

* Updated flash constants

* Fixed flash constant locations

I originally supplied anchor references, not locations of the constants themselves. That's been fixed. Also, I changed the field name for flash.radius, so it's hopefully clearer.

* Fixed some other pointer issues with RAM addresses in script commands

RAM addresses can't be encased in <> nicely. Some commands still needed their RAM-address pointers to have the ::|h formatting instead.

* Fixing some parameter formats in the script reference file.

There were a few other commands that needed RAM-address parameters set to their correct format so that typing "2024284" doesn't auto format to 0xA024284, etc.

* update script reference (again)

* Added a failing test for duplicating trainer data

Bug report in query: https://discord.com/channels/538022037718040588/538022038376415234/1083215729177931877

---------

Co-authored-by: ShinyTillDawn <80070404+ShinyTillDawn@users.noreply.github.com>

* Fix test

ExportTilesetWithPalette2_EditTileset_ImportTilesetWithPalette2_DataMatches
-> fix formatting in LzSpriteRun
-> fix overflow error in SpriteRun
-> fix default palette detection in SpriteTool
-> improve test so it gives better failure info

* fix trainer duplication assert

fix test name / remove unneeded comments
handle Trainer team runs specially
update assertion error message

* Improve pointer error logic

Pointers are allowed to point into the middle of an existing run. Such a pointer is an error, but is not a metadata inconsistency. Update metadata checking for new logic. Update pointer logic to display pointer as an error.

* improve handling of `auto`

allow <auto> to be used if there's a one-byte gap

* improve interruptingSourceRun logic

an interrupting table is not always valid.
It's only valid if the source is at an index that would make it a pointer.

* don't clear bytes, clear anchors

If you have a custom anchor name in the middle of a script and then edit the script, that custom anchor name will be lost. But anything pointing to it will still point to it.

---------

Co-authored-by: ShinyTillDawn <80070404+ShinyTillDawn@users.noreply.github.com>
2023-03-10 21:40:55 -06:00
haven1433
e65644a236 repoint scripts based on previous script size, not computed size from model 2023-03-05 21:39:19 -06:00
haven1433
10f177154c fix broken tests 2023-03-04 22:00:44 -06:00
haven1433
43542dcf17 don't create orphans while no-edit formatting a script
When scripts get merged together, some inner-scripts no longer appear to be real scripts. These were showing up as orphans when the scripts get formatted, since that causes scripts to get merged. But the pointers are still there, so they're not actually orphans.

Fix the orphan-naming logic so that it won't name things as orphans if they're inner scripts that still have pointers
2023-03-04 21:33:49 -06:00
haven1433
8896946db2 ai script performance updates
ai script children should appear as ai scripts
editing an AI script shouldn't make a bunch of orphans
introduce a light caching system for noticing when scripts don't need to be loaded again.
script edits that don't change any compiled bytes should be capable of skipping the metadata update in situations where the metadata is already correct
2023-03-03 22:10:49 -06:00
haven1433
1688ad8d5c r10 through r15 are valid thumb variable names 2023-03-01 22:25:49 -06:00
haven1433
303bb131a3 <auto> improvements
* Selecting brock's script should select the _whole_ script
* Get correct number of code sections when scripts point to freespace
* Make sure script concatenation works correctly for `goto` followed by `end` (vanilla games do this a lot)
* multiple if statements / gotos all get compiled into one script, so long as it's all contiginous script data
* make sure `trainerbattle 01` works correctly with labels
* include blank line separators between labels when decompiling scripts
2023-01-24 20:26:46 -06:00
haven1433
5371397475 first part of <auto> support 2022-12-18 10:26:02 -06:00
haven1433
66f3bd9006 syntax highlighting for multiline comments 2022-12-06 21:40:45 -06:00
haven1433
a185ebe207 track cursor when changing text during script compiles
for example, when adding {} to the end of a script, or when changing ?????? to an actual address
2022-12-04 23:04:57 -06:00
haven1433
7d8ae74a00 script bugfixes
add enum types for fanfare / bufferitem
allow script constants to contain underscores
allow autocomplete for constants that are the last argument
allow 'find usages -> scripts' to find usages from macros (and fix crash)
2022-12-04 22:38:04 -06:00
haven1433
380738609b draft of auto-complete for script tool 2022-12-03 19:09:31 -06:00
haven1433
bf1d30fe7d more macros
also clear constant cache when refreshing ViewPort
2022-12-02 23:28:56 -06:00
haven1433
830740ad34 script editor is now colored 2022-12-02 20:44:59 -06:00
haven1433
4e7148a5f6 thumb editor is now colored 2022-12-02 11:35:24 -06:00
haven1433
f4221580c1 allow resizing for code tool content (ctrl+scroll) 2022-11-02 09:00:12 -05:00