paint: cleanup
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
void box_projects_show() {
|
||||
if (box_projects_icon_map != null) {
|
||||
if (box_projects_icon_map != NULL) {
|
||||
string_t_array_t *keys = map_keys(box_projects_icon_map);
|
||||
for (i32 i = 0; i < keys->length; ++i) {
|
||||
string_t *handle = keys->buffer[i];
|
||||
char *handle = keys->buffer[i];
|
||||
data_delete_image(handle);
|
||||
}
|
||||
gc_unroot(box_projects_icon_map);
|
||||
box_projects_icon_map = null;
|
||||
box_projects_icon_map = NULL;
|
||||
}
|
||||
|
||||
bool draggable;
|
||||
@@ -16,7 +16,7 @@ void box_projects_show() {
|
||||
draggable = true;
|
||||
#endif
|
||||
|
||||
ui_box_show_custom(&box_projects_show_74688, 600, 400, null, draggable, "");
|
||||
ui_box_show_custom(&box_projects_show_74688, 600, 400, NULL, draggable, "");
|
||||
}
|
||||
|
||||
void box_projects_show_74688() {
|
||||
@@ -33,27 +33,27 @@ void box_projects_show_74688() {
|
||||
}
|
||||
|
||||
void box_projects_tab() {
|
||||
if (ui_tab(box_projects_htab, tr("Projects", null), true, -1, false)) {
|
||||
if (ui_tab(box_projects_htab, tr("Projects", NULL), true, -1, false)) {
|
||||
ui_begin_sticky();
|
||||
|
||||
ui_separator(UI_ELEMENT_H(), false);
|
||||
|
||||
box_projects_draw_badge();
|
||||
|
||||
if (ui_icon_button(tr("New", null), ICON_PLUS, UI_ALIGN_CENTER)) {
|
||||
if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) {
|
||||
project_new(true);
|
||||
ui_box_hide();
|
||||
// Pick unique name
|
||||
i32 i = 0;
|
||||
i32 j = 0;
|
||||
string_t *title = string_join(string_join("", tr("untitled", null)), i32_to_string(i));
|
||||
char *title = string_join(string_join("", tr("untitled", NULL)), i32_to_string(i));
|
||||
while (j < config_raw->recent_projects->length) {
|
||||
string_t *base = config_raw->recent_projects->buffer[j];
|
||||
char *base = config_raw->recent_projects->buffer[j];
|
||||
base = string_copy(substring(base, string_last_index_of(base, PATH_SEP) + 1, string_last_index_of(base, ".")));
|
||||
j++;
|
||||
if (string_equals(title, base)) {
|
||||
i++;
|
||||
title = string_join(string_join("", tr("untitled", null)), i32_to_string(i));
|
||||
title = string_join(string_join("", tr("untitled", NULL)), i32_to_string(i));
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
@@ -95,29 +95,29 @@ void box_projects_tab() {
|
||||
continue;
|
||||
}
|
||||
|
||||
string_t *path = recent_projects->buffer[i];
|
||||
char *path = recent_projects->buffer[i];
|
||||
|
||||
#ifdef IRON_IOS
|
||||
string_t *document_directory = iron_save_dialog("", "");
|
||||
char *document_directory = iron_save_dialog("", "");
|
||||
document_directory = string_copy(substring(document_directory, 0, string_length(document_directory) - 8)); // Strip /"untitled"
|
||||
path = string_join(document_directory, path);
|
||||
#endif
|
||||
|
||||
string_t *icon_path = string_join(substring(path, 0, string_length(path) - 4), "_icon.png");
|
||||
if (box_projects_icon_map == null) {
|
||||
char *icon_path = string_join(substring(path, 0, string_length(path) - 4), "_icon.png");
|
||||
if (box_projects_icon_map == NULL) {
|
||||
gc_unroot(box_projects_icon_map);
|
||||
box_projects_icon_map = any_map_create();
|
||||
gc_root(box_projects_icon_map);
|
||||
}
|
||||
gpu_texture_t *icon = any_map_get(box_projects_icon_map, icon_path);
|
||||
if (icon == null) {
|
||||
if (icon == NULL) {
|
||||
gpu_texture_t *image = data_get_image(icon_path);
|
||||
icon = image;
|
||||
any_map_set(box_projects_icon_map, icon_path, icon);
|
||||
}
|
||||
|
||||
i32 uix = ui->_x;
|
||||
if (icon != null) {
|
||||
if (icon != NULL) {
|
||||
ui_fill(0, 0, 128, 128, ui->ops->theme->SEPARATOR_COL);
|
||||
|
||||
i32 state = ui_image(icon, 0xffffffff, 128 * UI_SCALE());
|
||||
@@ -127,12 +127,12 @@ void box_projects_tab() {
|
||||
ui_fill(0, 0, 128, 128, 0x66000000);
|
||||
ui->_x = _uix;
|
||||
#if defined(IRON_ANDROID) || defined(IRON_IOS)
|
||||
console_toast(tr("Opening project", null));
|
||||
console_toast(tr("Opening project", NULL));
|
||||
#endif
|
||||
sys_notify_on_next_frame(&box_projects_tab_75329, path);
|
||||
}
|
||||
|
||||
string_t *name = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_last_index_of(path, "."));
|
||||
char *name = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_last_index_of(path, "."));
|
||||
if (ui->is_hovered && ui->input_released_r) {
|
||||
gc_unroot(_box_projects_path);
|
||||
_box_projects_path = string_copy(path);
|
||||
@@ -174,7 +174,7 @@ void box_projects_tab() {
|
||||
void box_projects_tab_75419(any _) {
|
||||
iron_delete_file(_box_projects_path);
|
||||
iron_delete_file(_box_projects_icon_path);
|
||||
string_t *data_path = substring(_box_projects_path, 0, string_length(_box_projects_path) - 4);
|
||||
char *data_path = substring(_box_projects_path, 0, string_length(_box_projects_path) - 4);
|
||||
iron_delete_file(data_path);
|
||||
string_t_array_t *recent_projects = config_raw->recent_projects;
|
||||
array_splice(recent_projects, _box_projects_i, 1);
|
||||
@@ -182,32 +182,32 @@ void box_projects_tab_75419(any _) {
|
||||
|
||||
void box_projects_tab_75398() {
|
||||
// if (ui_menu_button(tr("Duplicate"), "", icon_t.DUPLICATE)) {}
|
||||
if (ui_menu_button(tr("Delete", null), "", ICON_DELETE)) {
|
||||
sys_notify_on_next_frame(&box_projects_tab_75419, null);
|
||||
if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) {
|
||||
sys_notify_on_next_frame(&box_projects_tab_75419, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void box_projects_tab_75329(string_t *path) {
|
||||
void box_projects_tab_75329(char *path) {
|
||||
ui_box_hide();
|
||||
import_arm_run_project(path);
|
||||
}
|
||||
|
||||
void box_projects_recent_tab() {
|
||||
if (ui_tab(box_projects_htab, tr("Recent", null), true, -1, false)) {
|
||||
if (ui_tab(box_projects_htab, tr("Recent", NULL), true, -1, false)) {
|
||||
|
||||
box_projects_draw_badge();
|
||||
|
||||
ui->enabled = config_raw->recent_projects->length > 0;
|
||||
box_projects_hsearch->text = string_copy(ui_text_input(box_projects_hsearch, tr("Search", null), UI_ALIGN_LEFT, true, true));
|
||||
box_projects_hsearch->text = string_copy(ui_text_input(box_projects_hsearch, tr("Search", NULL), UI_ALIGN_LEFT, true, true));
|
||||
ui->enabled = true;
|
||||
for (i32 i = 0; i < config_raw->recent_projects->length; ++i) {
|
||||
string_t *path = config_raw->recent_projects->buffer[i];
|
||||
char *path = config_raw->recent_projects->buffer[i];
|
||||
#ifdef IRON_WINDOWS
|
||||
path = string_copy(string_replace_all(path, "/", "\\"));
|
||||
#else
|
||||
path = string_copy(string_replace_all(path, "\\", "/"));
|
||||
#endif
|
||||
string_t *file = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_length(path));
|
||||
char *file = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_length(path));
|
||||
|
||||
if (string_index_of(to_lower_case(file), to_lower_case(box_projects_hsearch->text)) < 0) {
|
||||
continue; // Search filter
|
||||
@@ -230,17 +230,17 @@ void box_projects_recent_tab() {
|
||||
}
|
||||
|
||||
ui->enabled = config_raw->recent_projects->length > 0;
|
||||
if (ui_icon_button(tr("Clear", null), ICON_ERASE, UI_ALIGN_LEFT)) {
|
||||
if (ui_icon_button(tr("Clear", NULL), ICON_ERASE, UI_ALIGN_LEFT)) {
|
||||
config_raw->recent_projects = any_array_create_from_raw((any[]){}, 0);
|
||||
config_save();
|
||||
}
|
||||
ui->enabled = true;
|
||||
|
||||
ui_end_element();
|
||||
if (ui_icon_button(tr("New Project...", null), ICON_FILE_NEW, UI_ALIGN_LEFT)) {
|
||||
if (ui_icon_button(tr("New Project...", NULL), ICON_FILE_NEW, UI_ALIGN_LEFT)) {
|
||||
project_new_box();
|
||||
}
|
||||
if (ui_icon_button(tr("Open...", null), ICON_FOLDER_OPEN, UI_ALIGN_LEFT)) {
|
||||
if (ui_icon_button(tr("Open...", NULL), ICON_FOLDER_OPEN, UI_ALIGN_LEFT)) {
|
||||
project_open();
|
||||
}
|
||||
}
|
||||
@@ -253,17 +253,17 @@ void box_projects_draw_badge() {
|
||||
}
|
||||
|
||||
void box_projects_get_started_tab() {
|
||||
if (ui_tab(box_projects_htab, tr("Get Started", null), true, -1, false)) {
|
||||
if (ui_tab(box_projects_htab, tr("Get Started", NULL), true, -1, false)) {
|
||||
|
||||
ui_separator(UI_ELEMENT_H(), false);
|
||||
|
||||
if (ui_icon_button(tr("Manual", null), ICON_HELP, UI_ALIGN_CENTER)) {
|
||||
if (ui_icon_button(tr("Manual", NULL), ICON_HELP, UI_ALIGN_CENTER)) {
|
||||
iron_load_url(string_join(manifest_url, "/manual"));
|
||||
}
|
||||
if (ui_icon_button(tr("How To", null), ICON_HELP, UI_ALIGN_CENTER)) {
|
||||
if (ui_icon_button(tr("How To", NULL), ICON_HELP, UI_ALIGN_CENTER)) {
|
||||
iron_load_url(string_join(manifest_url, "/howto"));
|
||||
}
|
||||
if (ui_icon_button(tr("What's New", null), ICON_LINK, UI_ALIGN_CENTER)) {
|
||||
if (ui_icon_button(tr("What's New", NULL), ICON_LINK, UI_ALIGN_CENTER)) {
|
||||
iron_load_url(string_join(manifest_url, "/notes"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user