tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Prompt to apply automapping rules when saving

Open Seanba opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. When using live automapping I may end up with tiles just outside the Automapping Radius that are in a bad state. I have to remember to use the AutoMap menu item so that I can be sure that all tiles have rules applied to them.

Describe the solution you'd like Some kind of prompt or option that runs automapping when the map is saved.

Seanba avatar Aug 27 '22 16:08 Seanba

This seems like it would be better implemented as a script, as this seems rather niche, useful only if your automapping radius is too low or if automapping while drawing is inconsistently used.

Such a script would look something like this:

let autoAutomapAction = tiled.registerAction("toggleAutoAutomap", function(action) {});
autoAutomapAction.checkable = true;
autoAutomapAction.checked= true;
autoAutomapAction.text = "Automap Reminders";
tiled.extendMenu("Map", [
    { action: "toggleAutoAutomap", before: "AutoMapWhileDrawing" }
]);

tiled.assetAboutToBeSaved.connect(function(asset) {
	if(autoAutomapAction.checked && asset.isTileMap) {
		//let automap = tiled.confirm("Would you like to apply automapping?");
		//if(automap)
			asset.automap();
	}
});

The main problem with this is that your preference isn't saved, it'll be reset to checked (or unchecked, if you remove the line that checks it) whenever you restart Tiled or otherwise reload scripts. You could save it to a file or custom property, but I leave that to you. If we ever get the option to add custom properties to projects, that would be a good way to store settings like this. A minor problem is that checkable actions look a little silly as their icon replaces the checkbox. That is a separate and hopefully easy-to-fix issue xP

eishiya avatar Aug 27 '22 17:08 eishiya

I think a prompt would get annoying fast, but I could imagine adding an "AutoMap on Save" option along with the "AutoMap While Drawing" option. In the meantime though, this is indeed something you could script as per @eishiya's example above. :-)

I think another solution might be to increase your "AutomappingRadius" so that it covers your entire map. Depending on the size of your map and number of rules this could be fast enough now.

bjorn avatar Aug 29 '22 08:08 bjorn