コード例 #1
0
/**
* 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;
}
コード例 #2
0
/**
* Initializes the list of properties based on the type (material, stage, special stage).
* @param listType The type of list (material, stage, special stage)
* @param stageNum The stage from which to get the attributes.
*/
void MaterialPropTreeView::SetPropertyListType(int listType, int stageNum) {

	currentListType = listType;
	currentStage = stageNum;

	m_Tree.DeleteAllItems();

	//idList<MaterialProp_t*>* propList = NULL;
	MaterialDefList* propList = MaterialDefManager::GetMaterialDefs(currentListType);
	currentPropDefs = propList;

	if(!propList)
		return;

	CPropTreeItem* pCurrentGroup = NULL;
	CPropTreeItem* pCurrentNode = NULL;

	for(int i = 0; i < propList->Num(); i++) {
		switch((*propList)[i]->type) {
			case MaterialDef::MATERIAL_DEF_TYPE_GROUP:
				{
					pCurrentGroup = m_Tree.InsertItem(new CPropTreeItem());
					pCurrentNode = pCurrentGroup;

					if(!registry.GetBool(va("Expand%d%s", currentListType, (*propList)[i]->displayName.c_str())))
						pCurrentGroup->Expand();
				}
				break;
			case MaterialDef::MATERIAL_DEF_TYPE_BOOL:
				{
					CPropTreeItemCheck* pCheck;
					pCheck = (CPropTreeItemCheck*)m_Tree.InsertItem(new CPropTreeItemCheck(), pCurrentGroup);
					pCheck->CreateCheckBox();
					pCurrentNode = pCheck;
				}
				break;
			case MaterialDef::MATERIAL_DEF_TYPE_STRING:
				{
					//pCurrentNode = m_Tree.InsertItem(new CPropTreeItemEdit(), pCurrentGroup);	
					pCurrentNode = m_Tree.InsertItem(new CPropTreeItemFileEdit(), pCurrentGroup);

				}
				break;
		}

		if(pCurrentNode) {
			(*propList)[i]->SetViewData(PROP_TREE_VIEW, pCurrentNode->GetCtrlID());
			pCurrentNode->SetLabelText((*propList)[i]->displayName);
			pCurrentNode->SetInfoText((*propList)[i]->displayInfo);
		}
	}

	RefreshProperties();
}
コード例 #3
0
void MaterialPreviewPropView::OnPropertyButtonClick(NMHDR *nmhdr, LRESULT *lresult)
{
	NMPROPTREE		*nmProp;
	CPropTreeItem	*item;

	nmProp = (NMPROPTREE *)nmhdr;
	item = nmProp->pItem;

	idStr	itemLabel = item->GetLabelText();

	if (itemLabel == "Preview Lights") {
		AddLight();

	} else if (itemLabel.Left(5) == "Light") {
		CPropTreeItem	*light;
		int lightId = item->GetCtrlID();
		int testLightNum = 0;

		m_Tree.DeleteItem(item);

		for (light = m_Tree.GetRootItem()->GetChild(); light != NULL; light = light->GetSibling()) {
			idStr label = light->GetLabelText();

			if (label.Left(5) == "Light") {
				testLightNum++;
				light->SetLabelText(_T(va("Light #%d", testLightNum)));
				light->SetInfoText(_T(va("Parameters for light number %d.", testLightNum)));
				light->SetCtrlID(testLightNum - 1);
			}
		}

		materialPreview->OnDeleteLight(lightId);

		numLights--;
	} else if (itemLabel == "Custom Model") {
		CFileDialog dlg(TRUE);
		dlg.m_ofn.Flags |= OFN_FILEMUSTEXIST;
		item->Check(FALSE);

		if (dlg.DoModal()== IDOK) {
			item->Check(FALSE);
			item->SetItemValue((LPARAM)fileSystem->OSPathToRelativePath(dlg.m_ofn.lpstrFile));
			m_Tree.SendNotify(PTN_ITEMCHANGED, item);
		}
	}
}
コード例 #4
0
void MaterialPreviewPropView::OnPropertyChangeNotification(NMHDR *nmhdr, LRESULT *lresult)
{
	idVec3			testColor;
	int				lightId = 0;
	COLORREF		color;
	NMPROPTREE		*nmProp;
	CPropTreeItem	*item;
	CPropTreeItem	*parent;

	nmProp = (NMPROPTREE *)nmhdr;
	item = nmProp->pItem;

	// Determine which light this item modifies
	parent = item->GetParent();

	if (parent) {
		lightId = parent->GetCtrlID();
	}

	idStr	itemLabel = item->GetLabelText();

	if (itemLabel == "Model Type") {
		materialPreview->OnModelChange(item->GetItemValue());

	} else if (itemLabel == "Custom Model") {
		materialPreview->OnCustomModelChange((const char *)item->GetItemValue());

	} else if (itemLabel == "Show Lights") {
		materialPreview->OnShowLightsChange(item->GetItemValue() ? true : false);

	} else if (itemLabel == "Shader") {
		CPropTreeItemCombo	*combo = (CPropTreeItemCombo *)item;
		CString materialName;

		combo->GetLBText(combo->GetCurSel(), materialName);

		materialPreview->OnLightShaderChange(lightId, materialName.GetBuffer());

	} else if (itemLabel == "Radius") {
		materialPreview->OnLightRadiusChange(lightId, atof((char *)item->GetItemValue()));

	} else if (itemLabel == "Color") {
		color = item->GetItemValue();

		testColor.x = (float)GetRValue(color) * (float)(1.f/255.f);
		testColor.y = (float)GetGValue(color) * (float)(1.f/255.f);
		testColor.z = (float)GetBValue(color) * (float)(1.f/255.f);

		materialPreview->OnLightColorChange(lightId, testColor);

	} else if (itemLabel == "Move light") {
		materialPreview->OnLightAllowMoveChange(lightId, item->GetItemValue() ? true : false);

	} else if (itemLabel.Left(4) == "parm") {
		int index;

		itemLabel.Strip("parm");
		index = atoi(itemLabel.c_str());

		materialPreview->OnLocalParmChange(index, atof((char *)item->GetItemValue()));

	} else if (itemLabel.Left(6) == "global") {
		int index;

		itemLabel.Strip("global");
		index = atoi(itemLabel.c_str());

		materialPreview->OnGlobalParmChange(index, atof((char *)item->GetItemValue()));
	}
}