#include "server.h"
#include "guiPauseMenu.h"
#include "guiPasswordChange.h"
-#include "guiInventoryMenu.h"
+#include "guiFormSpecMenu.h"
#include "guiTextInputMenu.h"
#include "guiDeathScreen.h"
#include "tool.h"
{
m_client->typeChatMessage(text);
}
+ void gotText(std::map<std::string, std::string> fields)
+ {
+ m_client->typeChatMessage(narrow_to_wide(fields["text"]));
+ }
Client *m_client;
};
m_p = p;
m_client = client;
}
+ // This is deprecated I guess? -celeron55
void gotText(std::wstring text)
{
std::string ntext = wide_to_narrow(text);
- infostream<<"Changing text of a sign node: "
- <<ntext<<std::endl;
+ infostream<<"Submitting 'text' field of node at ("<<m_p.X<<","
+ <<m_p.Y<<","<<m_p.Z<<"): "<<ntext<<std::endl;
std::map<std::string, std::string> fields;
fields["text"] = ntext;
m_client->sendNodemetaFields(m_p, "", fields);
}
+ void gotText(std::map<std::string, std::string> fields)
+ {
+ m_client->sendNodemetaFields(m_p, "", fields);
+ }
v3s16 m_p;
Client *m_client;
};
+struct TextDestPlayerInventory : public TextDest
+{
+ TextDestPlayerInventory(Client *client)
+ {
+ m_client = client;
+ }
+ void gotText(std::map<std::string, std::string> fields)
+ {
+ m_client->sendInventoryFields("", fields);
+ }
+
+ Client *m_client;
+};
+
/* Respawn menu callback */
class MainRespawnInitiator: public IRespawnInitiator
return "";
return meta->getString("formspec");
}
+ std::string resolveText(std::string str)
+ {
+ NodeMetadata *meta = m_map->getNodeMetadata(m_p);
+ if(!meta)
+ return str;
+ return meta->resolveString(str);
+ }
ClientMap *m_map;
v3s16 m_p;
s16 zend = pos_i.Z + (camera_direction.Z>0 ? a : 1);
s16 xend = pos_i.X + (camera_direction.X>0 ? a : 1);
+ // Prevent signed number overflow
+ if(yend==32767)
+ yend=32766;
+ if(zend==32767)
+ zend=32766;
+ if(xend==32767)
+ xend=32766;
+
for(s16 y = ystart; y <= yend; y++)
for(s16 z = zstart; z <= zend; z++)
for(s16 x = xstart; x <= xend; x++)
infostream<<"the_game: "
<<"Launching inventory"<<std::endl;
- GUIInventoryMenu *menu =
- new GUIInventoryMenu(guienv, guiroot, -1,
+ GUIFormSpecMenu *menu =
+ new GUIFormSpecMenu(guienv, guiroot, -1,
&g_menumgr,
&client, gamedef);
PlayerInventoryFormSource *src = new PlayerInventoryFormSource(&client);
assert(src);
menu->setFormSpec(src->getForm(), inventoryloc);
- menu->setFormSource(new PlayerInventoryFormSource(&client));
+ menu->setFormSource(src);
+ menu->setTextDest(new TextDestPlayerInventory(&client));
menu->drop();
}
else if(input->wasKeyDown(EscapeKey))
{
infostream<<"Ground right-clicked"<<std::endl;
- // sign special case, at least until formspec is properly implemented
+ // Sign special case, at least until formspec is properly implemented.
+ // Deprecated?
if(meta && meta->getString("formspec") == "hack:sign_text_input" && !random_input)
{
infostream<<"Launching metadata text input"<<std::endl;
/* Create menu */
- GUIInventoryMenu *menu =
- new GUIInventoryMenu(guienv, guiroot, -1,
+ GUIFormSpecMenu *menu =
+ new GUIFormSpecMenu(guienv, guiroot, -1,
&g_menumgr,
&client, gamedef);
menu->setFormSpec(meta->getString("formspec"),
inventoryloc);
menu->setFormSource(new NodeMetadataFormSource(
&client.getEnv().getClientMap(), nodepos));
+ menu->setTextDest(new TextDestNodeMetadata(nodepos, &client));
menu->drop();
}
// Otherwise report right click to server
<<playeritem.name<<" is "
<<def.node_placement_prediction<<std::endl;
v3s16 p = neighbourpos;
+ // Place inside node itself if buildable_to
+ try{
+ MapNode n_under = map.getNode(nodepos);
+ if(nodedef->get(n_under).buildable_to)
+ p = nodepos;
+ }catch(InvalidPositionException &e){}
+ // Find id of predicted node
content_t id;
bool found =
nodedef->getId(def.node_placement_prediction, id);