aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cpp1
-rw-r--r--src/client/client.h1
-rw-r--r--src/client/game.cpp75
-rw-r--r--src/client/hud.cpp30
-rw-r--r--src/client/hud.h2
-rw-r--r--src/client/mapblock_mesh.cpp2
-rw-r--r--src/client/minimap.cpp237
-rw-r--r--src/client/minimap.h41
8 files changed, 263 insertions, 126 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp
index d6e529c40..7fafe0da9 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -129,6 +129,7 @@ Client::Client(
if (g_settings->getBool("enable_minimap")) {
m_minimap = new Minimap(this);
}
+
m_cache_save_interval = g_settings->getU16("server_map_save_interval");
}
diff --git a/src/client/client.h b/src/client/client.h
index 733634db1..8f4aac6e3 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -223,6 +223,7 @@ public:
void handleCommand_CSMRestrictionFlags(NetworkPacket *pkt);
void handleCommand_PlayerSpeed(NetworkPacket *pkt);
void handleCommand_MediaPush(NetworkPacket *pkt);
+ void handleCommand_MinimapModes(NetworkPacket *pkt);
void ProcessData(NetworkPacket *pkt);
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 366464467..54e0c9f20 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -1416,11 +1416,9 @@ bool Game::createClient(const GameStartData &start_data)
}
mapper = client->getMinimap();
- if (mapper) {
- mapper->setMinimapMode(MINIMAP_MODE_OFF);
- if (client->modsLoaded())
- client->getScript()->on_minimap_ready(mapper);
- }
+
+ if (mapper && client->modsLoaded())
+ client->getScript()->on_minimap_ready(mapper);
return true;
}
@@ -2222,52 +2220,37 @@ void Game::toggleMinimap(bool shift_pressed)
if (!mapper || !m_game_ui->m_flags.show_hud || !g_settings->getBool("enable_minimap"))
return;
- if (shift_pressed) {
+ if (shift_pressed)
mapper->toggleMinimapShape();
- return;
- }
+ else
+ mapper->nextMode();
+
+ // TODO: When legacy minimap is deprecated, keep only HUD minimap stuff here
+ // Not so satisying code to keep compatibility with old fixed mode system
+ // -->
u32 hud_flags = client->getEnv().getLocalPlayer()->hud_flags;
- MinimapMode mode = MINIMAP_MODE_OFF;
- if (hud_flags & HUD_FLAG_MINIMAP_VISIBLE) {
- mode = mapper->getMinimapMode();
- mode = (MinimapMode)((int)mode + 1);
- // If radar is disabled and in, or switching to, radar mode
- if (!(hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE) && mode > 3)
- mode = MINIMAP_MODE_OFF;
- }
+ if (!(hud_flags & HUD_FLAG_MINIMAP_VISIBLE)) {
+ m_game_ui->m_flags.show_minimap = false;
+ } else {
- m_game_ui->m_flags.show_minimap = true;
- switch (mode) {
- case MINIMAP_MODE_SURFACEx1:
- m_game_ui->showTranslatedStatusText("Minimap in surface mode, Zoom x1");
- break;
- case MINIMAP_MODE_SURFACEx2:
- m_game_ui->showTranslatedStatusText("Minimap in surface mode, Zoom x2");
- break;
- case MINIMAP_MODE_SURFACEx4:
- m_game_ui->showTranslatedStatusText("Minimap in surface mode, Zoom x4");
- break;
- case MINIMAP_MODE_RADARx1:
- m_game_ui->showTranslatedStatusText("Minimap in radar mode, Zoom x1");
- break;
- case MINIMAP_MODE_RADARx2:
- m_game_ui->showTranslatedStatusText("Minimap in radar mode, Zoom x2");
- break;
- case MINIMAP_MODE_RADARx4:
- m_game_ui->showTranslatedStatusText("Minimap in radar mode, Zoom x4");
- break;
- default:
- mode = MINIMAP_MODE_OFF;
- m_game_ui->m_flags.show_minimap = false;
- if (hud_flags & HUD_FLAG_MINIMAP_VISIBLE)
- m_game_ui->showTranslatedStatusText("Minimap hidden");
- else
- m_game_ui->showTranslatedStatusText("Minimap currently disabled by game or mod");
- }
+ // If radar is disabled, try to find a non radar mode or fall back to 0
+ if (!(hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE))
+ while (mapper->getModeIndex() &&
+ mapper->getModeDef().type == MINIMAP_TYPE_RADAR)
+ mapper->nextMode();
- mapper->setMinimapMode(mode);
+ m_game_ui->m_flags.show_minimap = mapper->getModeDef().type !=
+ MINIMAP_TYPE_OFF;
+ }
+ // <--
+ // End of 'not so satifying code'
+ if ((hud_flags & HUD_FLAG_MINIMAP_VISIBLE) ||
+ (hud && hud->hasElementOfType(HUD_ELEM_MINIMAP)))
+ m_game_ui->showStatusText(utf8_to_wide(mapper->getModeDef().label));
+ else
+ m_game_ui->showTranslatedStatusText("Minimap currently disabled by game or mod");
}
void Game::toggleFog()
@@ -3954,7 +3937,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
/*
Update minimap pos and rotation
*/
- if (mapper && m_game_ui->m_flags.show_minimap && m_game_ui->m_flags.show_hud) {
+ if (mapper && m_game_ui->m_flags.show_hud) {
mapper->setPos(floatToInt(player->getPosition(), BS));
mapper->setAngle(player->getYaw());
}
diff --git a/src/client/hud.cpp b/src/client/hud.cpp
index d3038230c..f6497fe25 100644
--- a/src/client/hud.cpp
+++ b/src/client/hud.cpp
@@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mesh.h"
#include "wieldmesh.h"
#include "client/renderingengine.h"
+#include "client/minimap.h"
#ifdef HAVE_TOUCHSCREENGUI
#include "gui/touchscreengui.h"
@@ -297,6 +298,18 @@ void Hud::drawItems(v2s32 upperleftpos, v2s32 screen_offset, s32 itemcount,
}
}
+bool Hud::hasElementOfType(HudElementType type)
+{
+ for (size_t i = 0; i != player->maxHudId(); i++) {
+ HudElement *e = player->getHud(i);
+ if (!e)
+ continue;
+ if (e->type == type)
+ return true;
+ }
+ return false;
+}
+
// Calculates screen position of waypoint. Returns true if waypoint is visible (in front of the player), else false.
bool Hud::calculateScreenPos(const v3s16 &camera_offset, HudElement *e, v2s32 *pos)
{
@@ -491,7 +504,22 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
default:
break;
}
-
+ break; }
+ case HUD_ELEM_MINIMAP: {
+ if (e->size.X <= 0 || e->size.Y <= 0)
+ break;
+ if (!client->getMinimap())
+ break;
+ // Draw a minimap of size "size"
+ v2s32 dstsize(e->size.X * m_scale_factor,
+ e->size.Y * m_scale_factor);
+ // (no percent size as minimap would likely be anamorphosed)
+ v2s32 offset((e->align.X - 1.0) * dstsize.X / 2,
+ (e->align.Y - 1.0) * dstsize.Y / 2);
+ core::rect<s32> rect(0, 0, dstsize.X, dstsize.Y);
+ rect += pos + offset + v2s32(e->offset.X * m_scale_factor,
+ e->offset.Y * m_scale_factor);
+ client->getMinimap()->drawMinimap(rect);
break; }
default:
infostream << "Hud::drawLuaElements: ignoring drawform " << e->type <<
diff --git a/src/client/hud.h b/src/client/hud.h
index cf83cb16e..d46545d71 100644
--- a/src/client/hud.h
+++ b/src/client/hud.h
@@ -81,6 +81,8 @@ public:
m_selected_face_normal = face_normal;
}
+ bool hasElementOfType(HudElementType type);
+
void drawLuaElements(const v3s16 &camera_offset);
private:
diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp
index 2f96ca61f..b59679523 100644
--- a/src/client/mapblock_mesh.cpp
+++ b/src/client/mapblock_mesh.cpp
@@ -1044,7 +1044,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
m_use_tangent_vertices = data->m_use_tangent_vertices;
m_enable_vbo = g_settings->getBool("enable_vbo");
- if (g_settings->getBool("enable_minimap")) {
+ if (data->m_client->getMinimap()) {
m_minimap_mapblock = new MinimapMapblock;
m_minimap_mapblock->getMinimapNodes(
&data->m_vmanip, data->m_blockpos * MAP_BLOCKSIZE);
diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp
index 68770ec19..6bae408b4 100644
--- a/src/client/minimap.cpp
+++ b/src/client/minimap.cpp
@@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "shader.h"
#include "mapblock.h"
#include "client/renderingengine.h"
-
+#include "gettext.h"
////
//// MinimapUpdateThread
@@ -108,8 +108,11 @@ void MinimapUpdateThread::doUpdate()
}
}
- if (data->map_invalidated && data->mode != MINIMAP_MODE_OFF) {
- getMap(data->pos, data->map_size, data->scan_height);
+
+ if (data->map_invalidated && (
+ data->mode.type == MINIMAP_TYPE_RADAR ||
+ data->mode.type == MINIMAP_TYPE_SURFACE)) {
+ getMap(data->pos, data->mode.map_size, data->mode.scan_height);
data->map_invalidated = false;
}
}
@@ -181,19 +184,26 @@ Minimap::Minimap(Client *client)
this->m_ndef = client->getNodeDefManager();
m_angle = 0.f;
+ m_current_mode_index = 0;
// Initialize static settings
m_enable_shaders = g_settings->getBool("enable_shaders");
m_surface_mode_scan_height =
g_settings->getBool("minimap_double_scan_height") ? 256 : 128;
+ // Initialize minimap modes
+ addMode(MINIMAP_TYPE_OFF);
+ addMode(MINIMAP_TYPE_SURFACE, 256);
+ addMode(MINIMAP_TYPE_SURFACE, 128);
+ addMode(MINIMAP_TYPE_SURFACE, 64);
+ addMode(MINIMAP_TYPE_RADAR, 512);
+ addMode(MINIMAP_TYPE_RADAR, 256);
+ addMode(MINIMAP_TYPE_RADAR, 128);
+
// Initialize minimap data
data = new MinimapData;
- data->mode = MINIMAP_MODE_OFF;
- data->is_radar = false;
- data->map_invalidated = true;
- data->texture = NULL;
- data->heightmap_texture = NULL;
+ data->map_invalidated = true;
+
data->minimap_shape_round = g_settings->getBool("minimap_shape_round");
// Get round minimap textures
@@ -215,6 +225,8 @@ Minimap::Minimap(Client *client)
// Create object marker texture
data->object_marker_red = m_tsrc->getTexture("object_marker_red.png");
+ setModeIndex(0);
+
// Create mesh buffer for minimap
m_meshbuffer = getMinimapMeshBuffer();
@@ -280,29 +292,101 @@ MinimapShape Minimap::getMinimapShape()
return MINIMAP_SHAPE_SQUARE;
}
-void Minimap::setMinimapMode(MinimapMode mode)
+void Minimap::setModeIndex(size_t index)
{
- static const MinimapModeDef modedefs[MINIMAP_MODE_COUNT] = {
- {false, 0, 0},
- {false, m_surface_mode_scan_height, 256},
- {false, m_surface_mode_scan_height, 128},
- {false, m_surface_mode_scan_height, 64},
- {true, 32, 128},
- {true, 32, 64},
- {true, 32, 32}
- };
-
- if (mode >= MINIMAP_MODE_COUNT)
- return;
-
MutexAutoLock lock(m_mutex);
- data->is_radar = modedefs[mode].is_radar;
- data->scan_height = modedefs[mode].scan_height;
- data->map_size = modedefs[mode].map_size;
- data->mode = mode;
+ if (index < m_modes.size()) {
+ data->mode = m_modes[index];
+ m_current_mode_index = index;
+ } else {
+ data->mode = MinimapModeDef{MINIMAP_TYPE_OFF, N_("Minimap hidden"), 0, 0, ""};
+ m_current_mode_index = 0;
+ }
+
+ data->map_invalidated = true;
- m_minimap_update_thread->deferUpdate();
+ if (m_minimap_update_thread)
+ m_minimap_update_thread->deferUpdate();
+}
+
+void Minimap::addMode(MinimapModeDef mode)
+{
+ // Check validity
+ if (mode.type == MINIMAP_TYPE_TEXTURE) {
+ if (mode.texture.empty())
+ return;
+ if (mode.scale < 1)
+ mode.scale = 1;
+ }
+
+ int zoom = -1;
+
+ // Build a default standard label
+ if (mode.label == "") {
+ switch (mode.type) {
+ case MINIMAP_TYPE_OFF:
+ mode.label = N_("Minimap hidden");
+ break;
+ case MINIMAP_TYPE_SURFACE:
+ mode.label = N_("Minimap in surface mode, Zoom x%d");
+ if (mode.map_size > 0)
+ zoom = 256 / mode.map_size;
+ break;
+ case MINIMAP_TYPE_RADAR:
+ mode.label = N_("Minimap in radar mode, Zoom x%d");
+ if (mode.map_size > 0)
+ zoom = 512 / mode.map_size;
+ break;
+ case MINIMAP_TYPE_TEXTURE:
+ mode.label = N_("Minimap in texture mode");
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (zoom >= 0) {
+ char label_buf[1024];
+ porting::mt_snprintf(label_buf, sizeof(label_buf),
+ mode.label.c_str(), zoom);
+ mode.label = label_buf;
+ }
+
+ m_modes.push_back(mode);
+}
+
+void Minimap::addMode(MinimapType type, u16 size, std::string label,
+ std::string texture, u16 scale)
+{
+ MinimapModeDef mode;
+ mode.type = type;
+ mode.label = label;
+ mode.map_size = size;
+ mode.texture = texture;
+ mode.scale = scale;
+ switch (type) {
+ case MINIMAP_TYPE_SURFACE:
+ mode.scan_height = m_surface_mode_scan_height;
+ break;
+ case MINIMAP_TYPE_RADAR:
+ mode.scan_height = 32;
+ break;
+ default:
+ mode.scan_height = 0;
+ }
+ addMode(mode);
+}
+
+void Minimap::nextMode()
+{
+ if (m_modes.empty())
+ return;
+ m_current_mode_index++;
+ if (m_current_mode_index >= m_modes.size())
+ m_current_mode_index = 0;
+
+ setModeIndex(m_current_mode_index);
}
void Minimap::setPos(v3s16 pos)
@@ -331,16 +415,16 @@ void Minimap::setAngle(f32 angle)
void Minimap::blitMinimapPixelsToImageRadar(video::IImage *map_image)
{
video::SColor c(240, 0, 0, 0);
- for (s16 x = 0; x < data->map_size; x++)
- for (s16 z = 0; z < data->map_size; z++) {
- MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->map_size];
+ for (s16 x = 0; x < data->mode.map_size; x++)
+ for (s16 z = 0; z < data->mode.map_size; z++) {
+ MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->mode.map_size];
if (mmpixel->air_count > 0)
c.setGreen(core::clamp(core::round32(32 + mmpixel->air_count * 8), 0, 255));
else
c.setGreen(0);
- map_image->setPixel(x, data->map_size - z - 1, c);
+ map_image->setPixel(x, data->mode.map_size - z - 1, c);
}
}
@@ -349,9 +433,9 @@ void Minimap::blitMinimapPixelsToImageSurface(
{
// This variable creation/destruction has a 1% cost on rendering minimap
video::SColor tilecolor;
- for (s16 x = 0; x < data->map_size; x++)
- for (s16 z = 0; z < data->map_size; z++) {
- MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->map_size];
+ for (s16 x = 0; x < data->mode.map_size; x++)
+ for (s16 z = 0; z < data->mode.map_size; z++) {
+ MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->mode.map_size];
const ContentFeatures &f = m_ndef->get(mmpixel->n);
const TileDef *tile = &f.tiledef[0];
@@ -367,10 +451,10 @@ void Minimap::blitMinimapPixelsToImageSurface(
tilecolor.setBlue(tilecolor.getBlue() * f.minimap_color.getBlue() / 255);
tilecolor.setAlpha(240);
- map_image->setPixel(x, data->map_size - z - 1, tilecolor);
+ map_image->setPixel(x, data->mode.map_size - z - 1, tilecolor);
u32 h = mmpixel->height;
- heightmap_image->setPixel(x,data->map_size - z - 1,
+ heightmap_image->setPixel(x,data->mode.map_size - z - 1,
video::SColor(255, h, h, h));
}
}
@@ -378,21 +462,46 @@ void Minimap::blitMinimapPixelsToImageSurface(
video::ITexture *Minimap::getMinimapTexture()
{
// update minimap textures when new scan is ready
- if (data->map_invalidated)
+ if (data->map_invalidated && data->mode.type != MINIMAP_TYPE_TEXTURE)
return data->texture;
// create minimap and heightmap images in memory
- core::dimension2d<u32> dim(data->map_size, data->map_size);
+ core::dimension2d<u32> dim(data->mode.map_size, data->mode.map_size);
video::IImage *map_image = driver->createImage(video::ECF_A8R8G8B8, dim);
video::IImage *heightmap_image = driver->createImage(video::ECF_A8R8G8B8, dim);
video::IImage *minimap_image = driver->createImage(video::ECF_A8R8G8B8,
core::dimension2d<u32>(MINIMAP_MAX_SX, MINIMAP_MAX_SY));
// Blit MinimapPixels to images
- if (data->is_radar)
- blitMinimapPixelsToImageRadar(map_image);
- else
+ switch(data->mode.type) {
+ case MINIMAP_TYPE_OFF:
+ break;
+ case MINIMAP_TYPE_SURFACE:
blitMinimapPixelsToImageSurface(map_image, heightmap_image);
+ break;
+ case MINIMAP_TYPE_RADAR:
+ blitMinimapPixelsToImageRadar(map_image);
+ break;
+ case MINIMAP_TYPE_TEXTURE:
+ // Want to use texture source, to : 1 find texture, 2 cache it
+ video::ITexture* texture = m_tsrc->getTexture(data->mode.texture);
+ video::IImage* image = driver->createImageFromData(
+ texture->getColorFormat(), texture->getSize(), texture->lock(), true, false);
+ texture->unlock();
+
+ auto dim = image->getDimension();
+
+ map_image->fill(video::SColor(255, 0, 0, 0));
+
+ image->copyTo(map_image,
+ irr::core::vector2d<int> {
+ ((data->mode.map_size - (static_cast<int>(dim.Width))) >> 1)
+ - data->pos.X / data->mode.scale,
+ ((data->mode.map_size - (static_cast<int>(dim.Height))) >> 1)
+ + data->pos.Z / data->mode.scale
+ });
+ image->drop();
+ }
map_image->copyToScaling(minimap_image);
map_image->drop();
@@ -461,21 +570,31 @@ scene::SMeshBuffer *Minimap::getMinimapMeshBuffer()
void Minimap::drawMinimap()
{
+ // Non hud managed minimap drawing (legacy minimap)
+ v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
+ const u32 size = 0.25 * screensize.Y;
+
+ drawMinimap(core::rect<s32>(
+ screensize.X - size - 10, 10,
+ screensize.X - 10, size + 10));
+}
+
+void Minimap::drawMinimap(core::rect<s32> rect) {
+
video::ITexture *minimap_texture = getMinimapTexture();
if (!minimap_texture)
return;
+ if (data->mode.type == MINIMAP_TYPE_OFF)
+ return;
+
updateActiveMarkers();
- v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
- const u32 size = 0.25 * screensize.Y;
core::rect<s32> oldViewPort = driver->getViewPort();
core::matrix4 oldProjMat = driver->getTransform(video::ETS_PROJECTION);
core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW);
- driver->setViewPort(core::rect<s32>(
- screensize.X - size - 10, 10,
- screensize.X - 10, size + 10));
+ driver->setViewPort(rect);
driver->setTransform(video::ETS_PROJECTION, core::matrix4());
driver->setTransform(video::ETS_VIEW, core::matrix4());
@@ -488,7 +607,7 @@ void Minimap::drawMinimap()
material.TextureLayer[0].Texture = minimap_texture;
material.TextureLayer[1].Texture = data->heightmap_texture;
- if (m_enable_shaders && !data->is_radar) {
+ if (m_enable_shaders && data->mode.type == MINIMAP_TYPE_SURFACE) {
u16 sid = m_shdrsrc->getShader("minimap_shader", 1, 1);
material.MaterialType = m_shdrsrc->getShaderInfo(sid).material;
} else {
@@ -529,14 +648,14 @@ void Minimap::drawMinimap()
driver->setViewPort(oldViewPort);
// Draw player markers
- v2s32 s_pos(screensize.X - size - 10, 10);
+ v2s32 s_pos(rect.UpperLeftCorner.X, rect.UpperLeftCorner.Y);
core::dimension2di imgsize(data->object_marker_red->getOriginalSize());
core::rect<s32> img_rect(0, 0, imgsize.Width, imgsize.Height);
static const video::SColor col(255, 255, 255, 255);
static const video::SColor c[4] = {col, col, col, col};
f32 sin_angle = std::sin(m_angle * core::DEGTORAD);
f32 cos_angle = std::cos(m_angle * core::DEGTORAD);
- s32 marker_size2 = 0.025 * (float)size;
+ s32 marker_size2 = 0.025 * (float)rect.getWidth();;
for (std::list<v2f>::const_iterator
i = m_active_markers.begin();
i != m_active_markers.end(); ++i) {
@@ -547,8 +666,8 @@ void Minimap::drawMinimap()
posf.X = t1;
posf.Y = t2;
}
- posf.X = (posf.X + 0.5) * (float)size;
- posf.Y = (posf.Y + 0.5) * (float)size;
+ posf.X = (posf.X + 0.5) * (float)rect.getWidth();
+ posf.Y = (posf.Y + 0.5) * (float)rect.getHeight();
core::rect<s32> dest_rect(
s_pos.X + posf.X - marker_size2,
s_pos.Y + posf.Y - marker_size2,
@@ -571,16 +690,16 @@ void Minimap::updateActiveMarkers()
for (Nametag *nametag : nametags) {
v3s16 pos = floatToInt(nametag->parent_node->getAbsolutePosition() +
intToFloat(client->getCamera()->getOffset(), BS), BS);
- pos -= data->pos - v3s16(data->map_size / 2,
- data->scan_height / 2,
- data->map_size / 2);
- if (pos.X < 0 || pos.X > data->map_size ||
- pos.Y < 0 || pos.Y > data->scan_height ||
- pos.Z < 0 || pos.Z > data->map_size) {
+ pos -= data->pos - v3s16(data->mode.map_size / 2,
+ data->mode.scan_height / 2,
+ data->mode.map_size / 2);
+ if (pos.X < 0 || pos.X > data->mode.map_size ||
+ pos.Y < 0 || pos.Y > data->mode.scan_height ||
+ pos.Z < 0 || pos.Z > data->mode.map_size) {
continue;
}
- pos.X = ((float)pos.X / data->map_size) * MINIMAP_MAX_SX;
- pos.Z = ((float)pos.Z / data->map_size) * MINIMAP_MAX_SY;
+ pos.X = ((float)pos.X / data->mode.map_size) * MINIMAP_MAX_SX;
+ pos.Z = ((float)pos.Z / data->mode.map_size) * MINIMAP_MAX_SY;
const video::SColor &mask_col = minimap_mask->getPixel(pos.X, pos.Z);
if (!mask_col.getAlpha()) {
continue;
diff --git a/src/client/minimap.h b/src/client/minimap.h
index 258d5330d..11374b116 100644
--- a/src/client/minimap.h
+++ b/src/client/minimap.h
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
+#include "../hud.h"
#include "irrlichttypes_extrabloated.h"
#include "util/thread.h"
#include "voxel.h"
@@ -33,26 +34,18 @@ class IShaderSource;
#define MINIMAP_MAX_SX 512
#define MINIMAP_MAX_SY 512
-enum MinimapMode {
- MINIMAP_MODE_OFF,
- MINIMAP_MODE_SURFACEx1,
- MINIMAP_MODE_SURFACEx2,
- MINIMAP_MODE_SURFACEx4,
- MINIMAP_MODE_RADARx1,
- MINIMAP_MODE_RADARx2,
- MINIMAP_MODE_RADARx4,
- MINIMAP_MODE_COUNT,
-};
-
enum MinimapShape {
MINIMAP_SHAPE_SQUARE,
MINIMAP_SHAPE_ROUND,
};
struct MinimapModeDef {
- bool is_radar;
+ MinimapType type;
+ std::string label;
u16 scan_height;
u16 map_size;
+ std::string texture;
+ u16 scale;
};
struct MinimapPixel {
@@ -69,12 +62,9 @@ struct MinimapMapblock {
};
struct MinimapData {
- bool is_radar;
- MinimapMode mode;
+ MinimapModeDef mode;
v3s16 pos;
v3s16 old_pos;
- u16 scan_height;
- u16 map_size;
MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
bool map_invalidated;
bool minimap_shape_round;
@@ -127,12 +117,22 @@ public:
v3s16 getPos() const { return data->pos; }
void setAngle(f32 angle);
f32 getAngle() const { return m_angle; }
- void setMinimapMode(MinimapMode mode);
- MinimapMode getMinimapMode() const { return data->mode; }
void toggleMinimapShape();
void setMinimapShape(MinimapShape shape);
MinimapShape getMinimapShape();
+ void clearModes() { m_modes.clear(); };
+ void addMode(MinimapModeDef mode);
+ void addMode(MinimapType type, u16 size = 0, std::string label = "",
+ std::string texture = "", u16 scale = 1);
+
+ void setModeIndex(size_t index);
+ size_t getModeIndex() const { return m_current_mode_index; };
+ size_t getMaxModeIndex() const { return m_modes.size() - 1; };
+ void nextMode();
+
+ void setModesFromString(std::string modes_string);
+ MinimapModeDef getModeDef() const { return data->mode; }
video::ITexture *getMinimapTexture();
@@ -144,6 +144,7 @@ public:
void updateActiveMarkers();
void drawMinimap();
+ void drawMinimap(core::rect<s32> rect);
video::IVideoDriver *driver;
Client* client;
@@ -153,9 +154,11 @@ private:
ITextureSource *m_tsrc;
IShaderSource *m_shdrsrc;
const NodeDefManager *m_ndef;
- MinimapUpdateThread *m_minimap_update_thread;
+ MinimapUpdateThread *m_minimap_update_thread = nullptr;
scene::SMeshBuffer *m_meshbuffer;
bool m_enable_shaders;
+ std::vector<MinimapModeDef> m_modes;
+ size_t m_current_mode_index;
u16 m_surface_mode_scan_height;
f32 m_angle;
std::mutex m_mutex;