Add an option to print progress information while generating the map.
This commit is contained in:
parent
db2d27c077
commit
c1f2df705b
@ -13,6 +13,7 @@
|
||||
#include <fstream>
|
||||
#include <gdfontmb.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cerrno>
|
||||
@ -113,6 +114,7 @@ static inline Color mixColors(Color a, Color b)
|
||||
TileGenerator::TileGenerator():
|
||||
verboseCoordinates(false),
|
||||
verboseStatistics(false),
|
||||
progressIndicator(false),
|
||||
m_bgColor(255, 255, 255),
|
||||
m_scaleColor(0, 0, 0),
|
||||
m_originColor(255, 0, 0),
|
||||
@ -254,6 +256,11 @@ void TileGenerator::setShading(bool shading)
|
||||
m_shading = shading;
|
||||
}
|
||||
|
||||
void TileGenerator::enableProgressIndicator(void)
|
||||
{
|
||||
progressIndicator = true;
|
||||
}
|
||||
|
||||
void TileGenerator::setGeometry(int x, int y, int w, int h)
|
||||
{
|
||||
if (x > 0) {
|
||||
@ -665,6 +672,8 @@ void TileGenerator::renderMap()
|
||||
area_rendered++;
|
||||
if (currentPos.z != pos.z && currentPos.z != INT_MIN && m_shading)
|
||||
renderShading(currentPos.z);
|
||||
if (progressIndicator && currentPos.z != pos.z)
|
||||
cout << "Processing Z-coordinate: " << std::setw(5) << pos.z*16 << "\r" << std::flush;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
m_readedPixels[i] = 0;
|
||||
}
|
||||
@ -779,6 +788,8 @@ void TileGenerator::renderMap()
|
||||
<< "/" << (m_xMax-m_xMin+1) * (m_zMax-m_zMin+1)
|
||||
<< " (" << (long long)area_rendered*16*16 << " nodes)"
|
||||
<< std::endl;
|
||||
else if (progressIndicator)
|
||||
cout << std::setw(40) << "" << "\r";
|
||||
}
|
||||
|
||||
inline void TileGenerator::renderMapBlock(const unsigned_string &mapBlock, const BlockPos &pos, int version)
|
||||
|
@ -126,6 +126,7 @@ public:
|
||||
void setTileBorderSize(int size);
|
||||
void setTileSize(int width, int heigth);
|
||||
void setTileOrigin(int x, int y);
|
||||
void enableProgressIndicator(void);
|
||||
void parseColorsFile(const std::string &fileName);
|
||||
void setBackend(std::string backend);
|
||||
void generate(const std::string &input, const std::string &output);
|
||||
@ -152,6 +153,7 @@ private:
|
||||
public:
|
||||
bool verboseCoordinates;
|
||||
bool verboseStatistics;
|
||||
bool progressIndicator;
|
||||
|
||||
private:
|
||||
Color m_bgColor;
|
||||
|
@ -19,6 +19,7 @@
|
||||
using namespace std;
|
||||
|
||||
#define OPT_SQLITE_CACHEWORLDROW 0x81
|
||||
#define OPT_PROGRESS_INDICATOR 0x82
|
||||
|
||||
void usage()
|
||||
{
|
||||
@ -44,6 +45,7 @@ void usage()
|
||||
" --tiles <tilesize>[+<border>]\n"
|
||||
" --tileorigin x:y|center-world|center-map\n"
|
||||
" --verbose\n"
|
||||
" --progress\n"
|
||||
"Color format: '#000000'\n";
|
||||
std::cout << usage_text;
|
||||
}
|
||||
@ -74,6 +76,7 @@ int main(int argc, char *argv[])
|
||||
{"tileorigin", required_argument, 0, 'T'},
|
||||
{"tilebordercolor", required_argument, 0, 'B'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"progress", no_argument, 0, OPT_PROGRESS_INDICATOR},
|
||||
};
|
||||
|
||||
string input;
|
||||
@ -140,6 +143,9 @@ int main(int argc, char *argv[])
|
||||
case OPT_SQLITE_CACHEWORLDROW:
|
||||
generator.setSqliteCacheWorldRow(true);
|
||||
break;
|
||||
case OPT_PROGRESS_INDICATOR:
|
||||
generator.enableProgressIndicator();
|
||||
break;
|
||||
case 'a': {
|
||||
istringstream iss;
|
||||
iss.str(optarg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user