Ejemplo n.º 1
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('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;
}
Ejemplo n.º 2
0
  /// Called from Message() for MSG_DESCRIPTION_COMMAND.
  void OnDescriptionCommand(BaseObject* op, DescriptionCommand* cmdData)
  {
    BaseDocument* doc = op->GetDocument();
    const AutoUndo au(doc);
    const LONG id = cmdData->id[0].id;

    switch (id)
    {
      case NRCONTAINER_PACKUP:
        ToggleProtect(op);
        break;
      case NRCONTAINER_ICON_LOAD:
      {
        if (m_protected) break;

        // Ask the user for an image-file.
        Filename flname;
        flname.SetDirectory(GeGetC4DPath(C4D_PATH_DESKTOP));
        Bool ok = flname.FileSelect(FILESELECTTYPE_IMAGES, FILESELECT_LOAD,
            GeLoadString(IDS_SELECTICON));

        if (ok)
        {
          // Ensure the destination bitmap is allocated.
          if (!m_customIcon)
            m_customIcon = BaseBitmap::Alloc();
          else
            m_customIcon->FlushAll();

          // If it is still null here, allocation failed.
          if (!m_customIcon)
            MessageDialog(GeLoadString(IDS_INFO_OUTOFMEMORY));
          else
          {
            IMAGERESULT res = m_customIcon->Init(flname);
            if (res != IMAGERESULT_OK)
            {
              MessageDialog(IDS_INFO_INVALIDIMAGE);
              BaseBitmap::Free(m_customIcon);
            }
            else
            {
              // Scale the bitmap down to 64x64 pixels.
              BaseBitmap* dest = BaseBitmap::Alloc();
              const LONG size = CONTAINEROBJECT_ICONSIZE;
              dest->Init(size, size);
              m_customIcon->ScaleIt(dest, 256, true, true);
              BaseBitmap::Free(m_customIcon);
              m_customIcon = dest;
            }
          }
        }
        break;
      }
      case NRCONTAINER_ICON_CLEAR:
      {
        if (m_protected) break;
        if (m_customIcon)
        {
          // TODO: We possibly require a flag for removing the icon
          // on the next MSG_GETCUSTOMICON message, because Cinema
          // still references this bitmap.
          BaseBitmap::Free(m_customIcon);
        }
        break;
      }
    }
  }
Ejemplo n.º 3
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();
}
Ejemplo n.º 4
0
void ReadDistriPrefs()
{
	ReadDistriPrefs(GeGetC4DPath(C4D_PATH_PREFS) + String("ResEdit"));
	ReadDistriPrefs(GeGetC4DPath(C4D_PATH_RESOURCE) + String("distribution"));
}
Ejemplo n.º 5
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;
}