Move tool stuff to tool.{h,cpp}
[oweals/minetest.git] / src / game.cpp
index 30bd1bcf7fce04ea9a59a6c491ed5b2cc18b0724..bd84593b8d94a786088bd83e4faa2f2b28f7a6b9 100644 (file)
@@ -43,14 +43,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gettext.h"
 #include "log.h"
 #include "filesys.h"
-// Needed for writing to signs (CONTENT_SIGN_WALL)
-// TODO: A generic way for handling such should be created
-#include "content_mapnode.h"
-// Needed for sign text input
-// TODO: A generic way for handling such should be created
-#include "content_nodemeta.h"
 // Needed for determining pointing to nodes
 #include "mapnode_contentfeatures.h"
+#include "nodemetadata.h"
 
 /*
        Setting this to 1 enables a special camera mode that forces
@@ -115,9 +110,9 @@ struct TextDestChat : public TextDest
        Client *m_client;
 };
 
-struct TextDestSignNode : public TextDest
+struct TextDestNodeMetadata : public TextDest
 {
-       TextDestSignNode(v3s16 p, Client *client)
+       TextDestNodeMetadata(v3s16 p, Client *client)
        {
                m_p = p;
                m_client = client;
@@ -1784,23 +1779,22 @@ void the_game(
                                        menu->setDrawSpec(draw_spec);
                                        menu->drop();
                                }
-                               else if(meta && meta->typeId() == CONTENT_SIGN_WALL && !random_input)
+                               // If metadata provides text input, activate text input
+                               else if(meta && meta->allowsTextInput() && !random_input)
                                {
-                                       infostream<<"Sign node right-clicked"<<std::endl;
-                                       
-                                       SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
+                                       infostream<<"Launching metadata text input"<<std::endl;
                                        
                                        // Get a new text for it
 
-                                       TextDest *dest = new TextDestSignNode(nodepos, &client);
+                                       TextDest *dest = new TextDestNodeMetadata(nodepos, &client);
 
-                                       std::wstring wtext =
-                                                       narrow_to_wide(signmeta->getText());
+                                       std::wstring wtext = narrow_to_wide(meta->getText());
 
                                        (new GUITextInputMenu(guienv, guiroot, -1,
                                                        &g_menumgr, dest,
                                                        wtext))->drop();
                                }
+                               // Otherwise report right click to server
                                else
                                {
                                        client.groundAction(1, nodepos, neighbourpos, g_selected_item);