Merge branch 'dev-right-click-camera' into dev

dev-time-step
krzys-h 2016-03-13 14:52:17 +01:00
commit cbdda57288
21 changed files with 194 additions and 238 deletions

View File

@ -370,7 +370,9 @@ msgstr ""
msgid "Film sequences\\Films before and after the missions" msgid "Film sequences\\Films before and after the missions"
msgstr "" 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 "" msgstr ""
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"

View File

@ -331,6 +331,13 @@ msgstr "Kamera weiter weg"
msgid "Camera back\\Moves the camera backward" msgid "Camera back\\Moves the camera backward"
msgstr "Kamera weiter\\Bewegung der Kamera rückwärts" 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" msgid "Camera closer\\Moves the camera forward"
msgstr "Kamera näher\\Bewegung der Kamera vorwärts" msgstr "Kamera näher\\Bewegung der Kamera vorwärts"
@ -1311,10 +1318,6 @@ msgstr "Speichern\\Aktuelle Mission speichern"
msgid "Save\\Saves the current mission" msgid "Save\\Saves the current mission"
msgstr "Speichern\\Speichert die 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" msgid "Select the astronaut\\Selects the astronaut"
msgstr "Astronauten auswählen\\Astronauten auswählen" msgstr "Astronauten auswählen\\Astronauten auswählen"

View File

@ -324,6 +324,14 @@ msgstr "Caméra plus loin"
msgid "Camera back\\Moves the camera backward" msgid "Camera back\\Moves the camera backward"
msgstr "Caméra plus loin\\Recule la caméra" 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" msgid "Camera closer\\Moves the camera forward"
msgstr "Caméra plus proche\\Avance la caméra" 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" msgid "Save\\Saves the current mission"
msgstr "Enregistrer\\Enregistrer la mission en cours" 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" msgid "Select the astronaut\\Selects the astronaut"
msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute" msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute"

View File

@ -334,6 +334,12 @@ msgstr "Camera awayest"
msgid "Camera back\\Moves the camera backward" msgid "Camera back\\Moves the camera backward"
msgstr "Kamera dalej\\Oddala kamerę" 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" msgid "Camera closer\\Moves the camera forward"
msgstr "Kamera bliżej\\Przybliża kamerę" msgstr "Kamera bliżej\\Przybliża kamerę"
@ -1307,11 +1313,6 @@ msgstr "Zapisz\\Zapisuje bieżącą misję"
msgid "Save\\Saves the current mission" msgid "Save\\Saves the current mission"
msgstr "Zapisz\\Zapisuje bieżącą misję" 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" msgid "Select the astronaut\\Selects the astronaut"
msgstr "Zaznacz astronautę\\Zaznacza astronautę" msgstr "Zaznacz astronautę\\Zaznacza astronautę"

View File

@ -326,6 +326,12 @@ msgstr "Отдалить камеру"
msgid "Camera back\\Moves the camera backward" msgid "Camera back\\Moves the camera backward"
msgstr "Отдалить камеру\\Перемещение камеры назад" msgstr "Отдалить камеру\\Перемещение камеры назад"
#, fuzzy
msgid ""
"Camera border scrolling\\Scrolling when the mouse touches right or left "
"border"
msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана"
msgid "Camera closer\\Moves the camera forward" msgid "Camera closer\\Moves the camera forward"
msgstr "Приблизать камеру\\Перемещение камеры вперед" msgstr "Приблизать камеру\\Перемещение камеры вперед"
@ -1306,9 +1312,6 @@ msgstr "Сохранить\\Сохранить текущую миссию"
msgid "Save\\Saves the current mission" msgid "Save\\Saves the current mission"
msgstr "Сохранить\\Сохранить текущую миссию" msgstr "Сохранить\\Сохранить текущую миссию"
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
msgstr "Прокрутка\\Прокрутка, когда указатель мыши касается граней экрана"
msgid "Select the astronaut\\Selects the astronaut" msgid "Select the astronaut\\Selects the astronaut"
msgstr "Выбор астронавта\\Выбор астронавта" msgstr "Выбор астронавта\\Выбор астронавта"

