andrews05 / ResForge

Resource editor for macOS
MIT License
118 stars 8 forks source link

Add visual system map editor for managing stellar objects in a system #19

Closed bendyer closed 5 days ago

bendyer commented 1 month ago

Overview

This change adds a system map reference next to the existing galaxy map reference in the sÿst resource template; this refers to a dummy sÿsm resource type for which 2048 entries are provided in Templates.rsrc (one per available sÿst resource ID):

image

The editor for this sÿsm resource type is based on the GalaxyView editor, with large-scale modifications made to constrain the set of displayed stellars to the single selected system, and support graphical previews of each stellar object based on the linked spïn resource. The system's 16 available NavDefaults are shown in a table view on the left of the window, including NavDefault index (# 1–4 are hotkeyed in EV), resource ID and name:

image

Interface functionality is essentially the same as the existing galaxy editor; selection is synchronized between the table and the graphical views, multiple objects can be clicked, dragging objects moves them, and double-clicking empty space in the map view creates a new stellar object at that position in the first available NavDefault slot.

As with the galaxy view, dragging to move existing resources results in the template edit panel for those resources updating immediately; editing the xPos/yPos/Type fields commits the change to the map view upon closing the template edit panel.

Note that the maximum zoom level is fairly zoomed out (displaying smaller than in-game); this is because EVN wraps the player around at ±15,000 pixels from the system origin, so you can reasonably put spöbs out to around that range, while the maximum size of an NSView is 10,000 pixels (i.e. ±5,000). It would of course be possible to implement a different approach to scrolling etc to remove this limitation but I don't think it's worth the effort.

Testing

Cases tested:

Possible future work

bendyer commented 1 month ago

The test I haven't ticked off is this one:

Setup: Open Nova Data 2 and Nova Graphics 2. Open sÿst ID 130 in Nova Data 2. Copy and paste all stellars 4 times. Result: All stellars are duplicated, to the limit of 16 NavDefaults but further pastes have no effect.

The actual result is that the underlying stellars are duplicated but the duplicates are not added as NavDefaults.

The most obvious way to fix this would be to replace the paste action with one that calls the EditorManager's document.add method in the same way that the underlying document paste action does, and then use the returned resources from add to update the NavDefaults.

However this would require exposing the ResourceDocument to plugins, which is not currently done.

I don't think the extra functionality on paste is worth the implementation effort on this one.

andrews05 commented 4 weeks ago

Nice work! I agree the extra functionality on paste is not of great importance, though just as a quick thought perhaps you could read the pasteboard to check the number of resources and then forward the call to the document only if there's enough free slots.

I'll try to find time to review...

bendyer commented 3 weeks ago

Thanks for the feedback! Will work through the stylistic stuff, as you can tell I'm new to this whole Swift thing!

andrews05 commented 5 days ago

Thanks again for your work here, it's really great to have this feature! A couple of notes on some further changes I made: I think I initially misunderstood your comment about pasting. When I realised what you meant I decided it's probably best to just remove copy/paste for now. I also realise you may be on macOS 13 where clipsToBounds defaults to true, meaning the stellar highlight box may appear differently when you build it than when I build it. I made some tweaks here that may make it look worse to you, but don't worry - the release build will look the same for everyone.