diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 0b0f9d700..1813bf4db 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -222,7 +222,7 @@ void CSMPrefs::State::declare() declareShortcut ("document-file-newaddon", "Create new addon", QKeySequence()); declareShortcut ("document-file-open", "Open", QKeySequence()); declareShortcut ("document-file-save", "Save", QKeySequence(Qt::ControlModifier | Qt::Key_S)); - declareShortcut ("document-file-verify", "Verify", QKeySequence(Qt::ControlModifier | Qt::Key_V)); + declareShortcut ("document-file-verify", "Verify", QKeySequence()); declareShortcut ("document-file-merge", "Merge", QKeySequence()); declareShortcut ("document-file-errorlog", "Load error log", QKeySequence()); declareShortcut ("document-file-metadata", "Meta Data", QKeySequence()); @@ -320,6 +320,11 @@ void CSMPrefs::State::declare() declareShortcut ("scene-select-primary", "Primary select", QKeySequence(Qt::MiddleButton)); declareShortcut ("scene-select-secondary", "Secondary select", QKeySequence(Qt::ControlModifier | (int)Qt::MiddleButton)); + declareShortcut ("scene-load-cam-cell", "Load camera cell", QKeySequence(Qt::KeypadModifier | Qt::Key_5)); + declareShortcut ("scene-load-cam-eastcell", "Load east cell", QKeySequence(Qt::KeypadModifier | Qt::Key_6)); + declareShortcut ("scene-load-cam-northcell", "Load north cell", QKeySequence(Qt::KeypadModifier | Qt::Key_8)); + declareShortcut ("scene-load-cam-westcell", "Load west cell", QKeySequence(Qt::KeypadModifier | Qt::Key_4)); + declareShortcut ("scene-load-cam-southcell", "Load south cell", QKeySequence(Qt::KeypadModifier | Qt::Key_2)); declareShortcut ("scene-edit-abort", "Abort", QKeySequence(Qt::Key_Escape)); declareShortcut ("scene-focus-toolbar", "Toggle toolbar focus", QKeySequence(Qt::Key_T)); declareShortcut ("scene-render-stats", "Debug rendering stats", QKeySequence(Qt::Key_F3)); diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 397b86f0d..786beb530 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -8,6 +8,8 @@ #include +#include "../../model/prefs/shortcut.hpp" + #include "../../model/world/tablemimedata.hpp" #include "../../model/world/idtable.hpp" @@ -433,6 +435,24 @@ void CSVRender::PagedWorldspaceWidget::moveCellSelection (int x, int y) mSelection = newSelection; } +void CSVRender::PagedWorldspaceWidget::addCellToSceneFromCamera (int offsetX, int offsetY) +{ + const int CellSize = 8192; + + osg::Vec3f eye, center, up; + getCamera()->getViewMatrixAsLookAt(eye, center, up); + + int cellX = (int)std::floor(center.x() / CellSize) + offsetX; + int cellY = (int)std::floor(center.y() / CellSize) + offsetY; + + CSMWorld::CellCoordinates cellCoordinates(cellX, cellY); + + if (mCells.find(cellCoordinates) == mCells.end()) + { + addCellToScene(cellCoordinates); + } +} + CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document) : WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default"), mControlElements(NULL), mDisplayCellCoord(true) @@ -446,6 +466,22 @@ CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc this, SLOT (cellRemoved (const QModelIndex&, int, int))); connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (cellAdded (const QModelIndex&, int, int))); + + // Shortcuts + CSMPrefs::Shortcut* loadCameraCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-cell", this); + connect(loadCameraCellShortcut, SIGNAL(activated()), this, SLOT(loadCameraCell())); + + CSMPrefs::Shortcut* loadCameraEastCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-eastcell", this); + connect(loadCameraEastCellShortcut, SIGNAL(activated()), this, SLOT(loadEastCell())); + + CSMPrefs::Shortcut* loadCameraNorthCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-northcell", this); + connect(loadCameraNorthCellShortcut, SIGNAL(activated()), this, SLOT(loadNorthCell())); + + CSMPrefs::Shortcut* loadCameraWestCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-westcell", this); + connect(loadCameraWestCellShortcut, SIGNAL(activated()), this, SLOT(loadWestCell())); + + CSMPrefs::Shortcut* loadCameraSouthCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-southcell", this); + connect(loadCameraSouthCellShortcut, SIGNAL(activated()), this, SLOT(loadSouthCell())); } CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget() @@ -718,3 +754,28 @@ void CSVRender::PagedWorldspaceWidget::cellAdded (const QModelIndex& index, int if (adjustCells()) flagAsModified(); } + +void CSVRender::PagedWorldspaceWidget::loadCameraCell() +{ + addCellToSceneFromCamera(0, 0); +} + +void CSVRender::PagedWorldspaceWidget::loadEastCell() +{ + addCellToSceneFromCamera(1, 0); +} + +void CSVRender::PagedWorldspaceWidget::loadNorthCell() +{ + addCellToSceneFromCamera(0, 1); +} + +void CSVRender::PagedWorldspaceWidget::loadWestCell() +{ + addCellToSceneFromCamera(-1, 0); +} + +void CSVRender::PagedWorldspaceWidget::loadSouthCell() +{ + addCellToSceneFromCamera(0, -1); +} diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index 462580d49..b963c6144 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -74,6 +74,8 @@ namespace CSVRender /// \note Does not update the view or any cell marker void moveCellSelection (int x, int y); + void addCellToSceneFromCamera (int offsetX, int offsetY); + public: PagedWorldspaceWidget (QWidget *parent, CSMDoc::Document& document); @@ -152,6 +154,16 @@ namespace CSVRender virtual void cellAdded (const QModelIndex& index, int start, int end); + void loadCameraCell(); + + void loadEastCell(); + + void loadNorthCell(); + + void loadWestCell(); + + void loadSouthCell(); + }; }