mirror of
https://github.com/minetest/minetestmapper.git
synced 2025-07-02 00:20:22 +02:00
Parsing of colors moved to TileGenerator.
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user