paint: text import fixes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user