本文整理汇总了C++中MaterialDoc类的典型用法代码示例。如果您正苦于以下问题:C++ MaterialDoc类的具体用法?C++ MaterialDoc怎么用?C++ MaterialDoc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MaterialDoc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMaterialSource
/**
* Gets the source of the current document and populates the
* source edit control.
*/
void MaterialEditView::GetMaterialSource() {
//Clear it
sourceInit = true;
m_textView.SetText("");
sourceInit = false;
if(materialDocManager) {
MaterialDoc* material = materialDocManager->GetCurrentMaterialDoc();
if(material) {
idStr text = material->GetEditSourceText();
// clean up new-line crapola
text.Replace( "\r", "" );
text.Replace( "\n", "\r" );
text.Replace( "\v", "\r" );
text.StripLeading( '\r' );
text.Append( "\r" );
sourceInit = true;
m_textView.SetText(text);
sourceInit = false;
}
}
}
示例2: GetTreeCtrl
/**
* 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;
}
示例3: RefreshProperties
/**
* Initializes the property tree with the data from the currently selected material.
*/
void MaterialPropTreeView::RefreshProperties() {
MaterialDefList* propList = MaterialDefManager::GetMaterialDefs(currentListType);
if(!propList)
return;
MaterialDoc* materialDoc = materialDocManager->GetCurrentMaterialDoc();
for(int i = 0; i < propList->Num(); i++) {
switch((*propList)[i]->type) {
case MaterialDef::MATERIAL_DEF_TYPE_BOOL:
{
bool val = materialDoc->GetAttributeBool(currentStage, (*propList)[i]->dictName);
CPropTreeItemCheck* item = (CPropTreeItemCheck*)m_Tree.FindItem((*propList)[i]->GetViewData(PROP_TREE_VIEW));
item->SetCheckState(val ? TRUE:FALSE);
}
break;
case MaterialDef::MATERIAL_DEF_TYPE_STRING:
{
idStr val = materialDoc->GetAttribute(currentStage, (*propList)[i]->dictName);
CPropTreeItemEdit* item = (CPropTreeItemEdit*)m_Tree.FindItem((*propList)[i]->GetViewData(PROP_TREE_VIEW));
item->SetItemValue((LPARAM)val.c_str());
}
break;
}
}
Invalidate();
}
示例4: Undo
/**
* Performs an undo operation of a deleted stage.
*/
void StageDeleteModifier::Undo() {
MaterialDoc* material = manager->CreateMaterialDoc(materialName);
material->InsertStage(stageNum, stageData.GetInt("stagetype"), stageData.GetString("name"), false);
material->SetData(stageNum, &stageData);
}
示例5: FindDefForTreeID
/**
* Updated the material when an attribute has been changed.
*/
void MaterialPropTreeView::OnPropertyChangeNotification( NMHDR *nmhdr, LRESULT *lresult ) {
NMPROPTREE *nmProp = (NMPROPTREE *)nmhdr;
CPropTreeItem *item = nmProp->pItem;
internalChange = true;
MaterialDef* propItem = FindDefForTreeID(item->GetCtrlID());
if(propItem) {
MaterialDoc* materialDoc = materialDocManager->GetCurrentMaterialDoc();
switch(propItem->type) {
case MaterialDef::MATERIAL_DEF_TYPE_BOOL:
{
BOOL val = item->GetItemValue();
materialDoc->SetAttributeBool(currentStage, propItem->dictName, val ? true : false);
}
break;
case MaterialDef::MATERIAL_DEF_TYPE_STRING:
{
idStr val = (LPCTSTR)item->GetItemValue();
materialDoc->SetAttribute(currentStage, propItem->dictName, val);
}
break;
}
}
internalChange = false;
*lresult = 0;
}
示例6: GetListCtrl
/**
* Performs the stage move when the user has dragged and dropped a stage.
*/
void StageView::DropItemOnList() {
CListCtrl& list = GetListCtrl();
int toStage;
//Get and adjust the drop index based on the direction of the move
dropIndex = list.HitTest(dropPoint);
if(dropIndex < 0) dropIndex = list.GetItemCount()-1;
//Ignore the drop if the index is the same or they are droping on the material
if(dropIndex == dragIndex || dropIndex == 0)
return;
//Move the stage data
MaterialDoc* material = materialDocManager->GetCurrentMaterialDoc();
internalChange = true;
toStage = dropIndex-1;
material->MoveStage(dragIndex-1, dropIndex-1);
internalChange = false;
if(dragIndex < dropIndex) {
dropIndex++;
}
//Get the item
char szLabel[256];
LV_ITEM lvi;
ZeroMemory(&lvi, sizeof(LV_ITEM));
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
lvi.pszText = szLabel;
lvi.iItem = dragIndex;
lvi.cchTextMax = 255;
list.GetItem(&lvi);
//Insert the item
lvi.iItem = dropIndex;
list.InsertItem(&lvi);
//Adjust the drag index if the move was up in the list
if(dragIndex > dropIndex) {
dragIndex++;
}
//Delete the original item
list.DeleteItem(dragIndex);
int type = -1;
int stageType = currentMaterial->GetAttributeInt(toStage, "stagetype");
switch(stageType) {
case MaterialDoc::STAGE_TYPE_NORMAL:
type = MaterialDefManager::MATERIAL_DEF_STAGE;
break;
case MaterialDoc::STAGE_TYPE_SPECIALMAP:
type = MaterialDefManager::MATERIAL_DEF_SPECIAL_STAGE;
break;
}
m_propView->SetPropertyListType(type, toStage);
}
示例7: OnLvnBeginlabeledit
/**
* Determines is a label edit can be performed on the selected stage.
*/
void StageView::OnLvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult) {
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
//if this is a special stage then don't allow edit
int index = pDispInfo->item.iItem;
MaterialDoc* material = materialDocManager->GetCurrentMaterialDoc();
if(index <= 0 || material->GetAttributeInt(index-1, "stagetype") != MaterialDoc::STAGE_TYPE_NORMAL)
{
*pResult = 1;
return;
}
//ToDo: Can we move the edit box
/*HWND edit = ListView_GetEditControl(m_hWnd);
CWnd* editWnd = CWnd::FromHandle(edit);
CRect rect;
editWnd->GetWindowRect(rect);
rect.left += 22;
rect.right += 22;
editWnd->MoveWindow(rect);*/
*pResult = 0;
}
示例8: MessageBox
/**
* Conforms the user wants to delete all stages and then performs the operation.
*/
void StageView::OnDeleteAllStages() {
int result = MessageBox("Are you sure you want to delete all stages?", "Delete?", MB_ICONQUESTION | MB_YESNO);
if(result == IDYES) {
MaterialDoc* material = materialDocManager->GetCurrentMaterialDoc();
material->ClearStages();
}
}
示例9: OnEnChangeEdit
/**
* Called when the user changes text in the edit control
*/
void MaterialEditView::OnEnChangeEdit( NMHDR *pNMHDR, LRESULT *pResult ) {
if(materialDocManager && !sourceInit) {
MaterialDoc* material = materialDocManager->GetCurrentMaterialDoc();
if(material && !material->IsSourceModified()) {
sourceChanged = true;
material->SourceModify(this);
}
}
}
示例10: OnStateChanged
/**
* Called by the ToggleListView when the toggle state has changed.
*/
void StageView::OnStateChanged(int index, int toggleState) {
MaterialDoc* material = materialDocManager->GetCurrentMaterialDoc();
if(material && index > 0) {
if (toggleState == ToggleListView::TOGGLE_STATE_ON) {
material->EnableStage(index-1, true);
} else if (toggleState == ToggleListView::TOGGLE_STATE_OFF) {
material->EnableStage(index-1, false);
}
}
}
示例11: OnLvnEndlabeledit
/**
* Performs the stage name change after the label edit is done.
*/
void StageView::OnLvnEndlabeledit( NMHDR *pNMHDR, LRESULT *pResult ) {
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO *>( pNMHDR );
if( pDispInfo->item.pszText ) {
MaterialDoc *material = materialDocManager->GetCurrentMaterialDoc();
internalChange = true;
material->SetAttribute( pDispInfo->item.iItem - 1, "name", pDispInfo->item.pszText );
internalChange = false;
*pResult = 1;
} else {
*pResult = 0;
}
}
示例12: strncpy
/**
* 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;
}
}
}
示例13: ApplyMaterialSource
/**
* Takes the source out of the edit control and applies it
* to the material.
*/
void MaterialEditView::ApplyMaterialSource() {
if(!sourceChanged)
return;
MaterialDoc* material = materialDocManager->CreateMaterialDoc(currentMaterialName);
if(material) {
idStr text = GetSourceText();
material->ApplySourceModify(text);
}
sourceChanged = false;
}
示例14: GetListCtrl
/**
* Deletes the selected stage when the user selects the delete menu option.
*/
void StageView::OnDeleteStage() {
CListCtrl &list = GetListCtrl();
POSITION pos = list.GetFirstSelectedItemPosition();
int nItem = -1;
if( pos ) {
nItem = list.GetNextSelectedItem( pos );
if( nItem > 0 ) {
int result = MessageBox( "Are you sure you want to delete this stage?", "Delete?", MB_ICONQUESTION | MB_YESNO );
if( result == IDYES ) {
MaterialDoc *material = materialDocManager->GetCurrentMaterialDoc();
material->RemoveStage( nItem - 1 );
}
}
}
}
示例15: OnPaste
/**
* Performs a paste operation when the user selects the menu option.
*/
void StageView::OnPaste() {
if( materialDocManager->IsCopyStage() ) {
MaterialDoc *material = materialDocManager->GetCurrentMaterialDoc();
int type;
idStr name;
materialDocManager->GetCopyStageInfo( type, name );
int existingIndex = material->FindStage( type, name );
if( type != MaterialDoc::STAGE_TYPE_SPECIALMAP || existingIndex == -1 ) {
materialDocManager->PasteStage( material );
} else {
if( MessageBox( va( "Do you want to replace '%s' stage?", name.c_str() ), "Replace?", MB_ICONQUESTION | MB_YESNO ) == IDYES ) {
material->RemoveStage( existingIndex );
materialDocManager->PasteStage( material );
}
}
}
}