Skip to content
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

tmxrasterizer as a git diff tool: override search path, and allow explicitly writing to stdout #3867

Open
eevee opened this issue Jan 8, 2024 · 2 comments
Labels
feature It's a feature, not a bug.

Comments

@eevee
Copy link

eevee commented Jan 8, 2024

Two little features would make it much easier to plug tmxrasterizer into git as a map differ:

  1. An argument for overriding the initial search path. The problem is, when git diffs two versions of the same file, it has to put at least one of them in a temporary file, and now it doesn't know where to find any of its tilesets. I know the original full path, but I have no way to provide it.

  2. Writing the image to stdout. This isn't strictly necessary since tempfiles are always an option, but it did surprise me a little that giving - as the outfile path literally created a file named - :)

With both, I believe you could diff a map against its committed version with a oneliner (in zsh, anyway):

compare -metric PHASH =(tmxrasterizer -s 0.25 -p $(dirname $1) $2 -) =(tmxrasterizer -s 0.25 -p $(dirname $1) $5 -) png:- | display -title "$1" -
@eevee eevee added the feature It's a feature, not a bug. label Jan 8, 2024
@eevee
Copy link
Author

eevee commented Jan 10, 2024

i fudged something similar by dumping the original file to a tempfile in the source directory (highly dubious), and i think this is a cool start:

scaled-down view of a map with some changed areas highlighted in red

@bjorn
Copy link
Member

bjorn commented Jan 11, 2024

I quite like this idea! To implement this, the MapFormat interface would need to be extended with an option to read a map while using a custom search path:

virtual std::unique_ptr<Map> read(const QString &fileName) = 0;

The TMX format already has a function that can be used to implement such an interface:

std::unique_ptr<Map> readMap(QIODevice *device, const QString &path = QString());

The JsonMapFormat can also be quite trivially extended with such an overload. For other formats, I guess providing a default implementation that ignores the custom search path would be fine for now, so we don't need to change all the implementations.

Finally, we would add a Tiled::readMap overload that takes this search path, and we can use it in TmxRasterizer.

And I don't think it'll be an issue to get - to output a PNG to standard out, either. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants