diff options
| author | aura <nw@moneybot.cc> | 2026-03-16 13:35:33 +0100 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-03-16 13:35:33 +0100 |
| commit | e59a032fb9afac6496acf3fba51a2a329bd0f992 (patch) | |
| tree | 930bc3bc05e32127153cba12ac1248bc400b860d /src | |
| parent | f1882249843caa8bd931ecb76bb489615e079b10 (diff) | |
more editor work
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor/editor.cpp | 2 | ||||
| -rw-r--r-- | src/editor/properties.cpp | 54 | ||||
| -rw-r--r-- | src/game/world/map.cpp | 8 | ||||
| -rw-r--r-- | src/game/world/map.h | 8 |
4 files changed, 39 insertions, 33 deletions
diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index e2267b8..bc14146 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -610,9 +610,9 @@ STAT editor_new_map( GAME_EDITOR* e, const char* mapname ) { m->startpos = { 10.f, 10.f, 0.f }; m->props.push( { .clr = { 1.f, 1.f, 1.f, 1.f } } ); m->walls.push( { + .propid = 0, .start = { 0 , 0, -40.f }, .end = { 10.f, 0, 80.f }, - .propid = 0 } ); CFG_SECTION* map_cfg = map_serialize( m ); 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 ) { diff --git a/src/game/world/map.cpp b/src/game/world/map.cpp index 5f1f5d7..7b8060b 100644 --- a/src/game/world/map.cpp +++ b/src/game/world/map.cpp @@ -380,24 +380,24 @@ void map_gen_skybox( WORLD_MAP* m ) { VEC3 maxs = m->maxs + VEC3( SKYBOX_OFFSET, SKYBOX_OFFSET, SKYBOX_OFFSET ); m->skybox.walls[0] = { + .propid = MAPPROP_SKYBOX, .start = { mins.x, mins.y, mins.z }, .end = { maxs.x, mins.y, maxs.z - mins.z }, - .propid = MAPPROP_SKYBOX }; m->skybox.walls[1] = { + .propid = MAPPROP_SKYBOX, .start = { maxs.x, mins.y, mins.z }, .end = { maxs.x, maxs.y, maxs.z - mins.z }, - .propid = MAPPROP_SKYBOX }; m->skybox.walls[2] = { + .propid = MAPPROP_SKYBOX, .start = { maxs.x, maxs.y, mins.z }, .end = { mins.x, maxs.y, maxs.z - mins.z }, - .propid = MAPPROP_SKYBOX }; m->skybox.walls[3] = { + .propid = MAPPROP_SKYBOX, .start = { mins.x, maxs.y, mins.z }, .end = { mins.x, mins.y, maxs.z - mins.z }, - .propid = MAPPROP_SKYBOX }; VEC2 floor[] = { diff --git a/src/game/world/map.h b/src/game/world/map.h index 89c467c..8e6444e 100644 --- a/src/game/world/map.h +++ b/src/game/world/map.h @@ -39,22 +39,22 @@ struct MAP_PROPREF { }; struct MAP_POLYGON : public EOBJECT { + EPROP( MAP_PROPREF, propid, {}, "prop id" ); EPROP( LIST<MAP_VERTEX>, vertices, {}, "vertices" ); VEC3 mins; VEC3 maxs; U8 type; - EPROP( MAP_PROPREF, propid, {}, "prop id" ); }; struct MAP_WALL : public EOBJECT { + EPROP( MAP_PROPREF, propid, {}, "prop id" ); + EPROP( VEC3, start, {}, "start pos" ); EPROP( VEC3, end, {}, "end pos" ); EPROP( VEC2, uvstart, {}, "uv start offset" ); EPROP( VEC2, uvend, {}, "uv end offset" ); - - EPROP( MAP_PROPREF, propid, {}, "prop id" ); }; struct MAP_TEXTURE_ENTRY { @@ -64,10 +64,10 @@ struct MAP_TEXTURE_ENTRY { }; struct MAP_SPRITE : public EOBJECT { + EPROP( GL_TEX2D*, tex, {}, "texture" ); EPROP( VEC3, pos, {}, "position" ); EPROP( VEC2, size, {}, "size" ); EPROP( CLR, clr, {}, "color" ); - EPROP( GL_TEX2D*, tex, {}, "texture" ); }; struct MAP_ENTITY : public EOBJECT { |
