Fix alpha for liquid nodes (#5494)
[oweals/minetest.git] / src / minimap.h
index edb491717e13591ff9e738351270ac8d2610efea..c50530335082bcf80c45be4130af51b88e7d860f 100644 (file)
@@ -20,18 +20,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef MINIMAP_HEADER
 #define MINIMAP_HEADER
 
-#include <map>
-#include <string>
-#include <vector>
 #include "irrlichttypes_extrabloated.h"
 #include "client.h"
 #include "voxel.h"
-#include "jthread/jmutex.h"
-#include "jthread/jsemaphore.h"
+#include "threading/mutex.h"
+#include "threading/semaphore.h"
+#include <map>
+#include <string>
+#include <vector>
+#include "camera.h"
 
 #define MINIMAP_MAX_SX 512
 #define MINIMAP_MAX_SY 512
 
+
 enum MinimapMode {
        MINIMAP_MODE_OFF,
        MINIMAP_MODE_SURFACEx1,
@@ -43,6 +45,11 @@ enum MinimapMode {
        MINIMAP_MODE_COUNT,
 };
 
+enum MinimapShape {
+       MINIMAP_SHAPE_SQUARE,
+       MINIMAP_SHAPE_ROUND,
+};
+
 struct MinimapModeDef {
        bool is_radar;
        u16 scan_height;
@@ -50,10 +57,10 @@ struct MinimapModeDef {
 };
 
 struct MinimapPixel {
-       u16 id;
+       //! The topmost node that the minimap displays.
+       MapNode n;
        u16 height;
        u16 air_count;
-       u16 light;
 };
 
 struct MinimapMapblock {
@@ -81,6 +88,7 @@ struct MinimapData {
        video::ITexture *minimap_overlay_round;
        video::ITexture *minimap_overlay_square;
        video::ITexture *player_marker;
+       video::ITexture *object_marker_red;
 };
 
 struct QueuedMinimapUpdate {
@@ -90,48 +98,43 @@ struct QueuedMinimapUpdate {
 
 class MinimapUpdateThread : public UpdateThread {
 public:
+       MinimapUpdateThread() : UpdateThread("Minimap") {}
        virtual ~MinimapUpdateThread();
 
-       void getMap(v3s16 pos, s16 size, s16 height, bool radar);
-       MinimapPixel *getMinimapPixel(v3s16 pos, s16 height, s16 *pixel_height);
-       s16 getAirCount(v3s16 pos, s16 height);
-       video::SColor getColorFromId(u16 id);
-
+       void getMap(v3s16 pos, s16 size, s16 height);
        void enqueueBlock(v3s16 pos, MinimapMapblock *data);
-
        bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
        bool popBlockUpdate(QueuedMinimapUpdate *update);
 
        MinimapData *data;
 
 protected:
-       const char *getName()
-       {
-               return "MinimapUpdateThread";
-       }
-
        virtual void doUpdate();
 
 private:
-       JMutex m_queue_mutex;
+       Mutex m_queue_mutex;
        std::deque<QueuedMinimapUpdate> m_update_queue;
        std::map<v3s16, MinimapMapblock *> m_blocks_cache;
 };
 
-class Mapper {
+class Minimap {
 public:
-       Mapper(IrrlichtDevice *device, Client *client);
-       ~Mapper();
+       Minimap(IrrlichtDevice *device, Client *client);
+       ~Minimap();
 
        void addBlock(v3s16 pos, MinimapMapblock *data);
 
        v3f getYawVec();
-       MinimapMode getMinimapMode();
 
        void setPos(v3s16 pos);
+       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();
 
 
        video::ITexture *getMinimapTexture();
@@ -141,9 +144,12 @@ public:
                video::IImage *heightmap_image);
 
        scene::SMeshBuffer *getMinimapMeshBuffer();
+
+       void updateActiveMarkers();
        void drawMinimap();
 
        video::IVideoDriver *driver;
+       Client* client;
        MinimapData *data;
 
 private:
@@ -155,7 +161,8 @@ private:
        bool m_enable_shaders;
        u16 m_surface_mode_scan_height;
        f32 m_angle;
-       JMutex m_mutex;
+       Mutex m_mutex;
+       std::list<v2f> m_active_markers;
 };
 
 #endif