diff --git a/po/colobot.pot b/po/colobot.pot index 0a5baefc..5bd50baa 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 b068dce0..57fa1883 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 9906d853..d86eab30 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" @@ -1300,11 +1308,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 d0d1d057..fa934d7e 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 f9eac19b..b9f12699 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 "Выбор астронавта\\Выбор астронавта" 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/common/restext.cpp b/src/common/restext.cpp index b9cd9cef..0139c1ed 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,7 +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("Scrolling\\Scrolling when the mouse touches right or left border"); + 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"); @@ -765,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 11bc3a73..2b67ef1d 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -80,7 +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", "CameraScroll", camera->GetCameraScroll()); + GetConfigFile().SetBoolProperty("Setup", "OldCameraScroll", camera->GetOldCameraScroll()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertX", camera->GetCameraInvertX()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY()); GetConfigFile().SetBoolProperty("Setup", "InterfaceEffect", camera->GetEffect()); @@ -155,8 +155,8 @@ 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", "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 6c187a22..a8558cef 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) @@ -98,11 +99,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; @@ -124,19 +120,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; - m_mouseMarging = 0.01f; - - m_motorTurn = 0.0f; m_centeringPhase = CAM_PHASE_NULL; m_centeringAngleH = 0.0f; @@ -156,7 +144,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; @@ -165,7 +153,7 @@ CCamera::CCamera() m_effect = true; m_blood = true; - m_cameraScroll = true; + m_oldCameraScroll = false; m_cameraInvertX = false; m_cameraInvertY = false; } @@ -194,14 +182,14 @@ bool CCamera::GetBlood() return m_blood; } -void CCamera::SetCameraScroll(bool scroll) +void CCamera::SetOldCameraScroll(bool scroll) { - m_cameraScroll = scroll; + m_oldCameraScroll = scroll; } -bool CCamera::GetCameraScroll() +bool CCamera::GetOldCameraScroll() { - return m_cameraScroll; + return m_oldCameraScroll; } void CCamera::SetCameraInvertX(bool invert) @@ -224,13 +212,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; @@ -262,7 +243,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 +263,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 +385,7 @@ void CCamera::SetSmooth(CameraSmooth type) m_smooth = type; } -CameraSmooth CCamera::GetSmoth() +CameraSmooth CCamera::GetSmooth() { return m_smooth; } @@ -482,7 +461,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 +869,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 +884,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; @@ -1083,6 +1059,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; @@ -1099,6 +1080,64 @@ bool CCamera::EventProcess(const Event &event) bool CCamera::EventMouseMove(const Event &event) { + 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 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 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_mouseDeltaEdge.x /= 2*Math::PI; + m_mouseDeltaEdge.y /= Math::PI; + } + m_mousePos = event.mousePos; return true; } @@ -1136,8 +1175,30 @@ void CCamera::EventMouseWheel(const Event &event) } } +void CCamera::EventMouseButton(const Event &event) +{ + if (event.GetData()->button == MOUSE_BUTTON_RIGHT || event.GetData()->button == MOUSE_BUTTON_MIDDLE) + { + if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0) + { + m_engine->SetMouseType(ENG_MOUSE_MOVE); + } + else + { + m_engine->SetMouseType(ENG_MOUSE_NORM); + } + } +} + 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); @@ -1175,69 +1236,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; @@ -1248,10 +1246,9 @@ 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); + 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); @@ -1321,17 +1318,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); + 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); - if (m_cameraScroll) - { - // Left/Right. - 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_fixDirectionH = Math::NormAngle(m_fixDirectionH); + + m_mouseDelta.LoadZero(); m_terrain->AdjustToBounds(m_eyePt, 10.0f); @@ -1384,25 +1377,11 @@ bool CCamera::EventFrameBack(const Event &event) if (m_backDist > 200.0f) m_backDist = 200.0f; } - m_motorTurn = 0.0f; - - if (m_rightDown) - { - 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); + if (m_mouseDelta.Length() > 0) AbortCentering(); // special stops framing + m_mouseDelta.LoadZero(); // Increase the special framework float centeringH = 0.0f; @@ -1535,21 +1514,19 @@ bool CCamera::EventFrameFix(const Event &event) if (m_fixDist > 200.0f) m_fixDist = 200.0f; } + m_fixDirectionH -= m_mouseDelta.x * 2*Math::PI; + if (m_mouseDelta.Length() > 0) + AbortCentering(); // special stops framing + m_mouseDelta.LoadZero(); + // Left/Right - if (m_cameraScroll) - { - m_fixDirectionH += m_mouseDirH * event.rTime * 1.0f * m_speed; - m_fixDirectionH = Math::NormAngle(m_fixDirectionH); - } 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(); @@ -1574,8 +1551,8 @@ 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; + m_directionH -= m_mouseDelta.x * 2*Math::PI; + m_mouseDelta.LoadZero(); m_terrain->AdjustToBounds(m_eyePt, 10.0f); @@ -1656,12 +1633,10 @@ bool CCamera::EventFrameVisit(const Event &event) if (m_visitDirectionV > 0.0f ) m_visitDirectionV = 0.0f; } - if (m_cameraScroll) - { - m_visitDist -= m_mouseDirV * event.rTime * 30.0f * m_speed; - 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; @@ -1751,5 +1726,4 @@ void CCamera::SetCameraSpeed(float speed) m_speed = speed; } - } diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index 16c42eeb..f00332a0 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); @@ -206,25 +204,22 @@ public: bool GetEffect(); void SetBlood(bool enable); bool GetBlood(); - void SetCameraScroll(bool scroll); - bool GetCameraScroll(); + void SetOldCameraScroll(bool scroll); + bool GetOldCameraScroll(); void SetCameraInvertX(bool invert); bool GetCameraInvertX(); 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 @@ -303,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 @@ -347,22 +337,17 @@ 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; - float m_mouseDirV; - float m_mouseMarging; - - float m_motorTurn; + //! 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; @@ -396,12 +381,11 @@ 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? bool m_cameraInvertY; - }; diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 16747f89..7c9f50a8 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -683,7 +683,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 dad7a65a..cfc2e11b 100644 --- a/src/object/old_object.cpp +++ b/src/object/old_object.cpp @@ -2051,7 +2051,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 78efdcd9..9cf9d330 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 ) { diff --git a/src/ui/screen/screen_setup_game.cpp b/src/ui/screen/screen_setup_game.cpp index 0479c2d7..d28a5b68 100644 --- a/src/ui/screen/screen_setup_game.cpp +++ b/src/ui/screen/screen_setup_game.cpp @@ -214,7 +214,7 @@ bool CScreenSetupGame::EventProcess(const Event &event) break; case EVENT_INTERFACE_SCROLL: - m_camera->SetCameraScroll(!m_camera->GetCameraScroll()); + m_camera->SetOldCameraScroll(!m_camera->GetOldCameraScroll()); ChangeSetupButtons(); UpdateSetupButtons(); break; @@ -325,7 +325,7 @@ void CScreenSetupGame::UpdateSetupButtons() pc = static_cast(pw->SearchControl(EVENT_INTERFACE_SCROLL)); if ( pc != nullptr ) { - pc->SetState(STATE_CHECK, m_camera->GetCameraScroll()); + pc->SetState(STATE_CHECK, m_camera->GetOldCameraScroll()); } pc = static_cast(pw->SearchControl(EVENT_INTERFACE_INVERTX));