Esempio n. 1
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);
}
Esempio n. 2
0
Bool RegisterResEditIcon(Int32 id, Int32 x, Int32 y)
{
	CriticalAssert(g_pControlImages);
	x *= CONTROLIMAGE_SIZE;
	y *= CONTROLIMAGE_SIZE;
	return RegisterIcon(
		id, g_pControlImages, x, y, CONTROLIMAGE_SIZE, CONTROLIMAGE_SIZE);
}
Esempio n. 3
0
 /// Called to hide/unhide the container object contents.
 void HideNodes(BaseObject* op, BaseDocument* doc, Bool hide)
 {
   if (hide)
   {
     BaseContainer* bc = op->GetDataInstance();
     CriticalAssert(bc != nullptr);
     HideHierarchy(op->GetDown(), true, doc);
     if (bc->GetBool(NRCONTAINER_HIDE_TAGS))
       HideHierarchy(op->GetFirstTag(), true, doc);
     if (bc->GetBool(NRCONTAINER_HIDE_MATERIALS))
       HideMaterials(op, true, doc);
   }
   else
   {
     HideHierarchy(op->GetDown(), false, doc);
     HideHierarchy(op->GetFirstTag(), false, doc);
     HideMaterials(op, false, doc);
   }
 }
Esempio n. 4
0
/// ***************************************************************************
/// This function recursive hides or unhides a node and all its following
/// nodes in the same hierarchy level and below object manager and timeline.
/// Only direct children are hidden or revealed, no other branches.
/// @param[in] root The node to start with.
/// @param[in] hide \c true if the hierarchy should be hidden, \c false
///     if it should be revealed by this function.
/// @param[in] doc The BaseDocument to add undos to, if desired. Pass
///     \c nullptr if no undos should be created.
/// @param[in] sameLevel If \c true (default), all objects following *root*
///     in the hierarchy will also be processed by this function.
/// ***************************************************************************
static void HideHierarchy(BaseList2D* root, Bool hide, BaseDocument* doc, Bool sameLevel=true)
{
  while (root)
  {
    if (doc)
      doc->AddUndo(UNDOTYPE_BITS, root);
    const NBITCONTROL control = (hide ? NBITCONTROL_SET : NBITCONTROL_CLEAR);
    root->ChangeNBit(NBIT_OHIDE, control);
    root->ChangeNBit(NBIT_TL1_HIDE, control);
    root->ChangeNBit(NBIT_TL2_HIDE, control);
    root->ChangeNBit(NBIT_TL3_HIDE, control);
    root->ChangeNBit(NBIT_TL4_HIDE, control);
    root->ChangeNBit(NBIT_THIDE, control);
    root->DelBit(BIT_ACTIVE);

    Bool hideChildren = true;
    if (root->IsInstanceOf(Obase))
    {
      BaseObject* op = static_cast<BaseObject*>(root);
      BaseContainer* bc = op->GetDataInstance();
      CriticalAssert(bc);

      if (bc->GetString(CONTAINEROBJECT_PROTECTIONHASH).Content())
        // Don't modify the hierarchy of "protected" Null-Objects.
        hideChildren = false;
      else if (ContainerIsProtected(op))
        // Don't modify the hierarchy of protected Containers.
        hideChildren = false;
    }

    if (hideChildren)
      HideHierarchy(static_cast<BaseList2D*>(root->GetDown()), hide, doc);

    if (!sameLevel) break;
    root = root->GetNext();
  }
}