From 991122928213a084c0440a0539967be26a22b08a Mon Sep 17 00:00:00 2001 From: Katajisto Date: Sat, 17 Oct 2026 00:16:37 +0300 Subject: [PATCH] fix bug with entity autoedit ui --- src/editor/level_editor.jai | 2 +- src/ui/autoedit.jai | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/editor/level_editor.jai b/src/editor/level_editor.jai index 8039956..f59c509 100644 --- a/src/editor/level_editor.jai +++ b/src/editor/level_editor.jai @@ -1091,7 +1091,7 @@ add_entity_at :: (x: s32, y: s32, z: s32) { // Runs autoedit on the entity's concrete type, so each type gets an editor // generated from its own fields. entity_autoedit :: (rect: GR.Rect, e: *Entity, theme: *GR.Overall_Theme) { - #insert #run,stallable gen_entity_dispatch("autoedit(rect, cast(*%)e, theme, 400)"); + #insert #run,stallable gen_entity_dispatch("autoedit(rect, cast(*%)e, theme, cast(s32)e.id)"); } draw_editor_billboards :: (view: View_Id) { diff --git a/src/ui/autoedit.jai b/src/ui/autoedit.jai index 6f356db..2c0a730 100644 --- a/src/ui/autoedit.jai +++ b/src/ui/autoedit.jai @@ -73,17 +73,8 @@ autoedit_widget_id :: (identifier: s32, field_index: int) -> s32 { return identifier * 1000 + cast(s32) field_index; } -// A text input hands back a view into the widget's own buffer, so the value has -// to be copied out on every keystroke. The previous copy is freed only when this -// same helper allocated it and the field still points at it: a field's starting -// value is usually a literal from the struct definition, which must not be freed. -autoedit_owned_text : Table(*string, string); - autoedit_set_text :: (field: *string, text: string) -> string { - found, previous := table_find(*autoedit_owned_text, field); - if found && previous.data == field.data free(previous); result := copy_string(text); - table_set(*autoedit_owned_text, field, result); return result; } @@ -110,7 +101,7 @@ input_code_from_type_and_notes :: (name: string, type: *Type_Info, notes: []stri print_to_builder(*builder, "r.h = ui_h(7,0);\n"); print_to_builder(*builder, "{\n"); print_to_builder(*builder, "action, _, text_state := GR.text_input(r, value.%, *theme.text_input_theme, autoedit_widget_id(identifier, %));\n", name, index); - print_to_builder(*builder, "if (action & .TEXT_MODIFIED) || (action & .ENTERED) value.% = autoedit_set_text(*value.%, text_state.text);\n", name, name); + print_to_builder(*builder, "if (action & .TEXT_MODIFIED) || (action & .ENTERED) value.% = autoedit_set_text(*value.%, text_state.text); \n", name, name); print_to_builder(*builder, "}\n"); } else if type == type_info(Vector3) { if autoconf.kind == .DEFAULT {