trile editing fixes

This commit is contained in:
Tuomas Katajisto 2026-03-02 20:48:50 +02:00
parent 3a7f19c89d
commit 629af83d9b
2 changed files with 16 additions and 0 deletions

View File

@ -268,6 +268,7 @@ draw_tool_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
r.y += r.h * 2; r.y += r.h * 2;
if GR.button(r, "Save and gen", *theme.button_theme) { if GR.button(r, "Save and gen", *theme.button_theme) {
set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile)); set_trile_gfx(editor_current_trile.name, generate_trile_gfx_matias(editor_current_trile));
striles();
}; };
} }

View File

@ -58,7 +58,22 @@ set_trile_gfx :: (name: string, gfx: Trile_GFX, skip_preexist_check: bool = fals
set_trile :: (name: string, trile: Trile) { set_trile :: (name: string, trile: Trile) {
print("Setting trile with name: %\n",name); print("Setting trile with name: %\n",name);
// Destroy and remove any cached GFX so it gets regenerated from new data.
gfx_exists, old_gfx := table_find(*trile_gfx_table, name);
if gfx_exists {
sg_destroy_buffer(old_gfx.vertex_buffer);
sg_destroy_buffer(old_gfx.normal_buffer);
sg_destroy_buffer(old_gfx.centre_buffer);
sg_destroy_image(old_gfx.trixel_colors);
array_reset(*old_gfx.vertices);
table_remove(*trile_gfx_table, name);
}
saved_editor_name: string;
if editor_current_trile then saved_editor_name = editor_current_trile.name;
table_set(*trile_table, name, trile); table_set(*trile_table, name, trile);
if saved_editor_name.count > 0 {
editor_current_trile = table_find_pointer(*trile_table, saved_editor_name);
}
} }
get_trile :: (name: string) -> (*Trile, success: bool) { get_trile :: (name: string) -> (*Trile, success: bool) {