summaryrefslogtreecommitdiff
path: root/src/editor/properties.h
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-03-16 12:51:06 +0100
committeraura <nw@moneybot.cc>2026-03-16 12:51:06 +0100
commitf1882249843caa8bd931ecb76bb489615e079b10 (patch)
tree15d0e3f7d775684ff91d85cc37843138e72b1735 /src/editor/properties.h
parentb71bb14c7dec546304e3396d7040d88c6c86a3a7 (diff)
editor work
Diffstat (limited to 'src/editor/properties.h')
-rw-r--r--src/editor/properties.h75
1 files changed, 64 insertions, 11 deletions
diff --git a/src/editor/properties.h b/src/editor/properties.h
index 01edbbf..1eb51f8 100644
--- a/src/editor/properties.h
+++ b/src/editor/properties.h
@@ -8,17 +8,22 @@
#define EPROP( _type, name, value, display ) \
_type name = value; \
- EDITOR_PROP name##_prop{ .pdata = &name, .type = eprop_type<_type>(), .displayname = display, .parent = this };
+ EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, 0 };
+
+#define EPROP_RO( _type, name, value, display ) \
+ _type name = value; \
+ EDITOR_PROP name##_prop{ .pdata = &name, .type = eprop_type<_type>(), .displayname = display, .parent = this, .readonly = 1 };
#define EPROP_RANGED( _type, name, value, display, _min, _max ) \
_type name{ value }; \
EDITOR_PROP{ \
- .pdata = &name, \
- .type = eprop_type<_type>(), \
- .displayname = display, \
- .parent = this, \
- .min = _min, \
- .max = _max \
+ &name, \
+ eprop_type<_type>(), \
+ display, \
+ this, \
+ _min, \
+ _max, \
+ 0 \
}
enum EditorPropType_t {
@@ -45,9 +50,13 @@ enum EditorPropType_t {
EPROP_TEXTURE_LIST,
};
+struct EPROP_ENTRY {
+ U64 offset;
+};
+
// editor map object
struct EOBJECT {
- LIST<struct EDITOR_PROP*> eprops{};
+ LIST<EPROP_ENTRY> eprops{};
};
template <typename T>
@@ -55,13 +64,49 @@ concept __eobject_base = __is_base_of(EOBJECT, T);
// editor object property
struct EDITOR_PROP {
- void* pdata;
+ EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, U8 _readonly = 0 ) {
+ type = _type;
+ displayname = _displayname;
+ min = -INFINITY;
+ max = INFINITY;
+ readonly = _readonly;
+
+ U64 _this = (U64)this;
+ U64 pdata = (U64)_pdata;
+ U64 parent = (U64)_parent;
+ U64 offset = _this - parent;
+
+ _parent->eprops.push( { offset } );
+
+ offset = _this - pdata;
+ dataoff = offset;
+ }
+
+
+ EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, F32 _min, F32 _max, U8 _readonly = 0 ) {
+ type = _type;
+ displayname = _displayname;
+ min = _min;
+ max = _max;
+ readonly = _readonly;
+
+ U64 _this = (U64)this;
+ U64 pdata = (U64)_pdata;
+ U64 parent = (U64)_parent;
+ U64 offset = _this - parent;
+
+ _parent->eprops.push( { offset } );
+
+ offset = _this - pdata;
+ dataoff = offset;
+ }
+
+ U64 dataoff;
U8 type;
STR displayname;
F64 min{ -INFINITY };
F64 max{ INFINITY };
- struct EOBJECT* parent;
-
+ U8 readonly;
template <typename T> struct __eprop_type {
static const U8 type = EPROP_INVALID;
@@ -88,6 +133,14 @@ struct EDITOR_PROP {
template <> struct __eprop_type<LIST<struct MAP_TEXTURE_ENTRY*>> { static const U8 type = EPROP_TEXTURE_LIST; };
};
+inline EDITOR_PROP* eprop_from_ref( EOBJECT* obj, EPROP_ENTRY e ) {
+ return (EDITOR_PROP*)( (U64)obj + e.offset );
+}
+
+inline void* eprop_ptr( EDITOR_PROP* prop ) {
+ return (void*)( (U64)prop - prop->dataoff);
+}
+
template <typename T>
const U8 eprop_type() {
return EDITOR_PROP::__eprop_type<T>::type;