Added class TileGenerator.

This commit is contained in:
Miroslav Bendík 2012-08-23 12:46:22 +02:00
parent 6a4083d28c
commit 3d54e5edaa
4 changed files with 127 additions and 16 deletions

@ -28,10 +28,12 @@ include_directories(
) )
set(mapper_HDRS set(mapper_HDRS
TileGenerator.h
) )
set(mapper_SRCS set(mapper_SRCS
mapper.cpp mapper.cpp
TileGenerator.cpp
) )
add_executable(minetest_mapper add_executable(minetest_mapper

72
TileGenerator.cpp Normal file

@ -0,0 +1,72 @@
/*
* =====================================================================
* Version: 1.0
* Created: 23.08.2012 12:35:53
* Author: Miroslav Bendík
* Company: LinuxOS.sk
* =====================================================================
*/
#include "TileGenerator.h"
TileGenerator::TileGenerator():
m_bgColor("#ffffff"),
m_scaleColor("#000000"),
m_originColor("#ff0000"),
m_playerColor("#ff0000"),
m_drawOrigin(false),
m_drawPlayers(false),
m_drawScale(false),
m_drawUnderground(false)
{
}
TileGenerator::~TileGenerator()
{
}
void TileGenerator::setBgColor(const std::string &bgColor)
{
m_bgColor = bgColor;
}
void TileGenerator::setScaleColor(const std::string &scaleColor)
{
m_scaleColor = scaleColor;
}
void TileGenerator::setOriginColor(const std::string &originColor)
{
m_originColor = originColor;
}
void TileGenerator::setPlayerColor(const std::string &playerColor)
{
m_playerColor = playerColor;
}
void TileGenerator::setDrawOrigin(bool drawOrigin)
{
m_drawOrigin = drawOrigin;
}
void TileGenerator::setDrawPlayers(bool drawPlayers)
{
m_drawPlayers = drawPlayers;
}
void TileGenerator::setDrawScale(bool drawScale)
{
m_drawScale = drawScale;
}
void TileGenerator::setDrawUnderground(bool drawUnderground)
{
m_drawUnderground = drawUnderground;
}
void TileGenerator::generate(const std::string &/*input*/, const std::string &/*output*/)
{
}

42
TileGenerator.h Normal file

@ -0,0 +1,42 @@
/*
* =====================================================================
* Version: 1.0
* Created: 23.08.2012 12:35:59
* Author: Miroslav Bendík
* Company: LinuxOS.sk
* =====================================================================
*/
#ifndef TILEGENERATOR_H_JJNUCARH
#define TILEGENERATOR_H_JJNUCARH
#include <string>
class TileGenerator
{
public:
TileGenerator();
~TileGenerator();
void setBgColor(const std::string &bgColor);
void setScaleColor(const std::string &scaleColor);
void setOriginColor(const std::string &originColor);
void setPlayerColor(const std::string &playerColor);
void setDrawOrigin(bool drawOrigin);
void setDrawPlayers(bool drawPlayers);
void setDrawScale(bool drawScale);
void setDrawUnderground(bool drawUnderground);
void generate(const std::string &input, const std::string &output);
private:
std::string m_bgColor;
std::string m_scaleColor;
std::string m_originColor;
std::string m_playerColor;
bool m_drawOrigin;
bool m_drawPlayers;
bool m_drawScale;
bool m_drawUnderground;
}; /* ----- end of class TileGenerator ----- */
#endif /* end of include guard: TILEGENERATOR_H_JJNUCARH */

@ -14,6 +14,7 @@
#include <map> #include <map>
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
#include "TileGenerator.h"
using namespace std; using namespace std;
@ -95,17 +96,11 @@ int main(int argc, char *argv[])
{"drawscale", no_argument, 0, 'S'}, {"drawscale", no_argument, 0, 'S'},
{"drawunderground", no_argument, 0, 'U'} {"drawunderground", no_argument, 0, 'U'}
}; };
string input; string input;
string output; string output;
string bgcolor = "#ffffff";
string scalecolor = "#000000";
string origincolor = "#ff0000";
string playercolor = "#ff0000";
bool draworigin = false;
bool drawplayers = false;
bool drawscale = false;
bool drawunderground = false;
TileGenerator generator;
int option_index = 0; int option_index = 0;
int c = 0; int c = 0;
while (1) { while (1) {
@ -129,28 +124,28 @@ int main(int argc, char *argv[])
output = optarg; output = optarg;
break; break;
case 'b': case 'b':
bgcolor = optarg; generator.setBgColor(optarg);
break; break;
case 's': case 's':
scalecolor = optarg; generator.setScaleColor(optarg);
break; break;
case 'r': case 'r':
origincolor = optarg; generator.setOriginColor(optarg);
break; break;
case 'p': case 'p':
playercolor = optarg; generator.setPlayerColor(optarg);
break; break;
case 'R': case 'R':
draworigin = true; generator.setDrawOrigin(true);
break; break;
case 'P': case 'P':
drawplayers = true; generator.setDrawPlayers(true);
break; break;
case 'S': case 'S':
drawscale = true; generator.setDrawScale(true);
break; break;
case 'U': case 'U':
drawunderground = true; generator.setDrawScale(true);
break; break;
default: default:
abort(); abort();