From: Brendan Hansen Date: Sat, 26 Feb 2022 22:47:16 +0000 (-0600) Subject: re-added entity field rendering to editor X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=15a525a65a9d00bb3f650f326480653cb8ef7486;p=bar-game.git re-added entity field rendering to editor --- diff --git a/src/entity/editor.onyx b/src/entity/editor.onyx index 25a74f0..4ec0f08 100644 --- a/src/entity/editor.onyx +++ b/src/entity/editor.onyx @@ -253,10 +253,12 @@ editor_draw :: () { #local render_entity_fields :: (entity: ^Entity, x, y, w, h: f32) { assert(entity != null, "entity is null"); - /* - info := cast(^type_info.Type_Info_Struct) type_info.get_type_info(entity.type); - font_print(editor_big_font, x + 2, y + 24, info.name); + info := cast(^type_info.Type_Info_Struct) type_info.get_type_info(entity.schematic); + if info != null { + font_print(editor_big_font, x + 2, y + 24, info.name); + } + if draw_button(.{ x + w - 150, y, 150, 24 }, "Delete") { scene->delete(entity); selected_entity_id = Entity_Nothing; @@ -264,8 +266,17 @@ editor_draw :: () { } if active_index >= 0 do sidebar_width += w; - render_struct_fields(any.{~~entity, entity.type}, 0, x, y + 4, w, h); - */ + + y += 4; + i := 0; + for^ entry: entity.components.entries { + y += 16; + info = ~~ type_info.get_type_info(entry.key); + font_print(editor_font, x + 2, y + 24, info.name); + + y, i = render_struct_fields(any.{~~entry.value, entry.key}, i, x, y, w, h); + y += 16; + } } #local render_struct_fields :: (v: any, i: i32, x, y, w, h: f32, depth := 0) -> (new_y: f32, new_i: i32) {