Tile loading more or less works. TODO: investigate why displacement map lookup causes crashes.
This commit is contained in:
parent
4bb8b3373e
commit
3e3572c3ab
14 changed files with 342 additions and 82 deletions
|
@ -86,6 +86,11 @@ public:
|
||||||
_BitmapName[bitmapType]=name;
|
_BitmapName[bitmapType]=name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getFileName (TBitmap bitmapType) const
|
||||||
|
{
|
||||||
|
return _BitmapName[bitmapType];
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the additional orientation (CCW) for alpha texture.
|
/// Get the additional orientation (CCW) for alpha texture.
|
||||||
uint8 getRotAlpha ()
|
uint8 getRotAlpha ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Ryzom Core Studio - Tile Editor plugin
|
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
|
||||||
//
|
|
||||||
// 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 LAND_H
|
|
||||||
#define LAND_H
|
|
||||||
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
struct Land
|
|
||||||
{
|
|
||||||
QString name;
|
|
||||||
QStringList tilesets;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -229,6 +229,16 @@ void TileBank::renameTileSet( int idx, const QString &newName )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileBank::getTileSets( QStringList &l )
|
||||||
|
{
|
||||||
|
int c = m_pvt->m_bank.getTileSetCount();
|
||||||
|
for( int i = 0; i < c; i++ )
|
||||||
|
{
|
||||||
|
NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( i );
|
||||||
|
l.push_back( set->getName().c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TileBank::addLand( const QString &name )
|
void TileBank::addLand( const QString &name )
|
||||||
{
|
{
|
||||||
m_pvt->m_bank.addLand( name.toUtf8().constData() );
|
m_pvt->m_bank.addLand( name.toUtf8().constData() );
|
||||||
|
@ -239,6 +249,18 @@ void TileBank::removeLand( int idx )
|
||||||
m_pvt->m_bank.removeLand( idx );
|
m_pvt->m_bank.removeLand( idx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileBank::getLands( QStringList &l )
|
||||||
|
{
|
||||||
|
l.clear();
|
||||||
|
|
||||||
|
int c = m_pvt->m_bank.getLandCount();
|
||||||
|
for( int i = 0; i < c; i++ )
|
||||||
|
{
|
||||||
|
NL3D::CTileLand *land = m_pvt->m_bank.getLand( i );
|
||||||
|
l.push_back( land->getName().c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TileBank::setLandSets( int idx, const QStringList &l )
|
void TileBank::setLandSets( int idx, const QStringList &l )
|
||||||
{
|
{
|
||||||
NL3D::CTileLand *land = m_pvt->m_bank.getLand( idx );
|
NL3D::CTileLand *land = m_pvt->m_bank.getLand( idx );
|
||||||
|
@ -392,6 +414,126 @@ void TileBank::clearImage( int ts, int type, int tile, TileConstants::TTileChann
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TileBank::getTileCount( int tileSet, TileConstants::TNodeTileType type )
|
||||||
|
{
|
||||||
|
NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet );
|
||||||
|
if( set == NULL )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int c = 0;
|
||||||
|
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case TileConstants::Tile128:
|
||||||
|
c = set->getNumTile128();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TileConstants::Tile256:
|
||||||
|
c = set->getNumTile256();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TileConstants::TileTransition:
|
||||||
|
c = NL3D::CTileSet::count;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TileConstants::TileDisplacement:
|
||||||
|
c = NL3D::CTileSet::CountDisplace;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TileBank::getRealTileId( int tileSet, TileConstants::TNodeTileType type, int tileIdInSet )
|
||||||
|
{
|
||||||
|
NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet );
|
||||||
|
if( set == NULL )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int tile = -1;
|
||||||
|
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case TileConstants::Tile128:
|
||||||
|
tile = set->getTile128( tileIdInSet );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TileConstants::Tile256:
|
||||||
|
tile = set->getTile256( tileIdInSet );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TileConstants::TileTransition:
|
||||||
|
tile = set->getTransition( tileIdInSet )->getTile();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TileConstants::TileDisplacement:
|
||||||
|
tile = set->getDisplacementTile( NL3D::CTileSet::TDisplacement( tileIdInSet ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileBank::getTileImages( int tileSet, TileConstants::TNodeTileType type, int tileId, TileImages &images )
|
||||||
|
{
|
||||||
|
NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet );
|
||||||
|
if( set == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case TileConstants::Tile128:
|
||||||
|
case TileConstants::Tile256:
|
||||||
|
case TileConstants::TileTransition:
|
||||||
|
{
|
||||||
|
NL3D::CTile *t = m_pvt->m_bank.getTile( tileId );
|
||||||
|
if( t == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
images.diffuse = t->getFileName( channelToTBitmap( TileConstants::TileDiffuse ) ).c_str();
|
||||||
|
images.additive = t->getFileName( channelToTBitmap( TileConstants::TileAdditive ) ).c_str();
|
||||||
|
images.alpha = t->getFileName( channelToTBitmap( TileConstants::TileAlpha ) ).c_str();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TileConstants::TileDisplacement:
|
||||||
|
{
|
||||||
|
images.diffuse = m_pvt->m_bank.getDisplacementMap( tileId );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileBank::getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l )
|
||||||
|
{
|
||||||
|
l.clear();
|
||||||
|
|
||||||
|
NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet );
|
||||||
|
if( set == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int c = getTileCount( tileSet, type );
|
||||||
|
|
||||||
|
TileImages images;
|
||||||
|
|
||||||
|
for( int i = 0; i < c; i++ )
|
||||||
|
{
|
||||||
|
images.clear();
|
||||||
|
|
||||||
|
int id = getRealTileId( tileSet, type, i );
|
||||||
|
if( id < 0 )
|
||||||
|
{
|
||||||
|
l.push_back( images );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTileImages( tileSet, type, id, images );
|
||||||
|
|
||||||
|
l.push_back( images );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TileBank::setVegetation( int tileSet, const QString &vegetation )
|
void TileBank::setVegetation( int tileSet, const QString &vegetation )
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
#include "tile_constants.h"
|
#include "tile_constants.h"
|
||||||
|
#include "tile_images.h"
|
||||||
|
|
||||||
namespace NLMISC
|
namespace NLMISC
|
||||||
{
|
{
|
||||||
|
@ -23,9 +25,11 @@ public:
|
||||||
void addTileSet( const QString &name );
|
void addTileSet( const QString &name );
|
||||||
void removeTileSet( int idx );
|
void removeTileSet( int idx );
|
||||||
void renameTileSet( int idx, const QString &newName );
|
void renameTileSet( int idx, const QString &newName );
|
||||||
|
void getTileSets( QStringList &l );
|
||||||
|
|
||||||
void addLand( const QString &name );
|
void addLand( const QString &name );
|
||||||
void removeLand( int idx );
|
void removeLand( int idx );
|
||||||
|
void getLands( QStringList &l );
|
||||||
void setLandSets( int idx, const QStringList &l );
|
void setLandSets( int idx, const QStringList &l );
|
||||||
void getLandSets( int idx, QStringList &l );
|
void getLandSets( int idx, QStringList &l );
|
||||||
|
|
||||||
|
@ -35,6 +39,12 @@ public:
|
||||||
void replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name, const QVariant &pixmap );
|
void replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name, const QVariant &pixmap );
|
||||||
void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel );
|
void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel );
|
||||||
|
|
||||||
|
|
||||||
|
int getTileCount( int tileSet, TileConstants::TNodeTileType type );
|
||||||
|
int getRealTileId( int tileSet, TileConstants::TNodeTileType type, int tileIdInSet );
|
||||||
|
void getTileImages( int tileSet, TileConstants::TNodeTileType type, int tileId, TileImages &images );
|
||||||
|
void getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l );
|
||||||
|
|
||||||
void setVegetation( int tileSet, const QString &vegetation );
|
void setVegetation( int tileSet, const QString &vegetation );
|
||||||
QString getVegetation( int tileSet ) const;
|
QString getVegetation( int tileSet ) const;
|
||||||
|
|
||||||
|
|
|
@ -271,8 +271,7 @@ void TileEditorMainWindow::open()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileBankLoader loader;
|
TileBankLoader loader;
|
||||||
bool b = true;
|
bool b = loader.load( fn.toUtf8().constData(), m_tileModel );
|
||||||
//loader.load( fn.toUtf8().constData(), m_tileModel, m_lands );
|
|
||||||
|
|
||||||
if( !b )
|
if( !b )
|
||||||
{
|
{
|
||||||
|
@ -374,7 +373,7 @@ void TileEditorMainWindow::onTileSetAdd()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and append the new tile set to the model.
|
// Create and append the new tile set to the model.
|
||||||
TileSetNode *tileSet = model->createTileSetNode(text);
|
m_tileModel->addTileSet( text );
|
||||||
|
|
||||||
// Retrieve how many rows there currently are and set the current index using that.
|
// Retrieve how many rows there currently are and set the current index using that.
|
||||||
uint32 rows = model->rowCount();
|
uint32 rows = model->rowCount();
|
||||||
|
@ -684,8 +683,6 @@ void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
QString selectedFilter;
|
QString selectedFilter;
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Choose Tile Texture", "." , "Images (*.png);;All Files (*.*)", &selectedFilter, options);
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Choose Tile Texture", "." , "Images (*.png);;All Files (*.*)", &selectedFilter, options);
|
||||||
|
|
||||||
int c = n->childCount();
|
|
||||||
|
|
||||||
TileConstants::TNodeTileType type = tabToType( tabId );
|
TileConstants::TNodeTileType type = tabToType( tabId );
|
||||||
|
|
||||||
QStringListIterator itr( fileNames );
|
QStringListIterator itr( fileNames );
|
||||||
|
@ -693,8 +690,9 @@ void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
|
|
||||||
while( itr.hasNext() )
|
while( itr.hasNext() )
|
||||||
{
|
{
|
||||||
TileItemNode *newNode = m_tileModel->createItemNode( setId, type, c, TileConstants::TileDiffuse, itr.next() );
|
bool b = m_tileModel->addTile( setId, type, itr.next(), TileConstants::TileDiffuse );
|
||||||
if( newNode == NULL )
|
|
||||||
|
if( !b )
|
||||||
{
|
{
|
||||||
if( m_tileModel->hasError() )
|
if( m_tileModel->hasError() )
|
||||||
error = m_tileModel->getLastError();
|
error = m_tileModel->getLastError();
|
||||||
|
@ -708,9 +706,7 @@ void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
n->appendRow( newNode );
|
|
||||||
c++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex rootIdx = m_tileModel->index( tabId, 0, m_ui->tileSetLV->currentIndex());
|
QModelIndex rootIdx = m_tileModel->index( tabId, 0, m_ui->tileSetLV->currentIndex());
|
||||||
|
@ -809,7 +805,15 @@ void TileEditorMainWindow::onActionReplaceImage( int tabId )
|
||||||
void TileEditorMainWindow::onTileBankLoaded()
|
void TileEditorMainWindow::onTileBankLoaded()
|
||||||
{
|
{
|
||||||
m_ui->landLW->clear();
|
m_ui->landLW->clear();
|
||||||
// load lands
|
QStringList lands;
|
||||||
|
m_tileModel->getLands( lands );
|
||||||
|
QStringListIterator itr( lands );
|
||||||
|
while( itr.hasNext() )
|
||||||
|
{
|
||||||
|
m_ui->landLW->addItem( itr.next() );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_tileModel->onTBLoaded();
|
||||||
|
|
||||||
m_ui->listView128->reset();
|
m_ui->listView128->reset();
|
||||||
m_ui->listView256->reset();
|
m_ui->listView256->reset();
|
||||||
|
|
23
code/studio/src/plugins/tile_editor/tile_images.h
Normal file
23
code/studio/src/plugins/tile_editor/tile_images.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef TILE_IMAGES_H
|
||||||
|
#define TILE_IMAGES_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
struct TileImages
|
||||||
|
{
|
||||||
|
QString diffuse;
|
||||||
|
QString additive;
|
||||||
|
QString alpha;
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
diffuse.clear();
|
||||||
|
additive.clear();
|
||||||
|
alpha.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -312,6 +312,14 @@ TileItemNode::TileItemNode( TileConstants::TNodeTileType type, int tileId, TileC
|
||||||
setTileFilename( channel, filename );
|
setTileFilename( channel, filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TileItemNode::TileItemNode( TileConstants::TNodeTileType type, int tileId, Node *parent )
|
||||||
|
{
|
||||||
|
m_id = tileId;
|
||||||
|
m_parentItem = parent;
|
||||||
|
pvt = new TileItemNodePvt();
|
||||||
|
m_hasError = false;
|
||||||
|
}
|
||||||
|
|
||||||
TileItemNode::~TileItemNode()
|
TileItemNode::~TileItemNode()
|
||||||
{
|
{
|
||||||
delete pvt;
|
delete pvt;
|
||||||
|
|
|
@ -107,6 +107,7 @@ class TileItemNode : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TileItemNode( TileConstants::TNodeTileType type, int tileId, TileConstants::TTileChannel channel, QString filename, Node *parent=0);
|
TileItemNode( TileConstants::TNodeTileType type, int tileId, TileConstants::TTileChannel channel, QString filename, Node *parent=0);
|
||||||
|
TileItemNode( TileConstants::TNodeTileType type, int tileId, Node *parent=0);
|
||||||
virtual ~TileItemNode();
|
virtual ~TileItemNode();
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
int columnCount() const;
|
int columnCount() const;
|
||||||
|
|
|
@ -218,16 +218,10 @@ TileSetNode *TileModel::createTileSetNode(QString tileSetName)
|
||||||
|
|
||||||
// Append them in the correct order to the tile set.
|
// Append them in the correct order to the tile set.
|
||||||
this->appendRow(tileSet);
|
this->appendRow(tileSet);
|
||||||
m_tileBank->addTileSet(tileSetName);
|
|
||||||
|
|
||||||
return tileSet;
|
return tileSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileItemNode *TileModel::createItemNode( TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName )
|
|
||||||
{
|
|
||||||
return new TileItemNode( type, id, channel, fileName );
|
|
||||||
}
|
|
||||||
|
|
||||||
TileItemNode *TileModel::createItemNode( int idx, TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName )
|
TileItemNode *TileModel::createItemNode( int idx, TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName )
|
||||||
{
|
{
|
||||||
TileItemNode *n = new TileItemNode( type, id, channel, fileName );
|
TileItemNode *n = new TileItemNode( type, id, channel, fileName );
|
||||||
|
@ -305,6 +299,12 @@ void TileModel::clear()
|
||||||
removeRows( 0, c );
|
removeRows( 0, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileModel::onTBLoaded()
|
||||||
|
{
|
||||||
|
loadTileSets();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TileModel::addLand( const QString &name )
|
void TileModel::addLand( const QString &name )
|
||||||
{
|
{
|
||||||
m_tileBank->addLand( name );
|
m_tileBank->addLand( name );
|
||||||
|
@ -315,6 +315,11 @@ void TileModel::removeLand( int idx )
|
||||||
m_tileBank->removeLand( idx );
|
m_tileBank->removeLand( idx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileModel::getLands( QStringList &l )
|
||||||
|
{
|
||||||
|
m_tileBank->getLands( l );
|
||||||
|
}
|
||||||
|
|
||||||
void TileModel::setLandSets( int idx, const QStringList &l )
|
void TileModel::setLandSets( int idx, const QStringList &l )
|
||||||
{
|
{
|
||||||
m_tileBank->setLandSets( idx, l );
|
m_tileBank->setLandSets( idx, l );
|
||||||
|
@ -325,6 +330,15 @@ void TileModel::getLandSets( int idx, QStringList &l )
|
||||||
m_tileBank->getLandSets( idx, l );
|
m_tileBank->getLandSets( idx, l );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TileModel::addTileSet( const QString &name )
|
||||||
|
{
|
||||||
|
m_tileBank->addTileSet( name );
|
||||||
|
TileSetNode *tsn = createTileSetNode( name );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void TileModel::removeTileSet( int idx )
|
void TileModel::removeTileSet( int idx )
|
||||||
{
|
{
|
||||||
TileSetNode *set = static_cast< TileSetNode* >( rootItem->child( idx ) );
|
TileSetNode *set = static_cast< TileSetNode* >( rootItem->child( idx ) );
|
||||||
|
@ -341,6 +355,35 @@ void TileModel::renameTileSet( int idx, const QString &newName )
|
||||||
m_tileBank->renameTileSet( idx, newName );
|
m_tileBank->renameTileSet( idx, newName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TileModel::addTile( int ts, int type, const QString &fileName, TileConstants::TTileChannel channel )
|
||||||
|
{
|
||||||
|
TileSetNode *tsn = static_cast< TileSetNode* >( rootItem->child( ts ) );
|
||||||
|
if( tsn == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TileTypeNode *ttn = static_cast< TileTypeNode* >( tsn->child( type ) );
|
||||||
|
if( ttn == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int tile = ttn->childCount();
|
||||||
|
|
||||||
|
TileConstants::TNodeTileType t = TileConstants::TNodeTileType( type );
|
||||||
|
|
||||||
|
TileItemNode *item = new TileItemNode( t, tile, channel, fileName );
|
||||||
|
|
||||||
|
bool b = m_tileBank->addTile( ts, fileName, item->pixmap( channel ), channel, t );
|
||||||
|
if( !b )
|
||||||
|
{
|
||||||
|
delete item;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
item->setParent( ttn );
|
||||||
|
ttn->appendRow( item );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void TileModel::removeTile( int ts, int type, int tile )
|
void TileModel::removeTile( int ts, int type, int tile )
|
||||||
{
|
{
|
||||||
TileSetNode *set = static_cast< TileSetNode* >( rootItem->child( ts ) );
|
TileSetNode *set = static_cast< TileSetNode* >( rootItem->child( ts ) );
|
||||||
|
@ -458,4 +501,73 @@ void TileModel::selectFilenameDisplay(bool selected)
|
||||||
void TileModel::selectIndexDisplay(bool selected)
|
void TileModel::selectIndexDisplay(bool selected)
|
||||||
{
|
{
|
||||||
m_indexDisplay = selected;
|
m_indexDisplay = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileModel::loadTileSets()
|
||||||
|
{
|
||||||
|
QStringList l;
|
||||||
|
m_tileBank->getTileSets( l );
|
||||||
|
|
||||||
|
// Create tile sets
|
||||||
|
QStringListIterator itr( l );
|
||||||
|
while( itr.hasNext() )
|
||||||
|
{
|
||||||
|
createTileSetNode( itr.next() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loads sets
|
||||||
|
int c = rootItem->childCount();
|
||||||
|
for( int i = 0; i < c; i++ )
|
||||||
|
{
|
||||||
|
loadTileSet( i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TileModel::loadTileSet( int tileSet )
|
||||||
|
{
|
||||||
|
TileSetNode *set = static_cast< TileSetNode* >( rootItem->child( tileSet ) );
|
||||||
|
|
||||||
|
QList< TileImages > l;
|
||||||
|
//for( int i = TileConstants::Tile128; i < TileConstants::TileNodeTypeCount; i++ )
|
||||||
|
//for( int i = TileConstants::Tile128; i < TileConstants::TileTransition; i++ )
|
||||||
|
for( int i = TileConstants::Tile128; i < TileConstants::TileDisplacement; i++ )
|
||||||
|
{
|
||||||
|
TileConstants::TNodeTileType type = TileConstants::TNodeTileType( i );
|
||||||
|
l.clear();
|
||||||
|
m_tileBank->getTileImages( tileSet, type, l );
|
||||||
|
|
||||||
|
loadTileTypeNode( tileSet, type, l );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileModel::loadTileTypeNode( int tileSet, int type, const QList< TileImages > &l )
|
||||||
|
{
|
||||||
|
TileSetNode *set = static_cast< TileSetNode* >( rootItem->child( tileSet ) );
|
||||||
|
TileTypeNode *ttn = static_cast< TileTypeNode* >( set->child( type ) );
|
||||||
|
|
||||||
|
int tile = 0;
|
||||||
|
|
||||||
|
QList< TileImages >::const_iterator itr = l.begin();
|
||||||
|
while( itr != l.end() )
|
||||||
|
{
|
||||||
|
const TileImages &images = *itr;
|
||||||
|
|
||||||
|
TileItemNode *item = NULL;
|
||||||
|
|
||||||
|
if( ( type == TileConstants::Tile128 ) || ( type == TileConstants::Tile256 ) )
|
||||||
|
item = new TileItemNode( TileConstants::TNodeTileType( type ), tile, ttn );
|
||||||
|
else
|
||||||
|
item = static_cast< TileItemNode* >( ttn->child( tile ) );
|
||||||
|
|
||||||
|
item->setTileFilename( TileConstants::TileDiffuse, images.diffuse );
|
||||||
|
item->setTileFilename( TileConstants::TileAdditive, images.additive );
|
||||||
|
item->setTileFilename( TileConstants::TileAlpha, images.alpha );
|
||||||
|
|
||||||
|
if( ( type == TileConstants::Tile128 ) || ( type == TileConstants::Tile256 ) )
|
||||||
|
ttn->appendRow( item );
|
||||||
|
|
||||||
|
++itr;
|
||||||
|
tile++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "tile_constants.h"
|
#include "tile_constants.h"
|
||||||
|
#include "tile_images.h"
|
||||||
|
|
||||||
namespace NLMISC
|
namespace NLMISC
|
||||||
{
|
{
|
||||||
|
@ -32,6 +33,7 @@ class Node;
|
||||||
class TileSetNode;
|
class TileSetNode;
|
||||||
class TileItemNode;
|
class TileItemNode;
|
||||||
class TileBank;
|
class TileBank;
|
||||||
|
class TileModelPvt;
|
||||||
|
|
||||||
class TileModel : public QAbstractItemModel
|
class TileModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
|
@ -77,8 +79,6 @@ public:
|
||||||
|
|
||||||
void swapRows( int a, int b );
|
void swapRows( int a, int b );
|
||||||
|
|
||||||
TileSetNode *createTileSetNode(QString tileSetName);
|
|
||||||
static TileItemNode *createItemNode( TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName );
|
|
||||||
TileItemNode *createItemNode( int idx, TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName );
|
TileItemNode *createItemNode( int idx, TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName );
|
||||||
|
|
||||||
static const char *getTileTypeName(TileConstants::TNodeTileType type);
|
static const char *getTileTypeName(TileConstants::TNodeTileType type);
|
||||||
|
@ -89,13 +89,20 @@ public:
|
||||||
bool hasTileSet( const QString &name );
|
bool hasTileSet( const QString &name );
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
void onTBLoaded();
|
||||||
|
|
||||||
void addLand( const QString &name );
|
void addLand( const QString &name );
|
||||||
void removeLand( int idx );
|
void removeLand( int idx );
|
||||||
|
void getLands( QStringList &l );
|
||||||
|
|
||||||
|
bool addTileSet( const QString &name );
|
||||||
|
|
||||||
void removeTileSet( int idx );
|
void removeTileSet( int idx );
|
||||||
void renameTileSet( int idx, const QString &newName );
|
void renameTileSet( int idx, const QString &newName );
|
||||||
void setLandSets( int idx, const QStringList &l );
|
void setLandSets( int idx, const QStringList &l );
|
||||||
void getLandSets( int idx, QStringList &l );
|
void getLandSets( int idx, QStringList &l );
|
||||||
|
|
||||||
|
bool addTile( int ts, int type, const QString &fileName, TileConstants::TTileChannel channel );
|
||||||
void removeTile( int ts, int type, int tile );
|
void removeTile( int ts, int type, int tile );
|
||||||
bool replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name );
|
bool replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name );
|
||||||
void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel );
|
void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel );
|
||||||
|
@ -122,7 +129,11 @@ public Q_SLOTS:
|
||||||
void selectIndexDisplay(bool selected);
|
void selectIndexDisplay(bool selected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
TileSetNode *createTileSetNode(QString tileSetName);
|
||||||
Node *getItem(const QModelIndex &index) const;
|
Node *getItem(const QModelIndex &index) const;
|
||||||
|
void loadTileSets();
|
||||||
|
void loadTileSet( int tileSet );
|
||||||
|
void loadTileTypeNode( int tileSet, int type, const QList< TileImages > &l );
|
||||||
|
|
||||||
bool m_fileDisplay;
|
bool m_fileDisplay;
|
||||||
bool m_indexDisplay;
|
bool m_indexDisplay;
|
||||||
|
@ -133,6 +144,7 @@ private:
|
||||||
Node *rootItem;
|
Node *rootItem;
|
||||||
|
|
||||||
TileBank *m_tileBank;
|
TileBank *m_tileBank;
|
||||||
|
TileModelPvt *pvt;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TILE_MODEL_H
|
#endif // TILE_MODEL_H
|
||||||
|
|
|
@ -18,35 +18,23 @@
|
||||||
#include "tilebank_loader.h"
|
#include "tilebank_loader.h"
|
||||||
|
|
||||||
#include "tile_model.h"
|
#include "tile_model.h"
|
||||||
#include "tile_item.h"
|
|
||||||
|
|
||||||
#include "nel/3d/tile_bank.h"
|
|
||||||
#include "nel/misc/file.h"
|
#include "nel/misc/file.h"
|
||||||
|
|
||||||
class TileBankLoaderPvt
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
TileBankLoader::TileBankLoader()
|
TileBankLoader::TileBankLoader()
|
||||||
{
|
{
|
||||||
p = new TileBankLoaderPvt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TileBankLoader::~TileBankLoader()
|
TileBankLoader::~TileBankLoader()
|
||||||
{
|
{
|
||||||
delete p;
|
|
||||||
p = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileBankLoader::load( const char *filename, TileModel *model, QList< Land > &lands )
|
bool TileBankLoader::load( const char *filename, TileModel *model )
|
||||||
{
|
{
|
||||||
NLMISC::CIFile file;
|
NLMISC::CIFile file;
|
||||||
if( !file.open( filename, false ) )
|
if( !file.open( filename, false ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//p->bank.serial( file );
|
model->serial( file );
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,7 @@
|
||||||
#ifndef TILEBANK_LOADER_H
|
#ifndef TILEBANK_LOADER_H
|
||||||
#define TILEBANK_LOADER_H
|
#define TILEBANK_LOADER_H
|
||||||
|
|
||||||
#include "land.h"
|
|
||||||
|
|
||||||
class TileModel;
|
class TileModel;
|
||||||
class TileBankLoaderPvt;
|
|
||||||
|
|
||||||
class TileBankLoader
|
class TileBankLoader
|
||||||
{
|
{
|
||||||
|
@ -28,10 +25,9 @@ public:
|
||||||
TileBankLoader();
|
TileBankLoader();
|
||||||
~TileBankLoader();
|
~TileBankLoader();
|
||||||
|
|
||||||
bool load( const char *filename, TileModel *model, QList< Land > &lands );
|
bool load( const char *filename, TileModel *model );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TileBankLoaderPvt *p;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,21 +22,12 @@
|
||||||
#include "nel/3d/tile_bank.h"
|
#include "nel/3d/tile_bank.h"
|
||||||
#include "nel/misc/file.h"
|
#include "nel/misc/file.h"
|
||||||
|
|
||||||
class TileBankSaverPvt
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
TileBankSaver::TileBankSaver()
|
TileBankSaver::TileBankSaver()
|
||||||
{
|
{
|
||||||
p = new TileBankSaverPvt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TileBankSaver::~TileBankSaver()
|
TileBankSaver::~TileBankSaver()
|
||||||
{
|
{
|
||||||
delete p;
|
|
||||||
p = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileBankSaver::save( const char *fileName, TileModel* model )
|
bool TileBankSaver::save( const char *fileName, TileModel* model )
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
class TileModel;
|
class TileModel;
|
||||||
class TileBankSaverPvt;
|
|
||||||
|
|
||||||
class TileBankSaver
|
class TileBankSaver
|
||||||
{
|
{
|
||||||
|
@ -33,7 +32,7 @@ public:
|
||||||
bool save( const char *filename, TileModel* model );
|
bool save( const char *filename, TileModel* model );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TileBankSaverPvt *p;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue