Parsing of colors moved to TileGenerator.

This commit is contained in:
Miroslav Bendík
2012-08-23 12:55:31 +02:00
parent 3d54e5edaa
commit 957a72e2b4
4 changed files with 58 additions and 49 deletions

View File

@ -7,8 +7,13 @@
* =====================================================================
*/
#include <cstdlib>
#include <fstream>
#include <iostream>
#include "TileGenerator.h"
using namespace std;
TileGenerator::TileGenerator():
m_bgColor("#ffffff"),
m_scaleColor("#000000"),
@ -70,3 +75,36 @@ void TileGenerator::generate(const std::string &/*input*/, const std::string &/*
{
}
void TileGenerator::parseColorsFile(const std::string &fileName)
{
ifstream in;
in.open(fileName.c_str(), ifstream::in);
if (!in.is_open()) {
std::cerr << "File colors.txt does not exist" << std::endl;
exit(-2);
}
while (in.good()) {
string name;
Color color;
in >> name;
if (name[0] == '#') {
in.ignore(65536, '\n');
in >> name;
}
while (name == "\n" && in.good()) {
in >> name;
}
int r, g, b;
in >> r;
in >> g;
in >> b;
if (in.good()) {
m_colors[name] = color;
color.r = r;
color.g = g;
color.b = b;
}
}
}