Changed how properties work

This commit is contained in:
andreja6
2018-10-23 06:49:41 -07:00
parent 18b856602c
commit ee528d1245
11 changed files with 26 additions and 34 deletions

View File

@@ -11,7 +11,6 @@ ButtonListener* listener = NULL;
BaseButtonInstance::BaseButtonInstance(void)
{
listener = NULL;
initProperties();
}
void BaseButtonInstance::render(RenderDevice* rd)

View File

@@ -14,7 +14,6 @@ DataModelInstance::DataModelInstance(void)
mousey = 0;
mouseButton1Down = false;
showMessage = false;
initProperties();
}
DataModelInstance::~DataModelInstance(void)

View File

@@ -21,7 +21,6 @@ ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureR
floatRight = false;
disabled = false;
className = "ImageButton";
initProperties();
}
ImageButtonInstance::~ImageButtonInstance(void)

View File

@@ -15,7 +15,6 @@ Instance::Instance(const Instance &oinst)
setParent(oinst.parent);
name = oinst.name;
className = oinst.className;
initProperties();
}
void Instance::render(RenderDevice* rd)
@@ -26,22 +25,24 @@ void Instance::render(RenderDevice* rd)
}
}
void Update(PROPGRIDITEM)
void Instance::PropUpdate(DWORD addr, PROPGRIDITEM pItem)
{
}
void Instance::initProperties()
std::vector<Property> Instance::getProperties()
{
PROPGRIDITEM * pItem = new PROPGRIDITEM();
PropGrid_ItemInit((*pItem));
pItem->lpszCatalog="Properties";
pItem->lpszPropName="Name";
pItem->lpszPropDesc="The name of the current instance";
pItem->lpCurValue=(LPARAM)name.c_str();
pItem->iItemType=PIT_EDIT;
std::vector<Property> properties;
PROPGRIDITEM pItem;
PropGrid_ItemInit(pItem);
pItem.lpszCatalog="Properties";
pItem.lpszPropName="Name";
pItem.lpszPropDesc="The name of the current instance";
pItem.lpCurValue=(LPARAM)name.c_str();
pItem.iItemType=PIT_EDIT;
properties.push_back(new Property(pItem, Update));
properties.push_back(Property(pItem, (DWORD)&name));
return properties;
}

View File

@@ -5,7 +5,6 @@
class Instance
{
public:
std::vector<Property *> properties;
Instance(void);
Instance(const Instance&);
virtual ~Instance(void);
@@ -21,8 +20,10 @@ public:
void removeChild(Instance*);
Instance* getParent();
virtual Instance* clone() const { return new Instance(*this); }
virtual std::vector<Property> getProperties();
virtual void PropUpdate(DWORD addr, PROPGRIDITEM pItem);
protected:
std::string className;
Instance* parent; // Another pointer.
void initProperties();
};

View File

@@ -19,7 +19,6 @@ PhysicalInstance::PhysicalInstance(void)
back = Smooth;
left = Smooth;
bottom = Smooth;
initProperties();
}
PhysicalInstance::PhysicalInstance(const PhysicalInstance &oinst)

View File

@@ -1,20 +1,15 @@
#include "Property.h"
Property::Property(PROPGRIDITEM * item, void(*onPropUpdate)(PROPGRIDITEM))
Property::Property(PROPGRIDITEM item, DWORD addr)
{
this->callbackFuncOnChange = onPropUpdate;
this->addr = addr;
this->item = item;
}
Property::~Property(void)
{
delete item;
}
void Property::updateProperty(PROPGRIDITEM item)
{
callbackFuncOnChange(item);
}

View File

@@ -4,9 +4,8 @@
class Property
{
public:
void(*callbackFuncOnChange)(PROPGRIDITEM);
PROPGRIDITEM * item;
Property(PROPGRIDITEM * item, void(*onPropUpdate)(PROPGRIDITEM));
PROPGRIDITEM item;
DWORD addr;
Property(PROPGRIDITEM item, DWORD addr);
~Property(void);
void updateProperty(PROPGRIDITEM);
};

View File

@@ -112,11 +112,13 @@ void PropertyWindow::_redraw()
void PropertyWindow::SetProperties(Instance * instance)
{
PropGrid_ResetContent(_propGrid);
for(size_t i = 0; i < instance->properties.size(); i++)
std::vector<Property> prop = instance->getProperties();
for(size_t i = 0; i < prop.size(); i++)
{
::PROPGRIDITEM * item = instance->properties.at(i)->item;
PropGrid_AddItem(_propGrid, item);
::PROPGRIDITEM item = prop.at(i).item;
PropGrid_AddItem(_propGrid, &item);
}
PropGrid_ExpandAllCatalogs(_propGrid);
SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
_redraw();
}

View File

@@ -20,7 +20,6 @@ TextButtonInstance::TextButtonInstance(void)
visible = true;
className = "TextButton";
disabled = false;
initProperties();
}
bool TextButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)

View File

@@ -6,7 +6,6 @@ WorkspaceInstance::WorkspaceInstance(void)
className = "Workspace";
timer = 60.0F;
score = 0;
initProperties();
}
WorkspaceInstance::~WorkspaceInstance(void)