Open cpojer opened 2 months ago
I'd be interested in taking a pass at this one after the share url issue is complete since it touches similar parts of the code unless someone else wants to before then.
Go for it!
Oh I was beaten to the punch! I have been working on this a bit so probably my fault for not mentioning it sooner, is it okay if I keep plugging away @connorlindsey?
I'm at the point where i've got the undo stack restoring on reload and restoring the previous map. But I have a few questions about the MapObject.id
and the restore previous state UX.
@tjamesmac Yeah, go ahead 😄
Thank you!
My questions were:
The MapObject.id
is returning undefined and never returns an actual id. Is this expected? If it is, do you have any suggestions for generating a decent fallback?
Instead of restoring the previous map with the Restore
button, i'm restoring if a previousState is present. When clicking New map
I then delete the related localstorage items so a refresh doesn't continually bring back the last map. Does this sound like the right path for the U? Happy to change if I misinterpreted the requirement.
Also not sure if i'm missing something obvious but the confirmation dialogs for the new/reset map don't seem to work. I've just started calling new map directly
Lastly, are there tests for the map editor?
Hey @tjamesmac, thanks for working on this and sorry for the late reply, I was at a conference. Let's take it to the PR you created.
Right now, when you accidentally reload you lose undo/redo state. Ideally undo/redo state is stored in an encoded form (
MapData.toJSON
) inlocalStorage
and is therefore persisted after a reload, ensuring that players do not accidentally lose a map in progress. See theMapEditor
component. It's also worth checking out theupdateUndoStack
function.I suggest storing the undo state by
mapObject?.id
(or a fallback id if nomapObject
is provided) so the undo stack can be per-map which will be on a different route in the game.Additionally, when loading the map editor it has the ability to "restore" previous state, like from the last playtest. It should no longer be necessary to keep that feature separate, and instead the code should be cleaned up so that
restorePreviousState
just restores from the undo stack. This might need a fallback behavior so that it doesn't keep restoring the same previous map – or alternatively the "Restore Map" button in theMapEditorControlPanel
should just be an "Undo" button after the first click (or after undo/redo is executed once). Open to ideas to ensure a good user experience.Links
Funding