Save the tile border, etc data when saving.

This commit is contained in:
dfighter1985 2014-08-03 17:58:02 +02:00
parent 3823a9a01b
commit ca1f00e35a
3 changed files with 102 additions and 21 deletions

View file

@ -383,11 +383,6 @@ public:
if( error == NL3D::CTileSet::addFirstA128128 ) if( error == NL3D::CTileSet::addFirstA128128 )
return NL3D::CTileSet::addFirstA128128; return NL3D::CTileSet::addFirstA128128;
/*
enum TError { ok=0, topInterfaceProblem, bottomInterfaceProblem, leftInterfaceProblem,
rightInterfaceProblem, addFirstA128128, topBottomNotTheSame, rightLeftNotTheSame,
sizeInvalide, errorCount };
*/
static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""};
if( error != NL3D::CTileSet::ok ) if( error != NL3D::CTileSet::ok )
@ -485,6 +480,8 @@ public:
return false; return false;
} }
m_borderFirst[ channel ] = false;
if( !empty ) if( !empty )
{ {
if( !checkPixmap( channel, temp ) ) if( !checkPixmap( channel, temp ) )
@ -512,6 +509,8 @@ public:
QString getLastError() const{ return m_lastError; } QString getLastError() const{ return m_lastError; }
bool borderFirst( TileModel::TTileChannel channel ) const{ return m_borderFirst[ channel ]; } bool borderFirst( TileModel::TTileChannel channel ) const{ return m_borderFirst[ channel ]; }
const NL3D::CTileBorder &border( TileModel::TTileChannel channel ){ return m_border[ channel ]; }
private: private:
QPixmap pixmaps[ TileModel::TileChannelCount ]; QPixmap pixmaps[ TileModel::TileChannelCount ];
TileModel::TNodeTileType m_type; TileModel::TNodeTileType m_type;
@ -590,9 +589,19 @@ QString TileItemNode::getLastError() const
return pvt->getLastError(); return pvt->getLastError();
} }
bool TileItemNode::borderFirst() const bool TileItemNode::borderFirst( TileModel::TTileChannel channel ) const
{ {
return false; return pvt->borderFirst( channel );
}
const NL3D::CTileBorder& TileItemNode::border( TileModel::TTileChannel channel ) const
{
return pvt->border( channel );
}
int TileItemNode::alphaRot() const
{
return 0;
} }
QVariant TileItemNode::data(int column, int role) const QVariant TileItemNode::data(int column, int role) const

View file

@ -24,6 +24,11 @@
#include "tile_model.h" #include "tile_model.h"
namespace NL3D
{
class CTileBorder;
}
class TileWidget; class TileWidget;
class Node class Node
@ -118,7 +123,9 @@ public:
void setId( int id ); void setId( int id );
int id() const; int id() const;
QString getLastError() const; QString getLastError() const;
bool borderFirst() const; bool borderFirst( TileModel::TTileChannel channel ) const;
const NL3D::CTileBorder& border( TileModel::TTileChannel channel ) const;
int alphaRot() const;
static void setDisplayChannel( TileModel::TTileChannel channel ){ s_displayChannel = channel; } static void setDisplayChannel( TileModel::TTileChannel channel ){ s_displayChannel = channel; }
static TileModel::TTileChannel displayChannel(){ return s_displayChannel; } static TileModel::TTileChannel displayChannel(){ return s_displayChannel; }

View file

