diff --git a/radiant/camera/CamWnd.cpp b/radiant/camera/CamWnd.cpp index 554026eb86..738fb9e788 100644 --- a/radiant/camera/CamWnd.cpp +++ b/radiant/camera/CamWnd.cpp @@ -151,30 +151,29 @@ CamWnd::CamWnd(wxWindow* parent) : _timer(this), _timerLock(false) { - Connect(wxEVT_TIMER, wxTimerEventHandler(CamWnd::onFrame), NULL, this); + Bind(wxEVT_TIMER, &CamWnd::onFrame, this); constructGUIComponents(); // Deactivate all commands, just to make sure disableDiscreteMoveEvents(); - disableFreeMoveEvents(); // Connect the mouse button events - _wxGLWidget->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(CamWnd::onGLMouseButtonRelease), NULL, this); - _wxGLWidget->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(CamWnd::onGLMouseButtonRelease), NULL, this); - _wxGLWidget->Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(CamWnd::onGLMouseButtonRelease), NULL, this); - _wxGLWidget->Connect(wxEVT_AUX1_DOWN, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_AUX1_DCLICK, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_AUX1_UP, wxMouseEventHandler(CamWnd::onGLMouseButtonRelease), NULL, this); - _wxGLWidget->Connect(wxEVT_AUX2_DOWN, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_AUX2_DCLICK, wxMouseEventHandler(CamWnd::onGLMouseButtonPress), NULL, this); - _wxGLWidget->Connect(wxEVT_AUX2_UP, wxMouseEventHandler(CamWnd::onGLMouseButtonRelease), NULL, this); + _wxGLWidget->Bind(wxEVT_LEFT_DOWN, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_LEFT_DCLICK, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_LEFT_UP, &CamWnd::onGLMouseButtonRelease, this); + _wxGLWidget->Bind(wxEVT_RIGHT_DOWN, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_RIGHT_DCLICK, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_RIGHT_UP, &CamWnd::onGLMouseButtonRelease, this); + _wxGLWidget->Bind(wxEVT_MIDDLE_DOWN, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_MIDDLE_DCLICK, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_MIDDLE_UP, &CamWnd::onGLMouseButtonRelease, this); + _wxGLWidget->Bind(wxEVT_AUX1_DOWN, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_AUX1_DCLICK, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_AUX1_UP, &CamWnd::onGLMouseButtonRelease, this); + _wxGLWidget->Bind(wxEVT_AUX2_DOWN, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_AUX2_DCLICK, &CamWnd::onGLMouseButtonPress, this); + _wxGLWidget->Bind(wxEVT_AUX2_UP, &CamWnd::onGLMouseButtonRelease, this); // Now add the handlers for the non-freelook mode, the events are activated by this addHandlersMove(); @@ -528,8 +527,6 @@ void CamWnd::enableFreeMove() removeHandlersMove(); - enableFreeMoveEvents(); - update(); } @@ -539,8 +536,6 @@ void CamWnd::disableFreeMove() _camera.freeMoveEnabled = false; _camera.clearMovementFlags(MOVE_ALL); - disableFreeMoveEvents(); - addHandlersMove(); update(); @@ -829,63 +824,25 @@ void CamWnd::onSceneGraphChange() // ---------------------------------------------------------- -void CamWnd::enableFreeMoveEvents() -{ -#if 0 - GlobalEventManager().enableEvent("CameraFreeMoveForward"); - GlobalEventManager().enableEvent("CameraFreeMoveBack"); - GlobalEventManager().enableEvent("CameraFreeMoveLeft"); - GlobalEventManager().enableEvent("CameraFreeMoveRight"); - GlobalEventManager().enableEvent("CameraFreeMoveUp"); - GlobalEventManager().enableEvent("CameraFreeMoveDown"); -#endif -} - -void CamWnd::disableFreeMoveEvents() -{ -#if 0 - GlobalEventManager().disableEvent("CameraFreeMoveForward"); - GlobalEventManager().disableEvent("CameraFreeMoveBack"); - GlobalEventManager().disableEvent("CameraFreeMoveLeft"); - GlobalEventManager().disableEvent("CameraFreeMoveRight"); - GlobalEventManager().disableEvent("CameraFreeMoveUp"); - GlobalEventManager().disableEvent("CameraFreeMoveDown"); -#endif -} - void CamWnd::enableDiscreteMoveEvents() { -#if 0 - GlobalEventManager().enableEvent("CameraBack"); - GlobalEventManager().enableEvent("CameraLeft"); - GlobalEventManager().enableEvent("CameraRight"); -#endif GlobalEventManager().enableEvent("CameraStrafeRight"); GlobalEventManager().enableEvent("CameraStrafeLeft"); - GlobalEventManager().enableEvent("CameraUp"); - GlobalEventManager().enableEvent("CameraDown"); GlobalEventManager().enableEvent("CameraAngleUp"); GlobalEventManager().enableEvent("CameraAngleDown"); } void CamWnd::disableDiscreteMoveEvents() { -#if 0 - GlobalEventManager().disableEvent("CameraBack"); - GlobalEventManager().disableEvent("CameraLeft"); - GlobalEventManager().disableEvent("CameraRight"); -#endif GlobalEventManager().disableEvent("CameraStrafeRight"); GlobalEventManager().disableEvent("CameraStrafeLeft"); - GlobalEventManager().disableEvent("CameraUp"); - GlobalEventManager().disableEvent("CameraDown"); GlobalEventManager().disableEvent("CameraAngleUp"); GlobalEventManager().disableEvent("CameraAngleDown"); } void CamWnd::addHandlersMove() { - _wxGLWidget->Connect(wxEVT_MOTION, wxMouseEventHandler(CamWnd::onGLMouseMove), NULL, this); + _wxGLWidget->Bind(wxEVT_MOTION, &CamWnd::onGLMouseMove, this); // Enable either the free-look movement commands or the discrete ones, // depending on the selection @@ -893,25 +850,17 @@ void CamWnd::addHandlersMove() { enableDiscreteMoveEvents(); } - else - { - enableFreeMoveEvents(); - } } void CamWnd::removeHandlersMove() { - _wxGLWidget->Disconnect(wxEVT_MOTION, wxMouseEventHandler(CamWnd::onGLMouseMove), NULL, this); + _wxGLWidget->Unbind(wxEVT_MOTION, &CamWnd::onGLMouseMove, this); // Disable either the free-look movement commands or the discrete ones, depending on the selection if (getCameraSettings()->discreteMovement()) { disableDiscreteMoveEvents(); } - else - { - disableFreeMoveEvents(); - } } void CamWnd::update() diff --git a/radiant/camera/CamWnd.h b/radiant/camera/CamWnd.h index 2fe98be7ff..a0f8d99602 100644 --- a/radiant/camera/CamWnd.h +++ b/radiant/camera/CamWnd.h @@ -138,9 +138,7 @@ class CamWnd : void removeHandlersMove(); void enableDiscreteMoveEvents(); - void enableFreeMoveEvents(); void disableDiscreteMoveEvents(); - void disableFreeMoveEvents(); // Increases/decreases the far clip plane distance void farClipPlaneIn(); diff --git a/radiant/camera/GlobalCamera.cpp b/radiant/camera/GlobalCamera.cpp index f0ef091b0a..3b94d80d6a 100644 --- a/radiant/camera/GlobalCamera.cpp +++ b/radiant/camera/GlobalCamera.cpp @@ -60,15 +60,9 @@ void GlobalCameraManager::registerCommands() { cmd::ARGTYPE_STRING, cmd::ARGTYPE_DOUBLE }); // Insert movement commands - //GlobalCommandSystem().addCommand("CameraForward", std::bind(&GlobalCameraManager::moveForwardDiscrete, this, std::placeholders::_1)); - //GlobalCommandSystem().addCommand("CameraBack", std::bind(&GlobalCameraManager::moveBackDiscrete, this, std::placeholders::_1)); - //GlobalCommandSystem().addCommand("CameraLeft", std::bind(&GlobalCameraManager::rotateLeftDiscrete, this, std::placeholders::_1)); - //GlobalCommandSystem().addCommand("CameraRight", std::bind(&GlobalCameraManager::rotateRightDiscrete, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("CameraStrafeRight", std::bind(&GlobalCameraManager::moveRightDiscrete, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("CameraStrafeLeft", std::bind(&GlobalCameraManager::moveLeftDiscrete, this, std::placeholders::_1)); - //GlobalCommandSystem().addCommand("CameraUp", std::bind(&GlobalCameraManager::moveUpDiscrete, this, std::placeholders::_1)); - //GlobalCommandSystem().addCommand("CameraDown", std::bind(&GlobalCameraManager::moveDownDiscrete, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("CameraAngleUp", std::bind(&GlobalCameraManager::pitchUpDiscrete, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("CameraAngleDown", std::bind(&GlobalCameraManager::pitchDownDiscrete, this, std::placeholders::_1)); @@ -469,7 +463,7 @@ void GlobalCameraManager::onFreelookMoveDownKey(ui::KeyEventType eventType) auto camWnd = getActiveCamWnd(); if (!camWnd) return; - camWnd->getCamera().onUpKey(eventType); + camWnd->getCamera().onDownKey(eventType); #if 0 if (eventType == ui::KeyPressed) { @@ -482,34 +476,6 @@ void GlobalCameraManager::onFreelookMoveDownKey(ui::KeyEventType eventType) #endif } -void GlobalCameraManager::moveForwardDiscrete(const cmd::ArgumentList& args) { - CamWndPtr camWnd = getActiveCamWnd(); - if (camWnd == NULL) return; - - camWnd->getCamera().moveForwardDiscrete(SPEED_MOVE); -} - -void GlobalCameraManager::moveBackDiscrete(const cmd::ArgumentList& args) { - CamWndPtr camWnd = getActiveCamWnd(); - if (camWnd == NULL) return; - - camWnd->getCamera().moveBackDiscrete(SPEED_MOVE); -} - -void GlobalCameraManager::moveUpDiscrete(const cmd::ArgumentList& args) { - CamWndPtr camWnd = getActiveCamWnd(); - if (camWnd == NULL) return; - - camWnd->getCamera().moveUpDiscrete(SPEED_MOVE); -} - -void GlobalCameraManager::moveDownDiscrete(const cmd::ArgumentList& args) { - CamWndPtr camWnd = getActiveCamWnd(); - if (camWnd == NULL) return; - - camWnd->getCamera().moveDownDiscrete(SPEED_MOVE); -} - void GlobalCameraManager::moveLeftDiscrete(const cmd::ArgumentList& args) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd == NULL) return; @@ -524,20 +490,6 @@ void GlobalCameraManager::moveRightDiscrete(const cmd::ArgumentList& args) { camWnd->getCamera().moveRightDiscrete(SPEED_MOVE); } -void GlobalCameraManager::rotateLeftDiscrete(const cmd::ArgumentList& args) { - CamWndPtr camWnd = getActiveCamWnd(); - if (camWnd == NULL) return; - - camWnd->getCamera().rotateLeftDiscrete(); -} - -void GlobalCameraManager::rotateRightDiscrete(const cmd::ArgumentList& args) { - CamWndPtr camWnd = getActiveCamWnd(); - if (camWnd == NULL) return; - - camWnd->getCamera().rotateRightDiscrete(); -} - void GlobalCameraManager::pitchUpDiscrete(const cmd::ArgumentList& args) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd == NULL) return; diff --git a/radiant/camera/GlobalCamera.h b/radiant/camera/GlobalCamera.h index 89e40b8bbd..c4b670c00a 100644 --- a/radiant/camera/GlobalCamera.h +++ b/radiant/camera/GlobalCamera.h @@ -103,14 +103,8 @@ class GlobalCameraManager : // Movement commands (the calls are passed on to the Camera class) void moveCameraCmd(const cmd::ArgumentList& args); - void moveForwardDiscrete(const cmd::ArgumentList& args); - void moveBackDiscrete(const cmd::ArgumentList& args); - void moveUpDiscrete(const cmd::ArgumentList& args); - void moveDownDiscrete(const cmd::ArgumentList& args); void moveLeftDiscrete(const cmd::ArgumentList& args); void moveRightDiscrete(const cmd::ArgumentList& args); - void rotateLeftDiscrete(const cmd::ArgumentList& args); - void rotateRightDiscrete(const cmd::ArgumentList& args); void pitchUpDiscrete(const cmd::ArgumentList& args); void pitchDownDiscrete(const cmd::ArgumentList& args);