diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-06-18 02:00:01 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-06-18 02:00:01 +0300 |
commit | 931474658dacd32d1847b6718e3d5a33ca8f18ab (patch) | |
tree | 01e5c535f416d9727253e9f5b55a487ecd6d0d39 /src/game.cpp | |
parent | da692355e84f8d1e5210c3c89daf775cf23ec38b (diff) | |
download | hax-minetest-server-931474658dacd32d1847b6718e3d5a33ca8f18ab.tar.gz hax-minetest-server-931474658dacd32d1847b6718e3d5a33ca8f18ab.zip |
moved inventory menu definition of chest and furnace to content_nodemeta.{h,cpp}
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 87 |
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 { |