Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Custom Preferences in R13

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 264 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 06/05/2012 at 16:03, xxxxxxxx wrote:

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

      ---------
      Hey guys,

      I'm having some trouble with creating custom preferences.
      I'm using the example code that's in the docs to learn from. But I don't see anywhere in that example where it actually does anything.
      As a practice example. I tried to make the timeline's highlight option turn on/off with my custom entry. But it doesn't work.
      No errors..It just simply doesn't do anything.

      Here's the .cpp code:

      #include "c4d.h"  
      #include "c4d_symbols.h"    
      #include "lib_prefs.h"  
      #include "prefsmyprefs.h"   
      #include "..\..\..\..\modules\newman\res\description\prefstimeline.h"  
          
      #define PLUGIN_ID 1025669               //A plugin id gotten from plugincafe.com    
      #define MY_PREFS_DIALOG_ID 1026251      //A custom user container id gotten from plugincafe.com   
          
      class MyPrefs : public PrefsDialogObject  
      {  
        INSTANCEOF(MyPrefs, PrefsDialogObject)  
          
        public:  
          virtual Bool InitValues(const DescID &id, Description* desc = NULL);  
          
          virtual Bool Init(GeListNode* node);  
          virtual Bool GetDParameter(GeListNode *node, const DescID &id, GeData &t_data, DESCFLAGS_GET &flags);  
          virtual Bool SetDParameter(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags);  
          virtual Bool GetDEnabling(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc);  
          virtual Bool GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC &flags);  
          
          BaseContainer *GetMyPrefs();  
          
          static NodeData *Alloc() { return gNew MyPrefs; }  
      };  
          
      Bool MyPrefs::InitValues(const DescID &id, Description *desc)  
      {  
        BaseContainer* bc = GetMyPrefs();  
        if (!bc) return FALSE;  
          
        switch (id[0].id)  
        {  
          case PREF_MYPREFS_BOOL1: InitPrefsValue(PREF_MYPREFS_BOOL1,GeData(TRUE),desc,id,bc); return TRUE;  
        }  
          
        return TRUE;  
      }  
          
      Bool MyPrefs::Init(GeListNode* node)  
      {  
        InitValues(PREF_MYPREFS_BOOL1);  
          
        return TRUE;  
      }  
          
      Bool MyPrefs::GetDParameter(GeListNode *node, const DescID &id, GeData &t_data, DESCFLAGS_GET &flags)  
      {  
        BaseContainer* bc = GetMyPrefs();  
        if (!bc) SUPER::GetDParameter(node,id,t_data,flags);  
          
        switch (id[0].id)  
        {  
          case PREF_MYPREFS_BOOL1: t_data = bc->GetBool(PREF_TL_HIGHLIGHT,TRUE); flags |= DESCFLAGS_GET_PARAM_GET; return TRUE;  //<----Is this Wrong???  
        }  
          
        return SUPER::GetDParameter(node,id,t_data,flags);  
      }  
          
      Bool MyPrefs::SetDParameter(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags)  
      {  
        BaseContainer* bc = GetMyPrefs();  
        if (!bc) SUPER::SetDParameter(node,id,t_data,flags);  
          
        switch (id[0].id)  
        {  
          case PREF_MYPREFS_BOOL1: bc->SetBool(PREF_TL_HIGHLIGHT,t_data.GetLong()); flags |= DESCFLAGS_SET_PARAM_SET; GeUpdateUI();  return TRUE; //<----Is this Wrong???  
        }  
          
        return SUPER::SetDParameter(node,id,t_data,flags);  
      }  
          
      Bool MyPrefs::GetDEnabling(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc)  
      {  
        BaseContainer* bc = GetMyPrefs();  
        if (!bc) SUPER::GetDEnabling(node,id,t_data,flags,itemdesc);  
        return SUPER::GetDEnabling(node,id,t_data,flags,itemdesc);  
      }  
          
      Bool MyPrefs::GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC &flags)  
      {  
        if (!description->LoadDescription("Prefsmyprefs")) return FALSE;  
          
        if ( flags & DESCFLAGS_DESC_NEEDDEFAULTVALUE )  
        {  
          InitValues(PREF_MYPREFS_BOOL1,description);  
        }  
          
        flags |= DESCFLAGS_DESC_LOADED;  
        return SUPER::GetDDescription(node, description, flags);  
      }  
          
      BaseContainer* MyPrefs::GetMyPrefs()  
      {  
        BaseContainer* bc = GetWorldContainerInstance()->GetContainerInstance(MY_PREFS_DIALOG_ID);  
        if (!bc)  
        {  
          GetWorldContainerInstance()->SetContainer(MY_PREFS_DIALOG_ID, BaseContainer());  
          bc = GetWorldContainerInstance()->GetContainerInstance(MY_PREFS_DIALOG_ID);  
          if (!bc) return NULL;  
        }  
          
        return bc;  
      }  
          
          
      Bool RegisterMyPrefs()  
      {  
        PrefsDialogObject::Register(PLUGIN_ID, MyPrefs::Alloc, GeLoadString(IDS_MYPREFS), "Prefsmyprefs", 0, PREFS_PRI_MODULES);  
        return TRUE;  
      }
      

      AFAICT. This type of plugin uses descriptions to do it's work. And I'm guessing that the methods GetDParameter() & SetDParameter() are the heavy lifters that actually do the work to execute things that are enabled in the preferences?

      Can anyone tell me what I'm doing wrong?

      -ScottA

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 07/05/2012 at 01:22, xxxxxxxx wrote:

        Hi,

        Could you send your plugin's source code at sdk_support[at]maxon.net?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 07/05/2012 at 07:51, xxxxxxxx wrote:

          I managed to figure out how it works late last night Yannick.
          To execute something with the prefs. example in the docs. The code to do something has to go in the SetDParameter() method where "flags |= DESCFLAGS_SET_PARAM_SET" is located.

          -ScottA

          1 Reply Last reply Reply Quote 0
          • First post
            Last post