void ApplinkDialog::Timer(const BaseContainer &msg)
{
	Bool b;
	GetBool(IDC_CHK_PROMPT, b);
	if(b)
	{
		Filename fn;
		fn.SetDirectory(gPreferences.GetString(IDC_EXCH_FOLDER));
		fn.SetFile("export.txt");
        
		if(GeFExist(fn))
		{
			GePrint("File exists!");
			SetTimer(0);
			if(GeOutString("To import a new object?", GEMB_OKCANCEL) == GEMB_R_OK)
			{
				GePrint("Start import!");
				BaseDocument* doc = GetActiveDocument();
				ApplinkImporter* importer = NewObjClear(ApplinkImporter);
				importer->Execute(doc, &gPreferences);
				SetTimer(1000);
			}
			else
			{
				SetBool(IDC_CHK_PROMPT, false);
			}
		}
	}
}
Example #2
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");

	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);
}
Bool CSVNodeData::UpdateCSVTable(GvNode* node, GvRun* run, GvCalc* calc) {
    BaseDocument* doc = node->GetDocument();
    if (m_initCsv) return TRUE;

    // Obtain data to update the CSV Table. If *all* of those
    // succeeded, the CSV table is updated.
    GvPortCalc pCalc(node, &m_values, run, calc);
    Bool header;
    LONG delimiter;
    Filename filename;

    GvPort* pHeader = pCalc.GetInPort(CSVNODE_HEADER);
    if (pHeader && pHeader->GetBool(&header, run)) ;
    else return TRUE;

    GvPort* pDelimiter = pCalc.GetInPort(CSVNODE_DELIMITER);
    if (pDelimiter && pDelimiter->GetInteger(&delimiter, run)) ;
    else return TRUE;

    Bool ok = FALSE;
    GvPort* pFilename = pCalc.GetInPort(CSVNODE_FILENAME);
    filename = GvGetPortGeData(node, pFilename, run, &ok).GetFilename();
    if (!ok) return TRUE;

    // We now initialize the CSV Table and want to prevent any
    // further initialization in the calculation cycle.
    m_initCsv = TRUE;

    // Validate and set the data to the CSV Table object.
    if (m_pHeader != header) {
        m_forceUpdate = TRUE;
    }
    m_pHeader = header;
    m_table.SetHasHeader(header);

    if (delimiter < 0 || delimiter > 255) {
        delimiter = CSVNODE_DELIMITER_COMMA;
    }
    if (m_pDelimiter != delimiter) {
        m_forceUpdate = TRUE;
    }
    m_pDelimiter = delimiter;
    m_table.SetDelimiter((CHAR) delimiter);

    // Make the CSV Filename relative to the node's document if the file
    // does not exist.
    if (doc && filename.Content() && !GeFExist(filename)) {
        filename = doc->GetDocumentPath() + filename;
    }

    // Update the CSV Table.
    Bool updated = FALSE;
    Bool success = m_table.Init(filename, m_forceUpdate, &updated);
    m_forceUpdate = FALSE;

    return success;
}
Example #4
0
Bool AssertPathExists(const Filename &fn)
{
	if (GeFExist(fn, true))
		return true;

	CFilenameArray pfnDir;
	Filename fnDir = fn;
	Bool bRet = false;
	Int32 a;
	Filename** ppfn;

	while (!GeFExist(fnDir, true))
	{
		Filename* pfn = pfnDir.InsertAt(0);
		if (!pfn)
			goto _error;
		*pfn = fnDir.GetFile();
		fnDir = fnDir.GetDirectory();
		if (!fnDir.Content())
		{
			return false;
		}
	}

	ppfn = pfnDir.GetArray()->GetArray();
	for (a = 0; a < pfnDir.GetElementCount(); a++)
	{
		fnDir += fnDir + *(ppfn[a]);
		if (GeFExist(fnDir, true))
			continue;
		if (!GeFCreateDir(fnDir))
			goto _error;
	}

	bRet = true;
_error:
	return bRet;
}
Example #5
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);
					}
				}
			}
		}
	}
}
Bool ApplinkDialog::InitValues(void)
{
	if (!GeDialog::InitValues()) return false;
    
	filenamePrefs = GeGetPluginPath()+ "preference.ini";
	dirty = false;
	
	AutoAlloc<HyperFile> hyperfilePrefs;
    
	if(!GeFExist(filenamePrefs, false))
	{
		if (!hyperfilePrefs->Open('coat', filenamePrefs.GetString(), FILEOPEN_WRITE, FILEDIALOG_ANY)) return false;
        
		gPreferences.SetString(IDC_TMP_FOLDER, "");
        
        Filename path;
#if defined _WIN32 || defined _WIN64
        path = GeGetC4DPath(C4D_PATH_MYDOCUMENTS);
#elif __APPLE__
        path = GeGetC4DPath(C4D_PATH_HOME);
#endif
		//file magic!
		Filename exFolder = path + "3D-CoatV3" + "Exchange";
		if(GeFExist(exFolder, true))
		{
			gPreferences.SetString(IDC_EXCH_FOLDER, exFolder.GetString());
		}
		else
		{
			exFolder = path + "3D-CoatV4" + "Exchange";
			if (GeFExist(exFolder, true))
			{
				gPreferences.SetString(IDC_EXCH_FOLDER, exFolder.GetString());
			}

			else
			{
				GePrint("Not Find");
#if defined _WIN32 || defined _WIN64
				GePrint(String("Folder ..\\MyDocuments\\3D-CoatV3\\Exchange not found!"));
#elif __APPLE__
				GePrint(String("Folder ../Users/admin/3D-CoatV3/Exchange  not found!"));
#endif
				gPreferences.SetString(IDC_EXCH_FOLDER, "");
			}
		}
        
		gPreferences.SetInt32(IDC_COMBO_MAP_TYPE, 0);
		gPreferences.SetBool(IDC_CHK_EXP_MAT, true);
		gPreferences.SetBool(IDC_CHK_EXP_UV, true);
		gPreferences.SetBool(IDC_CHK_SKIP_IMP_DIALOG, false);
		gPreferences.SetBool(IDC_CHK_SKIP_EXP_DIALOG, false);
        
		gPreferences.SetBool(IDC_CHK_IMP_MAT, true);
		gPreferences.SetInt32(IDC_COMBO_MAP_IMPORT, 0);
		gPreferences.SetBool(IDC_CHK_IMP_UV, true);
		gPreferences.SetBool(IDC_CHK_REPLACE, true);
		gPreferences.SetBool(IDC_CHK_PROMPT, false);
		
		gPreferences.SetString(IDC_COAT_EXE_PATH, "");
		gPreferences.SetBool(IDC_CHK_COAT_START, false);
        
		hyperfilePrefs->WriteContainer(gPreferences);
		hyperfilePrefs->Close();
	}
    
	if(!hyperfilePrefs->Open('coat', filenamePrefs.GetString(), FILEOPEN_READ, FILEDIALOG_ANY)) return false;
    
	hyperfilePrefs->ReadContainer(&gPreferences, true);
	hyperfilePrefs->Close();
    
	SetString(IDC_TMP_FOLDER, gPreferences.GetString(IDC_TMP_FOLDER));
	SetString(IDC_EXCH_FOLDER, gPreferences.GetString(IDC_EXCH_FOLDER));
    
	SetInt32(IDC_COMBO_MAP_TYPE, gPreferences.GetInt32(IDC_COMBO_MAP_TYPE));
	SetBool(IDC_CHK_EXP_MAT, gPreferences.GetBool(IDC_CHK_EXP_MAT));
	SetBool(IDC_CHK_EXP_UV, gPreferences.GetBool(IDC_CHK_EXP_UV));
	SetBool(IDC_CHK_SKIP_IMP_DIALOG, gPreferences.GetBool(IDC_CHK_SKIP_IMP_DIALOG));
	SetBool(IDC_CHK_SKIP_EXP_DIALOG, gPreferences.GetBool(IDC_CHK_SKIP_EXP_DIALOG));
    
	SetBool(IDC_CHK_IMP_MAT, gPreferences.GetBool(IDC_CHK_IMP_MAT));
	SetInt32(IDC_COMBO_MAP_IMPORT, gPreferences.GetInt32(IDC_COMBO_MAP_IMPORT));
	SetBool(IDC_CHK_IMP_UV, gPreferences.GetBool(IDC_CHK_IMP_UV));
	SetBool(IDC_CHK_REPLACE, gPreferences.GetBool(IDC_CHK_REPLACE));
	SetBool(IDC_CHK_PROMPT, gPreferences.GetBool(IDC_CHK_PROMPT));
	
	SetString(IDC_COAT_EXE_PATH, gPreferences.GetString(IDC_COAT_EXE_PATH));
	SetBool(IDC_CHK_COAT_START, gPreferences.GetBool(IDC_CHK_COAT_START));

    
#ifdef __APPLE__
    //------------ temp    
    //Enable(IDC_CHK_COAT_START, false);
    //Enable(IDC_COAT_EXE_PATH, false);    
    //-------------
//    SetString(IDS_STATIC12, "Folder ../Users/user/3D-CoatV3/Exchange  not found!");
#endif
    
	SetTimer(1000);
    
	return true;
}
Example #7
0
void WriteElement(PresetElement* pElement)
{
	CDynamicArray <char> arLine, arTempString;
	AutoAlloc <BaseFile> pFile;
	Filename fn = GeGetC4DPath(C4D_PATH_PREFS) + String("ResEdit");
	if (!pFile)
		return;

	String strNewName;
	Int32 n;
	for (n = 0; n < pElement->strName.GetLength(); n++)
	{
		UInt16 w = (UInt16)pElement->strName[n];
#if defined _WINDOWS
		if (('0' <= w && w <= '9') || ('A' <= w && w <= 'z') || w == ' ' || w == '_' || w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�' ||
				w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�')
#elif defined __MAC
		if (('0' <= w && w <= '9') || ('A' <= w && w <= 'z') || w == ' ' || w == '_' || w == (UInt16)'Š' || w == (UInt16)'š' || w == (UInt16)'Ÿ' ||
				w == (UInt16)'€' || w == (UInt16)'…' || w == (UInt16)'†' || w == (UInt16)'§')
#elif defined __LINUX
		if (('0' <= w && w <= '9') || ('A' <= w && w <= 'z') || w == ' ' || w == '_' || w == (UInt16)'ü' || w == (UInt16)'ö' || w == (UInt16)'ä' ||
				w == (UInt16)'Ü' || w == (UInt16)'Ö' || w == (UInt16)'Ä' || w == (UInt16)'ß')
#else
#error Wrong operating system
#endif
			strNewName += String(1, w);
		else
			strNewName += String(1, '_');
	}

	if (!AssertPathExists(fn))
	{
		GePrint(String("Could not create path ") + fn.GetString());
		return;
	}

	if (GetPresetCrc(pElement) == pElement->ulCRC && (GeFExist(fn + (strNewName + ".prf")) || GeFExist(GeGetC4DPath(C4D_PATH_RESOURCE) + String("distribution") + (strNewName + ".prf"))))
		return;

	fn += (strNewName + ".prf");
	if (!ForceOpenFileWrite(pFile, fn))
	{
		GePrint(String("Could not write file ") + fn.GetString());
		return;
	}

	AppendString(arLine, FILE_HEADER);
	WriteLine(arLine, pFile);

	AppendString(arLine, ORIG_PATH);
	AppendString(arLine, arTempString, pElement->strOrigin);
	WriteLine(arLine, pFile);

	AppendString(arLine, DEST_PATH);
	AppendString(arLine, arTempString, pElement->strDestination);
	WriteLine(arLine, pFile);

	AppendString(arLine, CREATE_ZIP);
	AppendString(arLine, pElement->bCreateZipFile ? "1" : "0");
	WriteLine(arLine, pFile);

	Char *pszZipLevel = String::IntToString(pElement->lCreateZipCompressionLevel).GetCStringCopy();
	if (pszZipLevel)
	{
		AppendString(arLine, CREATE_ZIP_COMPRESSION);
		AppendString(arLine, pszZipLevel);
		WriteLine(arLine, pFile);
		DeleteMem(pszZipLevel);
	}

	AppendString(arLine, CHECK_VERSION);
	AppendString(arLine, pElement->bCheckVersion ? "1" : "0");
	WriteLine(arLine, pFile);

	AppendString(arLine, PARSE_SYMBOLS);
	AppendString(arLine, pElement->bParseSymbols ? "1" : "0");
	WriteLine(arLine, pFile);

	AppendString(arLine, WRITE_BUILD);
	AppendString(arLine, pElement->bWriteBuildInfo ? "1" : "0");
	WriteLine(arLine, pFile);

	AppendString(arLine, BATCH);
	AppendString(arLine, pElement->bBatch ? "1" : "0");
	WriteLine(arLine, pFile);

	AppendString(arLine, REMOVE_SCC);
	AppendString(arLine, pElement->bRemoveSCC ? "1" : "0");
	WriteLine(arLine, pFile);

	AppendString(arLine, PASSWORD);
	AppendString(arLine, arTempString, EncryptPassword(pElement->strPassword));
	WriteLine(arLine, pFile);

	Int32 lFilterCount = pElement->arFilters.GetElementCount();
	FilterElement** ppFilterElements = pElement->arFilters.GetArray()->GetArray();

	for (n = 0; n < lFilterCount; n++)
	{
		AppendString(arLine, FILTER_STRING);
		AppendString(arLine, arTempString, ppFilterElements[n]->str);
		AppendString(arLine, " " FILTER_CONDITION);
		switch (ppFilterElements[n]->lCondition)
		{
		case FILTER_COND_FN_IS: AppendString(arLine, arTempString, W_FILTER_COND_FN_IS); break;
		case FILTER_COND_FN_EXT: AppendString(arLine, arTempString, W_FILTER_COND_FN_EXT); break;
		case FILTER_COND_PATH_CONTAINS: AppendString(arLine, arTempString, W_FILTER_COND_PATH_CONTAINS); break;
		case FILTER_COND_PATH_IS: AppendString(arLine, arTempString, W_FILTER_COND_PATH_IS); break;
		case FILTER_COND_DIRECTORY_IS: AppendString(arLine, arTempString, W_FILTER_COND_DIRECTORY_IS); break;
		default:
			DebugAssert(false);
		}
		AppendString(arLine, " " FILTER_ACTION);
		switch (ppFilterElements[n]->lAction)
		{
		case FILTER_ACTION_INCLUDE: AppendString(arLine, arTempString, W_FILTER_ACTION_INCLUDE); break;
		case FILTER_ACTION_EXCLUDE: AppendString(arLine, arTempString, W_FILTER_ACTION_EXCLUDE); break;
		case FILTER_ACTION_RENAME: AppendString(arLine, arTempString, W_FILTER_ACTION_RENAME); AppendString(arLine, " " FILTER_RENAME); AppendString(arLine, arTempString, ppFilterElements[n]->strRename); break;
		case FILTER_ACTION_COMPILE_INCL: AppendString(arLine, arTempString, W_FILTER_ACTION_COMPILE_INCL); break;
		case FILTER_ACTION_MOVE_TO: AppendString(arLine, arTempString, W_FILTER_ACTION_MOVE_TO); break;
		case FILTER_ACTION_FORCE_COPY: AppendString(arLine, arTempString, W_FILTER_ACTION_FORCE_COPY); break;
		case FILTER_ACTION_COMPILE_INCL_KILL: AppendString(arLine, arTempString, W_FILTER_ACTION_COMPILE_INCL_KILL); break;
		default:
			DebugAssert(false);
		}
		if (ppFilterElements[n]->bSetXBit)
		{
			AppendString(arLine, " " FILTER_FLAG);
			AppendString(arLine, arTempString, W_FILTER_FLAG_SET_XBIT);
		}
		WriteLine(arLine, pFile);
	}

	pFile->Close();
}
Example #8
0
Bool ApplinkDialog::InitValues(void)
{
	if (!GeDialog::InitValues()) return FALSE;

	filenamePrefs = GeGetPluginPath()+ "preference.ini";
	dirty = FALSE;
	
	AutoAlloc<HyperFile> hyperfilePrefs;

	if(!GeFExist(filenamePrefs, FALSE))
	{
		if (!hyperfilePrefs->Open(filenamePrefs.GetString(), GE_WRITE, FILE_NODIALOG)) return FALSE;

		gPreferences.SetString(IDC_TMP_FOLDER, "");

		Filename exFolder = GeGetC4DPath(C4D_PATH_MYDOCUMENTS) + "3D-CoatV3" + "Exchange";
		if(GeFExist(exFolder, TRUE))
		{
			gPreferences.SetString(IDC_EXCH_FOLDER, exFolder.GetString());
		}
		else
		{
			GePrint(String("Folder ..\\MyDocuments\\3D-CoatV3\\Exchange not found!"));
			gPreferences.SetString(IDC_EXCH_FOLDER, "");
		}

		gPreferences.SetLong(IDC_COMBO_MAP_TYPE, 0);
		gPreferences.SetBool(IDC_CHK_EXP_MAT, TRUE);
		gPreferences.SetBool(IDC_CHK_EXP_UV, TRUE);

		gPreferences.SetBool(IDC_CHK_IMP_MAT, TRUE);
		gPreferences.SetLong(IDC_COMBO_MAP_IMPORT, 0);
		gPreferences.SetBool(IDC_CHK_IMP_UV, TRUE);
		gPreferences.SetBool(IDC_CHK_REPLACE, TRUE);
		gPreferences.SetBool(IDC_CHK_PROMPT, FALSE);
		
		gPreferences.SetString(IDC_COAT_EXE_PATH, "");
		gPreferences.SetBool(IDC_CHK_COAT_START, FALSE);

		hyperfilePrefs->WriteContainer(gPreferences);
		hyperfilePrefs->Close();
	}

	if(!hyperfilePrefs->Open(filenamePrefs.GetString(), GE_READ, FILE_NODIALOG)) return FALSE;

	hyperfilePrefs->ReadContainer(&gPreferences, TRUE);
	hyperfilePrefs->Close();

	SetString(IDC_TMP_FOLDER, gPreferences.GetString(IDC_TMP_FOLDER));
	SetString(IDC_EXCH_FOLDER, gPreferences.GetString(IDC_EXCH_FOLDER));

	SetLong(IDC_COMBO_MAP_TYPE, gPreferences.GetLong(IDC_COMBO_MAP_TYPE));
	SetBool(IDC_CHK_EXP_MAT, gPreferences.GetBool(IDC_CHK_EXP_MAT));
	SetBool(IDC_CHK_EXP_UV, gPreferences.GetBool(IDC_CHK_EXP_UV));

	SetBool(IDC_CHK_IMP_MAT, gPreferences.GetBool(IDC_CHK_IMP_MAT));
	SetLong(IDC_COMBO_MAP_IMPORT, gPreferences.GetLong(IDC_COMBO_MAP_IMPORT));
	SetBool(IDC_CHK_IMP_UV, gPreferences.GetBool(IDC_CHK_IMP_UV));
	SetBool(IDC_CHK_REPLACE, gPreferences.GetBool(IDC_CHK_REPLACE));
	SetBool(IDC_CHK_PROMPT, gPreferences.GetBool(IDC_CHK_PROMPT));
	
	SetString(IDC_COAT_EXE_PATH, gPreferences.GetString(IDC_COAT_EXE_PATH));
	SetBool(IDC_CHK_COAT_START, gPreferences.GetBool(IDC_CHK_COAT_START));

	SetTimer(1000);

	return TRUE;
}