void GLIShaderDebug::UpdateVariableDisplay() { //Delete all existing items propTree->DeleteAllItems(); // Create the watch variables root item CPropTreeItem* pRoot; pRoot = propTree->InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("Watch values")); pRoot->Expand(); //Loop for all watch values and add them //Add a empty watch value to enable a new one to be added CPropTreeItem* pItem; pItem = propTree->InsertItem(new CPropTreeItem(), pRoot); pItem->SetLabelText(_T("")); pItem->SetInfoText(_T("")); //Create the uniforms root item pRoot = propTree->InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("Uniforms")); pRoot->Expand(); //Loop for all uniforms and add values of the appropiate type for(uint i=0; i<uniformValues.size(); i++) { AddVariableDisplay(pRoot, uniformValues[i]); } }
/** * 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(); }
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); } } }
//Create sample data for the preview properties void MaterialPreviewPropView::InitializePropTree(void) { int i; CPropTreeItem *pRoot; CPropTreeItem *pParmRoot; CPropTreeItemCheck *pCheck; CPropTreeItemEdit *pEdit; pRoot = m_Tree.InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("Preview Properties")); pRoot->SetInfoText(_T("Properties for the preview window.")); pRoot->Expand(); // have this item expanded by default CPropTreeItemCombo *pCombo; pCombo = (CPropTreeItemCombo *)m_Tree.InsertItem(new CPropTreeItemCombo(), pRoot); pCombo->SetLabelText(_T("Model Type")); pCombo->SetInfoText(_T("Select the type of model on which to preview the material.")); pCombo->CreateComboBox(); pCombo->InsertString(0, "Cube"); pCombo->InsertString(1, "Box - 2:1"); pCombo->InsertString(2, "Box - 4:1"); pCombo->InsertString(3, "Box - 1:2"); pCombo->InsertString(4, "Box - 1:4"); pCombo->InsertString(5, "Cylinder - V"); pCombo->InsertString(6, "Cylinder - H"); pCombo->InsertString(7, "Sphere"); pCombo->SetItemData(0, 0); pCombo->SetItemData(1, 1); pCombo->SetItemData(2, 2); pCombo->SetItemData(3, 3); pCombo->SetItemData(4, 4); pCombo->SetItemData(5, 5); pCombo->SetItemData(6, 6); pCombo->SetItemData(7, 7); pCombo->SetCurSel(0); // Custom model entry /*pEdit = (CPropTreeItemEdit*)m_Tree.InsertItem( new CPropTreeItemEdit(), pRoot ); pEdit->SetLabelText(_T("Custom Model")); pEdit->SetInfoText(_T("Specify any model to display the current material.")); pEdit->SetItemValue((LPARAM)_T(""));*/ CPropTreeItemEditButton *pCutomButton; pCutomButton = (CPropTreeItemEditButton *)m_Tree.InsertItem(new CPropTreeItemEditButton(), pRoot); pCutomButton->SetButtonText(_T("...")); pCutomButton->SetLabelText(_T("Custom Model")); pCutomButton->SetInfoText(_T("Specify any model to display the current material.")); pCutomButton->SetItemValue((LPARAM)_T("")); // Checkbox for showing debug light spheres pCheck = (CPropTreeItemCheck *)m_Tree.InsertItem(new CPropTreeItemCheck(), pRoot); pCheck->SetLabelText(_T("Show Lights")); pCheck->SetInfoText(_T("Show the light origin sphere and number in the preview.")); pCheck->CreateCheckBox(); pCheck->SetCheckState(BST_CHECKED); // Local and Global shader parms pParmRoot = m_Tree.InsertItem(new CPropTreeItem()); pParmRoot->SetLabelText(_T("Local Parms")); pParmRoot->SetInfoText(_T("Local shaderparms for the model being displayed.")); pParmRoot->Expand(FALSE); // have this item NOT expanded by default for (i = 0; i < MAX_ENTITY_SHADER_PARMS; i++) { pEdit = (CPropTreeItemEdit *)m_Tree.InsertItem(new CPropTreeItemEdit(), pParmRoot); pEdit->SetLabelText(_T(va("parm%d", i))); pEdit->SetInfoText(_T("Set the local shaderparm for the model")); if (i < 4) { pEdit->SetItemValue((LPARAM)_T("1")); } else { pEdit->SetItemValue((LPARAM)_T("0")); } } pParmRoot = m_Tree.InsertItem(new CPropTreeItem()); pParmRoot->SetLabelText(_T("Global Parms")); pParmRoot->SetInfoText(_T("Global shaderparms for the renderworld being displayed.")); pParmRoot->Expand(FALSE); // have this item NOT expanded by default for (i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++) { pEdit = (CPropTreeItemEdit *)m_Tree.InsertItem(new CPropTreeItemEdit(), pParmRoot); pEdit->SetLabelText(_T(va("global%d", i))); pEdit->SetInfoText(_T("Set the global shaderparm for the renderworld")); if (i < 4) { pEdit->SetItemValue((LPARAM)_T("1")); } else { pEdit->SetItemValue((LPARAM)_T("0")); } } // Lights pRoot = m_Tree.InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("")); pRoot->SetInfoText(_T("")); CPropTreeItemButton *pButton; pButton = (CPropTreeItemButton *)m_Tree.InsertItem(new CPropTreeItemButton()); pButton->SetButtonText(_T(" Add Light ")); pButton->SetLabelText(_T("Preview Lights")); pButton->SetInfoText(_T("Test the button.")); pRoot = m_Tree.InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("")); pRoot->SetInfoText(_T("")); AddLight(); }