From 2b674cedaad6261594418689bbd5bc1ae7bc04f7 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Sat, 16 Mar 2019 14:38:51 +0200 Subject: [PATCH] Implement view cell from r-type hint --- .../view/render/pagedworldspacewidget.cpp | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index ff69656a29..7f31373ee8 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -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 ( + *mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_References)); + int cellColumn = references.findColumnIndex(CSMWorld::Columns::ColumnId_Cell); + QVariant cell = references.data(references.getModelIndex(refCode, cellColumn)).value(); + 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);