Fixed: #1301 Now works correctly with translucent tiles.
This commit is contained in:
parent
b9732cb5bb
commit
e809eba015
4 changed files with 43 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -100,14 +99,15 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo
|
||||||
// Enable bilinear filtering
|
// Enable bilinear filtering
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName);
|
sint32 sizeX = 1, sizeY = 1;
|
||||||
|
sizeX = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
||||||
|
sizeY = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
||||||
|
|
||||||
sint32 deltaX = 0, deltaY = 0;
|
sint32 deltaX = 0, deltaY = 0;
|
||||||
|
|
||||||
// Calculate offset for graphics item (for items with size that are larger than 1)
|
// Calculate offset for graphics item (for items with size that are larger than 1)
|
||||||
if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1))
|
if ((sizeX > 1) || (sizeY > 1))
|
||||||
{
|
{
|
||||||
sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY();
|
|
||||||
if (data.flip == 0)
|
if (data.flip == 0)
|
||||||
{
|
{
|
||||||
switch (data.rot)
|
switch (data.rot)
|
||||||
|
@ -165,6 +165,8 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_ZONES);
|
item->setZValue(LAYER_ZONES);
|
||||||
|
|
||||||
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
||||||
|
|
||||||
// Get image from pixmap database
|
// Get image from pixmap database
|
||||||
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
||||||
|
|
||||||
if (pixmap == 0)
|
if (pixmap == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -195,6 +198,8 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_EMPTY_ZONES);
|
item->setZValue(LAYER_EMPTY_ZONES);
|
||||||
|
|
||||||
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,14 +97,15 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo
|
||||||
// Enable bilinear filtering
|
// Enable bilinear filtering
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilderBase->getZoneBank().getElementByZoneName(data.zoneName);
|
sint32 sizeX = 1, sizeY = 1;
|
||||||
|
sizeX = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
||||||
|
sizeY = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
||||||
|
|
||||||
sint32 deltaX = 0, deltaY = 0;
|
sint32 deltaX = 0, deltaY = 0;
|
||||||
|
|
||||||
// Calculate offset for graphics item (for items with size that are larger than 1)
|
// Calculate offset for graphics item (for items with size that are larger than 1)
|
||||||
if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1))
|
if ((sizeX > 1) || (sizeY > 1))
|
||||||
{
|
{
|
||||||
sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY();
|
|
||||||
if (data.flip == 0)
|
if (data.flip == 0)
|
||||||
{
|
{
|
||||||
switch (data.rot)
|
switch (data.rot)
|
||||||
|
@ -162,6 +163,8 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_ZONES);
|
item->setZValue(LAYER_ZONES);
|
||||||
|
|
||||||
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +195,8 @@ QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zoneP
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_EMPTY_ZONES);
|
item->setZValue(LAYER_EMPTY_ZONES);
|
||||||
|
|
||||||
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QtGui/QProgressDialog>
|
#include <QtGui/QProgressDialog>
|
||||||
|
@ -35,12 +36,23 @@ namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
PixmapDatabase::PixmapDatabase(int textureSize)
|
PixmapDatabase::PixmapDatabase(int textureSize)
|
||||||
: m_textureSize(textureSize)
|
: m_textureSize(textureSize),
|
||||||
|
m_errorPixmap(0)
|
||||||
{
|
{
|
||||||
|
m_errorPixmap = new QPixmap(QSize(m_textureSize, m_textureSize));
|
||||||
|
QPainter painter(m_errorPixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
painter.fillRect(m_errorPixmap->rect(), QBrush(QColor(Qt::black)));
|
||||||
|
painter.setFont(QFont("Helvetica [Cronyx]", 14));
|
||||||
|
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
||||||
|
painter.drawText(m_errorPixmap->rect(), Qt::AlignCenter | Qt::TextWordWrap,
|
||||||
|
QObject::tr("Pixmap and LIGO files not found. Set the correct data path and reload landscape."));
|
||||||
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
PixmapDatabase::~PixmapDatabase()
|
PixmapDatabase::~PixmapDatabase()
|
||||||
{
|
{
|
||||||
|
delete m_errorPixmap;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +85,19 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon
|
||||||
if (pixmap->isNull())
|
if (pixmap->isNull())
|
||||||
{
|
{
|
||||||
// Generate filled pixmap
|
// Generate filled pixmap
|
||||||
|
QPixmap *emptyPixmap = new QPixmap(QSize(sizeX * m_textureSize, sizeY * m_textureSize));
|
||||||
|
QPainter painter(emptyPixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
painter.fillRect(emptyPixmap->rect(), QBrush(QColor(Qt::black)));
|
||||||
|
painter.setFont(QFont("Helvetica [Cronyx]", 18));
|
||||||
|
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
||||||
|
painter.drawText(emptyPixmap->rect(), Qt::AlignCenter, QObject::tr("Pixmap not found"));
|
||||||
|
painter.end();
|
||||||
|
delete pixmap;
|
||||||
|
m_pixmapMap.insert(zonePixmapName, emptyPixmap);
|
||||||
}
|
}
|
||||||
// All pixmaps must be have same size
|
// All pixmaps must be have same size
|
||||||
if (pixmap->width() != sizeX * m_textureSize)
|
else if (pixmap->width() != sizeX * m_textureSize)
|
||||||
{
|
{
|
||||||
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
|
@ -114,7 +136,7 @@ QStringList PixmapDatabase::listPixmaps() const
|
||||||
|
|
||||||
QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const
|
QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const
|
||||||
{
|
{
|
||||||
QPixmap *result = 0;
|
QPixmap *result = m_errorPixmap;
|
||||||
if (!m_pixmapMap.contains(zoneName))
|
if (!m_pixmapMap.contains(zoneName))
|
||||||
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -61,6 +60,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int m_textureSize;
|
int m_textureSize;
|
||||||
|
QPixmap *m_errorPixmap;
|
||||||
QMap<QString, QPixmap *> m_pixmapMap;
|
QMap<QString, QPixmap *> m_pixmapMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue