summaryrefslogtreecommitdiff
path: root/src/editor/properties.cpp
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.cpp
parentb71bb14c7dec546304e3396d7040d88c6c86a3a7 (diff)
editor work
Diffstat (limited to 'src/editor/properties.cpp')
-rw-r--r--src/editor/properties.cpp79
1 files changed, 60 insertions, 19 deletions
diff --git a/src/editor/properties.cpp b/src/editor/properties.cpp
index f3e9473..e97ac72 100644
--- a/src/editor/properties.cpp
+++ b/src/editor/properties.cpp
@@ -1,3 +1,4 @@
+#include "properties.h"
#include "editor.h"
#include "../render/gl.h"
#include "../game/assets.h"
@@ -66,6 +67,63 @@ void gui_editor_propview_select( GUI_EDITOR_PROPVIEW* view, void* what, U8 selty
gui_editor_propview_update( view );
}
+
+void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 space ) {
+ F32 step = editor->propgrid ? editor->grid : 0.25f;
+ F32 w = propview_input_width( view );
+ F32 action_x = propview_action_x( view );
+ const char* n = prop->displayname;
+ F32 min = prop->min;
+ F32 max = prop->max;
+
+ switch( prop->type ) {
+ case EPROP_F32: gui_floatinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), min, max, step ); *y += (space+18); break;
+ case EPROP_VEC2: gui_vectorinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), 2, min, max, step, "xy", "%.03f" ); *y += (space+18); break;
+ case EPROP_VEC3: gui_vectorinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), 3, min, max, step, "xyz", "%.03f" ); *y += (space+18); break;
+ case EPROP_VEC4: gui_vectorinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), 3, min, max, step, "xyzw", "%0.03f" ); *y += (space+18); break;
+ case EPROP_CLR: gui_colorinput( *x, *y, w, n, (CLR*)eprop_ptr( prop ) );
+ case EPROP_MAPPROP: {
+ MAP_PROPREF* ref = (MAP_PROPREF*)eprop_ptr( prop );
+ SURF_PROPS* props = map_get_props( editor->map, ref->id );
+ gui_label( *x, *y, n );
+ GUI_BUTTON* btn = gui_button( action_x, *y, 20, 20, "\x1A", pfn( void* ptr ) {
+ GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
+ gui_editor_propview_select( editor->gui.props, btn->extra, EDITOR_SELECT_SURFPROPS );
+ } ); btn->extra = props;
+ *y += space;
+ } break;
+ case EPROP_TEXTURE: {
+ GL_TEX2D** tex = (GL_TEX2D**)eprop_ptr( prop );
+ if( *tex ) gui_label( *x, *y, "%s: %s", n, (*tex)->name );
+ else gui_label( *x, *y, "%s: none", n );
+ GUI_BUTTON* btn = gui_button( action_x, *y, 20, 20, "\x1A", pfn( void* ptr ) {
+ GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
+ GL_TEX2D** ptex = (GL_TEX2D**)btn->extra;
+ GUI_EDITOR_TEXTUREPICKER* picker = gui_editor_texturepicker( 200, 100, 400, 400, ptex );
+ picker->cb = pfn( void* ) { gui_editor_propview_update( editor->gui.props ); };
+ } ); btn->extra = tex;
+ } break;
+ }
+}
+
+void gui_editor_propview_create_eobj_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 space ) {
+
+}
+
+void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, I32* x, I32* y ) {
+ MAP_SPRITE* e = (MAP_SPRITE*)view->curselect;
+ I32 space = 20;
+
+ for( auto& it : e->eprops ) {
+ EDITOR_PROP* eprop = eprop_from_ref( e, it );
+ if( eprop->readonly )
+ gui_editor_propview_create_eobj_prop_ro( view, eprop, x, y, space );
+ else
+ gui_editor_propview_create_eobj_prop( view, eprop, x, y, space );
+ }
+}
+
+
// returns the subentry height
I32 gui_editor_propview_surfprops_subentry(
GUI_EDITOR_PROPVIEW* view,
@@ -258,6 +316,7 @@ void gui_editor_propview_create_pvertexprops( GUI_EDITOR_PROPVIEW* view ) {
gui_colorinput( x, y, propview_input_width( view ), "color", &v->clr ); y += (space+18);
}
+
void gui_editor_propview_create_spriteprops( GUI_EDITOR_PROPVIEW* view ) {
MAP_SPRITE* s = (MAP_SPRITE*)view->curselect;
WORLD_MAP* m = editor->map;
@@ -268,27 +327,9 @@ void gui_editor_propview_create_spriteprops( GUI_EDITOR_PROPVIEW* view ) {
I32 sprite_idx = m->sprites.idx_where( fn( MAP_SPRITE* ms ) {
return ms == s;
} );
- I32 action_x = propview_action_x( view );
-
- F32 step = editor->propgrid? editor->grid : 0.25f;
gui_label( x, y, "idx: %d", sprite_idx ); y += space;
- gui_vectorinput( x, y, propview_input_width( view ), "position", (F32*)&s->pos, 3, -INFINITY, INFINITY, step ); y += (space+18);
- gui_vectorinput( x, y, propview_input_width( view ), "size", (F32*)&s->size, 2, 1.f, INFINITY, 1.f, "wh" ); y += (space+18);
- gui_colorinput( x, y, propview_input_width( view ), "color", &s->clr ); y += (space+18);
- if( s->tex )
- gui_label( x, y, "texture: %s", s->tex->name );
- else
- gui_label( x, y, "texture: none" );
-
- GUI_BUTTON* btn = gui_button( action_x, y, 20, 20, "\x1A", pfn( void* ptr ) {
- GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
- GL_TEX2D** ptex = (GL_TEX2D**)btn->extra;
- GUI_EDITOR_TEXTUREPICKER* picker = gui_editor_texturepicker( 200, 100, 400, 400, ptex );
- picker->cb = pfn( void* ) { gui_editor_propview_update( editor->gui.props ); };
- } );
- btn->extra = &s->tex;
- y += space;
+ return gui_editor_propview_create_eobj_props( view, &x, &y );
}
void gui_editor_propview_create_surfprops( GUI_EDITOR_PROPVIEW* view ) {