]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/camera.h
Merge branch 'master' of https://github.com/minetest/minetest
[dragonfireclient.git] / src / client / camera.h
index 403d6024c9e6aedf4ad11d68bdcf4480e7fab5ef..ecd71f1e72d2cee62f6956d84b0cc4d2690cd675 100644 (file)
@@ -40,18 +40,44 @@ struct Nametag
        video::SColor textcolor;
        Optional<video::SColor> bgcolor;
        v3f pos;
+       ITextureSource *texture_source;
+       std::vector<video::ITexture *> images;
+       core::dimension2di images_dim;
 
        Nametag(scene::ISceneNode *a_parent_node,
                        const std::string &text,
                        const video::SColor &textcolor,
                        const Optional<video::SColor> &bgcolor,
-                       const v3f &pos):
+                       const v3f &pos,
+                       ITextureSource *tsrc,
+                       const std::vector<std::string> &image_names):
                parent_node(a_parent_node),
                text(text),
                textcolor(textcolor),
                bgcolor(bgcolor),
-               pos(pos)
+               pos(pos),
+               texture_source(tsrc),
+               images(),
+               images_dim(0, 0)
        {
+               setImages(image_names);
+       }
+
+       void setImages(const std::vector<std::string> &image_names)
+       {
+               images.clear();
+               images_dim = core::dimension2di(0, 0);
+
+               for (const std::string &image_name : image_names) {
+                       video::ITexture *texture = texture_source->getTexture(image_name);
+                       core::dimension2di imgsize(texture->getOriginalSize());
+
+                       images_dim.Width += imgsize.Width;
+                       if (images_dim.Height < imgsize.Height)
+                               images_dim.Height = imgsize.Height;
+
+                       images.push_back(texture);
+               }
        }
 
        video::SColor getBgColor(bool use_fallback) const
@@ -181,7 +207,8 @@ class Camera
 
        Nametag *addNametag(scene::ISceneNode *parent_node,
                const std::string &text, video::SColor textcolor,
-               Optional<video::SColor> bgcolor, const v3f &pos);
+               Optional<video::SColor> bgcolor, const v3f &pos,
+               const std::vector<std::string> &image_names);
 
        void removeNametag(Nametag *nametag);