Commit Graph

127 Commits

Author SHA1 Message Date
haven1433
2bef8d62f0 write updated run after deserializing 2023-03-17 22:04:30 -05:00
haven1433
d547f88ebc insert end token when writing a movement stream
note that this could be dangerous, since we're writing an end token to an arbitrary address that is still being decided on. A couple things mitigate this problem:
* the user can use <auto> pointers in scripts
* addresses won't be checked/used unless the user has both an open < and a close >.
2023-03-17 15:06:21 -05:00
haven1433
542ac1ca86 auto-include closing } after inserting a { 2023-03-17 14:27:23 -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
4959d8f8ca don't auto-format script pointers in edge cases
* points to itself? Don't add the format
* points into existing data? Don't add the format
2023-03-07 07:29:37 -06:00
haven1433
ccbdca51f3 support |z suffix for arguments in script reference files 2023-03-05 21:39:41 -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
3fdb3a8028 improve caching for improved performance
don't re-calculate the length of scripts if nothing has changed
2023-03-03 22:46:17 -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
7e6dc34302 use decorations instead of mart for pokemart2
And fix name to decorationmart
2023-03-02 19:48:30 -06:00
haven1433
800aee0361 fix crash in script editor 2023-02-02 07:44:56 -06:00
haven1433
4badfe06b9 ai scripts can end with more commands 2023-02-01 21:35:24 -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
2b8c35c1d5 <auto> improvements
if the last thing is a label, make sure to include an end command for it
if the last thing isn't an end command (or goto, etc) make sure to include an end command for it
2023-01-22 21:25:31 -06:00
haven1433
f74c1abd45 include unused labels at end of script 2023-01-22 20:20:16 -06:00
haven1433
7d1e6065d5 ScriptParser updates
* add a basic limiter so that parsing scripts will 'give up' if they get the same 0-arg command 20 times
* fix crash that could happen sometimes when trying to check a pointer for sources during script decoding
* don't try to decode streams as scripts (misuse of the destinations collection)
2023-01-21 21:29:49 -06:00
haven1433
e55ef5c8a3 Include sub-scripts from scripts that were combined with the current script
Since scripts don't always end at an `end` or `goto` anymore (if there's a label from within the script to directly after the script), we need to make sure that these appended scripts still get a chance to add more scripts into the UI.
2023-01-21 20:41:42 -06:00
haven1433
65e534a46d map editor fixes
* say width/height correctly in the tooltips of the map size handles
* less flickering during undo
* include default OW sprite instead of blank (for example, tutorial catch man in viridian city)
* speed up the initial script-check process that looks for default trainer sprites for each OW by not caring about the length of child scripts
* use proper thread locking during block cache invalidation and renewal so that undo doesn't mess up the number of blocks shown in the block panel
2023-01-04 23:06:51 -06:00
haven1433
fe07a3e458 <auto> pointer bugfix 2022-12-22 17:26:56 -06:00
haven1433
c4dba402cb battlescript bugfixes 2022-12-22 17:26:35 -06:00
haven1433
5ab843d3b2 implement game-specific macros 2022-12-21 22:47:41 -06:00
haven1433
2c52358396 Compile / Decompile improvements
* when docompiling, don't include a box that contains a partial script that's already in the main box
* when compiling, require arg counting for getting macro length
2022-12-21 08:33:53 -06:00
haven1433
3e16f8ee20 add stream content recursively for scripts
This should make <auto> able to work even when there are scripts that point to scripts, as the content will appear after the last attached script.
2022-12-20 22:34:26 -06:00
haven1433
3b6a18072f improving auto support
for mart, movement, and if statements
2022-12-20 14:29:20 -06:00
haven1433
5371397475 first part of <auto> support 2022-12-18 10:26:02 -06:00
haven1433
6874768ffc additional macros
support for out-of-order macro commands
also allows for arguments to be applied multiple times
2022-12-15 08:06:26 -06:00
haven1433
66f3bd9006 syntax highlighting for multiline comments 2022-12-06 21:40:45 -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
4a5f351d6f final fixes for 0.5
givePokemon, use item constants
fix crashes/errors in hover-tip logic for trainerbattle commands
* tested that macros and array args still work right
2022-12-03 22:50:33 -06:00
haven1433
88e90f980c fix completion tips for array-arg and 0-arg commands 2022-12-03 21:24:05 -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
d6d6a6c54f initial macro support 2022-12-02 22:41:39 -06:00
haven1433
830740ad34 script editor is now colored 2022-12-02 20:44:59 -06:00
haven1433
c0f3ade883 allow script lines to have multiple stream sections 2022-12-02 10:22:00 -06:00
haven1433
a44841290f first pass at updating script pointer logic
instead of the script line itself knowing that it points to something,
pull it down to the argument level, so that each argument knows
if it points to something.

This will allow a single script line to point to multiple things (like trainers pointing to multiple text or scripts)
2022-12-02 08:38:21 -06:00
haven1433
4c2089196b usability feedback
label stuff
center new connections
berry shortcuts
fix goto shortcuts
2022-11-24 11:24:56 -06:00
haven1433
e285eaaf7b add 'scripts' option to 'show uses' button
Unlike the other ones, this one doesn't pre-calculate, and may end up being empty when you click on it.
2022-11-23 08:26:46 -06:00
haven1433
d350c6bfa9 fix ai scripts for emerald 2022-11-22 08:52:52 -06:00
haven1433
6a703c1fae call UpdateFromParent when updating TableStream via textbox 2022-11-18 09:10:31 -06:00
haven1433
d09b3c32c7 finish more templates 2022-11-07 21:56:39 -06:00
haven1433
b4f4e86277 don't clear the newgame pokemon tables
These were being cleared because they existed within scripts. Make the script ClearFormat logic smarter so it skips tables that align to single arguments.
2022-10-04 23:05:32 -05:00
haven1433
4317864b64 fix disappearing script section bug 2022-10-04 16:58:45 -05:00
haven1433
7a6ba78d94 fix {} creation after <??????>
Only add the {} if there isn't one already
2022-09-28 22:19:06 -05:00
haven1433
7a6ce76b23 serialize null list items as numbers
also fix width on script tooltip
2022-09-22 07:36:26 -05:00
Haven1433
29092415a6 multi-select
and some flag-based utilities
and hide layoutID
2022-09-16 21:27:55 -05:00
Haven1433
ee28bc8a02 initial ai script support 2022-09-12 20:23:40 -05:00
Haven1433
610171b59a fix broken behavior
New rule: when clearing format and the run starts _before_ what we're clearing, leave the pointers and a NoInfoRun. Before this rule, we would clear out the anchor as well, which could cause some confusion if that anchor/format was re-added later, since it wouldn't know about tables that point to it.

Fix bug in script parser: next text runs should know about pointers to them
2022-09-11 20:59:35 -05:00
Haven1433
52880278ea update battleScriptReference
thanks to AGSMG for helping to fill out some of these missing details
2022-09-01 12:45:33 -05:00