mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-12-27 03:10:37 +01:00
Implemented rendering of names.
This commit is contained in:
parent
3349bee3a4
commit
8396275bf8
@ -25,13 +25,14 @@ find_package_handle_standard_args(LibSqlite3 DEFAULT_MSG LIBSQLITE3_LIBRARY LIB
|
|||||||
|
|
||||||
mark_as_advanced(LIBSQLITE3_INCLUDE_DIR LIBSQLITE3_LIBRARY )
|
mark_as_advanced(LIBSQLITE3_INCLUDE_DIR LIBSQLITE3_LIBRARY )
|
||||||
|
|
||||||
|
find_package(Boost COMPONENTS filesystem)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
"${PROJECT_BINARY_DIR}"
|
"${PROJECT_BINARY_DIR}"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
${LIBSQLITE3_INCLUDE_DIRS}
|
${LIBSQLITE3_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
set(mapper_HDRS
|
set(mapper_HDRS
|
||||||
@ -53,6 +54,7 @@ add_executable(minetest_mapper
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
minetest_mapper
|
minetest_mapper
|
||||||
${LIBSQLITE3_LIBRARIES}
|
${LIBSQLITE3_LIBRARIES}
|
||||||
|
${Boost_LIBRARIES}
|
||||||
gd
|
gd
|
||||||
z
|
z
|
||||||
)
|
)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
#include "TileGenerator.h"
|
#include "TileGenerator.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -241,6 +242,9 @@ void TileGenerator::generate(const std::string &input, const std::string &output
|
|||||||
if (m_drawOrigin) {
|
if (m_drawOrigin) {
|
||||||
renderOrigin();
|
renderOrigin();
|
||||||
}
|
}
|
||||||
|
if (m_drawPlayers) {
|
||||||
|
renderPlayers(input);
|
||||||
|
}
|
||||||
writeImage(output);
|
writeImage(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,6 +544,48 @@ void TileGenerator::renderOrigin()
|
|||||||
gdImageArc(m_image, imageX, imageY, 12, 12, 0, 360, rgb2int(m_originColor.r, m_originColor.g, m_originColor.b));
|
gdImageArc(m_image, imageX, imageY, 12, 12, 0, 360, rgb2int(m_originColor.r, m_originColor.g, m_originColor.b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileGenerator::renderPlayers(const std::string &inputPath)
|
||||||
|
{
|
||||||
|
int color = rgb2int(m_playerColor.r, m_playerColor.g, m_playerColor.b);
|
||||||
|
|
||||||
|
string playersPath = inputPath + "players";
|
||||||
|
boost::filesystem::path path(playersPath.c_str());
|
||||||
|
boost::filesystem::directory_iterator end_iter;
|
||||||
|
boost::filesystem::directory_iterator iter(path);
|
||||||
|
for (; iter != end_iter; ++iter) {
|
||||||
|
if (!boost::filesystem::is_directory(iter->status())) {
|
||||||
|
string path = iter->path().string();
|
||||||
|
|
||||||
|
ifstream in;
|
||||||
|
in.open(path.c_str(), ifstream::in);
|
||||||
|
string buffer;
|
||||||
|
string name;
|
||||||
|
string position;
|
||||||
|
while (getline(in, buffer)) {
|
||||||
|
if (buffer.find("name = ") == 0) {
|
||||||
|
name = buffer.substr(7);
|
||||||
|
}
|
||||||
|
else if (buffer.find("position = ") == 0) {
|
||||||
|
position = buffer.substr(12, buffer.length() - 13);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double x, y, z;
|
||||||
|
char comma;
|
||||||
|
istringstream positionStream(position, istringstream::in);
|
||||||
|
positionStream >> x;
|
||||||
|
positionStream >> comma;
|
||||||
|
positionStream >> y;
|
||||||
|
positionStream >> comma;
|
||||||
|
positionStream >> z;
|
||||||
|
int imageX = x / 10 - m_xMin * 16 + m_border;
|
||||||
|
int imageY = m_mapHeight - (z / 10 - m_zMin * 16) + m_border;
|
||||||
|
|
||||||
|
gdImageArc(m_image, imageX, imageY, 5, 5, 0, 360, color);
|
||||||
|
gdImageString(m_image, gdFontGetMediumBold(), imageX + 2, imageY + 2, reinterpret_cast<unsigned char *>(const_cast<char *>(name.c_str())), color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline std::list<int> TileGenerator::getZValueList() const
|
inline std::list<int> TileGenerator::getZValueList() const
|
||||||
{
|
{
|
||||||
std::list<int> zlist;
|
std::list<int> zlist;
|
||||||
|
@ -99,6 +99,7 @@ private:
|
|||||||
void renderShading(int zPos);
|
void renderShading(int zPos);
|
||||||
void renderScale();
|
void renderScale();
|
||||||
void renderOrigin();
|
void renderOrigin();
|
||||||
|
void renderPlayers(const std::string &inputPath);
|
||||||
void writeImage(const std::string &output);
|
void writeImage(const std::string &output);
|
||||||
int getImageX(int val) const;
|
int getImageX(int val) const;
|
||||||
int getImageY(int val) const;
|
int getImageY(int val) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user