@ -96,19 +96,76 @@ public:
} }
} }
void setupTiles128( NL3D::CTileSet *set, TileTypeNode *node )
{
TileItemNode *tileNode = NULL;
for( int i = 0; i < node->childCount(); i++ )
{
tileNode = static_cast< TileItemNode* >( node->child( i ) );
for( int j = TileModel::TileDiffuse; j < TileModel::TileAlpha; j++ )
{
TileModel::TTileChannel channel = TileModel::TTileChannel( j );
NL3D::CTile::TBitmap bm = channelToTBitmap( channel );
const NL3D::CTileBorder &border = tileNode->border( channel );
if( tileNode->borderFirst( channel ) )
set->setBorder( bm, border );
set->setTile128( i, tileNode->getTileFilename( channel ).toUtf8().constData(), bm, bank );
}
}
}
void setupTiles256( NL3D::CTileSet *set, TileTypeNode *node )
{
TileItemNode *tileNode = NULL;
for( int i = 0; i < node->childCount(); i++ )
{
tileNode = static_cast< TileItemNode* >( node->child( i ) );
for( int j = TileModel::TileDiffuse; j < TileModel::TileAlpha; j++ )
{
TileModel::TTileChannel channel = TileModel::TTileChannel( j );
NL3D::CTile::TBitmap bm = channelToTBitmap( channel );
const NL3D::CTileBorder &border = tileNode->border( channel );
if( tileNode->borderFirst( channel ) )
set->setBorder( bm, border );
set->setTile256( i, tileNode->getTileFilename( channel ).toUtf8().constData(), bm, bank );
}
}
}
void setupTransitionTile( NL3D::CTileSet *set, TileItemNode *node, int idx ) void setupTransitionTile( NL3D::CTileSet *set, TileItemNode *node, int idx )
{ {
NL3D::CTileSetTransition *tr = set->getTransition( idx ); TileModel::TTileChannel channel;
int tid = tr->getTile(); NL3D::CTile::TBitmap bm;
NL3D::CTile *tile = bank.getTile( tid ); NL3D::CTileSet::TTransition tr;
if( tile == NULL ) // Diffuse, Additive
return; for( int i = TileModel::TileDiffuse; i < TileModel::TileAlpha; i++ )
for( int i = TileModel::TileDiffuse; i <= TileModel::TileAlpha; i++ )
{ {
QString fn = node->getTileFilename( TileModel::TTileChannel( i ) ); channel =TileModel::TTileChannel( i );
tile->setFileName( channelToTBitmap( TileModel::TTileChannel( i ) ), fn.toUtf8().constData() ); bm = channelToTBitmap( channel );
tr = NL3D::CTileSet::TTransition( idx );
const NL3D::CTileBorder &border = node->border( channel );
if( node->borderFirst( channel ) )
set->setBorder( bm, border );
set->setTileTransition( tr, node->getTileFilename( channel ).toUtf8().constData(), bm, bank, border );
}
// Alpha
{
channel = TileModel::TileAlpha;
bm = channelToTBitmap( channel );
tr = NL3D::CTileSet::TTransition( idx );
const NL3D::CTileBorder &border = node->border( channel );
int rot = node->alphaRot();
set->setTileTransitionAlpha( tr, node->getTileFilename( channel ).toUtf8().constData(), bank, border, rot );
} }
} }
@ -149,6 +206,17 @@ public:
setupDisplacementTiles( set, tn ); setupDisplacementTiles( set, tn );
} }
void setupTiles( NL3D::CTileSet *set, TileSetNode *node )
{
TileTypeNode *tn128 = static_cast< TileTypeNode* >( node->child( 0 ) );
TileTypeNode *tn256 = static_cast< TileTypeNode* >( node->child( 1 ) );
setupTiles128( set, tn128 );
setupTiles256( set, tn256 );
setupTransitionTiles( set, node );
setupDisplacementTiles( set, node );
}
void addLands( const QList< Land > &lands ) void addLands( const QList< Land > &lands )
{ {
QListIterator< Land > itr( lands ); QListIterator< Land > itr( lands );
@ -185,11 +253,8 @@ public:
TileSetNode *n = reinterpret_cast< TileSetNode* >( idx.internalPointer() ); TileSetNode *n = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
addTilesToSet( set, n ); addTilesToSet( set, n );
setupTransitionTiles( set, n ); setupTiles( set, n );
setupDisplacementTiles( set, n );
set->setOriented( n->isOriented() ); set->setOriented( n->isOriented() );
set->setTileVegetableDescFileName( n->vegetSet().toUtf8().constData() ); set->setTileVegetableDescFileName( n->vegetSet().toUtf8().constData() );
} }