THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/09/2010 at 03:32, xxxxxxxx wrote:
Basically all that is needed now for plugin preference hooks is your own overloaded PrefsDialogObject class. As you may have noticed preferences are description based in R12 and derived from NodeData.
Here an example from our timeline prefs which should get you started. There are still some things unclear to myself but currently the developer responsible for the prefs overhaul is on vacation. I will keep you posted.
class TimelinePrefsObject : public PrefsDialogObject
{
INSTANCEOF(TimelinePrefsObject,PrefsDialogObject)
public:
static NodeData *Alloc() { return gNew TimelinePrefsObject; }
virtual Bool GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC &flags);
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 Init(GeListNode* node);
virtual Bool InitValues(const DescID &id, Description* desc = NULL);
private:
BaseContainer* GetTLPrefs();
};
// My own function to get the TL containmer from the world prefs
BaseContainer* TimelinePrefsObject::GetTLPrefs()
{
BaseContainer* bc=GetWorldContainerInstance()->GetContainerInstance(PREFSDIALOG_ID);
if (!bc)
{
GetWorldContainerInstance()->SetContainer(PREFSDIALOG_ID,BaseContainer());
bc = GetWorldContainerInstance()->GetContainerInstance(PREFSDIALOG_ID);
if (!bc) return NULL;
}
return bc;
}
// Return the Parameter --> make sure to always set the flag
Bool TimelinePrefsObject::GetDParameter(GeListNode *node, const DescID &id,GeData &t_data,DESCFLAGS_GET &flags)
{
BaseContainer* bc = GetTLPrefs();
if (!bc) SUPER::GetDParameter(node,id,t_data,flags);
switch (id[0].id)
{
case PREF_TL_HIGHLIGHT:
t_data = bc->GetBool(WPREFS_HIGHLIGHT,TRUE);
flags |= DESCFLAGS_GET_PARAM_GET;
return TRUE;
// ...
}
return SUPER::GetDParameter(node,id,t_data,flags);
}
// Enable and disable the parameters
Bool TimelinePrefsObject::GetDEnabling(GeListNode *node, const DescID &id,const GeData &t_data,DESCFLAGS_ENABLE flags,const BaseContainer *itemdesc)
{
BaseContainer* bc = GetTLPrefs();
if (!bc) SUPER::GetDEnabling(node,id,t_data,flags,itemdesc);
return SUPER::GetDEnabling(node,id,t_data,flags,itemdesc);
}
// Set the parameters -> make sure to always set the flag and call GeUpdateUI()
Bool TimelinePrefsObject::SetDParameter(GeListNode *node, const DescID &id,const GeData &t_data,DESCFLAGS_SET &flags)
{
BaseContainer* bc = GetTLPrefs();
if (!bc) SUPER::SetDParameter(node,id,t_data,flags);
switch (id[0].id)
{
case PREF_TL_HIGHLIGHT:
bc->SetBool(WPREFS_HIGHLIGHT,t_data.GetLong());
flags |= DESCFLAGS_SET_PARAM_SET;
GeUpdateUI();
return TRUE;
}
return SUPER::SetDParameter(node,id,t_data,flags);
}
// Init the values
Bool TimelinePrefsObject::Init(GeListNode* node)
{
BaseContainer* bc = GetTLPrefs();
if (!bc) return FALSE;
InitPrefsValue(WPREFS_HIGHLIGHT,GeData(TRUE),desc,id,bc);
// do this for all values
return TRUE;
}
// Set the description and if the flag DESCFLAGS_DESC_NEEDDEFAULTVALUE was set the user called reset to Parameter
Bool TimelinePrefsObject::GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC &flags)
{
if (!description->LoadDescription("Prefstimeline")) return FALSE;
if ( flags & DESCFLAGS_DESC_NEEDDEFAULTVALUE )
{
InitPrefsValue(WPREFS_HIGHLIGHT,GeData(TRUE),desc,id,bc);
// do this for all values
}
flags |= DESCFLAGS_DESC_LOADED;
return SUPER::GetDDescription(node, description, flags);
}
// Register
Bool RegisterPrefs()
{
PrefsDialogObject::Register(PREFS_TL,TimelinePrefsObject::Alloc,GeLoadString(IDS_TL_TITLEPREFS),"Prefstimeline",0,PREFS_PRI_MODULES);
return TRUE;
}
cheers,
Matthias