Skip to content

Commit

Permalink
Merge pull request #2256 from unelsson/instance_viewcell
Browse files Browse the repository at this point in the history
Editor: Implement exterior cell view from Instances table
  • Loading branch information
psi29a committed Mar 16, 2019
2 parents adb96bf + 2b674ce commit 433893e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion apps/opencs/view/render/pagedworldspacewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <memory>
#include <sstream>
#include <string>

#include <QMouseEvent>
#include <QApplication>
Expand Down Expand Up @@ -615,7 +616,39 @@ void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
}
else if (hint[0]=='r')
{
/// \todo implement 'r' type hints
// syntax r:ref#number (e.g. r:ref#100)
char ignore;

std::istringstream stream (hint.c_str());
if (stream >> ignore) // ignore r
{
char ignore1; // : or ;

std::string refCode; // ref#number (e.g. ref#100)

while (stream >> ignore1 >> refCode) {}

//Find out cell coordinate
CSMWorld::IdTable& references = dynamic_cast<CSMWorld::IdTable&> (
*mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_References));
int cellColumn = references.findColumnIndex(CSMWorld::Columns::ColumnId_Cell);
QVariant cell = references.data(references.getModelIndex(refCode, cellColumn)).value<QVariant>();
QString cellqs = cell.toString();
std::istringstream streamCellCoord (cellqs.toStdString().c_str());

if (streamCellCoord >> ignore) //ignore #
{
// Current coordinate
int x, y;

// Loop through all the coordinates to add them to selection
while (streamCellCoord >> x >> y)
selection.add (CSMWorld::CellCoordinates (x, y));

// Mark that camera needs setup
mCamPositionSet=false;
}
}
}

setCellSelection (selection);
Expand Down

0 comments on commit 433893e

Please sign in to comment.