From 61d206ae8469d45b7d28a50466edf4874c44590a Mon Sep 17 00:00:00 2001 From: ALONSO Laurent Date: Fri, 29 Oct 2021 09:16:20 +0200 Subject: [PATCH] try to improve the sheets conversion when the width is less than 280 special_parse.cpp: simplify the code --- src/fileio/special_parse.cpp | 16 +--------------- src/gfx/gfxsheets.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/fileio/special_parse.cpp b/src/fileio/special_parse.cpp index bd2bb670..58a71e24 100644 --- a/src/fileio/special_parse.cpp +++ b/src/fileio/special_parse.cpp @@ -162,21 +162,7 @@ void SpecialParser::next_line(Iter, Iter end) { void SpecialParser::init_block(Iter, Iter) { cur_node++; temp_symbol.clear(); - curSpec.type = eSpecType::NONE; - curSpec.sd1 = -1; - curSpec.sd2 = -1; - curSpec.m1 = -1; - curSpec.m2 = -1; - curSpec.m3 = -1; - curSpec.pic = -1; - curSpec.pictype = 4; // PIC_DLOG - curSpec.ex1a = -1; - curSpec.ex1b = -1; - curSpec.ex1c = -1; - curSpec.ex2a = -1; - curSpec.ex2b = -1; - curSpec.ex2c = -1; - curSpec.jumpto = -1; + curSpec = cSpecial(); } void SpecialParser::prep_add_symbol(Iter start, Iter end) { diff --git a/src/gfx/gfxsheets.cpp b/src/gfx/gfxsheets.cpp index 5e2ad7b6..6c968eba 100644 --- a/src/gfx/gfxsheets.cpp +++ b/src/gfx/gfxsheets.cpp @@ -49,11 +49,12 @@ size_t cCustomGraphics::count(bool party) { else if(party && !party_sheet) return 0; else if(is_old || party) { rectangle bounds(party ? party_sheet : sheets[0]); - if(bounds.width() < 280) return bounds.width() / 28; + // let assume that each row have 10 element, even if(bounds.width() < 280) return 10 * bounds.height() / 36; } else { size_t count = 100 * (numSheets - 1); rectangle bounds(sheets[numSheets - 1]); + // CHECKME: we probably want to assume that each row have 10 elements if(bounds.width() < 280) count += bounds.width() / 28; else count += 10 * bounds.height() / 36; return count; @@ -125,9 +126,9 @@ void cCustomGraphics::convert_sheets() { fs::path pic_dir = tempDir/scenario_temp_dir_name/"graphics"; for(size_t i = 0; i < numSheets; i++) { sf::IntRect subrect; - subrect.top = i * 280; - subrect.width = 280; - subrect.height = 360; + subrect.top = i * 360; + subrect.width = std::min(280, int(old_graph.getSize().x)); + subrect.height = std::min(360, int(old_graph.getSize().y-i*360)); sf::Image sheet; sheet.create(280, 360);