summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp87
1 files changed, 34 insertions, 53 deletions
diff --git a/src/game.cpp b/src/game.cpp
index b11547679..c36688d12 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1709,75 +1709,56 @@ void the_game(
{
std::cout<<DTIME<<"Ground right-clicked"<<std::endl;
- if(meta && meta->typeId() == CONTENT_SIGN_WALL && !random_input)
+ // If metadata provides an inventory view, activate it
+ if(meta && meta->getInventoryDrawSpecString() != "" && !random_input)
{
- dstream<<"Sign node right-clicked"<<std::endl;
-
- SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
-
- // Get a new text for it
-
- TextDest *dest = new TextDestSignNode(nodepos, &client);
-
- std::wstring wtext =
- narrow_to_wide(signmeta->getText());
-
- (new GUITextInputMenu(guienv, guiroot, -1,
- &g_menumgr, dest,
- wtext))->drop();
- }
- else if(meta && meta->typeId() == CONTENT_CHEST && !random_input)
- {
- dstream<<"Chest node right-clicked"<<std::endl;
-
- //ChestNodeMetadata *chestmeta = (ChestNodeMetadata*)meta;
-
+ dstream<<DTIME<<"Launching custom inventory view"<<std::endl;
/*
- Construct the unique identification string of this
- chest's inventory
+ Construct the unique identification string of the node
*/
- std::string chest_inv_id;
- chest_inv_id += "nodemeta:";
- chest_inv_id += itos(nodepos.X);
- chest_inv_id += ",";
- chest_inv_id += itos(nodepos.Y);
- chest_inv_id += ",";
- chest_inv_id += itos(nodepos.Z);
-
+ std::string current_name;
+ current_name += "nodemeta:";
+ current_name += itos(nodepos.X);
+ current_name += ",";
+ current_name += itos(nodepos.Y);
+ current_name += ",";
+ current_name += itos(nodepos.Z);
+
/*
- Create a menu with the player's inventory and the
- chest's inventory
+ Create menu
*/
+
+ core::array<GUIInventoryMenu::DrawSpec> draw_spec;
+ v2s16 invsize =
+ GUIInventoryMenu::makeDrawSpecArrayFromString(
+ draw_spec,
+ meta->getInventoryDrawSpecString(),
+ current_name);
+
GUIInventoryMenu *menu =
new GUIInventoryMenu(guienv, guiroot, -1,
- &g_menumgr, v2s16(8,9),
+ &g_menumgr, invsize,
client.getInventoryContext(),
&client);
-
- core::array<GUIInventoryMenu::DrawSpec> draw_spec;
-
- draw_spec.push_back(GUIInventoryMenu::DrawSpec(
- "list", chest_inv_id, "0",
- v2s32(0, 0), v2s32(8, 4)));
- draw_spec.push_back(GUIInventoryMenu::DrawSpec(
- "list", "current_player", "main",
- v2s32(0, 5), v2s32(8, 4)));
-
menu->setDrawSpec(draw_spec);
-
menu->drop();
-
}
- else if(meta && meta->typeId() == CONTENT_FURNACE && !random_input)
+ else if(meta && meta->typeId() == CONTENT_SIGN_WALL && !random_input)
{
- dstream<<"Furnace node right-clicked"<<std::endl;
+ dstream<<"Sign node right-clicked"<<std::endl;
+
+ SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
- GUIFurnaceMenu *menu =
- new GUIFurnaceMenu(guienv, guiroot, -1,
- &g_menumgr, nodepos, &client);
+ // Get a new text for it
- menu->drop();
+ TextDest *dest = new TextDestSignNode(nodepos, &client);
+
+ std::wstring wtext =
+ narrow_to_wide(signmeta->getText());
+ (new GUITextInputMenu(guienv, guiroot, -1,
+ &g_menumgr, dest,
+ wtext))->drop();
}
else
{