Re-add --backend to allow overriding auto-detected backend

This commit is contained in:
sfan5 2014-07-11 10:54:50 +02:00
parent bca8d3ce07
commit 2cc1ffc543
3 changed files with 22 additions and 7 deletions

@ -96,6 +96,7 @@ TileGenerator::TileGenerator():
m_drawScale(false), m_drawScale(false),
m_drawAlpha(false), m_drawAlpha(false),
m_shading(true), m_shading(true),
m_backend(""),
m_border(0), m_border(0),
m_image(0), m_image(0),
m_xMin(INT_MAX), m_xMin(INT_MAX),
@ -181,6 +182,11 @@ void TileGenerator::setShading(bool shading)
m_shading = shading; m_shading = shading;
} }
void TileGenerator::setBackend(std::string backend)
{
m_backend = backend;
}
void TileGenerator::setGeometry(int x, int y, int w, int h) void TileGenerator::setGeometry(int x, int y, int w, int h)
{ {
if (x > 0) { if (x > 0) {
@ -284,11 +290,14 @@ void TileGenerator::parseColorsStream(std::istream &in)
void TileGenerator::openDb(const std::string &input) void TileGenerator::openDb(const std::string &input)
{ {
std::ifstream ifs((input + "/world.mt").c_str()); std::string backend = m_backend;
if(!ifs.good()) if(backend == "") {
throw std::runtime_error("Failed to read world.mt"); std::ifstream ifs((input + "/world.mt").c_str());
std::string backend = get_setting("backend", ifs); if(!ifs.good())
ifs.close(); throw std::runtime_error("Failed to read world.mt");
backend = get_setting("backend", ifs);
ifs.close();
}
if(backend == "sqlite3") if(backend == "sqlite3")
m_db = new DBSQLite3(input); m_db = new DBSQLite3(input);

@ -86,6 +86,7 @@ private:
bool m_drawScale; bool m_drawScale;
bool m_drawAlpha; bool m_drawAlpha;
bool m_shading; bool m_shading;
std::string m_backend;
int m_border; int m_border;
DB *m_db; DB *m_db;

@ -34,6 +34,7 @@ void usage()
" --noshading\n" " --noshading\n"
" --min-y <y>\n" " --min-y <y>\n"
" --max-y <y>\n" " --max-y <y>\n"
" --backend <backend>\n"
" --geometry x:y+w+h\n" " --geometry x:y+w+h\n"
"Color format: '#000000'\n"; "Color format: '#000000'\n";
std::cout << usage_text; std::cout << usage_text;
@ -55,6 +56,7 @@ int main(int argc, char *argv[])
{"drawscale", no_argument, 0, 'S'}, {"drawscale", no_argument, 0, 'S'},
{"drawalpha", no_argument, 0, 'e'}, {"drawalpha", no_argument, 0, 'e'},
{"noshading", no_argument, 0, 'H'}, {"noshading", no_argument, 0, 'H'},
{"backend", required_argument, 0, 'd'},
{"geometry", required_argument, 0, 'g'}, {"geometry", required_argument, 0, 'g'},
{"min-y", required_argument, 0, 'a'}, {"min-y", required_argument, 0, 'a'},
{"max-y", required_argument, 0, 'c'} {"max-y", required_argument, 0, 'c'}
@ -109,11 +111,14 @@ int main(int argc, char *argv[])
generator.setDrawScale(true); generator.setDrawScale(true);
break; break;
case 'e': case 'e':
generator.setDrawAlpha(true); generator.setDrawAlpha(true);
break; break;
case 'H': case 'H':
generator.setShading(false); generator.setShading(false);
break; break;
case 'd':
generator.setBackend(optarg);
break;
case 'a': { case 'a': {
istringstream iss; istringstream iss;
iss.str(optarg); iss.str(optarg);