From d42d218a3685c030a7370d30f2de5495ea526d99 Mon Sep 17 00:00:00 2001 From: aura Date: Fri, 13 Mar 2026 05:03:12 +0100 Subject: wip on props --- src/editor/properties.h | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/editor/properties.h (limited to 'src/editor') diff --git a/src/editor/properties.h b/src/editor/properties.h new file mode 100644 index 0000000..f3d55b5 --- /dev/null +++ b/src/editor/properties.h @@ -0,0 +1,88 @@ +#pragma once + +#include "../gamedef.h" + +#if IS_EDITOR +#include +#include "../util/string.h" + +#define EPROP( _type, name, value, display ) \ + _type name = value; \ + EDITOR_PROP name##_prop{ .pdata = &name, .type = eprop_type<_type>(), .displayname = display, .parent = this }; + +#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 \ + } + +enum EditorPropType_t { + EPROP_INVALID = 0, + EPROP_U8 = 1, + EPROP_U16, + EPROP_U32, + EPROP_U64, + EPROP_I8, + EPROP_I16, + EPROP_I32, + EPROP_I64, + EPROP_F32, + EPROP_F64, + EPROP_STRING, + EPROP_OBJ, + EPROP_LIST, + EPROP_TEXTURE_LIST, +}; + +// editor map object +struct EOBJECT { + LIST eprops{}; +}; + +// editor object property +struct EDITOR_PROP { + void* pdata; + U8 type; + STR displayname; + F64 min{ -INFINITY }; + F64 max{ INFINITY }; + struct EOBJECT* parent; + + + template struct __eprop_type { + static const U8 type = EPROP_INVALID; + }; + template <> struct __eprop_type { static const U8 type = EPROP_U8; }; + template <> struct __eprop_type { static const U8 type = EPROP_U16; }; + template <> struct __eprop_type { static const U8 type = EPROP_U32; }; + template <> struct __eprop_type { static const U8 type = EPROP_U64; }; + template <> struct __eprop_type { static const U8 type = EPROP_I8; }; + template <> struct __eprop_type { static const U8 type = EPROP_I16; }; + template <> struct __eprop_type { static const U8 type = EPROP_I32; }; + template <> struct __eprop_type { static const U8 type = EPROP_I64; }; + template <> struct __eprop_type { static const U8 type = EPROP_F32; }; + template <> struct __eprop_type { static const U8 type = EPROP_F64; }; + template <> struct __eprop_type { static const U8 type = EPROP_STRING; }; + template <> struct __eprop_type { static const U8 type = EPROP_OBJ; }; + template struct __eprop_type> { static const U8 type = EPROP_LIST; }; + template <> struct __eprop_type> { static const U8 type = EPROP_TEXTURE_LIST; }; +}; + +template +const U8 eprop_type() { + if constexpr( __is_base_of( EOBJECT, T ) ) + return EPROP_OBJ; + + return EDITOR_PROP::__eprop_type::type; +} +#else +struct EOBJECT {}; + +#define EPROP( type, name, value, displayname ) \ + type name{ value }; +#endif -- cgit v1.2.3