Made properties work

This commit is contained in:
Vulpovile
2022-10-22 21:26:41 -07:00
parent 793e85a57f
commit 78f135732e
11 changed files with 41 additions and 79 deletions

View File

@@ -677,10 +677,6 @@
<Filter
Name="PropertiesV2"
>
<File
RelativePath=".\src\source\PropertiesV2\BaseProperty.cpp"
>
</File>
<File
RelativePath=".\src\source\PropertiesV2\BoolProperty.cpp"
>
@@ -970,10 +966,6 @@
<Filter
Name="PropertiesV2"
>
<File
RelativePath=".\src\include\PropertiesV2\BaseProperty.h"
>
</File>
<File
RelativePath=".\src\include\PropertiesV2\BoolProperty.h"
>

View File

@@ -32,7 +32,7 @@ public:
//Deprecated
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
virtual std::vector<BaseProperty> collectProperties();
virtual std::vector<Property *> collectProperties();
int listicon;
protected:

View File

@@ -1,29 +0,0 @@
#pragma once
#include <string>
#include <G3DAll.h>
#include "propertyGrid.h"
class Instance;
/**
DO NOT INHERIT FROM THIS CLASS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
INHERIT FROM PROPERTY INSTEAD
*/
class BaseProperty
{
public:
BaseProperty(LPSTR name, LPSTR desc, LPSTR catalog, Instance * owner) {
_name = name;
_desc = desc;
_owner = owner;
_catalog = catalog;
}
~BaseProperty(void){};
virtual PROPGRIDITEM getPropGridItem();
virtual void setProperty(LPPROPGRIDITEM &pItem);
protected:
Instance* _owner;
LPSTR _name;
LPSTR _desc;
LPSTR _catalog;
};

View File

@@ -1,20 +1,20 @@
#pragma once
#include "Property.h"
class BoolProperty : public Property<bool>
class BoolProperty : public Property
{
public:
typedef void (Instance::*instanceSetter)(bool);
//Win32 why
~BoolProperty(void){};
~BoolProperty(void);
BoolProperty(LPSTR name, LPSTR desc, LPSTR catalog, bool value, Instance * owner, instanceSetter setterFunc)
:Property(name, desc, catalog, value, owner)
:Property(name, desc, catalog, (void*)value, owner)
{
this->setterFunc = setterFunc;
}
const void setValue(bool val){
(_owner->*setterFunc)(val);
_value = val;
_value = (void *)val;
}
PROPGRIDITEM getPropGridItem();
void setProperty(LPPROPGRIDITEM &pItem);

View File

@@ -1,21 +1,35 @@
#pragma once
#include "PropertiesV2/BaseProperty.h"
#include <G3DAll.h>
#include "propertyGrid.h"
template <typename T>
class Property : public BaseProperty
class Instance;
class Property
{
public:
Property(LPSTR name, LPSTR desc, LPSTR catalog, T value, Instance * owner)
:BaseProperty(name, desc, catalog, owner)
{
Property(LPSTR name, LPSTR desc, LPSTR catalog, Instance * owner){
_name = name;
_desc = desc;
_catalog = catalog;
_owner = owner;
}
Property(LPSTR name, LPSTR desc, LPSTR catalog, void* value, Instance * owner){
_name = name;
_desc = desc;
_catalog = catalog;
_owner = owner;
_value = value;
}
~Property(void){};
const T getValue() {
~Property(void){}
const void* getValue() {
return _value;
}
virtual PROPGRIDITEM getPropGridItem();
virtual void setProperty(LPPROPGRIDITEM &pItem);
protected:
T _value;
Instance* _owner;
LPSTR _name;
LPSTR _desc;
LPSTR _catalog;
void* _value;
};

View File

@@ -1,14 +1,15 @@
#pragma once
#include "Property.h"
class StringProperty : public Property<std::string>
class StringProperty : public Property
{
public:
typedef void (Instance::*instanceSetter)(std::string);
~StringProperty(void){};
StringProperty(LPSTR name, LPSTR desc, LPSTR catalog, std::string value, Instance * owner, instanceSetter setterFunc)
:Property(name, desc, catalog, value, owner)
:Property(name, desc, catalog, &_value, owner)
{
this->_value = value;
this->setterFunc = setterFunc;
}
const void setValue(std::string val){
@@ -18,5 +19,6 @@ public:
PROPGRIDITEM getPropGridItem();
void setProperty(LPPROPGRIDITEM &pItem);
private:
std::string _value;
instanceSetter setterFunc;
};

View File

@@ -80,10 +80,10 @@ std::vector<PROPGRIDITEM> Instance::getProperties()
}
std::vector<BaseProperty> Instance::collectProperties()
std::vector<Property *> Instance::collectProperties()
{
std::vector<BaseProperty> properties;
properties.push_back(StringProperty("Name", "The name of this instance", "Properties", name, this, &Instance::setName));
std::vector<Property *> properties;
properties.push_back(new StringProperty("Name", "The name of this instance", "Properties", name, this, &Instance::setName));
return properties;
}

View File

@@ -1,14 +0,0 @@
#include "PropertiesV2/BaseProperty.h"
PROPGRIDITEM BaseProperty::getPropGridItem(){
PROPGRIDITEM pItem;
PropGrid_ItemInit(pItem);
pItem.lpszCatalog=_catalog;
pItem.lpszPropName=_name;
pItem.lpszPropDesc=_desc;
pItem.iItemType=PIT_EDIT;
return pItem;
}
void BaseProperty::setProperty(LPPROPGRIDITEM &pItem){
}

View File

@@ -6,7 +6,7 @@ PROPGRIDITEM BoolProperty::getPropGridItem(){
pItem.lpszCatalog=_catalog;
pItem.lpszPropName=_name;
pItem.lpszPropDesc=_desc;
pItem.lpCurValue=_value;
pItem.lpCurValue=_value > 0;
pItem.iItemType=PIT_CHECK;
return pItem;
}

View File

@@ -1,17 +1,14 @@
#include "PropertiesV2/Property.h"
template <typename T>
PROPGRIDITEM Property<T>::getPropGridItem(){
PROPGRIDITEM Property::getPropGridItem(){
PROPGRIDITEM pItem;
PropGrid_ItemInit(pItem);
pItem.lpszCatalog=_catalog;
pItem.lpszPropName=_name;
pItem.lpszPropDesc=_desc;
pItem.lpCurValue="invalid";
pItem.iItemType=PIT_EDIT;
return pItem;
}
template <typename T>
void Property<T>::setProperty(LPPROPGRIDITEM &pItem){
void Property::setProperty(LPPROPGRIDITEM &pItem){
}

View File

@@ -6,7 +6,7 @@
#include "strsafe.h"
#include "Application.h"
std::vector<PROPGRIDITEM> prop;
std::vector<Property*> prop;
std::vector<Instance*> children;
Instance * selectedInstance;
Instance * parent = NULL;
@@ -349,13 +349,13 @@ void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
}
Instance * instance = instances[0];
PropGrid_ResetContent(_propGrid);
prop = instance->getProperties();
prop = instance->collectProperties();
//if (selectedInstance != instance)
{
selectedInstance = instance;
for(size_t i = 0; i < prop.size(); i++)
{
::PROPGRIDITEM item = prop.at(i);
::PROPGRIDITEM item = prop.at(i)->getPropGridItem();
PropGrid_AddItem(_propGrid, &item);
//PRGP propgp;
//propgp.instance = instance;