-
-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Map Editor Undo should be stored in localStorage #3
Comments
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 |
@tjamesmac Yeah, go ahead 😄 |
Thank you! My questions were:
|
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
The text was updated successfully, but these errors were encountered: