mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Merge d026f0a5c9
into 0794145b64
This commit is contained in:
commit
d7326a0a70
3 changed files with 32 additions and 17 deletions
|
@ -160,11 +160,6 @@ safe_dig_and_place (Safe digging and placing) bool false
|
|||
|
||||
[*Keyboard and Mouse]
|
||||
|
||||
# Invert vertical mouse movement.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
invert_mouse (Invert mouse) bool false
|
||||
|
||||
# Mouse sensitivity multiplier.
|
||||
#
|
||||
# Requires: keyboard_mouse
|
||||
|
@ -493,6 +488,12 @@ view_bobbing_amount (View bobbing factor) float 1.0 0.0 7.9
|
|||
|
||||
[**Camera]
|
||||
|
||||
# Invert vertical camera movement.
|
||||
invert_camera (Invert camera) bool false
|
||||
|
||||
# Inverts the 3rd person front-facing camera.
|
||||
invert_third_person_front (Invert 3rd person front) bool true
|
||||
|
||||
# Field of view in degrees.
|
||||
fov (Field of view) int 72 45 160
|
||||
|
||||
|
|
|
@ -632,6 +632,7 @@ protected:
|
|||
|
||||
void updateCameraDirection(CameraOrientation *cam, float dtime);
|
||||
void updateCameraOrientation(CameraOrientation *cam, float dtime);
|
||||
float getInvertedCameraState(float dir);
|
||||
bool getTogglableKeyState(GameKeyType key, bool toggling_enabled, bool prev_key_state);
|
||||
void updatePlayerControl(const CameraOrientation &cam);
|
||||
void updatePauseState();
|
||||
|
@ -832,7 +833,8 @@ private:
|
|||
f32 m_repeat_dig_time;
|
||||
f32 m_cache_cam_smoothing;
|
||||
|
||||
bool m_invert_mouse;
|
||||
bool m_invert_camera;
|
||||
bool m_invert_third_person_front;
|
||||
bool m_enable_hotbar_mouse_wheel;
|
||||
bool m_invert_hotbar_mouse_wheel;
|
||||
|
||||
|
@ -895,7 +897,9 @@ Game::Game() :
|
|||
&settingChangedCallback, this);
|
||||
g_settings->registerChangedCallback("camera_smoothing",
|
||||
&settingChangedCallback, this);
|
||||
g_settings->registerChangedCallback("invert_mouse",
|
||||
g_settings->registerChangedCallback("invert_camera",
|
||||
&settingChangedCallback, this);
|
||||
g_settings->registerChangedCallback("invert_third_person_front",
|
||||
&settingChangedCallback, this);
|
||||
g_settings->registerChangedCallback("enable_hotbar_mouse_wheel",
|
||||
&settingChangedCallback, this);
|
||||
|
@ -2484,18 +2488,14 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
|
|||
// User setting is already applied by TouchControls.
|
||||
f32 sens_scale = getSensitivityScaleFactor();
|
||||
cam->camera_yaw += g_touchcontrols->getYawChange() * sens_scale;
|
||||
cam->camera_pitch += g_touchcontrols->getPitchChange() * sens_scale;
|
||||
cam->camera_pitch += getInvertedCameraState(g_touchcontrols->getPitchChange()) * sens_scale;
|
||||
} else {
|
||||
v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2);
|
||||
v2s32 dist = input->getMousePos() - center;
|
||||
|
||||
if (m_invert_mouse || camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT) {
|
||||
dist.Y = -dist.Y;
|
||||
}
|
||||
|
||||
f32 sens_scale = getSensitivityScaleFactor();
|
||||
cam->camera_yaw -= dist.X * m_cache_mouse_sensitivity * sens_scale;
|
||||
cam->camera_pitch += dist.Y * m_cache_mouse_sensitivity * sens_scale;
|
||||
cam->camera_pitch += getInvertedCameraState(dist.Y) * m_cache_mouse_sensitivity * sens_scale;
|
||||
|
||||
if (dist.X != 0 || dist.Y != 0)
|
||||
input->setMousePos(center.X, center.Y);
|
||||
|
@ -2505,12 +2505,24 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
|
|||
f32 sens_scale = getSensitivityScaleFactor();
|
||||
f32 c = m_cache_joystick_frustum_sensitivity * dtime * sens_scale;
|
||||
cam->camera_yaw -= input->joystick.getAxisWithoutDead(JA_FRUSTUM_HORIZONTAL) * c;
|
||||
cam->camera_pitch += input->joystick.getAxisWithoutDead(JA_FRUSTUM_VERTICAL) * c;
|
||||
cam->camera_pitch += getInvertedCameraState(input->joystick.getAxisWithoutDead(JA_FRUSTUM_VERTICAL)) * c;
|
||||
}
|
||||
|
||||
cam->camera_pitch = rangelim(cam->camera_pitch, -90, 90);
|
||||
}
|
||||
|
||||
float Game::getInvertedCameraState(float dir)
|
||||
{
|
||||
if (m_invert_camera) {
|
||||
dir = -dir;
|
||||
}
|
||||
|
||||
if (m_invert_third_person_front) {
|
||||
if (camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT) {
|
||||
dir = -dir;
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
// Get the state of an optionally togglable key
|
||||
bool Game::getTogglableKeyState(GameKeyType key, bool toggling_enabled, bool prev_key_state)
|
||||
|
@ -4229,7 +4241,8 @@ void Game::readSettings()
|
|||
m_cache_cam_smoothing = rangelim(m_cache_cam_smoothing, 0.01f, 1.0f);
|
||||
m_cache_mouse_sensitivity = rangelim(m_cache_mouse_sensitivity, 0.001, 100.0);
|
||||
|
||||
m_invert_mouse = g_settings->getBool("invert_mouse");
|
||||
m_invert_camera = g_settings->getBool("invert_camera");
|
||||
m_invert_third_person_front = g_settings->getBool("invert_third_person_front");
|
||||
m_enable_hotbar_mouse_wheel = g_settings->getBool("enable_hotbar_mouse_wheel");
|
||||
m_invert_hotbar_mouse_wheel = g_settings->getBool("invert_hotbar_mouse_wheel");
|
||||
|
||||
|
|
|
@ -263,6 +263,8 @@ void set_default_settings()
|
|||
settings->setDefault("autosave_screensize", "true");
|
||||
settings->setDefault("fullscreen", bool_to_cstr(has_touch));
|
||||
settings->setDefault("vsync", "false");
|
||||
settings->setDefault("invert_camera", "false");
|
||||
settings->setDefault("invert_third_person_front", "true");
|
||||
settings->setDefault("fov", "72");
|
||||
settings->setDefault("leaves_style", "fancy");
|
||||
settings->setDefault("connected_glass", "false");
|
||||
|
@ -355,7 +357,6 @@ void set_default_settings()
|
|||
settings->setDefault("shadow_sky_body_orbit_tilt", "0.0");
|
||||
|
||||
// Input
|
||||
settings->setDefault("invert_mouse", "false");
|
||||
settings->setDefault("enable_hotbar_mouse_wheel", "true");
|
||||
settings->setDefault("invert_hotbar_mouse_wheel", "false");
|
||||
settings->setDefault("mouse_sensitivity", "0.2");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue