mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 18:19:40 +00:00
Add context menu for orbit camera.
This commit is contained in:
parent
4ef9981544
commit
6c471349f0
5 changed files with 100 additions and 9 deletions
|
@ -86,6 +86,7 @@ opencs_units (view/widget
|
||||||
opencs_units (view/render
|
opencs_units (view/render
|
||||||
scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget
|
scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget
|
||||||
previewwidget editmode instancemode instanceselectionmode instancemovemode
|
previewwidget editmode instancemode instanceselectionmode instancemovemode
|
||||||
|
orbitcameramode
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/render
|
opencs_units_noqt (view/render
|
||||||
|
|
37
apps/opencs/view/render/orbitcameramode.cpp
Normal file
37
apps/opencs/view/render/orbitcameramode.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#include "orbitcameramode.hpp"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
OrbitCameraMode::OrbitCameraMode(WorldspaceWidget* worldspaceWidget, const QIcon& icon, const QString& tooltip,
|
||||||
|
QWidget* parent)
|
||||||
|
: ModeButton(icon, tooltip, parent)
|
||||||
|
, mWorldspaceWidget(worldspaceWidget)
|
||||||
|
, mCenterOnSelection(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OrbitCameraMode::activate(CSVWidget::SceneToolbar* toolbar)
|
||||||
|
{
|
||||||
|
mCenterOnSelection = new QAction("Center on selected object", this);
|
||||||
|
connect(mCenterOnSelection, SIGNAL(triggered()), this, SLOT(centerSelection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OrbitCameraMode::createContextMenu(QMenu* menu)
|
||||||
|
{
|
||||||
|
if (menu)
|
||||||
|
{
|
||||||
|
menu->addAction(mCenterOnSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OrbitCameraMode::centerSelection()
|
||||||
|
{
|
||||||
|
mWorldspaceWidget->centerOrbitCameraOnSelection();
|
||||||
|
}
|
||||||
|
}
|
33
apps/opencs/view/render/orbitcameramode.hpp
Normal file
33
apps/opencs/view/render/orbitcameramode.hpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef CSV_RENDER_ORBITCAMERAPICKMODE_H
|
||||||
|
#define CSV_RENDER_ORBITCAMERAPICKMODE_H
|
||||||
|
|
||||||
|
#include "../widget/modebutton.hpp"
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class WorldspaceWidget;
|
||||||
|
|
||||||
|
class OrbitCameraMode : public CSVWidget::ModeButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
OrbitCameraMode(WorldspaceWidget* worldspaceWidget, const QIcon& icon, const QString& tooltip = "",
|
||||||
|
QWidget* parent = 0);
|
||||||
|
|
||||||
|
virtual void activate(CSVWidget::SceneToolbar* toolbar);
|
||||||
|
virtual bool createContextMenu(QMenu* menu);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
WorldspaceWidget* mWorldspaceWidget;
|
||||||
|
QAction* mCenterOnSelection;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void centerSelection();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "../../model/prefs/state.hpp"
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
|
#include "../render/orbitcameramode.hpp"
|
||||||
|
|
||||||
#include "../widget/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
#include "../widget/scenetooltoggle2.hpp"
|
#include "../widget/scenetooltoggle2.hpp"
|
||||||
#include "../widget/scenetoolrun.hpp"
|
#include "../widget/scenetoolrun.hpp"
|
||||||
|
@ -27,6 +29,7 @@
|
||||||
#include "mask.hpp"
|
#include "mask.hpp"
|
||||||
#include "editmode.hpp"
|
#include "editmode.hpp"
|
||||||
#include "instancemode.hpp"
|
#include "instancemode.hpp"
|
||||||
|
#include "cameracontroller.hpp"
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
||||||
: SceneWidget (document.getData().getResourceSystem(), parent, 0, false), mSceneElements(0), mRun(0), mDocument(document),
|
: SceneWidget (document.getData().getResourceSystem(), parent, 0, false), mSceneElements(0), mRun(0), mDocument(document),
|
||||||
|
@ -99,6 +102,19 @@ void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
|
||||||
selectNavigationMode("1st");
|
selectNavigationMode("1st");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::WorldspaceWidget::centerOrbitCameraOnSelection()
|
||||||
|
{
|
||||||
|
std::vector<osg::ref_ptr<TagBase> > selection = getSelection(~0);
|
||||||
|
|
||||||
|
for (std::vector<osg::ref_ptr<TagBase> >::iterator it = selection.begin(); it!=selection.end(); ++it)
|
||||||
|
{
|
||||||
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag*> (it->get()))
|
||||||
|
{
|
||||||
|
mOrbitCamControl->setCenter(objectTag->mObject->getPosition().asVec3());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
CSVWidget::SceneToolbar *parent)
|
CSVWidget::SceneToolbar *parent)
|
||||||
{
|
{
|
||||||
|
@ -123,15 +139,17 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
"<li>Roll camera with Q and E keys</li>"
|
"<li>Roll camera with Q and E keys</li>"
|
||||||
"<li>Hold shift to speed up movement</li>"
|
"<li>Hold shift to speed up movement</li>"
|
||||||
"</ul>");
|
"</ul>");
|
||||||
tool->addButton (":scenetoolbar/orbiting-camera", "orbit",
|
tool->addButton(
|
||||||
"Orbiting Camera"
|
new CSVRender::OrbitCameraMode(this, QIcon(":scenetoolbar/orbiting-camera"),
|
||||||
"<ul><li>Always facing the centre point</li>"
|
"Orbiting Camera"
|
||||||
"<li>Rotate around the centre point via WASD or by moving the mouse while holding the left button</li>"
|
"<ul><li>Always facing the centre point</li>"
|
||||||
"<li>Mouse wheel moves camera away or towards centre point but can not pass through it</li>"
|
"<li>Rotate around the centre point via WASD or by moving the mouse while holding the left button</li>"
|
||||||
"<li>Roll camera with Q and E keys</li>"
|
"<li>Mouse wheel moves camera away or towards centre point but can not pass through it</li>"
|
||||||
"<li>Strafing (also vertically) by holding the left mouse button and control (includes relocation of the centre point)</li>"
|
"<li>Roll camera with Q and E keys</li>"
|
||||||
"<li>Hold shift to speed up movement</li>"
|
"<li>Strafing (also vertically) by holding the left mouse button and control (includes relocation of the centre point)</li>"
|
||||||
"</ul>");
|
"<li>Hold shift to speed up movement</li>"
|
||||||
|
"</ul>", tool),
|
||||||
|
"orbit");
|
||||||
|
|
||||||
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
||||||
this, SLOT (selectNavigationMode (const std::string&)));
|
this, SLOT (selectNavigationMode (const std::string&)));
|
||||||
|
|
|
@ -97,6 +97,8 @@ namespace CSVRender
|
||||||
|
|
||||||
void selectDefaultNavigationMode();
|
void selectDefaultNavigationMode();
|
||||||
|
|
||||||
|
void centerOrbitCameraOnSelection();
|
||||||
|
|
||||||
static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
|
static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
|
||||||
|
|
||||||
virtual dropRequirments getDropRequirements(DropType type) const;
|
virtual dropRequirments getDropRequirements(DropType type) const;
|
||||||
|
|
Loading…
Reference in a new issue