This commit is contained in:
luboslenco
2025-09-08 15:15:40 +02:00
parent 01bc405878
commit fb23a24566
5 changed files with 6 additions and 122 deletions
-90
View File
@@ -2565,9 +2565,6 @@ void ui_theme_default(ui_theme_t *t) {
}
#define MATH_PI 3.14159265358979323846
static char data_path[128] = "";
static char last_path[512];
static ui_handle_t *wheel_selected_handle = NULL;
static ui_handle_t *gradient_selected_handle = NULL;
static ui_handle_t radio_handle;
@@ -2641,93 +2638,6 @@ float ui_float_input(ui_handle_t *handle, char *label, int align, float precisio
return handle->value;
}
void ui_init_path(ui_handle_t *handle, const char *system_id) {
strcpy(handle->text, strcmp(system_id, "Windows") == 0 ? "C:\\Users" : "/");
// %HOMEDRIVE% + %HomePath%
// ~
}
char *ui_file_browser(ui_handle_t *handle, bool folders_only) {
ui_t *current = ui_get_current();
const char *sep = "/";
char cmd[64];
strcpy(cmd, "ls ");
const char *system_id = iron_system_id();
if (strcmp(system_id, "Windows") == 0) {
strcpy(cmd, "dir /b ");
if (folders_only) {
strcat(cmd, "/ad ");
}
sep = "\\";
handle->text = string_replace_all(handle->text, "\\\\", "\\");
handle->text = string_replace_all(handle->text, "\r", "");
}
if (handle->text[0] == '\0') {
ui_init_path(handle, system_id);
}
char save[256];
strcpy(save, iron_internal_get_files_location());
strcat(save, sep);
strcat(save, data_path);
strcat(save, "dir.txt");
if (strcmp(handle->text, last_path) != 0) {
char str[512];
strcpy(str, cmd);
strcat(str, "\"");
strcat(str, handle->text);
strcat(str, "\" > \"");
strcat(str, save);
strcat(str, "\"");
}
strcpy(last_path, handle->text);
iron_file_reader_t reader;
if (!iron_file_reader_open(&reader, save, IRON_FILE_TYPE_ASSET)) {
return NULL;
}
int reader_size = (int)iron_file_reader_size(&reader);
char str[2048]; // reader_size
iron_file_reader_read(&reader, str, reader_size);
iron_file_reader_close(&reader);
// Up directory
int i1 = strstr(handle->text, "/") - handle->text;
int i2 = strstr(handle->text, "\\") - handle->text;
bool nested =
(i1 > -1 && strlen(handle->text) - 1 > i1) ||
(i2 > -1 && strlen(handle->text) - 1 > i2);
handle->changed = false;
if (nested && ui_button("..", UI_ALIGN_LEFT, "")) {
handle->changed = current->changed = true;
handle->text[strrchr(handle->text, sep[0]) - handle->text] = 0;
// Drive root
if (strlen(handle->text) == 2 && handle->text[1] == ':') {
strcat(handle->text, sep);
}
}
// Directory contents
int count = ui_line_count(str);
for (int i = 0; i < count; ++i) {
char *f = ui_extract_line(str, i);
if (f[0] == '\0' || f[0] == '.') {
continue; // Skip hidden
}
if (ui_button(f, UI_ALIGN_LEFT, "")) {
handle->changed = current->changed = true;
if (handle->text[strlen(handle->text) - 1] != sep[0]) {
strcat(handle->text, sep);
}
strcat(handle->text, f);
}
}
return handle->text;
}
int ui_inline_radio(ui_handle_t *handle, char_ptr_array_t *texts, int align) {
ui_t *current = ui_get_current();
-1
View File
@@ -377,7 +377,6 @@ extern const char *ui_theme_keys[];
extern int ui_theme_keys_count;
float ui_float_input(ui_handle_t *handle, char *label, int align, float precision);
char *ui_file_browser(ui_handle_t *handle, bool folders_only);
int ui_inline_radio(ui_handle_t *handle, char_ptr_array_t *texts, int align);
int ui_color_wheel(ui_handle_t *handle, bool alpha, float w, float h, bool color_preview, void (*picker)(void *), void *data);
char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, bool word_wrap);
+1 -6
View File
@@ -136,11 +136,6 @@ function file_download_bytes(url: string, done: (url: string, ab: buffer_t)=>voi
}
function file_cache_cloud(path: string, done: (s: string)=>void) {
///if arm_ios
let path2: string = string_replace_all(path, "/", "_"); // Cache everything into root folder
///else
let path2: string = path;
///end
let dest: string;
if (path_is_protected()) {
dest = iron_internal_save_path();
@@ -148,7 +143,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) {
else {
dest = iron_get_files_location() + path_sep;
}
dest += path2;
dest += path;
if (iron_file_exists(dest)) {
///if (arm_macos || arm_ios)