Commit Graph

3392 Commits

Author SHA1 Message Date
Benjamin Popp
1f8428c810 Autoformat 2019-11-24 14:41:05 -06:00
Benjamin Popp
ee38a7b080 Add Dex Tables
There are 4 tables related to the pokedex that I'm adding here:
* regional dex: for each pokemon, what is its regional dex index
* national dex: for each pokemon, what is its national dex index
* conversion: for each regional dex entry, what index is it in the national dex (can be computed automatically, so I added a QuickEdit item)
* dex info, such as the dex description

I also updated App.xaml and MainWindow.xaml.cs to make the QuickEditItems look better.
2019-11-24 14:39:17 -06:00
Benjamin Popp
2147911d6a Bugfix
In the case of the next run bing a table but the current address not being within it, don't crash.
2019-11-23 21:46:51 -06:00
Benjamin Popp
f976c02417 Include decorations table
Not really much to say here. Added format for new table, added test for new table, done. Probably the most straightforward addition I've done so far.
2019-11-23 15:39:43 -06:00
Benjamin Popp
f401323dd8 Support for evolution table
* table format feature: allow for recursive table definitions, simply because it's shorter.
* include expected locations of pointers to the Evolution table
* unit tests to show that we found the evolution table correctly
* model bugfix: when specifying to keep pointers, don't clear them during unusual loading situations
* model bugfix: when adding a format to a pointer in a table, if that location is already a table, give up and leave the table there.
2019-11-22 22:56:29 -06:00
Benjamin Popp
3895eb2370 Add Move Descriptions table
The first move has no move description. So the move desciptions table should be the same length as the move names table, minus one. Added support for this kind of concept.
2019-11-22 14:39:38 -06:00
Benjamin Popp
19aac4beab ViewPort's "Clear Format" context menu button should clear pointers too
Previously, right-clicking on an actual anchor would let you clear the format of the anchor but keep the anchor, while right-clicking on the format without the anchor would let you clear both the anchor and the format. Not only is this backwards, but it's inconsistent.

Now, a much simpler system: if you use the right-click to clear the format, the app assumes that the entire anchor was in error, so the anchor and any pointers to it are all cleared, but no data is changed.
2019-11-20 22:26:23 -06:00
Benjamin Popp
14d44fe2f5 Improve performance
- Whenever I RefreshBackingData, do a lazy load of the view: don't load any cells until those cells are asked for.
- When cell (0,0) is requested, go ahead and load everything in an efficient manner, only getting each Run object once.
- Throughout ViewPort, always use this[x,y] to get a cell, since that will do the lazy-load.
2019-11-20 21:31:54 -06:00
Benjamin Popp
5db7df3472 Make Copy work for trainer teams 2019-11-18 21:28:55 -06:00
Benjamin Popp
2fea0d1ac1 Improve partial string matching
when a character is matched, only check the string _after_ the current character for future characters. this makes searching for "mm" correctly filter out any words with only a single 'm'.
2019-11-18 21:17:30 -06:00
Benjamin Popp
54ebcbf800 Allow ITableRun.NotifyChildren to return ErrorInfo so they can notify when they move their children
This also requires that the FieldArrayElementViewModel be able to ask the ViewPort to raise messages... which of course requires the FieldArrayElementViewModel to have access to the ViewPort.
2019-11-18 21:14:19 -06:00
Benjamin Popp
f68852b310 Limit the number of auto-complete options for performance 2019-11-18 20:51:16 -06:00
Benjamin Popp
d09751cd67 Let the table update itself
Changes to the table can require updates to other fields in the table, so let the table tool changes cause table tool reloads.
2019-11-17 21:59:40 -06:00
Benjamin Popp
67a6ab1ed3 Fix default moves
When changing from a team format with no custom moves to a team format with custom moves, give sane defaults for the custom moves.
2019-11-17 16:00:40 -06:00
Benjamin Popp
66cbfb38b0 Arrays getter performance improvement
old version:
Search linearly through all runs for any that are `ArrayRun`s

new version:
Search linearly through all anchors for any that are `ArrayRun`s

