Commit Graph

346 Commits

Author SHA1 Message Date
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
6f7029f193 code to protect against UpdateNewRunFromPointerFormat returning a run with no length
This can happen if the run fails to generate due to a data conflict, such as in fr omega where a text run overwrites the first byte of a trainer team run
2022-12-11 21:01:06 -06:00
haven1433
30026eea8d first pass at universal-branch-link feature
this allows us to select/cut/paste thumb routines safely
2022-12-09 00:09:42 -06:00
haven1433
d6d6a6c54f initial macro support 2022-12-02 22:41:39 -06:00
haven1433
c0f3ade883 allow script lines to have multiple stream sections 2022-12-02 10:22:00 -06:00
haven1433
fd8d6a0330 Improve palette-picking for goto shortcut buttons
also make tooltip images have a transparent background
2022-11-28 20:22:36 -06:00
haven1433
8214ba845b add a sanity check for checking pointers 2022-11-15 22:21:36 -06:00
haven1433
5543b64e15 bugfixes
* bitfields should support names with the `'` character.
* don't let tables/ascii runs go past the end of the file
* don't let arrays have zero length per element
* allow editing record enums in tables
* don't create change tokens when no change is needed
2022-11-14 22:08:02 -06:00
haven1433
e1da957c30 don't allow image formats to have 0 width/height/tiles 2022-11-14 07:25:59 -06:00
haven1433
614a619ead table streams should know about pointers to the passed-in run
needed for parent-length streams to get the right length
2022-11-13 00:50:33 -06:00
haven1433
b0306dc401 code cleanup 2022-11-11 14:52:51 -06:00
haven1433
d3d2422ec0 fix decap algorithm
Now works right for capital letters that come after escape bytes
also fix random crash in ModelTable string recognition
also fi random assert from adding an anchor to a pointer
2022-11-01 23:36:40 -05:00
haven1433
a78ca56744 appending to a table should refresh the table view
so that new elements can be seen when in single-table-focus

don't write runs into other runs when changing pointers in text-pointer tables.
2022-10-23 20:09:47 -05:00
haven1433
93ccd80230 fix metadata creation issues
* if adding a new run would overwrite the pointer that made us want to add it, stick with a no-info run.
* if adding a palette would cause us to overwiret a pointer that made us want to add it, stick with a no-info run
2022-10-22 21:28:52 -05:00
haven1433
3615c5174c fix liquid crystal patch metadata bug
* add debug message for non-positive run lengths
* add a sanity check for the number of pokemon in a trainer team. In vanilla it'll never be more than 6, so put a reasonable cap of 1000 on it to prevent possible integer overflows
* make sure that a missing map names table doesn't cause issues
2022-10-21 07:40:17 -05:00
haven1433
a371b65a15 fix bugs
* don't freeze when AMap saves
* allow edit->paste to target the ViewPort even if it doesn't have focus
* notify on repoint
* command to jump to data in the viewport
* show hover point in the corner
* finish script UI (add, remove, edit)
* find record fields when doing Show Uses
* tooltip for address for rom overview
2022-10-19 20:00:24 -05:00
haven1433
dc7878b0f0 bugfixes
* make sure the model length changes after importing a sprite causes the rom to auto-expand
* require less freespace by default as excess to a run being expanded, and require less freespace buffer placed after runs.
* fix double-click crashes reported by wet blanket
* if Ctrl+F is used before the rom finishes loading, wait for the rom to finish loading before trying to do the find.
*
2022-10-16 22:24:50 -05:00
haven1433
ce3d307251 bug fixing
* fairy script wasn't adding correctly
* right-click menus for inner-pointers weren't showing the right addresses
* appending a table and then updating the new pointer to point into a new table wasn't clearing the old pointer location from the old anchor
* search was causing thread-lock issues
* Display As Text was causing thread-lock issues
* python tool needs to update related fields when updating a table (structType, child table length from parent)
* fix character set issues
* fix crashes with mapper when tables don't have expected elements
* fix showing map options when there's no mapper
* improve handling of custom character escape sequences
* truncate text in tooltips
2022-10-10 21:33:57 -05:00
haven1433
03b0198207 be more surgical with locking during Initialize 2022-10-02 00:33:49 -05:00
haven1433
0f3748419b lock like you mean it
change all instances of lock (runs) to lock (threadlock) so that there's just one master threadlock that's used when accessing / editing the runs collection.

All public methods that access or edit the runs collection are now protected by the threadlock.

PLEASE tell me I didn't accidentally cause a deadlock here...
2022-10-01 22:20:54 -05:00
haven1433
26103602dd improve text finding logic
When the asks HMA to recognize something as text, be smarter about working around things HMA thinks it has found.
* Be able to find text despite false PCSRun/NoInfoRun runs.
* Be able to find text despite false pointers
* Make sure that this new logic doesn't accidentally clear tables.
2022-09-30 22:21:33 -05:00
haven1433
5813fd00f7 Fix table-stream expansion logic
Normally, HMA allows you to extend a table by typing a `+` directly after the table. But for tables that have an end-token, they should instead be expanded by typing `+` over the end token `[]`.
2022-09-30 15:50:34 -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
b5817e65cf fix table expansion anchor glitch
Expanding a table where the last element has a named anchor adds another pointer to that anchor. Some format types, such as palettes, do a ClearFormat when adding the new run. This is reasonable, but causes us to lose any custom name attached to those elements, which update their pointers to point to null and adds the name to the unmapped anchor names list.

