Improve GUIMessageMenu (move and resize elements based on size of text)
[oweals/minetest.git] / src / camera.cpp
index 8dad8dc63e59d7c7ec99414c7237cb073d9a6de0..290776bf3d2da197a60ee5398b0c40d29872558c 100644 (file)
@@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "noise.h" // easeCurve
 #include "gamedef.h"
 #include "sound.h"
+#include "event.h"
 
 Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
                IGameDef *gamedef):
@@ -177,20 +178,33 @@ void Camera::step(f32 dtime)
                        bool step = (was == 0 ||
                                        (was < 0.5f && m_view_bobbing_anim >= 0.5f) ||
                                        (was > 0.5f && m_view_bobbing_anim <= 0.5f));
-                       if(step)
-                               m_gamedef->sound()->playSound("default_grass_walk", false, 1.0);
+                       if(step){
+                               MtEvent *e = new SimpleTriggerEvent("ViewBobbingStep");
+                               m_gamedef->event()->put(e);
+                       }
                }
        }
 
        if (m_digging_button != -1)
        {
                f32 offset = dtime * 3.5;
+               float m_digging_anim_was = m_digging_anim;
                m_digging_anim += offset;
                if (m_digging_anim >= 1)
                {
                        m_digging_anim = 0;
                        m_digging_button = -1;
-                       m_gamedef->sound()->playSound("dig", false, 1.0);
+               }
+               float lim = 0.15;
+               if(m_digging_anim_was < lim && m_digging_anim >= lim)
+               {
+                       if(m_digging_button == 0){
+                               MtEvent *e = new SimpleTriggerEvent("CameraPunchLeft");
+                               m_gamedef->event()->put(e);
+                       } else if(m_digging_button == 1){
+                               MtEvent *e = new SimpleTriggerEvent("CameraPunchRight");
+                               m_gamedef->event()->put(e);
+                       }
                }
        }
 }
@@ -276,6 +290,9 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
        // FOV and aspect ratio
        m_aspect = (f32)screensize.X / (f32) screensize.Y;
        m_fov_y = fov_degrees * PI / 180.0;
+       // Increase vertical FOV on lower aspect ratios (<16:10)
+       m_fov_y *= MYMAX(1.0, MYMIN(1.4, sqrt(16./10. / m_aspect)));
+       // WTF is this? It can't be right
        m_fov_x = 2 * atan(0.5 * m_aspect * tan(m_fov_y));
        m_cameranode->setAspectRatio(m_aspect);
        m_cameranode->setFOV(m_fov_y);
@@ -334,7 +351,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
        if ((hypot(speed.X, speed.Z) > BS) &&
                (player->touching_ground) &&
                (g_settings->getBool("view_bobbing") == true) &&
-               (g_settings->getBool("free_move") == false))
+               (g_settings->getBool("free_move") == false ||
+                               !m_gamedef->checkLocalPrivilege("fly")))
        {
                // Start animation
                m_view_bobbing_state = 1;