Getting a run from an anchor is O(log(n)), so this should be much faster when the number of runs is large.
2019-11-17 15:47:30 -06:00
Benjamin Popp
febefec53f Fix repoint
Repoint was broken because 'start' was using a closure version of the original start instead of the current start.
2019-11-17 15:42:44 -06:00
Benjamin Popp
f8437f0c91 Performance Improvement
Reuse existing ViewModels in the table where possible, as keeping the same DataContext and just changing a few properties massively speeds up the table tool layout.
2019-11-17 15:11:39 -06:00
Benjamin Popp
06e9624924 Ignore whitespace in address field 2019-11-16 08:53:05 -06:00
Benjamin Popp
0a79044edf Adding default items doesn't break moves
Bug: when changing the struct type from "custom moves" to "custom moves & items", the first move got turned into an item. The test captures that bug, the code change fixes it.
2019-11-16 07:42:56 -06:00
Benjamin Popp
da8619fb79 Clear extra data when making a struct shorter
Also, refresh the hex view when a change is made that could cause the table to update other rows automatically.
Also, when writing data, write IVs, Level, then Pokemon instead of Level, Pokemon, IVs.
2019-11-15 22:56:20 -06:00
Benjamin Popp
020093d356 Initial Implementation of automatic trainer team updates
- if the user changes the struct type, the pokemon team updates automatically, potentially adding default moves to the pokemon. This works both with inline hex updates and with tool changes. Other trainers that use the same team are also updated.
- if the user changes the pokemonCount, the pokemon team updates automatically. This works both with inline hex updates and with tool changes. Other trainers that use the same team are also updated.
- if the user updates the child run using the stream, the parent(s) change their struct type / pokemonCount to match.
- if the user updates the  child run by using the table tool or changing the inline hex, the parent(s) update to match.

Passes all unit tests, but hasn't been hand-tested yet for edge cases.
2019-11-15 16:37:05 -06:00
Benjamin Popp
3d7157749b Display bad table pointers as errors
Now that table pointers are not guaranteed to be valid, we need a fast way to show this to the user.
2019-11-10 22:27:56 -06:00
Benjamin Popp
42773ae4ba Don't require table pointers to point to valid anchors
In many fangames, the game contains an error where a pointer in a table points to something unexpected.
* I need to allow the pointer, because the table format requires that it be a pointer, and that's how the game reads it.
* I need to allow the destination to not be an anchor, because the destination may be being used for something else.

To make sure I'm handling this correctly for a wide variety of cases, I added `BasicLoadTests.CanLoad` for a wide variety of romhacks.

Also related, I added another section to `PokemonModel.ResolveConflicts` that validates pointers within tables, instead of only pointerruns.
2019-11-10 22:17:55 -06:00
Benjamin Popp
0b3a06da79 Bugfix: don't change combo index on selection
For lists where multiple elements have the same text (example, the multiple 'picnicker' trainerclassname entries), loading the item with the table tool always selects the first element with that text in the combobox, even if that's not the index that was bound to. This is a binding issue.

To fix it, the ViewModel uses a slightly more complex data-type that wraps the string. The two options are now seen as different unequal objects, so no coercion happens.
2019-11-09 21:22:18 -06:00
Benjamin Popp
c6ce6c2163 Recognize trainer teams correctly
For trainers whose pokemon have items AND moves, the item is listed before the moves, not after.
2019-11-08 22:33:36 -06:00
Benjamin Popp
f39f3dba84 table selection in tool always aligns hex content
The hex content normally jumps to a table when you select the table with the table tool. However, it doesn't jump if the table is already selected. The user experienced confusion, wanting to jump to the start of the table using the table drop-down, but they couldn't because they were already looking at that table.
2019-11-08 22:14:48 -06:00
Benjamin Popp
6ee2740400 Color the number
despite adding the warning into the table, the next user still made the same mistake: they edited the existing pointer data in the table, which also edited other instances that pointed to that data. Hopefully doing this odd coloring will make it more clear.
2019-11-08 19:12:54 -06:00
Benjamin Popp
9eb5a83e21 PLMStreams behave better when resizing
- When the text being deserialized is bad, don't return a level of zero: just skip that line.
- When shrinking a PLMRun, clear out all extra bytes up to the original length. This is important in case the user removes multiple moves at once.
2019-11-08 19:03:14 -06:00
Benjamin Popp
b0552ce7ad Table tool should say 'null' for null pointers 2019-11-08 18:24:29 -06:00
Benjamin Popp
2888cf7787 Use yellow instead of red for the edit cell background color 2019-11-08 18:18:23 -06:00
Benjamin Popp
32b8de5fd7 Version Bump 2019-11-08 15:49:48 -06:00
Benjamin Popp
bcba21d4b8 Hotfix: Performance of edited cell background highlight
using 'opacity' is really slow. Do the blending manually.
2019-11-08 08:16:28 -06:00
Benjamin Popp
b96a0cb737 Add logic for default moves for trainer pokemon
At some point, I'm going to implement what happens when you switch a pokemon from auto-moves to manual moves. When I do that, I need a reasonable default move list to assign to the pokemon as I'm swapping out the data type. Might as well write the default-move logic now.
2019-11-07 22:20:11 -06:00
Benjamin Popp
a7f8960415 scrolling fixes for text tool search 2019-11-07 21:17:35 -06:00
Benjamin Popp
da6d23f4fb Merge branch 'universal-loading' into usability-updates-3-2 2019-11-07 19:59:09 -06:00
Benjamin Popp
9d4e6ee138 Don't crash when trying to load heavily modified roms 2019-11-07 14:37:28 -06:00
Benjamin Popp
ee1aaedb68 Less changes from tools
When using a tool to edit the egg moves, only change the cells that are actually changing.

When using a tool to edit a bit array, only change the cells that are actually changing.

This makes the edit easier to see for the user.
2019-11-06 15:08:06 -06:00
Benjamin Popp
52fb90beb3 Adding tests for finding trainers
also realized that TPTRuns will temporarily have no sources while in the process of being removed.
2019-11-06 14:47:57 -06:00
Benjamin Popp
b0ebd70dc1 Update start screen table list 2019-11-06 13:55:50 -06:00
Benjamin Popp
3b968b94f9 bugfix: backspace should behave when working outside of a run 2019-11-06 13:54:46 -06:00
Benjamin Popp
e4156c418d Better change tracking implementation & UI
change tracking was previously done in the model, but exposed in the ViewModel via a data format. The problem with this is that it meant that all changed formats were wrapped in a new format, which would require a lot of work to fully validate.

The new implementation is still in the model, but exposed in the ViewModel through a new property on the HexElement. The data formats are unchanged.
2019-11-06 12:36:26 -06:00
Benjamin Popp
d878c2ae9d Refactoring to make it possible to show edited cells 2019-11-05 22:11:24 -06:00
Benjamin Popp
ce24b401fe Refactor roated bit arrays 2019-11-05 16:26:18 -06:00
Benjamin Popp
5800420d78 Merge branch 'rotated-bit-array-editing' into usability-updates-3-2 2019-11-05 16:14:40 -06:00
Benjamin Popp
05d197b11a Performance fix
in some cases, auto-moving runs and then updating the selection was really slow. For example, updating pokenames (and related tables). This was due to a bug where the scroll value was being updated incorrectly, resulting in excessive horizontal panning to align the data.
2019-11-05 16:05:40 -06:00
Benjamin Popp
aac787fbe0 Don't auto-open tools
As useful as this bug was, it's preventing people from noticing the panel on the left. As the editor grows, this panel will become more useful. I'm going to remove the bug, so that the tool panel no longer auto-opens. This requires more work from the user, but that work causes them to discover the panels existence (hopefully).
2019-11-05 15:26:47 -06:00
Benjamin Popp
0d9322aa94 Tool should auto-switch in some situations.
There are times where the table tool doesn't make sense but the text tool does, and vice-versa. In such situations, automatically switch from whichever of those tools is open to the other one.
Note that this will not automatically open a tool when none are open, nor will it mess with the code tool, nor will it change the tool in situations where both are applicable (such as the text portion of a table, or a run that is both a table and a stream). But it should reduce confusion and clicks in many common situations.
2019-11-05 15:19:48 -06:00
Benjamin Popp
27cf7906db Allows names to the first PCS segment of a table, not just if that is segment 0
this allows things like Ctrl+G->trainer/brock to work as expected.
2019-11-05 14:47:53 -06:00
Benjamin Popp
c2af96e975 Improve auto-alignment
When jumping into a table backwards from a pointer, the table should still be aligned to the start of individual elements.
2019-11-05 12:21:58 -06:00
Benjamin Popp
f148e8a7fe Refactor: make trainer teams work with new table features
Trainer teams are also a stream run. Add support for searching for them into the table tool.
2019-11-05 12:08:02 -06:00