|
@@ -377,8 +377,7 @@ void ObjectsLayer::draw(bool onlyDirty)
|
|
return;
|
|
return;
|
|
|
|
|
|
QPainter painter(pixmap.get());
|
|
QPainter painter(pixmap.get());
|
|
- std::set<const CGObjectInstance *> drawen;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
if(onlyDirty)
|
|
if(onlyDirty)
|
|
{
|
|
{
|
|
//objects could be modified
|
|
//objects could be modified
|
|
@@ -392,7 +391,7 @@ void ObjectsLayer::draw(bool onlyDirty)
|
|
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
|
|
|
|
for(auto & p : dirty)
|
|
for(auto & p : dirty)
|
|
- handler->drawObjects(painter, p.x, p.y, p.z);
|
|
|
|
|
|
+ handler->drawObjects(painter, p.x, p.y, p.z, lockedObjects);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -401,7 +400,7 @@ void ObjectsLayer::draw(bool onlyDirty)
|
|
{
|
|
{
|
|
for(int i = 0; i < map->width; ++i)
|
|
for(int i = 0; i < map->width; ++i)
|
|
{
|
|
{
|
|
- handler->drawObjects(painter, i, j, scene->level);
|
|
|
|
|
|
+ handler->drawObjects(painter, i, j, scene->level, lockedObjects);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -430,6 +429,19 @@ void ObjectsLayer::setDirty(const CGObjectInstance * object)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void ObjectsLayer::setLockObject(const CGObjectInstance * object, bool lock)
|
|
|
|
+{
|
|
|
|
+ if(lock)
|
|
|
|
+ lockedObjects.insert(object);
|
|
|
|
+ else
|
|
|
|
+ lockedObjects.erase(object);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ObjectsLayer::unlockAll()
|
|
|
|
+{
|
|
|
|
+ lockedObjects.clear();
|
|
|
|
+}
|
|
|
|
+
|
|
SelectionObjectsLayer::SelectionObjectsLayer(MapSceneBase * s): AbstractLayer(s), newObject(nullptr)
|
|
SelectionObjectsLayer::SelectionObjectsLayer(MapSceneBase * s): AbstractLayer(s), newObject(nullptr)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
@@ -501,7 +513,7 @@ CGObjectInstance * SelectionObjectsLayer::selectObjectAt(int x, int y, const CGO
|
|
//visitable is most important
|
|
//visitable is most important
|
|
for(auto & object : objects)
|
|
for(auto & object : objects)
|
|
{
|
|
{
|
|
- if(!object.obj || object.obj == ignore)
|
|
|
|
|
|
+ if(!object.obj || object.obj == ignore || lockedObjects.count(object.obj))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if(object.obj->visitableAt(x, y))
|
|
if(object.obj->visitableAt(x, y))
|
|
@@ -513,7 +525,7 @@ CGObjectInstance * SelectionObjectsLayer::selectObjectAt(int x, int y, const CGO
|
|
//if not visitable tile - try to get blocked
|
|
//if not visitable tile - try to get blocked
|
|
for(auto & object : objects)
|
|
for(auto & object : objects)
|
|
{
|
|
{
|
|
- if(!object.obj || object.obj == ignore)
|
|
|
|
|
|
+ if(!object.obj || object.obj == ignore || lockedObjects.count(object.obj))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if(object.obj->blockingAt(x, y))
|
|
if(object.obj->blockingAt(x, y))
|
|
@@ -525,7 +537,7 @@ CGObjectInstance * SelectionObjectsLayer::selectObjectAt(int x, int y, const CGO
|
|
//finally, we can take any object
|
|
//finally, we can take any object
|
|
for(auto & object : objects)
|
|
for(auto & object : objects)
|
|
{
|
|
{
|
|
- if(!object.obj || object.obj == ignore)
|
|
|
|
|
|
+ if(!object.obj || object.obj == ignore || lockedObjects.count(object.obj))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if(object.obj->coveringAt(x, y))
|
|
if(object.obj->coveringAt(x, y))
|
|
@@ -555,7 +567,8 @@ void SelectionObjectsLayer::selectObjects(int x1, int y1, int x2, int y2)
|
|
if(map->isInTheMap(int3(i, j, scene->level)))
|
|
if(map->isInTheMap(int3(i, j, scene->level)))
|
|
{
|
|
{
|
|
for(auto & o : handler->getObjects(i, j, scene->level))
|
|
for(auto & o : handler->getObjects(i, j, scene->level))
|
|
- selectObject(o.obj, false); //do not inform about each object added
|
|
|
|
|
|
+ if(!lockedObjects.count(o.obj))
|
|
|
|
+ selectObject(o.obj, false); //do not inform about each object added
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -599,6 +612,19 @@ void SelectionObjectsLayer::onSelection()
|
|
emit selectionMade(!selectedObjects.empty());
|
|
emit selectionMade(!selectedObjects.empty());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void SelectionObjectsLayer::setLockObject(const CGObjectInstance * object, bool lock)
|
|
|
|
+{
|
|
|
|
+ if(lock)
|
|
|
|
+ lockedObjects.insert(object);
|
|
|
|
+ else
|
|
|
|
+ lockedObjects.erase(object);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SelectionObjectsLayer::unlockAll()
|
|
|
|
+{
|
|
|
|
+ lockedObjects.clear();
|
|
|
|
+}
|
|
|
|
+
|
|
MinimapLayer::MinimapLayer(MapSceneBase * s): AbstractLayer(s)
|
|
MinimapLayer::MinimapLayer(MapSceneBase * s): AbstractLayer(s)
|
|
{
|
|
{
|
|
|
|
|