Changed: #1301 Binding 2d renderer to NELLIGO.
--HG-- branch : gsoc2011-worldeditorqt
This commit is contained in:
parent
7099b96a90
commit
7c98cba1f5
14 changed files with 2904 additions and 232 deletions
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "builder_zone.h"
|
#include "builder_zone.h"
|
||||||
|
#include "list_zones_widget.h"
|
||||||
|
#include "landscape_actions.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
@ -29,9 +31,9 @@
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
const int PixmapScale = 256;
|
|
||||||
|
|
||||||
PixmapDatabase::PixmapDatabase()
|
PixmapDatabase::PixmapDatabase()
|
||||||
|
: m_textureSize(256)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,15 +68,21 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon
|
||||||
// Generate filled pixmap
|
// Generate filled pixmap
|
||||||
}
|
}
|
||||||
// All pixmaps must be have same size
|
// All pixmaps must be have same size
|
||||||
if (pixmap->width() != sizeX * PixmapScale)
|
if (pixmap->width() != sizeX * m_textureSize)
|
||||||
{
|
{
|
||||||
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * PixmapScale, sizeY * PixmapScale));
|
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
m_pixmapMap.insert(zonePixmapName, scaledPixmap);
|
m_pixmapMap.insert(zonePixmapName, scaledPixmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_pixmapMap.insert(zonePixmapName, pixmap);
|
m_pixmapMap.insert(zonePixmapName, pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap *pixmap = new QPixmap(zonePath + "_UNUSED_.png");
|
||||||
|
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(m_textureSize, m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
|
delete pixmap;
|
||||||
|
m_pixmapMap.insert(QString(STRING_UNUSED), scaledPixmap);
|
||||||
|
|
||||||
delete progressDialog;
|
delete progressDialog;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -105,8 +113,17 @@ QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneBuilder::ZoneBuilder()
|
int PixmapDatabase::textureSize() const
|
||||||
: m_pixmapDatabase(0)
|
{
|
||||||
|
return m_textureSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneBuilder::ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack)
|
||||||
|
: m_currentZoneRegion(-1),
|
||||||
|
m_pixmapDatabase(0),
|
||||||
|
m_listZonesWidget(listZonesWidget),
|
||||||
|
m_landscapeScene(landscapeScene),
|
||||||
|
m_undoStack(undoStack)
|
||||||
{
|
{
|
||||||
m_pixmapDatabase = new PixmapDatabase();
|
m_pixmapDatabase = new PixmapDatabase();
|
||||||
m_lastPathName = "";
|
m_lastPathName = "";
|
||||||
|
@ -144,10 +161,131 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((makeAZone) && (bRet))
|
if ((makeAZone) && (bRet))
|
||||||
newZone();
|
createZoneRegion();
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
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_undoStack->push(new LigoTileCommand(data, zonePos, this, m_landscapeScene));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY)
|
||||||
|
{
|
||||||
|
nlinfo("ligoMove");
|
||||||
|
//m_undoStack->push(new LigoMoveCommand(index, deltaX, deltaY, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY)
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::addZone(sint32 posX, sint32 posY)
|
||||||
|
{
|
||||||
|
if (m_builderZoneRegions.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
uint8 rot = uint8(m_listZonesWidget->currentRot());
|
||||||
|
uint8 flip = uint8(m_listZonesWidget->currentFlip());
|
||||||
|
|
||||||
|
NLLIGO::CZoneBankElement *zoneBankElement = getZoneBank().getElementByZoneName(zoneName);
|
||||||
|
|
||||||
|
m_undoStack->beginMacro(QString("Add zone %1,%2").arg(posX).arg(posY));
|
||||||
|
if (m_listZonesWidget->isForce())
|
||||||
|
{
|
||||||
|
builderZoneRegion->addForce(posX, posY, rot, flip, zoneBankElement);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_listZonesWidget->isNotPropogate())
|
||||||
|
builderZoneRegion->addNotPropagate(posX, posY, rot, flip, zoneBankElement);
|
||||||
|
else
|
||||||
|
builderZoneRegion->add(posX, posY, rot, flip, zoneBankElement);
|
||||||
|
}
|
||||||
|
m_undoStack->endMacro();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::addTransition(const sint32 posX, const sint32 posY)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::delZone(const sint32 posX, const sint32 posY)
|
||||||
|
{
|
||||||
|
if (m_builderZoneRegions.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_undoStack->beginMacro(QString("Del zone %1,%2").arg(posX).arg(posY));
|
||||||
|
BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion);
|
||||||
|
std::string error;
|
||||||
|
builderZoneRegion->init(this, error);
|
||||||
|
builderZoneRegion->del(posX, posY);
|
||||||
|
m_undoStack->endMacro();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZoneBuilder::createZoneRegion()
|
||||||
|
{
|
||||||
|
ZoneRegionEditor *newZoneRegion = new ZoneRegionEditor();
|
||||||
|
m_zoneRegions.push_back(newZoneRegion);
|
||||||
|
if (m_currentZoneRegion == -1)
|
||||||
|
m_currentZoneRegion = m_zoneRegions.indexOf(newZoneRegion);
|
||||||
|
|
||||||
|
newZone();
|
||||||
|
return m_zoneRegions.indexOf(newZoneRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::deleteZoneRegion(int id)
|
||||||
|
{
|
||||||
|
if ((0 <= id) && (id < m_zoneRegions.size()))
|
||||||
|
delete m_zoneRegions.takeAt(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::setCurrentZoneRegion(int id)
|
||||||
|
{
|
||||||
|
if ((0 <= id) && (id < m_zoneRegions.size()))
|
||||||
|
m_currentZoneRegion = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZoneBuilder::currentIdZoneRegion() const
|
||||||
|
{
|
||||||
|
return m_currentZoneRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneRegionEditor *ZoneBuilder::currentZoneRegion() const
|
||||||
|
{
|
||||||
|
return m_zoneRegions.at(m_currentZoneRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZoneBuilder::countZoneRegion() const
|
||||||
|
{
|
||||||
|
return m_zoneRegions.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneRegionEditor *ZoneBuilder::zoneRegion(int id) const
|
||||||
|
{
|
||||||
|
return m_zoneRegions.at(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
m_zoneRegions.at(zonePos.region)->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);
|
||||||
|
}
|
||||||
|
|
||||||
bool ZoneBuilder::initZoneBank (const QString &pathName)
|
bool ZoneBuilder::initZoneBank (const QString &pathName)
|
||||||
{
|
{
|
||||||
QDir *dir = new QDir(pathName);
|
QDir *dir = new QDir(pathName);
|
||||||
|
@ -178,8 +316,112 @@ QString ZoneBuilder::dataPath() const
|
||||||
return m_lastPathName;
|
return m_lastPathName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneBuilder::newZone (bool bDisplay)
|
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)
|
||||||
|
{
|
||||||
|
const NLLIGO::CZoneRegion &zoneRegion = m_zoneRegions.at(i)->zoneRegion();
|
||||||
|
const std::string &zoneName = zoneRegion.getName (x, y);
|
||||||
|
if ((zoneName != STRING_OUT_OF_BOUND) && (zoneName != STRING_UNUSED))
|
||||||
|
{
|
||||||
|
++x;
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
calcMask();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneBuilder::getZoneMask(sint32 x, sint32 y)
|
||||||
|
{
|
||||||
|
if ((x < m_minX) || (x > m_maxX) ||
|
||||||
|
(y < m_minY) || (y > m_maxY))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_zoneMask[(x - m_minX) + (y - m_minY) * (1 + m_maxX - m_minX)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::calcMask()
|
||||||
|
{
|
||||||
|
sint32 i;
|
||||||
|
sint32 x, y;
|
||||||
|
|
||||||
|
m_minY = m_minX = 1000000;
|
||||||
|
m_maxY = m_maxX = -1000000;
|
||||||
|
|
||||||
|
if (m_builderZoneRegions.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i)
|
||||||
|
{
|
||||||
|
const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion();
|
||||||
|
|
||||||
|
if (m_minX > region.getMinX())
|
||||||
|
m_minX = region.getMinX();
|
||||||
|
if (m_minY > region.getMinY())
|
||||||
|
m_minY = region.getMinY();
|
||||||
|
if (m_maxX < region.getMaxX())
|
||||||
|
m_maxX = region.getMaxX();
|
||||||
|
if (m_maxY < region.getMaxY())
|
||||||
|
m_maxY = region.getMaxY();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_zoneMask.resize ((1 + m_maxX - m_minX) * (1 + m_maxY - m_minY));
|
||||||
|
sint32 stride = (1 + m_maxX - m_minX);
|
||||||
|
for (y = m_minY; y <= m_maxY; ++y)
|
||||||
|
for (x = m_minX; x <= m_maxX; ++x)
|
||||||
|
{
|
||||||
|
m_zoneMask[x - m_minX + (y - m_minY) * stride] = true;
|
||||||
|
|
||||||
|
for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i)
|
||||||
|
if (i != m_currentZoneRegion)
|
||||||
|
{
|
||||||
|
const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion();
|
||||||
|
|
||||||
|
const std::string &rSZone = region.getName (x, y);
|
||||||
|
if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED))
|
||||||
|
{
|
||||||
|
m_zoneMask[x - m_minX + (y - m_minY) * stride] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneBuilder::getZoneAmongRegions (ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y)
|
||||||
|
{
|
||||||
|
Q_FOREACH(ZoneRegionEditor *zoneRegion, m_zoneRegions)
|
||||||
|
{
|
||||||
|
const NLLIGO::CZoneRegion ®ion = zoneRegion->zoneRegion();
|
||||||
|
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);
|
||||||
|
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();
|
||||||
|
if ((x < region.getMinX()) || (x > region.getMaxX()) ||
|
||||||
|
(y < region.getMinY()) || (y > region.getMaxY()))
|
||||||
|
return false; // Out Of Bound
|
||||||
|
|
||||||
|
zonePos = ZonePosition(x, y, builderZoneRegionFrom->getRegionId());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -19,9 +19,12 @@
|
||||||
#define BUILDER_ZONE_H
|
#define BUILDER_ZONE_H
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
|
#include "builder_zone_region.h"
|
||||||
|
#include "zone_region_editor.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/zone_bank.h>
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
// STL includes
|
// STL includes
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -30,11 +33,38 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtGui/QPixmap>
|
#include <QtGui/QPixmap>
|
||||||
|
#include <QtGui/QUndoStack>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
class ListZonesWidget;
|
||||||
|
class LandscapeScene;
|
||||||
|
|
||||||
|
// Data
|
||||||
|
struct ZonePosition
|
||||||
|
{
|
||||||
|
// Absolute position
|
||||||
|
sint32 x;
|
||||||
|
sint32 y;
|
||||||
|
int region;
|
||||||
|
|
||||||
|
ZonePosition()
|
||||||
|
{
|
||||||
|
x = 0xffffffff;
|
||||||
|
y = 0xffffffff;
|
||||||
|
region = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZonePosition(const sint32 posX, const sint32 posY, const int id)
|
||||||
|
{
|
||||||
|
x = posX;
|
||||||
|
y = posY;
|
||||||
|
region = id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class PixmapDatabase
|
@class PixmapDatabase
|
||||||
|
@ -59,8 +89,12 @@ public:
|
||||||
/// Get original pixmap
|
/// Get original pixmap
|
||||||
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
|
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
|
||||||
QPixmap *pixmap(const QString &zoneName) const;
|
QPixmap *pixmap(const QString &zoneName) const;
|
||||||
|
|
||||||
|
int textureSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
int m_textureSize;
|
||||||
QMap<QString, QPixmap*> m_pixmapMap;
|
QMap<QString, QPixmap*> m_pixmapMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,13 +108,37 @@ PixmapDatabase contains the graphics for the zones
|
||||||
class ZoneBuilder
|
class ZoneBuilder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZoneBuilder();
|
ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack);
|
||||||
~ZoneBuilder();
|
~ZoneBuilder();
|
||||||
|
|
||||||
// Init zoneBank and init zone pixmap database
|
/// Init zoneBank and init zone pixmap database
|
||||||
bool init(const QString &pathName, bool bMakeAZone);
|
bool init(const QString &pathName, bool bMakeAZone);
|
||||||
|
|
||||||
void newZone(bool bDisplay=true);
|
void calcMask();
|
||||||
|
void newZone();
|
||||||
|
bool getZoneMask (sint32 x, sint32 y);
|
||||||
|
bool getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
void addZone(sint32 posX, sint32 posY);
|
||||||
|
void addTransition(const sint32 posX, const sint32 posY);
|
||||||
|
void delZone(const sint32 posX, const sint32 posY);
|
||||||
|
|
||||||
|
// Zone Region
|
||||||
|
int createZoneRegion();
|
||||||
|
void deleteZoneRegion(int id);
|
||||||
|
void setCurrentZoneRegion(int id);
|
||||||
|
int currentIdZoneRegion() const;
|
||||||
|
ZoneRegionEditor *currentZoneRegion() const;
|
||||||
|
int countZoneRegion() const;
|
||||||
|
ZoneRegionEditor *zoneRegion(int id) const;
|
||||||
|
void ligoData(LigoData &data, const ZonePosition &zonePos);
|
||||||
|
void setLigoData(LigoData &data, const ZonePosition &zonePos);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
NLLIGO::CZoneBank &getZoneBank()
|
NLLIGO::CZoneBank &getZoneBank()
|
||||||
|
@ -94,15 +152,24 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Scan ./zoneligos dir and add all *.ligozone files to zoneBank
|
/// Scan ./zoneligos dir and add all *.ligozone files to zoneBank
|
||||||
bool initZoneBank (const QString &path);
|
bool initZoneBank (const QString &path);
|
||||||
|
|
||||||
sint32 m_minX, m_maxX, m_minY, m_maxY;
|
sint32 m_minX, m_maxX, m_minY, m_maxY;
|
||||||
|
std::vector<bool> m_zoneMask;
|
||||||
|
|
||||||
QString m_lastPathName;
|
QString m_lastPathName;
|
||||||
|
|
||||||
|
QList<ZoneRegionEditor *> m_zoneRegions;
|
||||||
|
int m_currentZoneRegion;
|
||||||
|
|
||||||
|
std::vector<BuilderZoneRegion *> m_builderZoneRegions;
|
||||||
|
|
||||||
PixmapDatabase *m_pixmapDatabase;
|
PixmapDatabase *m_pixmapDatabase;
|
||||||
NLLIGO::CZoneBank m_zoneBank;
|
NLLIGO::CZoneBank m_zoneBank;
|
||||||
std::vector<NLLIGO::CZoneBankElement*> m_currentSelection;
|
ListZonesWidget *m_listZonesWidget;
|
||||||
|
LandscapeScene *m_landscapeScene;
|
||||||
|
QUndoStack *m_undoStack;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,11 +22,79 @@
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/zone_bank.h>
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
class ZoneBuilder;
|
||||||
|
|
||||||
|
// CZoneRegion contains informations about the zones painted
|
||||||
|
class BuilderZoneRegion
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
BuilderZoneRegion(uint regionId);
|
||||||
|
|
||||||
|
// New interface
|
||||||
|
bool init(ZoneBuilder *zoneBuilder, std::string &error);
|
||||||
|
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);
|
||||||
|
bool addNotPropagate(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||||
|
|
||||||
|
/// Brutal adding a zone over empty space do not propagate in any way -> can result
|
||||||
|
/// in inconsistency when trying the propagation mode
|
||||||
|
void addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||||
|
void del(sint32 x, sint32 y, bool transition = false, void *pInternal = NULL);
|
||||||
|
void move(sint32 x, sint32 y);
|
||||||
|
uint32 countZones();
|
||||||
|
void reduceMin();
|
||||||
|
uint getRegionId() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// An element of the graph
|
||||||
|
struct SMatNode
|
||||||
|
{
|
||||||
|
std::string Name;
|
||||||
|
// Position in the tree (vector of nodes)
|
||||||
|
std::vector<uint32> Arcs;
|
||||||
|
};
|
||||||
|
|
||||||
|
void addTransition(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||||
|
|
||||||
|
void addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2);
|
||||||
|
|
||||||
|
void putTransitions(sint32 x, sint32 y, const NLLIGO::SPiece &mask, const std::string &matName, void *pInternal);
|
||||||
|
void updateTrans(sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement = NULL);
|
||||||
|
|
||||||
|
std::string getNextMatInTree(const std::string &matA, const std::string &matB);
|
||||||
|
|
||||||
|
/// Find the fastest way between posA and posB in the MatTree (Dijkstra)
|
||||||
|
void tryPath(uint32 posA, uint32 posB, std::vector<uint32> &path);
|
||||||
|
|
||||||
|
void set(sint32 x, sint32 y, sint32 posX, sint32 posY, const std::string &zoneName, bool transition=false);
|
||||||
|
void setRot(sint32 x, sint32 y, uint8 rot);
|
||||||
|
void setFlip(sint32 x, sint32 y, uint8 flip);
|
||||||
|
void resize(sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY);
|
||||||
|
|
||||||
|
uint m_regionId;
|
||||||
|
|
||||||
|
// To use the global mask
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
|
||||||
|
// The tree of transition between materials
|
||||||
|
std::vector<SMatNode> m_matTree;
|
||||||
|
|
||||||
|
bool m_firstInit;
|
||||||
|
};
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
|
|
@ -62,54 +62,111 @@ void NewLandscapeCommand::redo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLigoTileCommand::AddLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent)
|
LigoTileCommand::LigoTileCommand(const LigoData &data, const ZonePosition &zonePos,
|
||||||
|
ZoneBuilder *zoneBuilder, LandscapeScene *scene,
|
||||||
|
QUndoCommand *parent)
|
||||||
: QUndoCommand(parent),
|
: QUndoCommand(parent),
|
||||||
m_item(0),
|
m_zoneBuilder(zoneBuilder),
|
||||||
m_scene(scene)
|
m_scene(scene)
|
||||||
{
|
{
|
||||||
m_ligoData = data;
|
// Backup position
|
||||||
|
m_zonePos = zonePos;
|
||||||
|
|
||||||
|
// Backup new data
|
||||||
|
m_newLigoData = data;
|
||||||
|
|
||||||
|
// Backup old data
|
||||||
|
m_zoneBuilder->ligoData(m_oldLigoData, m_zonePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLigoTileCommand::~AddLigoTileCommand()
|
LigoTileCommand::~LigoTileCommand()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLigoTileCommand::undo()
|
void LigoTileCommand::undo ()
|
||||||
{
|
{
|
||||||
m_scene->removeItem(m_item);
|
m_zoneBuilder->setLigoData(m_oldLigoData, m_zonePos);
|
||||||
delete m_item;
|
m_scene->createZoneItem(m_oldLigoData, m_zonePos);
|
||||||
m_item = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLigoTileCommand::redo()
|
void LigoTileCommand::redo ()
|
||||||
{
|
{
|
||||||
m_item = m_scene->createZoneItem(m_ligoData);
|
m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos);
|
||||||
setText(QObject::tr("Add tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY));
|
m_scene->createZoneItem(m_newLigoData, m_zonePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
DelLigoTileCommand::DelLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent)
|
LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX,
|
||||||
|
sint32 newMinY, sint32 newMaxY, ZoneBuilder *zoneBuilder,
|
||||||
|
QUndoCommand *parent)
|
||||||
: QUndoCommand(parent),
|
: QUndoCommand(parent),
|
||||||
m_item(0),
|
m_zoneBuilder(zoneBuilder)
|
||||||
m_scene(scene)
|
|
||||||
{
|
{
|
||||||
m_ligoData = data;
|
m_index = index;
|
||||||
|
m_newMinX = newMinX;
|
||||||
|
m_newMaxX = newMaxX;
|
||||||
|
m_newMinY = newMinY;
|
||||||
|
m_newMaxY = newMaxY;
|
||||||
|
|
||||||
|
// Backup old region zone
|
||||||
|
m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
DelLigoTileCommand::~DelLigoTileCommand()
|
LigoResizeCommand::~LigoResizeCommand()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DelLigoTileCommand::undo()
|
void LigoResizeCommand::undo ()
|
||||||
{
|
{
|
||||||
m_item = m_scene->createZoneItem(m_ligoData);
|
// Restore old region zone
|
||||||
|
m_zoneBuilder->zoneRegion(m_index)->setZoneRegion(m_oldZoneRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DelLigoTileCommand::redo()
|
void LigoResizeCommand::redo ()
|
||||||
{
|
{
|
||||||
m_item = m_scene->itemAt(m_ligoData.PosX * m_scene->cellSize(), m_ligoData.PosY * m_scene->cellSize());
|
// Get the zone region
|
||||||
delete m_item;
|
NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion();
|
||||||
m_item = 0;
|
|
||||||
setText(QObject::tr("Del tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY));
|
sint32 i, j;
|
||||||
|
std::vector<LigoData> newZones;
|
||||||
|
newZones.resize((1 + m_newMaxX - m_newMinX) * (1 + m_newMaxY - m_newMinY));
|
||||||
|
|
||||||
|
sint32 newStride = 1 + m_newMaxX - m_newMinX;
|
||||||
|
sint32 Stride = 1 + region.getMaxX() - region.getMinX();
|
||||||
|
|
||||||
|
for (j = m_newMinY; j <= m_newMaxY; ++j)
|
||||||
|
for (i = m_newMinX; i <= m_newMaxX; ++i)
|
||||||
|
{
|
||||||
|
// Ref on the new value
|
||||||
|
LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride];
|
||||||
|
|
||||||
|
// In the old array ?
|
||||||
|
if ((i >= region.getMinX()) && (i <= region.getMaxX()) &&
|
||||||
|
(j >= region.getMinY()) && (j <= region.getMaxY()))
|
||||||
|
{
|
||||||
|
// Backup values
|
||||||
|
m_zoneBuilder->ligoData(data, ZonePosition(i, j, m_index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
region.resize(m_newMinX, m_newMaxX, m_newMinY, m_newMaxY);
|
||||||
|
|
||||||
|
for (j = m_newMinY; j <= m_newMaxY; ++j)
|
||||||
|
for (i = m_newMinX; i <= m_newMaxX; ++i)
|
||||||
|
{
|
||||||
|
// Ref on the new value
|
||||||
|
const LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride];
|
||||||
|
|
||||||
|
region.setName(i, j, data.zoneName);
|
||||||
|
region.setPosX(i, j, data.posX);
|
||||||
|
region.setPosY(i, j, data.posY);
|
||||||
|
region.setRot(i, j, data.rot);
|
||||||
|
region.setFlip(i, j, data.flip);
|
||||||
|
uint k;
|
||||||
|
for (k = 0; k < 4; k++)
|
||||||
|
{
|
||||||
|
region.setSharingMatNames(i, j, k, data.sharingMatNames[k]);
|
||||||
|
region.setSharingCutEdges(i, j, k, data.sharingCutEdges[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -56,36 +56,64 @@ public:
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class AddLigoTileCommand: public QUndoCommand
|
// Modify the landscape
|
||||||
|
class LigoTileCommand: public QUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AddLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent = 0);
|
LigoTileCommand(const LigoData &data, const ZonePosition &zonePos,
|
||||||
virtual ~AddLigoTileCommand();
|
ZoneBuilder *zoneBuilder, LandscapeScene *scene,
|
||||||
|
QUndoCommand *parent = 0);
|
||||||
|
virtual ~LigoTileCommand();
|
||||||
|
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ZonePosition m_zonePos;
|
||||||
LigoData m_ligoData;
|
LigoData m_newLigoData;
|
||||||
QGraphicsItem *m_item;
|
LigoData m_oldLigoData;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
LandscapeScene *m_scene;
|
LandscapeScene *m_scene;
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
class DelLigoTileCommand: public QUndoCommand
|
// Move the landscape
|
||||||
|
class LigoMoveCommand: public QUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DelLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent = 0);
|
|
||||||
virtual ~DelLigoTileCommand();
|
LigoMoveCommand(int index, sint32 deltaX, sint32 deltaY, ZoneBuilder *zoneBuilder, QUndoCommand *parent = 0);
|
||||||
|
virtual ~LigoMoveCommand();
|
||||||
|
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
private:
|
||||||
|
|
||||||
|
int m_index;
|
||||||
|
sint32 m_deltaX;
|
||||||
|
sint32 m_deltaY;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
// Modify the landscape
|
||||||
|
class LigoResizeCommand: public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX,
|
||||||
|
sint32 newMinY, sint32 newMaxY, ZoneBuilder *zoneBuilder,
|
||||||
|
QUndoCommand *parent = 0);
|
||||||
|
virtual ~LigoResizeCommand();
|
||||||
|
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int m_index;
|
||||||
LigoData m_ligoData;
|
sint32 m_newMinX;
|
||||||
QGraphicsItem *m_item;
|
sint32 m_newMaxX;
|
||||||
LandscapeScene *m_scene;
|
sint32 m_newMinY;
|
||||||
|
sint32 m_newMaxY;
|
||||||
|
NLLIGO::CZoneRegion m_oldZoneRegion;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "landscape_editor_window.h"
|
#include "landscape_editor_window.h"
|
||||||
#include "landscape_editor_constants.h"
|
#include "landscape_editor_constants.h"
|
||||||
#include "builder_zone.h"
|
#include "builder_zone.h"
|
||||||
|
#include "zone_region_editor.h"
|
||||||
#include "landscape_scene.h"
|
#include "landscape_scene.h"
|
||||||
#include "project_settings_dialog.h"
|
#include "project_settings_dialog.h"
|
||||||
#include "snapshot_dialog.h"
|
#include "snapshot_dialog.h"
|
||||||
|
@ -45,12 +46,14 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
m_zoneBuilder = new ZoneBuilder();
|
m_landscapeScene = new LandscapeScene(this);
|
||||||
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false);
|
|
||||||
|
m_zoneBuilder = new ZoneBuilder(m_ui.zoneListWidget, m_landscapeScene, m_undoStack);
|
||||||
|
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", true);
|
||||||
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||||
m_ui.zoneListWidget->updateUi();
|
m_ui.zoneListWidget->updateUi();
|
||||||
|
|
||||||
m_landscapeScene = new LandscapeScene(m_undoStack, m_ui.zoneListWidget, m_zoneBuilder, this);
|
m_landscapeScene->setZoneBuilder(m_zoneBuilder);
|
||||||
m_ui.graphicsView->setScene(m_landscapeScene);
|
m_ui.graphicsView->setScene(m_landscapeScene);
|
||||||
//m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer)));
|
//m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer)));
|
||||||
m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)));
|
m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)));
|
||||||
|
@ -88,11 +91,14 @@ void LandscapeEditorWindow::open()
|
||||||
_lastDir = QFileInfo(list.front()).absolutePath();
|
_lastDir = QFileInfo(list.front()).absolutePath();
|
||||||
Q_FOREACH(QString fileName, fileNames)
|
Q_FOREACH(QString fileName, fileNames)
|
||||||
{
|
{
|
||||||
m_zoneRegionEditor.load(fileName.toStdString());
|
int id = m_zoneBuilder->createZoneRegion();
|
||||||
m_landscapeScene->processZoneRegion(m_zoneRegionEditor.zoneRegion());
|
ZoneRegionEditor *zoneRegion = m_zoneBuilder->zoneRegion(id);
|
||||||
m_landscapeScene->setCurrentZoneRegion(&m_zoneRegionEditor.zoneRegion());
|
zoneRegion->load(fileName.toStdString());
|
||||||
m_ui.graphicsView->centerOn(m_zoneRegionEditor.zoneRegion().getMinX() * m_landscapeScene->cellSize(),
|
m_landscapeScene->processZoneRegion(zoneRegion->zoneRegion());
|
||||||
abs(m_zoneRegionEditor.zoneRegion().getMinY()) * m_landscapeScene->cellSize());
|
m_ui.graphicsView->centerOn(zoneRegion->zoneRegion().getMinX() * m_landscapeScene->cellSize(),
|
||||||
|
abs(zoneRegion->zoneRegion().getMinY()) * m_landscapeScene->cellSize());
|
||||||
|
|
||||||
|
m_zoneBuilder->setCurrentZoneRegion(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "ui_landscape_editor_window.h"
|
#include "ui_landscape_editor_window.h"
|
||||||
#include "zone_region_editor.h"
|
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QUndoStack>
|
#include <QtGui/QUndoStack>
|
||||||
|
@ -55,8 +54,6 @@ private:
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
ZoneRegionEditor m_zoneRegionEditor;
|
|
||||||
|
|
||||||
LandscapeScene *m_landscapeScene;
|
LandscapeScene *m_landscapeScene;
|
||||||
ZoneBuilder *m_zoneBuilder;
|
ZoneBuilder *m_zoneBuilder;
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_scene.h"
|
#include "landscape_scene.h"
|
||||||
#include "builder_zone.h"
|
|
||||||
#include "landscape_actions.h"
|
|
||||||
#include "list_zones_widget.h"
|
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
@ -32,12 +29,9 @@
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
LandscapeScene::LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZonesWidget, ZoneBuilder *zoneBuilder, QObject *parent)
|
LandscapeScene::LandscapeScene(QObject *parent)
|
||||||
: QGraphicsScene(parent),
|
: QGraphicsScene(parent),
|
||||||
m_undoStack(undoStack),
|
m_zoneBuilder(0)
|
||||||
m_listZonesWidget(listZonesWidget),
|
|
||||||
m_zoneBuilder(zoneBuilder),
|
|
||||||
m_zoneRegion(0)
|
|
||||||
{
|
{
|
||||||
m_cellSize = 160;
|
m_cellSize = 160;
|
||||||
}
|
}
|
||||||
|
@ -51,20 +45,34 @@ int LandscapeScene::cellSize() const
|
||||||
return m_cellSize;
|
return m_cellSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data)
|
void LandscapeScene::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
||||||
{
|
{
|
||||||
|
m_zoneBuilder = zoneBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data, const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
if (data.zoneName == STRING_UNUSED)
|
||||||
|
return createEmptyZoneItem(zonePos);
|
||||||
|
|
||||||
|
if ((m_zoneBuilder == 0) || (data.zoneName.empty()) ||
|
||||||
|
(data.posX != 0) || (data.posY != 0))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
checkUnderZone(data, zonePos);
|
||||||
|
|
||||||
// Get image from pixmap database
|
// Get image from pixmap database
|
||||||
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.ZoneName.c_str()));
|
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str()));
|
||||||
if (pixmap == 0)
|
if (pixmap == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Rotate the image counterclockwise
|
// Rotate the image counterclockwise
|
||||||
QMatrix matrix;
|
QMatrix matrix;
|
||||||
matrix.rotate(-data.Rot * 90.0);
|
matrix.rotate(-data.rot * 90.0);
|
||||||
|
|
||||||
QGraphicsPixmapItem *item;
|
QGraphicsPixmapItem *item;
|
||||||
|
|
||||||
if (data.Flip == 0)
|
if (data.flip == 0)
|
||||||
{
|
{
|
||||||
item = new QGraphicsPixmapItem(pixmap->transformed(matrix, Qt::SmoothTransformation), 0, this);
|
item = new QGraphicsPixmapItem(pixmap->transformed(matrix, Qt::SmoothTransformation), 0, this);
|
||||||
}
|
}
|
||||||
|
@ -79,58 +87,82 @@ QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data)
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
// Set position graphics item with offset for large piece
|
// Set position graphics item with offset for large piece
|
||||||
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.ZoneName);
|
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName);
|
||||||
item->setPos(data.PosX * m_cellSize, (abs(data.PosY) - zoneBankItem->getSizeY() + 1) * m_cellSize);
|
item->setPos(zonePos.x * m_cellSize, (abs(zonePos.y) - zoneBankItem->getSizeY() + 1) * m_cellSize);
|
||||||
|
|
||||||
// The size graphics item should be equal or proportional m_cellSize
|
// The size graphics item should be equal or proportional m_cellSize
|
||||||
item->setScale(m_cellSize / 256.0);
|
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
||||||
|
|
||||||
// add debug info
|
|
||||||
QGraphicsSimpleTextItem *itemText = addSimpleText(QString("%1,%2 R-%3 F-%4").
|
|
||||||
arg(data.PosX).arg(data.PosY).
|
|
||||||
arg(data.Rot * 90.0).
|
|
||||||
arg(data.Flip),
|
|
||||||
QFont("Helvetica [Cronyx]", 14));
|
|
||||||
|
|
||||||
itemText->setZValue(2);
|
|
||||||
itemText->setPos(data.PosX * m_cellSize + 10, (abs(data.PosY) - zoneBankItem->getSizeY() + 1) * m_cellSize + 10);
|
|
||||||
itemText->setBrush(QBrush(Qt::white));
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGraphicsItem *LandscapeScene::createEmptyZoneItem(const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
if (m_zoneBuilder == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
deleteZoneItem(zonePos);
|
||||||
|
|
||||||
|
// Get image from pixmap database
|
||||||
|
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
||||||
|
if (pixmap == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(*pixmap, 0, this);
|
||||||
|
|
||||||
|
// Enable bilinear filtering
|
||||||
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
|
// Set position graphics item
|
||||||
|
item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize);
|
||||||
|
|
||||||
|
// The size graphics item should be equal or proportional m_cellSize
|
||||||
|
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeScene::deleteZoneItem(const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize);
|
||||||
|
if (item != 0)
|
||||||
|
{
|
||||||
|
removeItem(item);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
{
|
{
|
||||||
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
||||||
{
|
{
|
||||||
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
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);
|
std::string zoneName = zoneRegion.getName(i, j);
|
||||||
if ((!zoneName.empty()) &&
|
if (zoneName == STRING_UNUSED)
|
||||||
(zoneName != STRING_UNUSED) &&
|
{
|
||||||
(zoneRegion.getPosX(i, j) == 0) &&
|
ZonePosition zonePos(i, j, -1);
|
||||||
(zoneRegion.getPosY(i, j) == 0))
|
QGraphicsItem *item = createEmptyZoneItem(zonePos);
|
||||||
|
}
|
||||||
|
else if (!zoneName.empty())
|
||||||
{
|
{
|
||||||
LigoData data;
|
LigoData data;
|
||||||
data.PosX = i;
|
ZonePosition zonePos(i, j, -1);
|
||||||
data.PosY = j;
|
data.zoneName = zoneName;
|
||||||
data.ZoneName = zoneName;
|
data.rot = zoneRegion.getRot(i, j);
|
||||||
data.Rot = zoneRegion.getRot(i, j);
|
data.flip = zoneRegion.getFlip(i, j);
|
||||||
data.Flip = zoneRegion.getFlip(i, j);
|
data.posX = zoneRegion.getPosX(i, j);
|
||||||
QGraphicsItem *item = createZoneItem(data);
|
data.posY = zoneRegion.getPosY(i, j);
|
||||||
|
QGraphicsItem *item = createZoneItem(data, zonePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::setCurrentZoneRegion(NLLIGO::CZoneRegion *zoneRegion)
|
|
||||||
{
|
|
||||||
m_zoneRegion = zoneRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LandscapeScene::snapshot(const QString &fileName, int sizeSource)
|
void LandscapeScene::snapshot(const QString &fileName, int sizeSource)
|
||||||
{
|
{
|
||||||
if (m_zoneRegion == 0)
|
/* if (m_zoneRegion == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sint32 regionMinX = m_zoneRegion->getMinX();
|
sint32 regionMinX = m_zoneRegion->getMinX();
|
||||||
|
@ -142,11 +174,15 @@ void LandscapeScene::snapshot(const QString &fileName, int sizeSource)
|
||||||
int regionHeight = (regionMaxY - regionMinY + 1);
|
int regionHeight = (regionMaxY - regionMinY + 1);
|
||||||
|
|
||||||
snapshot(fileName, regionWidth * sizeSource, regionHeight * sizeSource);
|
snapshot(fileName, regionWidth * sizeSource, regionHeight * sizeSource);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::snapshot(const QString &fileName, int width, int height)
|
void LandscapeScene::snapshot(const QString &fileName, int width, int height)
|
||||||
{
|
{
|
||||||
if (m_zoneRegion == 0)
|
if (m_zoneBuilder == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* if (m_zoneRegion == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sint32 regionMinX = m_zoneRegion->getMinX();
|
sint32 regionMinX = m_zoneRegion->getMinX();
|
||||||
|
@ -170,44 +206,37 @@ void LandscapeScene::snapshot(const QString &fileName, int width, int height)
|
||||||
QRectF(regionMinX * m_cellSize, abs(regionMaxY) * m_cellSize, regionWidth * m_cellSize, regionHeight * m_cellSize));
|
QRectF(regionMinX * m_cellSize, abs(regionMaxY) * m_cellSize, regionWidth * m_cellSize, regionHeight * m_cellSize));
|
||||||
|
|
||||||
image.save(fileName);
|
image.save(fileName);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
{
|
{
|
||||||
|
if (m_zoneBuilder == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
qreal x = mouseEvent->scenePos().rx();
|
qreal x = mouseEvent->scenePos().rx();
|
||||||
qreal y = mouseEvent->scenePos().ry();
|
qreal y = mouseEvent->scenePos().ry();
|
||||||
if ((x < 0) || (y < 0))
|
if ((x < 0) || (y < 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sint32 posX = sint32(floor(x / m_cellSize));
|
||||||
|
sint32 posY = sint32(-floor(y / m_cellSize));
|
||||||
|
|
||||||
if (mouseEvent->button() == Qt::LeftButton)
|
if (mouseEvent->button() == Qt::LeftButton)
|
||||||
{
|
m_zoneBuilder->addZone(posX, posY);
|
||||||
// Add new zone brick
|
else if (mouseEvent->button() == Qt::RightButton)
|
||||||
LigoData ligoData = m_listZonesWidget->currentLigoData();
|
m_zoneBuilder->delZone(posX, posY);
|
||||||
if (ligoData.ZoneName == "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
ligoData.PosX = int(floor(x / m_cellSize));
|
|
||||||
ligoData.PosY = int(-floor(y / m_cellSize));
|
|
||||||
|
|
||||||
AddLigoTileCommand *action = new AddLigoTileCommand(ligoData, this);
|
|
||||||
m_undoStack->push(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if (mouseEvent->button() == Qt::RightButton)
|
|
||||||
{
|
|
||||||
// Delete zone brick
|
|
||||||
LigoData ligoData;
|
|
||||||
|
|
||||||
ligoData.PosX = int(floor(x / m_cellSize));
|
|
||||||
ligoData.PosY = int(floor(y / m_cellSize));
|
|
||||||
ligoData.ZoneName = m_zoneRegion->getName(ligoData.PosX, -ligoData.PosY);
|
|
||||||
ligoData.Flip = m_zoneRegion->getFlip(ligoData.PosX, -ligoData.PosY);
|
|
||||||
ligoData.Rot = m_zoneRegion->getRot(ligoData.PosX, -ligoData.PosY);
|
|
||||||
DelLigoTileCommand *action = new DelLigoTileCommand(ligoData, this);
|
|
||||||
m_undoStack->push(action);
|
|
||||||
}*/
|
|
||||||
QGraphicsScene::mousePressEvent(mouseEvent);
|
QGraphicsScene::mousePressEvent(mouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LandscapeScene::checkUnderZone(const LigoData &data, const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
// NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName);
|
||||||
|
// uint8 sizeX = zoneBankItem->getSizeX();
|
||||||
|
// uint8 sizeY = zoneBankItem->getSizeY();
|
||||||
|
// std::vector<bool> &mask = zoneBankItem->getMask();
|
||||||
|
deleteZoneItem(zonePos);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#define LANDSCAPE_SCENE_H
|
#define LANDSCAPE_SCENE_H
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
|
#include "zone_region_editor.h"
|
||||||
|
#include "builder_zone.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/zone_region.h>
|
#include <nel/ligo/zone_region.h>
|
||||||
|
@ -26,54 +28,25 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QGraphicsScene>
|
#include <QtGui/QGraphicsScene>
|
||||||
#include <QtGui/QGraphicsSceneMouseEvent>
|
#include <QtGui/QGraphicsSceneMouseEvent>
|
||||||
#include <QtGui/QUndoStack>
|
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
class ZoneBuilder;
|
|
||||||
class ListZonesWidget;
|
|
||||||
|
|
||||||
// Data
|
|
||||||
struct LigoData
|
|
||||||
{
|
|
||||||
sint32 PosX;
|
|
||||||
sint32 PosY;
|
|
||||||
uint8 Rot;
|
|
||||||
uint8 Flip;
|
|
||||||
std::string ZoneName;
|
|
||||||
std::string SharingMatNames[4];
|
|
||||||
uint8 SharingCutEdges[4];
|
|
||||||
bool operator!= (const LigoData& other) const
|
|
||||||
{
|
|
||||||
return (PosX != other.PosX) ||
|
|
||||||
(PosY != other.PosY) ||
|
|
||||||
(Rot != other.Rot) ||
|
|
||||||
(Flip != other.Flip) ||
|
|
||||||
(ZoneName != other.ZoneName) ||
|
|
||||||
(SharingMatNames[0] != other.SharingMatNames[0]) ||
|
|
||||||
(SharingMatNames[1] != other.SharingMatNames[1]) ||
|
|
||||||
(SharingMatNames[2] != other.SharingMatNames[2]) ||
|
|
||||||
(SharingMatNames[3] != other.SharingMatNames[3]) ||
|
|
||||||
(SharingCutEdges[0] != other.SharingCutEdges[0]) ||
|
|
||||||
(SharingCutEdges[1] != other.SharingCutEdges[1]) ||
|
|
||||||
(SharingCutEdges[2] != other.SharingCutEdges[2]) ||
|
|
||||||
(SharingCutEdges[3] != other.SharingCutEdges[3]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class LandscapeScene : public QGraphicsScene
|
class LandscapeScene : public QGraphicsScene
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZonesWidget, ZoneBuilder *zoneBuilder, QObject *parent = 0);
|
LandscapeScene(QObject *parent = 0);
|
||||||
virtual ~LandscapeScene();
|
virtual ~LandscapeScene();
|
||||||
|
|
||||||
int cellSize() const;
|
int cellSize() const;
|
||||||
|
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
||||||
|
|
||||||
QGraphicsItem *createZoneItem(const LigoData &data);
|
QGraphicsItem *createZoneItem(const LigoData &data, const ZonePosition &zonePos);
|
||||||
|
QGraphicsItem *createEmptyZoneItem(const ZonePosition &zonePos);
|
||||||
|
void deleteZoneItem(const ZonePosition &zonePos);
|
||||||
void processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
void processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||||
void setCurrentZoneRegion(NLLIGO::CZoneRegion *zoneRegion);
|
|
||||||
|
|
||||||
void snapshot(const QString &fileName, int sizeSource);
|
void snapshot(const QString &fileName, int sizeSource);
|
||||||
void snapshot(const QString &fileName, int width, int height);
|
void snapshot(const QString &fileName, int width, int height);
|
||||||
|
@ -82,12 +55,10 @@ protected:
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void checkUnderZone(const LigoData &data, const ZonePosition &zonePos);
|
||||||
|
|
||||||
int m_cellSize;
|
int m_cellSize;
|
||||||
ListZonesWidget *m_listZonesWidget;
|
|
||||||
QUndoStack *m_undoStack;
|
|
||||||
ZoneBuilder *m_zoneBuilder;
|
ZoneBuilder *m_zoneBuilder;
|
||||||
NLLIGO::CZoneRegion *m_zoneRegion;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "list_zones_widget.h"
|
#include "list_zones_widget.h"
|
||||||
#include "list_zones_model.h"
|
#include "list_zones_model.h"
|
||||||
|
#include "builder_zone.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
@ -100,17 +101,34 @@ void ListZonesWidget::updateUi()
|
||||||
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
||||||
}
|
}
|
||||||
|
|
||||||
LigoData ListZonesWidget::currentLigoData() const
|
QString ListZonesWidget::currentZoneName() const
|
||||||
{
|
{
|
||||||
LigoData ligoData;
|
QString zoneName = "";
|
||||||
ligoData.ZoneName = "";
|
|
||||||
QModelIndex index = m_ui.listView->currentIndex();
|
QModelIndex index = m_ui.listView->currentIndex();
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
ligoData.ZoneName = index.data().toString().toStdString();
|
zoneName = index.data().toString();
|
||||||
|
|
||||||
ligoData.Rot = m_ui.rotComboBox->currentIndex();
|
return zoneName;
|
||||||
ligoData.Flip = m_ui.flipComboBox->currentIndex();
|
}
|
||||||
return ligoData;
|
|
||||||
|
int ListZonesWidget::currentRot() const
|
||||||
|
{
|
||||||
|
return m_ui.rotComboBox->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ListZonesWidget::currentFlip() const
|
||||||
|
{
|
||||||
|
return m_ui.flipComboBox->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ListZonesWidget::isNotPropogate() const
|
||||||
|
{
|
||||||
|
return m_ui.propogateCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ListZonesWidget::isForce() const
|
||||||
|
{
|
||||||
|
return m_ui.forceCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "ui_list_zones_widget.h"
|
#include "ui_list_zones_widget.h"
|
||||||
#include "builder_zone.h"
|
|
||||||
#include "landscape_scene.h"
|
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
|
|
||||||
|
@ -30,6 +28,7 @@
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
class ListZonesModel;
|
class ListZonesModel;
|
||||||
|
class ZoneBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class ZoneListWidget
|
@class ZoneListWidget
|
||||||
|
@ -46,7 +45,11 @@ public:
|
||||||
|
|
||||||
void updateUi();
|
void updateUi();
|
||||||
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
||||||
LigoData currentLigoData() const;
|
QString currentZoneName() const;
|
||||||
|
int currentRot() const;
|
||||||
|
int currentFlip() const;
|
||||||
|
bool isNotPropogate() const;
|
||||||
|
bool isForce() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
|
|
@ -30,6 +30,23 @@
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
LigoData::LigoData()
|
||||||
|
{
|
||||||
|
posX = 0;
|
||||||
|
posY = 0;
|
||||||
|
zoneName = "";
|
||||||
|
rot = 0;
|
||||||
|
flip = 0;
|
||||||
|
sharingMatNames[0] = "";
|
||||||
|
sharingMatNames[1] = "";
|
||||||
|
sharingMatNames[2] = "";
|
||||||
|
sharingMatNames[3] = "";
|
||||||
|
sharingCutEdges[0] = 0;
|
||||||
|
sharingCutEdges[1] = 0;
|
||||||
|
sharingCutEdges[2] = 0;
|
||||||
|
sharingCutEdges[3] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ZoneRegionEditor::ZoneRegionEditor()
|
ZoneRegionEditor::ZoneRegionEditor()
|
||||||
{
|
{
|
||||||
m_fileName = "";
|
m_fileName = "";
|
||||||
|
@ -111,9 +128,58 @@ void ZoneRegionEditor::setFileName(const std::string &fileName)
|
||||||
m_fileName = fileName;
|
m_fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneRegionEditor::ligoData(LigoData &data, const sint32 x, const sint32 y)
|
||||||
|
{
|
||||||
|
nlassert((x >= m_zoneRegion.getMinX()) &&
|
||||||
|
(x <= m_zoneRegion.getMaxX()) &&
|
||||||
|
(y >= m_zoneRegion.getMinY()) &&
|
||||||
|
(y <= m_zoneRegion.getMaxY()));
|
||||||
|
|
||||||
|
data.posX = m_zoneRegion.getPosX(x, y);
|
||||||
|
data.posY = m_zoneRegion.getPosY(x, y);
|
||||||
|
data.zoneName = m_zoneRegion.getName(x, y);
|
||||||
|
data.rot = m_zoneRegion.getRot(x, y);
|
||||||
|
data.flip = m_zoneRegion.getFlip(x, y);
|
||||||
|
data.sharingMatNames[0] = m_zoneRegion.getSharingMatNames(x, y, 0);
|
||||||
|
data.sharingMatNames[1] = m_zoneRegion.getSharingMatNames(x, y, 1);
|
||||||
|
data.sharingMatNames[2] = m_zoneRegion.getSharingMatNames(x, y, 2);
|
||||||
|
data.sharingMatNames[3] = m_zoneRegion.getSharingMatNames(x, y, 3);
|
||||||
|
data.sharingCutEdges[0] = m_zoneRegion.getSharingCutEdges(x, y, 0);
|
||||||
|
data.sharingCutEdges[1] = m_zoneRegion.getSharingCutEdges(x, y, 1);
|
||||||
|
data.sharingCutEdges[2] = m_zoneRegion.getSharingCutEdges(x, y, 2);
|
||||||
|
data.sharingCutEdges[3] = m_zoneRegion.getSharingCutEdges(x, y, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneRegionEditor::setLigoData(const LigoData &data, const sint32 x, const sint32 y)
|
||||||
|
{
|
||||||
|
nlassert((x >= m_zoneRegion.getMinX()) &&
|
||||||
|
(x <= m_zoneRegion.getMaxX()) &&
|
||||||
|
(y >= m_zoneRegion.getMinY()) &&
|
||||||
|
(y <= m_zoneRegion.getMaxY()));
|
||||||
|
|
||||||
|
m_zoneRegion.setPosX(x, y, data.posX);
|
||||||
|
m_zoneRegion.setPosY(x, y, data.posY);
|
||||||
|
m_zoneRegion.setName(x, y, data.zoneName);
|
||||||
|
m_zoneRegion.setRot(x, y, data.rot);
|
||||||
|
m_zoneRegion.setFlip(x, y, data.flip);
|
||||||
|
m_zoneRegion.setSharingMatNames(x, y, 0, data.sharingMatNames[0]);
|
||||||
|
m_zoneRegion.setSharingMatNames(x, y, 1, data.sharingMatNames[1]);
|
||||||
|
m_zoneRegion.setSharingMatNames(x, y, 2, data.sharingMatNames[2]);
|
||||||
|
m_zoneRegion.setSharingMatNames(x, y, 3, data.sharingMatNames[3]);
|
||||||
|
m_zoneRegion.setSharingCutEdges(x, y, 0, data.sharingCutEdges[0]);
|
||||||
|
m_zoneRegion.setSharingCutEdges(x, y, 1, data.sharingCutEdges[1]);
|
||||||
|
m_zoneRegion.setSharingCutEdges(x, y, 2, data.sharingCutEdges[2]);
|
||||||
|
m_zoneRegion.setSharingCutEdges(x, y, 3, data.sharingCutEdges[3]);
|
||||||
|
}
|
||||||
|
|
||||||
NLLIGO::CZoneRegion &ZoneRegionEditor::zoneRegion()
|
NLLIGO::CZoneRegion &ZoneRegionEditor::zoneRegion()
|
||||||
{
|
{
|
||||||
return m_zoneRegion;
|
return m_zoneRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneRegionEditor::setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
|
{
|
||||||
|
m_zoneRegion = zoneRegion;
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -32,6 +32,36 @@
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct LigoData
|
||||||
|
{
|
||||||
|
uint8 posX;
|
||||||
|
uint8 posY;
|
||||||
|
uint8 rot;
|
||||||
|
uint8 flip;
|
||||||
|
std::string zoneName;
|
||||||
|
std::string sharingMatNames[4];
|
||||||
|
uint8 sharingCutEdges[4];
|
||||||
|
|
||||||
|
LigoData();
|
||||||
|
|
||||||
|
bool operator!= (const LigoData& other) const
|
||||||
|
{
|
||||||
|
return (posX != other.posX) ||
|
||||||
|
(posY != other.posY) ||
|
||||||
|
(rot != other.rot) ||
|
||||||
|
(flip != other.flip) ||
|
||||||
|
(zoneName != other.zoneName) ||
|
||||||
|
(sharingMatNames[0] != other.sharingMatNames[0]) ||
|
||||||
|
(sharingMatNames[1] != other.sharingMatNames[1]) ||
|
||||||
|
(sharingMatNames[2] != other.sharingMatNames[2]) ||
|
||||||
|
(sharingMatNames[3] != other.sharingMatNames[3]) ||
|
||||||
|
(sharingCutEdges[0] != other.sharingCutEdges[0]) ||
|
||||||
|
(sharingCutEdges[1] != other.sharingCutEdges[1]) ||
|
||||||
|
(sharingCutEdges[2] != other.sharingCutEdges[2]) ||
|
||||||
|
(sharingCutEdges[3] != other.sharingCutEdges[3]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ZoneRegionEditor
|
class ZoneRegionEditor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -44,11 +74,17 @@ public:
|
||||||
// Save landscape data to file
|
// Save landscape data to file
|
||||||
bool save();
|
bool save();
|
||||||
|
|
||||||
|
void ligoData(LigoData &data, const sint32 x, const sint32 y);
|
||||||
|
|
||||||
|
void setLigoData(const LigoData &data, const sint32 x, const sint32 y);
|
||||||
|
|
||||||
// Set file name
|
// Set file name
|
||||||
void setFileName(const std::string &fileName);
|
void setFileName(const std::string &fileName);
|
||||||
|
|
||||||
NLLIGO::CZoneRegion &zoneRegion();
|
NLLIGO::CZoneRegion &zoneRegion();
|
||||||
|
|
||||||
|
void setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_modified;
|
bool m_modified;
|
||||||
|
|
Loading…
Reference in a new issue