1
0
forked from 0ad/0ad

Make configurable mouse edge distance for view scroll.

Differential Revision: https://code.wildfiregames.com/D4552
This was SVN commit r26665.
This commit is contained in:
Vladislav Belov 2022-03-17 18:25:54 +00:00
parent 2ed2e9de0c
commit 2a66c783ee
3 changed files with 11 additions and 6 deletions

View File

@ -562,6 +562,7 @@ terms = "0" ; Version (hash) of the UserReporter Terms tha
[view] ; Camera control settings
scroll.speed = 120.0
scroll.speed.modifier = 1.05 ; Multiplier for changing scroll speed
scroll.mouse.detectdistance = 3
rotate.x.speed = 1.2
rotate.x.min = 28.0
rotate.x.max = 60.0

View File

@ -58,6 +58,7 @@ CCameraController::CCameraController(CCamera& camera)
// Dummy values (these will be filled in by the config file)
m_ViewScrollSpeed(0),
m_ViewScrollSpeedModifier(1),
m_ViewScrollMouseDetectDistance(3),
m_ViewRotateXSpeed(0),
m_ViewRotateXMin(0),
m_ViewRotateXMax(0),
@ -104,6 +105,7 @@ void CCameraController::LoadConfig()
{
CFG_GET_VAL("view.scroll.speed", m_ViewScrollSpeed);
CFG_GET_VAL("view.scroll.speed.modifier", m_ViewScrollSpeedModifier);
CFG_GET_VAL("view.scroll.mouse.detectdistance", m_ViewScrollMouseDetectDistance);
CFG_GET_VAL("view.rotate.x.speed", m_ViewRotateXSpeed);
CFG_GET_VAL("view.rotate.x.min", m_ViewRotateXMin);
CFG_GET_VAL("view.rotate.x.max", m_ViewRotateXMax);
@ -182,16 +184,16 @@ void CCameraController::Update(const float deltaRealTime)
moveForward += m_ViewDragSpeed * -mouse_dy;
}
if (g_mouse_active)
if (g_mouse_active && m_ViewScrollMouseDetectDistance > 0)
{
if (g_mouse_x >= g_xres - 2 && g_mouse_x < g_xres)
if (g_mouse_x >= g_xres - m_ViewScrollMouseDetectDistance && g_mouse_x < g_xres)
moveRightward += m_ViewScrollSpeed * deltaRealTime;
else if (g_mouse_x <= 3 && g_mouse_x >= 0)
else if (g_mouse_x < m_ViewScrollMouseDetectDistance && g_mouse_x >= 0)
moveRightward -= m_ViewScrollSpeed * deltaRealTime;
if (g_mouse_y >= g_yres - 2 && g_mouse_y < g_yres)
if (g_mouse_y >= g_yres - m_ViewScrollMouseDetectDistance && g_mouse_y < g_yres)
moveForward -= m_ViewScrollSpeed * deltaRealTime;
else if (g_mouse_y <= 3 && g_mouse_y >= 0)
else if (g_mouse_y < m_ViewScrollMouseDetectDistance && g_mouse_y >= 0)
moveForward += m_ViewScrollSpeed * deltaRealTime;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -88,6 +88,8 @@ private:
// Settings
float m_ViewScrollSpeed;
float m_ViewScrollSpeedModifier;
// How close the mouse pointer should be to a view edge to move the camera.
int m_ViewScrollMouseDetectDistance;
float m_ViewRotateXSpeed;
float m_ViewRotateXMin;
float m_ViewRotateXMax;