Update inventory texture too
[oweals/minetest.git] / src / nodedef.cpp
index 74d825362e51093a9cbd3c2c4e6d9f16e7a16b85..57807449e4247fe2925afd001a19ce7c051fd043 100644 (file)
@@ -64,6 +64,7 @@ void ContentFeatures::setInventoryTexture(std::string imgname,
        
        imgname += "^[forcesingle";
        
+       inventory_texture_name = imgname;
        inventory_texture = tsrc->getTextureRaw(imgname);
 }
 
@@ -84,6 +85,7 @@ void ContentFeatures::setInventoryTextureCube(std::string top,
        imgname_full += left;
        imgname_full += "{";
        imgname_full += right;
+       inventory_texture_name = imgname_full;
        inventory_texture = tsrc->getTextureRaw(imgname_full);
 }
 #endif
@@ -164,6 +166,30 @@ public:
                assert(c <= MAX_CONTENT);
                return &m_content_features[c];
        }
+       virtual void updateTextures(ITextureSource *tsrc)
+       {
+#ifndef SERVER
+               infostream<<"CNodeDefManager::updateTextures(): Updating "
+                               <<"textures in node definitions"<<std::endl;
+               for(u16 i=0; i<=MAX_CONTENT; i++)
+               {
+                       ContentFeatures *f = &m_content_features[i];
+                       for(u16 j=0; j<6; j++)
+                               tsrc->updateAP(f->tiles[j].texture);
+                       if(f->special_atlas){
+                               tsrc->updateAP(*(f->special_atlas));
+                               if(f->special_material)
+                                       f->special_material->setTexture(0, f->special_atlas->atlas);
+                               if(f->special_material2)
+                                       f->special_material2->setTexture(0, f->special_atlas->atlas);
+                       }
+                       if(f->inventory_texture_name != ""){
+                               f->inventory_texture =
+                                       tsrc->getTextureRaw(f->inventory_texture_name);
+                       }
+               }
+#endif
+       }
 private:
        ContentFeatures m_content_features[MAX_CONTENT+1];
 };