1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 12:39:55 +00:00

some cleanup of the scene view drop code

This commit is contained in:
Marc Zinnschlag 2014-09-11 11:27:56 +02:00
parent 3f24593dba
commit 5a9376450b
6 changed files with 28 additions and 57 deletions

View File

@ -240,14 +240,14 @@ void CSVRender::PagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::
} }
} }
CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
{ {
switch (type) switch (type)
{ {
case cellsExterior: case Type_CellsExterior:
return canHandle; return canHandle;
case cellsInterior: case Type_CellsInterior:
return needUnpaged; return needUnpaged;
default: default:

View File

@ -59,7 +59,7 @@ namespace CSVRender
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data); virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
virtual dropRequirments getDropRequirements(dropType type) const; virtual dropRequirments getDropRequirements(DropType type) const;
/// \attention The created tool is not added to the toolbar (via addTool). Doing /// \attention The created tool is not added to the toolbar (via addTool). Doing
/// that is the responsibility of the calling function. /// that is the responsibility of the calling function.

View File

@ -166,14 +166,14 @@ std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction()
return stream.str(); return stream.str();
} }
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
{ {
switch(type) switch(type)
{ {
case cellsInterior: case Type_CellsInterior:
return canHandle; return canHandle;
case cellsExterior: case Type_CellsExterior:
return needPaged; return needPaged;
default: default:

View File

@ -41,7 +41,7 @@ namespace CSVRender
UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,
QWidget *parent); QWidget *parent);
virtual dropRequirments getDropRequirements(dropType type) const; virtual dropRequirments getDropRequirements(DropType type) const;
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data); virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);

View File

@ -162,54 +162,26 @@ CSVWidget::SceneToolRun *CSVRender::WorldspaceWidget::makeRunTool (
return mRun; return mRun;
} }
CSVRender::WorldspaceWidget::dropType CSVRender::WorldspaceWidget::getDropType ( CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType (
const std::vector< CSMWorld::UniversalId >& data) const std::vector< CSMWorld::UniversalId >& data)
{ {
dropType output = notCells; DropType output = Type_Other;
bool firstIteration = true;
for (unsigned i = 0; i < data.size(); ++i) for (std::vector<CSMWorld::UniversalId>::const_iterator iter (data.begin());
iter!=data.end(); ++iter)
{ {
if (data[i].getType() == CSMWorld::UniversalId::Type_Cell || DropType type = Type_Other;
data[i].getType() == CSMWorld::UniversalId::Type_Cell_Missing)
if (iter->getType()==CSMWorld::UniversalId::Type_Cell ||
iter->getType()==CSMWorld::UniversalId::Type_Cell_Missing)
{ {
if (*(data[i].getId().begin()) == '#') //exterior type = iter->getId().substr (0, 1)=="#" ? Type_CellsExterior : Type_CellsInterior;
{
if (firstIteration)
{
output = cellsExterior;
firstIteration = false;
continue;
}
if (output == cellsInterior)
{
output = cellsMixed;
break;
} else {
output = cellsInterior;
}
} else //interior
{
if (firstIteration)
{
output = cellsInterior;
firstIteration = false;
continue;
}
if (output == cellsExterior)
{
output = cellsMixed;
break;
} else {
output = cellsInterior;
}
}
} else {
output = notCells;
break;
} }
if (iter==data.begin())
output = type;
else if (output!=type) // mixed types -> ignore
return Type_Other;
} }
return output; return output;

View File

@ -36,12 +36,11 @@ namespace CSVRender
public: public:
enum dropType enum DropType
{ {
cellsMixed, Type_CellsInterior,
cellsInterior, Type_CellsExterior,
cellsExterior, Type_Other
notCells
}; };
enum dropRequirments enum dropRequirments
@ -69,9 +68,9 @@ namespace CSVRender
void selectDefaultNavigationMode(); void selectDefaultNavigationMode();
static dropType getDropType(const std::vector<CSMWorld::UniversalId>& data); static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
virtual dropRequirments getDropRequirements(dropType type) const = 0; virtual dropRequirments getDropRequirements(DropType type) const = 0;
virtual void useViewHint (const std::string& hint); virtual void useViewHint (const std::string& hint);
///< Default-implementation: ignored. ///< Default-implementation: ignored.