In this case, we need to track the name before we clear the format, so that when we add the new run, we can add the name as well.
2022-09-28 20:47:09 -05:00
haven1433
b8108e7638 Improve upgrade logic
When updating to a new version, don't upgrade tables that have been edited by the user.
2022-09-20 22:49:04 -05:00
haven1433
a8a13bea8b fix code that broke tests 2022-09-19 22:44:10 -05:00
haven1433
cfcc02d5dc fix possible crash 2022-09-19 19:16:45 -05:00
Haven1433
1ac960a477 support Goto 2022-09-15 08:03:04 -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
262180bee0 use a threadsafe dictionary for address/anchor mapping
In rare cases, you can get a race condition where we try to turn the address-for-anchor keys into a list while also adding a new address-for-anchor key. This multi-threaded work can crash the app.

Use a thread-locking version of version of the dictionary to prevent Keys from being accessed at the same time as Add.
2022-08-30 21:42:01 -05:00
Haven1433
131eca5481 Don't double-clear anchors during script edits
Double-clearing it is a problem if it's created in the same token, because then it counts as clearing something that isn't there... which means that undoing the interaction will bring back an anchor, even though it wasn't there to begin with.
2022-08-25 20:47:59 -05:00
Haven1433
c45b9347a1 export table group hash 2022-06-18 22:21:52 -05:00
Haven1433
774eaa6514 Exporting a list maintains its previous hash
If the hash doesn't match the list, HMA knows that the user edited it, and won't replace that list during metadata upgrades.
2022-06-18 22:06:24 -05:00
Haven1433
aef73703fd Use future object for Find results
This prevents the creation of a change token unless one is actually needed.
2022-06-17 20:18:56 -05:00
Haven1433
07658b2a0d first pass at map tileset animation editor
map tileset animations consist of 3 parts:
(1) an `init` routine that sets a hook and some Max values
(2) a callback that runs every frame that decides whether or not to animate
(3) a set of uncompressed tiles to replace existing tiles in the tileset

For each replacement effect, you need to know how many frames are in the animation, how often to update to the next frame, how many tiles to replace, which tiles to replace, and the new tiles to insert. This is handled by a new table that's created specifically for this purpose, where the first field of the table is a pointer to a table of frames. This should make it a bit easier to understand, but a good user guide is still needed for this feature.

This doesn't work yet: there's an issue with the thumb code import step. But this is a first draft.
2022-06-07 23:30:09 -05:00
Haven1433
59a965c7f1 Clear Format before adding constant
Shiny discovered a rom where the constant is added on top of a pointer. This is no good, because the constant replacing the pointer didn't clear the pointer from the anchor it points at.

Add logic to clear the format before adding the constant.
2022-06-02 22:09:52 -05:00
Haven1433
65765e695f Allow Text Macros
* Replace the static PCSString.Convert method with an instance method on a TextConverter that's owned by the Model. The TextConverter can know about different macros depending on which rom is being edited.
* Add macros to pcsReference.txt
2022-06-02 20:53:39 -05:00
Haven1433
3d98a79478 model pointer improvements
When generating a default anchor name, make sure that name isn't already in use.
When generating a default anchor name, put it in `misc.temp.`. Don't save anchors in from namespace to the toml file. This should make cut/paste operations less prone to adding noise to the toml.
2022-05-29 23:25:09 -05:00
Haven1433
ca04d5db32 don't copy the anchor unless the entire run is selected
This should improve copy/paste scenarios where the user wants to copy the content from the first element and paste it somewhere else within the same (or a similar) run, without negatively effecting the common cut/paste operation of moving an entire run to a new address.
2022-05-29 21:48:30 -05:00
Haven1433
873e5c104b slight refactoring
Don't need to call ResolveConflicts 3 times during start up
2022-05-28 20:42:39 -05:00
Haven1433
213b7b0fc8 undo/redo bugfix 2022-05-24 20:27:14 -05:00
Haven1433
91530a51f1 improve contest support 2022-05-22 21:03:53 -05:00
Haven1433
3f91e469d2 fix crash 2022-05-16 21:49:51 -05:00
Haven1433
ea37075c43 Delete from end of file should not cause asserts 2022-05-06 22:26:43 -05:00
Haven1433
d1166893ba Fix metadata issue for extending child arrays from parent arrays
When we extend a child array from a parent array expanding, it's possible to knock out another child of the same parent, which then needs to be re-added. Doing so makes us lose the pointers of that child, which is a metadata bug.

Just like with the constant, make sure that updating the child table length needs to check that all associated pointers exist.
2022-05-06 21:35:22 -05:00
Haven1433
484dc9c238 Fix metadata load edge cases with overlapping tables with constant length
These tables are first loaded with the wrong size and then updated once the constant is available. The tables need to clear correctly in the case of a conflict.
2022-05-05 19:57:36 -05:00
Haven1433
a880adaf23 Fix TableGroups Upgrade bug
When upgrading from an older version, tablegroups get duplicated. Fix that.
* Using the same DefaultHash trick as with Lists, we can track which TableGroups have been edited by users. Remove all the TableGroups that haven't been edited during upgrade. Then add all the new TableGroups. Don't add a TableGroup that contains a Table that we've already added.
2022-04-28 20:43:43 -05:00
Haven1433
e79f865ff8 Don't use HashCode
GetHashCode does not return consistent values. Use SHA256 instead.
2022-04-27 22:33:10 -05:00
Haven1433
f76c2c4736 Hand-Modified Lists shouldn't update during version upgrade
If the user modified a list or added new elements to it, don't modify the list during version upgrades. If the list has never been modified, go ahead and update the list based on the new default metadata.

This is implementing by storing a 'Default Hash' for lists. The user that modifies the list will leave the default hash alone, and the program can notice the mismatch and avoid updating the modified list.
2022-04-27 22:04:19 -05:00