mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-22 23:26:15 +00:00
Save the tile border, etc data when saving.
--HG-- branch : gsoc2014-dfighter
This commit is contained in:
parent
175af2fa74
commit
49deedad7d
3 changed files with 102 additions and 21 deletions
|
@ -383,11 +383,6 @@ public:
|
|||
if( error == 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", ""};
|
||||
|
||||
if( error != NL3D::CTileSet::ok )
|
||||
|
@ -484,6 +479,8 @@ public:
|
|||
m_lastError = QObject::tr( "Cannot open file %1" ).arg( fn );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_borderFirst[ channel ] = false;
|
||||
|
||||
if( !empty )
|
||||
{
|
||||
|
@ -512,6 +509,8 @@ public:
|
|||
QString getLastError() const{ return m_lastError; }
|
||||
bool borderFirst( TileModel::TTileChannel channel ) const{ return m_borderFirst[ channel ]; }
|
||||
|
||||
const NL3D::CTileBorder &border( TileModel::TTileChannel channel ){ return m_border[ channel ]; }
|
||||
|
||||
private:
|
||||
QPixmap pixmaps[ TileModel::TileChannelCount ];
|
||||
TileModel::TNodeTileType m_type;
|
||||
|
@ -590,9 +589,19 @@ QString TileItemNode::getLastError() const
|
|||
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
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
|
||||
#include "tile_model.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CTileBorder;
|
||||
}
|
||||
|
||||
class TileWidget;
|
||||
|
||||
class Node
|
||||
|
@ -118,7 +123,9 @@ public:
|
|||
void setId( int id );
|
||||
int id() 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 TileModel::TTileChannel displayChannel(){ return s_displayChannel; }
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
NL3D::CTileSetTransition *tr = set->getTransition( idx );
|
||||
int tid = tr->getTile();
|
||||
NL3D::CTile *tile = bank.getTile( tid );
|
||||
TileModel::TTileChannel channel;
|
||||
NL3D::CTile::TBitmap bm;
|
||||
NL3D::CTileSet::TTransition tr;
|
||||
|
||||
if( tile == NULL )
|
||||
return;
|
||||
|
||||
for( int i = TileModel::TileDiffuse; i <= TileModel::TileAlpha; i++ )
|
||||
// Diffuse, Additive
|
||||
for( int i = TileModel::TileDiffuse; i < TileModel::TileAlpha; i++ )
|
||||
{
|
||||
QString fn = node->getTileFilename( TileModel::TTileChannel( i ) );
|
||||
tile->setFileName( channelToTBitmap( TileModel::TTileChannel( i ) ), fn.toUtf8().constData() );
|
||||
channel =TileModel::TTileChannel( i );
|
||||
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 );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
QListIterator< Land > itr( lands );
|
||||
|
@ -185,11 +253,8 @@ public:
|
|||
TileSetNode *n = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
|
||||
|
||||
addTilesToSet( set, n );
|
||||
setupTransitionTiles( set, n );
|
||||
setupDisplacementTiles( set, n );
|
||||
|
||||
setupTiles( set, n );
|
||||
set->setOriented( n->isOriented() );
|
||||
|
||||
set->setTileVegetableDescFileName( n->vegetSet().toUtf8().constData() );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue