]> git.lizzy.rs Git - minetest.git/blobdiff - src/game.cpp
Merge pull request #503 from RealBadAngel/master
[minetest.git] / src / game.cpp
index ca992c05618cd00f898e71050b58b0727a7a68a5..86909ccf076800c38eebe8531bbfcae7d2ea0030 100644 (file)
@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "server.h"
 #include "guiPauseMenu.h"
 #include "guiPasswordChange.h"
+#include "guiVolumeChange.h"
 #include "guiFormSpecMenu.h"
 #include "guiTextInputMenu.h"
 #include "guiDeathScreen.h"
@@ -36,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "guiChatConsole.h"
 #include "config.h"
 #include "clouds.h"
+#include "particles.h"
 #include "camera.h"
 #include "farmesh.h"
 #include "mapblock.h"
@@ -118,13 +120,20 @@ struct TextDestPlayerInventory : public TextDest
        TextDestPlayerInventory(Client *client)
        {
                m_client = client;
+               m_formname = "";
+       }
+       TextDestPlayerInventory(Client *client, std::string formname)
+       {
+               m_client = client;
+               m_formname = formname;
        }
        void gotText(std::map<std::string, std::string> fields)
        {
-               m_client->sendInventoryFields("", fields);
+               m_client->sendInventoryFields(m_formname, fields);
        }
 
        Client *m_client;
+       std::string m_formname;
 };
 
 /* Respawn menu callback */
@@ -1254,7 +1263,7 @@ void the_game(
        gui::IGUIStaticText *guitext_info = guienv->addStaticText(
                        L"",
                        core::rect<s32>(0,0,400,text_height*5+5) + v2s32(100,200),
-                       false, false);
+                       false, true);
        
        // Status text (displays info when showing and hiding GUI stuff, etc.)
        gui::IGUIStaticText *guitext_status = guienv->addStaticText(
@@ -1511,6 +1520,13 @@ void the_game(
                        g_gamecallback->changepassword_requested = false;
                }
 
+               if(g_gamecallback->changevolume_requested)
+               {
+                       (new GUIVolumeChange(guienv, guiroot, -1,
+                               &g_menumgr, &client))->drop();
+                       g_gamecallback->changevolume_requested = false;
+               }
+
                /* Process TextureSource's queue */
                tsrc->processQueue();
 
@@ -2092,7 +2108,8 @@ void the_game(
                                {
                                        break;
                                }
-                               else if(event.type == CE_PLAYER_DAMAGE)
+                               else if(event.type == CE_PLAYER_DAMAGE &&
+                                               client.getHP() != 0)
                                {
                                        //u16 damage = event.player_damage.amount;
                                        //infostream<<"Player damage: "<<damage<<std::endl;
@@ -2154,6 +2171,7 @@ void the_game(
                                                                                &g_menumgr,
                                                                                &client, gamedef);
                                                menu->setFormSource(current_formspec);
+                                               menu->setTextDest(new TextDestPlayerInventory(&client,*(event.show_formspec.formname)));
                                                menu->drop();
                                        }
                                        else
@@ -2162,6 +2180,7 @@ void the_game(
                                                current_formspec->setForm(*(event.show_formspec.formspec));
                                        }
                                        delete(event.show_formspec.formspec);
+                                       delete(event.show_formspec.formname);
                                }
                                else if(event.type == CE_TEXTURES_UPDATED)
                                {
@@ -2305,6 +2324,8 @@ void the_game(
 
                if(input->getRightState())
                        repeat_rightclick_timer += dtime;
+               else
+                       repeat_rightclick_timer = 0;
 
                if(playeritem_usable && input->getLeftState())
                {
@@ -2389,6 +2410,13 @@ void the_game(
                                else
                                {
                                        dig_time_complete = params.time;
+                                       if (g_settings->getBool("enable_particles"))
+                                       {
+                                               const ContentFeatures &features =
+                                                       client.getNodeDefManager()->get(n);
+                                               addPunchingParticles
+                                                       (gamedef, smgr, player, nodepos, features.tiles);
+                                       }
                                }
 
                                if(dig_time_complete >= 0.001)
@@ -2420,6 +2448,14 @@ void the_game(
                                        MapNode wasnode = map.getNode(nodepos);
                                        client.removeNode(nodepos);
 
+                                       if (g_settings->getBool("enable_particles"))
+                                       {
+                                               const ContentFeatures &features =
+                                                       client.getNodeDefManager()->get(wasnode);
+                                               addDiggingParticles
+                                                       (gamedef, smgr, player, nodepos, features.tiles);
+                                       }
+
                                        dig_time = 0;
                                        digging = false;
 
@@ -2454,7 +2490,9 @@ void the_game(
                                
                                // Sign special case, at least until formspec is properly implemented.
                                // Deprecated?
-                               if(meta && meta->getString("formspec") == "hack:sign_text_input" && !random_input)
+                               if(meta && meta->getString("formspec") == "hack:sign_text_input" 
+                                               && !random_input
+                                               && !input->isKeyDown(getKeySetting("keymap_sneak")))
                                {
                                        infostream<<"Launching metadata text input"<<std::endl;
                                        
@@ -2469,7 +2507,8 @@ void the_game(
                                                        wtext))->drop();
                                }
                                // If metadata provides an inventory view, activate it
-                               else if(meta && meta->getString("formspec") != "" && !random_input)
+                               else if(meta && meta->getString("formspec") != "" && !random_input
+                                               && !input->isKeyDown(getKeySetting("keymap_sneak")))
                                {
                                        infostream<<"Launching custom inventory view"<<std::endl;
 
@@ -2500,7 +2539,8 @@ void the_game(
                                        // make that happen
                                        const ItemDefinition &def =
                                                        playeritem.getDefinition(itemdef);
-                                       if(def.node_placement_prediction != "")
+                                       if(def.node_placement_prediction != ""
+                                                       && !nodedef->get(map.getNode(nodepos)).rightclickable)
                                        do{ // breakable
                                                verbosestream<<"Node placement prediction for "
                                                                <<playeritem.name<<" is "
@@ -2688,6 +2728,12 @@ void the_game(
                        farmesh->update(v2f(player_position.X, player_position.Z),
                                        brightness, farmesh_range);
                }
+
+               /*
+                       Update particles
+               */
+
+               allparticles_step(dtime, client.getEnv());
                
                /*
                        Fog