base: text import fixes
This commit is contained in:
@@ -780,9 +780,6 @@ gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, char *forma
|
||||
if (data == NULL || data->length == 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (ends_with(format, "txt")) { // plugin
|
||||
return NULL;
|
||||
}
|
||||
gpu_texture_t *texture = (gpu_texture_t *)malloc(sizeof(gpu_texture_t));
|
||||
texture->buffer = NULL;
|
||||
unsigned char *texture_data;
|
||||
|
||||
@@ -15,6 +15,7 @@ bool path_is_protected_linux = false;
|
||||
string_array_t *_path_mesh_formats = NULL;
|
||||
string_array_t *_path_texture_formats = NULL;
|
||||
string_array_t *_path_sound_formats = NULL;
|
||||
string_array_t *_path_text_formats = NULL;
|
||||
static string_array_t *_path_base_color_ext = NULL;
|
||||
static string_array_t *_path_opacity_ext = NULL;
|
||||
static string_array_t *_path_normal_map_ext = NULL;
|
||||
@@ -60,6 +61,16 @@ string_array_t *path_sound_formats(void) {
|
||||
return _path_sound_formats;
|
||||
}
|
||||
|
||||
string_array_t *path_text_formats(void) {
|
||||
if (_path_text_formats == NULL) {
|
||||
_path_text_formats = string_array_create(0);
|
||||
gc_root(_path_text_formats);
|
||||
string_array_push(_path_text_formats, "txt");
|
||||
string_array_push(_path_text_formats, "json");
|
||||
}
|
||||
return _path_text_formats;
|
||||
}
|
||||
|
||||
string_array_t *path_base_color_ext(void) {
|
||||
if (_path_base_color_ext == NULL) {
|
||||
_path_base_color_ext = string_array_create(0);
|
||||
@@ -288,8 +299,16 @@ bool path_is_json(char *path) {
|
||||
}
|
||||
|
||||
bool path_is_text(char *path) {
|
||||
char *p = to_lower_case(path);
|
||||
return ends_with(p, ".txt");
|
||||
char *p = to_lower_case(path);
|
||||
string_array_t *formats = path_text_formats();
|
||||
for (uint32_t i = 0; i < formats->length; ++i) {
|
||||
char *s = formats->buffer[i];
|
||||
char *ext = string(".%s", s);
|
||||
if (ends_with(p, ext)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool path_is_ext_format(char *path) {
|
||||
|
||||
@@ -17,6 +17,7 @@ extern bool path_is_protected_linux;
|
||||
|
||||
string_array_t *path_mesh_formats(void);
|
||||
string_array_t *path_texture_formats(void);
|
||||
string_array_t *path_text_formats(void);
|
||||
|
||||
char *path_data(void);
|
||||
char *path_to_relative(char *from, char *to);
|
||||
|
||||
Reference in New Issue
Block a user