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

GUI: Debug tilesets are placed in root output folder #202

Open
1 task
serin-delaunay opened this issue Sep 11, 2017 · 4 comments
Open
1 task

GUI: Debug tilesets are placed in root output folder #202

serin-delaunay opened this issue Sep 11, 2017 · 4 comments

Comments

@serin-delaunay
Copy link
Collaborator

serin-delaunay commented Sep 11, 2017

Debug tilesets can optionally be written to files in order to help users understand how a configuration generates tilesets. They are not part of the output necessary to use a tileset, so in the command line tool they are placed in eg. configuration_folder/output/debug/*png. However, in the GUI they are currently placed in eg. configuration_folder/output/*.png.

  • Alter the GUI's methods for saving debug tilesets, so that they are placed in the same path as in the CLI.
@eguiraud
Copy link
Contributor

I'll give it a go :)

@hryniuk
Copy link
Member

hryniuk commented Sep 28, 2017

@bluehood nice :)!

So, to start, you can take a look on how it's implemented in CLI:

  • tilesets are saved just after generation

tg.generate([](const sf::Texture& output, std::string filename)
{
const std::string image_dir = boost::filesystem::path(filename).remove_filename().string();
boost::filesystem::create_directories(image_dir);
if (!output.copyToImage().saveToFile(filename))
throw std::runtime_error("Couldn't write image");
});

and in GUI:

  1. at first, tilesets are saved for a preview:

    mTilesetGenerator->generate([this](const sf::Texture& output, std::string filepath)
    {
    const sf::Image source_image = output.copyToImage();
    const auto filename = boost::filesystem::path(filepath).filename().string();
    const auto qimage = convertSfImageToQImage(source_image);
    mPreviewImages.emplace(std::make_pair(filename,
    std::make_pair(filepath, std::move(qimage))));
    });

  2. and then, after clicking "Save", they are saved, basing on filenames generated in the previous step:

    for (const auto& preview_image : mPreviewImages)
    {
    p.append(preview_image.first);
    if (!preview_image.second.second.save(QString(p.string().c_str())))
    {
    QMessageBox critical_error_message;
    critical_error_message.critical(this, "Error during saving tilesets", QString("Couldn't save tileset image"));
    return;
    }
    p.remove_filename();
    }

The problem is that only output directory is taken into account and filenames are just appended to it. Instead, Wangscape in step 2. should go through paths generated in step 1. and concatenate both mOptions->relativeOutputDirectory and filepath.

Good luck!

@eguiraud
Copy link
Contributor

What C++ standard can I use? I see at least C++11 is allowed

@serin-delaunay
Copy link
Collaborator Author

C++14 is fine; we're already using std::make_unique. We're supporting VS2015, so there are a few features we can't use: https://msdn.microsoft.com/en-us/library/hh567368.aspx

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

No branches or pull requests

3 participants