void CPathCtrl::OnAddButton() { if(m_nEmptyPromptID && !m_path.IsEmpty()) { AfxMessageBox(m_nEmptyPromptID, MB_ICONINFORMATION); //AfxMessageBox("In the following box, click 'Cancel' to empty this file path", MB_ICONINFORMATION ); } //char pszSelectionPrompt[1001]; CString sSelectionPrompt; if(m_nSelectionPromptID) sSelectionPrompt.LoadString(m_nSelectionPromptID); //AfxLoadString(m_nSelectionPromptID, pszSelectionPrompt, 1000); //AfxLoadString if(m_nFlags & kSelectFolder) { CString s; //CFolderDialog dlg(m_path.IsEmpty()?m_path.getFullPath():m_path.getDirectory()); CDirDialog dlg; dlg.m_strWindowTitle = _T("Select Folder"); dlg.m_strSelDir = m_path.getFullPath(); if(m_nSelectionPromptID) dlg.m_strTitle = sSelectionPrompt; else dlg.m_strTitle = _T(" "); //dlg.m_bi.lpszTitle =sSelectionPrompt; if(dlg.DoBrowse() == IDOK) { m_path = dlg.m_strPath +_T("\\"); //dlg.GetPathName() +_T("\\"); } else if(m_nEmptyPromptID) { m_path=_T(""); } } else { CFileDialog dlg(TRUE, m_sDefaultExt, m_path.getFullPath(), OFN_HIDEREADONLY,//|OFN_FILEMUSTEXIST, m_sFilter); if(m_nSelectionPromptID) dlg.m_ofn.lpstrTitle= sSelectionPrompt; if(dlg.DoModal() == IDOK) { m_path = dlg.GetPathName(); } else if(m_nEmptyPromptID) { m_path=_T(""); } } updatePathDisplay(); }
void CDlgPicFilePath::OnBnClickedFile() { CDirDialog dlgDir; dlgDir.m_strTitle = _T("选择抓图文件路径"); UpdateData(TRUE); dlgDir.m_strSelDir = "C:\\"; dlgDir.m_strWindowTitle = _T("目录选择"); if (dlgDir.DoBrowse(this) == IDOK) { m_FilePath = dlgDir.m_strPath; UpdateData(FALSE); } TRACE("%s", m_FilePath); }
void CPrefabTrackerDlg::OnButtonGenerate() { CWaitCursor WaitCursor; //first off clear out any existing window text, and any old data m_Prefabs.SetSize(0); ClearText(); //alright, now we need to get the prefab directory and the world directory CDirDialog PrefabDir; PrefabDir.m_hwndOwner = m_hWnd; PrefabDir.m_strInitDir = GetProject()->m_BaseProjectDir; PrefabDir.m_strTitle = "Select Prefab Directory"; if(!PrefabDir.DoBrowse()) return; CDirDialog WorldDir; WorldDir.m_hwndOwner = m_hWnd; WorldDir.m_strInitDir = GetProject()->m_BaseProjectDir; WorldDir.m_strTitle = "Select World Directory"; if(!WorldDir.DoBrowse()) return; //alright, we now have both directories. Now build up a list of all the prefabs and worlds under //that directory CMoArray<CString> sPrefabs; CFileUtils::GetAllWorldFiles(PrefabDir.m_strPath, sPrefabs); CMoArray<CString> sWorlds; CFileUtils::GetAllWorldFiles(WorldDir.m_strPath, sWorlds); //alright, we now need to convert the prefab file list over to structures we can use m_Prefabs.SetSize(sPrefabs.GetSize()); uint32 nCurrPrefab; for(nCurrPrefab = 0; nCurrPrefab < sPrefabs.GetSize(); nCurrPrefab++) { m_Prefabs[nCurrPrefab].m_sFilename = RemoveProjectPath(sPrefabs[nCurrPrefab]); m_Prefabs[nCurrPrefab].m_nTotalRefCount = 0; m_Prefabs[nCurrPrefab].m_References.SetSize(0); } //alright, now we run through every level, open it, and look for prefabs for(uint32 nCurrWorld = 0; nCurrWorld < sWorlds.GetSize(); nCurrWorld++) { CString sWorld = sWorlds[nCurrWorld]; CString sRelativeWorld = RemoveProjectPath(sWorld); //load up the LTA if it is a world CLTALoadOnlyAlloc Allocator(512 * 1024); //open up the file CLTAReader File; if(!File.Open(sWorld, CLTAUtil::IsFileCompressed(sWorld))) { continue; } //load up the world node CLTANode* pWorld = CLTANodeReader::LoadNode(&File, "world", &Allocator); //clean up the file File.Close(); //if there is no world node, then this was not a world if(pWorld == NULL) { Allocator.FreeNode(pWorld); Allocator.FreeAllMemory(); continue; } //now find any matching prefabs CLTANodeIterator Iter(pWorld); CLTANode* pPrefabName; while((pPrefabName = Iter.FindNextList("prefabfile")) != NULL) { //sanity checks ASSERT(pPrefabName->IsList()); if(pPrefabName->GetNumElements() < 2) continue; CLTANode* pValue = pPrefabName->GetElement(1); if(pValue->IsList()) continue; //valid, now see if we have a match for(uint32 nCurrPrefab = 0; nCurrPrefab < m_Prefabs.GetSize(); nCurrPrefab++) { if(m_Prefabs[nCurrPrefab].m_sFilename.CompareNoCase(pValue->GetValue()) == 0) { //we have a match, add this reference bool bFoundRef = false; for(uint32 nCurrRef = 0; nCurrRef < m_Prefabs[nCurrPrefab].m_References.GetSize(); nCurrRef++) { if(m_Prefabs[nCurrPrefab].m_References[nCurrRef].m_sFile.CompareNoCase(sRelativeWorld) == 0) { //found a reference m_Prefabs[nCurrPrefab].m_References[nCurrRef].m_nRefCount++; bFoundRef = true; break; } } //no luck finding an existing one, make a new one if(!bFoundRef) { SPrefabInfo::SPrefabRef NewRef; NewRef.m_sFile = sRelativeWorld; NewRef.m_nRefCount = 1; m_Prefabs[nCurrPrefab].m_References.Append(NewRef); } m_Prefabs[nCurrPrefab].m_nTotalRefCount++; } } } //now clean up the world and the memory Allocator.FreeNode(pWorld); Allocator.FreeAllMemory(); } FillEditText(); }