diff options
author | Esteban I. Ruiz Moreno <exio4.com@gmail.com> | 2013-03-31 00:30:32 -0300 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2016-08-10 12:18:25 +0200 |
commit | 2c31b79235dd83de753fce5890c5797e149048b8 (patch) | |
tree | 86dac00e356f00d89a48bde28b3b052214e8168c /src | |
parent | c013c73f338b1c2227662458ebc650883f83271c (diff) | |
download | minetest-2c31b79235dd83de753fce5890c5797e149048b8.tar.gz minetest-2c31b79235dd83de753fce5890c5797e149048b8.tar.bz2 minetest-2c31b79235dd83de753fce5890c5797e149048b8.zip |
Add zoom, tweakable with zoom_fov, default key: Z (like optifine)
Diffstat (limited to 'src')
-rw-r--r-- | src/camera.cpp | 10 | ||||
-rw-r--r-- | src/camera.h | 1 | ||||
-rw-r--r-- | src/client/keys.h | 1 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 2 | ||||
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/guiKeyChangeMenu.cpp | 2 | ||||
-rw-r--r-- | src/player.h | 4 |
7 files changed, 20 insertions, 2 deletions
diff --git a/src/camera.cpp b/src/camera.cpp index 6893b8cbf..e1d6dd910 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -103,6 +103,7 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, m_cache_fall_bobbing_amount = g_settings->getFloat("fall_bobbing_amount"); m_cache_view_bobbing_amount = g_settings->getFloat("view_bobbing_amount"); m_cache_fov = g_settings->getFloat("fov"); + m_cache_zoom_fov = g_settings->getFloat("zoom_fov"); m_cache_view_bobbing = g_settings->getBool("view_bobbing"); m_nametags.clear(); } @@ -387,8 +388,13 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, if (m_camera_mode == CAMERA_MODE_THIRD_FRONT) m_camera_position = my_cp; - // Get FOV setting - f32 fov_degrees = m_cache_fov; + // Get FOV + f32 fov_degrees; + if (player->getPlayerControl().zoom) { + fov_degrees = m_cache_zoom_fov; + } else { + fov_degrees = m_cache_fov; + } fov_degrees = MYMAX(fov_degrees, 10.0); fov_degrees = MYMIN(fov_degrees, 170.0); diff --git a/src/camera.h b/src/camera.h index ce46c3190..cb0e9686d 100644 --- a/src/camera.h +++ b/src/camera.h @@ -231,6 +231,7 @@ private: f32 m_cache_fall_bobbing_amount; f32 m_cache_view_bobbing_amount; f32 m_cache_fov; + f32 m_cache_zoom_fov; bool m_cache_view_bobbing; std::list<Nametag *> m_nametags; diff --git a/src/client/keys.h b/src/client/keys.h index 0921bc166..6467c443e 100644 --- a/src/client/keys.h +++ b/src/client/keys.h @@ -59,6 +59,7 @@ public: INCREASE_VIEWING_RANGE, DECREASE_VIEWING_RANGE, RANGESELECT, + ZOOM, QUICKTUNE_NEXT, QUICKTUNE_PREV, diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 3220b915a..42b232afc 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -40,6 +40,7 @@ void set_default_settings(Settings *settings) settings->setDefault("keymap_jump", "KEY_SPACE"); settings->setDefault("keymap_sneak", "KEY_LSHIFT"); settings->setDefault("keymap_drop", "KEY_KEY_Q"); + settings->setDefault("keymap_zoom", "KEY_KEY_Z"); settings->setDefault("keymap_inventory", "KEY_KEY_I"); settings->setDefault("keymap_special1", "KEY_KEY_E"); settings->setDefault("keymap_chat", "KEY_KEY_T"); @@ -74,6 +75,7 @@ void set_default_settings(Settings *settings) settings->setDefault("always_fly_fast", "true"); settings->setDefault("directional_colored_fog", "true"); settings->setDefault("tooltip_show_delay", "400"); + settings->setDefault("zoom_fov", "15"); // Some (temporary) keys for debugging settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); diff --git a/src/game.cpp b/src/game.cpp index 9b9f3a75f..1a036d03a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1371,6 +1371,7 @@ void KeyCache::populate() = getKeySetting("keymap_decrease_viewing_range_min"); key[KeyType::RANGESELECT] = getKeySetting("keymap_rangeselect"); + key[KeyType::ZOOM] = getKeySetting("keymap_zoom"); key[KeyType::QUICKTUNE_NEXT] = getKeySetting("keymap_quicktune_next"); key[KeyType::QUICKTUNE_PREV] = getKeySetting("keymap_quicktune_prev"); @@ -3270,6 +3271,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam) isKeyDown(KeyType::JUMP), isKeyDown(KeyType::SPECIAL1), isKeyDown(KeyType::SNEAK), + isKeyDown(KeyType::ZOOM), isLeftPressed(), isRightPressed(), cam.camera_pitch, diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp index 785e921f7..07137d1bc 100644 --- a/src/guiKeyChangeMenu.cpp +++ b/src/guiKeyChangeMenu.cpp @@ -59,6 +59,7 @@ enum GUI_ID_KEY_INVENTORY_BUTTON, GUI_ID_KEY_DUMP_BUTTON, GUI_ID_KEY_RANGE_BUTTON, + GUI_ID_KEY_ZOOM_BUTTON, // other GUI_ID_CB_AUX1_DESCENDS, GUI_ID_CB_DOUBLETAP_JUMP, @@ -414,5 +415,6 @@ void GUIKeyChangeMenu::init_keys() this->add_key(GUI_ID_KEY_NOCLIP_BUTTON, wgettext("Toggle noclip"), "keymap_noclip"); this->add_key(GUI_ID_KEY_RANGE_BUTTON, wgettext("Range select"), "keymap_rangeselect"); this->add_key(GUI_ID_KEY_DUMP_BUTTON, wgettext("Print stacks"), "keymap_print_debug_stacks"); + this->add_key(GUI_ID_KEY_ZOOM_BUTTON, wgettext("Zoom"), "keymap_zoom"); } diff --git a/src/player.h b/src/player.h index e6fcf388a..eab00bb04 100644 --- a/src/player.h +++ b/src/player.h @@ -49,6 +49,7 @@ struct PlayerControl sidew_move_joystick_axis = .0f; forw_move_joystick_axis = .0f; } + PlayerControl( bool a_up, bool a_down, @@ -57,6 +58,7 @@ struct PlayerControl bool a_jump, bool a_aux1, bool a_sneak, + bool a_zoom, bool a_LMB, bool a_RMB, float a_pitch, @@ -72,6 +74,7 @@ struct PlayerControl jump = a_jump; aux1 = a_aux1; sneak = a_sneak; + zoom = a_zoom; LMB = a_LMB; RMB = a_RMB; pitch = a_pitch; @@ -86,6 +89,7 @@ struct PlayerControl bool jump; bool aux1; bool sneak; + bool zoom; bool LMB; bool RMB; float pitch; |