Drawing a new map straight into the world
This is the fourth feature, which was to drag out a rectangle in empty world space and a new map shows up right there, instead of going to File and then New Map, filling in a dialog, saving it somewhere, and then adding it to the world by hand.
What I actually did click to open
So while dragging it snaps to the world grid, which is what makes the new map line up with whatever is already sitting there. If we want it off the grid we can hold Control, same as with the resize handles, and Escape or right click cancels the drag if we change our mind halfway. The map also picks up its orientation, tile size, render order and tilesets from the nearest map in the world, otherwise you would draw into an isometric world and get one odd orthogonal map sitting in the middle of it.
There were a few things which I wasn't sure about, like undo was moving the created file to the trash and no other undo command in the codebase touches files, so was that okay. Should the new map open in a tab straight away. And should the file go next to the .world file or next to the nearest map, since in sticker-knight all the maps live in a map folder.
To my questions my mentor said to keep the automatic saving in this PR, and only delete on undo when the map has no content, but then try making maps stay unsaved as a separate commit and fold it in if it stayed small.
My PR had a few issues in it, like worlds refer to their maps by file name, so an unsaved map has no name to be found by. Clicking one in the world opened it in its own tab with the world and the grid gone, because worldForMap only ever had a file name to search with. I suggested putting a plain non owning Map* on the entry just for identity, and Bjorn said that sounds too fragile to keep valid, and to pass the MapDocument* into worldForMap instead so it can match by pointer too. That one change fixed the world staying visible, and it also made Remove from World work for unsaved maps.
On testing there were three more things, like unsaved maps were selecting on press while saved maps select on release, so it felt abrupt. Creating another map while an unsaved map was selected put it in the wrong spot, which was the world rect being looked up by file name again. And switching to a new map inside a world made the view fit the map, which is the normal first time behaviour but wrong here since you're already looking at the world. Those are all fixed now, and resizing an unsaved map from the left or top edge moves its rect in the world as well, so the content stays put like it does for saved maps.
The PR is still in review, and delete maps in the world will come after this one.