From 3d54e5edaaab6ca0ed2928c840627a94b96a42cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bend=C3=ADk?= Date: Thu, 23 Aug 2012 12:46:22 +0200 Subject: [PATCH] Added class TileGenerator. --- CMakeLists.txt | 2 ++ TileGenerator.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++ TileGenerator.h | 42 +++++++++++++++++++++++++++ mapper.cpp | 27 ++++++++---------- 4 files changed, 127 insertions(+), 16 deletions(-) create mode 100644 TileGenerator.cpp create mode 100644 TileGenerator.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6af67cc..f677200 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,12 @@ include_directories( ) set(mapper_HDRS + TileGenerator.h ) set(mapper_SRCS mapper.cpp + TileGenerator.cpp ) add_executable(minetest_mapper diff --git a/TileGenerator.cpp b/TileGenerator.cpp new file mode 100644 index 0000000..030d1e1 --- /dev/null +++ b/TileGenerator.cpp @@ -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*/) +{ +} + diff --git a/TileGenerator.h b/TileGenerator.h new file mode 100644 index 0000000..047db31 --- /dev/null +++ b/TileGenerator.h @@ -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 + +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 */ + diff --git a/mapper.cpp b/mapper.cpp index f468569..1721671 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "TileGenerator.h" using namespace std; @@ -95,17 +96,11 @@ int main(int argc, char *argv[]) {"drawscale", no_argument, 0, 'S'}, {"drawunderground", no_argument, 0, 'U'} }; + string input; 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 c = 0; while (1) { @@ -129,28 +124,28 @@ int main(int argc, char *argv[]) output = optarg; break; case 'b': - bgcolor = optarg; + generator.setBgColor(optarg); break; case 's': - scalecolor = optarg; + generator.setScaleColor(optarg); break; case 'r': - origincolor = optarg; + generator.setOriginColor(optarg); break; case 'p': - playercolor = optarg; + generator.setPlayerColor(optarg); break; case 'R': - draworigin = true; + generator.setDrawOrigin(true); break; case 'P': - drawplayers = true; + generator.setDrawPlayers(true); break; case 'S': - drawscale = true; + generator.setDrawScale(true); break; case 'U': - drawunderground = true; + generator.setDrawScale(true); break; default: abort();