From d9ccd6edf308bed6979f4494cb5f41018127f740 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 30 Jan 2016 10:37:39 +0100 Subject: [PATCH 1/7] Camera smoothness adjustment --- src/graphics/engine/camera.cpp | 19 ++++++------------- src/graphics/engine/camera.h | 7 +------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 6c187a22..60a48bf6 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -124,13 +124,11 @@ CCamera::CCamera() m_visitDist = 0.0f; m_visitTime = 0.0f; m_visitType = CAM_TYPE_NULL; - m_visitDirectionH = 0.0f; m_visitDirectionV = 0.0f; m_editHeight = 40.0f; m_remotePan = 0.0f; - m_remoteZoom = 0.0f; m_mouseDirH = 0.0f; m_mouseDirV = 0.0f; @@ -156,7 +154,7 @@ CCamera::CCamera() m_overType = CAM_OVER_EFFECT_NULL; m_overForce = 0.0f; m_overTime = 0.0f; - m_overMode = 0.0f; + m_overMode = 0; m_overFadeIn = 0.0f; m_overFadeOut = 0.0f; @@ -262,7 +260,6 @@ void CCamera::Init(Math::Vector eye, Math::Vector lookat, float delay) m_scriptLookat = m_actualLookat; m_focus = 1.00f; m_remotePan = 0.0f; - m_remoteZoom = 0.0f; FlushEffect(); FlushOver(); @@ -283,7 +280,6 @@ CObject* CCamera::GetControllingObject() void CCamera::SetType(CameraType type) { m_remotePan = 0.0f; - m_remoteZoom = 0.0f; if ( (m_type == CAM_TYPE_BACK) && m_transparency ) { @@ -406,7 +402,7 @@ void CCamera::SetSmooth(CameraSmooth type) m_smooth = type; } -CameraSmooth CCamera::GetSmoth() +CameraSmooth CCamera::GetSmooth() { return m_smooth; } @@ -482,7 +478,6 @@ void CCamera::StartVisit(Math::Vector goal, float dist) m_visitGoal = goal; m_visitDist = dist; m_visitTime = 0.0f; - m_visitDirectionH = 0.0f; m_visitDirectionV = -Math::PI*0.10f; } @@ -891,9 +886,8 @@ void CCamera::SetViewTime(const Math::Vector &eyePt, float dist = Math::Distance(m_finalEye, m_actualEye); if (m_smooth == CAM_SMOOTH_NONE) prog = dist; - if (m_smooth == CAM_SMOOTH_NORM) prog = powf(dist, 1.5f) * rTime * 0.5f; - if (m_smooth == CAM_SMOOTH_HARD) prog = powf(dist, 1.0f) * rTime * 4.0f; - if (m_smooth == CAM_SMOOTH_SPEC) prog = powf(dist, 1.0f) * rTime * 0.05f; + if (m_smooth == CAM_SMOOTH_NORM) prog = dist * rTime * 3.0f; + if (m_smooth == CAM_SMOOTH_HARD) prog = dist * rTime * 4.0f; if (dist == 0.0f) { m_actualEye = m_finalEye; @@ -907,9 +901,8 @@ void CCamera::SetViewTime(const Math::Vector &eyePt, dist = Math::Distance(m_finalLookat, m_actualLookat); if ( m_smooth == CAM_SMOOTH_NONE ) prog = dist; - if ( m_smooth == CAM_SMOOTH_NORM ) prog = powf(dist, 1.5f) * rTime * 2.0f; - if ( m_smooth == CAM_SMOOTH_HARD ) prog = powf(dist, 1.0f) * rTime * 4.0f; - if ( m_smooth == CAM_SMOOTH_SPEC ) prog = powf(dist, 1.0f) * rTime * 4.0f; + if ( m_smooth == CAM_SMOOTH_NORM ) prog = dist * rTime * 6.0f; + if ( m_smooth == CAM_SMOOTH_HARD ) prog = dist * rTime * 4.0f; if ( dist == 0.0f ) { m_actualLookat = m_finalLookat; diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index 16c42eeb..31614718 100644 --- a/src/graphics/engine/camera.h +++ b/src/graphics/engine/camera.h @@ -77,8 +77,6 @@ enum CameraSmooth CAM_SMOOTH_NORM = 1, //! Hard CAM_SMOOTH_HARD = 2, - //! Special - CAM_SMOOTH_SPEC = 3, }; enum CenteringPhase @@ -151,7 +149,7 @@ public: //! Management of the smoothing mode void SetSmooth(CameraSmooth type); - CameraSmooth GetSmoth(); + CameraSmooth GetSmooth(); //! Management of the setback distance void SetDist(float dist); @@ -347,15 +345,12 @@ protected: //! CAM_TYPE_VISIT: initial type CameraType m_visitType; //! CAM_TYPE_VISIT: direction - float m_visitDirectionH; - //! CAM_TYPE_VISIT: direction float m_visitDirectionV; //! CAM_TYPE_EDIT: height float m_editHeight; float m_remotePan; - float m_remoteZoom; Math::Point m_mousePos; float m_mouseDirH; From 47d39e5b227fece6fa6e47c65e385a4377ba8e6e Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 14 Feb 2016 15:51:18 +0100 Subject: [PATCH 2/7] Right click camera; minor CCamera cleanups --- src/common/event.h | 10 -- src/graphics/engine/camera.cpp | 180 +++++++++++---------------------- src/graphics/engine/camera.h | 24 ++--- src/level/robotmain.cpp | 1 - src/object/old_object.cpp | 1 - src/ui/controls/control.cpp | 2 +- src/ui/controls/edit.cpp | 2 +- src/ui/controls/interface.cpp | 8 +- src/ui/controls/interface.h | 2 - src/ui/controls/list.cpp | 17 ++-- src/ui/controls/map.cpp | 13 ++- src/ui/controls/target.cpp | 2 +- src/ui/controls/window.cpp | 2 +- 13 files changed, 87 insertions(+), 177 deletions(-) diff --git a/src/common/event.h b/src/common/event.h index 362fb09c..50fb0c98 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -636,16 +636,6 @@ struct MouseButtonEventData : public EventData MouseButton button = MOUSE_BUTTON_LEFT; }; -/** - * \enum WheelDirection - * \brief Direction of mouse wheel movement - */ -enum WheelDirection -{ - WHEEL_UP, - WHEEL_DOWN -}; - /** * \struct MouseWheelEventData * \brief Additional data for mouse wheel event. diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 60a48bf6..41796a4c 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -98,11 +98,6 @@ CCamera::CCamera() m_normLookat = Math::Vector(0.0f, 0.0f, 0.0f); m_focus = 1.0f; - m_rightDown = false; - m_rightPosInit = Math::Point(0.5f, 0.5f); - m_rightPosCenter = Math::Point(0.5f, 0.5f); - m_rightPosMove = Math::Point(0.5f, 0.5f); - m_eyePt = Math::Vector(0.0f, 0.0f, 0.0f); m_directionH = 0.0f; m_directionV = 0.0f; @@ -130,12 +125,6 @@ CCamera::CCamera() m_remotePan = 0.0f; - m_mouseDirH = 0.0f; - m_mouseDirV = 0.0f; - m_mouseMarging = 0.01f; - - m_motorTurn = 0.0f; - m_centeringPhase = CAM_PHASE_NULL; m_centeringAngleH = 0.0f; m_centeringAngleV = 0.0f; @@ -222,13 +211,6 @@ bool CCamera::GetCameraInvertY() return m_cameraInvertY; } -float CCamera::GetMotorTurn() -{ - if (m_type == CAM_TYPE_BACK) - return m_motorTurn; - return 0.0f; -} - void CCamera::Init(Math::Vector eye, Math::Vector lookat, float delay) { m_initDelay = delay; @@ -1076,6 +1058,11 @@ bool CCamera::EventProcess(const Event &event) EventFrame(event); break; + case EVENT_MOUSE_BUTTON_DOWN: + case EVENT_MOUSE_BUTTON_UP: + EventMouseButton(event); + break; + case EVENT_MOUSE_MOVE: EventMouseMove(event); break; @@ -1092,7 +1079,10 @@ bool CCamera::EventProcess(const Event &event) bool CCamera::EventMouseMove(const Event &event) { + m_mouseDelta += (event.mousePos - m_mousePos); m_mousePos = event.mousePos; + if (m_mouseRightDown) + m_engine->SetMouseType(ENG_MOUSE_MOVE); return true; } @@ -1129,6 +1119,24 @@ void CCamera::EventMouseWheel(const Event &event) } } +void CCamera::EventMouseButton(const Event &event) +{ + if (event.GetData()->button == MOUSE_BUTTON_RIGHT) + { + if (event.type == EVENT_MOUSE_BUTTON_DOWN) + { + m_mouseRightDown = true; + m_mouseDelta.LoadZero(); + m_engine->SetMouseType(ENG_MOUSE_MOVE); + } + else + { + m_mouseRightDown = false; + m_engine->SetMouseType(ENG_MOUSE_NORM); + } + } +} + bool CCamera::EventFrame(const Event &event) { EffectFrame(event); @@ -1168,69 +1176,6 @@ bool CCamera::EventFrame(const Event &event) return true; } -EngineMouseType CCamera::GetMouseDef(Math::Point pos) -{ - EngineMouseType type = ENG_MOUSE_NORM; - m_mousePos = pos; - - if (m_type == CAM_TYPE_INFO) - return type; - - if (m_rightDown) // the right button pressed? - { - m_rightPosMove.x = pos.x - m_rightPosCenter.x; - m_rightPosMove.y = pos.y - m_rightPosCenter.y; - type = ENG_MOUSE_MOVE; - } - else - { - if (!m_cameraScroll) - return type; - - m_mouseDirH = 0.0f; - m_mouseDirV = 0.0f; - - if (pos.x < m_mouseMarging) - m_mouseDirH = pos.x / m_mouseMarging - 1.0f; - - if (pos.x > 1.0f - m_mouseMarging) - m_mouseDirH = 1.0f - (1.0f - pos.x) / m_mouseMarging; - - if (pos.y < m_mouseMarging) - m_mouseDirV = pos.y / m_mouseMarging - 1.0f; - - if (pos.y > 1.0f-m_mouseMarging) - m_mouseDirV = 1.0f - (1.0f - pos.y) / m_mouseMarging; - - if ( m_type == CAM_TYPE_FREE || - m_type == CAM_TYPE_EDIT || - m_type == CAM_TYPE_BACK || - m_type == CAM_TYPE_FIX || - m_type == CAM_TYPE_PLANE || - m_type == CAM_TYPE_EXPLO ) - { - if (m_mouseDirH > 0.0f) - type = ENG_MOUSE_SCROLLR; - if (m_mouseDirH < 0.0f) - type = ENG_MOUSE_SCROLLL; - } - - if ( m_type == CAM_TYPE_FREE || - m_type == CAM_TYPE_EDIT ) - { - if (m_mouseDirV > 0.0f) - type = ENG_MOUSE_SCROLLU; - if (m_mouseDirV < 0.0f) - type = ENG_MOUSE_SCROLLD; - } - - if (m_cameraInvertX) - m_mouseDirH = -m_mouseDirH; - } - - return type; -} - bool CCamera::EventFrameFree(const Event &event) { Math::Vector cameraInput = event.cameraInput; @@ -1241,10 +1186,12 @@ bool CCamera::EventFrameFree(const Event &event) float factor = m_heightEye * 0.5f + 30.0f; - if ( m_mouseDirH != 0.0f ) - m_directionH -= m_mouseDirH * event.rTime * 0.7f * m_speed; - if ( m_mouseDirV != 0.0f ) - m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDirV * event.rTime * factor * m_speed); + if ( m_mouseRightDown ) + { + m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed); + m_mouseDelta.LoadZero(); + } // Up/Down m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, cameraInput.y * event.rTime * factor * m_speed); @@ -1314,17 +1261,13 @@ bool CCamera::EventFrameEdit(const Event &event) { float factor = m_editHeight * 0.5f + 30.0f; - if (m_mouseDirH != 0.0f) - m_directionH -= m_mouseDirH * event.rTime * 0.7f * m_speed; - if (m_mouseDirV != 0.0f) - m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDirV * event.rTime * factor * m_speed); - - if (m_cameraScroll) + if (m_mouseRightDown) { - // Left/Right. - m_fixDirectionH += m_mouseDirH * event.rTime * 1.0f * m_speed; - m_fixDirectionH = Math::NormAngle(m_fixDirectionH); + m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed); + m_mouseDelta.LoadZero(); } + m_fixDirectionH = Math::NormAngle(m_fixDirectionH); m_terrain->AdjustToBounds(m_eyePt, 10.0f); @@ -1377,25 +1320,13 @@ bool CCamera::EventFrameBack(const Event &event) if (m_backDist > 200.0f) m_backDist = 200.0f; } - m_motorTurn = 0.0f; - - if (m_rightDown) + if (m_mouseRightDown) { - m_addDirectionH = m_rightPosMove.x * 6.0f; - m_addDirectionV = -m_rightPosMove.y * 2.0f; - } - else - { - if (m_cameraScroll) - { - // Left/Right - m_addDirectionH += m_mouseDirH * event.rTime * 1.0f * m_speed; - m_addDirectionH = Math::NormAngle(m_addDirectionH); - } - } - - if ((m_mouseDirH != 0) || (m_mouseDirV != 0)) + m_addDirectionH -= m_mouseDelta.x * 2*Math::PI; + m_addDirectionH = Math::NormAngle(m_addDirectionH); + m_mouseDelta.LoadZero(); AbortCentering(); // special stops framing + } // Increase the special framework float centeringH = 0.0f; @@ -1528,21 +1459,21 @@ bool CCamera::EventFrameFix(const Event &event) if (m_fixDist > 200.0f) m_fixDist = 200.0f; } - // Left/Right - if (m_cameraScroll) + if (m_mouseRightDown) { - m_fixDirectionH += m_mouseDirH * event.rTime * 1.0f * m_speed; - m_fixDirectionH = Math::NormAngle(m_fixDirectionH); + m_fixDirectionH -= m_mouseDelta.x * 2*Math::PI; + m_mouseDelta.LoadZero(); + AbortCentering(); // special stops framing } + + // Left/Right m_fixDirectionH += event.cameraInput.x * event.rTime * 0.7f * m_speed; + m_fixDirectionH = Math::NormAngle(m_fixDirectionH); // Up/Down m_fixDirectionV -= event.cameraInput.y * event.rTime * 0.7f * m_speed; m_fixDirectionV = Math::Min(Math::Max(m_fixDirectionV, -0.5*Math::PI), 0.25*Math::PI); - if ((m_mouseDirH != 0) || (m_mouseDirV != 0)) - AbortCentering(); // special stops framing - if (m_cameraObj != nullptr) { Math::Vector lookatPt = m_cameraObj->GetPosition(); @@ -1567,8 +1498,11 @@ bool CCamera::EventFrameFix(const Event &event) bool CCamera::EventFrameExplo(const Event &event) { - if (m_mouseDirH != 0.0f) - m_directionH -= m_mouseDirH * event.rTime * 0.7f * m_speed; + if (m_mouseRightDown) + { + m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_mouseDelta.LoadZero(); + } m_terrain->AdjustToBounds(m_eyePt, 10.0f); @@ -1649,9 +1583,10 @@ bool CCamera::EventFrameVisit(const Event &event) if (m_visitDirectionV > 0.0f ) m_visitDirectionV = 0.0f; } - if (m_cameraScroll) + if (m_mouseRightDown) { - m_visitDist -= m_mouseDirV * event.rTime * 30.0f * m_speed; + m_visitDist -= m_mouseDelta.y * 100.0f * m_speed; + m_mouseDelta.LoadZero(); if (m_visitDist < 20.0f) m_visitDist = 20.0f; if (m_visitDist > 200.0f) m_visitDist = 200.0f; } @@ -1744,5 +1679,4 @@ void CCamera::SetCameraSpeed(float speed) m_speed = speed; } - } diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index 31614718..0d5c7d7e 100644 --- a/src/graphics/engine/camera.h +++ b/src/graphics/engine/camera.h @@ -211,18 +211,15 @@ public: void SetCameraInvertY(bool invert); bool GetCameraInvertY(); - //! Returns an additional force to turn - float GetMotorTurn(); - //! Returns the default sprite to use for the mouse - EngineMouseType GetMouseDef(Math::Point pos); - void SetCameraSpeed(float speed); protected: //! Changes the camera according to the mouse moved bool EventMouseMove(const Event &event); //! Mouse wheel operation - void EventMouseWheel(const Event& event); + void EventMouseWheel(const Event &event); + //! Mouse button handling + void EventMouseButton(const Event &event); //! Changes the camera according to the time elapsed bool EventFrame(const Event &event); //! Moves the point of view @@ -301,11 +298,6 @@ protected: float m_focus; - bool m_rightDown; - Math::Point m_rightPosInit; - Math::Point m_rightPosCenter; - Math::Point m_rightPosMove; - //! CAM_TYPE_FREE: eye Math::Vector m_eyePt; //! CAM_TYPE_FREE: horizontal direction @@ -352,12 +344,9 @@ protected: float m_remotePan; - Math::Point m_mousePos; - float m_mouseDirH; - float m_mouseDirV; - float m_mouseMarging; - - float m_motorTurn; + bool m_mouseRightDown = false; + Math::Point m_mousePos = Math::Point(0.5f, 0.5f); + Math::Point m_mouseDelta = Math::Point(0.0f, 0.0f); CenteringPhase m_centeringPhase; float m_centeringAngleH; @@ -396,7 +385,6 @@ protected: bool m_cameraInvertX; //! Y inversion in the edges? bool m_cameraInvertY; - }; diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 57918012..d1daf0c8 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -687,7 +687,6 @@ bool CRobotMain::ProcessEvent(Event &event) m_displayText->EventProcess(event); RemoteCamera(m_cameraPan, m_cameraZoom, event.rTime); - m_interface->EventProcess(event); if (m_displayInfo != nullptr) // current edition? m_displayInfo->EventProcess(event); diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp index 55343e64..7fd53ca6 100644 --- a/src/object/old_object.cpp +++ b/src/object/old_object.cpp @@ -2103,7 +2103,6 @@ bool COldObject::EventProcess(const Event &event) axeZ = -1.0f; // tomb } - axeX += m_camera->GetMotorTurn(); // additional power according to camera if ( axeX > 1.0f ) axeX = 1.0f; if ( axeX < -1.0f ) axeX = -1.0f; diff --git a/src/ui/controls/control.cpp b/src/ui/controls/control.cpp index d167b081..e0b8ccf9 100644 --- a/src/ui/controls/control.cpp +++ b/src/ui/controls/control.cpp @@ -314,7 +314,7 @@ bool CControl::EventProcess(const Event &event) GlintFrame(event); } - if ( event.type == EVENT_MOUSE_MOVE ) + if ( event.type == EVENT_MOUSE_MOVE || event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP ) { m_glintMouse = event.mousePos; diff --git a/src/ui/controls/edit.cpp b/src/ui/controls/edit.cpp index 481e7c20..2e99cec1 100644 --- a/src/ui/controls/edit.cpp +++ b/src/ui/controls/edit.cpp @@ -266,7 +266,7 @@ bool CEdit::EventProcess(const Event &event) m_timeBlink += event.rTime; } - if ( event.type == EVENT_MOUSE_MOVE ) + if ( event.type == EVENT_MOUSE_MOVE || event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP ) { if ( Detect(event.mousePos) && event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) diff --git a/src/ui/controls/interface.cpp b/src/ui/controls/interface.cpp index 6ad3bfc0..ad8d6ef0 100644 --- a/src/ui/controls/interface.cpp +++ b/src/ui/controls/interface.cpp @@ -54,7 +54,6 @@ CInterface::CInterface() { m_event = CApplication::GetInstancePointer()->GetEventQueue(); m_engine = Gfx::CEngine::GetInstancePointer(); - m_camera = nullptr; } // Object's destructor. @@ -300,12 +299,9 @@ CControl* CInterface::SearchControl(EventType eventMsg) bool CInterface::EventProcess(const Event &event) { - if (event.type == EVENT_MOUSE_MOVE) + if (event.type == EVENT_MOUSE_MOVE || event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP) { - if (m_camera == nullptr) - m_camera = CRobotMain::GetInstancePointer()->GetCamera(); - - m_engine->SetMouseType(m_camera->GetMouseDef(event.mousePos)); + m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); } for (auto& control : boost::adaptors::reverse(m_controls)) diff --git a/src/ui/controls/interface.h b/src/ui/controls/interface.h index 5c351e8b..264faf3b 100644 --- a/src/ui/controls/interface.h +++ b/src/ui/controls/interface.h @@ -29,7 +29,6 @@ namespace Gfx { -class CCamera; class CEngine; } // namespace Gfx @@ -101,7 +100,6 @@ protected: CEventQueue* m_event; Gfx::CEngine* m_engine; - Gfx::CCamera* m_camera; std::array, MAXCONTROL> m_controls; }; diff --git a/src/ui/controls/list.cpp b/src/ui/controls/list.cpp index c23c9354..b446bd2f 100644 --- a/src/ui/controls/list.cpp +++ b/src/ui/controls/list.cpp @@ -293,15 +293,18 @@ bool CList::EventProcess(const Event &event) CControl::EventProcess(event); - if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos)) + if (event.type == EVENT_MOUSE_MOVE || event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP) { - m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); - for (int i = 0; i < m_displayLine; i++) + if (Detect(event.mousePos)) { - if (i + m_firstLine >= m_totalLine) - break; - if (m_buttons[i] != nullptr) - m_buttons[i]->EventProcess(event); + m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); + for (int i = 0; i < m_displayLine; i++) + { + if (i + m_firstLine >= m_totalLine) + break; + if (m_buttons[i] != nullptr) + m_buttons[i]->EventProcess(event); + } } } diff --git a/src/ui/controls/map.cpp b/src/ui/controls/map.cpp index 0bc607d7..9bc35b91 100644 --- a/src/ui/controls/map.cpp +++ b/src/ui/controls/map.cpp @@ -203,12 +203,15 @@ bool CMap::EventProcess(const Event &event) if ( event.type == EVENT_FRAME ) m_time += event.rTime; - if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) ) + if ( event.type == EVENT_MOUSE_MOVE || event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP ) { - m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); - bool inMap = false; - if (DetectObject(event.mousePos, inMap) != nullptr) - m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); + if (Detect(event.mousePos)) + { + m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); + bool inMap = false; + if (DetectObject(event.mousePos, inMap) != nullptr) + m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); + } } if (event.type == EVENT_MOUSE_BUTTON_DOWN && diff --git a/src/ui/controls/target.cpp b/src/ui/controls/target.cpp index 1bd7ac78..b42116fc 100644 --- a/src/ui/controls/target.cpp +++ b/src/ui/controls/target.cpp @@ -64,7 +64,7 @@ bool CTarget::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.type == EVENT_MOUSE_MOVE ) + if ( event.type == EVENT_MOUSE_MOVE || event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP ) { m_main->SetFriendAim(false); diff --git a/src/ui/controls/window.cpp b/src/ui/controls/window.cpp index 0f4f9ac3..8182aaff 100644 --- a/src/ui/controls/window.cpp +++ b/src/ui/controls/window.cpp @@ -662,7 +662,7 @@ int CWindow::BorderDetect(Math::Point pos) bool CWindow::EventProcess(const Event &event) { - if ( event.type == EVENT_MOUSE_MOVE ) + if ( event.type == EVENT_MOUSE_MOVE || event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP ) { if ( m_bCapture ) { From 1efa4b132c7cf5b294ff1ce95150ecb11541aff3 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 14 Feb 2016 16:07:17 +0100 Subject: [PATCH 3/7] Fixed mouse invert settings; removed camera scroll setting --- po/colobot.pot | 3 --- po/de.po | 9 +++++---- po/fr.po | 10 +++++----- po/pl.po | 10 +++++----- po/ru.po | 6 +++--- src/common/event.cpp | 1 - src/common/event.h | 1 - src/common/restext.cpp | 1 - src/common/settings.cpp | 4 ---- src/graphics/engine/camera.cpp | 17 ++++++----------- src/graphics/engine/camera.h | 2 -- src/ui/screen/screen_setup_game.cpp | 15 --------------- 12 files changed, 24 insertions(+), 55 deletions(-) diff --git a/po/colobot.pot b/po/colobot.pot index 4343aa2a..e8057295 100644 --- a/po/colobot.pot +++ b/po/colobot.pot @@ -370,9 +370,6 @@ msgstr "" msgid "Film sequences\\Films before and after the missions" msgstr "" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" - msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" msgstr "" diff --git a/po/de.po b/po/de.po index 3ae02cdf..7ea55498 100644 --- a/po/de.po +++ b/po/de.po @@ -1311,10 +1311,6 @@ msgstr "Speichern\\Aktuelle Mission speichern" msgid "Save\\Saves the current mission" msgstr "Speichern\\Speichert die Mission" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Astronauten auswählen\\Astronauten auswählen" @@ -1905,6 +1901,11 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Robby\\Ihr Assistent" +#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" +#~ msgstr "" +#~ "Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand " +#~ "erreicht" + #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Himmel\\Himmel und Wolken" diff --git a/po/fr.po b/po/fr.po index 730e849c..95cda05d 100644 --- a/po/fr.po +++ b/po/fr.po @@ -1299,11 +1299,6 @@ msgstr "Enregistrer\\Enregistrer la mission en cours" msgid "Save\\Saves the current mission" msgstr "Enregistrer\\Enregistrer la mission en cours" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Défilement dans les bords\\Défilement lorsque la souris touches les bords " -"gauche ou droite" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute" @@ -1892,6 +1887,11 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Robbie\\Votre assistant" +#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" +#~ msgstr "" +#~ "Défilement dans les bords\\Défilement lorsque la souris touches les bords " +#~ "gauche ou droite" + #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Ciel\\Ciel et nuages" diff --git a/po/pl.po b/po/pl.po index a54a297c..9c509fb7 100644 --- a/po/pl.po +++ b/po/pl.po @@ -1307,11 +1307,6 @@ msgstr "Zapisz\\Zapisuje bieżącą misję" msgid "Save\\Saves the current mission" msgstr "Zapisz\\Zapisuje bieżącą misję" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego " -"krawędzi" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Zaznacz astronautę\\Zaznacza astronautę" @@ -1885,6 +1880,11 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Robbie\\Twój asystent" +#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" +#~ msgstr "" +#~ "Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego " +#~ "krawędzi" + #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Niebo\\Chmury i mgławice" diff --git a/po/ru.po b/po/ru.po index 1febf458..33838732 100644 --- a/po/ru.po +++ b/po/ru.po @@ -1306,9 +1306,6 @@ msgstr "Сохранить\\Сохранить текущую миссию" msgid "Save\\Saves the current mission" msgstr "Сохранить\\Сохранить текущую миссию" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Выбор астронавта\\Выбор астронавта" @@ -1896,6 +1893,9 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Робби\\Ваш помощник" +#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" +#~ msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана" + #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Небо\\Облака и туманности" diff --git a/src/common/event.cpp b/src/common/event.cpp index ccd7fe8a..b1fb6093 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -208,7 +208,6 @@ void InitializeEventTypeTexts() EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINT] = "EVENT_INTERFACE_GLINT"; EVENT_TYPE_TEXT[EVENT_INTERFACE_TOOLTIP] = "EVENT_INTERFACE_TOOLTIP"; EVENT_TYPE_TEXT[EVENT_INTERFACE_MOVIES] = "EVENT_INTERFACE_MOVIES"; - EVENT_TYPE_TEXT[EVENT_INTERFACE_SCROLL] = "EVENT_INTERFACE_SCROLL"; EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTX] = "EVENT_INTERFACE_INVERTX"; EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTY] = "EVENT_INTERFACE_INVERTY"; EVENT_TYPE_TEXT[EVENT_INTERFACE_EFFECT] = "EVENT_INTERFACE_EFFECT"; diff --git a/src/common/event.h b/src/common/event.h index 50fb0c98..f211ba1b 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -237,7 +237,6 @@ enum EventType EVENT_INTERFACE_GLINT = 463, EVENT_INTERFACE_TOOLTIP = 464, EVENT_INTERFACE_MOVIES = 465, - EVENT_INTERFACE_SCROLL = 467, EVENT_INTERFACE_INVERTX = 468, EVENT_INTERFACE_INVERTY = 469, EVENT_INTERFACE_EFFECT = 470, diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 18e78614..62a929ef 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -190,7 +190,6 @@ void InitializeRestext() stringsEvent[EVENT_INTERFACE_GLINT] = TR("Reflections on the buttons \\Shiny buttons"); stringsEvent[EVENT_INTERFACE_TOOLTIP] = TR("Help balloons\\Explain the function of the buttons"); stringsEvent[EVENT_INTERFACE_MOVIES] = TR("Film sequences\\Films before and after the missions"); - stringsEvent[EVENT_INTERFACE_SCROLL] = TR("Scrolling\\Scrolling when the mouse touches right or left border"); stringsEvent[EVENT_INTERFACE_INVERTX] = TR("Mouse inversion X\\Inversion of the scrolling direction on the X axis"); stringsEvent[EVENT_INTERFACE_INVERTY] = TR("Mouse inversion Y\\Inversion of the scrolling direction on the Y axis"); stringsEvent[EVENT_INTERFACE_EFFECT] = TR("Quake at explosions\\The screen shakes at explosions"); diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 519b3172..2f6ef2cb 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -80,7 +80,6 @@ void CSettings::SaveSettings() GetConfigFile().SetBoolProperty("Setup", "Soluce4", m_soluce4); GetConfigFile().SetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().SetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); - GetConfigFile().SetBoolProperty("Setup", "CameraScroll", camera->GetCameraScroll()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertX", camera->GetCameraInvertX()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY()); GetConfigFile().SetBoolProperty("Setup", "InterfaceEffect", camera->GetEffect()); @@ -152,9 +151,6 @@ void CSettings::LoadSettings() GetConfigFile().GetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().GetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); - if (GetConfigFile().GetBoolProperty("Setup", "CameraScroll", bValue)) - camera->SetCameraScroll(bValue); - if (GetConfigFile().GetBoolProperty("Setup", "CameraInvertX", bValue)) camera->SetCameraInvertX(bValue); diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 41796a4c..cc1f24d3 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -152,7 +152,6 @@ CCamera::CCamera() m_effect = true; m_blood = true; - m_cameraScroll = true; m_cameraInvertX = false; m_cameraInvertY = false; } @@ -181,16 +180,6 @@ bool CCamera::GetBlood() return m_blood; } -void CCamera::SetCameraScroll(bool scroll) -{ - m_cameraScroll = scroll; -} - -bool CCamera::GetCameraScroll() -{ - return m_cameraScroll; -} - void CCamera::SetCameraInvertX(bool invert) { m_cameraInvertX = invert; @@ -1080,7 +1069,13 @@ bool CCamera::EventProcess(const Event &event) bool CCamera::EventMouseMove(const Event &event) { m_mouseDelta += (event.mousePos - m_mousePos); + if (m_cameraInvertX) + m_mouseDelta.x = -m_mouseDelta.x; + if (m_cameraInvertY) + m_mouseDelta.y = -m_mouseDelta.y; + m_mousePos = event.mousePos; + if (m_mouseRightDown) m_engine->SetMouseType(ENG_MOUSE_MOVE); return true; diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index 0d5c7d7e..1cb990e2 100644 --- a/src/graphics/engine/camera.h +++ b/src/graphics/engine/camera.h @@ -204,8 +204,6 @@ public: bool GetEffect(); void SetBlood(bool enable); bool GetBlood(); - void SetCameraScroll(bool scroll); - bool GetCameraScroll(); void SetCameraInvertX(bool invert); bool GetCameraInvertX(); void SetCameraInvertY(bool invert); diff --git a/src/ui/screen/screen_setup_game.cpp b/src/ui/screen/screen_setup_game.cpp index 0479c2d7..c1bce9e2 100644 --- a/src/ui/screen/screen_setup_game.cpp +++ b/src/ui/screen/screen_setup_game.cpp @@ -69,9 +69,6 @@ void CScreenSetupGame::CreateInterface() pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOVIES); pc->SetState(STATE_SHADOW); pos.y -= 0.048f; - pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SCROLL); - pc->SetState(STATE_SHADOW); - pos.y -= 0.048f; pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_INVERTX); pc->SetState(STATE_SHADOW); pos.y -= 0.048f; @@ -213,12 +210,6 @@ bool CScreenSetupGame::EventProcess(const Event &event) UpdateSetupButtons(); break; - case EVENT_INTERFACE_SCROLL: - m_camera->SetCameraScroll(!m_camera->GetCameraScroll()); - ChangeSetupButtons(); - UpdateSetupButtons(); - break; - case EVENT_INTERFACE_INVERTX: m_camera->SetCameraInvertX(!m_camera->GetCameraInvertX()); ChangeSetupButtons(); @@ -322,12 +313,6 @@ void CScreenSetupGame::UpdateSetupButtons() pc->SetState(STATE_CHECK, m_settings->GetMovies()); } - pc = static_cast(pw->SearchControl(EVENT_INTERFACE_SCROLL)); - if ( pc != nullptr ) - { - pc->SetState(STATE_CHECK, m_camera->GetCameraScroll()); - } - pc = static_cast(pw->SearchControl(EVENT_INTERFACE_INVERTX)); if ( pc != nullptr ) { From b15666f48e3a53becebaac03765c5ec79c039f6d Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 19 Feb 2016 16:46:33 +0100 Subject: [PATCH 4/7] Restored old camera scroll as a config option --- po/colobot.pot | 3 + po/de.po | 9 +- po/fr.po | 10 +- po/pl.po | 10 +- po/ru.po | 6 +- src/common/event.cpp | 1 + src/common/event.h | 1 + src/common/restext.cpp | 5 +- src/common/settings.cpp | 4 + src/graphics/engine/camera.cpp | 139 +++++++++++++++++++--------- src/graphics/engine/camera.h | 7 +- src/ui/screen/screen_setup_game.cpp | 15 +++ 12 files changed, 141 insertions(+), 69 deletions(-) diff --git a/po/colobot.pot b/po/colobot.pot index e8057295..4343aa2a 100644 --- a/po/colobot.pot +++ b/po/colobot.pot @@ -370,6 +370,9 @@ msgstr "" msgid "Film sequences\\Films before and after the missions" msgstr "" +msgid "Scrolling\\Scrolling when the mouse touches right or left border" +msgstr "" + msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" msgstr "" diff --git a/po/de.po b/po/de.po index 7ea55498..3ae02cdf 100644 --- a/po/de.po +++ b/po/de.po @@ -1311,6 +1311,10 @@ msgstr "Speichern\\Aktuelle Mission speichern" msgid "Save\\Saves the current mission" msgstr "Speichern\\Speichert die Mission" +msgid "Scrolling\\Scrolling when the mouse touches right or left border" +msgstr "" +"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht" + msgid "Select the astronaut\\Selects the astronaut" msgstr "Astronauten auswählen\\Astronauten auswählen" @@ -1901,11 +1905,6 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Robby\\Ihr Assistent" -#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" -#~ msgstr "" -#~ "Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand " -#~ "erreicht" - #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Himmel\\Himmel und Wolken" diff --git a/po/fr.po b/po/fr.po index 95cda05d..730e849c 100644 --- a/po/fr.po +++ b/po/fr.po @@ -1299,6 +1299,11 @@ msgstr "Enregistrer\\Enregistrer la mission en cours" msgid "Save\\Saves the current mission" msgstr "Enregistrer\\Enregistrer la mission en cours" +msgid "Scrolling\\Scrolling when the mouse touches right or left border" +msgstr "" +"Défilement dans les bords\\Défilement lorsque la souris touches les bords " +"gauche ou droite" + msgid "Select the astronaut\\Selects the astronaut" msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute" @@ -1887,11 +1892,6 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Robbie\\Votre assistant" -#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" -#~ msgstr "" -#~ "Défilement dans les bords\\Défilement lorsque la souris touches les bords " -#~ "gauche ou droite" - #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Ciel\\Ciel et nuages" diff --git a/po/pl.po b/po/pl.po index 9c509fb7..a54a297c 100644 --- a/po/pl.po +++ b/po/pl.po @@ -1307,6 +1307,11 @@ msgstr "Zapisz\\Zapisuje bieżącą misję" msgid "Save\\Saves the current mission" msgstr "Zapisz\\Zapisuje bieżącą misję" +msgid "Scrolling\\Scrolling when the mouse touches right or left border" +msgstr "" +"Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego " +"krawędzi" + msgid "Select the astronaut\\Selects the astronaut" msgstr "Zaznacz astronautę\\Zaznacza astronautę" @@ -1880,11 +1885,6 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Robbie\\Twój asystent" -#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" -#~ msgstr "" -#~ "Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego " -#~ "krawędzi" - #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Niebo\\Chmury i mgławice" diff --git a/po/ru.po b/po/ru.po index 33838732..1febf458 100644 --- a/po/ru.po +++ b/po/ru.po @@ -1306,6 +1306,9 @@ msgstr "Сохранить\\Сохранить текущую миссию" msgid "Save\\Saves the current mission" msgstr "Сохранить\\Сохранить текущую миссию" +msgid "Scrolling\\Scrolling when the mouse touches right or left border" +msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана" + msgid "Select the astronaut\\Selects the astronaut" msgstr "Выбор астронавта\\Выбор астронавта" @@ -1893,9 +1896,6 @@ msgstr "www.epsitec.com" #~ msgid "Robbie\\Your assistant" #~ msgstr "Робби\\Ваш помощник" -#~ msgid "Scrolling\\Scrolling when the mouse touches right or left border" -#~ msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана" - #~ msgid "Sky\\Clouds and nebulae" #~ msgstr "Небо\\Облака и туманности" diff --git a/src/common/event.cpp b/src/common/event.cpp index b1fb6093..ccd7fe8a 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -208,6 +208,7 @@ void InitializeEventTypeTexts() EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINT] = "EVENT_INTERFACE_GLINT"; EVENT_TYPE_TEXT[EVENT_INTERFACE_TOOLTIP] = "EVENT_INTERFACE_TOOLTIP"; EVENT_TYPE_TEXT[EVENT_INTERFACE_MOVIES] = "EVENT_INTERFACE_MOVIES"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SCROLL] = "EVENT_INTERFACE_SCROLL"; EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTX] = "EVENT_INTERFACE_INVERTX"; EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTY] = "EVENT_INTERFACE_INVERTY"; EVENT_TYPE_TEXT[EVENT_INTERFACE_EFFECT] = "EVENT_INTERFACE_EFFECT"; diff --git a/src/common/event.h b/src/common/event.h index f211ba1b..50fb0c98 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -237,6 +237,7 @@ enum EventType EVENT_INTERFACE_GLINT = 463, EVENT_INTERFACE_TOOLTIP = 464, EVENT_INTERFACE_MOVIES = 465, + EVENT_INTERFACE_SCROLL = 467, EVENT_INTERFACE_INVERTX = 468, EVENT_INTERFACE_INVERTY = 469, EVENT_INTERFACE_EFFECT = 470, diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 62a929ef..5d3ed298 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -20,8 +20,6 @@ #include "common/restext.h" -#include "common/config.h" - #include "CBot/CBot.h" #include "app/input.h" @@ -190,6 +188,7 @@ void InitializeRestext() stringsEvent[EVENT_INTERFACE_GLINT] = TR("Reflections on the buttons \\Shiny buttons"); stringsEvent[EVENT_INTERFACE_TOOLTIP] = TR("Help balloons\\Explain the function of the buttons"); stringsEvent[EVENT_INTERFACE_MOVIES] = TR("Film sequences\\Films before and after the missions"); + stringsEvent[EVENT_INTERFACE_SCROLL] = TR("Camera border scrolling\\Scrolling when the mouse touches right or left border"); stringsEvent[EVENT_INTERFACE_INVERTX] = TR("Mouse inversion X\\Inversion of the scrolling direction on the X axis"); stringsEvent[EVENT_INTERFACE_INVERTY] = TR("Mouse inversion Y\\Inversion of the scrolling direction on the Y axis"); stringsEvent[EVENT_INTERFACE_EFFECT] = TR("Quake at explosions\\The screen shakes at explosions"); @@ -764,7 +763,7 @@ void PutKeyName(std::string& dst, const char* src) src[s+3] == 'y' && src[s+4] == ' ' ) { - int count; + unsigned int count; for(count = 0; src[s+5+count] != ';'; count++); CInput* input = CInput::GetInstancePointer(); InputSlot key = input->SearchKeyById(std::string(&src[s+5], count)); diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 2f6ef2cb..63258ce7 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -80,6 +80,7 @@ void CSettings::SaveSettings() GetConfigFile().SetBoolProperty("Setup", "Soluce4", m_soluce4); GetConfigFile().SetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().SetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); + GetConfigFile().SetBoolProperty("Setup", "OldCameraScroll", camera->GetOldCameraScroll()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertX", camera->GetCameraInvertX()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY()); GetConfigFile().SetBoolProperty("Setup", "InterfaceEffect", camera->GetEffect()); @@ -151,6 +152,9 @@ void CSettings::LoadSettings() GetConfigFile().GetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().GetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); + if (GetConfigFile().GetBoolProperty("Setup", "OldCameraScroll", bValue)) + camera->SetOldCameraScroll(bValue); + if (GetConfigFile().GetBoolProperty("Setup", "CameraInvertX", bValue)) camera->SetCameraInvertX(bValue); diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index cc1f24d3..9c1a76a6 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -50,6 +50,7 @@ namespace Gfx { +const float MOUSE_EDGE_MARGIN = 0.01f; //! Changes the level of transparency of an object and objects transported (battery & cargo) void SetTransparency(CObject* obj, float value) @@ -152,6 +153,7 @@ CCamera::CCamera() m_effect = true; m_blood = true; + m_oldCameraScroll = false; m_cameraInvertX = false; m_cameraInvertY = false; } @@ -180,6 +182,16 @@ bool CCamera::GetBlood() return m_blood; } +void CCamera::SetOldCameraScroll(bool scroll) +{ + m_oldCameraScroll = scroll; +} + +bool CCamera::GetOldCameraScroll() +{ + return m_oldCameraScroll; +} + void CCamera::SetCameraInvertX(bool invert) { m_cameraInvertX = invert; @@ -1068,16 +1080,62 @@ bool CCamera::EventProcess(const Event &event) bool CCamera::EventMouseMove(const Event &event) { - m_mouseDelta += (event.mousePos - m_mousePos); - if (m_cameraInvertX) - m_mouseDelta.x = -m_mouseDelta.x; - if (m_cameraInvertY) - m_mouseDelta.y = -m_mouseDelta.y; + if (m_engine->GetMouseType() == ENG_MOUSE_SCROLLR || + m_engine->GetMouseType() == ENG_MOUSE_SCROLLL || + m_engine->GetMouseType() == ENG_MOUSE_SCROLLU || + m_engine->GetMouseType() == ENG_MOUSE_SCROLLD || + m_engine->GetMouseType() == ENG_MOUSE_MOVE ) + { + m_engine->SetMouseType(ENG_MOUSE_NORM); + } + + if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0) + { + Math::Point newDelta = event.mousePos - m_mousePos; + if (m_cameraInvertX) + newDelta.x = -newDelta.x; + if (m_cameraInvertY) + newDelta.y = -newDelta.y; + m_mouseDelta += newDelta; + + m_engine->SetMouseType(ENG_MOUSE_MOVE); + } + + m_mouseDeltaEdge.LoadZero(); + if (m_oldCameraScroll) + { + if (event.mousePos.x < MOUSE_EDGE_MARGIN) + m_mouseDeltaEdge.x = event.mousePos.x / MOUSE_EDGE_MARGIN - 1.0f; + if (event.mousePos.x > 1.0f - MOUSE_EDGE_MARGIN) + m_mouseDeltaEdge.x = 1.0f - (1.0f - event.mousePos.x) / MOUSE_EDGE_MARGIN; + if (event.mousePos.y < MOUSE_EDGE_MARGIN) + m_mouseDeltaEdge.y = event.mousePos.y / MOUSE_EDGE_MARGIN - 1.0f; + if (event.mousePos.y > 1.0f - MOUSE_EDGE_MARGIN) + m_mouseDeltaEdge.y = 1.0f - (1.0f - event.mousePos.y) / MOUSE_EDGE_MARGIN; + + if (m_type == CAM_TYPE_FREE || + m_type == CAM_TYPE_EDIT || + m_type == CAM_TYPE_BACK || + m_type == CAM_TYPE_FIX || + m_type == CAM_TYPE_PLANE || + m_type == CAM_TYPE_EXPLO ) + { + if (m_mouseDeltaEdge.x > 0.0f) + m_engine->SetMouseType(ENG_MOUSE_SCROLLR); + if (m_mouseDeltaEdge.x < 0.0f) + m_engine->SetMouseType(ENG_MOUSE_SCROLLL); + } + if (m_type == CAM_TYPE_FREE || + m_type == CAM_TYPE_EDIT ) + { + if (m_mouseDeltaEdge.y > 0.0f) + m_engine->SetMouseType(ENG_MOUSE_SCROLLU); + if (m_mouseDeltaEdge.y < 0.0f) + m_engine->SetMouseType(ENG_MOUSE_SCROLLD); + } + } m_mousePos = event.mousePos; - - if (m_mouseRightDown) - m_engine->SetMouseType(ENG_MOUSE_MOVE); return true; } @@ -1120,13 +1178,10 @@ void CCamera::EventMouseButton(const Event &event) { if (event.type == EVENT_MOUSE_BUTTON_DOWN) { - m_mouseRightDown = true; - m_mouseDelta.LoadZero(); m_engine->SetMouseType(ENG_MOUSE_MOVE); } else { - m_mouseRightDown = false; m_engine->SetMouseType(ENG_MOUSE_NORM); } } @@ -1134,6 +1189,13 @@ void CCamera::EventMouseButton(const Event &event) bool CCamera::EventFrame(const Event &event) { + Math::Point newDelta = m_mouseDeltaEdge * m_speed * event.rTime; + if (m_cameraInvertX) + newDelta.x = -newDelta.x; + if (m_cameraInvertY) + newDelta.y = -newDelta.y; + m_mouseDelta += newDelta; + EffectFrame(event); OverFrame(event); @@ -1181,12 +1243,9 @@ bool CCamera::EventFrameFree(const Event &event) float factor = m_heightEye * 0.5f + 30.0f; - if ( m_mouseRightDown ) - { - m_directionH -= m_mouseDelta.x * 2*Math::PI; - m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed); - m_mouseDelta.LoadZero(); - } + m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed); + m_mouseDelta.LoadZero(); // Up/Down m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, cameraInput.y * event.rTime * factor * m_speed); @@ -1256,12 +1315,10 @@ bool CCamera::EventFrameEdit(const Event &event) { float factor = m_editHeight * 0.5f + 30.0f; - if (m_mouseRightDown) - { - m_directionH -= m_mouseDelta.x * 2*Math::PI; - m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed); - m_mouseDelta.LoadZero(); - } + m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed); + m_mouseDelta.LoadZero(); + m_fixDirectionH = Math::NormAngle(m_fixDirectionH); m_terrain->AdjustToBounds(m_eyePt, 10.0f); @@ -1315,13 +1372,11 @@ bool CCamera::EventFrameBack(const Event &event) if (m_backDist > 200.0f) m_backDist = 200.0f; } - if (m_mouseRightDown) - { - m_addDirectionH -= m_mouseDelta.x * 2*Math::PI; - m_addDirectionH = Math::NormAngle(m_addDirectionH); - m_mouseDelta.LoadZero(); + m_addDirectionH -= m_mouseDelta.x * 2*Math::PI; + m_addDirectionH = Math::NormAngle(m_addDirectionH); + if (m_mouseDelta.Length() > 0) AbortCentering(); // special stops framing - } + m_mouseDelta.LoadZero(); // Increase the special framework float centeringH = 0.0f; @@ -1454,12 +1509,10 @@ bool CCamera::EventFrameFix(const Event &event) if (m_fixDist > 200.0f) m_fixDist = 200.0f; } - if (m_mouseRightDown) - { - m_fixDirectionH -= m_mouseDelta.x * 2*Math::PI; - m_mouseDelta.LoadZero(); + m_fixDirectionH -= m_mouseDelta.x * 2*Math::PI; + if (m_mouseDelta.Length() > 0) AbortCentering(); // special stops framing - } + m_mouseDelta.LoadZero(); // Left/Right m_fixDirectionH += event.cameraInput.x * event.rTime * 0.7f * m_speed; @@ -1493,11 +1546,8 @@ bool CCamera::EventFrameFix(const Event &event) bool CCamera::EventFrameExplo(const Event &event) { - if (m_mouseRightDown) - { - m_directionH -= m_mouseDelta.x * 2*Math::PI; - m_mouseDelta.LoadZero(); - } + m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_mouseDelta.LoadZero(); m_terrain->AdjustToBounds(m_eyePt, 10.0f); @@ -1578,13 +1628,10 @@ bool CCamera::EventFrameVisit(const Event &event) if (m_visitDirectionV > 0.0f ) m_visitDirectionV = 0.0f; } - if (m_mouseRightDown) - { - m_visitDist -= m_mouseDelta.y * 100.0f * m_speed; - m_mouseDelta.LoadZero(); - if (m_visitDist < 20.0f) m_visitDist = 20.0f; - if (m_visitDist > 200.0f) m_visitDist = 200.0f; - } + m_visitDist -= m_mouseDelta.y * 100.0f * m_speed; + m_mouseDelta.LoadZero(); + if (m_visitDist < 20.0f) m_visitDist = 20.0f; + if (m_visitDist > 200.0f) m_visitDist = 200.0f; float angleH = (m_visitTime / 10.0f) * (Math::PI * 2.0f); float angleV = m_visitDirectionV; diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index 1cb990e2..f00332a0 100644 --- a/src/graphics/engine/camera.h +++ b/src/graphics/engine/camera.h @@ -204,6 +204,8 @@ public: bool GetEffect(); void SetBlood(bool enable); bool GetBlood(); + void SetOldCameraScroll(bool scroll); + bool GetOldCameraScroll(); void SetCameraInvertX(bool invert); bool GetCameraInvertX(); void SetCameraInvertY(bool invert); @@ -342,9 +344,10 @@ protected: float m_remotePan; - bool m_mouseRightDown = false; + //! Last known mouse position, used to calculate change since last frame Math::Point m_mousePos = Math::Point(0.5f, 0.5f); Math::Point m_mouseDelta = Math::Point(0.0f, 0.0f); + Math::Point m_mouseDeltaEdge = Math::Point(0.0f, 0.0f); CenteringPhase m_centeringPhase; float m_centeringAngleH; @@ -378,7 +381,7 @@ protected: //! Blood? bool m_blood; //! Scroll in the edges? - bool m_cameraScroll; + bool m_oldCameraScroll; //! X inversion in the edges? bool m_cameraInvertX; //! Y inversion in the edges? diff --git a/src/ui/screen/screen_setup_game.cpp b/src/ui/screen/screen_setup_game.cpp index c1bce9e2..d28a5b68 100644 --- a/src/ui/screen/screen_setup_game.cpp +++ b/src/ui/screen/screen_setup_game.cpp @@ -69,6 +69,9 @@ void CScreenSetupGame::CreateInterface() pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOVIES); pc->SetState(STATE_SHADOW); pos.y -= 0.048f; + pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SCROLL); + pc->SetState(STATE_SHADOW); + pos.y -= 0.048f; pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_INVERTX); pc->SetState(STATE_SHADOW); pos.y -= 0.048f; @@ -210,6 +213,12 @@ bool CScreenSetupGame::EventProcess(const Event &event) UpdateSetupButtons(); break; + case EVENT_INTERFACE_SCROLL: + m_camera->SetOldCameraScroll(!m_camera->GetOldCameraScroll()); + ChangeSetupButtons(); + UpdateSetupButtons(); + break; + case EVENT_INTERFACE_INVERTX: m_camera->SetCameraInvertX(!m_camera->GetCameraInvertX()); ChangeSetupButtons(); @@ -313,6 +322,12 @@ void CScreenSetupGame::UpdateSetupButtons() pc->SetState(STATE_CHECK, m_settings->GetMovies()); } + pc = static_cast(pw->SearchControl(EVENT_INTERFACE_SCROLL)); + if ( pc != nullptr ) + { + pc->SetState(STATE_CHECK, m_camera->GetOldCameraScroll()); + } + pc = static_cast(pw->SearchControl(EVENT_INTERFACE_INVERTX)); if ( pc != nullptr ) { From 700f3ad448673e646f3ab2ab8bddfe536e65c206 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 19 Feb 2016 17:22:20 +0100 Subject: [PATCH 5/7] Edge camera speed fix --- src/graphics/engine/camera.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 9c1a76a6..43a68206 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -1133,6 +1133,9 @@ bool CCamera::EventMouseMove(const Event &event) if (m_mouseDeltaEdge.y < 0.0f) m_engine->SetMouseType(ENG_MOUSE_SCROLLD); } + + m_mouseDeltaEdge.x /= 2*Math::PI; + m_mouseDeltaEdge.y /= Math::PI; } m_mousePos = event.mousePos; @@ -1315,12 +1318,14 @@ bool CCamera::EventFrameEdit(const Event &event) { float factor = m_editHeight * 0.5f + 30.0f; - m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_directionH -= m_mouseDelta.x * 0.7f * 2*Math::PI; m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed); - m_mouseDelta.LoadZero(); + m_fixDirectionH += m_mouseDelta.x * 2*Math::PI; m_fixDirectionH = Math::NormAngle(m_fixDirectionH); + m_mouseDelta.LoadZero(); + m_terrain->AdjustToBounds(m_eyePt, 10.0f); if (m_terrain->AdjustToFloor(m_eyePt, false)) From 1be66b40c39b90b4cf71946089cd5ee1c6cf2b45 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 19 Feb 2016 17:24:59 +0100 Subject: [PATCH 6/7] Update translation files --- po/colobot.pot | 4 +++- po/de.po | 11 +++++++---- po/fr.po | 13 ++++++++----- po/pl.po | 11 ++++++----- po/ru.po | 9 ++++++--- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/po/colobot.pot b/po/colobot.pot index 4343aa2a..94e8ca7b 100644 --- a/po/colobot.pot +++ b/po/colobot.pot @@ -370,7 +370,9 @@ msgstr "" msgid "Film sequences\\Films before and after the missions" msgstr "" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" +msgid "" +"Camera border scrolling\\Scrolling when the mouse touches right or left " +"border" msgstr "" msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" diff --git a/po/de.po b/po/de.po index 3ae02cdf..7bcf9ff9 100644 --- a/po/de.po +++ b/po/de.po @@ -331,6 +331,13 @@ msgstr "Kamera weiter weg" msgid "Camera back\\Moves the camera backward" msgstr "Kamera weiter\\Bewegung der Kamera rückwärts" +#, fuzzy +msgid "" +"Camera border scrolling\\Scrolling when the mouse touches right or left " +"border" +msgstr "" +"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht" + msgid "Camera closer\\Moves the camera forward" msgstr "Kamera näher\\Bewegung der Kamera vorwärts" @@ -1311,10 +1318,6 @@ msgstr "Speichern\\Aktuelle Mission speichern" msgid "Save\\Saves the current mission" msgstr "Speichern\\Speichert die Mission" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Astronauten auswählen\\Astronauten auswählen" diff --git a/po/fr.po b/po/fr.po index 730e849c..e7b0219b 100644 --- a/po/fr.po +++ b/po/fr.po @@ -324,6 +324,14 @@ msgstr "Caméra plus loin" msgid "Camera back\\Moves the camera backward" msgstr "Caméra plus loin\\Recule la caméra" +#, fuzzy +msgid "" +"Camera border scrolling\\Scrolling when the mouse touches right or left " +"border" +msgstr "" +"Défilement dans les bords\\Défilement lorsque la souris touches les bords " +"gauche ou droite" + msgid "Camera closer\\Moves the camera forward" msgstr "Caméra plus proche\\Avance la caméra" @@ -1299,11 +1307,6 @@ msgstr "Enregistrer\\Enregistrer la mission en cours" msgid "Save\\Saves the current mission" msgstr "Enregistrer\\Enregistrer la mission en cours" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Défilement dans les bords\\Défilement lorsque la souris touches les bords " -"gauche ou droite" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute" diff --git a/po/pl.po b/po/pl.po index a54a297c..6da05008 100644 --- a/po/pl.po +++ b/po/pl.po @@ -334,6 +334,12 @@ msgstr "Camera awayest" msgid "Camera back\\Moves the camera backward" msgstr "Kamera dalej\\Oddala kamerę" +msgid "" +"Camera border scrolling\\Scrolling when the mouse touches right or left " +"border" +msgstr "" +"Przewijanie kamery przy krawędzi\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego krawędzi" + msgid "Camera closer\\Moves the camera forward" msgstr "Kamera bliżej\\Przybliża kamerę" @@ -1307,11 +1313,6 @@ msgstr "Zapisz\\Zapisuje bieżącą misję" msgid "Save\\Saves the current mission" msgstr "Zapisz\\Zapisuje bieżącą misję" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego " -"krawędzi" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Zaznacz astronautę\\Zaznacza astronautę" diff --git a/po/ru.po b/po/ru.po index 1febf458..176d7c3b 100644 --- a/po/ru.po +++ b/po/ru.po @@ -326,6 +326,12 @@ msgstr "Отдалить камеру" msgid "Camera back\\Moves the camera backward" msgstr "Отдалить камеру\\Перемещение камеры назад" +#, fuzzy +msgid "" +"Camera border scrolling\\Scrolling when the mouse touches right or left " +"border" +msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана" + msgid "Camera closer\\Moves the camera forward" msgstr "Приблизать камеру\\Перемещение камеры вперед" @@ -1306,9 +1312,6 @@ msgstr "Сохранить\\Сохранить текущую миссию" msgid "Save\\Saves the current mission" msgstr "Сохранить\\Сохранить текущую миссию" -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана" - msgid "Select the astronaut\\Selects the astronaut" msgstr "Выбор астронавта\\Выбор астронавта" From 3de6794835d688053bdcd3490e29e334100df361 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 19 Feb 2016 17:27:55 +0100 Subject: [PATCH 7/7] Allow both right and middle mouse button for camera movement --- src/graphics/engine/camera.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index 43a68206..a8558cef 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -1089,7 +1089,7 @@ bool CCamera::EventMouseMove(const Event &event) m_engine->SetMouseType(ENG_MOUSE_NORM); } - if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0) + if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0) { Math::Point newDelta = event.mousePos - m_mousePos; if (m_cameraInvertX) @@ -1177,9 +1177,9 @@ void CCamera::EventMouseWheel(const Event &event) void CCamera::EventMouseButton(const Event &event) { - if (event.GetData()->button == MOUSE_BUTTON_RIGHT) + if (event.GetData()->button == MOUSE_BUTTON_RIGHT || event.GetData()->button == MOUSE_BUTTON_MIDDLE) { - if (event.type == EVENT_MOUSE_BUTTON_DOWN) + if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0) { m_engine->SetMouseType(ENG_MOUSE_MOVE); }