On 23/01/2015 at 07:02, xxxxxxxx wrote:
That wasn't it. The obvious solution was to make a CustomDataTypeClass plugin that exposes the
same custom properties. The settings will be merged in the same BaseContainer that is passed to the
iCustomGui.
I have only one problem left, unfortunately. I want one of the custom properties to be a String.
static CustomProperty BannerGuiProperties[] = {
{ CUSTOMTYPE_LONG, BANNERGUI_ICONID, "ICON_ID" },
{ CUSTOMTYPE_LONG, BANNERGUI_BGCOLOR_ID, "BGCOLOR_ID" },
{ CUSTOMTYPE_VECTOR, BANNERGUI_BGCOLOR_VECTOR, "BGCOLOR_VECTOR" },
{ CUSTOMTYPE_FLAG, BANNERGUI_TRANSPARENT, "TRANSPARENT" },
**{ CUSTOMTYPE_STRING, BANNERGUI_HALIGN, "ALIGN_H" },**
{ CUSTOMTYPE_LONG, BANNERGUI_WIDTH, "WIDTH" },
{ CUSTOMTYPE_LONG, BANNERGUI_HEIGHT, "HEIGHT" },
{ CUSTOMTYPE_FLAG, BANNERGUI_LOCKSCALE, "LOCKSCALE" },
{ CUSTOMTYPE_END, 0, "" },
};
But when the property is specified in the Description resource, the entry in the settings container I
get in the iCustomGui is empty (DA_NIL). If the property is left out, I get the default value that I
initialized in CustomDataTypeClass::GetDefaultProperties() (which is fine).
GROUP {
BANNER TEST { ICON_ID 5159; WIDTH 16; ALIGN_H "center"; LOCKSCALE; TRANSPARENT; }
}
class BannerGuiDataType : public CustomDataTypeClass {
typedef CustomDataTypeClass super;
public:
// CustomDataTypeClass
virtual Int32 GetId() override
{
return CUSTOMDATATYPE_BANNER;
}
virtual CustomDataType* AllocData() override
{
return NewObjClear(CustomDataType);
}
virtual void FreeData(CustomDataType* data) override
{
DeleteObj(data);
}
virtual Bool CopyData(
const CustomDataType* src, CustomDataType* dest, AliasTrans* at)
override
{
return true;
}
virtual Int32 Compare(const CustomDataType* d1, const CustomDataType* d2)
override
{
return -1;
}
virtual Bool WriteData(const CustomDataType* data, HyperFile* hf) override
{
return true;
}
virtual Bool ReadData(CustomDataType* data, HyperFile* hf, Int32 level)
override
{
return true;
}
virtual const Char* GetResourceSym() override
{
return "BANNER";
}
virtual CustomProperty* GetProperties() override
{
return ::BannerGuiProperties;
}
virtual void GetDefaultProperties(BaseContainer& data) override
{
data.SetInt32(BANNERGUI_ICONID, 0);
data.SetInt32(BANNERGUI_BGCOLOR_ID, -1);
data.SetVector(BANNERGUI_BGCOLOR_VECTOR, Vector(0, 0, 0));
data.SetBool(BANNERGUI_TRANSPARENT, false);
data.SetString(BANNERGUI_HALIGN, "LEFT");
data.SetInt32(BANNERGUI_WIDTH, -1);
data.SetInt32(BANNERGUI_HEIGHT, -1);
data.SetBool(BANNERGUI_LOCKSCALE, false);
data.SetInt32(DESC_ANIMATE, DESC_ANIMATE_OFF);
data.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BANNER);
}
};
// -------------------------------------------------------------------------
BannerGui::BannerGui(
const BaseContainer& bc, CUSTOMGUIPLUGIN* plugin)
: super(bc, plugin), iconData(), ownsBitmap(false)
{
this->ua = NewObjClear(BannerGuiUserArea, this);
this->iconId = bc.GetInt32(BANNERGUI_ICONID, 0);
this->transparent = bc.GetBool(BANNERGUI_TRANSPARENT);
if (bc.GetInt32(BANNERGUI_BGCOLOR_ID, -1) < 0) {
this->bgColor = bc.GetVector(BANNERGUI_BGCOLOR_VECTOR);
}
else {
this->bgColor = bc.GetInt32(BANNERGUI_BGCOLOR_ID);
}
const String alignMode = bc.GetString(BANNERGUI_HALIGN).ToLower();
if (alignMode == "right") {
this->alignH = BANNERGUI_HALIGN_RIGHT;
}
else if (alignMode == "center") {
this->alignH = BANNERGUI_HALIGN_CENTER;
}
else if (alignMode == "left" || true) {
this->alignH = BANNERGUI_HALIGN_LEFT;
}
this->width = bc.GetInt32(BANNERGUI_WIDTH, -1);
this->height = bc.GetInt32(BANNERGUI_HEIGHT, -1);
this->lockScale = bc.GetBool(BANNERGUI_LOCKSCALE, false);
GePrint("HALIGN Dtype: " + String::IntToString(bc.GetType(BANNERGUI_HALIGN)));
GePrint("Icon ID: " + String::IntToString(this->iconId));
GePrint("alignMode: " + alignMode);
GePrint("Width: " + String::IntToString(this->width));
GePrint("Height: " + String::IntToString(this->height));
GePrint("LockScale: " + String::IntToString(this->lockScale));
}
An idea where the problem could be? Thanks!
Niklas