mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 13:01:41 +00:00
Changed: #1301 Added checking for the overlaps when adding a new landscape. Added blackout inactive landscapes. Operations adding and removing landscapes work correctly.
This commit is contained in:
parent
eacb41e5b2
commit
712349f7f5
9 changed files with 232 additions and 97 deletions
|
@ -32,13 +32,14 @@
|
|||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
ZoneBuilder::ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack)
|
||||
ZoneBuilder::ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget, QUndoStack *undoStack)
|
||||
: m_currentZoneRegion(-1),
|
||||
m_pixmapDatabase(0),
|
||||
m_listZonesWidget(listZonesWidget),
|
||||
m_landscapeScene(landscapeScene),
|
||||
m_undoStack(undoStack)
|
||||
{
|
||||
nlassert(m_landscapeScene);
|
||||
m_pixmapDatabase = new PixmapDatabase();
|
||||
m_lastPathName = "";
|
||||
}
|
||||
|
@ -81,6 +82,9 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone)
|
|||
|
||||
void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zonePos)
|
||||
{
|
||||
if (m_undoStack == 0)
|
||||
return;
|
||||
|
||||
checkBeginMacro();
|
||||
nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str());
|
||||
m_zonePositionList.push_back(zonePos);
|
||||
|
@ -89,6 +93,9 @@ void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zoneP
|
|||
|
||||
void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY)
|
||||
{
|
||||
if (m_undoStack == 0)
|
||||
return;
|
||||
|
||||
checkBeginMacro();
|
||||
nlinfo("ligoMove");
|
||||
//m_undoStack->push(new LigoMoveCommand(index, deltaX, deltaY, this));
|
||||
|
@ -96,6 +103,9 @@ void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY)
|
|||
|
||||
void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY)
|
||||
{
|
||||
if (m_undoStack == 0)
|
||||
return;
|
||||
|
||||
checkBeginMacro();
|
||||
nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str());
|
||||
m_undoStack->push(new LigoResizeCommand(index, newMinX, newMaxX, newMinY, newMaxY, this));
|
||||
|
@ -103,16 +113,20 @@ void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, s
|
|||
|
||||
void ZoneBuilder::addZone(sint32 posX, sint32 posY)
|
||||
{
|
||||
if (m_builderZoneRegions.empty())
|
||||
// Read-only mode
|
||||
if ((m_listZonesWidget == 0) || (m_undoStack == 0))
|
||||
return;
|
||||
|
||||
if (m_landscapeItems.empty())
|
||||
return;
|
||||
|
||||
// Check zone name
|
||||
std::string zoneName = m_listZonesWidget->currentZoneName().toStdString();
|
||||
if (zoneName.empty())
|
||||
return;
|
||||
|
||||
std::string error;
|
||||
BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion);
|
||||
builderZoneRegion->init(this, error);
|
||||
BuilderZoneRegion *builderZoneRegion = m_landscapeItems.at(m_currentZoneRegion).builderZoneRegion;
|
||||
builderZoneRegion->init(this);
|
||||
|
||||
uint8 rot = uint8(m_listZonesWidget->currentRot());
|
||||
uint8 flip = uint8(m_listZonesWidget->currentFlip());
|
||||
|
@ -122,8 +136,6 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY)
|
|||
m_titleAction = QString("Add zone %1,%2").arg(posX).arg(posY);
|
||||
m_createdAction = false;
|
||||
m_zonePositionList.clear();
|
||||
|
||||
nlinfo("---------");
|
||||
if (m_listZonesWidget->isForce())
|
||||
{
|
||||
builderZoneRegion->addForce(posX, posY, rot, flip, zoneBankElement);
|
||||
|
@ -140,45 +152,95 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY)
|
|||
|
||||
void ZoneBuilder::addTransition(const sint32 posX, const sint32 posY)
|
||||
{
|
||||
if ((m_listZonesWidget == 0) || (m_undoStack == 0))
|
||||
return;
|
||||
}
|
||||
|
||||
void ZoneBuilder::delZone(const sint32 posX, const sint32 posY)
|
||||
{
|
||||
if (m_builderZoneRegions.empty())
|
||||
if ((m_listZonesWidget == 0) || (m_undoStack == 0))
|
||||
return;
|
||||
|
||||
if (m_landscapeItems.empty())
|
||||
return;
|
||||
|
||||
m_titleAction = QString("Del zone %1,%2").arg(posX).arg(posY);
|
||||
m_createdAction = false;
|
||||
|
||||
BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion);
|
||||
std::string error;
|
||||
nlinfo("---------");
|
||||
builderZoneRegion->init(this, error);
|
||||
BuilderZoneRegion *builderZoneRegion = m_landscapeItems.at(m_currentZoneRegion).builderZoneRegion;
|
||||
|
||||
builderZoneRegion->init(this);
|
||||
builderZoneRegion->del(posX, posY);
|
||||
checkEndMacro();
|
||||
}
|
||||
|
||||
int ZoneBuilder::createZoneRegion()
|
||||
{
|
||||
ZoneRegionObject *newZoneRegion = new ZoneRegionObject();
|
||||
m_zoneRegions.push_back(newZoneRegion);
|
||||
if (m_currentZoneRegion == -1)
|
||||
m_currentZoneRegion = m_zoneRegions.indexOf(newZoneRegion);
|
||||
int newId = m_landscapeItems.size();
|
||||
LandscapeItem landItem;
|
||||
landItem.zoneRegionObject = new ZoneRegionObject();
|
||||
landItem.builderZoneRegion = new BuilderZoneRegion(newId);
|
||||
landItem.builderZoneRegion->init(this);
|
||||
landItem.rectItem = 0;
|
||||
|
||||
newZone();
|
||||
return m_zoneRegions.indexOf(newZoneRegion);
|
||||
m_landscapeItems.push_back(landItem);
|
||||
if (m_currentZoneRegion == -1)
|
||||
setCurrentZoneRegion(newId);
|
||||
|
||||
return newId;
|
||||
}
|
||||
|
||||
int ZoneBuilder::createZoneRegion(const QString &fileName)
|
||||
{
|
||||
int newId = m_landscapeItems.size();
|
||||
LandscapeItem landItem;
|
||||
landItem.zoneRegionObject = new ZoneRegionObject();
|
||||
landItem.zoneRegionObject->load(fileName.toStdString());
|
||||
|
||||
if (!checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion()))
|
||||
{
|
||||
delete landItem.zoneRegionObject;
|
||||
return -1;
|
||||
}
|
||||
landItem.builderZoneRegion = new BuilderZoneRegion(newId);
|
||||
landItem.builderZoneRegion->init(this);
|
||||
|
||||
newZone();
|
||||
m_landscapeItems.push_back(landItem);
|
||||
|
||||
m_landscapeScene->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion());
|
||||
m_landscapeItems.at(newId).rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion());
|
||||
|
||||
if (m_currentZoneRegion == -1)
|
||||
setCurrentZoneRegion(newId);
|
||||
|
||||
return newId;
|
||||
}
|
||||
|
||||
void ZoneBuilder::deleteZoneRegion(int id)
|
||||
{
|
||||
if ((0 <= id) && (id < m_zoneRegions.size()))
|
||||
delete m_zoneRegions.takeAt(id);
|
||||
if ((0 <= id) && (id < int(m_landscapeItems.size())))
|
||||
{
|
||||
m_landscapeScene->delZoneRegion(m_landscapeItems.at(id).zoneRegionObject->ligoZoneRegion());
|
||||
delete m_landscapeItems.at(id).zoneRegionObject;
|
||||
delete m_landscapeItems.at(id).builderZoneRegion;
|
||||
delete m_landscapeItems.at(id).rectItem;
|
||||
m_landscapeItems.erase(m_landscapeItems.begin() + id);
|
||||
calcMask();
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneBuilder::setCurrentZoneRegion(int id)
|
||||
{
|
||||
if ((0 <= id) && (id < m_zoneRegions.size()))
|
||||
if ((0 <= id) && (id < int(m_landscapeItems.size())))
|
||||
{
|
||||
if (currentIdZoneRegion() != -1)
|
||||
m_landscapeItems.at(m_currentZoneRegion).rectItem = m_landscapeScene->createLayerBlackout(currentZoneRegion()->ligoZoneRegion());
|
||||
m_currentZoneRegion = id;
|
||||
delete m_landscapeItems.at(id).rectItem;
|
||||
m_landscapeItems.at(id).rectItem = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ZoneBuilder::currentIdZoneRegion() const
|
||||
|
@ -188,27 +250,27 @@ int ZoneBuilder::currentIdZoneRegion() const
|
|||
|
||||
ZoneRegionObject *ZoneBuilder::currentZoneRegion() const
|
||||
{
|
||||
return m_zoneRegions.at(m_currentZoneRegion);
|
||||
return m_landscapeItems.at(m_currentZoneRegion).zoneRegionObject;
|
||||
}
|
||||
|
||||
int ZoneBuilder::countZoneRegion() const
|
||||
{
|
||||
return m_zoneRegions.size();
|
||||
return m_landscapeItems.size();
|
||||
}
|
||||
|
||||
ZoneRegionObject *ZoneBuilder::zoneRegion(int id) const
|
||||
{
|
||||
return m_zoneRegions.at(id);
|
||||
return m_landscapeItems.at(id).zoneRegionObject;
|
||||
}
|
||||
|
||||
void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos)
|
||||
{
|
||||
m_zoneRegions.at(zonePos.region)->ligoData(data, zonePos.x, zonePos.y);
|
||||
m_landscapeItems.at(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y);
|
||||
}
|
||||
|
||||
void ZoneBuilder::setLigoData(LigoData &data, const ZonePosition &zonePos)
|
||||
{
|
||||
m_zoneRegions.at(zonePos.region)->setLigoData(data, zonePos.x, zonePos.y);
|
||||
m_landscapeItems.at(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y);
|
||||
}
|
||||
|
||||
bool ZoneBuilder::initZoneBank (const QString &pathName)
|
||||
|
@ -243,16 +305,13 @@ QString ZoneBuilder::dataPath() const
|
|||
|
||||
void ZoneBuilder::newZone()
|
||||
{
|
||||
BuilderZoneRegion *builderZoneRegion = new BuilderZoneRegion(m_builderZoneRegions.size());
|
||||
m_builderZoneRegions.push_back(builderZoneRegion);
|
||||
|
||||
// Select starting point for the moment 0,0
|
||||
sint32 x = 0, y = 0;
|
||||
|
||||
// If there are some zone already present increase x until free
|
||||
for (int i = 0; i < m_zoneRegions.size(); ++i)
|
||||
for (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneRegions.at(i)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion();
|
||||
const std::string &zoneName = zoneRegion.getName (x, y);
|
||||
if ((zoneName != STRING_OUT_OF_BOUND) && (zoneName != STRING_UNUSED))
|
||||
{
|
||||
|
@ -278,18 +337,17 @@ bool ZoneBuilder::getZoneMask(sint32 x, sint32 y)
|
|||
|
||||
void ZoneBuilder::calcMask()
|
||||
{
|
||||
sint32 i;
|
||||
sint32 x, y;
|
||||
|
||||
m_minY = m_minX = 1000000;
|
||||
m_maxY = m_maxX = -1000000;
|
||||
|
||||
if (m_builderZoneRegions.size() == 0)
|
||||
if (m_landscapeItems.size() == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i)
|
||||
for (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||
{
|
||||
const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion ®ion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion();
|
||||
|
||||
if (m_minX > region.getMinX())
|
||||
m_minX = region.getMinX();
|
||||
|
@ -308,10 +366,10 @@ void ZoneBuilder::calcMask()
|
|||
{
|
||||
m_zoneMask[x - m_minX + (y - m_minY) * stride] = true;
|
||||
|
||||
for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i)
|
||||
if (i != m_currentZoneRegion)
|
||||
for (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||
if (int(i) != m_currentZoneRegion)
|
||||
{
|
||||
const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->ligoZoneRegion();
|
||||
|
||||
const std::string &rSZone = region.getName (x, y);
|
||||
if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED))
|
||||
|
@ -322,25 +380,24 @@ void ZoneBuilder::calcMask()
|
|||
}
|
||||
}
|
||||
|
||||
bool ZoneBuilder::getZoneAmongRegions (ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y)
|
||||
bool ZoneBuilder::getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y)
|
||||
{
|
||||
Q_FOREACH(ZoneRegionObject *zoneRegion, m_zoneRegions)
|
||||
for (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||
{
|
||||
const NLLIGO::CZoneRegion ®ion = zoneRegion->zoneRegion();
|
||||
const NLLIGO::CZoneRegion ®ion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion();
|
||||
if ((x < region.getMinX()) || (x > region.getMaxX()) ||
|
||||
(y < region.getMinY()) || (y > region.getMaxY()))
|
||||
continue;
|
||||
if (region.getName(x, y) != STRING_UNUSED)
|
||||
{
|
||||
int index = m_zoneRegions.indexOf(zoneRegion);
|
||||
builderZoneRegionFrom = m_builderZoneRegions.at(index);
|
||||
zonePos = ZonePosition(x, y, index);
|
||||
builderZoneRegionFrom = m_landscapeItems.at(i).builderZoneRegion;
|
||||
zonePos = ZonePosition(x, y, i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// The zone is not present in other region so it is an empty or oob zone of the current region
|
||||
const NLLIGO::CZoneRegion ®ion = zoneRegion(builderZoneRegionFrom->getRegionId())->zoneRegion();
|
||||
const NLLIGO::CZoneRegion ®ion = zoneRegion(builderZoneRegionFrom->getRegionId())->ligoZoneRegion();
|
||||
if ((x < region.getMinX()) || (x > region.getMaxX()) ||
|
||||
(y < region.getMinY()) || (y > region.getMaxY()))
|
||||
return false; // Out Of Bound
|
||||
|
@ -372,4 +429,24 @@ void ZoneBuilder::checkEndMacro()
|
|||
}
|
||||
}
|
||||
|
||||
bool ZoneBuilder::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion)
|
||||
{
|
||||
for (size_t j = 0; j < m_landscapeItems.size(); ++j)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_landscapeItems.at(j).zoneRegionObject->ligoZoneRegion();
|
||||
for (sint32 y = zoneRegion.getMinY(); y <= zoneRegion.getMaxY(); ++y)
|
||||
for (sint32 x = zoneRegion.getMinX(); x <= zoneRegion.getMaxX(); ++x)
|
||||
{
|
||||
const std::string &refZoneName = zoneRegion.getName(x, y);
|
||||
if (refZoneName != STRING_UNUSED)
|
||||
{
|
||||
const std::string &zoneName = newZoneRegion.getName(x, y);
|
||||
if ((zoneName != STRING_UNUSED) && (zoneName != STRING_OUT_OF_BOUND))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} /* namespace LandscapeEditor */
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QtCore/QString>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QUndoStack>
|
||||
#include <QtGui/QGraphicsRectItem>
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
@ -77,7 +78,7 @@ PixmapDatabase contains the graphics for the zones
|
|||
class ZoneBuilder
|
||||
{
|
||||
public:
|
||||
ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack);
|
||||
ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget = 0, QUndoStack *undoStack = 0);
|
||||
~ZoneBuilder();
|
||||
|
||||
/// Init zoneBank and init zone pixmap database
|
||||
|
@ -88,18 +89,24 @@ public:
|
|||
bool getZoneMask (sint32 x, sint32 y);
|
||||
bool getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y);
|
||||
|
||||
// Ligo Actions
|
||||
/// Ligo Actions
|
||||
/// @{
|
||||
void actionLigoTile(const LigoData &data, const ZonePosition &zonePos);
|
||||
void actionLigoMove(uint index, sint32 deltaX, sint32 deltaY);
|
||||
void actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY);
|
||||
/// @}
|
||||
|
||||
// Zone Bricks
|
||||
/// Zone Bricks
|
||||
/// @{
|
||||
void addZone(sint32 posX, sint32 posY);
|
||||
void addTransition(const sint32 posX, const sint32 posY);
|
||||
void delZone(const sint32 posX, const sint32 posY);
|
||||
/// @}
|
||||
|
||||
// Zone Region
|
||||
/// Zone Region
|
||||
/// @{
|
||||
int createZoneRegion();
|
||||
int createZoneRegion(const QString &fileName);
|
||||
void deleteZoneRegion(int id);
|
||||
void setCurrentZoneRegion(int id);
|
||||
int currentIdZoneRegion() const;
|
||||
|
@ -108,6 +115,7 @@ public:
|
|||
ZoneRegionObject *zoneRegion(int id) const;
|
||||
void ligoData(LigoData &data, const ZonePosition &zonePos);
|
||||
void setLigoData(LigoData &data, const ZonePosition &zonePos);
|
||||
/// @}
|
||||
|
||||
// Accessors
|
||||
NLLIGO::CZoneBank &getZoneBank()
|
||||
|
@ -127,15 +135,22 @@ private:
|
|||
void checkBeginMacro();
|
||||
void checkEndMacro();
|
||||
|
||||
bool checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion);
|
||||
|
||||
struct LandscapeItem
|
||||
{
|
||||
BuilderZoneRegion *builderZoneRegion;
|
||||
ZoneRegionObject *zoneRegionObject;
|
||||
QGraphicsRectItem *rectItem;
|
||||
};
|
||||
|
||||
sint32 m_minX, m_maxX, m_minY, m_maxY;
|
||||
std::vector<bool> m_zoneMask;
|
||||
|
||||
QString m_lastPathName;
|
||||
|
||||
QList<ZoneRegionObject *> m_zoneRegions;
|
||||
int m_currentZoneRegion;
|
||||
|
||||
std::vector<BuilderZoneRegion *> m_builderZoneRegions;
|
||||
std::vector<LandscapeItem> m_landscapeItems;
|
||||
|
||||
bool m_createdAction;
|
||||
QString m_titleAction;
|
||||
|
|
|
@ -35,7 +35,7 @@ BuilderZoneRegion::BuilderZoneRegion(uint regionId)
|
|||
{
|
||||
}
|
||||
|
||||
bool BuilderZoneRegion::init(ZoneBuilder *zoneBuilder, std::string &error)
|
||||
bool BuilderZoneRegion::init(ZoneBuilder *zoneBuilder)
|
||||
{
|
||||
if (m_firstInit)
|
||||
return true;
|
||||
|
@ -264,7 +264,7 @@ void BuilderZoneRegion::add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::C
|
|||
|
||||
void BuilderZoneRegion::invertCutEdge(sint32 x, sint32 y, uint8 cePos)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) ||
|
||||
(y < zoneRegion.getMinY ()) || (y > zoneRegion.getMaxY ()))
|
||||
return;
|
||||
|
@ -371,7 +371,7 @@ void BuilderZoneRegion::invertCutEdge(sint32 x, sint32 y, uint8 cePos)
|
|||
|
||||
void BuilderZoneRegion::cycleTransition(sint32 x, sint32 y)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) ||
|
||||
(y < zoneRegion.getMinY ()) || (y > zoneRegion.getMaxY ()))
|
||||
return;
|
||||
|
@ -391,7 +391,7 @@ void BuilderZoneRegion::cycleTransition(sint32 x, sint32 y)
|
|||
|
||||
bool BuilderZoneRegion::addNotPropagate (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY();
|
||||
sint32 i, j;
|
||||
NLLIGO::SPiece sMask, sPosX, sPosY;
|
||||
|
@ -472,7 +472,7 @@ bool BuilderZoneRegion::addNotPropagate (sint32 x, sint32 y, uint8 rot, uint8 fl
|
|||
|
||||
void BuilderZoneRegion::addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY();
|
||||
sint32 i, j;
|
||||
NLLIGO::SPiece sMask, sPosX, sPosY;
|
||||
|
@ -636,7 +636,7 @@ uint8 TransToEdge[72][4] =
|
|||
|
||||
void BuilderZoneRegion::addTransition (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
uint32 i;
|
||||
// Check that we write in an already defined place
|
||||
if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) ||
|
||||
|
@ -806,7 +806,7 @@ void BuilderZoneRegion::addTransition (sint32 x, sint32 y, uint8 rot, uint8 flip
|
|||
|
||||
void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
ToUpdate *ptCreate = reinterpret_cast<ToUpdate *>(pInt1);
|
||||
ToUpdate *ptUpdate = reinterpret_cast<ToUpdate *>(pInt2);
|
||||
sint32 stride = (1 + zoneRegion.getMaxX() - zoneRegion.getMinX());
|
||||
|
@ -831,7 +831,7 @@ void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegio
|
|||
void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SPiece &mask, const std::string &matName,
|
||||
void *pInternal)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
ToUpdate tCreate; // Transition to create
|
||||
ToUpdate *ptUpdate = reinterpret_cast<ToUpdate *>(pInternal); // Transition to update
|
||||
|
||||
|
@ -984,7 +984,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP
|
|||
// For all transition to update choose the cut edge
|
||||
for (m = 0; m < (sint32)tCreate.size(); ++m)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion();
|
||||
x = tCreate.getX(m);
|
||||
y = tCreate.getY(m);
|
||||
|
||||
|
@ -1145,7 +1145,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP
|
|||
// Finally update all transition
|
||||
for (m = 0; m < (sint32)tCreate.size(); ++m)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion();
|
||||
x = tCreate.getX(m);
|
||||
y = tCreate.getY(m);
|
||||
|
||||
|
@ -1155,7 +1155,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP
|
|||
}
|
||||
for (m = 0; m < (sint32)ptUpdate->size(); ++m)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion();
|
||||
x = ptUpdate->getX(m);
|
||||
y = ptUpdate->getY(m);
|
||||
if ((x >= zoneRegion2.getMinX()) && (x <= zoneRegion2.getMaxX()) &&
|
||||
|
@ -1166,7 +1166,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP
|
|||
// Cross material
|
||||
for (m = 0; m < (sint32)tCreate.size(); ++m)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion();
|
||||
x = tCreate.getX(m);
|
||||
y = tCreate.getY(m);
|
||||
|
||||
|
@ -1363,7 +1363,7 @@ STrans TranConvTable[128] =
|
|||
|
||||
void BuilderZoneRegion::updateTrans (sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) ||
|
||||
(y < zoneRegion.getMinY()) || (y > zoneRegion.getMaxY()))
|
||||
return;
|
||||
|
@ -1564,7 +1564,7 @@ void BuilderZoneRegion::updateTrans (sint32 x, sint32 y, NLLIGO::CZoneBankElemen
|
|||
|
||||
std::string BuilderZoneRegion::getNextMatInTree (const std::string &matA, const std::string &matB)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
uint32 i, posA = 10000, posB = 10000;
|
||||
|
||||
if (matA == matB)
|
||||
|
@ -1600,7 +1600,7 @@ struct SNode
|
|||
|
||||
void BuilderZoneRegion::tryPath(uint32 posA, uint32 posB, std::vector<uint32> &path)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
|
||||
// Build the adjascence matrix
|
||||
std::vector<sint32> matAdj;
|
||||
|
@ -1662,7 +1662,7 @@ void BuilderZoneRegion::tryPath(uint32 posA, uint32 posB, std::vector<uint32> &p
|
|||
|
||||
void BuilderZoneRegion::del(sint32 x, sint32 y, bool transition, void *pInternal)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
if (!m_zoneBuilder->getZoneMask(x, y))
|
||||
return;
|
||||
|
||||
|
@ -1783,7 +1783,7 @@ void BuilderZoneRegion::move (sint32 x, sint32 y)
|
|||
|
||||
uint32 BuilderZoneRegion::countZones ()
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
sint32 x, y;
|
||||
|
||||
uint32 counter = 0;
|
||||
|
@ -1799,7 +1799,7 @@ uint32 BuilderZoneRegion::countZones ()
|
|||
void BuilderZoneRegion::set(sint32 x, sint32 y, sint32 posX, sint32 posY,
|
||||
const std::string &zoneName, bool transition)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
|
||||
// Do we need to resize ?
|
||||
if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) ||
|
||||
|
@ -1988,7 +1988,7 @@ void BuilderZoneRegion::setFlip(sint32 x, sint32 y, uint8 flip)
|
|||
|
||||
void BuilderZoneRegion::reduceMin ()
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
sint32 i, j;
|
||||
|
||||
sint32 newMinX = zoneRegion.getMinX(), newMinY = zoneRegion.getMinY ();
|
||||
|
@ -2099,7 +2099,7 @@ uint BuilderZoneRegion::getRegionId() const
|
|||
|
||||
void BuilderZoneRegion::resize (sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY)
|
||||
{
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion();
|
||||
const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion();
|
||||
if ((zoneRegion.getMinX ()!= newMinX) ||
|
||||
(zoneRegion.getMaxX ()!= newMaxX) ||
|
||||
(zoneRegion.getMinY ()!= newMinY) ||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
BuilderZoneRegion(uint regionId);
|
||||
|
||||
// New interface
|
||||
bool init(ZoneBuilder *zoneBuilder, std::string &error);
|
||||
bool init(ZoneBuilder *zoneBuilder);
|
||||
void add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||
void invertCutEdge(sint32 x, sint32 y, uint8 cePos);
|
||||
void cycleTransition(sint32 x, sint32 y);
|
||||
|
|
|
@ -114,7 +114,6 @@ void UndoScanRegionCommand::undo()
|
|||
{
|
||||
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||
m_scene->deleteItemZone(m_zonePositionList.at(i));
|
||||
nlinfo("------");
|
||||
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||
{
|
||||
LigoData data;
|
||||
|
@ -152,7 +151,6 @@ void RedoScanRegionCommand::redo()
|
|||
{
|
||||
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||
m_scene->deleteItemZone(m_zonePositionList.at(i));
|
||||
nlinfo("------");
|
||||
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||
{
|
||||
LigoData data;
|
||||
|
@ -174,7 +172,7 @@ LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX,
|
|||
m_newMaxY = newMaxY;
|
||||
|
||||
// Backup old region zone
|
||||
m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion();
|
||||
m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion();
|
||||
}
|
||||
|
||||
LigoResizeCommand::~LigoResizeCommand()
|
||||
|
@ -184,13 +182,13 @@ LigoResizeCommand::~LigoResizeCommand()
|
|||
void LigoResizeCommand::undo ()
|
||||
{
|
||||
// Restore old region zone
|
||||
m_zoneBuilder->zoneRegion(m_index)->setZoneRegion(m_oldZoneRegion);
|
||||
m_zoneBuilder->zoneRegion(m_index)->setLigoZoneRegion(m_oldZoneRegion);
|
||||
}
|
||||
|
||||
void LigoResizeCommand::redo ()
|
||||
{
|
||||
// Get the zone region
|
||||
NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion();
|
||||
NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion();
|
||||
|
||||
sint32 i, j;
|
||||
std::vector<LigoData> newZones;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
// Qt includes
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
@ -51,7 +52,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
|||
m_undoStack = new QUndoStack(this);
|
||||
m_landscapeScene = new LandscapeScene(this);
|
||||
|
||||
m_zoneBuilder = new ZoneBuilder(m_ui.zoneListWidget, m_landscapeScene, m_undoStack);
|
||||
m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack);
|
||||
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", true);
|
||||
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||
m_ui.zoneListWidget->updateUi();
|
||||
|
@ -96,12 +97,15 @@ void LandscapeEditorWindow::open()
|
|||
_lastDir = QFileInfo(list.front()).absolutePath();
|
||||
Q_FOREACH(QString fileName, fileNames)
|
||||
{
|
||||
int id = m_zoneBuilder->createZoneRegion();
|
||||
int id = m_zoneBuilder->createZoneRegion(fileName);
|
||||
if (id == -1)
|
||||
{
|
||||
QMessageBox::critical(this, "Landscape Editor", "Cannot add this zone because it overlaps existing ones");
|
||||
continue;
|
||||
}
|
||||
ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id);
|
||||
zoneRegion->load(fileName.toStdString());
|
||||
m_landscapeScene->processZoneRegion(zoneRegion->zoneRegion());
|
||||
m_ui.graphicsView->centerOn(zoneRegion->zoneRegion().getMinX() * m_landscapeScene->cellSize(),
|
||||
abs(zoneRegion->zoneRegion().getMinY()) * m_landscapeScene->cellSize());
|
||||
m_ui.graphicsView->centerOn(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(),
|
||||
abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize());
|
||||
|
||||
m_zoneBuilder->setCurrentZoneRegion(id);
|
||||
}
|
||||
|
@ -157,7 +161,8 @@ void LandscapeEditorWindow::openSnapshotDialog()
|
|||
void LandscapeEditorWindow::showEvent(QShowEvent *showEvent)
|
||||
{
|
||||
QMainWindow::showEvent(showEvent);
|
||||
m_oglWidget->makeCurrent();
|
||||
if (m_oglWidget != 0)
|
||||
m_oglWidget->makeCurrent();
|
||||
}
|
||||
|
||||
void LandscapeEditorWindow::createMenus()
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
// Project includes
|
||||
#include "landscape_scene.h"
|
||||
#include "pixmap_database.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/debug.h>
|
||||
|
@ -29,7 +30,10 @@
|
|||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
static const int ZoneName = 0;
|
||||
static const int ZONE_NAME = 0;
|
||||
static const int LAYER_ZONES = 2;
|
||||
static const int LAYER_EMPTY_ZONES = 3;
|
||||
static const int LAYER_BLACKOUT = 4;
|
||||
|
||||
LandscapeScene::LandscapeScene(QObject *parent)
|
||||
: QGraphicsScene(parent),
|
||||
|
@ -78,19 +82,18 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo
|
|||
|
||||
if (data.flip == 0)
|
||||
{
|
||||
item = new QGraphicsPixmapItem(pixmap->transformed(matrix, Qt::SmoothTransformation), 0, this);
|
||||
item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation));
|
||||
}
|
||||
else
|
||||
{
|
||||
// mirror image
|
||||
QImage mirrorImage = pixmap->toImage();
|
||||
QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false));
|
||||
item = new QGraphicsPixmapItem(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation), 0, this);
|
||||
item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation));
|
||||
}
|
||||
// Enable bilinear filtering
|
||||
item->setTransformationMode(Qt::SmoothTransformation);
|
||||
|
||||
// Set position graphics item with offset for large piece
|
||||
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName);
|
||||
|
||||
sint32 deltaX = 0, deltaY = 0;
|
||||
|
@ -145,16 +148,16 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo
|
|||
}
|
||||
}
|
||||
|
||||
// set position graphics item with taking into account the offset
|
||||
// Set position graphics item with offset for large piece
|
||||
item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize);
|
||||
|
||||
// The size graphics item should be equal or proportional m_cellSize
|
||||
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
||||
|
||||
item->setData(ZoneName, QString(data.zoneName.c_str()));
|
||||
//item->setData(ZONE_NAME, QString(data.zoneName.c_str()));
|
||||
|
||||
// for not full item zone
|
||||
item->setZValue(0);
|
||||
item->setZValue(LAYER_ZONES);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -169,7 +172,7 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
|||
if (pixmap == 0)
|
||||
return 0;
|
||||
|
||||
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(*pixmap, 0, this);
|
||||
QGraphicsPixmapItem *item = addPixmap(*pixmap);
|
||||
|
||||
// Enable bilinear filtering
|
||||
item->setTransformationMode(Qt::SmoothTransformation);
|
||||
|
@ -181,11 +184,23 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
|||
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
||||
|
||||
// for not full item zone
|
||||
item->setZValue(1);
|
||||
item->setZValue(LAYER_EMPTY_ZONES);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
QGraphicsRectItem *LandscapeScene::createLayerBlackout(const NLLIGO::CZoneRegion &zoneRegion)
|
||||
{
|
||||
QGraphicsRectItem *rectItem = addRect(zoneRegion.getMinX() * m_cellSize,
|
||||
abs(zoneRegion.getMaxY()) * m_cellSize,
|
||||
(abs(zoneRegion.getMaxX() - zoneRegion.getMinX()) + 1) * m_cellSize,
|
||||
(abs(zoneRegion.getMaxY() - zoneRegion.getMinY()) + 1) * m_cellSize,
|
||||
Qt::NoPen, QBrush(QColor(0, 0, 0, 50)));
|
||||
|
||||
rectItem->setZValue(LAYER_BLACKOUT);
|
||||
return rectItem;
|
||||
}
|
||||
|
||||
void LandscapeScene::deleteItemZone(const ZonePosition &zonePos)
|
||||
{
|
||||
QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize);
|
||||
|
@ -196,12 +211,13 @@ void LandscapeScene::deleteItemZone(const ZonePosition &zonePos)
|
|||
}
|
||||
}
|
||||
|
||||
void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||
void LandscapeScene::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||
{
|
||||
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
||||
{
|
||||
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
||||
{
|
||||
|
||||
//nlinfo(QString("%1 %2 %3").arg(i).arg(j).arg(zoneRegion.getName(i, j).c_str()).toStdString().c_str());
|
||||
std::string zoneName = zoneRegion.getName(i, j);
|
||||
if (zoneName == STRING_UNUSED)
|
||||
|
@ -224,6 +240,17 @@ void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
|||
}
|
||||
}
|
||||
|
||||
void LandscapeScene::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||
{
|
||||
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
||||
{
|
||||
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
||||
{
|
||||
deleteItemZone(ZonePosition(i, -j, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LandscapeScene::snapshot(const QString &fileName, int sizeSource)
|
||||
{
|
||||
/* if (m_zoneRegion == 0)
|
||||
|
@ -305,7 +332,9 @@ bool LandscapeScene::checkUnderZone(const int posX, const int posY)
|
|||
{
|
||||
QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize);
|
||||
if (item != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
// Project includes
|
||||
#include "zone_region_editor.h"
|
||||
#include "builder_zone.h"
|
||||
#include "landscape_editor_global.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/ligo/zone_region.h>
|
||||
|
@ -32,7 +33,12 @@
|
|||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
class LandscapeScene : public QGraphicsScene
|
||||
/**
|
||||
@class LandscapeScene
|
||||
@brief
|
||||
@details
|
||||
*/
|
||||
class LANDSCAPE_EDITOR_EXPORT LandscapeScene : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -45,15 +51,18 @@ public:
|
|||
|
||||
QGraphicsItem *createItemZone(const LigoData &data, const ZonePosition &zonePos);
|
||||
QGraphicsItem *createItemEmptyZone(const ZonePosition &zonePos);
|
||||
QGraphicsRectItem *createLayerBlackout(const NLLIGO::CZoneRegion &zoneRegion);
|
||||
void deleteItemZone(const ZonePosition &zonePos);
|
||||
void processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||
|
||||
void addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||
void delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||
|
||||
void snapshot(const QString &fileName, int sizeSource);
|
||||
void snapshot(const QString &fileName, int width, int height);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect);
|
||||
|
||||
private:
|
||||
|
|
|
@ -41,6 +41,7 @@ LandscapeView::LandscapeView(QWidget *parent)
|
|||
setBackgroundBrush(QBrush(Qt::lightGray));
|
||||
//setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||
//setRenderHints(QPainter::Antialiasing);
|
||||
//setCacheMode(QGraphicsView::CacheBackground);
|
||||
m_cellSize = 160;
|
||||
m_numSteps = 0;
|
||||
m_maxSteps = 20;
|
||||
|
@ -83,6 +84,7 @@ void LandscapeView::wheelEvent(QWheelEvent *event)
|
|||
--m_numSteps;
|
||||
}
|
||||
scale(factor, factor);
|
||||
QGraphicsView::wheelEvent(event);
|
||||
}
|
||||
|
||||
void LandscapeView::mousePressEvent(QMouseEvent *event)
|
||||
|
|
Loading…
Reference in a new issue