When creating a new graphics sheet, initialize it with a convenient checkerboard pattern

- Also fix a crash when first creating a graphics sheet in a scenario due to the temporary folder not being in the image search paths
This commit is contained in:
2015-07-29 12:55:44 -04:00
parent db2ecd2e79
commit e9381f194e
3 changed files with 20 additions and 2 deletions

View File

@@ -3378,9 +3378,10 @@ void edit_custom_sheets() {
spec_scen_g.clear();
spec_scen_g.sheets = new sf::Texture[1];
spec_scen_g.numSheets = 1;
spec_scen_g.sheets[0].create(280, 360);
spec_scen_g.init_sheet(0);
spec_scen_g.sheets[0].copyToImage().saveToFile((pic_dir/"sheet0.png").string().c_str());
all_pics.insert(all_pics.begin(), 0);
ResMgr::pushPath<ImageRsrc>(pic_dir);
}
set_cursor(watch_curs);
@@ -3468,7 +3469,7 @@ void edit_custom_sheets() {
sf::Texture* wasSheets = spec_scen_g.sheets;
spec_scen_g.sheets = new sf::Texture[spec_scen_g.numSheets + 1];
std::copy_n(wasSheets, spec_scen_g.numSheets, spec_scen_g.sheets);
spec_scen_g.sheets[newSheet].create(280,360);
spec_scen_g.init_sheet(newSheet);
spec_scen_g.sheets[newSheet].copyToImage().saveToFile(sheetPath.string().c_str());
spec_scen_g.numSheets++;
auto iter = all_pics.insert(std::upper_bound(all_pics.begin(), all_pics.end(), newSheet), newSheet);

View File

@@ -535,6 +535,22 @@ void cCustomGraphics::replace_sheet(size_t num, sf::Image& newSheet) {
ResMgr::free<ImageRsrc>(sheetname);
}
void cCustomGraphics::init_sheet(size_t num) {
sheets[num].create(280,360);
sf::Image fill1, fill2;
fill1.create(28,36,{0xff,0xff,0xc0});
fill2.create(28,36,{0xc0,0xff,0xc0});
for(int y = 0; y < 10; y++) {
for(int x = 0; x < 10; x++) {
if(x % 2 == y % 2) {
sheets[num].update(fill1.getPixelsPtr(), 28, 36, x * 28, y * 36);
} else {
sheets[num].update(fill2.getPixelsPtr(), 28, 36, x * 28, y * 36);
}
}
}
}
// TODO: This doesn't belong in this file
std::string get_str(std::string list, short j){
if(j == 0) return list;

View File

@@ -83,6 +83,7 @@ struct cCustomGraphics {
graf_pos find_graphic(pic_num_t pic, bool party = false);
size_t count(bool party = false);
void replace_sheet(size_t num, sf::Image& newSheet);
void init_sheet(size_t num);
};
struct snippet_t {