mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 12:50:53 +00:00
merge from default
This commit is contained in:
commit
a119bd4ecf
32 changed files with 6543 additions and 11 deletions
|
@ -19,14 +19,15 @@
|
||||||
|
|
||||||
#include "nel/ligo/zone_bank.h"
|
#include "nel/ligo/zone_bank.h"
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
|
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
#include "nel/misc/file.h"
|
#include "nel/misc/file.h"
|
||||||
#include "nel/misc/i_xml.h"
|
#include "nel/misc/i_xml.h"
|
||||||
#include "nel/misc/o_xml.h"
|
#include "nel/misc/o_xml.h"
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#endif // NL_OS_WINDOWS
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
@ -496,8 +497,9 @@ void CZoneBank::reset ()
|
||||||
_Selection.clear ();
|
_Selection.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
bool CZoneBank::initFromPath(const string &sPathName, std::string &error)
|
bool CZoneBank::initFromPath(const std::string &sPathName, std::string &error)
|
||||||
{
|
{
|
||||||
char sDirBackup[512];
|
char sDirBackup[512];
|
||||||
GetCurrentDirectory (512, sDirBackup);
|
GetCurrentDirectory (512, sDirBackup);
|
||||||
|
@ -520,6 +522,7 @@ bool CZoneBank::initFromPath(const string &sPathName, std::string &error)
|
||||||
SetCurrentDirectory (sDirBackup);
|
SetCurrentDirectory (sDirBackup);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif // NL_OS_WINDOWS
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
bool CZoneBank::addElement (const std::string &elementName, std::string &error)
|
bool CZoneBank::addElement (const std::string &elementName, std::string &error)
|
||||||
|
@ -694,6 +697,4 @@ void CZoneBank::getSelection (std::vector<CZoneBankElement*> &SelectedElements)
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
} // namespace NLLIGO
|
} // namespace NLLIGO
|
||||||
|
|
||||||
#endif // NL_OS_WINDOWS
|
|
|
@ -11,9 +11,18 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h
|
||||||
landscape_editor_window.h
|
landscape_editor_window.h
|
||||||
|
landscape_scene.h
|
||||||
|
list_zones_model.h
|
||||||
|
list_zones_widget.h
|
||||||
|
landscape_view.h
|
||||||
|
project_settings_dialog.h
|
||||||
|
snapshot_dialog.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui
|
||||||
|
list_zones_widget.ui
|
||||||
|
project_settings_dialog.ui
|
||||||
|
shapshot_dialog.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc)
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc)
|
||||||
|
@ -37,7 +46,7 @@ ADD_LIBRARY(ovqt_plugin_landscape_editor MODULE ${SRC}
|
||||||
${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS}
|
${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS}
|
||||||
${OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS})
|
${OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
|
TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d nelgeorges nelligo ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
|
||||||
|
|
||||||
NL_DEFAULT_PROPS(ovqt_plugin_landscape_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Landscape Editor")
|
NL_DEFAULT_PROPS(ovqt_plugin_landscape_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Landscape Editor")
|
||||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_landscape_editor)
|
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_landscape_editor)
|
||||||
|
|
|
@ -0,0 +1,456 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "builder_zone.h"
|
||||||
|
#include "list_zones_widget.h"
|
||||||
|
#include "landscape_actions.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
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 = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneBuilder::~ZoneBuilder()
|
||||||
|
{
|
||||||
|
delete m_pixmapDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneBuilder::init(const QString &pathName, bool makeAZone)
|
||||||
|
{
|
||||||
|
bool bRet = true;
|
||||||
|
if (pathName != m_lastPathName)
|
||||||
|
{
|
||||||
|
m_lastPathName = pathName;
|
||||||
|
QString zoneBankPath = pathName;
|
||||||
|
zoneBankPath += "/zoneligos/";
|
||||||
|
|
||||||
|
// Init the ZoneBank
|
||||||
|
m_zoneBank.reset ();
|
||||||
|
if (!initZoneBank (zoneBankPath))
|
||||||
|
{
|
||||||
|
m_zoneBank.reset ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Construct the DataBase from the ZoneBank
|
||||||
|
QString zoneBitmapPath = pathName;
|
||||||
|
zoneBitmapPath += "/zonebitmaps/";
|
||||||
|
m_pixmapDatabase->reset();
|
||||||
|
if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank))
|
||||||
|
{
|
||||||
|
m_zoneBank.reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((makeAZone) && (bRet))
|
||||||
|
createZoneRegion();
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
m_undoStack->push(new LigoTileCommand(data, zonePos, this, m_landscapeScene));
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::addZone(sint32 posX, sint32 posY)
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
BuilderZoneRegion *builderZoneRegion = m_landscapeItems.at(m_currentZoneRegion).builderZoneRegion;
|
||||||
|
builderZoneRegion->init(this);
|
||||||
|
|
||||||
|
uint8 rot = uint8(m_listZonesWidget->currentRot());
|
||||||
|
uint8 flip = uint8(m_listZonesWidget->currentFlip());
|
||||||
|
|
||||||
|
NLLIGO::CZoneBankElement *zoneBankElement = getZoneBank().getElementByZoneName(zoneName);
|
||||||
|
|
||||||
|
m_titleAction = QString("Add zone %1,%2").arg(posX).arg(posY);
|
||||||
|
m_createdAction = false;
|
||||||
|
m_zonePositionList.clear();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
checkEndMacro();
|
||||||
|
}
|
||||||
|
|
||||||
|
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_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_landscapeItems.at(m_currentZoneRegion).builderZoneRegion;
|
||||||
|
|
||||||
|
builderZoneRegion->init(this);
|
||||||
|
builderZoneRegion->del(posX, posY);
|
||||||
|
checkEndMacro();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZoneBuilder::createZoneRegion()
|
||||||
|
{
|
||||||
|
int newId = m_landscapeItems.size();
|
||||||
|
LandscapeItem landItem;
|
||||||
|
landItem.zoneRegionObject = new ZoneRegionObject();
|
||||||
|
landItem.builderZoneRegion = new BuilderZoneRegion(newId);
|
||||||
|
landItem.builderZoneRegion->init(this);
|
||||||
|
landItem.rectItem = 0;
|
||||||
|
|
||||||
|
newZone();
|
||||||
|
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 < int(m_landscapeItems.size())))
|
||||||
|
{
|
||||||
|
if (m_landscapeItems.at(id).rectItem != 0)
|
||||||
|
delete m_landscapeItems.at(id).rectItem;
|
||||||
|
m_landscapeScene->delZoneRegion(m_landscapeItems.at(id).zoneRegionObject->ligoZoneRegion());
|
||||||
|
delete m_landscapeItems.at(id).zoneRegionObject;
|
||||||
|
delete m_landscapeItems.at(id).builderZoneRegion;
|
||||||
|
m_landscapeItems.erase(m_landscapeItems.begin() + id);
|
||||||
|
calcMask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::setCurrentZoneRegion(int id)
|
||||||
|
{
|
||||||
|
if ((0 <= id) && (id < int(m_landscapeItems.size())))
|
||||||
|
{
|
||||||
|
if (currentIdZoneRegion() != -1)
|
||||||
|
{
|
||||||
|
NLLIGO::CZoneRegion &ligoRegion = m_landscapeItems.at(m_currentZoneRegion).zoneRegionObject->ligoZoneRegion();
|
||||||
|
m_landscapeItems.at(m_currentZoneRegion).rectItem = m_landscapeScene->createLayerBlackout(ligoRegion);
|
||||||
|
}
|
||||||
|
delete m_landscapeItems.at(id).rectItem;
|
||||||
|
m_landscapeItems.at(id).rectItem = 0;
|
||||||
|
m_currentZoneRegion = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZoneBuilder::currentIdZoneRegion() const
|
||||||
|
{
|
||||||
|
return m_currentZoneRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneRegionObject *ZoneBuilder::currentZoneRegion() const
|
||||||
|
{
|
||||||
|
return m_landscapeItems.at(m_currentZoneRegion).zoneRegionObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZoneBuilder::countZoneRegion() const
|
||||||
|
{
|
||||||
|
return m_landscapeItems.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneRegionObject *ZoneBuilder::zoneRegion(int id) const
|
||||||
|
{
|
||||||
|
return m_landscapeItems.at(id).zoneRegionObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
m_landscapeItems.at(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::setLigoData(LigoData &data, const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
m_landscapeItems.at(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneBuilder::initZoneBank (const QString &pathName)
|
||||||
|
{
|
||||||
|
QDir *dir = new QDir(pathName);
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.ligozone";
|
||||||
|
|
||||||
|
// Find all ligozone files in dir
|
||||||
|
QStringList listFiles = dir->entryList(filters, QDir::Files);
|
||||||
|
|
||||||
|
std::string error;
|
||||||
|
Q_FOREACH(QString file, listFiles)
|
||||||
|
{
|
||||||
|
//nlinfo(file.toStdString().c_str());
|
||||||
|
if (!m_zoneBank.addElement((pathName + file).toStdString(), error))
|
||||||
|
QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
delete dir;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PixmapDatabase *ZoneBuilder::pixmapDatabase() const
|
||||||
|
{
|
||||||
|
return m_pixmapDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ZoneBuilder::dataPath() const
|
||||||
|
{
|
||||||
|
return m_lastPathName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::newZone()
|
||||||
|
{
|
||||||
|
// 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 (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
++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 x, y;
|
||||||
|
|
||||||
|
m_minY = m_minX = 1000000;
|
||||||
|
m_maxY = m_maxX = -1000000;
|
||||||
|
|
||||||
|
if (m_landscapeItems.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||||
|
{
|
||||||
|
const NLLIGO::CZoneRegion ®ion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion();
|
||||||
|
|
||||||
|
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 (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||||
|
if (int(i) != m_currentZoneRegion)
|
||||||
|
{
|
||||||
|
const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->ligoZoneRegion();
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < m_landscapeItems.size(); ++i)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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())->ligoZoneRegion();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::checkBeginMacro()
|
||||||
|
{
|
||||||
|
if (!m_createdAction)
|
||||||
|
{
|
||||||
|
m_createdAction = true;
|
||||||
|
m_undoStack->beginMacro(m_titleAction);
|
||||||
|
m_undoScanRegionCommand = new UndoScanRegionCommand(this, m_landscapeScene);
|
||||||
|
m_undoStack->push(m_undoScanRegionCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneBuilder::checkEndMacro()
|
||||||
|
{
|
||||||
|
if (m_createdAction)
|
||||||
|
{
|
||||||
|
RedoScanRegionCommand *redoScanRegionCommand = new RedoScanRegionCommand(this, m_landscapeScene);
|
||||||
|
m_undoScanRegionCommand->setScanList(m_zonePositionList);
|
||||||
|
redoScanRegionCommand->setScanList(m_zonePositionList);
|
||||||
|
m_undoStack->push(redoScanRegionCommand);
|
||||||
|
m_undoStack->endMacro();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 */
|
|
@ -0,0 +1,169 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef BUILDER_ZONE_H
|
||||||
|
#define BUILDER_ZONE_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "builder_zone_region.h"
|
||||||
|
#include "zone_region_editor.h"
|
||||||
|
#include "pixmap_database.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtGui/QPixmap>
|
||||||
|
#include <QtGui/QUndoStack>
|
||||||
|
#include <QtGui/QGraphicsRectItem>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
class ListZonesWidget;
|
||||||
|
class LandscapeScene;
|
||||||
|
class UndoScanRegionCommand;
|
||||||
|
|
||||||
|
// 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 ZoneBuilder
|
||||||
|
@brief ZoneBuilder contains all the shared data between the tools and the engine.
|
||||||
|
@details ZoneBank contains the macro zones that is composed of several zones plus a mask.
|
||||||
|
PixmapDatabase contains the graphics for the zones
|
||||||
|
*/
|
||||||
|
class ZoneBuilder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget = 0, QUndoStack *undoStack = 0);
|
||||||
|
~ZoneBuilder();
|
||||||
|
|
||||||
|
/// Init zoneBank and init zone pixmap database
|
||||||
|
bool init(const QString &pathName, bool bMakeAZone);
|
||||||
|
|
||||||
|
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();
|
||||||
|
int createZoneRegion(const QString &fileName);
|
||||||
|
void deleteZoneRegion(int id);
|
||||||
|
void setCurrentZoneRegion(int id);
|
||||||
|
int currentIdZoneRegion() const;
|
||||||
|
ZoneRegionObject *currentZoneRegion() const;
|
||||||
|
int countZoneRegion() const;
|
||||||
|
ZoneRegionObject *zoneRegion(int id) const;
|
||||||
|
void ligoData(LigoData &data, const ZonePosition &zonePos);
|
||||||
|
void setLigoData(LigoData &data, const ZonePosition &zonePos);
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
NLLIGO::CZoneBank &getZoneBank()
|
||||||
|
{
|
||||||
|
return m_zoneBank;
|
||||||
|
}
|
||||||
|
|
||||||
|
PixmapDatabase *pixmapDatabase() const;
|
||||||
|
|
||||||
|
QString dataPath() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/// Scan ./zoneligos dir and add all *.ligozone files to zoneBank
|
||||||
|
bool initZoneBank (const QString &path);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
int m_currentZoneRegion;
|
||||||
|
std::vector<LandscapeItem> m_landscapeItems;
|
||||||
|
|
||||||
|
bool m_createdAction;
|
||||||
|
QString m_titleAction;
|
||||||
|
QList<ZonePosition> m_zonePositionList;
|
||||||
|
UndoScanRegionCommand *m_undoScanRegionCommand;
|
||||||
|
|
||||||
|
PixmapDatabase *m_pixmapDatabase;
|
||||||
|
NLLIGO::CZoneBank m_zoneBank;
|
||||||
|
ListZonesWidget *m_listZonesWidget;
|
||||||
|
LandscapeScene *m_landscapeScene;
|
||||||
|
QUndoStack *m_undoStack;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // BUILDER_ZONE_H
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,101 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef BUILDER_ZONE_REGION_H
|
||||||
|
#define BUILDER_ZONE_REGION_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
class ZoneBuilder;
|
||||||
|
|
||||||
|
// CZoneRegion contains informations about the zones painted
|
||||||
|
class BuilderZoneRegion
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
BuilderZoneRegion(uint regionId);
|
||||||
|
|
||||||
|
// New interface
|
||||||
|
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);
|
||||||
|
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 */
|
||||||
|
|
||||||
|
#endif // BUILDER_ZONE_REGION_H
|
|
@ -0,0 +1,236 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "landscape_actions.h"
|
||||||
|
#include "builder_zone.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
OpenLandscapeCommand::OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent)
|
||||||
|
: QUndoCommand(parent),
|
||||||
|
m_fileName(fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenLandscapeCommand::~OpenLandscapeCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenLandscapeCommand::undo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenLandscapeCommand::redo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NewLandscapeCommand::NewLandscapeCommand(QUndoCommand *parent)
|
||||||
|
: QUndoCommand(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NewLandscapeCommand::~NewLandscapeCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewLandscapeCommand::undo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewLandscapeCommand::redo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LigoTileCommand::LigoTileCommand(const LigoData &data, const ZonePosition &zonePos,
|
||||||
|
ZoneBuilder *zoneBuilder, LandscapeScene *scene,
|
||||||
|
QUndoCommand *parent)
|
||||||
|
: QUndoCommand(parent),
|
||||||
|
m_zoneBuilder(zoneBuilder),
|
||||||
|
m_scene(scene)
|
||||||
|
{
|
||||||
|
// Backup position
|
||||||
|
m_zonePos = zonePos;
|
||||||
|
|
||||||
|
// Backup new data
|
||||||
|
m_newLigoData = data;
|
||||||
|
|
||||||
|
// Backup old data
|
||||||
|
m_zoneBuilder->ligoData(m_oldLigoData, m_zonePos);
|
||||||
|
}
|
||||||
|
|
||||||
|
LigoTileCommand::~LigoTileCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LigoTileCommand::undo ()
|
||||||
|
{
|
||||||
|
m_zoneBuilder->setLigoData(m_oldLigoData, m_zonePos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LigoTileCommand::redo ()
|
||||||
|
{
|
||||||
|
m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos);
|
||||||
|
}
|
||||||
|
|
||||||
|
UndoScanRegionCommand::UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent)
|
||||||
|
: QUndoCommand(parent),
|
||||||
|
m_zoneBuilder(zoneBuilder),
|
||||||
|
m_scene(scene)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
UndoScanRegionCommand::~UndoScanRegionCommand()
|
||||||
|
{
|
||||||
|
m_zonePositionList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoScanRegionCommand::setScanList(const QList<ZonePosition> &zonePositionList)
|
||||||
|
{
|
||||||
|
m_zonePositionList = zonePositionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoScanRegionCommand::undo()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||||
|
m_scene->deleteItemZone(m_zonePositionList.at(i));
|
||||||
|
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||||
|
{
|
||||||
|
LigoData data;
|
||||||
|
m_zoneBuilder->ligoData(data, m_zonePositionList.at(i));
|
||||||
|
m_scene->createItemZone(data, m_zonePositionList.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoScanRegionCommand::redo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RedoScanRegionCommand::RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent)
|
||||||
|
: QUndoCommand(parent),
|
||||||
|
m_zoneBuilder(zoneBuilder),
|
||||||
|
m_scene(scene)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RedoScanRegionCommand::~RedoScanRegionCommand()
|
||||||
|
{
|
||||||
|
m_zonePositionList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RedoScanRegionCommand::setScanList(const QList<ZonePosition> &zonePositionList)
|
||||||
|
{
|
||||||
|
m_zonePositionList = zonePositionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RedoScanRegionCommand::undo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RedoScanRegionCommand::redo()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||||
|
m_scene->deleteItemZone(m_zonePositionList.at(i));
|
||||||
|
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||||
|
{
|
||||||
|
LigoData data;
|
||||||
|
m_zoneBuilder->ligoData(data, m_zonePositionList.at(i));
|
||||||
|
m_scene->createItemZone(data, m_zonePositionList.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX,
|
||||||
|
sint32 newMinY, sint32 newMaxY, ZoneBuilder *zoneBuilder,
|
||||||
|
QUndoCommand *parent)
|
||||||
|
: QUndoCommand(parent),
|
||||||
|
m_zoneBuilder(zoneBuilder)
|
||||||
|
{
|
||||||
|
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)->ligoZoneRegion();
|
||||||
|
}
|
||||||
|
|
||||||
|
LigoResizeCommand::~LigoResizeCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LigoResizeCommand::undo ()
|
||||||
|
{
|
||||||
|
// Restore old region zone
|
||||||
|
m_zoneBuilder->zoneRegion(m_index)->setLigoZoneRegion(m_oldZoneRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LigoResizeCommand::redo ()
|
||||||
|
{
|
||||||
|
// Get the zone region
|
||||||
|
NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion();
|
||||||
|
|
||||||
|
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 */
|
|
@ -0,0 +1,156 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef LANDSCAPE_ACTIONS_H
|
||||||
|
#define LANDSCAPE_ACTIONS_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "builder_zone.h"
|
||||||
|
#include "landscape_scene.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QUndoCommand>
|
||||||
|
#include <QtGui/QGraphicsScene>
|
||||||
|
#include <QtGui/QGraphicsItem>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
class OpenLandscapeCommand: public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent = 0);
|
||||||
|
virtual ~OpenLandscapeCommand();
|
||||||
|
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
private:
|
||||||
|
|
||||||
|
QString m_fileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
class NewLandscapeCommand: public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NewLandscapeCommand(QUndoCommand *parent = 0);
|
||||||
|
virtual ~NewLandscapeCommand();
|
||||||
|
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
// Modify the landscape
|
||||||
|
class LigoTileCommand: public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LigoTileCommand(const LigoData &data, const ZonePosition &zonePos,
|
||||||
|
ZoneBuilder *zoneBuilder, LandscapeScene *scene,
|
||||||
|
QUndoCommand *parent = 0);
|
||||||
|
virtual ~LigoTileCommand();
|
||||||
|
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ZonePosition m_zonePos;
|
||||||
|
LigoData m_newLigoData;
|
||||||
|
LigoData m_oldLigoData;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
LandscapeScene *m_scene;
|
||||||
|
};
|
||||||
|
|
||||||
|
class UndoScanRegionCommand: public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0);
|
||||||
|
virtual ~UndoScanRegionCommand();
|
||||||
|
|
||||||
|
void setScanList(const QList<ZonePosition> &zonePositionList);
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QList<ZonePosition> m_zonePositionList;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
LandscapeScene *m_scene;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RedoScanRegionCommand: public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0);
|
||||||
|
virtual ~RedoScanRegionCommand();
|
||||||
|
|
||||||
|
void setScanList(const QList<ZonePosition> &zonePositionList);
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QList<ZonePosition> m_zonePositionList;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
LandscapeScene *m_scene;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Move the landscape
|
||||||
|
class LigoMoveCommand: public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
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 redo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_index;
|
||||||
|
sint32 m_newMinX;
|
||||||
|
sint32 m_newMaxX;
|
||||||
|
sint32 m_newMinY;
|
||||||
|
sint32 m_newMaxY;
|
||||||
|
NLLIGO::CZoneRegion m_oldZoneRegion;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // LANDSCAPE_ACTIONS_H
|
|
@ -26,6 +26,8 @@ const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor";
|
||||||
|
|
||||||
//settings
|
//settings
|
||||||
const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor";
|
const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor";
|
||||||
|
const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState";
|
||||||
|
const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry";
|
||||||
|
|
||||||
//resources
|
//resources
|
||||||
const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png";
|
const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png";
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
}
|
}
|
||||||
virtual QIcon icon() const
|
virtual QIcon icon() const
|
||||||
{
|
{
|
||||||
return QIcon();
|
return QIcon(Constants::ICON_LANDSCAPE_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
// Project includes
|
// Project includes
|
||||||
#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 "zone_region_editor.h"
|
||||||
|
#include "landscape_scene.h"
|
||||||
|
#include "project_settings_dialog.h"
|
||||||
|
#include "snapshot_dialog.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/imenu_manager.h"
|
#include "../core/imenu_manager.h"
|
||||||
|
@ -28,25 +33,70 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const int LANDSCAPE_ID = 32;
|
||||||
|
int NewLandCounter = 0;
|
||||||
QString _lastDir;
|
QString _lastDir;
|
||||||
|
|
||||||
LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent),
|
||||||
|
m_currentRow(-1),
|
||||||
|
m_landscapeScene(0),
|
||||||
|
m_zoneBuilder(0),
|
||||||
|
m_undoStack(0),
|
||||||
|
m_oglWidget(0)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
|
m_landscapeScene = new LandscapeScene(this);
|
||||||
|
|
||||||
|
m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack);
|
||||||
|
m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false);
|
||||||
|
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||||
|
m_ui.zoneListWidget->updateUi();
|
||||||
|
|
||||||
|
m_landscapeScene->setZoneBuilder(m_zoneBuilder);
|
||||||
|
m_ui.graphicsView->setScene(m_landscapeScene);
|
||||||
|
//m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer));
|
||||||
|
m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers));
|
||||||
|
m_ui.graphicsView->setViewport(m_oglWidget);
|
||||||
|
|
||||||
|
m_ui.newLandAction->setIcon(QIcon(Core::Constants::ICON_NEW));
|
||||||
|
m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
|
m_ui.saveLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
|
m_ui.saveAsLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS));
|
||||||
|
m_ui.deleteLandAction->setEnabled(false);
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
|
createToolBars();
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
|
connect(m_ui.saveAction, SIGNAL(triggered()), this, SLOT(save()));
|
||||||
|
connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings()));
|
||||||
|
connect(m_ui.snapshotAction, SIGNAL(triggered()), this, SLOT(openSnapshotDialog()));
|
||||||
|
connect(m_ui.enableGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool)));
|
||||||
|
|
||||||
|
connect(m_ui.newLandAction, SIGNAL(triggered()), this, SLOT(newLand()));
|
||||||
|
connect(m_ui.setActiveLandAction, SIGNAL(triggered()), this, SLOT(setActiveLand()));
|
||||||
|
connect(m_ui.saveLandAction, SIGNAL(triggered()), this, SLOT(saveSelectedLand()));
|
||||||
|
connect(m_ui.saveAsLandAction, SIGNAL(triggered()), this, SLOT(saveAsSelectedLand()));
|
||||||
|
connect(m_ui.deleteLandAction, SIGNAL(triggered()), this, SLOT(deleteSelectedLand()));
|
||||||
|
|
||||||
|
connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu()));
|
||||||
|
m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeEditorWindow::~LandscapeEditorWindow()
|
LandscapeEditorWindow::~LandscapeEditorWindow()
|
||||||
{
|
{
|
||||||
|
delete m_zoneBuilder;
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,19 +116,252 @@ void LandscapeEditorWindow::open()
|
||||||
{
|
{
|
||||||
QStringList list = fileNames;
|
QStringList list = fileNames;
|
||||||
_lastDir = QFileInfo(list.front()).absolutePath();
|
_lastDir = QFileInfo(list.front()).absolutePath();
|
||||||
|
Q_FOREACH(QString fileName, fileNames)
|
||||||
|
{
|
||||||
|
int row = createLandscape(fileName);
|
||||||
|
if (row != -1)
|
||||||
|
setActiveLandscape(row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::save()
|
||||||
|
{
|
||||||
|
saveLandscape(m_currentRow, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::openProjectSettings()
|
||||||
|
{
|
||||||
|
ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilder->dataPath(), this);
|
||||||
|
dialog->show();
|
||||||
|
int ok = dialog->exec();
|
||||||
|
if (ok == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
m_zoneBuilder->init(dialog->dataPath(), false);
|
||||||
|
m_ui.zoneListWidget->updateUi();
|
||||||
|
}
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::openSnapshotDialog()
|
||||||
|
{
|
||||||
|
SnapshotDialog *dialog = new SnapshotDialog(this);
|
||||||
|
dialog->show();
|
||||||
|
int ok = dialog->exec();
|
||||||
|
if (ok == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
|
tr("Save screenshot landscape"), _lastDir,
|
||||||
|
tr("Image file (*.png)"));
|
||||||
|
|
||||||
|
setCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
|
NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->currentZoneRegion()->ligoZoneRegion();
|
||||||
|
sint32 regionMinX = zoneRegion.getMinX();
|
||||||
|
sint32 regionMaxX = zoneRegion.getMaxX();
|
||||||
|
sint32 regionMinY = zoneRegion.getMinY();
|
||||||
|
sint32 regionMaxY = zoneRegion.getMaxY();
|
||||||
|
|
||||||
|
int regionWidth = (regionMaxX - regionMinX + 1);
|
||||||
|
int regionHeight = (regionMaxY - regionMinY + 1);
|
||||||
|
|
||||||
|
int cellSize = m_landscapeScene->cellSize();
|
||||||
|
QRectF rect(regionMinX * cellSize, abs(regionMaxY) * cellSize, regionWidth * cellSize, regionHeight * cellSize);
|
||||||
|
|
||||||
|
if (dialog->isCustomSize())
|
||||||
|
{
|
||||||
|
int widthSnapshot = dialog->widthSnapshot();
|
||||||
|
int heightSnapshot = dialog->heightSnapshot();
|
||||||
|
if (dialog->isKeepRatio())
|
||||||
|
heightSnapshot = (widthSnapshot / regionWidth) * regionHeight;
|
||||||
|
|
||||||
|
m_landscapeScene->snapshot(fileName, widthSnapshot, heightSnapshot, rect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_landscapeScene->snapshot(fileName, regionWidth * dialog->resolutionZone(),
|
||||||
|
regionHeight * dialog->resolutionZone(), rect);
|
||||||
|
}
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::customContextMenu()
|
||||||
|
{
|
||||||
|
if (m_ui.landscapesListWidget->currentRow() == -1)
|
||||||
|
return;
|
||||||
|
QMenu *popurMenu = new QMenu(this);
|
||||||
|
popurMenu->addAction(m_ui.setActiveLandAction);
|
||||||
|
popurMenu->addAction(m_ui.saveLandAction);
|
||||||
|
popurMenu->addAction(m_ui.saveAsLandAction);
|
||||||
|
popurMenu->addAction(m_ui.deleteLandAction);
|
||||||
|
popurMenu->exec(QCursor::pos());
|
||||||
|
delete popurMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::newLand()
|
||||||
|
{
|
||||||
|
createLandscape(QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::setActiveLand()
|
||||||
|
{
|
||||||
|
setActiveLandscape(m_ui.landscapesListWidget->currentRow());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::saveSelectedLand()
|
||||||
|
{
|
||||||
|
saveLandscape(m_ui.landscapesListWidget->currentRow(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::saveAsSelectedLand()
|
||||||
|
{
|
||||||
|
saveLandscape(m_ui.landscapesListWidget->currentRow(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::deleteSelectedLand()
|
||||||
|
{
|
||||||
|
int row = m_ui.landscapesListWidget->currentRow();
|
||||||
|
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
||||||
|
if (row == m_currentRow)
|
||||||
|
{
|
||||||
|
if (row == 0)
|
||||||
|
++row;
|
||||||
|
else
|
||||||
|
--row;
|
||||||
|
setActiveLandscape(row);
|
||||||
|
}
|
||||||
|
m_zoneBuilder->deleteZoneRegion(item->data(LANDSCAPE_ID).toInt());
|
||||||
|
m_ui.landscapesListWidget->removeItemWidget(item);
|
||||||
|
delete item;
|
||||||
|
if (m_ui.landscapesListWidget->count() == 1)
|
||||||
|
m_ui.deleteLandAction->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LandscapeEditorWindow::createLandscape(const QString &fileName)
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
id = m_zoneBuilder->createZoneRegion();
|
||||||
|
else
|
||||||
|
id = m_zoneBuilder->createZoneRegion(fileName);
|
||||||
|
|
||||||
|
if (id == -1)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, "Landscape Editor", "Cannot add this zone because it overlaps existing ones");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id);
|
||||||
|
m_ui.graphicsView->centerOn(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(),
|
||||||
|
abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize());
|
||||||
|
|
||||||
|
QListWidgetItem *item;
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
item = new QListWidgetItem(QString("NewLandscape%1").arg(NewLandCounter++), m_ui.landscapesListWidget);
|
||||||
|
else
|
||||||
|
item = new QListWidgetItem(fileName, m_ui.landscapesListWidget);
|
||||||
|
|
||||||
|
item->setData(LANDSCAPE_ID, id);
|
||||||
|
item->setFont(QFont("SansSerif", 9, QFont::Normal));
|
||||||
|
|
||||||
|
if (m_ui.landscapesListWidget->count() > 1)
|
||||||
|
m_ui.deleteLandAction->setEnabled(true);
|
||||||
|
|
||||||
|
return m_ui.landscapesListWidget->count() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::setActiveLandscape(int row)
|
||||||
|
{
|
||||||
|
if ((0 <= row) && (row < m_ui.landscapesListWidget->count()))
|
||||||
|
{
|
||||||
|
if (m_currentRow != -1)
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = m_ui.landscapesListWidget->item(m_currentRow);
|
||||||
|
item->setFont(QFont("SansSerif", 9, QFont::Normal));
|
||||||
|
}
|
||||||
|
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
||||||
|
item->setFont(QFont("SansSerif", 9, QFont::Bold));
|
||||||
|
m_zoneBuilder->setCurrentZoneRegion(item->data(LANDSCAPE_ID).toInt());
|
||||||
|
m_currentRow = row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::saveLandscape(int row, bool force)
|
||||||
|
{
|
||||||
|
if ((0 <= row) && (row < m_ui.landscapesListWidget->count()))
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
||||||
|
ZoneRegionObject *regionObject = m_zoneBuilder->zoneRegion(item->data(LANDSCAPE_ID).toInt());
|
||||||
|
if ((!force) || (regionObject->fileName().empty()))
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
|
tr("Save NeL Ligo land file"), _lastDir,
|
||||||
|
tr("NeL Ligo land file (*.land)"));
|
||||||
|
if (!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
regionObject->setFileName(fileName.toStdString());
|
||||||
|
regionObject->save();
|
||||||
|
regionObject->setModified(false);
|
||||||
|
item->setText(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
regionObject->save();
|
||||||
|
regionObject->setModified(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::showEvent(QShowEvent *showEvent)
|
||||||
|
{
|
||||||
|
QMainWindow::showEvent(showEvent);
|
||||||
|
if (m_oglWidget != 0)
|
||||||
|
m_oglWidget->makeCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::createMenus()
|
void LandscapeEditorWindow::createMenus()
|
||||||
{
|
{
|
||||||
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::createToolBars()
|
||||||
|
{
|
||||||
|
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
|
//QAction *action = menuManager->action(Core::Constants::NEW);
|
||||||
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
QAction *action = menuManager->action(Core::Constants::OPEN);
|
||||||
|
m_ui.fileToolBar->addAction(m_ui.newLandAction);
|
||||||
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
m_ui.fileToolBar->addAction(m_ui.saveAction);
|
||||||
|
|
||||||
|
const char * const UNDO = "ObjectViewerQt.Undo";
|
||||||
|
const char * const REDO = "ObjectViewerQt.Redo";
|
||||||
|
|
||||||
|
//action = menuManager->action(Core::Constants::UNDO);
|
||||||
|
action = menuManager->action(UNDO);
|
||||||
|
if (action != 0)
|
||||||
|
m_ui.undoToolBar->addAction(action);
|
||||||
|
|
||||||
|
//action = menuManager->action(Core::Constants::REDO);
|
||||||
|
action = menuManager->action(REDO);
|
||||||
|
if (action != 0)
|
||||||
|
m_ui.undoToolBar->addAction(action);
|
||||||
|
|
||||||
|
//action = menuManager->action(Core::Constants::SAVE);
|
||||||
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
//action = menuManager->action(Core::Constants::SAVE_AS);
|
||||||
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::readSettings()
|
void LandscapeEditorWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||||
|
restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray());
|
||||||
|
restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +369,8 @@ void LandscapeEditorWindow::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||||
|
settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState());
|
||||||
|
settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,14 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QUndoStack>
|
#include <QtGui/QUndoStack>
|
||||||
|
#include <QtOpenGL/QGLWidget>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class LandscapeScene;
|
||||||
|
class ZoneBuilder;
|
||||||
|
|
||||||
class LandscapeEditorWindow: public QMainWindow
|
class LandscapeEditorWindow: public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -40,14 +44,36 @@ public:
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void open();
|
void open();
|
||||||
|
void save();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
void openProjectSettings();
|
||||||
|
void openSnapshotDialog();
|
||||||
|
void customContextMenu();
|
||||||
|
void newLand();
|
||||||
|
void setActiveLand();
|
||||||
|
void saveSelectedLand();
|
||||||
|
void saveAsSelectedLand();
|
||||||
|
void deleteSelectedLand();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent *showEvent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createMenus();
|
void createMenus();
|
||||||
|
void createToolBars();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
void setActiveLandscape(int row);
|
||||||
|
void saveLandscape(int row, bool force);
|
||||||
|
int createLandscape(const QString &fileName);
|
||||||
|
|
||||||
|
int m_currentRow;
|
||||||
|
LandscapeScene *m_landscapeScene;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
|
QGLWidget *m_oglWidget;
|
||||||
Ui::LandscapeEditorWindow m_ui;
|
Ui::LandscapeEditorWindow m_ui;
|
||||||
}; /* class LandscapeEditorWindow */
|
}; /* class LandscapeEditorWindow */
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,30 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="margin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGraphicsView" name="graphicsView"/>
|
<widget class="LandscapeEditor::LandscapeView" name="graphicsView">
|
||||||
|
<property name="sceneRect">
|
||||||
|
<rectf>
|
||||||
|
<x>0.000000000000000</x>
|
||||||
|
<y>0.000000000000000</y>
|
||||||
|
<width>99999.000000000000000</width>
|
||||||
|
<height>99999.000000000000000</height>
|
||||||
|
</rectf>
|
||||||
|
</property>
|
||||||
|
<property name="dragMode">
|
||||||
|
<enum>QGraphicsView::NoDrag</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="toolBar">
|
<widget class="QToolBar" name="fileToolBar">
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>toolBar</string>
|
<string>toolBar</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -35,7 +53,155 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QDockWidget" name="dockWidget">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Zones</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>2</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="LandscapeEditor::ListZonesWidget" name="zoneListWidget"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="undoToolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar_2</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QDockWidget" name="landscapesDockWidget">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Landscapes</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>1</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="margin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QListWidget" name="landscapesListWidget"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="zoneToolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="projectSettingsAction"/>
|
||||||
|
<addaction name="snapshotAction"/>
|
||||||
|
<addaction name="enableGridAction"/>
|
||||||
|
</widget>
|
||||||
|
<action name="projectSettingsAction">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_landscape_settings.png</normaloff>:/icons/ic_nel_landscape_settings.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Project settings</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="enableGridAction">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>EnableGrid</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Show/Hide Grid</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+G</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="snapshotAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>snapshot</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="saveAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="setActiveLandAction">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_zone.png</normaloff>:/icons/ic_nel_zone.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Set active</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Set active selected landscape</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="saveLandAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Save selected landscape</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="saveAsLandAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save As landscape</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Save as selected landscape</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="deleteLandAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Delete</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Delete selected landscape</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="newLandAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>New</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Create new landscape</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LandscapeEditor::ListZonesWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>list_zones_widget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LandscapeEditor::LandscapeView</class>
|
||||||
|
<extends>QGraphicsView</extends>
|
||||||
|
<header>landscape_view.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="landscape_editor.qrc"/>
|
<include location="landscape_editor.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -0,0 +1,337 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "landscape_scene.h"
|
||||||
|
#include "pixmap_database.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
#include <QtGui/QGraphicsPixmapItem>
|
||||||
|
#include <QtGui/QGraphicsSimpleTextItem>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
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),
|
||||||
|
m_mouseX(0.0),
|
||||||
|
m_mouseY(0.0),
|
||||||
|
m_zoneBuilder(0)
|
||||||
|
{
|
||||||
|
m_cellSize = 160;
|
||||||
|
}
|
||||||
|
|
||||||
|
LandscapeScene::~LandscapeScene()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int LandscapeScene::cellSize() const
|
||||||
|
{
|
||||||
|
return m_cellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeScene::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
||||||
|
{
|
||||||
|
m_zoneBuilder = zoneBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (data.zoneName == STRING_UNUSED)
|
||||||
|
return createItemEmptyZone(zonePos);
|
||||||
|
|
||||||
|
if ((m_zoneBuilder == 0) || (data.zoneName.empty()))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Get image from pixmap database
|
||||||
|
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str()));
|
||||||
|
if (pixmap == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Rotate the image counterclockwise
|
||||||
|
QMatrix matrix;
|
||||||
|
matrix.rotate(-data.rot * 90.0);
|
||||||
|
|
||||||
|
QGraphicsPixmapItem *item;
|
||||||
|
|
||||||
|
if (data.flip == 0)
|
||||||
|
{
|
||||||
|
item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// mirror image
|
||||||
|
QImage mirrorImage = pixmap->toImage();
|
||||||
|
QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false));
|
||||||
|
item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation));
|
||||||
|
}
|
||||||
|
// Enable bilinear filtering
|
||||||
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
|
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName);
|
||||||
|
|
||||||
|
sint32 deltaX = 0, deltaY = 0;
|
||||||
|
|
||||||
|
// Calculate offset for graphics item (for items with size that are larger than 1)
|
||||||
|
if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1))
|
||||||
|
{
|
||||||
|
sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY();
|
||||||
|
if (data.flip == 0)
|
||||||
|
{
|
||||||
|
switch (data.rot)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
deltaX = -data.posX;
|
||||||
|
deltaY = -data.posY + sizeY - 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
deltaX = -(sizeY - 1 - data.posY);
|
||||||
|
deltaY = -data.posX + sizeX - 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
deltaX = -(sizeX - 1 - data.posX);
|
||||||
|
deltaY = data.posY;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
deltaX = -data.posY;
|
||||||
|
deltaY = data.posX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (data.rot)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
deltaX = -(sizeX - 1 - data.posX);
|
||||||
|
deltaY = -data.posY + sizeY - 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
deltaX = -(sizeY - 1 - data.posY);
|
||||||
|
deltaY = +data.posX;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
deltaX = -data.posX;
|
||||||
|
deltaY = data.posY;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
deltaX = -data.posY;
|
||||||
|
deltaY = -data.posX + sizeX - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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(ZONE_NAME, QString(data.zoneName.c_str()));
|
||||||
|
|
||||||
|
// for not full item zone
|
||||||
|
item->setZValue(LAYER_ZONES);
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
||||||
|
{
|
||||||
|
if (m_zoneBuilder == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Get image from pixmap database
|
||||||
|
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
||||||
|
if (pixmap == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
QGraphicsPixmapItem *item = addPixmap(*pixmap);
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
|
||||||
|
// for not full item zone
|
||||||
|
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);
|
||||||
|
if (item != 0)
|
||||||
|
{
|
||||||
|
removeItem(item);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string zoneName = zoneRegion.getName(i, j);
|
||||||
|
if (zoneName == STRING_UNUSED)
|
||||||
|
{
|
||||||
|
ZonePosition zonePos(i, j, -1);
|
||||||
|
QGraphicsItem *item = createItemEmptyZone(zonePos);
|
||||||
|
}
|
||||||
|
else if (!zoneName.empty())
|
||||||
|
{
|
||||||
|
LigoData data;
|
||||||
|
ZonePosition zonePos(i, j, -1);
|
||||||
|
data.zoneName = zoneName;
|
||||||
|
data.rot = zoneRegion.getRot(i, j);
|
||||||
|
data.flip = zoneRegion.getFlip(i, j);
|
||||||
|
data.posX = zoneRegion.getPosX(i, j);
|
||||||
|
data.posY = zoneRegion.getPosY(i, j);
|
||||||
|
QGraphicsItem *item = createItemZone(data, zonePos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 width, int height, const QRectF &landRect)
|
||||||
|
{
|
||||||
|
if (m_zoneBuilder == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Create image
|
||||||
|
QImage image(landRect.width(), landRect.height(), QImage::Format_RGB888);
|
||||||
|
QPainter painter(&image);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
|
// Add white background
|
||||||
|
painter.setBrush(QBrush(Qt::white));
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.drawRect(0, 0, landRect.width(), landRect.height());
|
||||||
|
|
||||||
|
// Paint landscape
|
||||||
|
render(&painter, QRectF(0, 0, landRect.width(), landRect.height()), landRect);
|
||||||
|
|
||||||
|
QImage scaledImage = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
scaledImage.save(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
|
{
|
||||||
|
if (m_zoneBuilder == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
qreal x = mouseEvent->scenePos().rx();
|
||||||
|
qreal y = mouseEvent->scenePos().ry();
|
||||||
|
if ((x < 0) || (y < 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
sint32 posX = sint32(floor(x / m_cellSize));
|
||||||
|
sint32 posY = sint32(-floor(y / m_cellSize));
|
||||||
|
|
||||||
|
if (mouseEvent->button() == Qt::LeftButton)
|
||||||
|
m_zoneBuilder->addZone(posX, posY);
|
||||||
|
else if (mouseEvent->button() == Qt::RightButton)
|
||||||
|
m_zoneBuilder->delZone(posX, posY);
|
||||||
|
|
||||||
|
QGraphicsScene::mousePressEvent(mouseEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent)
|
||||||
|
{
|
||||||
|
m_mouseX = mouseEvent->scenePos().x();
|
||||||
|
m_mouseY = mouseEvent->scenePos().y();
|
||||||
|
QGraphicsScene::mouseMoveEvent(mouseEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
QGraphicsScene::drawForeground(painter, rect);
|
||||||
|
/*
|
||||||
|
// Render debug text (slow!)
|
||||||
|
painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine));
|
||||||
|
|
||||||
|
int left = int(floor(rect.left() / m_cellSize));
|
||||||
|
int right = int(floor(rect.right() / m_cellSize));
|
||||||
|
int top = int(floor(rect.top() / m_cellSize));
|
||||||
|
int bottom = int(floor(rect.bottom() / m_cellSize));
|
||||||
|
|
||||||
|
for (int i = left; i < right; ++i)
|
||||||
|
{
|
||||||
|
for (int j = top; j < bottom; ++j)
|
||||||
|
{
|
||||||
|
LigoData data;
|
||||||
|
m_zoneBuilder->currentZoneRegion()->ligoData(data, i, -j);
|
||||||
|
painter->drawText(i * m_cellSize + 10, j * m_cellSize + 10, QString("%1 %2 %3 %4").arg(i).arg(j).arg(data.posX).arg(data.posY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,77 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef LANDSCAPE_SCENE_H
|
||||||
|
#define LANDSCAPE_SCENE_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "zone_region_editor.h"
|
||||||
|
#include "builder_zone.h"
|
||||||
|
#include "landscape_editor_global.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QGraphicsScene>
|
||||||
|
#include <QtGui/QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class LandscapeScene
|
||||||
|
@brief
|
||||||
|
@details
|
||||||
|
*/
|
||||||
|
class LANDSCAPE_EDITOR_EXPORT LandscapeScene : public QGraphicsScene
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
LandscapeScene(QObject *parent = 0);
|
||||||
|
virtual ~LandscapeScene();
|
||||||
|
|
||||||
|
int cellSize() const;
|
||||||
|
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
||||||
|
|
||||||
|
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 addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||||
|
void delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||||
|
|
||||||
|
void snapshot(const QString &fileName, int width, int height, const QRectF &landRect);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||||
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||||
|
virtual void drawForeground(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool checkUnderZone(const int posX, const int posY);
|
||||||
|
|
||||||
|
int m_cellSize;
|
||||||
|
qreal m_mouseX, m_mouseY;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // LANDSCAPE_SCENE_H
|
|
@ -0,0 +1,142 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "landscape_view.h"
|
||||||
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
|
#include "../core/icore.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
LandscapeView::LandscapeView(QWidget *parent)
|
||||||
|
: QGraphicsView(parent),
|
||||||
|
m_visibleGrid(true),
|
||||||
|
m_moveMouse(false)
|
||||||
|
{
|
||||||
|
setDragMode(ScrollHandDrag);
|
||||||
|
setTransformationAnchor(AnchorUnderMouse);
|
||||||
|
setBackgroundBrush(QBrush(Qt::lightGray));
|
||||||
|
//setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||||
|
//setRenderHints(QPainter::Antialiasing);
|
||||||
|
//setCacheMode(QGraphicsView::CacheBackground);
|
||||||
|
m_cellSize = 160;
|
||||||
|
m_numSteps = 0;
|
||||||
|
m_maxSteps = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
LandscapeView::~LandscapeView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LandscapeView::isVisibleGrid() const
|
||||||
|
{
|
||||||
|
return m_visibleGrid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::setVisibleGrid(bool visible)
|
||||||
|
{
|
||||||
|
m_visibleGrid = visible;
|
||||||
|
|
||||||
|
// hack for repaint view
|
||||||
|
translate(0.0001, 0.0001);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
double numDegrees = event->delta() / 8.0;
|
||||||
|
double numSteps = numDegrees / 15.0;
|
||||||
|
double factor = std::pow(1.125, numSteps);
|
||||||
|
if (factor > 1.0)
|
||||||
|
{
|
||||||
|
// check max scale view
|
||||||
|
if (m_numSteps > m_maxSteps)
|
||||||
|
return;
|
||||||
|
++m_numSteps;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check min scale view
|
||||||
|
if (m_numSteps < -m_maxSteps)
|
||||||
|
return;
|
||||||
|
--m_numSteps;
|
||||||
|
}
|
||||||
|
scale(factor, factor);
|
||||||
|
QGraphicsView::wheelEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
QGraphicsView::mousePressEvent(event);
|
||||||
|
if (event->button() != Qt::MiddleButton)
|
||||||
|
return;
|
||||||
|
m_moveMouse = true;
|
||||||
|
QApplication::setOverrideCursor(Qt::ClosedHandCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (m_moveMouse)
|
||||||
|
translate(0.001, 0.001);
|
||||||
|
QGraphicsView::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
m_moveMouse = false;
|
||||||
|
QGraphicsView::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
QGraphicsView::drawForeground(painter, rect);
|
||||||
|
|
||||||
|
if (!m_visibleGrid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
qreal scaleFactor = transform().m11();
|
||||||
|
painter->setPen(QPen(Qt::white, 0, Qt::SolidLine));
|
||||||
|
|
||||||
|
// draw grid
|
||||||
|
qreal left = m_cellSize * floor(rect.left() / m_cellSize);
|
||||||
|
qreal top = m_cellSize * floor(rect.top() / m_cellSize);
|
||||||
|
|
||||||
|
// draw vertical lines
|
||||||
|
while (left < rect.right())
|
||||||
|
{
|
||||||
|
painter->drawLine(int(left), int(rect.bottom()), int(left), int(rect.top()));
|
||||||
|
left += m_cellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw horizontal lines
|
||||||
|
while (top < rect.bottom())
|
||||||
|
{
|
||||||
|
painter->drawLine(int(rect.left()), int(top), int(rect.right()), int(top));
|
||||||
|
top += m_cellSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,62 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef LANDSCAPE_VIEW_H
|
||||||
|
#define LANDSCAPE_VIEW_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "landscape_editor_global.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QGraphicsView>
|
||||||
|
#include <QtGui/QWheelEvent>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
class LANDSCAPE_EDITOR_EXPORT LandscapeView: public QGraphicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
LandscapeView(QWidget *parent = 0);
|
||||||
|
virtual ~LandscapeView();
|
||||||
|
|
||||||
|
bool isVisibleGrid() const;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setVisibleGrid(bool visible);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
protected:
|
||||||
|
virtual void wheelEvent(QWheelEvent *event);
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
virtual void drawForeground(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool m_visibleGrid;
|
||||||
|
int m_numSteps, m_maxSteps;
|
||||||
|
int m_cellSize;
|
||||||
|
bool m_moveMouse;
|
||||||
|
}; /* class LandscapeView */
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // LANDSCAPE_VIEW_H
|
|
@ -0,0 +1,139 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "list_zones_model.h"
|
||||||
|
#include "builder_zone.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
ListZonesModel::ListZonesModel(int scaleRatio, QObject *parent)
|
||||||
|
: QAbstractListModel(parent),
|
||||||
|
m_scaleRatio(scaleRatio)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
ListZonesModel::~ListZonesModel()
|
||||||
|
{
|
||||||
|
resetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ListZonesModel::rowCount(const QModelIndex & /* parent */) const
|
||||||
|
{
|
||||||
|
return m_listNames.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ListZonesModel::columnCount(const QModelIndex & /* parent */) const
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ListZonesModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
switch (role)
|
||||||
|
{
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
|
return int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return m_listNames.at(index.row());
|
||||||
|
case Qt::DecorationRole:
|
||||||
|
{
|
||||||
|
QPixmap *pixmap = getPixmap(m_listNames.at(index.row()));
|
||||||
|
return qVariantFromValue(*pixmap);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ListZonesModel::headerData(int section,
|
||||||
|
Qt::Orientation /* orientation */,
|
||||||
|
int role) const
|
||||||
|
{
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesModel::setScaleRatio(int scaleRatio)
|
||||||
|
{
|
||||||
|
m_scaleRatio = scaleRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesModel::setListZones(QStringList &listZones)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
m_listNames.clear();
|
||||||
|
m_listNames = listZones;
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesModel::resetModel()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
QStringList listNames(m_pixmapMap.keys());
|
||||||
|
Q_FOREACH(QString name, listNames)
|
||||||
|
{
|
||||||
|
QPixmap *pixmap = m_pixmapMap.value(name);
|
||||||
|
delete pixmap;
|
||||||
|
}
|
||||||
|
m_pixmapMap.clear();
|
||||||
|
m_listNames.clear();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesModel::rebuildModel(PixmapDatabase *pixmapDatabase)
|
||||||
|
{
|
||||||
|
resetModel();
|
||||||
|
|
||||||
|
beginResetModel();
|
||||||
|
QStringList listNames;
|
||||||
|
listNames = pixmapDatabase->listPixmaps();
|
||||||
|
|
||||||
|
Q_FOREACH(QString name, listNames)
|
||||||
|
{
|
||||||
|
QPixmap *pixmap = pixmapDatabase->pixmap(name);
|
||||||
|
QPixmap *smallPixmap = new QPixmap(pixmap->scaled(pixmap->width() / m_scaleRatio, pixmap->height() / m_scaleRatio));
|
||||||
|
m_pixmapMap.insert(name, smallPixmap);
|
||||||
|
}
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const
|
||||||
|
{
|
||||||
|
QPixmap *result = 0;
|
||||||
|
if (!m_pixmapMap.contains(zoneName))
|
||||||
|
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
||||||
|
else
|
||||||
|
result = m_pixmapMap.value(zoneName);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,79 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef LIST_ZONES_MODEL_H
|
||||||
|
#define LIST_ZONES_MODEL_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtGui/QPixmap>
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
class PixmapDatabase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class ListZonesModel
|
||||||
|
@brief ListZonesModel contains the small images for QListView
|
||||||
|
@details
|
||||||
|
*/
|
||||||
|
class ListZonesModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ListZonesModel(int scaleRatio = 4, QObject *parent = 0);
|
||||||
|
~ListZonesModel();
|
||||||
|
|
||||||
|
int rowCount(const QModelIndex &parent) const;
|
||||||
|
int columnCount(const QModelIndex &parent) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
|
int role) const;
|
||||||
|
|
||||||
|
/// Set size for small pixmaps
|
||||||
|
/// Value should be set before calling rebuildModel
|
||||||
|
void setScaleRatio(int scaleRatio);
|
||||||
|
|
||||||
|
/// Unload all images and reset model
|
||||||
|
void resetModel();
|
||||||
|
|
||||||
|
/// Set current list zones which will be available in QListView
|
||||||
|
void setListZones(QStringList &listZones);
|
||||||
|
|
||||||
|
/// Build own pixmaps database(all images are scaled: width/scaleRatio, height/scaleRatio) from pixmapDatabase
|
||||||
|
void rebuildModel(PixmapDatabase *pixmapDatabase);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Get pixmap
|
||||||
|
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
|
||||||
|
QPixmap *getPixmap(const QString &zoneName) const;
|
||||||
|
|
||||||
|
int m_scaleRatio;
|
||||||
|
QMap<QString, QPixmap*> m_pixmapMap;
|
||||||
|
QStringList m_listNames;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // LIST_ZONES_MODEL_H
|
|
@ -0,0 +1,308 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "list_zones_widget.h"
|
||||||
|
#include "list_zones_model.h"
|
||||||
|
#include "builder_zone.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QIcon>
|
||||||
|
#include <QtCore/QModelIndex>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
ListZonesWidget::ListZonesWidget(QWidget *parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
m_rotCycle(0),
|
||||||
|
m_flipCycle(0),
|
||||||
|
m_listZonesModel(0),
|
||||||
|
m_zoneBuilder(0)
|
||||||
|
{
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
|
m_listZonesModel = new ListZonesModel(4, this);
|
||||||
|
m_ui.listView->setModel(m_listZonesModel);
|
||||||
|
|
||||||
|
m_ui.addFilterButton_1->setChecked(false);
|
||||||
|
m_ui.addFilterButton_2->setChecked(false);
|
||||||
|
m_ui.addFilterButton_3->setChecked(false);
|
||||||
|
|
||||||
|
connect(m_ui.categoryTypeComboBox_1, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_1(QString)));
|
||||||
|
connect(m_ui.categoryTypeComboBox_2, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_2(QString)));
|
||||||
|
connect(m_ui.categoryTypeComboBox_3, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_3(QString)));
|
||||||
|
connect(m_ui.categoryTypeComboBox_4, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_4(QString)));
|
||||||
|
connect(m_ui.categoryValueComboBox_1, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
|
connect(m_ui.categoryValueComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
|
connect(m_ui.categoryValueComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
|
connect(m_ui.categoryValueComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
|
connect(m_ui.logicComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
|
connect(m_ui.logicComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
|
connect(m_ui.logicComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ListZonesWidget::~ListZonesWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::updateUi()
|
||||||
|
{
|
||||||
|
if (m_zoneBuilder == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
disableSignals(true);
|
||||||
|
std::vector<std::string> listCategoryType;
|
||||||
|
m_zoneBuilder->getZoneBank().getCategoriesType(listCategoryType);
|
||||||
|
|
||||||
|
QStringList listCategories;
|
||||||
|
|
||||||
|
listCategories << STRING_UNUSED;
|
||||||
|
for (size_t i = 0; i < listCategoryType.size(); ++i)
|
||||||
|
listCategories << QString(listCategoryType[i].c_str());
|
||||||
|
|
||||||
|
m_ui.categoryTypeComboBox_1->clear();
|
||||||
|
m_ui.categoryTypeComboBox_2->clear();
|
||||||
|
m_ui.categoryTypeComboBox_3->clear();
|
||||||
|
m_ui.categoryTypeComboBox_4->clear();
|
||||||
|
m_ui.categoryValueComboBox_1->clear();
|
||||||
|
m_ui.categoryValueComboBox_2->clear();
|
||||||
|
m_ui.categoryValueComboBox_3->clear();
|
||||||
|
m_ui.categoryValueComboBox_4->clear();
|
||||||
|
|
||||||
|
m_ui.categoryTypeComboBox_1->addItems(listCategories);
|
||||||
|
m_ui.categoryTypeComboBox_2->addItems(listCategories);
|
||||||
|
m_ui.categoryTypeComboBox_3->addItems(listCategories);
|
||||||
|
m_ui.categoryTypeComboBox_4->addItems(listCategories);
|
||||||
|
|
||||||
|
disableSignals(false);
|
||||||
|
|
||||||
|
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ListZonesWidget::currentZoneName()
|
||||||
|
{
|
||||||
|
QString zoneName = "";
|
||||||
|
QModelIndex index = m_ui.listView->currentIndex();
|
||||||
|
if (index.isValid())
|
||||||
|
zoneName = index.data().toString();
|
||||||
|
if (m_ui.zoneSelectComboBox->currentIndex() == 1)
|
||||||
|
{
|
||||||
|
// Random value
|
||||||
|
if (m_listSelection.size() > 0)
|
||||||
|
{
|
||||||
|
uint32 randZone = uint32(NLMISC::frand(m_listSelection.size()));
|
||||||
|
NLMISC::clamp(randZone, (uint32)0, uint32(m_listSelection.size() - 1));
|
||||||
|
zoneName = m_listSelection[randZone];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_ui.zoneSelectComboBox->currentIndex() == 2)
|
||||||
|
{
|
||||||
|
// Full cycle
|
||||||
|
if (m_listSelection.size() > 0)
|
||||||
|
{
|
||||||
|
zoneName = m_listSelection[m_zoneNameCycle];
|
||||||
|
m_zoneNameCycle++;
|
||||||
|
m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zoneName;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ListZonesWidget::currentRot()
|
||||||
|
{
|
||||||
|
int rot = m_ui.rotComboBox->currentIndex();
|
||||||
|
if (rot == 4)
|
||||||
|
{
|
||||||
|
// Random value
|
||||||
|
uint32 randRot = uint32(NLMISC::frand(4.0));
|
||||||
|
NLMISC::clamp(randRot, (uint32)0, (uint32)3);
|
||||||
|
rot = int(randRot);
|
||||||
|
}
|
||||||
|
else if (rot == 5)
|
||||||
|
{
|
||||||
|
// Full cycle
|
||||||
|
rot = m_rotCycle;
|
||||||
|
m_rotCycle++;
|
||||||
|
m_rotCycle = m_rotCycle % 4;
|
||||||
|
}
|
||||||
|
return rot;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ListZonesWidget::currentFlip()
|
||||||
|
{
|
||||||
|
int flip = m_ui.flipComboBox->currentIndex();
|
||||||
|
if (flip == 2)
|
||||||
|
{
|
||||||
|
// Random value
|
||||||
|
uint32 randFlip = uint32(NLMISC::frand(2.0));
|
||||||
|
NLMISC::clamp (randFlip, (uint32)0, (uint32)1);
|
||||||
|
flip = int(randFlip);
|
||||||
|
}
|
||||||
|
else if (flip == 3)
|
||||||
|
{
|
||||||
|
// Full cycle
|
||||||
|
flip = m_flipCycle;
|
||||||
|
m_flipCycle++;
|
||||||
|
m_flipCycle = m_flipCycle % 2;
|
||||||
|
}
|
||||||
|
return flip;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ListZonesWidget::isNotPropogate() const
|
||||||
|
{
|
||||||
|
return m_ui.propogateCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ListZonesWidget::isForce() const
|
||||||
|
{
|
||||||
|
return m_ui.forceCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
||||||
|
{
|
||||||
|
m_zoneBuilder = zoneBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::updateFilters_1(const QString &value)
|
||||||
|
{
|
||||||
|
disableSignals(true);
|
||||||
|
std::vector<std::string> allCategoryValues;
|
||||||
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
|
m_ui.categoryValueComboBox_1->clear();
|
||||||
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
|
m_ui.categoryValueComboBox_1->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
|
disableSignals(false);
|
||||||
|
updateListZones();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::updateFilters_2(const QString &value)
|
||||||
|
{
|
||||||
|
disableSignals(true);
|
||||||
|
std::vector<std::string> allCategoryValues;
|
||||||
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
|
|
||||||
|
m_ui.categoryValueComboBox_2->clear();
|
||||||
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
|
m_ui.categoryValueComboBox_2->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
|
disableSignals(false);
|
||||||
|
updateListZones();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::updateFilters_3(const QString &value)
|
||||||
|
{
|
||||||
|
disableSignals(true);
|
||||||
|
std::vector<std::string> allCategoryValues;
|
||||||
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
|
|
||||||
|
m_ui.categoryValueComboBox_3->clear();
|
||||||
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
|
m_ui.categoryValueComboBox_3->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
|
disableSignals(false);
|
||||||
|
updateListZones();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::updateFilters_4(const QString &value)
|
||||||
|
{
|
||||||
|
disableSignals(true);
|
||||||
|
std::vector<std::string> allCategoryValues;
|
||||||
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
|
|
||||||
|
m_ui.categoryValueComboBox_4->clear();
|
||||||
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
|
m_ui.categoryValueComboBox_4->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
|
disableSignals(false);
|
||||||
|
updateListZones();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::updateListZones()
|
||||||
|
{
|
||||||
|
// Execute the filter
|
||||||
|
NLLIGO::CZoneBank &zoneBank = m_zoneBuilder->getZoneBank();
|
||||||
|
zoneBank.resetSelection ();
|
||||||
|
|
||||||
|
if(m_ui.categoryTypeComboBox_1->currentIndex() > 0 )
|
||||||
|
zoneBank.addOrSwitch (m_ui.categoryTypeComboBox_1->currentText().toStdString()
|
||||||
|
, m_ui.categoryValueComboBox_1->currentText().toStdString());
|
||||||
|
|
||||||
|
if(m_ui.categoryTypeComboBox_2->currentIndex() > 0 )
|
||||||
|
{
|
||||||
|
if (m_ui.logicComboBox_2->currentIndex() == 0) // AND switch wanted
|
||||||
|
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString()
|
||||||
|
,m_ui.categoryValueComboBox_2->currentText().toStdString());
|
||||||
|
else // OR switch wanted
|
||||||
|
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString()
|
||||||
|
,m_ui.categoryValueComboBox_2->currentText().toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_ui.categoryTypeComboBox_3->currentIndex() > 0 )
|
||||||
|
{
|
||||||
|
if (m_ui.logicComboBox_3->currentIndex() == 0) // AND switch wanted
|
||||||
|
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString()
|
||||||
|
,m_ui.categoryValueComboBox_3->currentText().toStdString());
|
||||||
|
else // OR switch wanted
|
||||||
|
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString()
|
||||||
|
,m_ui.categoryValueComboBox_3->currentText().toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_ui.categoryTypeComboBox_4->currentIndex() > 0 )
|
||||||
|
{
|
||||||
|
if (m_ui.logicComboBox_4->currentIndex() == 0) // AND switch wanted
|
||||||
|
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString()
|
||||||
|
,m_ui.categoryValueComboBox_4->currentText().toStdString());
|
||||||
|
else // OR switch wanted
|
||||||
|
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString()
|
||||||
|
,m_ui.categoryValueComboBox_4->currentText().toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<NLLIGO::CZoneBankElement *> currentSelection;
|
||||||
|
zoneBank.getSelection (currentSelection);
|
||||||
|
|
||||||
|
m_listSelection.clear();
|
||||||
|
m_zoneNameCycle = 0;
|
||||||
|
for (size_t i = 0; i < currentSelection.size(); ++i)
|
||||||
|
m_listSelection << currentSelection[i]->getName().c_str();
|
||||||
|
|
||||||
|
m_listZonesModel->setListZones(m_listSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListZonesWidget::disableSignals(bool block)
|
||||||
|
{
|
||||||
|
m_ui.categoryTypeComboBox_1->blockSignals(block);
|
||||||
|
m_ui.categoryTypeComboBox_2->blockSignals(block);
|
||||||
|
m_ui.categoryTypeComboBox_3->blockSignals(block);
|
||||||
|
m_ui.categoryTypeComboBox_4->blockSignals(block);
|
||||||
|
m_ui.categoryValueComboBox_1->blockSignals(block);
|
||||||
|
m_ui.categoryValueComboBox_2->blockSignals(block);
|
||||||
|
m_ui.categoryValueComboBox_3->blockSignals(block);
|
||||||
|
m_ui.categoryValueComboBox_4->blockSignals(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,84 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef LIST_ZONES_WIDGET_H
|
||||||
|
#define LIST_ZONES_WIDGET_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "ui_list_zones_widget.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
class ListZonesModel;
|
||||||
|
class ZoneBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class ZoneListWidget
|
||||||
|
@brief ZoneListWidget displays list available zones in accordance with the filter settings
|
||||||
|
@details
|
||||||
|
*/
|
||||||
|
class ListZonesWidget: public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ListZonesWidget(QWidget *parent = 0);
|
||||||
|
~ListZonesWidget();
|
||||||
|
|
||||||
|
void updateUi();
|
||||||
|
|
||||||
|
// Set zone builder, call this method before using this class
|
||||||
|
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
||||||
|
|
||||||
|
// Get current zone name which user selected from list.
|
||||||
|
QString currentZoneName();
|
||||||
|
|
||||||
|
// Get current rotation value which user selected (Rot 0-0deg, 1-90deg, 2-180deg, 3-270deg).
|
||||||
|
int currentRot();
|
||||||
|
|
||||||
|
// Get current flip value which user selected (Flip 0-false, 1-true).
|
||||||
|
int currentFlip();
|
||||||
|
|
||||||
|
bool isNotPropogate() const;
|
||||||
|
bool isForce() const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void updateFilters_1(const QString &value);
|
||||||
|
void updateFilters_2(const QString &value);
|
||||||
|
void updateFilters_3(const QString &value);
|
||||||
|
void updateFilters_4(const QString &value);
|
||||||
|
void updateListZones();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void disableSignals(bool block);
|
||||||
|
|
||||||
|
int m_rotCycle, m_flipCycle;
|
||||||
|
int m_zoneNameCycle;
|
||||||
|
QStringList m_listSelection;
|
||||||
|
|
||||||
|
ListZonesModel *m_listZonesModel;
|
||||||
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
Ui::ListZonesWidget m_ui;
|
||||||
|
}; /* ZoneListWidget */
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // LIST_ZONES_WIDGET_H
|
|
@ -0,0 +1,493 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ListZonesWidget</class>
|
||||||
|
<widget class="QWidget" name="ListZonesWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>359</width>
|
||||||
|
<height>579</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<property name="margin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Filter</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="margin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="categoryTypeComboBox_1"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QComboBox" name="categoryValueComboBox_1"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QComboBox" name="zoneSelectComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Select</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Random</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fyll cycle</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="categoryTypeComboBox_2">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QComboBox" name="categoryValueComboBox_2">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QComboBox" name="logicComboBox_2">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>And</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Or</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="categoryTypeComboBox_3">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QComboBox" name="categoryValueComboBox_3">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QComboBox" name="logicComboBox_3">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>And</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Or</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="categoryTypeComboBox_4">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QComboBox" name="categoryValueComboBox_4">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="3">
|
||||||
|
<widget class="QComboBox" name="logicComboBox_4">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>And</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Or</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QToolButton" name="addFilterButton_1">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../core/core.qrc">
|
||||||
|
<normaloff>:/core/icons/ic_nel_add_item.png</normaloff>
|
||||||
|
<normalon>:/core/icons/ic_nel_delete_item.png</normalon>:/core/icons/ic_nel_add_item.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QToolButton" name="addFilterButton_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../core/core.qrc">
|
||||||
|
<normaloff>:/core/icons/ic_nel_add_item.png</normaloff>
|
||||||
|
<normalon>:/core/icons/ic_nel_delete_item.png</normalon>:/core/icons/ic_nel_add_item.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QToolButton" name="addFilterButton_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../core/core.qrc">
|
||||||
|
<normaloff>:/core/icons/ic_nel_add_item.png</normaloff>
|
||||||
|
<normalon>:/core/icons/ic_nel_delete_item.png</normalon>:/core/icons/ic_nel_add_item.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Placement</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="margin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="rotComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>0°</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>90°</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>180°</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>270°</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Random</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Full cycle</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="flipComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>NoFlip</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Flip</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Random</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fyll cycle</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QCheckBox" name="forceCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Force</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QCheckBox" name="propogateCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Not propogate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QListView" name="listView">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollMode">
|
||||||
|
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../core/core.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_1</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>categoryTypeComboBox_2</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>20</x>
|
||||||
|
<y>36</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>81</x>
|
||||||
|
<y>53</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_1</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>categoryValueComboBox_2</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>24</x>
|
||||||
|
<y>32</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>181</x>
|
||||||
|
<y>50</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_1</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>logicComboBox_2</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>20</x>
|
||||||
|
<y>31</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>301</x>
|
||||||
|
<y>55</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_2</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>categoryTypeComboBox_3</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>27</x>
|
||||||
|
<y>62</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>57</x>
|
||||||
|
<y>75</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_2</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>categoryValueComboBox_3</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>23</x>
|
||||||
|
<y>58</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>156</x>
|
||||||
|
<y>76</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_2</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>logicComboBox_3</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>23</x>
|
||||||
|
<y>53</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>255</x>
|
||||||
|
<y>77</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_3</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>categoryTypeComboBox_4</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>32</x>
|
||||||
|
<y>94</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>44</x>
|
||||||
|
<y>104</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_3</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>categoryValueComboBox_4</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>32</x>
|
||||||
|
<y>94</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>207</x>
|
||||||
|
<y>103</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_3</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>logicComboBox_4</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>21</x>
|
||||||
|
<y>81</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>278</x>
|
||||||
|
<y>104</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_2</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>addFilterButton_3</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>15</x>
|
||||||
|
<y>59</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>16</x>
|
||||||
|
<y>80</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>addFilterButton_1</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>addFilterButton_2</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>13</x>
|
||||||
|
<y>35</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>17</x>
|
||||||
|
<y>60</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -0,0 +1,132 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "pixmap_database.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
PixmapDatabase::PixmapDatabase(int textureSize)
|
||||||
|
: m_textureSize(textureSize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PixmapDatabase::~PixmapDatabase()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank, bool displayProgress)
|
||||||
|
{
|
||||||
|
QProgressDialog *progressDialog;
|
||||||
|
std::vector<std::string> listNames;
|
||||||
|
zoneBank.getCategoryValues ("zone", listNames);
|
||||||
|
if (displayProgress)
|
||||||
|
{
|
||||||
|
progressDialog = new QProgressDialog();
|
||||||
|
progressDialog->show();
|
||||||
|
progressDialog->setRange(0, listNames.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint i = 0; i < listNames.size(); ++i)
|
||||||
|
{
|
||||||
|
QApplication::processEvents();
|
||||||
|
|
||||||
|
if (displayProgress)
|
||||||
|
progressDialog->setValue(i);
|
||||||
|
|
||||||
|
NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (listNames[i]);
|
||||||
|
|
||||||
|
// Read the texture file
|
||||||
|
QString zonePixmapName(listNames[i].c_str());
|
||||||
|
uint8 sizeX = zoneBankItem->getSizeX();
|
||||||
|
uint8 sizeY = zoneBankItem->getSizeY();
|
||||||
|
|
||||||
|
QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png");
|
||||||
|
if (pixmap->isNull())
|
||||||
|
{
|
||||||
|
// Generate filled pixmap
|
||||||
|
}
|
||||||
|
// All pixmaps must be have same size
|
||||||
|
if (pixmap->width() != sizeX * m_textureSize)
|
||||||
|
{
|
||||||
|
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
|
delete pixmap;
|
||||||
|
m_pixmapMap.insert(zonePixmapName, scaledPixmap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (displayProgress)
|
||||||
|
delete progressDialog;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PixmapDatabase::reset()
|
||||||
|
{
|
||||||
|
QStringList listNames(m_pixmapMap.keys());
|
||||||
|
Q_FOREACH(QString name, listNames)
|
||||||
|
{
|
||||||
|
QPixmap *pixmap = m_pixmapMap.value(name);
|
||||||
|
delete pixmap;
|
||||||
|
}
|
||||||
|
m_pixmapMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList PixmapDatabase::listPixmaps() const
|
||||||
|
{
|
||||||
|
return m_pixmapMap.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const
|
||||||
|
{
|
||||||
|
QPixmap *result = 0;
|
||||||
|
if (!m_pixmapMap.contains(zoneName))
|
||||||
|
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
||||||
|
else
|
||||||
|
result = m_pixmapMap.value(zoneName);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PixmapDatabase::textureSize() const
|
||||||
|
{
|
||||||
|
return m_textureSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,69 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef PIXMAP_DATABASE_H
|
||||||
|
#define PIXMAP_DATABASE_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "landscape_editor_global.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtGui/QPixmap>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class PixmapDatabase
|
||||||
|
@brief PixmapDatabase contains the image database
|
||||||
|
@details
|
||||||
|
*/
|
||||||
|
class LANDSCAPE_EDITOR_EXPORT PixmapDatabase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PixmapDatabase(int textureSize = 256);
|
||||||
|
~PixmapDatabase();
|
||||||
|
|
||||||
|
/// Load all images(png) from zonePath, list images gets from zoneBank
|
||||||
|
bool loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank, bool displayProgress = false);
|
||||||
|
|
||||||
|
/// Unload all images
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
/// Get list names all loaded pixmaps
|
||||||
|
QStringList listPixmaps() const;
|
||||||
|
|
||||||
|
/// Get original pixmap
|
||||||
|
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
|
||||||
|
QPixmap *pixmap(const QString &zoneName) const;
|
||||||
|
|
||||||
|
int textureSize() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int m_textureSize;
|
||||||
|
QMap<QString, QPixmap*> m_pixmapMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // PIXMAP_DATABASE_H
|
|
@ -0,0 +1,61 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "project_settings_dialog.h"
|
||||||
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
|
#include "../core/icore.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
|
setFixedHeight(sizeHint().height());
|
||||||
|
connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectSettingsDialog::~ProjectSettingsDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProjectSettingsDialog::dataPath() const
|
||||||
|
{
|
||||||
|
return m_ui.pathLineEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectSettingsDialog::selectPath()
|
||||||
|
{
|
||||||
|
QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text());
|
||||||
|
if (!dataPath.isEmpty())
|
||||||
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,49 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef PROJECT_SETTINGS_DIALOG_H
|
||||||
|
#define PROJECT_SETTINGS_DIALOG_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "ui_project_settings_dialog.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
class ProjectSettingsDialog: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ProjectSettingsDialog(const QString &dataPath, QWidget *parent = 0);
|
||||||
|
~ProjectSettingsDialog();
|
||||||
|
|
||||||
|
QString dataPath() const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void selectPath();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Ui::ProjectSettingsDialog m_ui;
|
||||||
|
}; /* class ProjectSettingsDialog */
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // PROJECT_SETTINGS_DIALOG_H
|
|
@ -0,0 +1,103 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ProjectSettingsDialog</class>
|
||||||
|
<widget class="QDialog" name="ProjectSettingsDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>419</width>
|
||||||
|
<height>93</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Project settings</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="landscape_editor.qrc">
|
||||||
|
<normaloff>:/icons/ic_nel_landscape_settings.png</normaloff>:/icons/ic_nel_landscape_settings.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Data directory:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>pathLineEdit</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="pathLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="selectPathButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Context:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>contextComboBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<widget class="QComboBox" name="contextComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="3">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="landscape_editor.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>ProjectSettingsDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>257</x>
|
||||||
|
<y>83</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>ProjectSettingsDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>325</x>
|
||||||
|
<y>83</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -0,0 +1,222 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SnapshotDialog</class>
|
||||||
|
<widget class="QDialog" name="SnapshotDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>230</width>
|
||||||
|
<height>187</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Snapshot</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="originalSizeRadioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Original size</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="resSpinBox">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1024</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QRadioButton" name="customSizeRadioButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Custom size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="widthSpinBox">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>99999</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>512</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Height:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>heightSpinBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="heightSpinBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>99999</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>512</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Width:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>widthSpinBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="keepRatioCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Keep bitmap ratio</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>originalSizeRadioButton</tabstop>
|
||||||
|
<tabstop>customSizeRadioButton</tabstop>
|
||||||
|
<tabstop>widthSpinBox</tabstop>
|
||||||
|
<tabstop>heightSpinBox</tabstop>
|
||||||
|
<tabstop>keepRatioCheckBox</tabstop>
|
||||||
|
<tabstop>buttonBox</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>SnapshotDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>227</x>
|
||||||
|
<y>164</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>158</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>SnapshotDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>276</x>
|
||||||
|
<y>170</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>285</x>
|
||||||
|
<y>158</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>customSizeRadioButton</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>groupBox</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>59</x>
|
||||||
|
<y>39</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>78</x>
|
||||||
|
<y>62</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>keepRatioCheckBox</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>heightSpinBox</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>84</x>
|
||||||
|
<y>122</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>178</x>
|
||||||
|
<y>106</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>keepRatioCheckBox</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>label_2</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>55</x>
|
||||||
|
<y>129</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>48</x>
|
||||||
|
<y>103</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -0,0 +1,71 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "snapshot_dialog.h"
|
||||||
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
|
#include "../core/icore.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
SnapshotDialog::SnapshotDialog(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
setFixedHeight(sizeHint().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapshotDialog::~SnapshotDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SnapshotDialog::isCustomSize() const
|
||||||
|
{
|
||||||
|
return m_ui.customSizeRadioButton->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SnapshotDialog::isKeepRatio() const
|
||||||
|
{
|
||||||
|
return m_ui.keepRatioCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SnapshotDialog::resolutionZone() const
|
||||||
|
{
|
||||||
|
return m_ui.resSpinBox->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SnapshotDialog::widthSnapshot() const
|
||||||
|
{
|
||||||
|
return m_ui.widthSpinBox->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SnapshotDialog::heightSnapshot() const
|
||||||
|
{
|
||||||
|
return m_ui.heightSpinBox->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,53 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef SNAPSHOT_DIALOG_H
|
||||||
|
#define SNAPSHOT_DIALOG_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "ui_shapshot_dialog.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
class SnapshotDialog: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SnapshotDialog(QWidget *parent = 0);
|
||||||
|
~SnapshotDialog();
|
||||||
|
|
||||||
|
bool isCustomSize() const;
|
||||||
|
bool isKeepRatio() const;
|
||||||
|
int resolutionZone() const;
|
||||||
|
int widthSnapshot() const;
|
||||||
|
int heightSnapshot() const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Ui::SnapshotDialog m_ui;
|
||||||
|
}; /* class SnapshotDialog */
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // SNAPSHOT_DIALOG_H
|
|
@ -0,0 +1,227 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "zone_region_editor.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
#include <nel/misc/file.h>
|
||||||
|
#include <nel/misc/i_xml.h>
|
||||||
|
#include <nel/misc/o_xml.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LigoData::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]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneRegionObject::ZoneRegionObject()
|
||||||
|
{
|
||||||
|
m_fileName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneRegionObject::~ZoneRegionObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneRegionObject::load(const std::string &fileName)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Open it
|
||||||
|
NLMISC::CIFile fileIn;
|
||||||
|
if (fileIn.open(fileName))
|
||||||
|
{
|
||||||
|
NLMISC::CIXml xml(true);
|
||||||
|
xml.init(fileIn);
|
||||||
|
m_zoneRegion.serial(xml);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("Can't open file %s for reading", fileName.c_str());
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NLMISC::Exception& e)
|
||||||
|
{
|
||||||
|
nlwarning("Error reading file %s : %s", fileName.c_str(), e.what ());
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
if (result)
|
||||||
|
m_fileName = fileName;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneRegionObject::save()
|
||||||
|
{
|
||||||
|
if (m_fileName.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool result = true;
|
||||||
|
// Save the landscape
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
// Open file for writing
|
||||||
|
NLMISC::COFile fileOut;
|
||||||
|
if (fileOut.open(m_fileName, false, false, true))
|
||||||
|
{
|
||||||
|
// Be careful with the flushing of the COXml object
|
||||||
|
{
|
||||||
|
NLMISC::COXml xmlOut;
|
||||||
|
xmlOut.init(&fileOut);
|
||||||
|
m_zoneRegion.serial(xmlOut);
|
||||||
|
// Done
|
||||||
|
m_modified = false;
|
||||||
|
}
|
||||||
|
fileOut.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("Can't open file %s for writing.", m_fileName.c_str());
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NLMISC::Exception& e)
|
||||||
|
{
|
||||||
|
nlwarning("Error writing file %s : %s", m_fileName.c_str(), e.what());
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ZoneRegionObject::fileName() const
|
||||||
|
{
|
||||||
|
return m_fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneRegionObject::setFileName(const std::string &fileName)
|
||||||
|
{
|
||||||
|
m_fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneRegionObject::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 ZoneRegionObject::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 &ZoneRegionObject::ligoZoneRegion()
|
||||||
|
{
|
||||||
|
return m_zoneRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneRegionObject::setLigoZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
|
{
|
||||||
|
m_zoneRegion = zoneRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneRegionObject::checkPos(const sint32 x, const sint32 y)
|
||||||
|
{
|
||||||
|
return ((x >= m_zoneRegion.getMinX()) &&
|
||||||
|
(x <= m_zoneRegion.getMaxX()) &&
|
||||||
|
(y >= m_zoneRegion.getMinY()) &&
|
||||||
|
(y <= m_zoneRegion.getMaxY()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneRegionObject::isModified() const
|
||||||
|
{
|
||||||
|
return m_modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneRegionObject::setModified(bool modified)
|
||||||
|
{
|
||||||
|
m_modified = modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
|
@ -0,0 +1,105 @@
|
||||||
|
// 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>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef LANDSCAPE_EDITOR_H
|
||||||
|
#define LANDSCAPE_EDITOR_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/ligo/zone_bank.h>
|
||||||
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
|
||||||
|
namespace LandscapeEditor
|
||||||
|
{
|
||||||
|
|
||||||
|
// Data
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class ZoneRegionObject
|
||||||
|
@brief
|
||||||
|
@details
|
||||||
|
*/
|
||||||
|
class ZoneRegionObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ZoneRegionObject();
|
||||||
|
~ZoneRegionObject();
|
||||||
|
|
||||||
|
/// Load landscape data from file
|
||||||
|
bool load(const std::string &fileName);
|
||||||
|
|
||||||
|
/// Save landscape data to file (before save, should set file name).
|
||||||
|
bool save();
|
||||||
|
|
||||||
|
/// Get ligo data
|
||||||
|
void ligoData(LigoData &data, const sint32 x, const sint32 y);
|
||||||
|
|
||||||
|
/// Set ligo data
|
||||||
|
void setLigoData(const LigoData &data, const sint32 x, const sint32 y);
|
||||||
|
|
||||||
|
/// Get file name
|
||||||
|
std::string fileName() const;
|
||||||
|
|
||||||
|
/// Set file name, use for saving data in file
|
||||||
|
void setFileName(const std::string &fileName);
|
||||||
|
|
||||||
|
/// Accessor to LIGO CZoneRegion
|
||||||
|
NLLIGO::CZoneRegion &ligoZoneRegion();
|
||||||
|
|
||||||
|
void setLigoZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
|
||||||
|
|
||||||
|
/// Check position, it belongs to the landscape
|
||||||
|
bool checkPos(const sint32 x, const sint32 y);
|
||||||
|
|
||||||
|
/// Helper flag to know if a ps has been modified
|
||||||
|
/// @{
|
||||||
|
bool isModified() const;
|
||||||
|
|
||||||
|
void setModified(bool modified);
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool m_modified;
|
||||||
|
bool m_editable;
|
||||||
|
std::string m_fileName;
|
||||||
|
NLLIGO::CZoneRegion m_zoneRegion;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
|
#endif // LANDSCAPE_EDITOR_H
|
Loading…
Reference in a new issue