/*********************************************************************\ Function name : CResEditBrowser::BrowsePath Description : Created at : 26.09.01, @ 11:59:42 Created by : Thomas Kunert Modified by : \*********************************************************************/ void CResEditBrowser::BrowsePath(Filename fn) { AutoAlloc <BrowseFiles> pBrowse; pBrowse->Init(fn, false); Filename fnBrowse; TreeViewItem* pNewItem; //TRACE_STRING(fn.GetString()); while (pBrowse->GetNext()) { fnBrowse = pBrowse->GetFilename(); if (pBrowse->IsDir()) { BrowsePath(fn + fnBrowse); continue; } pNewItem = nullptr; if (fnBrowse.CheckSuffix("res")) pNewItem = m_wndTreeView.AddItem(fnBrowse.GetFileString(), m_pDialogsItem); else if (fnBrowse.CheckSuffix("tif") || fnBrowse.CheckSuffix("jpg") || fnBrowse.CheckSuffix("bmp")) pNewItem = m_wndTreeView.AddItem(fnBrowse.GetFileString(), m_pImagesItem); if (pNewItem) pNewItem->GetData()->SetString(ITEM_PATH_NAME, (fn + fnBrowse).GetString()); } }
Bool DiffDistriDialog::Command(Int32 id, const BaseContainer &msg) { switch (id) { case IDC_DIFF_DISTRI_NEW_BTN: { Filename fn; if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, GeLoadString(IDS_DIFF_DISTRI_CHOOSE))) { if (!fn.CheckSuffix("zip")) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_INVALID_SUFFIX), GEMB_OK | GEMB_ICONSTOP); } else { g_pResEditPrefs->arOldFiles.AddFilename(fn); m_pTreeView->Refresh(); } } } break; case IDC_DIFF_DISTRI_REMOVE_BTN: if (m_fnSelection.Content()) { g_pResEditPrefs->arOldFiles.RemoveFilename(m_fnSelection); m_fnSelection = Filename(); m_pTreeView->Refresh(); } break; case IDC_DIFF_DISTRI_NEWZIP_EDIT: g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename(); break; case IDC_DIFF_DISTRI_DESTPATH_EDIT: { Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename(); g_pResEditPrefs->fnDestZip = fnDestZip; g_pResEditPrefs->fnDestZip.SetSuffix("zip"); if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip) m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip)); } break; case IDC_OK: { GeData d; String strPassword; Int32 lLen = 0; char* pchPassword = nullptr; Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename(); g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename(); g_pResEditPrefs->fnDestZip = fnDestZip; g_pResEditPrefs->fnDestZip.SetSuffix("zip"); if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip) m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip)); GetString(IDC_DIFF_DISTRI_PASSWORD_EDIT, strPassword); lLen = strPassword.GetCStringLen(STRINGENCODING_8BIT); if (lLen) { pchPassword = NewMemClear(Char,lLen + 2); if (pchPassword) strPassword.GetCString(pchPassword, lLen + 1, STRINGENCODING_8BIT); } if (!g_pResEditPrefs->arOldFiles.GetElementCount()) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_OLD), GEMB_ICONSTOP); DeleteMem(pchPassword); break; } if (!g_pResEditPrefs->fnNewZip.Content()) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_NEW), GEMB_ICONSTOP); DeleteMem(pchPassword); break; } if (!g_pResEditPrefs->fnDestZip.Content()) { GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_DEST), GEMB_ICONSTOP); DeleteMem(pchPassword); break; } if (!DiffZipFiles(g_pResEditPrefs->arOldFiles, g_pResEditPrefs->fnNewZip, g_pResEditPrefs->fnDestZip, pchPassword)) GeOutString(GeLoadString(IDS_DIFF_DISTRI_FAILED, g_pResEditPrefs->fnNewZip.GetString(), g_pResEditPrefs->fnDestZip.GetString()), GEMB_OK | GEMB_ICONEXCLAMATION); DeleteMem(pchPassword); } break; case IDC_CANCEL: Close(); break; default: break; } return true; }
/*********************************************************************\ Function name : CResEditBrowser::Command Description : Created at : 25.09.01, @ 22:33:39 Created by : Thomas Kunert Modified by : \*********************************************************************/ Bool CResEditBrowser::Command(Int32 lID, const BaseContainer &msg) { switch (lID) { case IDC_BROWSE_BUTTON: { Filename fn = m_strPath; AutoAlloc <BrowseFiles> pFiles; pFiles->Init(Filename("\\"), false); if (!m_strPath.Content()) fn = GeGetStartupPath() + String("resource"); if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_DIRECTORY, GeLoadString(IDS_SPECIFY_RES_PATH))) { m_strPath = fn; FillList(); } break; } case IDC_DIRECTORY_TREE: { TreeViewItem* pSelItem = (TreeViewItem*)msg.GetVoid(TREEVIEW_MESSAGE_ITEM); Int32 lType = msg.GetInt32(TREEVIEW_MESSAGE_TYPE); if (!pSelItem) break; if (lType == TREEVIEW_DOUBLECLICK) { Filename fn = pSelItem->GetData()->GetString(ITEM_PATH_NAME); if (fn.CheckSuffix("res")) { // open the resource file if (!g_bWasActive) { CResEditMenu m; m.Execute(nullptr); } if (!g_pTreeDialog) break; g_pTreeDialog->OpenDialog(fn); } else if (fn.CheckSuffix("str")) { CDialogDoc tempDoc; tempDoc.LoadGlobalStringTable(m_strPath, pSelItem->GetData()->GetString(TREEVIEW_TEXT)); CStringtableDialog dlg(&tempDoc, true); if (dlg.Open()) { if (GeOutString(GeLoadString(IDS_SAVE_STRINGTABLE), GEMB_YESNO | GEMB_ICONQUESTION) == GEMB_R_YES) { tempDoc.SaveGlobalStringTable(); } } } else if (fn.Content()) { // open the file (it may be an image) GeExecuteFile(fn); } return true; } else if (lType == TREEVIEW_SELCHANGE) { m_dirText = pSelItem->GetData()->GetString(ITEM_PATH_NAME); } break; } }; return GeDialog::Command(lID, msg); }
/*********************************************************************\ Function name : CResEditBrowser::FillList Description : Created at : 25.09.01, @ 22:58:07 Created by : Thomas Kunert Modified by : \*********************************************************************/ void CResEditBrowser::FillList() { SetTitle(GeLoadString(IDS_BROWSER_CAPT) + " - " + m_strPath.GetString()); GeShowMouse(MOUSE_BUSY); m_wndTreeView.LockWindowUpdate(); m_wndTreeView.Reset(); m_pDialogsItem = m_wndTreeView.AddItem(GeLoadString(IDS_BROWSER_DIALOGS)); m_pImagesItem = m_wndTreeView.AddItem(GeLoadString(IDS_BROWSER_IMAGES)); m_pStringTablesItem = m_wndTreeView.AddItem(GeLoadString(IDS_BROWSER_STRIG_TABLES)); BrowsePath(m_strPath); // add global string table(s) CDoubleLinkedList <CStringTableName> stringList; AutoAlloc <BrowseFiles> pBrowse; pBrowse->Init(m_strPath, false); while (pBrowse->GetNext()) { if (!pBrowse->IsDir()) continue; Filename fnNew = pBrowse->GetFilename(); if (fnNew.GetString().SubStr(0, 8).ToLower() == "strings_") { Filename fnStringTable = m_strPath + fnNew; TRACE("Found string table path "); //TRACE_STRING(fnStringTable.GetString()); AutoAlloc <BrowseFiles> pBrowseTable; pBrowseTable->Init(fnStringTable, false); while (pBrowseTable->GetNext()) { Filename fnTable = pBrowseTable->GetFilename(); if (fnTable.CheckSuffix("str")) { TRACE(" "); //TRACE_STRING(fnTable.GetString()); String strNewName = fnTable.GetString(); // check, if we didn't find this table before CStringTableName *pSearch = stringList.First(); Bool bFound = false; while (pSearch) { if (pSearch->strName == strNewName) { bFound = true; break; } pSearch = stringList.Next(pSearch); } if (bFound) continue; CStringTableName *pNewItem = NewObjClear(CStringTableName); pNewItem->strName = strNewName; stringList.Append(pNewItem); } } } } CStringTableName *pInsert = stringList.First(); while (pInsert) { TreeViewItem* pNewItem = m_wndTreeView.AddItem(pInsert->strName, m_pStringTablesItem); pNewItem->GetData()->SetString(ITEM_PATH_NAME, pInsert->strName); pInsert = stringList.Next(pInsert); } stringList.FreeList(); m_wndTreeView.SortChildren(m_pDialogsItem); m_wndTreeView.SortChildren(m_pImagesItem); m_wndTreeView.SortChildren(m_pStringTablesItem); m_wndTreeView.UnlockWindowUpdate(); GeShowMouse(MOUSE_NORMAL); }