diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 089cb01f07..0a02ae456b 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -75,6 +75,7 @@ CSVRender::WorldspaceWidget::WorldspaceWidget(CSMDoc::Document& document, QWidge , mShowToolTips(false) , mToolTipDelay(0) , mInConstructor(true) + , mSelectedNavigationMode(0) { setAcceptDrops(true); @@ -146,6 +147,10 @@ CSVRender::WorldspaceWidget::WorldspaceWidget(CSMDoc::Document& document, QWidge connect(new CSMPrefs::Shortcut("scene-clear-selection", this), qOverload<>(&CSMPrefs::Shortcut::activated), this, [this] { this->clearSelection(Mask_Reference); }); + CSMPrefs::Shortcut* switchPerspectiveShortcut = new CSMPrefs::Shortcut("scene-cam-cycle", this); + connect(switchPerspectiveShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this, + &WorldspaceWidget::cycleNavigationMode); + mInConstructor = false; } @@ -235,9 +240,11 @@ CSVWidget::SceneToolMode* CSVRender::WorldspaceWidget::makeNavigationSelector(CS tool), "orbit"); - connect(tool, &CSVWidget::SceneToolMode::modeChanged, this, &WorldspaceWidget::selectNavigationMode); + mCameraMode = tool; + + connect(mCameraMode, &CSVWidget::SceneToolMode::modeChanged, this, &WorldspaceWidget::selectNavigationMode); - return tool; + return mCameraMode; } CSVWidget::SceneToolToggle2* CSVRender::WorldspaceWidget::makeSceneVisibilitySelector(CSVWidget::SceneToolbar* parent) @@ -769,6 +776,26 @@ void CSVRender::WorldspaceWidget::toggleHiddenInstances() objectTag->mObject->getRootNode()->setNodeMask(firstMask); } +void CSVRender::WorldspaceWidget::cycleNavigationMode() +{ + switch (++mSelectedNavigationMode) + { + case (CameraMode::FirstPerson): + mCameraMode->setButton("1st"); + break; + case (CameraMode::Orbit): + mCameraMode->setButton("orbit"); + break; + case (CameraMode::Free): + mCameraMode->setButton("free"); + break; + default: + mCameraMode->setButton("1st"); + mSelectedNavigationMode = 0; + break; + } +} + void CSVRender::WorldspaceWidget::handleInteraction(InteractionType type, bool activate) { if (activate) diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 06470d2883..9a7df38620 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -75,6 +75,7 @@ namespace CSVRender CSMDoc::Document& mDocument; unsigned int mInteractionMask; CSVWidget::SceneToolMode* mEditMode; + CSVWidget::SceneToolMode* mCameraMode; bool mLocked; int mDragMode; bool mDragging; @@ -89,6 +90,7 @@ namespace CSVRender bool mShowToolTips; int mToolTipDelay; bool mInConstructor; + int mSelectedNavigationMode; public: enum DropType @@ -225,6 +227,13 @@ namespace CSVRender Button_Terrain = 0x8 }; + enum CameraMode + { + FirstPerson, + Orbit, + Free + }; + virtual void addVisibilitySelectorButtons(CSVWidget::SceneToolToggle2* tool); virtual void addEditModeSelectorButtons(CSVWidget::SceneToolMode* tool); @@ -240,6 +249,8 @@ namespace CSVRender bool getSpeedMode(); + void cycleNavigationMode(); + private: void dragEnterEvent(QDragEnterEvent* event) override;