本文整理汇总了C++中MaterialDoc::SetMaterialName方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialDoc::SetMaterialName方法的具体用法?C++ MaterialDoc::SetMaterialName怎么用?C++ MaterialDoc::SetMaterialName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaterialDoc
的用法示例。
在下文中一共展示了MaterialDoc::SetMaterialName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenameMaterial
/**
* Handles all of the little problems associated with renaming a folder.
*/
void MaterialTreeView::RenameMaterial( HTREEITEM item, const char *originalName ) {
CTreeCtrl &tree = GetTreeCtrl();
const idMaterial *material = declManager->FindMaterial( originalName );
MaterialDoc *pMaterial;
//pMaterial = materialDocManager->GetInProgressDoc(material);
//if(!pMaterial) {
pMaterial = materialDocManager->CreateMaterialDoc( const_cast<idMaterial *>( material ) );
//}
//Remove our old quick lookup value
materialToTree.Remove( originalName );
//Generate the new name
idStr materialName;
HTREEITEM parent = tree.GetParentItem( item );
DWORD parentType = tree.GetItemData( parent );
if( parentType == TYPE_MATERIAL_FOLDER ) {
//Need to include the material folder
materialName = GetMediaPath( parent, TYPE_MATERIAL_FOLDER );
materialName += "/";
}
materialName += tree.GetItemText( item );
//Add it to our quick lookup
materialToTree.Set( materialName, item );
//Finally make the change
internalChange = true;
pMaterial->SetMaterialName( materialName, false );
internalChange = false;
}
示例2: OnTvnEndlabeledit
/**
* Makes sure that a rename operation can be performed after a label edit is complete and
* performs the folder or material rename.
*/
void MaterialTreeView::OnTvnEndlabeledit( NMHDR *pNMHDR, LRESULT *pResult ) {
LPNMTVDISPINFO pTVDispInfo = reinterpret_cast<LPNMTVDISPINFO>( pNMHDR );
*pResult = 0;
if( pTVDispInfo->item.pszText ) {
//Convert any edited text to lower case to keep the name canonical
idStr newLabel = pTVDispInfo->item.pszText;
newLabel.ToLower();
strncpy( pTVDispInfo->item.pszText, newLabel.c_str(), pTVDispInfo->item.cchTextMax );
CTreeCtrl &tree = GetTreeCtrl();
DWORD type = tree.GetItemData( pTVDispInfo->item.hItem );
if( type == TYPE_MATERIAL ) {
MaterialDoc *pMaterial = materialDocManager->GetCurrentMaterialDoc();
//Remove our old quick lookup value
materialToTree.Remove( pMaterial->name.c_str() );
//Generate the new name
idStr material;
HTREEITEM parent = tree.GetParentItem( pTVDispInfo->item.hItem );
DWORD parentType = tree.GetItemData( parent );
if( parentType == TYPE_MATERIAL_FOLDER ) {
//Need to include the material folder
material = GetMediaPath( parent, TYPE_MATERIAL_FOLDER );
material += "/";
}
material += pTVDispInfo->item.pszText;
if( declManager->FindMaterial( material, false ) ) {
//Can't rename because it conflicts with an existing file
MessageBox( "Unable to rename material because it conflicts with another material", "Error" );
} else {
//Add it to our quick lookup
materialToTree.Set( material, pTVDispInfo->item.hItem );
//Finally make the change
internalChange = true;
pMaterial->SetMaterialName( material );
internalChange = false;
renamedFolder = pTVDispInfo->item.hItem;
PostMessage( MSG_RENAME_MATERIAL_COMPLETE );
*pResult = 1;
}
} else if( type == TYPE_MATERIAL_FOLDER ) {
//Clean up the quicktree with the current tree before we allow the edit to commit
CleanLookupTrees( pTVDispInfo->item.hItem );
//Store some data so the we can make the appropriate changes after the commit
renamedFolder = pTVDispInfo->item.hItem;
affectedMaterials.Clear();
GetMaterialPaths( renamedFolder, &affectedMaterials );
PostMessage( MSG_RENAME_FOLDER_COMPLETE );
RenameMaterialFolderModifier *mod = new RenameMaterialFolderModifier( materialDocManager, pTVDispInfo->item.pszText, this, pTVDispInfo->item.hItem, tree.GetItemText( pTVDispInfo->item.hItem ) );
materialDocManager->AddMaterialUndoModifier( mod );
*pResult = 1;
}
}
}
示例3: Redo
/**
* Performs a redo operation of a renamed material.
*/
void RenameMaterialModifier::Redo()
{
MaterialDoc *material = manager->CreateMaterialDoc(oldName);
material->SetMaterialName(materialName, false);
}