Exemple #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;
}
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()));
	}
}