Commit Graph

68 Commits

Author SHA1 Message Date
haven1433
6d01e78b15 "show in file explorer" option from tab context menu
also update crash dialog - when it opens the folder with crash.log, select crash.log
2023-06-25 16:43:05 -05:00
haven1433
fd7a8bd899 Don't starve the UI render thread during keyboard table scrolling
The new `WaitForRenderingAsync` method allows a ViewModel to check with the work dispatcher to make sure the render thread is caught up. We don't want to do this in all cases, but this gives us the ability to wait or skip events if rendering is taking too long, so that we don't starve the render thread.

For example, when using the `MoveSelectionStart` command, the ViewModel now checks if the rendering is caught up. If we're behind, the command request is simply ignored. If we're nearly caught up, it waits for rendering and then does the move work on a background task. If we're completely caught up, the work is still pushed to a background task, but is able to start running immediately.

If this becomes a performance issue and makes the app run too slowly, it'll be easy to just remove the await from the command.
2023-06-16 13:21:40 -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
6c588c0ccc fix importimage path bug 2022-11-28 21:06:00 -06:00
haven1433
8f3da7f04e bugfixes 2022-11-25 13:17:21 -06:00
haven1433
9c11ac55cb add automation metacommands exportimage / importimage
```
# sample for exporting / importing sprites via .hma scripts

@graphics.pokemon.sprites.front/bulbasaur  @!exportimage(test1.png)

@graphics.pokemon.sprites.front/charmander @!importimage(test1.png greedy)
```
2022-11-03 20:09:19 -05:00
haven1433
e0e81612a9 set a max width for the custom dialog popups 2022-10-16 00:10:18 -05:00
haven1433
492003dd37 fix threading issue
If we're already on the UI thread (and doing something that suspends dispatching), there's not need to dispatch, just do the work
2022-10-14 21:13:52 -05:00
haven1433
5c5f51fcc9 Sprite export improvement
Allow exporting indexed PNGs
Other changes:
* multi-select blocks
* edit borders
* fix castform export
2022-10-11 20:11:37 -05:00
haven1433
f3aa78575c fix expansion / truncation issues 2022-10-10 21:47:22 -05:00
Haven1433
5a4f63a8dc add option to copy crash message to clipboard 2022-09-01 21:15:43 -05:00
Haven1433
59c5c02f81 add 'Export All Table' function for images 2022-09-01 16:10:26 -05:00
Haven1433
6bb8fd0998 Fix dispatcher issue
better to block rather than being non-deterministic
2022-08-25 07:37:49 -05:00
Haven1433
216887b7d7 retry clipboard on failure 2022-08-19 21:53:38 -05:00
Haven1433
29ccd7d0fc Fix possible clipboard crash
happens when using remote desktop
2022-06-23 21:13:50 -05:00
Haven1433
fbc182a490 export metadata to *.extension.toml for non-gba files 2022-06-19 22:27:41 -05:00
Haven1433
7f7e182b98 Move CalculateHash to File menu
This is a thing you do to a file, so put it in the file menu.
2022-06-19 19:38:30 -05:00
Haven1433
a2174ed61f differentiate between different toml files using the full file name
.gba files will continue to use <name>.toml for <name>.gba files. All other files will use <name>.<extension>.toml. This is to allow you to store metadata for both your .gba file and your .sav file if you want to. And maybe even an .ips or .ups if you get fancy.
2022-04-20 22:31:43 -05:00
Haven1433
90b02713c3 Introduce AngleMenuItem
Used for the 'export' button in cases where we can export either a single page or an entire sprite.
2022-03-27 21:17:08 -05:00
Haven1433
2c384b177a allow task cancellation without throwing 2022-03-13 21:40:35 -05:00
Haven1433
ee227ac85e Fix loading bug
Don't CascadeScripts right away. Instead, wait until the model is done loading, and _then_ cascade scripts. RefreshBackingData at the same time so as to refresh the cells on the screen.
2022-03-03 21:30:02 -06:00
Haven1433
c0f518bcd8 Replace Model.AfterInitialized with InitializationWorkload
Tasks already do what I was wanting to do (manage work timing), and do it better with more features, and do it in a way that other developers will more easily understand. Stop being weird, just use a Task.
2022-03-03 20:42:00 -06:00
Haven1433
c28fce209a First pass: ViewPort.ConsiderReload is async 2022-03-01 21:10:36 -06:00
Haven1433
a5d79104b2 user should be able to copy messagebox text 2022-02-18 21:51:47 -06:00
Haven1433
0064623247 Update Error dialog to include links to Discord/Github. 2022-02-09 20:14:15 -06:00
Haven1433
b38ec77fd5 Refactor WindowsFileSystem.ShowCustomMessageBox
Allow for multiple links instead of just one.
2022-02-09 09:03:26 -06:00
Haven1433
afe46f2998 Put a wrapper around all uses of Process.Start
Process.Start is slightly different in .Net Core compared to .Net Framework
2022-01-05 06:48:36 -06:00
Benjamin Popp
1f53ef822a Use ProcessStartInfo instead of just a filename
UseShellExecute defaults to false in .Net Core. Give it an explicit value of 'true' to allow windows to run non-executable files. In this case, we want to look for whatever program is registered to run the *.gba file, which will very much not be an executable.
2021-11-29 07:30:32 -06:00
Benjamin Popp
104eb0af4f fix wrapping 2021-07-01 07:47:14 -05:00
Benjamin Popp
f2bb90efbc improve image error handling
* provide better error messages when import fails
* don't crash when trying to decode an image that doesn't have a width as a multiple of 8
2021-05-22 21:15:57 -05:00
Benjamin Popp
f7dcc6fdb5 Fix crash
Happens when trying to save a new document during close
2021-05-14 13:02:14 -05:00
Benjamin Popp
88c88912e4 Organize the Utilities menu better / add scripts
Add the ability to open the new scripts folder from within the app. Add sub-menus to organize the pokedex vs expansion utilities, since I'll be adding more expansion utilities soon.
2021-02-25 16:56:03 -06:00
Benjamin Popp
0e075a34b7 Allow dragging in a PNG to the image editor to paste it in. 2021-02-20 21:04:34 -06:00
Benjamin Popp
ffc13bbe84 Don't crash if there's no app to run the current loaded file. 2021-02-14 12:52:12 -06:00
Benjamin Popp
a05b360e15 Prefer Clipboard.SetDataObject over Clipboard.SetText
https://stackoverflow.com/questions/12769264/openclipboard-failed-when-copy-pasting-data-from-wpf-datagrid
Clipboard.SetText sometimes fails with a COMException, depending on what else is going on and what else is on the system. Starting in .Net 4.5, this issue is fixed... in Clibboard.SetDataObject.
2021-01-22 07:35:50 -06:00
Benjamin Popp
93a4c900e2 Add ability to launch the current file as a program by hitting F5 2020-12-26 22:57:54 -06:00
Benjamin Popp
b5e5f4f961 Improve load performance
Instead of initializing the model right away, launch a background task to do that. This allows the metadata to load while the tab draws itself. When initialization is complete, Refresh the ViewPort.