View File

@ -636,16 +636,6 @@ struct MouseButtonEventData : public EventData
MouseButton button = MOUSE_BUTTON_LEFT; MouseButton button = MOUSE_BUTTON_LEFT;
}; };
/**
* \enum WheelDirection
* \brief Direction of mouse wheel movement
*/
enum WheelDirection
{
WHEEL_UP,
WHEEL_DOWN
};
/** /**
* \struct MouseWheelEventData * \struct MouseWheelEventData
* \brief Additional data for mouse wheel event. * \brief Additional data for mouse wheel event.

View File

@ -20,8 +20,6 @@
#include "common/restext.h" #include "common/restext.h"
#include "common/config.h"
#include "CBot/CBot.h" #include "CBot/CBot.h"
#include "app/input.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_GLINT] = TR("Reflections on the buttons \\Shiny buttons");
stringsEvent[EVENT_INTERFACE_TOOLTIP] = TR("Help balloons\\Explain the function of the 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_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_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_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"); 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+3] == 'y' &&
src[s+4] == ' ' ) src[s+4] == ' ' )
{ {
int count; unsigned int count;
for(count = 0; src[s+5+count] != ';'; count++); for(count = 0; src[s+5+count] != ';'; count++);
CInput* input = CInput::GetInstancePointer(); CInput* input = CInput::GetInstancePointer();
InputSlot key = input->SearchKeyById(std::string(&src[s+5], count)); InputSlot key = input->SearchKeyById(std::string(&src[s+5], count));

View File

@ -80,7 +80,7 @@ void CSettings::SaveSettings()
GetConfigFile().SetBoolProperty("Setup", "Soluce4", m_soluce4); GetConfigFile().SetBoolProperty("Setup", "Soluce4", m_soluce4);
GetConfigFile().SetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().SetBoolProperty("Setup", "Movies", m_movies);
GetConfigFile().SetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); 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", "CameraInvertX", camera->GetCameraInvertX());
GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY());
GetConfigFile().SetBoolProperty("Setup", "InterfaceEffect", camera->GetEffect()); GetConfigFile().SetBoolProperty("Setup", "InterfaceEffect", camera->GetEffect());
@ -155,8 +155,8 @@ void CSettings::LoadSettings()
GetConfigFile().GetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().GetBoolProperty("Setup", "Movies", m_movies);
GetConfigFile().GetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); GetConfigFile().GetBoolProperty("Setup", "FocusLostPause", m_focusLostPause);
if (GetConfigFile().GetBoolProperty("Setup", "CameraScroll", bValue)) if (GetConfigFile().GetBoolProperty("Setup", "OldCameraScroll", bValue))
camera->SetCameraScroll(bValue); camera->SetOldCameraScroll(bValue);
if (GetConfigFile().GetBoolProperty("Setup", "CameraInvertX", bValue)) if (GetConfigFile().GetBoolProperty("Setup", "CameraInvertX", bValue))
camera->SetCameraInvertX(bValue); camera->SetCameraInvertX(bValue);

View File

@ -50,6 +50,7 @@
namespace Gfx namespace Gfx
{ {
const float MOUSE_EDGE_MARGIN = 0.01f;
//! Changes the level of transparency of an object and objects transported (battery & cargo) //! Changes the level of transparency of an object and objects transported (battery & cargo)
void SetTransparency(CObject* obj, float value) void SetTransparency(CObject* obj, float value)
@ -98,11 +99,6 @@ CCamera::CCamera()
m_normLookat = Math::Vector(0.0f, 0.0f, 0.0f); m_normLookat = Math::Vector(0.0f, 0.0f, 0.0f);
m_focus = 1.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_eyePt = Math::Vector(0.0f, 0.0f, 0.0f);
m_directionH = 0.0f; m_directionH = 0.0f;
m_directionV = 0.0f; m_directionV = 0.0f;
@ -124,19 +120,11 @@ CCamera::CCamera()
m_visitDist = 0.0f; m_visitDist = 0.0f;
m_visitTime = 0.0f; m_visitTime = 0.0f;
m_visitType = CAM_TYPE_NULL; m_visitType = CAM_TYPE_NULL;
m_visitDirectionH = 0.0f;
m_visitDirectionV = 0.0f; m_visitDirectionV = 0.0f;
m_editHeight = 40.0f; m_editHeight = 40.0f;
m_remotePan = 0.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_centeringPhase = CAM_PHASE_NULL;
m_centeringAngleH = 0.0f; m_centeringAngleH = 0.0f;
@ -156,7 +144,7 @@ CCamera::CCamera()
m_overType = CAM_OVER_EFFECT_NULL; m_overType = CAM_OVER_EFFECT_NULL;
m_overForce = 0.0f; m_overForce = 0.0f;
m_overTime = 0.0f; m_overTime = 0.0f;
m_overMode = 0.0f; m_overMode = 0;
m_overFadeIn = 0.0f; m_overFadeIn = 0.0f;
m_overFadeOut = 0.0f; m_overFadeOut = 0.0f;
@ -165,7 +153,7 @@ CCamera::CCamera()
m_effect = true; m_effect = true;
m_blood = true; m_blood = true;
m_cameraScroll = true; m_oldCameraScroll = false;
m_cameraInvertX = false; m_cameraInvertX = false;
m_cameraInvertY = false; m_cameraInvertY = false;
} }
@ -194,14 +182,14 @@ bool CCamera::GetBlood()
return m_blood; 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) void CCamera::SetCameraInvertX(bool invert)
@ -224,13 +212,6 @@ bool CCamera::GetCameraInvertY()
return m_cameraInvertY; 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) void CCamera::Init(Math::Vector eye, Math::Vector lookat, float delay)
{ {
m_initDelay = delay; m_initDelay = delay;
@ -262,7 +243,6 @@ void CCamera::Init(Math::Vector eye, Math::Vector lookat, float delay)
m_scriptLookat = m_actualLookat; m_scriptLookat = m_actualLookat;
m_focus = 1.00f; m_focus = 1.00f;
m_remotePan = 0.0f; m_remotePan = 0.0f;
m_remoteZoom = 0.0f;
FlushEffect(); FlushEffect();
FlushOver(); FlushOver();
@ -283,7 +263,6 @@ CObject* CCamera::GetControllingObject()
void CCamera::SetType(CameraType type) void CCamera::SetType(CameraType type)
{ {
m_remotePan = 0.0f; m_remotePan = 0.0f;
m_remoteZoom = 0.0f;
if ( (m_type == CAM_TYPE_BACK) && m_transparency ) if ( (m_type == CAM_TYPE_BACK) && m_transparency )
{ {
@ -406,7 +385,7 @@ void CCamera::SetSmooth(CameraSmooth type)
m_smooth = type; m_smooth = type;
} }
CameraSmooth CCamera::GetSmoth() CameraSmooth CCamera::GetSmooth()
{ {
return m_smooth; return m_smooth;
} }
@ -482,7 +461,6 @@ void CCamera::StartVisit(Math::Vector goal, float dist)
m_visitGoal = goal; m_visitGoal = goal;
m_visitDist = dist; m_visitDist = dist;
m_visitTime = 0.0f; m_visitTime = 0.0f;
m_visitDirectionH = 0.0f;
m_visitDirectionV = -Math::PI*0.10f; 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); float dist = Math::Distance(m_finalEye, m_actualEye);
if (m_smooth == CAM_SMOOTH_NONE) prog = dist; 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_NORM) prog = dist * rTime * 3.0f;
if (m_smooth == CAM_SMOOTH_HARD) prog = powf(dist, 1.0f) * rTime * 4.0f; if (m_smooth == CAM_SMOOTH_HARD) prog = dist * rTime * 4.0f;
if (m_smooth == CAM_SMOOTH_SPEC) prog = powf(dist, 1.0f) * rTime * 0.05f;
if (dist == 0.0f) if (dist == 0.0f)
{ {
m_actualEye = m_finalEye; m_actualEye = m_finalEye;
@ -907,9 +884,8 @@ void CCamera::SetViewTime(const Math::Vector &eyePt,
dist = Math::Distance(m_finalLookat, m_actualLookat); dist = Math::Distance(m_finalLookat, m_actualLookat);
if ( m_smooth == CAM_SMOOTH_NONE ) prog = dist; 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_NORM ) prog = dist * rTime * 6.0f;
if ( m_smooth == CAM_SMOOTH_HARD ) prog = powf(dist, 1.0f) * rTime * 4.0f; if ( m_smooth == CAM_SMOOTH_HARD ) prog = dist * rTime * 4.0f;
if ( m_smooth == CAM_SMOOTH_SPEC ) prog = powf(dist, 1.0f) * rTime * 4.0f;
if ( dist == 0.0f ) if ( dist == 0.0f )
{ {
m_actualLookat = m_finalLookat; m_actualLookat = m_finalLookat;
@ -1083,6 +1059,11 @@ bool CCamera::EventProcess(const Event &event)
EventFrame(event); EventFrame(event);
break; break;
case EVENT_MOUSE_BUTTON_DOWN:
case EVENT_MOUSE_BUTTON_UP:
EventMouseButton(event);
break;
case EVENT_MOUSE_MOVE: case EVENT_MOUSE_MOVE:
EventMouseMove(event); EventMouseMove(event);
break; break;
@ -1099,6 +1080,64 @@ bool CCamera::EventProcess(const Event &event)
bool CCamera::EventMouseMove(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; m_mousePos = event.mousePos;
return true; return true;
} }
@ -1136,8 +1175,30 @@ void CCamera::EventMouseWheel(const Event &event)
} }
} }
void CCamera::EventMouseButton(const Event &event)
{
if (event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_RIGHT || event.GetData<MouseButtonEventData>()->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) 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); EffectFrame(event);
OverFrame(event); OverFrame(event);
@ -1175,69 +1236,6 @@ bool CCamera::EventFrame(const Event &event)
return true; 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) bool CCamera::EventFrameFree(const Event &event)
{ {
Math::Vector cameraInput = event.cameraInput; Math::Vector cameraInput = event.cameraInput;
@ -1248,10 +1246,9 @@ bool CCamera::EventFrameFree(const Event &event)
float factor = m_heightEye * 0.5f + 30.0f; float factor = m_heightEye * 0.5f + 30.0f;
if ( m_mouseDirH != 0.0f ) m_directionH -= m_mouseDelta.x * 2*Math::PI;
m_directionH -= m_mouseDirH * event.rTime * 0.7f * m_speed; m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * m_speed);
if ( m_mouseDirV != 0.0f ) m_mouseDelta.LoadZero();
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDirV * event.rTime * factor * m_speed);
// Up/Down // Up/Down
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, cameraInput.y * event.rTime * factor * m_speed); 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; float factor = m_editHeight * 0.5f + 30.0f;
if (m_mouseDirH != 0.0f) m_directionH -= m_mouseDelta.x * 0.7f * 2*Math::PI;
m_directionH -= m_mouseDirH * event.rTime * 0.7f * m_speed; m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDelta.y * factor * 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) m_fixDirectionH += m_mouseDelta.x * 2*Math::PI;
{ m_fixDirectionH = Math::NormAngle(m_fixDirectionH);
// Left/Right.
m_fixDirectionH += m_mouseDirH * event.rTime * 1.0f * m_speed; m_mouseDelta.LoadZero();
m_fixDirectionH = Math::NormAngle(m_fixDirectionH);
}
m_terrain->AdjustToBounds(m_eyePt, 10.0f); 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; if (m_backDist > 200.0f) m_backDist = 200.0f;
} }
m_motorTurn = 0.0f; m_addDirectionH -= m_mouseDelta.x * 2*Math::PI;
m_addDirectionH = Math::NormAngle(m_addDirectionH);
if (m_rightDown) if (m_mouseDelta.Length() > 0)
{
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))
AbortCentering(); // special stops framing AbortCentering(); // special stops framing
m_mouseDelta.LoadZero();
// Increase the special framework // Increase the special framework
float centeringH = 0.0f; float centeringH = 0.0f;
@ -1535,21 +1514,19 @@ bool CCamera::EventFrameFix(const Event &event)
if (m_fixDist > 200.0f) m_fixDist = 200.0f; 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 // 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 += event.cameraInput.x * event.rTime * 0.7f * m_speed;
m_fixDirectionH = Math::NormAngle(m_fixDirectionH);
// Up/Down // Up/Down
m_fixDirectionV -= event.cameraInput.y * event.rTime * 0.7f * m_speed; 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); 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) if (m_cameraObj != nullptr)
{ {
Math::Vector lookatPt = m_cameraObj->GetPosition(); Math::Vector lookatPt = m_cameraObj->GetPosition();
@ -1574,8 +1551,8 @@ bool CCamera::EventFrameFix(const Event &event)
bool CCamera::EventFrameExplo(const Event &event) bool CCamera::EventFrameExplo(const Event &event)
{ {
if (m_mouseDirH != 0.0f) m_directionH -= m_mouseDelta.x * 2*Math::PI;
m_directionH -= m_mouseDirH * event.rTime * 0.7f * m_speed; m_mouseDelta.LoadZero();
m_terrain->AdjustToBounds(m_eyePt, 10.0f); 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_visitDirectionV > 0.0f ) m_visitDirectionV = 0.0f;
} }
if (m_cameraScroll) m_visitDist -= m_mouseDelta.y * 100.0f * m_speed;
{ m_mouseDelta.LoadZero();
m_visitDist -= m_mouseDirV * event.rTime * 30.0f * m_speed; if (m_visitDist < 20.0f) m_visitDist = 20.0f;
if (m_visitDist < 20.0f) m_visitDist = 20.0f; if (m_visitDist > 200.0f) m_visitDist = 200.0f;
if (m_visitDist > 200.0f) m_visitDist = 200.0f;
}
float angleH = (m_visitTime / 10.0f) * (Math::PI * 2.0f); float angleH = (m_visitTime / 10.0f) * (Math::PI * 2.0f);
float angleV = m_visitDirectionV; float angleV = m_visitDirectionV;
@ -1751,5 +1726,4 @@ void CCamera::SetCameraSpeed(float speed)
m_speed = speed; m_speed = speed;
} }
} }

View File

@ -77,8 +77,6 @@ enum CameraSmooth
CAM_SMOOTH_NORM = 1, CAM_SMOOTH_NORM = 1,
//! Hard //! Hard
CAM_SMOOTH_HARD = 2, CAM_SMOOTH_HARD = 2,
//! Special
CAM_SMOOTH_SPEC = 3,
}; };
enum CenteringPhase enum CenteringPhase
@ -151,7 +149,7 @@ public:
//! Management of the smoothing mode //! Management of the smoothing mode
void SetSmooth(CameraSmooth type); void SetSmooth(CameraSmooth type);
CameraSmooth GetSmoth(); CameraSmooth GetSmooth();
//! Management of the setback distance //! Management of the setback distance
void SetDist(float dist); void SetDist(float dist);
@ -206,25 +204,22 @@ public:
bool GetEffect(); bool GetEffect();
void SetBlood(bool enable); void SetBlood(bool enable);
bool GetBlood(); bool GetBlood();
void SetCameraScroll(bool scroll); void SetOldCameraScroll(bool scroll);
bool GetCameraScroll(); bool GetOldCameraScroll();
void SetCameraInvertX(bool invert); void SetCameraInvertX(bool invert);
bool GetCameraInvertX(); bool GetCameraInvertX();
void SetCameraInvertY(bool invert); void SetCameraInvertY(bool invert);
bool GetCameraInvertY(); 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); void SetCameraSpeed(float speed);
protected: protected:
//! Changes the camera according to the mouse moved //! Changes the camera according to the mouse moved
bool EventMouseMove(const Event &event); bool EventMouseMove(const Event &event);
//! Mouse wheel operation //! 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 //! Changes the camera according to the time elapsed
bool EventFrame(const Event &event); bool EventFrame(const Event &event);
//! Moves the point of view //! Moves the point of view
@ -303,11 +298,6 @@ protected:
float m_focus; float m_focus;
bool m_rightDown;
Math::Point m_rightPosInit;
Math::Point m_rightPosCenter;
Math::Point m_rightPosMove;
//! CAM_TYPE_FREE: eye //! CAM_TYPE_FREE: eye
Math::Vector m_eyePt; Math::Vector m_eyePt;
//! CAM_TYPE_FREE: horizontal direction //! CAM_TYPE_FREE: horizontal direction
@ -347,22 +337,17 @@ protected:
//! CAM_TYPE_VISIT: initial type //! CAM_TYPE_VISIT: initial type
CameraType m_visitType; CameraType m_visitType;
//! CAM_TYPE_VISIT: direction //! CAM_TYPE_VISIT: direction
float m_visitDirectionH;
//! CAM_TYPE_VISIT: direction
float m_visitDirectionV; float m_visitDirectionV;
//! CAM_TYPE_EDIT: height //! CAM_TYPE_EDIT: height
float m_editHeight; float m_editHeight;
float m_remotePan; float m_remotePan;
float m_remoteZoom;
Math::Point m_mousePos; //! Last known mouse position, used to calculate change since last frame
float m_mouseDirH; Math::Point m_mousePos = Math::Point(0.5f, 0.5f);
float m_mouseDirV; Math::Point m_mouseDelta = Math::Point(0.0f, 0.0f);
float m_mouseMarging; Math::Point m_mouseDeltaEdge = Math::Point(0.0f, 0.0f);
float m_motorTurn;
CenteringPhase m_centeringPhase; CenteringPhase m_centeringPhase;
float m_centeringAngleH; float m_centeringAngleH;
@ -396,12 +381,11 @@ protected:
//! Blood? //! Blood?
bool m_blood; bool m_blood;
//! Scroll in the edges? //! Scroll in the edges?
bool m_cameraScroll; bool m_oldCameraScroll;
//! X inversion in the edges? //! X inversion in the edges?
bool m_cameraInvertX; bool m_cameraInvertX;
//! Y inversion in the edges? //! Y inversion in the edges?
bool m_cameraInvertY; bool m_cameraInvertY;
}; };

View File

@ -683,7 +683,6 @@ bool CRobotMain::ProcessEvent(Event &event)
m_displayText->EventProcess(event); m_displayText->EventProcess(event);
RemoteCamera(m_cameraPan, m_cameraZoom, event.rTime); RemoteCamera(m_cameraPan, m_cameraZoom, event.rTime);
m_interface->EventProcess(event);
if (m_displayInfo != nullptr) // current edition? if (m_displayInfo != nullptr) // current edition?
m_displayInfo->EventProcess(event); m_displayInfo->EventProcess(event);

View File

@ -2051,7 +2051,6 @@ bool COldObject::EventProcess(const Event &event)
axeZ = -1.0f; // tomb 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;
if ( axeX < -1.0f ) axeX = -1.0f; if ( axeX < -1.0f ) axeX = -1.0f;

View File

@ -314,7 +314,7 @@ bool CControl::EventProcess(const Event &event)
GlintFrame(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; m_glintMouse = event.mousePos;

View File

@ -266,7 +266,7 @@ bool CEdit::EventProcess(const Event &event)
m_timeBlink += event.rTime; 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) && if ( Detect(event.mousePos) &&
event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )

View File

@ -54,7 +54,6 @@ CInterface::CInterface()
{ {
m_event = CApplication::GetInstancePointer()->GetEventQueue(); m_event = CApplication::GetInstancePointer()->GetEventQueue();
m_engine = Gfx::CEngine::GetInstancePointer(); m_engine = Gfx::CEngine::GetInstancePointer();
m_camera = nullptr;
} }
// Object's destructor. // Object's destructor.
@ -300,12 +299,9 @@ CControl* CInterface::SearchControl(EventType eventMsg)
bool CInterface::EventProcess(const Event &event) 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_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
m_camera = CRobotMain::GetInstancePointer()->GetCamera();
m_engine->SetMouseType(m_camera->GetMouseDef(event.mousePos));
} }
for (auto& control : boost::adaptors::reverse(m_controls)) for (auto& control : boost::adaptors::reverse(m_controls))

View File

@ -29,7 +29,6 @@
namespace Gfx namespace Gfx
{ {
class CCamera;
class CEngine; class CEngine;
} // namespace Gfx } // namespace Gfx
@ -101,7 +100,6 @@ protected:
CEventQueue* m_event; CEventQueue* m_event;
Gfx::CEngine* m_engine; Gfx::CEngine* m_engine;
Gfx::CCamera* m_camera;
std::array<std::unique_ptr<CControl>, MAXCONTROL> m_controls; std::array<std::unique_ptr<CControl>, MAXCONTROL> m_controls;
}; };

View File

@ -293,15 +293,18 @@ bool CList::EventProcess(const Event &event)
CControl::EventProcess(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); if (Detect(event.mousePos))
for (int i = 0; i < m_displayLine; i++)
{ {
if (i + m_firstLine >= m_totalLine) m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
break; for (int i = 0; i < m_displayLine; i++)
if (m_buttons[i] != nullptr) {
m_buttons[i]->EventProcess(event); if (i + m_firstLine >= m_totalLine)
break;
if (m_buttons[i] != nullptr)
m_buttons[i]->EventProcess(event);
}
} }
} }

View File

@ -203,12 +203,15 @@ bool CMap::EventProcess(const Event &event)
if ( event.type == EVENT_FRAME ) if ( event.type == EVENT_FRAME )
m_time += event.rTime; 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); if (Detect(event.mousePos))
bool inMap = false; {
if (DetectObject(event.mousePos, inMap) != nullptr) m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); bool inMap = false;
if (DetectObject(event.mousePos, inMap) != nullptr)
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
}
} }
if (event.type == EVENT_MOUSE_BUTTON_DOWN && if (event.type == EVENT_MOUSE_BUTTON_DOWN &&

View File

@ -64,7 +64,7 @@ bool CTarget::EventProcess(const Event &event)
CControl::EventProcess(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); m_main->SetFriendAim(false);

View File

@ -662,7 +662,7 @@ int CWindow::BorderDetect(Math::Point pos)
bool CWindow::EventProcess(const Event &event) 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 ) if ( m_bCapture )
{ {

View File

@ -214,7 +214,7 @@ bool CScreenSetupGame::EventProcess(const Event &event)
break; break;
case EVENT_INTERFACE_SCROLL: case EVENT_INTERFACE_SCROLL:
m_camera->SetCameraScroll(!m_camera->GetCameraScroll()); m_camera->SetOldCameraScroll(!m_camera->GetOldCameraScroll());
ChangeSetupButtons(); ChangeSetupButtons();
UpdateSetupButtons(); UpdateSetupButtons();
break; break;
@ -325,7 +325,7 @@ void CScreenSetupGame::UpdateSetupButtons()
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SCROLL)); pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SCROLL));
if ( pc != nullptr ) if ( pc != nullptr )
{ {
pc->SetState(STATE_CHECK, m_camera->GetCameraScroll()); pc->SetState(STATE_CHECK, m_camera->GetOldCameraScroll());
} }
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTX)); pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTX));