Add cancel button to password change menu. (#5720)
[oweals/minetest.git] / src / nodemetadata.h
index 710270502f76ab473b99aca4fdcb0e551d95b73e..f46c0fe911037ee3e0120517df40741fa1467c0b 100644 (file)
@@ -20,10 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef NODEMETADATA_HEADER
 #define NODEMETADATA_HEADER
 
-#include "irr_v3d.h"
-#include <string>
-#include <iostream>
-#include <map>
+#include "metadata.h"
 
 /*
        NodeMetadata stores arbitary amounts of data for special blocks.
@@ -35,55 +32,27 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 class Inventory;
-class IGameDef;
+class IItemDefManager;
 
-class NodeMetadata
+class NodeMetadata : public Metadata
 {
 public:
-       NodeMetadata(IGameDef *gamedef);
+       NodeMetadata(IItemDefManager *item_def_mgr);
        ~NodeMetadata();
-       
+
        void serialize(std::ostream &os) const;
        void deSerialize(std::istream &is);
-       
-       void clear();
 
-       // Generic key/value store
-       std::string getString(const std::string &name) const
-       {
-               std::map<std::string, std::string>::const_iterator i;
-               i = m_stringvars.find(name);
-               if(i == m_stringvars.end())
-                       return "";
-               return i->second;
-       }
-       void setString(const std::string &name, const std::string &var)
-       {
-               if(var.empty())
-                       m_stringvars.erase(name);
-               else
-                       m_stringvars[name] = var;
-       }
-       // support variable names in values
-       std::string resolveString(const std::string &str) const
-       {
-               if(str.substr(0,2) == "${" && str[str.length()-1] == '}')
-                       return getString(str.substr(2,str.length()-3));
-               return str;
-       }
-       std::map<std::string, std::string> getStrings() const
-       {
-               return m_stringvars;
-       }
+       void clear();
+       bool empty() const;
 
        // The inventory
-       InventorygetInventory()
+       Inventory *getInventory()
        {
                return m_inventory;
        }
 
 private:
-       std::map<std::string, std::string> m_stringvars;
        Inventory *m_inventory;
 };
 
@@ -98,20 +67,23 @@ public:
        ~NodeMetadataList();
 
        void serialize(std::ostream &os) const;
-       void deSerialize(std::istream &is, IGameDef *gamedef);
-       
+       void deSerialize(std::istream &is, IItemDefManager *item_def_mgr);
+
+       // Add all keys in this list to the vector keys
+       std::vector<v3s16> getAllKeys();
        // Get pointer to data
-       NodeMetadataget(v3s16 p);
+       NodeMetadata *get(v3s16 p);
        // Deletes data
        void remove(v3s16 p);
        // Deletes old data and sets a new one
        void set(v3s16 p, NodeMetadata *d);
        // Deletes all
        void clear();
-       
+
 private:
-       std::map<v3s16, NodeMetadata*> m_data;
+       int countNonEmpty() const;
+
+       std::map<v3s16, NodeMetadata *> m_data;
 };
 
 #endif
-