mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 05:36:13 +00:00
Started to rework tile checks, tile banks loading / saving. A tilebank will now be in the tilemodel, and it will work from there. Also moved some constants into an independent file.
This commit is contained in:
parent
16791d58c1
commit
8d7c974be6
11 changed files with 349 additions and 137 deletions
|
@ -172,6 +172,8 @@ public:
|
||||||
return _TileSet.find (name)!=_TileSet.end();
|
return _TileSet.find (name)!=_TileSet.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear(){ _TileSet.clear(); }
|
||||||
|
|
||||||
void serial(class NLMISC::IStream &f) throw(NLMISC::EStream);
|
void serial(class NLMISC::IStream &f) throw(NLMISC::EStream);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
110
code/studio/src/plugins/tile_editor/tile_bank.cpp
Normal file
110
code/studio/src/plugins/tile_editor/tile_bank.cpp
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
#include "tile_bank.h"
|
||||||
|
#include "nel/3d/tile_bank.h"
|
||||||
|
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
bool pixmapToCBGRA( QPixmap &pixmap, std::vector< NLMISC::CBGRA >& pixels )
|
||||||
|
{
|
||||||
|
QImage img = pixmap.toImage();
|
||||||
|
if( img.format() != QImage::Format_ARGB32 )
|
||||||
|
img = img.convertToFormat( QImage::Format_ARGB32 );
|
||||||
|
|
||||||
|
if( img.format() != QImage::Format_ARGB32 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int c = img.width() * img.height();
|
||||||
|
|
||||||
|
const unsigned char *data = img.bits();
|
||||||
|
const unsigned int *idata = reinterpret_cast< const unsigned int* >( data );
|
||||||
|
|
||||||
|
NLMISC::CBGRA bgra;
|
||||||
|
pixels.clear();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while( i < c )
|
||||||
|
{
|
||||||
|
bgra.A = ( idata[ i ] & 0xFF000000 ) >> 24;
|
||||||
|
bgra.R = ( idata[ i ] & 0x00FF0000 ) >> 16;
|
||||||
|
bgra.G = ( idata[ i ] & 0x0000FF00 ) >> 8;
|
||||||
|
bgra.B = ( idata[ i ] & 0x000000FF );
|
||||||
|
pixels.push_back( bgra );
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
class TileBankPvt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NL3D::CTileBank m_bank;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TileBank::TileBank()
|
||||||
|
{
|
||||||
|
m_pvt = new TileBankPvt();
|
||||||
|
}
|
||||||
|
|
||||||
|
TileBank::~TileBank()
|
||||||
|
{
|
||||||
|
delete m_pvt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileBank::addTileSet( const QString &name )
|
||||||
|
{
|
||||||
|
m_pvt->m_bank.addTileSet( name.toUtf8().constData() );
|
||||||
|
NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileBank::addLand( const QString &name )
|
||||||
|
{
|
||||||
|
m_pvt->m_bank.addLand( name.toUtf8().constData() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileBank::setLandSets( int idx, const QStringList &l )
|
||||||
|
{
|
||||||
|
NL3D::CTileLand *land = m_pvt->m_bank.getLand( idx );
|
||||||
|
land->clear();
|
||||||
|
|
||||||
|
QStringListIterator itr( l );
|
||||||
|
while( itr.hasNext() )
|
||||||
|
{
|
||||||
|
land->addTileSet( itr.next().toUtf8().constData() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TileBank::addTileToSet( int idx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type )
|
||||||
|
{
|
||||||
|
NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( idx );
|
||||||
|
if( set == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QPixmap pm = pixmap.value< QPixmap >();
|
||||||
|
if( pm.isNull() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( pm.width() != pm.height() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::vector< NLMISC::CBGRA > pixels;
|
||||||
|
pixmapToCBGRA( pm, pixels );
|
||||||
|
|
||||||
|
int tile;
|
||||||
|
set->addTile128( tile, m_pvt->m_bank );
|
||||||
|
|
||||||
|
NL3D::CTileBorder border;
|
||||||
|
border.set( pm.width(), pm.height(), pixels );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
29
code/studio/src/plugins/tile_editor/tile_bank.h
Normal file
29
code/studio/src/plugins/tile_editor/tile_bank.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef TILE_BANK_H
|
||||||
|
#define TILE_BANK_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include "tile_constants.h"
|
||||||
|
|
||||||
|
class TileBankPvt;
|
||||||
|
|
||||||
|
class TileBank
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TileBank();
|
||||||
|
~TileBank();
|
||||||
|
|
||||||
|
void addTileSet( const QString &name );
|
||||||
|
void addLand( const QString &name );
|
||||||
|
void setLandSets( int idx, const QStringList &l );
|
||||||
|
|
||||||
|
bool addTileToSet( int idx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type );
|
||||||
|
|
||||||
|
private:
|
||||||
|
TileBankPvt *m_pvt;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
26
code/studio/src/plugins/tile_editor/tile_constants.h
Normal file
26
code/studio/src/plugins/tile_editor/tile_constants.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef TILE_CONSTANTS_H
|
||||||
|
#define TILE_CONSTANTS_H
|
||||||
|
|
||||||
|
|
||||||
|
namespace TileConstants
|
||||||
|
{
|
||||||
|
enum TTileChannel
|
||||||
|
{
|
||||||
|
TileDiffuse = 0,
|
||||||
|
TileAdditive = 1,
|
||||||
|
TileAlpha = 2,
|
||||||
|
TileChannelCount = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum TNodeTileType
|
||||||
|
{
|
||||||
|
Tile128 = 0,
|
||||||
|
Tile256 = 1,
|
||||||
|
TileTransition = 2,
|
||||||
|
TileDisplacement = 3,
|
||||||
|
TileNodeTypeCount = 4
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -648,7 +648,7 @@ void TileEditorMainWindow::onDiffuseToggled( bool b )
|
||||||
if( !b )
|
if( !b )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileItemNode::setDisplayChannel( TileModel::TileDiffuse );
|
TileItemNode::setDisplayChannel( TileConstants::TileDiffuse );
|
||||||
updateTab();
|
updateTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +657,7 @@ void TileEditorMainWindow::onAdditiveToggled( bool b )
|
||||||
if( !b )
|
if( !b )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileItemNode::setDisplayChannel( TileModel::TileAdditive );
|
TileItemNode::setDisplayChannel( TileConstants::TileAdditive );
|
||||||
updateTab();
|
updateTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ void TileEditorMainWindow::onAlphaToggled( bool b )
|
||||||
if( !b )
|
if( !b )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileItemNode::setDisplayChannel( TileModel::TileAlpha );
|
TileItemNode::setDisplayChannel( TileConstants::TileAlpha );
|
||||||
updateTab();
|
updateTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,12 +680,12 @@ void TileEditorMainWindow::onTabChanged( int tab )
|
||||||
m_ui->diffuseTrBT->setChecked( true );
|
m_ui->diffuseTrBT->setChecked( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
TileModel::TNodeTileType tabToType( int tabId )
|
TileConstants::TNodeTileType tabToType( int tabId )
|
||||||
{
|
{
|
||||||
if( tabId >= TileModel::TileNodeTypeCount )
|
if( tabId >= TileConstants::TileNodeTypeCount )
|
||||||
return TileModel::TileNodeTypeCount;
|
return TileConstants::TileNodeTypeCount;
|
||||||
|
|
||||||
return TileModel::TNodeTileType( tabId );
|
return TileConstants::TNodeTileType( tabId );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileEditorMainWindow::onActionAddTile(int tabId)
|
void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
|
@ -705,6 +705,8 @@ void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
if( !idx.isValid() )
|
if( !idx.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int setId = idx.row();
|
||||||
|
|
||||||
TileSetNode *tsn = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
|
TileSetNode *tsn = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
|
||||||
|
|
||||||
Node *n = tsn->child( tabId );
|
Node *n = tsn->child( tabId );
|
||||||
|
@ -715,12 +717,25 @@ void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
|
|
||||||
int c = n->childCount();
|
int c = n->childCount();
|
||||||
|
|
||||||
TileModel::TNodeTileType type = tabToType( tabId );
|
TileConstants::TNodeTileType type = tabToType( tabId );
|
||||||
|
|
||||||
QStringListIterator itr( fileNames );
|
QStringListIterator itr( fileNames );
|
||||||
while( itr.hasNext() )
|
while( itr.hasNext() )
|
||||||
{
|
{
|
||||||
TileItemNode *newNode = TileModel::createItemNode( type, c, TileModel::TileDiffuse, itr.next() );
|
TileItemNode *newNode = m_tileModel->createItemNode( setId, type, c, TileConstants::TileDiffuse, itr.next() );
|
||||||
|
if( newNode == NULL )
|
||||||
|
{
|
||||||
|
int reply = QMessageBox::question( this,
|
||||||
|
tr( "Error adding tile" ),
|
||||||
|
tr( "Failed to create tile!\nContinue?" ),
|
||||||
|
QMessageBox::Yes, QMessageBox::No );
|
||||||
|
if( reply != QMessageBox::Yes )
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if( newNode->hasError() )
|
if( newNode->hasError() )
|
||||||
{
|
{
|
||||||
QString error = newNode->getLastError();
|
QString error = newNode->getLastError();
|
||||||
|
|
|
@ -203,7 +203,7 @@ int TileSetNode::columnCount() const
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
TileTypeNode::TileTypeNode(TileModel::TNodeTileType type, Node *parent) : m_nodeTileType(type)
|
TileTypeNode::TileTypeNode(TileConstants::TNodeTileType type, Node *parent) : m_nodeTileType(type)
|
||||||
{
|
{
|
||||||
m_parentItem = parent;
|
m_parentItem = parent;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ int TileTypeNode::columnCount() const
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileModel::TNodeTileType TileTypeNode::getTileType()
|
TileConstants::TNodeTileType TileTypeNode::getTileType()
|
||||||
{
|
{
|
||||||
return m_nodeTileType;
|
return m_nodeTileType;
|
||||||
}
|
}
|
||||||
|
@ -266,15 +266,15 @@ void TileTypeNode::reindex()
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
NL3D::CTile::TBitmap channelToTBitmap( TileModel::TTileChannel channel )
|
NL3D::CTile::TBitmap channelToTBitmap( TileConstants::TTileChannel channel )
|
||||||
{
|
{
|
||||||
NL3D::CTile::TBitmap bm;
|
NL3D::CTile::TBitmap bm;
|
||||||
|
|
||||||
switch( channel )
|
switch( channel )
|
||||||
{
|
{
|
||||||
case TileModel::TileDiffuse: bm = NL3D::CTile::diffuse; break;
|
case TileConstants::TileDiffuse: bm = NL3D::CTile::diffuse; break;
|
||||||
case TileModel::TileAdditive: bm = NL3D::CTile::additive; break;
|
case TileConstants::TileAdditive: bm = NL3D::CTile::additive; break;
|
||||||
case TileModel::TileAlpha: bm = NL3D::CTile::alpha; break;
|
case TileConstants::TileAlpha: bm = NL3D::CTile::alpha; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bm;
|
return bm;
|
||||||
|
@ -286,7 +286,7 @@ public:
|
||||||
|
|
||||||
TileItemNodePvt()
|
TileItemNodePvt()
|
||||||
{
|
{
|
||||||
for( int i = 0; i < TileModel::TileChannelCount; i++ )
|
for( int i = 0; i < TileConstants::TileChannelCount; i++ )
|
||||||
m_borderFirst[ i ] = false;
|
m_borderFirst[ i ] = false;
|
||||||
|
|
||||||
m_id = -1;
|
m_id = -1;
|
||||||
|
@ -325,33 +325,33 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getWidthForType( TileModel::TNodeTileType type, TileModel::TTileChannel channel )
|
int getWidthForType( TileConstants::TNodeTileType type, TileConstants::TTileChannel channel )
|
||||||
{
|
{
|
||||||
int width = -1;
|
int width = -1;
|
||||||
|
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case TileModel::Tile128: width = 128; break;
|
case TileConstants::Tile128: width = 128; break;
|
||||||
case TileModel::Tile256: width = 256; break;
|
case TileConstants::Tile256: width = 256; break;
|
||||||
case TileModel::TileTransition:
|
case TileConstants::TileTransition:
|
||||||
{
|
{
|
||||||
if( channel != TileModel::TileAlpha )
|
if( channel != TileConstants::TileAlpha )
|
||||||
width = 128;
|
width = 128;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TileModel::TileDisplacement: width = 32; break;
|
case TileConstants::TileDisplacement: width = 32; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
NL3D::CTileSet::TError checkTile( TileModel::TTileChannel channel )
|
NL3D::CTileSet::TError checkTile( TileConstants::TTileChannel channel )
|
||||||
{
|
{
|
||||||
if( m_type == TileModel::TileDisplacement )
|
if( m_type == TileConstants::TileDisplacement )
|
||||||
return NL3D::CTileSet::ok;
|
return NL3D::CTileSet::ok;
|
||||||
|
|
||||||
if( channel == TileModel::TileAdditive )
|
if( channel == TileConstants::TileAdditive )
|
||||||
return NL3D::CTileSet::ok;
|
return NL3D::CTileSet::ok;
|
||||||
|
|
||||||
int pixel;
|
int pixel;
|
||||||
|
@ -365,14 +365,14 @@ public:
|
||||||
|
|
||||||
switch( m_type )
|
switch( m_type )
|
||||||
{
|
{
|
||||||
case TileModel::Tile128:
|
case TileConstants::Tile128:
|
||||||
error = set.checkTile128( bm, m_border[ channel ], pixel, component );
|
error = set.checkTile128( bm, m_border[ channel ], pixel, component );
|
||||||
break;
|
break;
|
||||||
case TileModel::Tile256:
|
case TileConstants::Tile256:
|
||||||
error = set.checkTile256( bm, m_border[ channel ], pixel, component );
|
error = set.checkTile256( bm, m_border[ channel ], pixel, component );
|
||||||
break;
|
break;
|
||||||
case TileModel::TileTransition:
|
case TileConstants::TileTransition:
|
||||||
if( channel != TileModel::TileAlpha )
|
if( channel != TileConstants::TileAlpha )
|
||||||
error = set.checkTile128( bm, m_border[ channel ], pixel, component );
|
error = set.checkTile128( bm, m_border[ channel ], pixel, component );
|
||||||
else
|
else
|
||||||
error = set.checkTileTransition( NL3D::CTileSet::TTransition( m_id ), bm, m_border[ channel ], index, pixel, component );
|
error = set.checkTileTransition( NL3D::CTileSet::TTransition( m_id ), bm, m_border[ channel ], index, pixel, component );
|
||||||
|
@ -394,13 +394,13 @@ public:
|
||||||
|
|
||||||
switch( m_type )
|
switch( m_type )
|
||||||
{
|
{
|
||||||
case TileModel::Tile128:
|
case TileConstants::Tile128:
|
||||||
case TileModel::Tile256:
|
case TileConstants::Tile256:
|
||||||
m_lastError += QString( "pixel: %1 component: %2" ).arg( pixel ).arg( comp[ component ] );
|
m_lastError += QString( "pixel: %1 component: %2" ).arg( pixel ).arg( comp[ component ] );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TileModel::TileTransition:
|
case TileConstants::TileTransition:
|
||||||
if( channel != TileModel::TileAlpha )
|
if( channel != TileConstants::TileAlpha )
|
||||||
{
|
{
|
||||||
m_lastError += QString( "pixel: %1 component: %2" ).arg( pixel ).arg( comp[ component ] );
|
m_lastError += QString( "pixel: %1 component: %2" ).arg( pixel ).arg( comp[ component ] );
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ public:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkPixmap( TileModel::TTileChannel channel, QPixmap &pixmap )
|
bool checkPixmap( TileConstants::TTileChannel channel, QPixmap &pixmap )
|
||||||
{
|
{
|
||||||
int w = pixmap.width();
|
int w = pixmap.width();
|
||||||
int h = pixmap.height();
|
int h = pixmap.height();
|
||||||
|
@ -470,7 +470,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadImage( TileModel::TTileChannel channel, const QString &fn, bool empty = false )
|
bool loadImage( TileConstants::TTileChannel channel, const QString &fn, bool empty = false )
|
||||||
{
|
{
|
||||||
QPixmap temp;
|
QPixmap temp;
|
||||||
bool b = temp.load( fn );
|
bool b = temp.load( fn );
|
||||||
|
@ -483,52 +483,54 @@ public:
|
||||||
|
|
||||||
m_borderFirst[ channel ] = false;
|
m_borderFirst[ channel ] = false;
|
||||||
|
|
||||||
|
/*
|
||||||
if( !empty )
|
if( !empty )
|
||||||
{
|
{
|
||||||
if( !checkPixmap( channel, temp ) )
|
if( !checkPixmap( channel, temp ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
pixmaps[ channel ] = temp;
|
pixmaps[ channel ] = temp;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearImage( TileModel::TTileChannel channel )
|
void clearImage( TileConstants::TTileChannel channel )
|
||||||
{
|
{
|
||||||
pixmaps[ channel ] = QPixmap();
|
pixmaps[ channel ] = QPixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap& pixMap( TileModel::TTileChannel channel ) const{
|
const QPixmap& pixMap( TileConstants::TTileChannel channel ) const{
|
||||||
return pixmaps[ channel ];
|
return pixmaps[ channel ];
|
||||||
}
|
}
|
||||||
|
|
||||||
void setType( TileModel::TNodeTileType type ){ m_type = type; }
|
void setType( TileConstants::TNodeTileType type ){ m_type = type; }
|
||||||
void setId( int id ){ m_id = id; }
|
void setId( int id ){ m_id = id; }
|
||||||
int id() const{ return m_id; }
|
int id() const{ return m_id; }
|
||||||
|
|
||||||
QString getLastError() const{ return m_lastError; }
|
QString getLastError() const{ return m_lastError; }
|
||||||
bool borderFirst( TileModel::TTileChannel channel ) const{ return m_borderFirst[ channel ]; }
|
bool borderFirst( TileConstants::TTileChannel channel ) const{ return m_borderFirst[ channel ]; }
|
||||||
|
|
||||||
const NL3D::CTileBorder &border( TileModel::TTileChannel channel ){ return m_border[ channel ]; }
|
const NL3D::CTileBorder &border( TileConstants::TTileChannel channel ){ return m_border[ channel ]; }
|
||||||
|
|
||||||
int alphaRot() const{ return m_alphaRot; }
|
int alphaRot() const{ return m_alphaRot; }
|
||||||
void setAlphaRot( int rot ){ m_alphaRot = rot; }
|
void setAlphaRot( int rot ){ m_alphaRot = rot; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap pixmaps[ TileModel::TileChannelCount ];
|
QPixmap pixmaps[ TileConstants::TileChannelCount ];
|
||||||
TileModel::TNodeTileType m_type;
|
TileConstants::TNodeTileType m_type;
|
||||||
NL3D::CTileBorder m_border[ TileModel::TileChannelCount ];
|
NL3D::CTileBorder m_border[ TileConstants::TileChannelCount ];
|
||||||
int m_id;
|
int m_id;
|
||||||
QString m_lastError;
|
QString m_lastError;
|
||||||
bool m_borderFirst[ TileModel::TileChannelCount ];
|
bool m_borderFirst[ TileConstants::TileChannelCount ];
|
||||||
int m_alphaRot;
|
int m_alphaRot;
|
||||||
};
|
};
|
||||||
|
|
||||||
TileModel::TTileChannel TileItemNode::s_displayChannel = TileModel::TileDiffuse;
|
TileConstants::TTileChannel TileItemNode::s_displayChannel = TileConstants::TileDiffuse;
|
||||||
int TileItemNode::s_alphaRot = 0;
|
int TileItemNode::s_alphaRot = 0;
|
||||||
|
|
||||||
TileItemNode::TileItemNode( TileModel::TNodeTileType type, int tileId, TileModel::TTileChannel channel, QString filename, Node *parent)
|
TileItemNode::TileItemNode( TileConstants::TNodeTileType type, int tileId, TileConstants::TTileChannel channel, QString filename, Node *parent)
|
||||||
{
|
{
|
||||||
m_parentItem = parent;
|
m_parentItem = parent;
|
||||||
//nlinfo("dispalying tile %d - %s", m_tileId, m_tileFilename[TileModel::TileDiffuse].toAscii().data());
|
//nlinfo("dispalying tile %d - %s", m_tileId, m_tileFilename[TileModel::TileDiffuse].toAscii().data());
|
||||||
|
@ -550,7 +552,7 @@ TileItemNode::~TileItemNode()
|
||||||
qDeleteAll(m_childItems);
|
qDeleteAll(m_childItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileItemNode::setTileFilename(TileModel::TTileChannel channel, QString filename)
|
bool TileItemNode::setTileFilename(TileConstants::TTileChannel channel, QString filename)
|
||||||
{
|
{
|
||||||
QString fn = filename;
|
QString fn = filename;
|
||||||
bool empty = false;
|
bool empty = false;
|
||||||
|
@ -571,9 +573,9 @@ bool TileItemNode::setTileFilename(TileModel::TTileChannel channel, QString file
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TileItemNode::getTileFilename(TileModel::TTileChannel channel)
|
QString TileItemNode::getTileFilename(TileConstants::TTileChannel channel)
|
||||||
{
|
{
|
||||||
QMap< TileModel::TTileChannel, QString >::const_iterator itr
|
QMap< TileConstants::TTileChannel, QString >::const_iterator itr
|
||||||
= m_tileFilename.find( channel );
|
= m_tileFilename.find( channel );
|
||||||
if( itr == m_tileFilename.end() )
|
if( itr == m_tileFilename.end() )
|
||||||
return "";
|
return "";
|
||||||
|
@ -596,12 +598,12 @@ QString TileItemNode::getLastError() const
|
||||||
return pvt->getLastError();
|
return pvt->getLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileItemNode::borderFirst( TileModel::TTileChannel channel ) const
|
bool TileItemNode::borderFirst( TileConstants::TTileChannel channel ) const
|
||||||
{
|
{
|
||||||
return pvt->borderFirst( channel );
|
return pvt->borderFirst( channel );
|
||||||
}
|
}
|
||||||
|
|
||||||
const NL3D::CTileBorder& TileItemNode::border( TileModel::TTileChannel channel ) const
|
const NL3D::CTileBorder& TileItemNode::border( TileConstants::TTileChannel channel ) const
|
||||||
{
|
{
|
||||||
return pvt->border( channel );
|
return pvt->border( channel );
|
||||||
}
|
}
|
||||||
|
@ -659,3 +661,9 @@ int TileItemNode::columnCount() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant TileItemNode::pixmap( TileConstants::TTileChannel channel ) const
|
||||||
|
{
|
||||||
|
return pvt->pixMap( channel );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,18 +95,18 @@ class TileTypeNode : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TileTypeNode(TileModel::TNodeTileType type, Node *parent=0);
|
TileTypeNode(TileConstants::TNodeTileType type, Node *parent=0);
|
||||||
virtual ~TileTypeNode();
|
virtual ~TileTypeNode();
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
int columnCount() const;
|
int columnCount() const;
|
||||||
|
|
||||||
TileModel::TNodeTileType getTileType();
|
TileConstants::TNodeTileType getTileType();
|
||||||
|
|
||||||
bool removeChildren( int position, int count );
|
bool removeChildren( int position, int count );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reindex();
|
void reindex();
|
||||||
TileModel::TNodeTileType m_nodeTileType;
|
TileConstants::TNodeTileType m_nodeTileType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TileItemNodePvt;
|
class TileItemNodePvt;
|
||||||
|
@ -114,30 +114,32 @@ class TileItemNodePvt;
|
||||||
class TileItemNode : public Node
|
class TileItemNode : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TileItemNode( TileModel::TNodeTileType type, int tileId, TileModel::TTileChannel channel, QString filename, Node *parent=0);
|
TileItemNode( TileConstants::TNodeTileType type, int tileId, TileConstants::TTileChannel channel, QString filename, 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;
|
||||||
bool setTileFilename(TileModel::TTileChannel channel, QString filename);
|
bool setTileFilename(TileConstants::TTileChannel channel, QString filename);
|
||||||
QString getTileFilename(TileModel::TTileChannel channel);
|
QString getTileFilename(TileConstants::TTileChannel channel);
|
||||||
void setId( int id );
|
void setId( int id );
|
||||||
int id() const;
|
int id() const;
|
||||||
QString getLastError() const;
|
QString getLastError() const;
|
||||||
bool borderFirst( TileModel::TTileChannel channel ) const;
|
bool borderFirst( TileConstants::TTileChannel channel ) const;
|
||||||
const NL3D::CTileBorder& border( TileModel::TTileChannel channel ) const;
|
const NL3D::CTileBorder& border( TileConstants::TTileChannel channel ) const;
|
||||||
int alphaRot() const;
|
int alphaRot() const;
|
||||||
|
|
||||||
static void setDisplayChannel( TileModel::TTileChannel channel ){ s_displayChannel = channel; }
|
static void setDisplayChannel( TileConstants::TTileChannel channel ){ s_displayChannel = channel; }
|
||||||
static TileModel::TTileChannel displayChannel(){ return s_displayChannel; }
|
static TileConstants::TTileChannel displayChannel(){ return s_displayChannel; }
|
||||||
static void setAlphaRot( int rot ){ s_alphaRot = rot; }
|
static void setAlphaRot( int rot ){ s_alphaRot = rot; }
|
||||||
|
|
||||||
bool hasError() const{ return m_hasError; }
|
bool hasError() const{ return m_hasError; }
|
||||||
|
|
||||||
private:
|
QVariant pixmap( TileConstants::TTileChannel channel ) const;
|
||||||
QMap<TileModel::TTileChannel, QString> m_tileFilename;
|
|
||||||
QMap<TileModel::TTileChannel, TileWidget*> m_tileWidget;
|
|
||||||
|
|
||||||
static TileModel::TTileChannel s_displayChannel;
|
private:
|
||||||
|
QMap<TileConstants::TTileChannel, QString> m_tileFilename;
|
||||||
|
QMap<TileConstants::TTileChannel, TileWidget*> m_tileWidget;
|
||||||
|
|
||||||
|
static TileConstants::TTileChannel s_displayChannel;
|
||||||
static int s_alphaRot;
|
static int s_alphaRot;
|
||||||
|
|
||||||
TileItemNodePvt *pvt;
|
TileItemNodePvt *pvt;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "tile_model.h"
|
#include "tile_model.h"
|
||||||
#include "tile_item.h"
|
#include "tile_item.h"
|
||||||
|
#include "tile_bank.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
@ -35,6 +36,8 @@ TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractIte
|
||||||
TileModel::CurrentZoomFactor = TileModel::TileZoom100;
|
TileModel::CurrentZoomFactor = TileModel::TileZoom100;
|
||||||
m_indexDisplay = true;
|
m_indexDisplay = true;
|
||||||
m_fileDisplay = true;
|
m_fileDisplay = true;
|
||||||
|
|
||||||
|
m_tileBank = new TileBank();
|
||||||
}
|
}
|
||||||
|
|
||||||
TileModel::~TileModel()
|
TileModel::~TileModel()
|
||||||
|
@ -182,59 +185,74 @@ TileSetNode *TileModel::createTileSetNode(QString tileSetName)
|
||||||
TileSetNode *tileSet = new TileSetNode(tileSetName);
|
TileSetNode *tileSet = new TileSetNode(tileSetName);
|
||||||
|
|
||||||
// child for 128x128 tiles
|
// child for 128x128 tiles
|
||||||
TileTypeNode *tile128= new TileTypeNode(Tile128);
|
TileTypeNode *tile128= new TileTypeNode( TileConstants::Tile128);
|
||||||
tileSet->appendRow(tile128);
|
tileSet->appendRow(tile128);
|
||||||
|
|
||||||
// child for 256x256 tiles
|
// child for 256x256 tiles
|
||||||
TileTypeNode *tile256= new TileTypeNode(Tile256);
|
TileTypeNode *tile256= new TileTypeNode( TileConstants::Tile256);
|
||||||
tileSet->appendRow(tile256);
|
tileSet->appendRow(tile256);
|
||||||
|
|
||||||
// child for transition tiles.
|
// child for transition tiles.
|
||||||
TileTypeNode *tileTrans= new TileTypeNode(TileTransition);
|
TileTypeNode *tileTrans= new TileTypeNode( TileConstants::TileTransition);
|
||||||
tileSet->appendRow(tileTrans);
|
tileSet->appendRow(tileTrans);
|
||||||
|
|
||||||
// Add the default transition tiles.
|
// Add the default transition tiles.
|
||||||
// TODO tie this to CTileSet::count from NeL
|
// TODO tie this to CTileSet::count from NeL
|
||||||
for(int transPos=0; transPos<48; transPos++)
|
for(int transPos=0; transPos<48; transPos++)
|
||||||
{
|
{
|
||||||
TileItemNode *transTile= new TileItemNode( TileModel::TileTransition, transPos, TileDiffuse, QString("empty"));
|
TileItemNode *transTile= new TileItemNode( TileConstants::TileTransition, transPos, TileConstants::TileDiffuse, QString("empty"));
|
||||||
tileTrans->appendRow(transTile);
|
tileTrans->appendRow(transTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// child for displacement tiles
|
// child for displacement tiles
|
||||||
TileTypeNode *tileDisp= new TileTypeNode(TileDisplacement);
|
TileTypeNode *tileDisp= new TileTypeNode( TileConstants::TileDisplacement);
|
||||||
tileSet->appendRow(tileDisp);
|
tileSet->appendRow(tileDisp);
|
||||||
|
|
||||||
// Add the default displacement tiles.
|
// Add the default displacement tiles.
|
||||||
// TODO tie this to CTileSet::CountDisplace from NeL
|
// TODO tie this to CTileSet::CountDisplace from NeL
|
||||||
for(int dispPos=0; dispPos<16; dispPos++)
|
for(int dispPos=0; dispPos<16; dispPos++)
|
||||||
{
|
{
|
||||||
TileItemNode *dispTile= new TileItemNode( TileModel::TileDisplacement, dispPos, TileDiffuse, QString("empty"));
|
TileItemNode *dispTile= new TileItemNode( TileConstants::TileDisplacement, dispPos, TileConstants::TileDiffuse, QString("empty"));
|
||||||
tileDisp->appendRow(dispTile);
|
tileDisp->appendRow(dispTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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( TileModel::TNodeTileType type, int id, TTileChannel channel, const QString &fileName )
|
TileItemNode *TileModel::createItemNode( TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName )
|
||||||
{
|
{
|
||||||
return new TileItemNode( type, id, channel, fileName );
|
return new TileItemNode( type, id, channel, fileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *TileModel::getTileTypeName(TileModel::TNodeTileType type)
|
TileItemNode *TileModel::createItemNode( int idx, TileConstants::TNodeTileType type, int id, TileConstants::TTileChannel channel, const QString &fileName )
|
||||||
|
{
|
||||||
|
TileItemNode *n = new TileItemNode( type, id, channel, fileName );
|
||||||
|
|
||||||
|
bool b = m_tileBank->addTileToSet( idx, fileName, n->pixmap( channel ), channel, type );
|
||||||
|
if( !b )
|
||||||
|
{
|
||||||
|
delete n;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *TileModel::getTileTypeName(TileConstants::TNodeTileType type)
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Tile128:
|
case TileConstants::Tile128:
|
||||||
return "128";
|
return "128";
|
||||||
case Tile256:
|
case TileConstants::Tile256:
|
||||||
return "256";
|
return "256";
|
||||||
case TileTransition:
|
case TileConstants::TileTransition:
|
||||||
return "Transition";
|
return "Transition";
|
||||||
case TileDisplacement:
|
case TileConstants::TileDisplacement:
|
||||||
return "Displacement";
|
return "Displacement";
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -242,17 +260,17 @@ const char *TileModel::getTileTypeName(TileModel::TNodeTileType type)
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 TileModel::getTileTypeSize(TileModel::TNodeTileType type)
|
uint32 TileModel::getTileTypeSize(TileConstants::TNodeTileType type)
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Tile128:
|
case TileConstants::Tile128:
|
||||||
return 128;
|
return 128;
|
||||||
case Tile256:
|
case TileConstants::Tile256:
|
||||||
return 256;
|
return 256;
|
||||||
case TileTransition:
|
case TileConstants::TileTransition:
|
||||||
return 64;
|
return 64;
|
||||||
case TileDisplacement:
|
case TileConstants::TileDisplacement:
|
||||||
return 32;
|
return 32;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -287,6 +305,16 @@ void TileModel::clear()
|
||||||
removeRows( 0, c );
|
removeRows( 0, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileModel::addLand( const QString &name )
|
||||||
|
{
|
||||||
|
m_tileBank->addLand( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileModel::setLandSets( int idx, const QStringList &l )
|
||||||
|
{
|
||||||
|
m_tileBank->setLandSets( idx, l );
|
||||||
|
}
|
||||||
|
|
||||||
void TileModel::selectFilenameDisplay(bool selected)
|
void TileModel::selectFilenameDisplay(bool selected)
|
||||||
{
|
{
|
||||||
m_fileDisplay = selected;
|
m_fileDisplay = selected;
|
||||||
|
|
|
@ -21,32 +21,18 @@
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
#include "tile_constants.h"
|
||||||
|
|
||||||
class Node;
|
class Node;
|
||||||
class TileSetNode;
|
class TileSetNode;
|
||||||
class TileItemNode;
|
class TileItemNode;
|
||||||
|
class TileBank;
|
||||||
|
|
||||||
class TileModel : public QAbstractItemModel
|
class TileModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum TTileChannel
|
|
||||||
{
|
|
||||||
TileDiffuse = 0,
|
|
||||||
TileAdditive = 1,
|
|
||||||
TileAlpha = 2,
|
|
||||||
TileChannelCount = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
enum TNodeTileType
|
|
||||||
{
|
|
||||||
Tile128 = 0,
|
|
||||||
Tile256 = 1,
|
|
||||||
TileTransition = 2,
|
|
||||||
TileDisplacement = 3,
|
|
||||||
TileNodeTypeCount = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
enum TTileItemRole
|
enum TTileItemRole
|
||||||
{
|
{
|
||||||
TilePixmapRole = Qt::UserRole+1,
|
TilePixmapRole = Qt::UserRole+1,
|
||||||
|
@ -87,10 +73,11 @@ public:
|
||||||
void swapRows( int a, int b );
|
void swapRows( int a, int b );
|
||||||
|
|
||||||
TileSetNode *createTileSetNode(QString tileSetName);
|
TileSetNode *createTileSetNode(QString tileSetName);
|
||||||
static TileItemNode *createItemNode( TileModel::TNodeTileType type, int id, TTileChannel channel, const QString &fileName );
|
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 );
|
||||||
|
|
||||||
static const char *getTileTypeName(TNodeTileType type);
|
static const char *getTileTypeName(TileConstants::TNodeTileType type);
|
||||||
static uint32 getTileTypeSize(TileModel::TNodeTileType type);
|
static uint32 getTileTypeSize(TileConstants::TNodeTileType type);
|
||||||
|
|
||||||
static TTileZoomFactor CurrentZoomFactor;
|
static TTileZoomFactor CurrentZoomFactor;
|
||||||
|
|
||||||
|
@ -101,6 +88,9 @@ public:
|
||||||
void setTexturePath( const QString &path ){ m_texturePath = path; }
|
void setTexturePath( const QString &path ){ m_texturePath = path; }
|
||||||
QString texturePath() const{ return m_texturePath; }
|
QString texturePath() const{ return m_texturePath; }
|
||||||
|
|
||||||
|
void addLand( const QString &name );
|
||||||
|
void setLandSets( int idx, const QStringList &l );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void selectFilenameDisplay(bool selected);
|
void selectFilenameDisplay(bool selected);
|
||||||
void selectIndexDisplay(bool selected);
|
void selectIndexDisplay(bool selected);
|
||||||
|
@ -117,6 +107,8 @@ private:
|
||||||
Node *rootItem;
|
Node *rootItem;
|
||||||
|
|
||||||
QString m_texturePath;
|
QString m_texturePath;
|
||||||
|
|
||||||
|
TileBank *m_tileBank;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TILE_MODEL_H
|
#endif // TILE_MODEL_H
|
||||||
|
|
|
@ -28,15 +28,15 @@ class TileBankLoaderPvt
|
||||||
public:
|
public:
|
||||||
NL3D::CTileBank bank;
|
NL3D::CTileBank bank;
|
||||||
|
|
||||||
static NL3D::CTile::TBitmap channelToTBitmap( TileModel::TTileChannel channel )
|
static NL3D::CTile::TBitmap channelToTBitmap( TileConstants::TTileChannel channel )
|
||||||
{
|
{
|
||||||
NL3D::CTile::TBitmap b = NL3D::CTile::bitmapCount;
|
NL3D::CTile::TBitmap b = NL3D::CTile::bitmapCount;
|
||||||
|
|
||||||
switch( channel )
|
switch( channel )
|
||||||
{
|
{
|
||||||
case TileModel::TileDiffuse: b = NL3D::CTile::diffuse; break;
|
case TileConstants::TileDiffuse: b = NL3D::CTile::diffuse; break;
|
||||||
case TileModel::TileAdditive: b = NL3D::CTile::additive; break;
|
case TileConstants::TileAdditive: b = NL3D::CTile::additive; break;
|
||||||
case TileModel::TileAlpha: b = NL3D::CTile::alpha; break;
|
case TileConstants::TileAlpha: b = NL3D::CTile::alpha; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
|
@ -75,11 +75,11 @@ public:
|
||||||
int idx = set->getTile128( i );
|
int idx = set->getTile128( i );
|
||||||
NL3D::CTile *tile = bank.getTile( idx );
|
NL3D::CTile *tile = bank.getTile( idx );
|
||||||
|
|
||||||
TileItemNode *tin = new TileItemNode( TileModel::Tile128, i, TileModel::TileDiffuse, "" );
|
TileItemNode *tin = new TileItemNode( TileConstants::Tile128, i, TileConstants::TileDiffuse, "" );
|
||||||
|
|
||||||
for( int i = TileModel::TileDiffuse; i < TileModel::TileAlpha; i++ )
|
for( int i = TileConstants::TileDiffuse; i < TileConstants::TileAlpha; i++ )
|
||||||
{
|
{
|
||||||
tin->setTileFilename( TileModel::TTileChannel( i ), tile->getRelativeFileName( channelToTBitmap( TileModel::TTileChannel( i ) ) ).c_str() );
|
tin->setTileFilename( TileConstants::TTileChannel( i ), tile->getRelativeFileName( channelToTBitmap( TileConstants::TTileChannel( i ) ) ).c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
node->appendChild( tin );
|
node->appendChild( tin );
|
||||||
|
@ -94,11 +94,11 @@ public:
|
||||||
int idx = set->getTile256( i );
|
int idx = set->getTile256( i );
|
||||||
NL3D::CTile *tile = bank.getTile( idx );
|
NL3D::CTile *tile = bank.getTile( idx );
|
||||||
|
|
||||||
TileItemNode *tin = new TileItemNode( TileModel::Tile256, i, TileModel::TileDiffuse, "" );
|
TileItemNode *tin = new TileItemNode( TileConstants::Tile256, i, TileConstants::TileDiffuse, "" );
|
||||||
|
|
||||||
for( int i = TileModel::TileDiffuse; i < TileModel::TileAlpha; i++ )
|
for( int i = TileConstants::TileDiffuse; i < TileConstants::TileAlpha; i++ )
|
||||||
{
|
{
|
||||||
tin->setTileFilename( TileModel::TTileChannel( i ), tile->getRelativeFileName( channelToTBitmap( TileModel::TTileChannel( i ) ) ).c_str() );
|
tin->setTileFilename( TileConstants::TTileChannel( i ), tile->getRelativeFileName( channelToTBitmap( TileConstants::TTileChannel( i ) ) ).c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
node->appendChild( tin );
|
node->appendChild( tin );
|
||||||
|
@ -115,9 +115,9 @@ public:
|
||||||
|
|
||||||
TileItemNode *tin = static_cast< TileItemNode* >( node->child( i ) );
|
TileItemNode *tin = static_cast< TileItemNode* >( node->child( i ) );
|
||||||
|
|
||||||
for( int j = TileModel::TileDiffuse; j <= TileModel::TileAlpha; j++ )
|
for( int j = TileConstants::TileDiffuse; j <= TileConstants::TileAlpha; j++ )
|
||||||
{
|
{
|
||||||
tin->setTileFilename( TileModel::TTileChannel( i ), tile->getRelativeFileName( channelToTBitmap( TileModel::TTileChannel( i ) ) ).c_str() );
|
tin->setTileFilename( TileConstants::TTileChannel( i ), tile->getRelativeFileName( channelToTBitmap( TileConstants::TTileChannel( i ) ) ).c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public:
|
||||||
const char *fn = bank.getDisplacementMap( did );
|
const char *fn = bank.getDisplacementMap( did );
|
||||||
|
|
||||||
TileItemNode *tin = static_cast< TileItemNode* >( node->child( i ) );
|
TileItemNode *tin = static_cast< TileItemNode* >( node->child( i ) );
|
||||||
tin->setTileFilename( TileModel::TileDiffuse, fn );
|
tin->setTileFilename( TileConstants::TileDiffuse, fn );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,35 +27,35 @@ class TileBankSaverPvt
|
||||||
public:
|
public:
|
||||||
NL3D::CTileBank bank;
|
NL3D::CTileBank bank;
|
||||||
|
|
||||||
static NL3D::CTile::TBitmap channelToTBitmap( TileModel::TTileChannel channel )
|
static NL3D::CTile::TBitmap channelToTBitmap( TileConstants::TTileChannel channel )
|
||||||
{
|
{
|
||||||
NL3D::CTile::TBitmap b = NL3D::CTile::bitmapCount;
|
NL3D::CTile::TBitmap b = NL3D::CTile::bitmapCount;
|
||||||
|
|
||||||
switch( channel )
|
switch( channel )
|
||||||
{
|
{
|
||||||
case TileModel::TileDiffuse: b = NL3D::CTile::diffuse; break;
|
case TileConstants::TileDiffuse: b = NL3D::CTile::diffuse; break;
|
||||||
case TileModel::TileAdditive: b = NL3D::CTile::additive; break;
|
case TileConstants::TileAdditive: b = NL3D::CTile::additive; break;
|
||||||
case TileModel::TileAlpha: b = NL3D::CTile::alpha; break;
|
case TileConstants::TileAlpha: b = NL3D::CTile::alpha; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
NL3D::CTile* addTileToSet( NL3D::CTileSet *set, TileModel::TNodeTileType type )
|
NL3D::CTile* addTileToSet( NL3D::CTileSet *set, TileConstants::TNodeTileType type )
|
||||||
{
|
{
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
int bidx = -1;
|
int bidx = -1;
|
||||||
|
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case TileModel::Tile128:
|
case TileConstants::Tile128:
|
||||||
{
|
{
|
||||||
set->addTile128( idx, bank );
|
set->addTile128( idx, bank );
|
||||||
bidx = set->getTile128( idx );
|
bidx = set->getTile128( idx );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TileModel::Tile256:
|
case TileConstants::Tile256:
|
||||||
{
|
{
|
||||||
set->addTile256( idx, bank );
|
set->addTile256( idx, bank );
|
||||||
bidx = set->getTile256( idx );
|
bidx = set->getTile256( idx );
|
||||||
|
@ -71,24 +71,24 @@ public:
|
||||||
|
|
||||||
void addTilesToSet( NL3D::CTileSet *set, TileTypeNode *node )
|
void addTilesToSet( NL3D::CTileSet *set, TileTypeNode *node )
|
||||||
{
|
{
|
||||||
TileModel::TNodeTileType type = node->getTileType();
|
TileConstants::TNodeTileType type = node->getTileType();
|
||||||
|
|
||||||
for( int i = 0; i < node->childCount(); i++ )
|
for( int i = 0; i < node->childCount(); i++ )
|
||||||
{
|
{
|
||||||
TileItemNode *tin = static_cast< TileItemNode* >( node->child( i ) );
|
TileItemNode *tin = static_cast< TileItemNode* >( node->child( i ) );
|
||||||
NL3D::CTile *tile = addTileToSet( set, type );
|
NL3D::CTile *tile = addTileToSet( set, type );
|
||||||
|
|
||||||
for( int j = TileModel::TileDiffuse; j < TileModel::TileAlpha; j++ )
|
for( int j = TileConstants::TileDiffuse; j < TileConstants::TileAlpha; j++ )
|
||||||
{
|
{
|
||||||
QString fn = tin->getTileFilename( TileModel::TTileChannel( j ) );
|
QString fn = tin->getTileFilename( TileConstants::TTileChannel( j ) );
|
||||||
tile->setFileName( channelToTBitmap( TileModel::TTileChannel( j ) ) , fn.toUtf8().constData() );
|
tile->setFileName( channelToTBitmap( TileConstants::TTileChannel( j ) ) , fn.toUtf8().constData() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTilesToSet( NL3D::CTileSet *set, TileSetNode *node )
|
void addTilesToSet( NL3D::CTileSet *set, TileSetNode *node )
|
||||||
{
|
{
|
||||||
for( int i = TileModel::Tile128; i <= TileModel::Tile256; i++ )
|
for( int i = TileConstants::Tile128; i <= TileConstants::Tile256; i++ )
|
||||||
{
|
{
|
||||||
TileTypeNode *tn = static_cast< TileTypeNode* >( node->child( i ) );
|
TileTypeNode *tn = static_cast< TileTypeNode* >( node->child( i ) );
|
||||||
|
|
||||||
|
@ -103,9 +103,9 @@ public:
|
||||||
{
|
{
|
||||||
tileNode = static_cast< TileItemNode* >( node->child( i ) );
|
tileNode = static_cast< TileItemNode* >( node->child( i ) );
|
||||||
|
|
||||||
for( int j = TileModel::TileDiffuse; j < TileModel::TileAlpha; j++ )
|
for( int j = TileConstants::TileDiffuse; j < TileConstants::TileAlpha; j++ )
|
||||||
{
|
{
|
||||||
TileModel::TTileChannel channel = TileModel::TTileChannel( j );
|
TileConstants::TTileChannel channel = TileConstants::TTileChannel( j );
|
||||||
NL3D::CTile::TBitmap bm = channelToTBitmap( channel );
|
NL3D::CTile::TBitmap bm = channelToTBitmap( channel );
|
||||||
const NL3D::CTileBorder &border = tileNode->border( channel );
|
const NL3D::CTileBorder &border = tileNode->border( channel );
|
||||||
|
|
||||||
|
@ -124,9 +124,9 @@ public:
|
||||||
{
|
{
|
||||||
tileNode = static_cast< TileItemNode* >( node->child( i ) );
|
tileNode = static_cast< TileItemNode* >( node->child( i ) );
|
||||||
|
|
||||||
for( int j = TileModel::TileDiffuse; j < TileModel::TileAlpha; j++ )
|
for( int j = TileConstants::TileDiffuse; j < TileConstants::TileAlpha; j++ )
|
||||||
{
|
{
|
||||||
TileModel::TTileChannel channel = TileModel::TTileChannel( j );
|
TileConstants::TTileChannel channel = TileConstants::TTileChannel( j );
|
||||||
NL3D::CTile::TBitmap bm = channelToTBitmap( channel );
|
NL3D::CTile::TBitmap bm = channelToTBitmap( channel );
|
||||||
const NL3D::CTileBorder &border = tileNode->border( channel );
|
const NL3D::CTileBorder &border = tileNode->border( channel );
|
||||||
|
|
||||||
|
@ -140,14 +140,14 @@ public:
|
||||||
|
|
||||||
void setupTransitionTile( NL3D::CTileSet *set, TileItemNode *node, int idx )
|
void setupTransitionTile( NL3D::CTileSet *set, TileItemNode *node, int idx )
|
||||||
{
|
{
|
||||||
TileModel::TTileChannel channel;
|
TileConstants::TTileChannel channel;
|
||||||
NL3D::CTile::TBitmap bm;
|
NL3D::CTile::TBitmap bm;
|
||||||
NL3D::CTileSet::TTransition tr;
|
NL3D::CTileSet::TTransition tr;
|
||||||
|
|
||||||
// Diffuse, Additive
|
// Diffuse, Additive
|
||||||
for( int i = TileModel::TileDiffuse; i < TileModel::TileAlpha; i++ )
|
for( int i = TileConstants::TileDiffuse; i < TileConstants::TileAlpha; i++ )
|
||||||
{
|
{
|
||||||
channel =TileModel::TTileChannel( i );
|
channel =TileConstants::TTileChannel( i );
|
||||||
bm = channelToTBitmap( channel );
|
bm = channelToTBitmap( channel );
|
||||||
tr = NL3D::CTileSet::TTransition( idx );
|
tr = NL3D::CTileSet::TTransition( idx );
|
||||||
const NL3D::CTileBorder &border = node->border( channel );
|
const NL3D::CTileBorder &border = node->border( channel );
|
||||||
|
@ -159,7 +159,7 @@ public:
|
||||||
|
|
||||||
// Alpha
|
// Alpha
|
||||||
{
|
{
|
||||||
channel = TileModel::TileAlpha;
|
channel = TileConstants::TileAlpha;
|
||||||
bm = channelToTBitmap( channel );
|
bm = channelToTBitmap( channel );
|
||||||
tr = NL3D::CTileSet::TTransition( idx );
|
tr = NL3D::CTileSet::TTransition( idx );
|
||||||
const NL3D::CTileBorder &border = node->border( channel );
|
const NL3D::CTileBorder &border = node->border( channel );
|
||||||
|
@ -187,7 +187,7 @@ public:
|
||||||
void setupDisplacementTile( NL3D::CTileSet *set, TileItemNode *node, int idx )
|
void setupDisplacementTile( NL3D::CTileSet *set, TileItemNode *node, int idx )
|
||||||
{
|
{
|
||||||
set->setDisplacement( NL3D::CTileSet::TDisplacement( idx ),
|
set->setDisplacement( NL3D::CTileSet::TDisplacement( idx ),
|
||||||
node->getTileFilename( TileModel::TileDiffuse ).toUtf8().constData(),
|
node->getTileFilename( TileConstants::TileDiffuse ).toUtf8().constData(),
|
||||||
bank );
|
bank );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue