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);
		}
	}
}
Exemplo n.º 2
0
/**
* Changes the property setting of a group when is expanding.
*/
void MaterialPropTreeView::OnPropertyItemExpanding( NMHDR *nmhdr, LRESULT *lresult ) {

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

	//The item isn't toggled till after this returns so use the opposite of the current state.
	registry.SetBool(va("Expand%d%s", currentListType, item->GetLabelText()), item->IsExpanded() ? true : false);
	registry.Save();

	*lresult = 0;
}
Exemplo n.º 3
0
void CPropTreeInfo::OnPaint()
{
	CPaintDC dc(this);
	CRect rc;

	GetClientRect(rc);

	dc.SelectObject(GetSysColorBrush(COLOR_BTNFACE));
	dc.PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATCOPY);

	dc.DrawEdge(&rc, BDR_SUNKENOUTER, BF_RECT);
	rc.DeflateRect(4, 4);

	ASSERT(m_pProp!=NULL);

	CPropTreeItem* pItem = m_pProp->GetFocusedItem();

	if (!m_pProp->IsWindowEnabled())
		dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT));
	else
		dc.SetTextColor(GetSysColor(COLOR_BTNTEXT));

	dc.SetBkMode(TRANSPARENT);
	dc.SelectObject(m_pProp->GetBoldFont());

	CString txt;

	if (!pItem)
		txt.LoadString(IDS_NOITEMSEL);
	else
		txt = pItem->GetLabelText();

	CRect ir;
	ir = rc;

	// draw label
	dc.DrawText(txt, &ir, DT_SINGLELINE|DT_CALCRECT);
	dc.DrawText(txt, &ir, DT_SINGLELINE);

	ir.top = ir.bottom;
	ir.bottom = rc.bottom;
	ir.right = rc.right;

	if (pItem)
		txt = pItem->GetInfoText();
	else
		txt.LoadString(IDS_SELFORINFO);

	dc.SelectObject(m_pProp->GetNormalFont());
	dc.DrawText(txt, &ir, DT_WORDBREAK);
}
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()));
	}
}