From fdc5e8760fb7ac0af8e7ebb98a2076db15e31082 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 10:15:01 +0100 Subject: giga refactor, fix ALL the leaks --- src/editor/properties.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/editor/properties.cpp') diff --git a/src/editor/properties.cpp b/src/editor/properties.cpp index ac21bb0..f3e9473 100644 --- a/src/editor/properties.cpp +++ b/src/editor/properties.cpp @@ -139,7 +139,7 @@ void gui_editor_propview_create_wallprops( GUI_EDITOR_PROPVIEW* view ) { } ); gui_label( x, y, "idx: %d", wall_idx ); y += space; - y += gui_editor_propview_surfprops_subentry( view, x, y, &s->propid, props ); + y += gui_editor_propview_surfprops_subentry( view, x, y, &s->propid.id, props ); GUI_VECTORINPUT* posinput; posinput = gui_vectorinput( x, y, propview_input_width( view ), "start", (F32*)&s->start, 3, -INFINITY, INFINITY, step ); y += (space+18); @@ -162,7 +162,7 @@ void gui_editor_propview_create_polyprops( GUI_EDITOR_PROPVIEW* view ) { I32 action_x = propview_action_x( view ); gui_label( x, y, "idx: %d", poly_idx ); y += space; - y += gui_editor_propview_surfprops_subentry( view, x, y, &p->propid, props ); + y += gui_editor_propview_surfprops_subentry( view, x, y, &p->propid.id, props ); gui_label( x, y, "vertices: %d", p->vertices.size ); y += space; I32 idx = 0; @@ -192,7 +192,7 @@ void gui_editor_propview_create_mapprops( GUI_EDITOR_PROPVIEW* view ) { F32 step = editor->propgrid? editor->grid : 0.25f; - gui_label( x, y, "name: %s", m->name ); y += space; + gui_label( x, y, "name: %s", m->name.data ); y += space; gui_label( x, y, "walls: %d", m->walls.size ); y += space; gui_label( x, y, "polygons: %d", m->polygons.size ); y += space; gui_label( x, y, "props: %d", m->props.size ); y += space; -- cgit v1.2.3 From f1882249843caa8bd931ecb76bb489615e079b10 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 12:51:06 +0100 Subject: editor work --- src/editor/properties.cpp | 79 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 19 deletions(-) (limited to 'src/editor/properties.cpp') 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 ) { -- cgit v1.2.3 From e59a032fb9afac6496acf3fba51a2a329bd0f992 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 13:35:33 +0100 Subject: more editor work --- src/editor/properties.cpp | 54 ++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'src/editor/properties.cpp') diff --git a/src/editor/properties.cpp b/src/editor/properties.cpp index e97ac72..3b15dc8 100644 --- a/src/editor/properties.cpp +++ b/src/editor/properties.cpp @@ -68,10 +68,12 @@ void gui_editor_propview_select( GUI_EDITOR_PROPVIEW* view, void* what, U8 selty } -void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 space ) { + +void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT* e, I32* x, I32* y, I32 w ); +void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space ) { F32 step = editor->propgrid ? editor->grid : 0.25f; - F32 w = propview_input_width( view ); F32 action_x = propview_action_x( view ); + I32 action2_x = propview_action2_x( view ); const char* n = prop->displayname; F32 min = prop->min; F32 max = prop->max; @@ -81,16 +83,28 @@ void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO 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_CLR: gui_colorinput( *x, *y, w, n, (CLR*)eprop_ptr( prop ) ); *y += (space+18); break; 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 ) { + SURF_PROPS* props = map_get_props( editor->map, *ref ); + gui_label( *x, *y, "prop id: %d", *ref ); + + GUI_BUTTON* newprop = gui_button( action2_x, *y, 20, 20, "+", pfn( void* ptr ) { + GUI_BUTTON* btn = (GUI_BUTTON*)ptr; + SURF_PROPS props{ .tex = 0, .clr = CLR::WHITE() }; + editor->map->props.push( props ); + + ((MAP_PROPREF*)btn->extra)->id = editor->map->props.size - 1; + editor->gui.assets_scroll = ( editor->map->props.size + 1 ) * 28; + gui_editor_propview_update( editor->gui.props ); + } ); newprop->extra = ref; + + GUI_BUTTON* goprop = 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; + } ); goprop->extra = props; *y += space; + + *x += 10; gui_editor_propview_create_eobj_props( view, props, x, y, w - 10 ); *x -= 10; } break; case EPROP_TEXTURE: { GL_TEX2D** tex = (GL_TEX2D**)eprop_ptr( prop ); @@ -101,25 +115,25 @@ void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO 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; + } ); btn->extra = tex; *y += space; } break; + default: 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_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space ) { } -void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, I32* x, I32* y ) { - MAP_SPRITE* e = (MAP_SPRITE*)view->curselect; +void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT* e, I32* x, I32* y, I32 w ) { 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 ); + gui_editor_propview_create_eobj_prop_ro( view, eprop, x, y, w, space ); else - gui_editor_propview_create_eobj_prop( view, eprop, x, y, space ); + gui_editor_propview_create_eobj_prop( view, eprop, x, y, w, space ); } } @@ -186,24 +200,16 @@ I32 gui_editor_propview_surfprops_subentry( void gui_editor_propview_create_wallprops( GUI_EDITOR_PROPVIEW* view ) { MAP_WALL* s = (MAP_WALL*)view->curselect; WORLD_MAP* m = editor->map; - SURF_PROPS* props = wall_get_props( m, s ); I32 x = 10, y = 10; I32 space = 20; - F32 step = editor->propgrid? editor->grid : 0.25f; I32 wall_idx = m->walls.idx_where( fn( MAP_WALL* ms ) { return s == ms; } ); gui_label( x, y, "idx: %d", wall_idx ); y += space; - y += gui_editor_propview_surfprops_subentry( view, x, y, &s->propid.id, props ); - - GUI_VECTORINPUT* posinput; - posinput = gui_vectorinput( x, y, propview_input_width( view ), "start", (F32*)&s->start, 3, -INFINITY, INFINITY, step ); y += (space+18); - posinput->cb = pfn( void* ) { map_check_bounds( editor->map ); }; - posinput = gui_vectorinput( x, y, propview_input_width( view ), "end", (F32*)&s->end, 3, -INFINITY, INFINITY, step ); y += (space+18); - posinput->cb = pfn( void* ) { map_check_bounds( editor->map ); }; + return gui_editor_propview_create_eobj_props( view, s, &x, &y, propview_input_width( view ) ); } void gui_editor_propview_create_polyprops( GUI_EDITOR_PROPVIEW* view ) { @@ -329,7 +335,7 @@ void gui_editor_propview_create_spriteprops( GUI_EDITOR_PROPVIEW* view ) { } ); gui_label( x, y, "idx: %d", sprite_idx ); y += space; - return gui_editor_propview_create_eobj_props( view, &x, &y ); + return gui_editor_propview_create_eobj_props( view, s, &x, &y, propview_input_width( view ) ); } void gui_editor_propview_create_surfprops( GUI_EDITOR_PROPVIEW* view ) { -- cgit v1.2.3 From 991352b0d2767e6bd1a46f554db4ac9d208c13ad Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 15:40:03 +0100 Subject: finish prop rewrite --- src/editor/properties.cpp | 171 ++++++++++++++-------------------------------- 1 file changed, 52 insertions(+), 119 deletions(-) (limited to 'src/editor/properties.cpp') diff --git a/src/editor/properties.cpp b/src/editor/properties.cpp index 3b15dc8..c9eb991 100644 --- a/src/editor/properties.cpp +++ b/src/editor/properties.cpp @@ -9,36 +9,36 @@ const I32 PROPVIEW_PAD = 10; const I32 PROPVIEW_ACTION_BTN_W = 20; const I32 PROPVIEW_ACTION_BTN_GAP = 5; -static I32 propview_col_left() { +I32 propview_col_left() { return PROPVIEW_PAD; } -static I32 propview_col_right( GUI_EDITOR_PROPVIEW* view ) { +I32 propview_col_right( GUI_EDITOR_PROPVIEW* view ) { if( !view ) return PROPVIEW_PAD; return max( PROPVIEW_PAD, view->w - PROPVIEW_PAD ); } -static I32 propview_input_width( GUI_EDITOR_PROPVIEW* view ) { +I32 propview_input_width( GUI_EDITOR_PROPVIEW* view ) { return max( 120, propview_col_right( view ) - propview_col_left() ); } -static I32 propview_sub_input_x( I32 x ) { +I32 propview_sub_input_x( I32 x ) { return x + 10; } -static I32 propview_sub_input_width( GUI_EDITOR_PROPVIEW* view, I32 x ) { - I32 right = propview_col_right( view ); - return max( 100, right - propview_sub_input_x( x ) ); -} +// I32 propview_sub_input_width( GUI_EDITOR_PROPVIEW* view, I32 x ) { +// I32 right = propview_col_right( view ); +// return max( 100, right - propview_sub_input_x( x ) ); +// } -static I32 propview_action_x( GUI_EDITOR_PROPVIEW* view ) { +I32 propview_action_x( GUI_EDITOR_PROPVIEW* view ) { I32 right = propview_col_right( view ); return max( propview_col_left(), right - PROPVIEW_ACTION_BTN_W ); } -static I32 propview_action2_x( GUI_EDITOR_PROPVIEW* view ) { +I32 propview_action2_x( GUI_EDITOR_PROPVIEW* view ) { return max( propview_col_left(), propview_action_x( view ) - PROPVIEW_ACTION_BTN_W - PROPVIEW_ACTION_BTN_GAP @@ -71,18 +71,21 @@ void gui_editor_propview_select( GUI_EDITOR_PROPVIEW* view, void* what, U8 selty void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT* e, I32* x, I32* y, I32 w ); void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space ) { - F32 step = editor->propgrid ? editor->grid : 0.25f; F32 action_x = propview_action_x( view ); I32 action2_x = propview_action2_x( view ); const char* n = prop->displayname; F32 min = prop->min; F32 max = prop->max; + F32 step; + + if( prop->step ) step = prop->step; + else step = editor->propgrid ? editor->grid : 0.25f; 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_VEC3: gui_vectorinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), 3, min, max, step, "xyz", "%.02f" ); *y += (space+18); break; + case EPROP_VEC4: gui_vectorinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), 3, min, max, step, "xyzw", "%0.02f" ); *y += (space+18); break; case EPROP_CLR: gui_colorinput( *x, *y, w, n, (CLR*)eprop_ptr( prop ) ); *y += (space+18); break; case EPROP_MAPPROP: { MAP_PROPREF* ref = (MAP_PROPREF*)eprop_ptr( prop ); @@ -117,12 +120,43 @@ void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO picker->cb = pfn( void* ) { gui_editor_propview_update( editor->gui.props ); }; } ); btn->extra = tex; *y += space; } break; + case EPROP_VERTEX_LIST: { + LIST* list = ( LIST* )eprop_ptr( prop ); + gui_label( *x, *y, "%s : %d", n, list->size ); *y += space; + for( U32 i = 0; i < list->size; ++i ) { + MAP_VERTEX* v = &list->data[i]; + gui_label( (*x) + 10, *y, "[%d] -> [%s]", i, to_str( v->pos ).data ); + 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_PVERTEX ); + } ); btn->extra = v; *y += space; + } + } break; default: break; } } void gui_editor_propview_create_eobj_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space ) { - + STR str = prop->displayname; + str += " : ["; + void* ptr = eprop_ptr( prop ); + + switch( prop->type ) { + case EPROP_F32: str += to_str( *(F32*)ptr ); break; + case EPROP_VEC2: str += to_str( *(VEC2*)ptr ); break; + case EPROP_VEC3: str += to_str( *(VEC3*)ptr ); break; + case EPROP_VEC4: str += to_str( *(VEC4*)ptr ); break; + case EPROP_CLR: str += to_str( *(CLR*)ptr ); break; + case EPROP_U32: str += to_str( *(U32*)ptr ); break; + case EPROP_U64: str += to_str( *(U64*)ptr ); break; + case EPROP_I32: str += to_str( *(I32*)ptr ); break; + case EPROP_I64: str += to_str( *(I64*)ptr ); break; + case EPROP_STRING: str += to_str( *(CLR*)ptr ); break; + } + + str += "]"; + gui_label( *x, *y, str.data ); + *y += space; } void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT* e, I32* x, I32* y, I32 w ) { @@ -137,66 +171,6 @@ void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT* } } - -// returns the subentry height -I32 gui_editor_propview_surfprops_subentry( - GUI_EDITOR_PROPVIEW* view, - I32 x, - I32 y, - I32* propid, - SURF_PROPS* props -) { - I32 oldy = y; - I32 space = 20; - I32 action_x = propview_action_x( view ); - I32 action2_x = propview_action2_x( view ); - gui_label( x, y, "prop id: %d", *propid ); - GUI_BUTTON* newprop = gui_button( action2_x, y, 20, 20, "+", pfn( void* ptr ) { - GUI_BUTTON* btn = (GUI_BUTTON*)ptr; - SURF_PROPS props; - props.tex = 0; - props.clr = { 1.f, 1.f, 1.f, 1.f }; - - editor->map->props.push( props ); - *(U32*)(btn->extra) = editor->map->props.size - 1; - // Keep the newest prop visible in the assets panel (pixel scroll). - editor->gui.assets_scroll = ( editor->map->props.size + 1 ) * 28; - gui_editor_propview_update( editor->gui.props ); - } ); - newprop->extra = propid; - GUI_BUTTON* goprop = 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 ); - } ); - goprop->extra = props; - - y += space; - - if( props->tex ) - gui_label( x + 10, y, "texture: %s", props->tex->name ); - else - gui_label( x + 10, 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 = &props->tex; - y += space; - gui_colorinput( - propview_sub_input_x( x ), - y, - propview_sub_input_width( view, x ), - "color", - &props->clr - ); y += (space+18); - - return y - oldy; -} - void gui_editor_propview_create_wallprops( GUI_EDITOR_PROPVIEW* view ) { MAP_WALL* s = (MAP_WALL*)view->curselect; WORLD_MAP* m = editor->map; @@ -215,37 +189,15 @@ void gui_editor_propview_create_wallprops( GUI_EDITOR_PROPVIEW* view ) { void gui_editor_propview_create_polyprops( GUI_EDITOR_PROPVIEW* view ) { MAP_POLYGON* p = (MAP_POLYGON*)view->curselect; WORLD_MAP* m = editor->map; - SURF_PROPS* props = polygon_get_props( m, p ); - I32 x = 10, y = 10; I32 space = 20; I32 poly_idx = m->polygons.idx_where( fn( MAP_POLYGON* mp ) { return p == mp; } ); - I32 action_x = propview_action_x( view ); gui_label( x, y, "idx: %d", poly_idx ); y += space; - y += gui_editor_propview_surfprops_subentry( view, x, y, &p->propid.id, props ); - - gui_label( x, y, "vertices: %d", p->vertices.size ); y += space; - I32 idx = 0; - p->vertices.each( fn( MAP_VERTEX* v ) { - gui_label( x + 10, y, "[%d] -> { %.02f, %.02f, %.02f }", idx, v->pos.x, v->pos.y, v->pos.z ); - GUI_BUTTON* btn = gui_button( action_x, y - 2, 20, 20, "\x1A", pfn( void* ptr ) { - GUI_EDITOR_PROPVIEW* view = editor->gui.props; - GUI_BUTTON* btn = (GUI_BUTTON*)ptr; - MAP_POLYGON* p = (MAP_POLYGON*)view->curselect; - I64 idx = (I64)btn->extra; - if( p ) // p100 - gui_editor_propview_select( view, &p->vertices[idx], EDITOR_SELECT_PVERTEX ); - } ); - - y += space; - btn->extra = (void*)( (I64)idx++ ); - } ); - gui_label( x, y, "mins: { %1.02f, %1.02f, %1.02f }", p->mins.x, p->mins.y, p->mins.z ); y += space; - gui_label( x, y, "maxs: { %1.02f, %1.02f, %1.02f }", p->maxs.x, p->maxs.y, p->maxs.z ); y += space; + return gui_editor_propview_create_eobj_props( view, p, &x, &y, propview_input_width( view ) ); } void gui_editor_propview_create_mapprops( GUI_EDITOR_PROPVIEW* view ) { @@ -296,12 +248,10 @@ void gui_editor_propview_create_pvertexprops( GUI_EDITOR_PROPVIEW* view ) { return vert_idx != -1; } ); - F32 step = editor->propgrid? editor->grid : 0.25f; I32 action_x = propview_action_x( view ); gui_label( x, y, "idx: %d", vert_idx ); y += space; gui_label( x, y, "polygon idx: %d", poly_idx ); - gui_button( action_x, y - 2, 20, 20, "\x1A", pfn( void* ) { GUI_EDITOR_PROPVIEW* view = editor->gui.props; MAP_VERTEX* v = (MAP_VERTEX*)view->curselect; @@ -313,13 +263,9 @@ void gui_editor_propview_create_pvertexprops( GUI_EDITOR_PROPVIEW* view ) { if( polygon ) gui_editor_propview_select( view, polygon, EDITOR_SELECT_POLY ); - } ); - y += space; + } ); y += space; - GUI_VECTORINPUT* posinput = gui_vectorinput( x, y, propview_input_width( view ), "position", (F32*)&v->pos, 3, -INFINITY, INFINITY, step ); y += (space+18); - posinput->cb = pfn( void* ptr ) { map_check_bounds( editor->map ); }; - gui_vectorinput( x, y, propview_input_width( view ), "texture coordinates", (F32*)&v->uv, 2, 0.f, 1.f, 0.005f, "xy", "%.03f" ); y += (space+18); - gui_colorinput( x, y, propview_input_width( view ), "color", &v->clr ); y += (space+18); + return gui_editor_propview_create_eobj_props( view, v, &x, &y, propview_input_width( view ) ); } @@ -348,22 +294,9 @@ void gui_editor_propview_create_surfprops( GUI_EDITOR_PROPVIEW* view ) { I32 i = m->props.idx_where( fn( SURF_PROPS* mp ) { return mp == p; } ); if( i == -1 ) return; - I32 action_x = propview_action_x( view ); gui_label( x, y, "prop id: %d", i ); y += space; - if( p->tex ) - gui_label( x, y, "texture: %s", assets_abspath( p->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 = &p->tex; - y += space; - gui_colorinput( x, y, propview_input_width( view ), "color", &p->clr ); y += (space+18); + return gui_editor_propview_create_eobj_props( view, p, &x, &y, propview_input_width( view ) ); } void gui_editor_propview_create_entprops( GUI_EDITOR_PROPVIEW* view ) { -- cgit v1.2.3