Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

[SOLVED] Dynamic Dropdown List

Author
Message
  Topic Search Topic Search
xNWP View Drop Down
Member
Member
Avatar

Joined: 2017 Jul 20
Location: Canada
Online Status: Offline
Posts: 10
Direct Link To This Post Topic: [SOLVED] Dynamic Dropdown List
    Posted: 2018 Jul 09 at 9:02pm

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


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


Edited by xNWP - 2018 Jul 10 at 4:14pm

--
Part of the Half-Life Advanced Effects Team (https://www.advancedfx.org/)
I make stuff for Source-Engine moviemaking :-)
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 235
Direct Link To This Post Posted: 2018 Jul 09 at 10:33pm
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;


Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1379
Direct Link To This Post Posted: 2018 Jul 10 at 1:32am
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
SDK Support Engineer
Back to Top
xNWP View Drop Down
Member
Member
Avatar

Joined: 2017 Jul 20
Location: Canada
Online Status: Offline
Posts: 10
Direct Link To This Post Posted: 2018 Jul 10 at 3:52pm
Thank-You both!

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

--
Part of the Half-Life Advanced Effects Team (https://www.advancedfx.org/)
I make stuff for Source-Engine moviemaking :-)
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.109 seconds.