From ee528d1245e41524ac2bd325b82eb92dd6f24dca Mon Sep 17 00:00:00 2001 From: andreja6 Date: Tue, 23 Oct 2018 06:49:41 -0700 Subject: [PATCH] Changed how properties work --- BaseButtonInstance.cpp | 1 - DataModelInstance.cpp | 1 - ImageButtonInstance.cpp | 1 - Instance.cpp | 23 ++++++++++++----------- Instance.h | 5 +++-- PhysicalInstance.cpp | 1 - Property.cpp | 11 +++-------- Property.h | 7 +++---- PropertyWindow.cpp | 8 +++++--- TextButtonInstance.cpp | 1 - WorkspaceInstance.cpp | 1 - 11 files changed, 26 insertions(+), 34 deletions(-) diff --git a/BaseButtonInstance.cpp b/BaseButtonInstance.cpp index 7f3f05e..99dfa46 100644 --- a/BaseButtonInstance.cpp +++ b/BaseButtonInstance.cpp @@ -11,7 +11,6 @@ ButtonListener* listener = NULL; BaseButtonInstance::BaseButtonInstance(void) { listener = NULL; - initProperties(); } void BaseButtonInstance::render(RenderDevice* rd) diff --git a/DataModelInstance.cpp b/DataModelInstance.cpp index da1c4b6..cc4ad49 100644 --- a/DataModelInstance.cpp +++ b/DataModelInstance.cpp @@ -14,7 +14,6 @@ DataModelInstance::DataModelInstance(void) mousey = 0; mouseButton1Down = false; showMessage = false; - initProperties(); } DataModelInstance::~DataModelInstance(void) diff --git a/ImageButtonInstance.cpp b/ImageButtonInstance.cpp index 461e380..6268941 100644 --- a/ImageButtonInstance.cpp +++ b/ImageButtonInstance.cpp @@ -21,7 +21,6 @@ ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureR floatRight = false; disabled = false; className = "ImageButton"; - initProperties(); } ImageButtonInstance::~ImageButtonInstance(void) diff --git a/Instance.cpp b/Instance.cpp index 1000510..67b4182 100644 --- a/Instance.cpp +++ b/Instance.cpp @@ -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 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 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; } diff --git a/Instance.h b/Instance.h index ef92e69..17d2914 100644 --- a/Instance.h +++ b/Instance.h @@ -5,7 +5,6 @@ class Instance { public: - std::vector 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 getProperties(); + virtual void PropUpdate(DWORD addr, PROPGRIDITEM pItem); protected: std::string className; Instance* parent; // Another pointer. - void initProperties(); + }; diff --git a/PhysicalInstance.cpp b/PhysicalInstance.cpp index 0f84e41..3c8bf35 100644 --- a/PhysicalInstance.cpp +++ b/PhysicalInstance.cpp @@ -19,7 +19,6 @@ PhysicalInstance::PhysicalInstance(void) back = Smooth; left = Smooth; bottom = Smooth; - initProperties(); } PhysicalInstance::PhysicalInstance(const PhysicalInstance &oinst) diff --git a/Property.cpp b/Property.cpp index b8862d4..4780735 100644 --- a/Property.cpp +++ b/Property.cpp @@ -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); } + diff --git a/Property.h b/Property.h index 793db69..59536c6 100644 --- a/Property.h +++ b/Property.h @@ -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); }; diff --git a/PropertyWindow.cpp b/PropertyWindow.cpp index 08379f4..34cee8c 100644 --- a/PropertyWindow.cpp +++ b/PropertyWindow.cpp @@ -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 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(); } \ No newline at end of file diff --git a/TextButtonInstance.cpp b/TextButtonInstance.cpp index da78ebb..349b439 100644 --- a/TextButtonInstance.cpp +++ b/TextButtonInstance.cpp @@ -20,7 +20,6 @@ TextButtonInstance::TextButtonInstance(void) visible = true; className = "TextButton"; disabled = false; - initProperties(); } bool TextButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd) diff --git a/WorkspaceInstance.cpp b/WorkspaceInstance.cpp index 0a01c83..f4cf49e 100644 --- a/WorkspaceInstance.cpp +++ b/WorkspaceInstance.cpp @@ -6,7 +6,6 @@ WorkspaceInstance::WorkspaceInstance(void) className = "Workspace"; timer = 60.0F; score = 0; - initProperties(); } WorkspaceInstance::~WorkspaceInstance(void)