Skip to content

Add a default world for standalone maps#4562

Open
kanishka0411 wants to merge 5 commits into
mapeditor:masterfrom
kanishka0411:feature/default-world
Open

Add a default world for standalone maps#4562
kanishka0411 wants to merge 5 commits into
mapeditor:masterfrom
kanishka0411:feature/default-world

Conversation

@kanishka0411

@kanishka0411 kanishka0411 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

This makes the resize handles of the world tool work on maps that are not part of any world.
Resizing only changes the map itself so it doesn't really need a world, and undo just works since it goes through the map's own undo stack.

@kanishka0411 kanishka0411 marked this pull request as draft July 1, 2026 20:53
@kanishka0411 kanishka0411 force-pushed the feature/default-world branch from 68f297f to 51f0d5d Compare July 5, 2026 20:19
@kanishka0411 kanishka0411 marked this pull request as ready for review July 5, 2026 20:31
@kanishka0411 kanishka0411 marked this pull request as draft July 5, 2026 20:31
@kanishka0411 kanishka0411 marked this pull request as ready for review July 6, 2026 20:14
bjorn added 3 commits July 7, 2026 23:15
Worlds created through the world tool's "Add another map" action were
not stored in the session, so they were no longer loaded after a
restart. The same applied to unloading worlds through "Unload All
Worlds".

Now MainWindow updates the session whenever the WorldManager reports
that a world was loaded or unloaded, instead of doing it at each call
site.
When a map is resized from its top or left edge, its content shifts,
while a map that is not part of a world stays anchored at 0,0 in the
scene. The view was only kept steady for maps that are part of a world,
based on their world position, so for other maps the content appeared
to jump on mouse release.

Now the view is also recentered for maps that are not part of a world,
based on the pixel offset resulting from the resize.
Moved the code for asking the user for a world file name and creating
an empty world at that location into MainWindow::createNewWorld, which
is now used both by the New World menu action and by the world tool
when it needs to create a world for the current map.

As a side effect, the world tool's dialog now also updates the last
used world path in the session and offers the All Files filter.
@bjorn

bjorn commented Jul 7, 2026

Copy link
Copy Markdown
Member

I pushed a few fixes for problems I found during review:

  • New Worlds created in response to adding a map were not getting added to the session. This was more an issue with existing code, since the list of worlds stored in the session was manually updates for some actions in MainWindow. Now it is updated based on the appropriate signals.

  • Fixed the jumping of the view after resize by taking into account that the map stays at 0,0.

  • Reduced code duplication by calling into the MainWindow for creating the new world. Not entirely sure if it's the right design, but it was a quick way to avoid two "New World" functions.

There are a few other potential issues:

  • If the user selects the file of a world that's already loaded in the New World save dialog, addEmptyWorld fails with "World already loaded" in an error box. Probably we could just add the map to that world instead?
  • In addAnotherMapToWorld, if the user creates the world but then cancels the "Load Map" dialog, they end up with a world containing only the current map. Maybe it's better to not do anything in this case?
  • "Add another map to the current world" is not the correct naming for this action when there is no world yet.

In general, I wonder if it would be better to separate the creation of the world. I think automatically creating the world when using the "add map" action might be too confusing. When the "New World" dialog pops up I think many people see just a file dialog and interpret it as the dialog to select the map from. What do you think?

@kanishka0411

Copy link
Copy Markdown
Contributor Author

I think the confusion mostly comes from the save dialog showing up right after clicking "add map", since it's easy to mistake it for the map picker. Maybe instead of separating the world creation completely, we could show a small confirmation first, like "This map is not part of a world. Create a new world containing it?", then let the user pick the map, and only create the world file at the end. That way cancelling anywhere leaves nothing behind, which also fixes the cancel case you mentioned.
For the already-loaded world I agree, just adding the map to it makes more sense than showing an error. And for the naming, I'd change the text when there's no world yet to something like "Add map to a new world".
But if you think a fully separate "create world first" step is clearer, I can go with that also :-)

@bjorn

bjorn commented Jul 8, 2026

Copy link
Copy Markdown
Member

Maybe instead of separating the world creation completely, we could show a small confirmation first, like "This map is not part of a world. Create a new world containing it?", then let the user pick the map, and only create the world file at the end.

I think that's worth a try. You can implement it and see how it feels. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants