paint: text import fixes

This commit is contained in:
luboslenco
2026-07-17 10:25:41 +02:00
parent 606a2f62d7
commit bf514afbe4
9 changed files with 102 additions and 36 deletions
+3
View File
@@ -63,6 +63,9 @@ void import_asset_run(char *path, f32 drop_x, f32 drop_y, bool show_box, bool hd
g_context->ddirty = 2;
}
}
else if (path_is_text(path)) {
import_text_run(path);
}
else if (path_is_sound(path)) {
import_sound_run(path);
}
+28
View File
@@ -0,0 +1,28 @@
#include "../global.h"
void import_text_default_importer(char *path) {
buffer_t *b = data_get_blob(path);
if (b == NULL) {
console_error(strings_unknown_asset_format());
return;
}
string_array_t *ar = string_split(path, PATH_SEP);
char *name = ar->buffer[ar->length - 1];
ui_box_show_message(name, sys_buffer_to_string(b), true);
data_delete_blob(path);
}
void import_text_run(char *path) {
char *ext = substring(path, string_last_index_of(path, ".") + 1, string_length(path));
void (*importer)(char *path) = any_map_get(import_text_importers, ext);
if (importer == NULL) {
import_text_default_importer(path);
return;
}
importer(path);
}