Expose getPointedThing to Lua
[oweals/minetest.git] / src / minimap.cpp
index a7f4822c901b572a6f3397693fce50e00c269381..8b240b199302e1b6d0d10b7e811ea17667696b0c 100644 (file)
@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/string.h"
 #include "mapblock.h"
 #include <math.h>
+#include "client/renderingengine.h"
 
 
 ////
@@ -184,10 +185,10 @@ void MinimapUpdateThread::getMap(v3s16 pos, s16 size, s16 height)
 //// Mapper
 ////
 
-Minimap::Minimap(IrrlichtDevice *device, Client *client)
+Minimap::Minimap(Client *client)
 {
        this->client    = client;
-       this->driver    = device->getVideoDriver();
+       this->driver    = RenderingEngine::get_video_driver();
        this->m_tsrc    = client->getTextureSource();
        this->m_shdrsrc = client->getShaderSource();
        this->m_ndef    = client->getNodeDefManager();
@@ -204,8 +205,6 @@ Minimap::Minimap(IrrlichtDevice *device, Client *client)
        data->mode              = MINIMAP_MODE_OFF;
        data->is_radar          = false;
        data->map_invalidated   = true;
-       data->heightmap_image   = NULL;
-       data->minimap_image     = NULL;
        data->texture           = NULL;
        data->heightmap_texture = NULL;
        data->minimap_shape_round = g_settings->getBool("minimap_shape_round");
@@ -272,6 +271,28 @@ void Minimap::toggleMinimapShape()
        m_minimap_update_thread->deferUpdate();
 }
 
+void Minimap::setMinimapShape(MinimapShape shape)
+{
+       MutexAutoLock lock(m_mutex);
+
+       if (shape == MINIMAP_SHAPE_SQUARE)
+               data->minimap_shape_round = false;
+       else if (shape == MINIMAP_SHAPE_ROUND)
+               data->minimap_shape_round = true;
+
+       g_settings->setBool("minimap_shape_round", data->minimap_shape_round);
+       m_minimap_update_thread->deferUpdate();
+}
+
+MinimapShape Minimap::getMinimapShape()
+{
+       if (data->minimap_shape_round) {
+               return MINIMAP_SHAPE_ROUND;
+       } else {
+               return MINIMAP_SHAPE_SQUARE;
+       }
+}
+
 void Minimap::setMinimapMode(MinimapMode mode)
 {
        static const MinimapModeDef modedefs[MINIMAP_MODE_COUNT] = {
@@ -458,7 +479,7 @@ void Minimap::drawMinimap()
                return;
 
        updateActiveMarkers();
-       v2u32 screensize = porting::getWindowSize();
+       v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
        const u32 size = 0.25 * screensize.Y;
 
        core::rect<s32> oldViewPort = driver->getViewPort();