From 6d1428ced9ca6ed1d71c540fcf8fa728904a2d88 Mon Sep 17 00:00:00 2001 From: andreja6 Date: Tue, 23 Oct 2018 12:29:36 -0700 Subject: [PATCH] Added properties to PhysicalInstance --- Instance.cpp | 32 ++++++++++++++++++++++++-------- Instance.h | 1 + PhysicalInstance.cpp | 30 ++++++++++++++++++++++++++++++ PhysicalInstance.h | 2 ++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/Instance.cpp b/Instance.cpp index 04aad28..de3ac11 100644 --- a/Instance.cpp +++ b/Instance.cpp @@ -17,6 +17,8 @@ Instance::Instance(const Instance &oinst) className = oinst.className; } + + void Instance::render(RenderDevice* rd) { for(size_t i = 0; i < children.size(); i++) @@ -25,6 +27,20 @@ void Instance::render(RenderDevice* rd) } } + + +PROPGRIDITEM Instance::createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type) +{ + PROPGRIDITEM pItem; + PropGrid_ItemInit(pItem); + pItem.lpszCatalog=catalog; + pItem.lpszPropName=propName; + pItem.lpszPropDesc=propDesc; + pItem.lpCurValue=curVal; + pItem.iItemType=type; + return pItem; +} + void Instance::PropUpdate(DWORD &addr, PROPGRIDITEM &pItem) { if((DWORD)&name == addr) @@ -36,15 +52,15 @@ void Instance::PropUpdate(DWORD &addr, PROPGRIDITEM &pItem) std::vector Instance::getProperties() { 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(Property(pItem, (DWORD)&name)); + + properties.push_back(Property(createPGI( + "Properties", + "Name", + "The name of this instance", + (LPARAM)name.c_str(), + PIT_EDIT + ), (DWORD)&name)); return properties; } diff --git a/Instance.h b/Instance.h index fbe14d8..65513f9 100644 --- a/Instance.h +++ b/Instance.h @@ -25,5 +25,6 @@ public: protected: std::string className; Instance* parent; // Another pointer. + PROPGRIDITEM createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type); }; diff --git a/PhysicalInstance.cpp b/PhysicalInstance.cpp index 3c8bf35..3f772e1 100644 --- a/PhysicalInstance.cpp +++ b/PhysicalInstance.cpp @@ -214,5 +214,35 @@ PhysicalInstance::~PhysicalInstance(void) } +void PhysicalInstance::PropUpdate(DWORD &addr, PROPGRIDITEM &pItem) +{ + if((DWORD)&name == addr) + { + name = pItem.lpCurValue; + } +} +std::vector PhysicalInstance::getProperties() +{ + std::vector properties; + + + properties.push_back(Property(createPGI( + "Properties", + "Name", + "The name of this instance", + (LPARAM)name.c_str(), + PIT_EDIT + ), (DWORD)&name)); + char pso[512]; + + properties.push_back(Property(createPGI( + "Item", + "Offset", + "The position of the object in the workspace", + (LPARAM)"Coming soon", + PIT_EDIT + ), (DWORD)&name)); + return properties; +} diff --git a/PhysicalInstance.h b/PhysicalInstance.h index 895df7f..f3fd26a 100644 --- a/PhysicalInstance.h +++ b/PhysicalInstance.h @@ -33,6 +33,8 @@ public: bool anchored; Vector3 rotVelocity; bool collides(Box); + virtual std::vector getProperties(); + virtual void PropUpdate(DWORD &addr, PROPGRIDITEM &pItem); private: Vector3 position; Vector3 size;