On 21/03/2016 at 13:00, xxxxxxxx wrote:
Here's the test code I'm using so far.
I'd expect, that MY_STRING would be animatable, but it isn't.
I assume that is because the NodeData has not been inserted into the document.
The DescriptionGui has to set its parameter OBJECTSNOTINDOC to display the Node Descriptions. This is what I meant with "document context".
Any explanation would be very welcome!
Thanks again. :)
main.h/main.cpp
#ifndef MAIN_H__
#define MAIN_H__
Bool RegisterMyCommandPlugin();
Bool RegisterMyNodeDataPlugin();
#endif // MAIN_H__
#####################
#include "c4d.h"
#include "main.h"
#define NPID 1000007
Bool PluginStart(void)
{
if (!RegisterMyCommandPlugin())
return false;
if (!RegisterMyNodeDataPlugin())
return false;
return true;
}
void PluginEnd(void)
{
}
Bool PluginMessage(Int32 id, void* data)
{
if (id == C4DPL_INIT_SYS)
{
resource.Init();
RegisterDescription(NPID, "my_type_a", resource.Get());
return false;
}
return false;
}
CommandData.cpp:
#include "c4d.h"
#include "mydialog.h"
#define PID 1000006
class MyCommandData : public CommandData
{
public:
virtual Bool Execute(BaseDocument* doc) override;
virtual Bool RestoreLayout(void* secret) override;
private:
MyDialog mainDialog;
BaseContainer* settings;
};
Bool MyCommandData::Execute(BaseDocument* doc)
{
return mainDialog.Open(DLG_TYPE_ASYNC, PID, -1, -1, 400, 200);
}
Bool MyCommandData::RestoreLayout(void* secret)
{
return mainDialog.RestoreLayout(PID, 0, secret);
}
Bool RegisterMyCommandPlugin()
{
return RegisterCommandPlugin(PID, "My Plugin", 0, 0, NULL, NewObjClear(MyCommandData));
}
MyDialog.h/MyDialog.cpp
#ifndef MYDIALOG_H
#define MYDIALOG_H
#include "c4d.h"
class MyDialog : public GeDialog
{
public:
virtual Bool CreateLayout(void) override;
};
#endif
#####################
#include "mydialog.h"
#include "c4d_symbols.h"
#define NPID 1000007
Bool MyDialog::CreateLayout(void)
{
Bool res = GeDialog::CreateLayout();
res = LoadDialogResource(DLG_MYDIALOG, nullptr, 0);
BaseList2D* node = BaseList2D::Alloc(NPID);
BaseList2D* op = static_cast<BaseList2D*>(node);
BaseContainer* bc = op->GetDataInstance();
bc->SetInt32('type', MY_TYPE_A);
DescriptionCustomGui* descGui = static_cast<DescriptionCustomGui*>(FindCustomGui(IDC_DESCGUI, CUSTOMGUI_DESCRIPTION));
descGui->SetObject(node);
return res;
}
Dialog resource:
// C4D-DialogResource
DIALOGSTRINGS DLG_MYDIALOG
{
IDS_DIALOG "Dialog";
}
MyNodeData.cpp:
#include "c4d.h"
#include "c4d_symbols.h"
#define NPID 1000007
class MyNodeData : public NodeData
{
public:
static NodeData* Alloc() {
return NewObjClear(MyNodeData);
}
virtual Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags) override;
};
Bool MyNodeData::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)
{
BaseList2D* op = static_cast<BaseList2D*>(node);
BaseContainer* bc = op->GetDataInstance();
Int32 type = bc->GetInt32('type');
switch (type) {
case MY_TYPE_A:
if (description->LoadDescription(type))
flags |= DESCFLAGS_DESC_LOADED;
break;
}
return NodeData::GetDDescription(node, description, flags);
}
Bool RegisterMyNodeDataPlugin()
{
return RegisterNodePlugin(NPID, "My NodeData", PLUGINFLAG_HIDE, MyNodeData::Alloc, NULL, 0, NULL);
}
c4d_symbols.h
enum
{
_FIRST_ELEMENT_ = 10000,
// Dialog definitions of DLG_MYDIALOG start here
DLG_MYDIALOG,
IDC_DESCGUI,
// Dialog definitions of DLG_MYDIALOG end here
MY_TYPE_A = 100009,
MY_STRING = 10008,
MY_LABEL,
// End of symbol definition
_DUMMY_ELEMENT_
};
Description resource my_type_a.h / my_type_a.res:
#ifndef MY_TYPE_A_H
#define MY_TYPE_A_H
enum
{
MY_STRING = 10010,
MY_LABEL,
};
#endif
########################
CONTAINER my_type_a
{
NAME my_type_a;
GROUP
{
COLUMNS 2;
STATICTEXT MY_LABEL { NAME STR_MY_LABEL; }
STRING MY_STRING { ANIM ON; }
}
}
String resource MY_TYPE_A:
STRINGTABLE my_type_a
{
my_type_a "My Type A";
STR_MY_LABEL "My Test Label";
}
Dialog resource:
// C4D-DialogResource
DIALOG DLG_MYDIALOG
{
NAME IDS_DIALOG; SCALE_V; SCALE_H;
DESCRIPTION IDC_DESCGUI
{
SCALE_V; SCALE_H;
OBJECTSNOTINDOC;
}
}
String resource DLG_MYDIALOG:
// C4D-DialogResource
DIALOGSTRINGS DLG_MYDIALOG
{
IDS_DIALOG "Dialog";
}