aboutsummaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-13 12:48:05 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:41 +0200
commit64fa59e24f7b3e046b7dfeba930e44c86e32668e (patch)
tree1509c79dde0ddd007df19d9647a2c5c9e968386d /src/game.cpp
parent79c9f14aec52c0fa1b3c2b1850ab3c6a9124a313 (diff)
downloadminetest-64fa59e24f7b3e046b7dfeba930e44c86e32668e.tar.gz
minetest-64fa59e24f7b3e046b7dfeba930e44c86e32668e.tar.bz2
minetest-64fa59e24f7b3e046b7dfeba930e44c86e32668e.zip
Generic NodeMetadata text input
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 30bd1bcf7..638ad9155 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -43,12 +43,6 @@ 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"
@@ -115,9 +109,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 +1778,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);