[SOLVED] Dynamic Dropdown List

On 09/07/2018 at 21:02, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R18 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hi all,

I want to have a drop down list that I can change on the fly with user data. The list is a list of image extensions and I would like to allow users to put in there own custom extensions and then add this to this list.

The user clicks on custom, enters a custom extension and this is saved to a user configuration file (I have everything up to this point working fine). Where I'm stuck is how I can populate this list with the saved data so that the user can see their custom extensions each time they open a file.

You can see the code if that makes anything clearer on my GitHub page for the project, the files of interest here are SMDLoader.cpp/.h and fsmdloader.res

https://github.com/xNWP/Cinema-4D-Source-Tools

Thank you in advanced to anyone who can help point me in the right direction !!

On 09/07/2018 at 22:33, xxxxxxxx wrote:

Here's what I did to fill a dropdown box with filenames and a custom entry

Bool DisplayMode::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)  
{  
  if (!description->LoadDescription(DISPLAYMODE_DESC_PLUGIN_ID))  
      return false;  
  
    // === CHECKER ===   
  
  // fill the dropdown with all available checker types  
  const DescID *singleid = description->GetSingleDescID();  
  DescID cid = DescLevel(CHECKER_TYPE, DTYPE_LONG, 0);  
  if (!singleid || cid.IsPartOf(*singleid, nullptr)) // important to check for speedup c4d!  
  {  
      SortedStringArray checkerFilenames;  
      // read the available checker bitmap filenames
        {  
          ...   
      }  
  
      // add a fixed "Custom Checker" entry in the list,  
      // separated from the file entries  
      // (leave out separator when no file entries)  
      BaseContainer listBC;  
      listBC.SetString(CUSTOM_CHECKER_ID, "Custom Checker");  
      if (checkerFilenames.GetCount() > 0)  
          listBC.SetString(-1, ""); // separator  
  
      for (SortedStringArray::ConstIterator it = checkerFilenames.Begin(); it != checkerFilenames.End(); ++it)  
          listBC.SetString(Int32(it - checkerFilenames.Begin()), *it);  
        
      // add the items to the dropdown gadget  
      BaseContainer comboBC = GetCustomDataTypeDefault(DTYPE_LONG);  
        // re-use the original label from the description  
      {  
          BaseContainer* bc = description->GetParameterI(cid, nullptr);  
          comboBC.SetString(DESC_SHORT_NAME, bc->GetString(DESC_SHORT_NAME));  
      }  
      comboBC.SetInt32(DESC_ANIMATE, DESC_ANIMATE_OFF);  
      comboBC.SetContainer(DESC_CYCLE, listBC);  
  
        // store the data into the description  
      if (!description->SetParameter(cid, comboBC, DescLevel(0)))  
          return FALSE;  
  

On 10/07/2018 at 01:32, xxxxxxxx wrote:

Hello,

as C4DS showed, you can edit the parameter description of a NodeData based element by implementing GetDDescription(). There are multiple manuals and example available:

An example of editing a drop down list is found in sculptdeformer.cpp.

best wishes,
Sebastian

On 10/07/2018 at 15:52, xxxxxxxx wrote:

Thank-You both!

This has absolutely done the trick and is working flawlessly :-)