Fix issues with the Edit Sheets dialog
This commit is contained in:
@@ -3331,17 +3331,19 @@ void edit_custom_sheets() {
|
||||
|
||||
// First, make sure we even have custom graphics! Also make sure they're not legacy format.
|
||||
bool must_init_spec_g = false;
|
||||
if(max_pic < 0) {
|
||||
if(spec_scen_g.is_old) {
|
||||
if(cChoiceDlog("convert-pics-now", {"cancel", "convert"}).show() == "cancel")
|
||||
return;
|
||||
spec_scen_g.convert_sheets();
|
||||
all_pics.resize(spec_scen_g.numSheets);
|
||||
std::iota(all_pics.begin(), all_pics.end(), 0);
|
||||
} else if(max_pic < 0) {
|
||||
if(cChoiceDlog("have-no-pics", {"cancel", "new"}).show() == "cancel")
|
||||
return;
|
||||
must_init_spec_g = true;
|
||||
} else if(max_pic >= 0 && spec_scen_g.numSheets < 1) {
|
||||
if(cChoiceDlog("have-only-full-pics", {"cancel", "new"}).show() == "new")
|
||||
must_init_spec_g = true;
|
||||
} else if(spec_scen_g.is_old) {
|
||||
if(cChoiceDlog("convert-pics-now", {"cancel", "convert"}).show() == "cancel")
|
||||
return;
|
||||
spec_scen_g.convert_sheets();
|
||||
}
|
||||
|
||||
if(must_init_spec_g) {
|
||||
|
@@ -2150,6 +2150,8 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store);
|
||||
|
||||
void load_spec_graphics_v1(fs::path scen_file) {
|
||||
static const char*const noGraphics = "The game will still work without the custom graphics, but some things will not look right.";
|
||||
fs::remove_all(tempDir/"scenario/graphics");
|
||||
fs::remove_all(tempDir/"scenario/sounds");
|
||||
fs::path path(scen_file);
|
||||
std::cout << "Loading scenario graphics... (" << path << ")\n";
|
||||
// Tried path.replace_extension, but that only deleted the extension, so I have to do it manually
|
||||
|
@@ -498,6 +498,8 @@ void cCustomGraphics::convert_sheets() {
|
||||
numSheets = num_graphics / 100;
|
||||
if(num_graphics % 100) numSheets++;
|
||||
sheets = new sf::Texture[numSheets];
|
||||
extern fs::path tempDir;
|
||||
fs::path pic_dir = tempDir/"scenario/graphics";
|
||||
for(size_t i = 0; i < numSheets; i++) {
|
||||
sf::IntRect subrect;
|
||||
subrect.top = i * 280;
|
||||
@@ -510,7 +512,11 @@ void cCustomGraphics::convert_sheets() {
|
||||
|
||||
sheets[i].create(280, 360);
|
||||
sheets[i].update(sheet);
|
||||
|
||||
fs::path sheetPath = pic_dir/("sheet" + std::to_string(i) + ".png");
|
||||
sheets[i].copyToImage().saveToFile(sheetPath.string().c_str());
|
||||
}
|
||||
ResMgr::pushPath<ImageRsrc>(pic_dir);
|
||||
}
|
||||
|
||||
void cCustomGraphics::replace_sheet(size_t num, sf::Image& newSheet) {
|
||||
|
Reference in New Issue
Block a user