本文整理汇总了C++中CTileBank::getAbsPath方法的典型用法代码示例。如果您正苦于以下问题:C++ CTileBank::getAbsPath方法的具体用法?C++ CTileBank::getAbsPath怎么用?C++ CTileBank::getAbsPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTileBank
的用法示例。
在下文中一共展示了CTileBank::getAbsPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_loadPushButton_clicked
void CTile_edit_dlg::on_loadPushButton_clicked()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Bank"), ui.absolutePathPushButton->text() , tr("NeL tile bank files (*.bank);;All Files (*.*);;"), &selectedFilter, options);
if (!fileName.isEmpty())
{
CIFile stream;
if ( stream.open( fileName.toUtf8().constData() ) )
{
ui.landListWidget->clear();
ui.tileSetListWidget->clear();
tileBank.clear();
tileBank.serial (stream);
}
int i;
QStringList lands;
for (i=0; i<tileBank.getLandCount(); i++)
{
// Add to the list
lands.append( QString(tileBank.getLand(i)->getName().c_str()) );
}
ui.landListWidget->addItems(lands);
QStringList tileSets;
for (i=0; i<tileBank.getTileSetCount(); i++)
{
// Add to the list
tileSets.append( QString( tileBank.getTileSet(i)->getName().c_str() ) );
}
ui.tileSetListWidget->addItems(tileSets);
// Set MainFile
mainFile = QFileInfo(fileName);
ui.savePushButton->setEnabled(true);
ui.absolutePathPushButton->setText( QString( tileBank.getAbsPath().c_str() ) );
}
}
示例2: build
void CTileSetCont::build (CTileBank& bank, uint tileSet)
{
// TileSet ref
CTileSet* set=bank.getTileSet (tileSet);
// Find a main bitmap with a valid name
if (set->getNumTile128())
{
// Get the name
std::string fileName=bank.getAbsPath()+bank.getTile (set->getTile128(0))->getRelativeFileName (CTile::diffuse);
// Valid name?
if (fileName!="")
{
// Create it
MainBitmap=new CTextureFile (fileName);
}
}
// Build group bitmaps
for (int group=0; group<NL3D_CTILE_NUM_GROUP; group++)
{
int tile;
// Look for a 128 tile in this group
for (tile=0; tile<set->getNumTile128(); tile++)
{
// Tile pointer
CTile* pTile=bank.getTile (set->getTile128 (tile));
// Look for a tile of the group
if (pTile->getGroupFlags ()&(1<<group))
{
// Get the name
std::string fileName=bank.getAbsPath()+pTile->getRelativeFileName (CTile::diffuse);
// Valid name?
if (fileName!="")
{
// Create it
if (GroupBitmap[group]==NULL)
GroupBitmap[group]=new CTextureFile (fileName);
// Add to the group list
GroupTile128[group].push_back (tile);
}
}
}
// Look for a 256 tile in this group
for (tile=0; tile<set->getNumTile256(); tile++)
{
// Tile pointer
CTile* pTile=bank.getTile (set->getTile256 (tile));
// Look for a tile of the group
if (pTile->getGroupFlags ()&(1<<group))
{
// Get the name
std::string fileName=bank.getAbsPath()+pTile->getRelativeFileName (CTile::diffuse);
// Valid name?
if (fileName!="")
{
// Create it
if (GroupBitmap[group]==NULL)
GroupBitmap[group]=new CTextureFile (fileName);
// Add to the group list
GroupTile256[group].push_back (tile);
}
}
}
}
// Current index
bool dmwarn = false;
for (uint displace=0; displace<CTileSet::CountDisplace; displace++)
{
uint dispTile = set->getDisplacementTile((CTileSet::TDisplacement)displace);
if (bank.getDisplacementMapCount() <= dispTile)
{
if (!dmwarn)
{
dmwarn = true;
MessageBox(NULL, "Tile bank not loaded, or bad tile bank. Missing a displacement tile. Use the tile bank utility to load the correct tilebank.", "NeL Patch Paint", MB_OK | MB_ICONWARNING);
}
continue; // with next displace
}
// Get the name
std::string fileName = bank.getDisplacementMap(dispTile);
if (fileName=="EmptyDisplacementMap")
fileName="";
// Valid name?
if (fileName!="")
{
// Create it
//.........这里部分代码省略.........
示例3: MyControllingFunction
unsigned long Browse::MyControllingFunction( void* pParam )
{
thread_actif = 1;
Browse *br = (Browse*)pParam;
br->m_ctrl.lockInsertion = 1;
int iFV,iLV;
br->m_ctrl.GetVisibility(iFV, iLV, br->m_128x128);
br->m_ctrl.UpdateBar(iFV, iLV, br->m_128x128);
tilelist::iterator p = br->m_ctrl.InfoList.GetFirst(br->m_128x128);
tilelist::iterator plast = p;
for (int i=0;i<br->m_ctrl.InfoList.GetSize(br->m_128x128);i++)
{
int *ld;
int rot=0;
std::string path;
LPBITMAPINFO pBmp;
std::vector<NLMISC::CBGRA>* bits;
switch (br->m_128x128)
{
case 0:
path = tileBank2.getTile (tileBank2.getTileSet (br->m_ctrl.InfoList._tileSet)->getTile128 (i))->
getRelativeFileName ((CTile::TBitmap)(br->m_ctrl.Texture-1));
break;
case 1:
path = tileBank2.getTile (tileBank2.getTileSet (br->m_ctrl.InfoList._tileSet)->getTile256 (i))->
getRelativeFileName ((CTile::TBitmap)(br->m_ctrl.Texture-1));
break;
case 2:
{
int index=tileBank2.getTileSet (br->m_ctrl.InfoList._tileSet)->getTransition (i)->getTile();
if (index!=-1)
{
path = tileBank2.getTile (index)->getRelativeFileName ((CTile::TBitmap)(br->m_ctrl.Texture-1));
if (br->m_ctrl.Texture==3)
rot = tileBank2.getTile (index)->getRotAlpha ();
}
else
path = "";
}
break;
case 3:
// Get diplacement filename
path = tileBank2.getDisplacementMap (tileBank2.getTileSet (br->m_ctrl.InfoList._tileSet)->getDisplacementTile ((CTileSet::TDisplacement)i));
break;
}
std::vector<NLMISC::CBGRA>* pAlpha=NULL;
switch (br->m_ctrl.Texture)
{
case 1:
ld = &p->loaded;
pBmp = &p->BmpInfo;
bits = &p->Bits;
pAlpha = &p->alphaBits;
break;
case 2:
ld = &p->nightLoaded;
pBmp = &p->nightBmpInfo;
bits = &p->nightBits;
pAlpha = &p->alphaBits;
break;
case 3:
ld = &p->alphaLoaded;
pBmp = &p->alphaBmpInfo;
bits = &p->alphaBits;
break;
}
if ((path!="") && _LoadBitmap(tileBank2.getAbsPath() + path, pBmp, *bits, pAlpha, rot))
{
*ld=1;
int iFV,iLV; br->m_ctrl.GetVisibility(iFV, iLV, br->m_128x128);
if (i<=iLV && i>=iFV)
{
CDC *pDC = br->m_ctrl.GetDC();
br->m_ctrl.DrawTile(p,pDC,1,br->m_128x128);
::ReleaseDC(*br,*pDC);
}
}
p++;
}
br->m_ctrl.lockInsertion = 0;
thread_actif = 0;
return 1;
}
示例4: on_absolutePathPushButton_clicked
void CTile_edit_dlg::on_absolutePathPushButton_clicked()
{
// Build the struct
QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly;
QString directory = QFileDialog::getExistingDirectory(this, tr("Select the absolute base path of the bank"), ui.absolutePathPushButton->text(), options);
// Select the path
if (!directory.isEmpty())
{
// Convert item into path string
QString path = QDir::toNativeSeparators(directory);
// Add a final back slash
if (!path.endsWith(QDir::separator()))
{
// Add a '\' at the end
path.append(QDir::separator());
}
//// Last check
QMessageBox::StandardButton reply;
QString confirmMessage = tr("Do you really want to set %1 as base path of the bank?").arg(path);
reply = QMessageBox::question(this, tr("Confirm Path"), confirmMessage, QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes)
{
// Set as default path..
// Old path
const char* oldPath=tileBank.getAbsPath ().c_str();
// Path are good
bool goodPath=true;
// If no absolute path, must check before use it
if ((*oldPath)==0)
{
// Compute xref
tileBank.computeXRef();
// For all tiles, check we can change the path
for (int tiles=0; tiles<tileBank.getTileCount(); tiles++)
{
// Get tile xref
int tileSet;
int number;
CTileBank::TTileType type;
tileBank.getTileXRef (tiles, tileSet, number, type);
// Is tile used ?
if (tileSet!=-1)
{
// 3 types of bitmaps
int type;
for (type=CTile::diffuse; type<CTile::bitmapCount; type++)
{
// Bitmap string
const std::string& bitmapPath=tileBank.getTile(tiles)->getRelativeFileName ((CTile::TBitmap)type);
// not empty ?
if (bitmapPath!="")
{
// Check the path
if ( CheckPath( bitmapPath, path.toUtf8() ) == false )
{
// Bad path
goodPath=false;
// Message
QString continueMessage = tr("Path '%1' can't be found in bitmap '%2'. Continue ?").arg(path).arg(QString(bitmapPath.c_str()));
reply = QMessageBox::question(this, tr("Continue"), continueMessage, QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::No)
break;
}
}
}
if (type!=CTile::bitmapCount)
break;
}
}
// For all tiles, check we can change the path
for (uint noise=1; noise<tileBank.getDisplacementMapCount (); noise++)
{
// Bitmap string
const char *bitmapPath=tileBank.getDisplacementMap (noise);
// not empty ?
if (strcmp (bitmapPath, "")!=0)
{
// Check the path
if (CheckPath( bitmapPath, path.toUtf8() )==false)
{
// Bad path
goodPath=false;
// Message
QString continueMessage = tr("Path '%1' can't be found in bitmap '%2'. Continue ?").arg(path).arg(QString(bitmapPath));
reply = QMessageBox::question(this, tr("Continue"), continueMessage, QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::No)
break;
//.........这里部分代码省略.........
示例5: on_importBorderPushButton_clicked
//TODO titegus: What's the point in Importing a new border if there is no Pixel Compatibility check ?
void CTile_browser_dlg::on_importBorderPushButton_clicked()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options);
if (!fileName.isEmpty())
{
fileName = QDir::toNativeSeparators(fileName);
// Get the border of the bank
std::vector<NLMISC::CBGRA> array(128*128);
// The bitmap
NLMISC::CBitmap bitmap;
// Read the bitmap
bool error=false;
try
{
CIFile file;
if (file.open (fileName.toStdString().c_str()))
{
// Export
bitmap.load (file);
}
else
error=true;
}
catch (Exception& e)
{
const char *toto=e.what ();
error=true;
}
// Error during import ?
if (error)
{
// Error message
QString s = tr("Can't read bitmap %1").arg(fileName);
QMessageBox::information (this, tr("Import border"), s);
}
// Get pixel
CRGBA *pPixel=(CRGBA*)&bitmap.getPixels()[0];
// Good size
if ((bitmap.getWidth()==128)&&(bitmap.getHeight()==128))
{
// Make a copy
for (int i=0; i<128*128; i++)
{
// Copy the pixel
array[i].R=pPixel->R;
array[i].G=pPixel->G;
array[i].B=pPixel->B;
array[i].A=pPixel->A;
pPixel++;
}
}
else
{
// Error message
QString s = tr("The bitmap must have a size of 128x128 (%1)").arg(fileName);
QMessageBox::information (this, tr("Import border"), s);
}
// 256 or 128 ?
CTileBorder border;
border.set (128, 128, array);
tileBankBrowser.getTileSet (tileSetIndex)->setBorder ((CTile::TBitmap) tileTextureButtonGroup->checkedId(), border);
// Message
QMessageBox::information (this, tr("Import border"), tr("The border has been changed."));
}
}
示例6: on_exportBorderPushButton_clicked
//TODO titegus: replace that by 4 buttons Export128Diffuse, Export128Additive, Export256Diffuse, Export256Diffuse ?
void CTile_browser_dlg::on_exportBorderPushButton_clicked()
{
// Select a file
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getSaveFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options);
if (!fileName.isEmpty())
{
fileName = QDir::toNativeSeparators(fileName);
// Get the border of the bank
std::vector<NLMISC::CBGRA> array;
// 256 or 128 ?
int width, height;
//TODO titegus: And So what if Alpha ??? and what about border256 ???
tileBankBrowser.getTileSet (tileSetIndex)->getBorder128 ((CTile::TBitmap)tileTextureButtonGroup->checkedId())->get (width, height, array);
// Make a bitmap
if (width&&height)
{
NLMISC::CBitmap bitmap;
bitmap.resize (width, height, NLMISC::CBitmap::RGBA);
// Get pixel
CRGBA *pPixel=(CRGBA*)&bitmap.getPixels()[0];
// Make a copy
for (int i=0; i<width*height; i++)
{
// Copy the pixel
pPixel->R=array[i].R;
pPixel->G=array[i].G;
pPixel->B=array[i].B;
pPixel->A=array[i].A;
pPixel++;
}
// Write the bitmap
bool error=false;
try
{
COFile file;
if (file.open (fileName.toStdString().c_str()))
{
// Export
bitmap.writeTGA (file, 32);
}
else
error=true;
}
catch (Exception& e)
{
const char *toto=e.what ();
error=true;
}
// Error during export ?
if (error)
{
// Error message
QString s = tr("Can't write bitmap %1").arg(fileName);
QMessageBox::information (this, tr("Export border"), s);
}
}
}
}
示例7: on_batchLoadPushButton_clicked
void CTile_browser_dlg::on_batchLoadPushButton_clicked()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , tr("Targa Bitmap (*.tga);;PNG Image (*.png);;All Files (*.*);;"), &selectedFilter, options);
QFileInfo fi(fileName);
QString baseName = fi.baseName() ;
if (!fileName.isEmpty())
{
QRegExp rx("\\d{2}$");
baseName = baseName.remove(rx);
//TODO titegus: What's the point in asking for rotation if Texture != Alpha ???
bool rotate = (QMessageBox::Yes == QMessageBox::question(this, tr("Import rotated tiles"), tr("Do you want to use rotation to reuse alpha tiles?"), QMessageBox::Yes | QMessageBox::No ));
for (int i=0; i<CTileSet::count; i++)
{
if (tileTextureButtonGroup->checkedId() == Alpha)
{
// Current transition
CTileSet::TTransition transition=(CTileSet::TTransition)i;
// Transition to patch
CTileSetTransition* trans=tileBankBrowser.getTileSet (tileSetIndex)->getTransition (transition);
if (tileBankBrowser.getTile (trans->getTile())->getRelativeFileName (CTile::alpha)=="")
{
// Continue ?
int ok;
// Try to load transition with rotation
for (int rot=0; rot<4; rot++)
{
// Try to load a tile with a file name like /tiletransition0.tga
QString transitionNumber = QString::number(transition);
QString batchNumber = transitionNumber.rightJustified(2, '0');
QString nextBaseName = baseName + batchNumber;
QString nextFileName = QDir::toNativeSeparators(fi.absolutePath()) + QDir::separator() + nextBaseName + QString(".") + fi.suffix();
FILE *pFile=fopen (nextFileName.toStdString().c_str(), "rb");
// Close the file and add the tile if opened
if (pFile)
{
fclose (pFile);
ok=browserModel.setTileTransitionAlpha (i, nextFileName.toStdString().c_str(), (4-rot)%4);
// End
break;
}
// Rotate the transition
transition=CTileSet::rotateTransition (transition);
if (!rotate)
break;
}
if (!ok)
break;
}
}
else
{
//TODO titegus: Check that, Batch Load seems useless
// Current transition
CTileSet::TTransition transition=(CTileSet::TTransition)i;
// Transition to patch
//CTileSetTransition* trans=tileBankBrowser.getTileSet (tileSetIndex)->getTransition (transition);
//if (tileBankBrowser.getTile (trans->getTile())->getRelativeFileName ((CTile::TBitmap)tileTextureButtonGroup->checkedId())=="")
//{
// // Try to load a tile with a file name like /tiletransition0.tga
// char sName2[256];
// char sFinal[256];
// sprintf (sName2, "%s%02d", sName, (int)transition);
// _makepath (sFinal, sDrive, sPath, sName2, sExt);
// FILE *pFile=fopen (sFinal, "rb");
// // Close the file and add the tile if opened
// if (pFile)
// {
// fclose (pFile);
// if (!infoList.setTileTransition (i, sFinal, (CTile::TBitmap) tileTextureButtonGroup->checkedId()))
// break;
// }
//}
}
}
LoadInThread();
}
}
示例8: on_actionReplaceImage_triggered
void CTile_browser_dlg::on_actionReplaceImage_triggered(bool checked)
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(this, "Choose Bitmap", QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options);
if (!fileName.isEmpty())
{
bool ok = false;
fileName = QDir::toNativeSeparators(fileName);
switch (tileTypeButtonGroup->checkedId())
{
case _128x128:
for (int i=0; i<ui.tileBrowserListView->selectionModel()->selectedRows().count(); i++)
{
int tileId = (ui.tileBrowserListView->selectionModel()->selectedRows().at(i).data(Qt::UserRole + 1)).toInt();
if ( ! browserModel.setTile128 ( tileId, fileName.toStdString(), (CTile::TBitmap) tileTextureButtonGroup->checkedId()) )
break;
}
break;
case _256x256:
for (int i=0; i<ui.tileBrowserListView->selectionModel()->selectedRows().count(); i++)
{
int tileId = (ui.tileBrowserListView->selectionModel()->selectedRows().at(i).data(Qt::UserRole + 1)).toInt();
if ( ! browserModel.setTile256 (tileId, fileName.toStdString(), (CTile::TBitmap) tileTextureButtonGroup->checkedId()) )
break;
}
break;
case Transition:
for (int i=0; i<ui.tileBrowserListView->selectionModel()->selectedRows().count(); i++)
{
int tileId = (ui.tileBrowserListView->selectionModel()->selectedRows().at(i).data(Qt::UserRole + 1)).toInt();
if ( tileTextureButtonGroup->checkedId() != Alpha )
{
if ( ! browserModel.setTileTransition (tileId, fileName.toStdString(), (CTile::TBitmap) tileTextureButtonGroup->checkedId()) )
break;
}
else
{
bool rotationOk = false;
int rot = CTile_rotation_dlg::getRotation(this, &rotationOk);
if (rotationOk)
{
if ( ! browserModel.setTileTransitionAlpha (tileId, fileName.toStdString(), rot) )
break;
}
}
}
break;
case Displace:
for (int i=0; i<ui.tileBrowserListView->selectionModel()->selectedRows().count(); i++)
{
int tileId = (ui.tileBrowserListView->selectionModel()->selectedRows().at(i).data(Qt::UserRole + 1)).toInt();
if ( ! browserModel.setDisplacement (tileId, fileName.toStdString(), (CTile::TBitmap) tileTextureButtonGroup->checkedId()) )
break;
}
break;
default:
nlassert (0); // no!
}
LoadInThread();
}
}
示例9: on_actionAddTile_triggered
void CTile_browser_dlg::on_actionAddTile_triggered(bool checked)
{
QFileDialog::Options options;
QString selectedFilter;
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Choose Bitmap", QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options);
qSort(fileNames.begin(), fileNames.end());
if (!fileNames.isEmpty())
{
int tileId;
QString fileName;
switch (tileTypeButtonGroup->checkedId())
{
case _128x128:
for (int i = 0; i < fileNames.size(); i++)
{
tileId = browserModel.addTile128 ();
fileName = QDir::toNativeSeparators(fileNames.at(i));
if ( ! browserModel.setTile128 ( tileId, fileName.toStdString(), (CTile::TBitmap) tileTextureButtonGroup->checkedId()) )
{
browserModel.removeTile128 (tileId);
break;
}
}
break;
case _256x256:
for (int i = 0; i < fileNames.size(); i++)
{
tileId = browserModel.addTile256 ();
fileName = QDir::toNativeSeparators(fileNames.at(i));
if ( ! browserModel.setTile256 ( tileId, fileName.toStdString(), (CTile::TBitmap) tileTextureButtonGroup->checkedId()) )
{
browserModel.removeTile256 (tileId);
break;
}
}
break;
default:
nlassert(0);
break;
}
LoadInThread();
}
}