For the tests, use InstantDispatcher
2020-12-21 16:50:01 -06:00
Benjamin Popp
2bcba6f45f Improve crash dialog 2020-12-11 22:20:29 -06:00
Benjamin Popp
39d9aa862e Don't crash if metadata can't be written. 2020-12-11 22:11:08 -06:00
Benjamin Popp
b055a56c4e Allow users to specify palettes to ignore when importing
Battle Backgrounds use palettes 2,3, and 4. But only palettes 2 and 3 flash when you let out a pokemon. Palette 4 is used for the obfuscation image that covers the screen as you scroll in, like grass or rocks or waves.
2020-12-09 14:26:30 -06:00
Benjamin Popp
b3c8abfd69 Improve crash dialog
When crashing, offer the user a way to open the folder with the crash.log file.
2020-12-06 21:08:28 -06:00
Benjamin Popp
e0e0ec23c8 Add "Export Backup" button 2020-11-28 22:53:09 -06:00
Benjamin Popp
9d102a5bf7 Include image previews in the import image dialog
When importing an image that shares a palette with another image / tileset, the user may be curious to know what all images use the palette. The input window now has the ability to display "additional details", which right now is only used for sprites. But this would allow me to add other information to the options dialog in the future.
2020-11-27 14:21:44 -06:00
Benjamin Popp
c902db54e6 Bug Hunting
Better handle errors when importing images.
Change order-of-operations to hopefully make tab-removal errors happen less often.
2020-11-21 22:54:35 -06:00
Benjamin Popp
3bdb686919 Usability updates
* Show an error when the width/height is wrong
* Show the palette to the right instead of below
* add pokedex habitats graphics
2020-11-05 21:59:54 -06:00
Benjamin Popp
87812cfbfd fix save crash
Files reload whenever they detect that the data changes. But this included if HMA changed the file itself o_O so I fixed that.
Re-initializing should not cause a duplicate dictionary addition for pointer offsets. Fixed.
2020-10-17 11:32:53 -05:00
Benjamin Popp
f62b9ab814 Update start screen
* Pull some important info / links down from the help menu to the start page.
* Remove the Help -> About option, because it's now redundant.
* Add support for opening recent files from the start screen
2020-10-14 07:24:18 -05:00
Benjamin Popp
efecf03aa7 Update IFileSystem interface for copy/paste images
* Remove concept of palettes from open/save images, since the actual code doesn't use this anymore.
* Refactor the bulk of short[]-and-width conversion into helper methods so they can be used by the new property.
* Add a new property, CopyImage, that can access an image in the clipboard.
2020-09-20 22:03:55 -05:00
Benjamin Popp
8a0624dba3 break IFileSystem into IFileSystem and IWorkDispatcher
The ability to Dispatch work to another thread is a scheduler concern, not a filesystem concern. These sets of operations should not be tied to the same object.
2020-09-01 14:37:10 -05:00
Benjamin Popp
f9661a6f11 Fail gracefully if the imported image is not a valid PNG 2020-08-23 13:49:11 -05:00