/*********************************************************************\ Function name : CLanguageList::Init Description : Created at : 26.09.01, @ 16:11:23 Created by : Thomas Kunert Modified by : \*********************************************************************/ void CLanguageList::Init() { Filename resourcepath = GeGetStartupPath() + Filename("resource"); if (GetC4DVersion() >= 16000) { // R16 has a new resource directory structure. The c4d_language.str // files we are searching for are in resource/modules/c4dplugin/strings_xx. // Fix for https://github.com/nr-plugins/resedit/issues/4 resourcepath = resourcepath + "modules" + "c4dplugin"; } AutoAlloc <BrowseFiles> pBrowse; pBrowse->Init(resourcepath, false); while (pBrowse->GetNext()) { if (pBrowse->IsDir()) { Filename fn = pBrowse->GetFilename(); if (fn.GetString().SubStr(0, 8).ToLower() == "strings_") { String idx = fn.GetString(); idx.Delete(0, 8); Filename stringname = resourcepath + fn+Filename("c4d_language.str"); AutoAlloc <BaseFile> pFile; if (!pFile) return; if (!GeFExist(stringname)) { GeOutString("Missing c4d_language.str to identify the string directory!!!", GEMB_ICONEXCLAMATION); } else if (pFile->Open(stringname)) { Int32 len = pFile->GetLength(); Char *buffer = NewMemClear(Char,len + 2); if (buffer) { pFile->ReadBytes(buffer,len); buffer[len]=0; Int32 i; for (i = 0; i < len && buffer[i] >= ' '; i++) { } buffer[i] = 0; for (i--; i > 0 && buffer[i]== ' '; i--) { } buffer[i + 1] = 0; AddLanguage(buffer, idx); DeleteMem(buffer); } } } } } CriticalAssert(GetNumLanguages() > 0); }
/*********************************************************************\ Function name : CLanguageList::Init Description : Created at : 26.09.01, @ 16:11:23 Created by : Thomas Kunert Modified by : \*********************************************************************/ void CLanguageList::Init() { Filename resourcepath = GeGetStartupPath() + Filename("resource"); AutoAlloc <BrowseFiles> pBrowse; pBrowse->Init(resourcepath, false); while (pBrowse->GetNext()) { if (pBrowse->IsDir()) { Filename fn = pBrowse->GetFilename(); if (fn.GetString().SubStr(0, 8).ToLower() == "strings_") { String idx = fn.GetString(); idx.Delete(0, 8); Filename stringname = resourcepath + fn+Filename("c4d_language.str"); AutoAlloc <BaseFile> pFile; if (!pFile) return; if (!GeFExist(stringname)) { GeOutString("Missing c4d_language.str to identify the string directory!!!", GEMB_ICONEXCLAMATION); } else if (pFile->Open(stringname)) { Int32 len = pFile->GetLength(); Char *buffer = NewMemClear(Char,len + 2); if (buffer) { pFile->ReadBytes(buffer,len); buffer[len]=0; Int32 i; for (i = 0; i < len && buffer[i] >= ' '; i++) { } buffer[i] = 0; for (i--; i > 0 && buffer[i]== ' '; i--) { } buffer[i + 1] = 0; AddLanguage(buffer, idx); DeleteMem(buffer); } } } } } }
void StringReplace::Init(const String &strBuildVersion) { DateTime dt; BaseContainer bc; char ch[100]; GetDateTimeNow(dt); sprintf_safe(ch, sizeof(ch), "%4d%02d%02d", (int)dt.year, (int)dt.month, (int)dt.day); m_strDate = ch; sprintf_safe(ch, sizeof(ch), "%02d%02d%02d", (int)dt.hour, (int)dt.minute, (int)dt.second); m_strTime = ch; m_strDateTime = m_strDate + "_" + m_strTime; Int32 lVersion = GetC4DVersion(); sprintf_safe(ch, sizeof(ch), "%.3f", ((Float32)lVersion) / 1000.0f); m_strCurrentVersion = ch; m_strStartupPath = GeGetStartupPath().GetString(); m_strPluginPath = GeGetPluginPath().GetString(); m_strBuildVersion = strBuildVersion; bc = GetMachineFeatures(); m_strReleaseLine = bc.GetString(1000001); m_strBuildID = bc.GetString(1000002); }
/*********************************************************************\ 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); }
CResEditBrowser::CResEditBrowser() : m_wndTreeView(false) { m_strPath = GeGetStartupPath() + String("resource"); m_dirText = ""; }