当前位置: 首页>>代码示例>>C++>>正文


C++ CTileBank::getTileSet方法代码示例

本文整理汇总了C++中CTileBank::getTileSet方法的典型用法代码示例。如果您正苦于以下问题:C++ CTileBank::getTileSet方法的具体用法?C++ CTileBank::getTileSet怎么用?C++ CTileBank::getTileSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTileBank的用法示例。


在下文中一共展示了CTileBank::getTileSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_tileSetListWidget_itemSelectionChanged

void CTile_edit_dlg::on_tileSetListWidget_itemSelectionChanged()
{
	tileSetSelectionChanging = true;

	int nindex = ui.tileSetListWidget->currentRow();
	if (nindex != -1) 
	{
		if ( !tileBank.getTileSet(nindex)->getTileVegetableDescFileName().empty() )
			ui.chooseVegetPushButton->setText( QString( tileBank.getTileSet(nindex)->getTileVegetableDescFileName().c_str() ) );
		else
			ui.chooseVegetPushButton->setText("...");

		ui.surfaceDataLineEdit->setText( QString::number( tileBank.getTileSet(nindex)->SurfaceData) );
		ui.orientedCheckBox->setChecked( tileBank.getTileSet(nindex)->getOriented() );
		
		ui.selectedTileSetGroupBox->setEnabled(true);
		ui.editTileSetPushButton->setEnabled(true);
		ui.deleteTileSetPushButton->setEnabled(true);
	}
	else
	{
		//TODO titegus: Init DetailFrame Method
		ui.chooseVegetPushButton->setText("...");
		ui.surfaceDataLineEdit->clear();
		ui.orientedCheckBox->setChecked(false);

		ui.selectedTileSetGroupBox->setEnabled(false);
		ui.editTileSetPushButton->setEnabled(false);
		ui.deleteTileSetPushButton->setEnabled(false);
	}

	tileSetSelectionChanging = false;
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:33,代码来源:tile_edit_dlg.cpp

示例2: Flags

void Browse::Flags (int flagNumber, bool go)
{
	// For each 
	for (int i=0;i<m_ctrl.InfoList.GetSize(m_128x128);i++)
	{
		// Selected ?
		if (m_ctrl.InfoList.theList[m_128x128][i].Selected)
		{
			// Tile index
			sint index;

			// get flags
			switch (m_128x128)
			{
			case 0:
				// Tile index
				index=tileBank2.getTileSet (land)->getTile128 (i);
				break;
			case 1:
				// Tile index
				index=tileBank2.getTileSet (land)->getTile256 (i);
				break;
			case 2:
				// Tile index
				index=tileBank2.getTileSet (land)->getTransition (i)->getTile ();
				break;
			default:
				nlassert (0);	// no!
			}

			// valid flags
			if (index!=-1)
			{
				// Get flags
				uint value=tileBank2.getTile (index)->getGroupFlags ();

				// Clear flag
				value&=~(1<<flagNumber);

				// Set the flag
				if (go)
					value|=(1<<flagNumber);

				// Setup
				tileBank2.getTile (index)->setGroupFlags (value);
			}
		}
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:49,代码来源:Browse.cpp

示例3: on_resetVegetPushButton_clicked

void CTile_edit_dlg::on_resetVegetPushButton_clicked()
{
	int nindex = ui.tileSetListWidget->currentRow();
	if (nindex != -1) 
	{
		tileBank.getTileSet (nindex)->setTileVegetableDescFileName ("");
		ui.chooseVegetPushButton->setText("...");
	}
	else
	{
		QMessageBox::information( this, tr("No Tile Set Selected"), tr("Please, select a Tile Set first ...") );
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:13,代码来源:tile_edit_dlg.cpp

示例4: OnOk

void Browse::OnOk() 
{
	// TODO: Add your control notification handler code here
	if (thread_actif) return;

	// trap - Don't know if this is the right place to do this
	UpdateData ();
	CTileSet *tileSet=tileBank2.getTileSet (land);
	tileSet->setOriented(Oriented?true:false);


	this->SendMessage(WM_CLOSE);
	EndDialog(1);
}
开发者ID:mixxit,项目名称:solinia,代码行数:14,代码来源:Browse.cpp

示例5: on_editLandPushButton_clicked

void CTile_edit_dlg::on_editLandPushButton_clicked()
{
	int nindex = ui.landListWidget->currentRow();
	if (nindex != -1) 
	{
		QStringList availableTileSetList;
		QStringList landTileSetList;
		for (int i=0; i<tileBank.getTileSetCount(); i++)
		{
			if (tileBank.getLand(nindex)->isTileSet (tileBank.getTileSet(i)->getName()))
				landTileSetList.append( QString( tileBank.getTileSet(i)->getName().c_str() ) );
			else
				availableTileSetList.append( QString( tileBank.getTileSet(i)->getName().c_str() ) );
		}

		bool ok = false;
		QStringList items = CItems_edit_dlg::getItems(this, tr("Edit Land"), ui.landListWidget->item(nindex)->text(), availableTileSetList, landTileSetList, &ok);

		if (ok)
		{
			for (int i=0; i<tileBank.getTileSetCount(); i++)
			{
				// remove tile set
				tileBank.getLand(nindex)->removeTileSet (tileBank.getTileSet(i)->getName());
			}
			for (int i=0; i<items.count(); i++)
			{
				QString rString = items[i];
				tileBank.getLand(nindex)->addTileSet( rString.toUtf8().constData() );
			}
		}
	}
	else
	{
		QMessageBox::information( this, tr("No Land Selected"), tr("Please, select the Land to edit first ...") );
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:37,代码来源:tile_edit_dlg.cpp

示例6: on_orientedCheckBox_stateChanged

void CTile_edit_dlg::on_orientedCheckBox_stateChanged ( int state )
{
	if (!tileSetSelectionChanging)
	{
		int nindex = ui.tileSetListWidget->currentRow();
		if (nindex != -1) 
		{
			tileBank.getTileSet (nindex)->setOriented(ui.orientedCheckBox->isChecked());
		}
		else
		{
			QMessageBox::information( this, tr("No Tile Set Selected"), tr("Please, select a Tile Set first ...") );
		}
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:15,代码来源:tile_edit_dlg.cpp

示例7: 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() ) );
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:42,代码来源:tile_edit_dlg.cpp

示例8: on_surfaceDataLineEdit_textChanged

void CTile_edit_dlg::on_surfaceDataLineEdit_textChanged()
{
	if (!tileSetSelectionChanging)
	{
		int nindex = ui.tileSetListWidget->currentRow();
		if (nindex != -1) 
		{
			bool ok;
			uint intValue = ui.surfaceDataLineEdit->text().toUInt( &ok, 10 );
			if (ok)
			{
				tileBank.getTileSet (nindex)->SurfaceData = (uint32)intValue;
			}
		}
		else
		{
			QMessageBox::information( this, tr("No Tile Set Selected"), tr("Please, select a Tile Set first ...") );
		}
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:20,代码来源:tile_edit_dlg.cpp

示例9: on_chooseVegetPushButton_clicked

void CTile_edit_dlg::on_chooseVegetPushButton_clicked()
{
	int nindex = ui.tileSetListWidget->currentRow();
	if (nindex != -1) 
	{
		QFileDialog::Options options;
		QString selectedFilter;
		QString fileName = QFileDialog::getOpenFileName(this, tr("Choose Veget Set"), ui.chooseVegetPushButton->text() , tr("NeL VegetSet Files (*.vegetset);;All Files (*.*);;"), &selectedFilter, options);
		
		if (!fileName.isEmpty())
		{
			QFileInfo fi(fileName);
			tileBank.getTileSet (nindex)->setTileVegetableDescFileName (fi.fileName().toUtf8().constData());
			ui.chooseVegetPushButton->setText(fi.fileName());
		}
	}
	else
	{
		QMessageBox::information( this, tr("No Tile Set Selected"), tr("Please, select a Tile Set first ...") );
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:21,代码来源:tile_edit_dlg.cpp

示例10: OnBatchLoad

void Browse::OnBatchLoad ()
{
	CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING,
		"Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);

	if (sFile.DoModal()==IDOK)
	{
		char sDrive[256];
		char sPath[256];
		char sName[256];
		char sExt[256];
		_splitpath (sFile.GetPathName(), sDrive, sPath, sName, sExt);

		// look for some numbers..
		char *sNumber=sName+strlen(sName)-1;
		while ((sNumber>sName)&&(*sNumber>='0')&&(*sNumber<='9'))
		{
			sNumber--;
		}
		sNumber[1]=0;

		bool rotate=false;
		if (::MessageBox (NULL, "Do you want to use rotation to reuse alpha tiles ?", "Import rotated tiles", MB_OK|MB_ICONQUESTION|MB_YESNO)==IDYES)
			rotate=true;

		for (int i=0; i<CTileSet::count; i++)
		{
			if (m_ctrl.Texture==3)
			{
				// Current transition
				CTileSet::TTransition transition=(CTileSet::TTransition)i;

				// Transition to patch
				CTileSetTransition* trans=tileBank2.getTileSet (land)->getTransition (transition);
				if (tileBank2.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
						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);
							ok=m_ctrl.InfoList.setTileTransitionAlpha (i, sFinal, (4-rot)%4);

							// End
							break;
						}

						// Rotate the transition
						transition=CTileSet::rotateTransition (transition);

						if (!rotate)
							break;
					}
					if (!ok)
						break;
				}
			}
			else
			{
				// Current transition
				CTileSet::TTransition transition=(CTileSet::TTransition)i;

				// Transition to patch
				CTileSetTransition* trans=tileBank2.getTileSet (land)->getTransition (transition);
				if (tileBank2.getTile (trans->getTile())->getRelativeFileName (m_ctrl.Texture==1?CTile::diffuse:CTile::additive)=="")
				{
					// 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 (!m_ctrl.InfoList.setTileTransition (i, sFinal, m_ctrl.Texture==1?CTile::diffuse:CTile::additive))
							break;
					}
				}
			}
		}
		m_ctrl.Invalidate ();

	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:99,代码来源:Browse.cpp

示例11: 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);
			}
		}
	}

}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:69,代码来源:tile_browser_dlg.cpp

示例12: Init

void Browse::Init()
{		
	UpdateData ();
	lbutton = 0;
	selection = 0;
	control = 0;
	m_ctrl.lockInsertion = 0; oldsel = -1;
	HKEY regkey; 
	unsigned long value; 
	unsigned long type; 
	int cx=-1,cy=-1,x=-1,y=-1;
	char sWindowpl[256];

	if (RegOpenKey(HKEY_CURRENT_USER,REGKEY_TILEDIT,&regkey)==ERROR_SUCCESS)
	{		
		value=256;
		type=REG_SZ;
		if (RegQueryValueEx(regkey,REGKEY_WNDPL,0,&type,(unsigned char *)&sWindowpl,&value)==ERROR_SUCCESS)
		{
			WINDOWPLACEMENT wndpl;
			sscanf(sWindowpl,"%d %d %d %d %d %d %d %d %d %d",
						&wndpl.flags,
						&wndpl.ptMaxPosition.x,&wndpl.ptMaxPosition.y,
						&wndpl.ptMinPosition.x,&wndpl.ptMinPosition.y,
						&wndpl.rcNormalPosition.bottom,&wndpl.rcNormalPosition.left,&wndpl.rcNormalPosition.right,&wndpl.rcNormalPosition.top,
						&wndpl.showCmd);
			wndpl.length = sizeof(WINDOWPLACEMENT);
			this->SetWindowPlacement(&wndpl);
		}
		value=256;
		type=REG_SZ;
		if (RegQueryValueEx(regkey,REGKEY_LASTPATH,0,&type,(unsigned char *)&sWindowpl,&value)!=ERROR_SUCCESS)
			m_ctrl.LastPath="";
		else
			m_ctrl.LastPath=(const char*)sWindowpl;
		value=4;
		type=REG_DWORD;
		if (RegQueryValueEx(regkey,REGKEY_BUTTONZOOM,0,&type,(unsigned char *)&m_ctrl.Zoom,&value)!=ERROR_SUCCESS) 
			m_ctrl.Zoom = 3;
		value=4;
		type=REG_DWORD;
		if (RegQueryValueEx(regkey,REGKEY_BUTTONVARIETY,0,&type,(unsigned char *)&m_128x128,&value)!=ERROR_SUCCESS) 
			m_128x128 = 0;
		value=4;
		type=REG_DWORD;
		if (RegQueryValueEx(regkey,REGKEY_BUTTONTEXTURE,0,&type,(unsigned char *)&m_ctrl.Texture,&value)!=ERROR_SUCCESS) 
			m_ctrl.Texture = 1;
		value=4;
		type=REG_DWORD;
		if (RegQueryValueEx(regkey,REGKEY_BUTTONTEXTINFO,0,&type,(unsigned char *)&m_ctrl.InfoTexte,&value)!=ERROR_SUCCESS) 
			m_ctrl.InfoTexte = 1;
		RegCloseKey(regkey);
	}		
	CButton *button = (CButton*)GetDlgItem(IDC_ZOOM1 + m_ctrl.Zoom -1);
	button->SetCheck(1);
	button = (CButton*)GetDlgItem(IDC_JOUR + m_ctrl.Texture -1);
	button->SetCheck(1);
	button = (CButton*)GetDlgItem(IDC_INFONUM + m_ctrl.InfoTexte -1);
	button->SetCheck(1);	
	if (cx!=-1 && cy!=-1 && x!=-1 && y!=-1) SetWindowPos(0,x,y,cx,cy,0);

	m_ctrl.Init(land, m_128x128);
	SelectionTerritoire *slt = (SelectionTerritoire*)GetParent();
	ccount=1;
	
	RECT rect;
	this->GetWindowRect(&rect);
	SendMessage(WM_SIZE,rect.right - rect.left,rect.bottom - rect.top); //force resize

	SelectionTerritoire *parent = (SelectionTerritoire*)GetParent();

	// The land	
	CTileSet *tileSet=tileBank2.getTileSet (land);

	if (tileSet->getOriented())
		Oriented = 1;
	else
		Oriented = 0;
	
	// 128
	m_ctrl.InfoList.theList128.resize (tileSet->getNumTile128 ());
	int i;
	for (i=0; i<tileSet->getNumTile128 (); i++)
	{
		m_ctrl.InfoList.theList128[i].id=i;
		m_ctrl.InfoList.theList128[i].Selected=0;
		m_ctrl.InfoList.theList128[i].loaded=0;
		m_ctrl.InfoList.theList128[i].nightLoaded=0;
		m_ctrl.InfoList.theList128[i].alphaLoaded=0;
	}
	m_ctrl.InfoList.Reload (0, tileSet->getNumTile128 (), 0);

	// 256
	m_ctrl.InfoList.theList256.resize (tileSet->getNumTile256 ());
	for (i=0; i<tileSet->getNumTile256 (); i++)
	{
		m_ctrl.InfoList.theList256[i].id=i;
		m_ctrl.InfoList.theList256[i].Selected=0;
		m_ctrl.InfoList.theList256[i].loaded=0;
		m_ctrl.InfoList.theList256[i].nightLoaded=0;
//.........这里部分代码省略.........
开发者ID:mixxit,项目名称:solinia,代码行数:101,代码来源:Browse.cpp

示例13: 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;
}
开发者ID:mixxit,项目名称:solinia,代码行数:85,代码来源:Browse.cpp

示例14: OnImportBorder

void Browse::OnImportBorder() 
{
	// Select a file
	CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING,
		"Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
	if (sFile.DoModal()==IDOK)
	{
		// Get the border of the bank
		std::vector<NLMISC::CBGRA> array(128*128);

		// The bitmap
		NLMISC::CBitmap bitmap;

		// Read the bitmap
		bool error=false;
		CString pathName=sFile.GetPathName();
		try
		{
			CIFile file;
			if (file.open ((const char*)pathName))
			{
				// Export
				bitmap.load (file);
			}
			else
				error=true;
		}
		catch (Exception& e)
		{
			const char *toto=e.what ();
			error=true;
		}

		// Error during import ?
		if (error)
		{
			// Error message
			char tmp[512];
			sprintf (tmp, "Can't read bitmap %s", (const char*)pathName);
			MessageBox (tmp, "Import border", MB_OK|MB_ICONEXCLAMATION);
		}

		// 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
			char tmp[512];
			sprintf (tmp, "The bitmap must have a size of 128x128 (%s)", (const char*)pathName);
			MessageBox (tmp, "Import border", MB_OK|MB_ICONEXCLAMATION);
		}

		// 256 or 128 ?
		CTileBorder border;
		border.set (128, 128, array);
		tileBank2.getTileSet (land)->setBorder (m_ctrl.Texture==1?CTile::diffuse:CTile::additive, border);

		// Message
		MessageBox ("The border has been changed.", "Import border", MB_OK|MB_ICONINFORMATION);
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:76,代码来源:Browse.cpp

示例15: OnExportBorder

void Browse::OnExportBorder() 
{
	// Select a file
	CFileDialog sFile (false, NULL, NULL, OFN_ENABLESIZING,
		"Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
	if (sFile.DoModal()==IDOK)
	{
		// Get the border of the bank
		std::vector<NLMISC::CBGRA> array;

		// 256 or 128 ?
		int width, height;
		tileBank2.getTileSet (land)->getBorder128 (m_ctrl.Texture==1?CTile::diffuse:CTile::additive)->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;
			CString pathName=sFile.GetPathName();
			try
			{
				COFile file;
				if (file.open ((const char*)pathName))
				{
					// 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
				char tmp[512];
				sprintf (tmp, "Can't write bitmap %s", (const char*)pathName);
				MessageBox (tmp, "Export border", MB_OK|MB_ICONEXCLAMATION);
			}
		}
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:65,代码来源:Browse.cpp


注:本文中的CTileBank::getTileSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。