Add zoom, tweakable with zoom_fov, default key: Z (like optifine)

This commit is contained in:
Esteban I. Ruiz Moreno 2013-03-31 00:30:32 -03:00 committed by est31
parent c013c73f33
commit 2c31b79235
7 changed files with 20 additions and 2 deletions

View File

@ -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);

View File

@ -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;

View File

@ -59,6 +59,7 @@ public:
INCREASE_VIEWING_RANGE,
DECREASE_VIEWING_RANGE,
RANGESELECT,
ZOOM,
QUICKTUNE_NEXT,
QUICKTUNE_PREV,

View File

@ -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");

View File

@ -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,

View File

@ -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");
}

View File

@ -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;