diff --git a/paint/sources/args.c b/paint/sources/args.c index 45ae20ea..eedb0680 100644 --- a/paint/sources/args.c +++ b/paint/sources/args.c @@ -65,17 +65,11 @@ void args_parse() { } } -void args_run() { - if (args_use) { - sys_notify_on_next_frame(&args_run_115314, NULL); - } -} - -void args_run_115626(void *_) { +void args_run_export_queue(void *_) { export_texture_run(args_export_textures_path, false); } -void args_run_115314(void *_) { +void args_run_on_next_frame(void *_) { if (!string_equals(project_filepath, "")) { import_arm_run_project(project_filepath); } @@ -138,7 +132,7 @@ void args_run_115314(void *_) { data_delete_blob(string_join("export_presets/", file)); // Export queue - sys_notify_on_next_frame(&args_run_115626, NULL); + sys_notify_on_next_frame(&args_run_export_queue, NULL); } else if (args_export_mesh) { if (!path_is_folder(args_export_mesh_path)) { @@ -160,3 +154,9 @@ void args_run_115314(void *_) { iron_stop(); } } + +void args_run() { + if (args_use) { + sys_notify_on_next_frame(&args_run_on_next_frame, NULL); + } +} diff --git a/paint/sources/base.c b/paint/sources/base.c index 799499f2..a1178024 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -1,12 +1,40 @@ #include "global.h" +void base_on_shutdown() { + #if defined(IRON_ANDROID) || defined(IRON_IOS) + project_save(false); + #endif + config_save(); +} + +void base_on_background() { + // Release keys after alt-tab / win-tab + _key_up(KEY_CODE_ALT, NULL); + _key_up(KEY_CODE_WIN, NULL); +} + +void base_on_pause() {} + +void base_on_resume() {} + +void base_on_foreground() { + context_raw->foreground_event = true; + context_raw->last_paint_x = -1; + context_raw->last_paint_y = -1; +} + +void base_on_drop_files(char *drop_path) { + drop_path = string_copy(trim_end(drop_path)); + any_array_push(base_drop_paths, drop_path); +} + void base_init() { base_last_window_width = iron_window_width(); base_last_window_height = iron_window_height(); - sys_notify_on_drop_files(&base_init_47689); - sys_notify_on_app_state(&base_init_47715, &base_init_47733, &base_init_47739, &base_init_47745, &base_init_47765); + sys_notify_on_drop_files(&base_on_drop_files); + sys_notify_on_app_state(&base_on_foreground, &base_on_resume, &base_on_pause, &base_on_background, &base_on_shutdown); iron_set_save_and_quit_callback(base_save_and_quit_callback); gc_unroot(base_font); @@ -82,34 +110,6 @@ void base_init() { } } -void base_init_47765() { // Shutdown - #if defined(IRON_ANDROID) || defined(IRON_IOS) - project_save(false); - #endif - config_save(); -} - -void base_init_47745() { // Background - // Release keys after alt-tab / win-tab - _key_up(KEY_CODE_ALT, NULL); - _key_up(KEY_CODE_WIN, NULL); -} - -void base_init_47739() {} // Pause - -void base_init_47733() {} // Resume - -void base_init_47715() { // Foreground - context_raw->foreground_event = true; - context_raw->last_paint_x = -1; - context_raw->last_paint_y = -1; -} - -void base_init_47689(char *drop_path) { - drop_path = string_copy(trim_end(drop_path)); - any_array_push(base_drop_paths, drop_path); -} - void base_save_and_quit_callback(bool save) { base_save_window_rect(); if (save) { @@ -269,6 +269,16 @@ void base_resize() { base_redraw_ui(); } +void base_update_import_asset_done() { + // Asset was material + if (project_materials->length > _base_material_count) { + gc_unroot(base_drag_material); + base_drag_material = context_raw->material; + gc_root(base_drag_material); + base_material_dropped(); + } +} + void base_update(void *_) { if (mouse_movement_x != 0 || mouse_movement_y != 0) { iron_mouse_set_cursor(IRON_CURSOR_ARROW); @@ -364,7 +374,7 @@ void base_update(void *_) { base_drop_y = mouse_y; _base_material_count = project_materials->length; - import_asset_run(base_drag_file, base_drop_x, base_drop_y, true, true, &base_update_49189); + import_asset_run(base_drag_file, base_drop_x, base_drop_y, true, true, &base_update_import_asset_done); } gc_unroot(base_drag_file); @@ -413,16 +423,6 @@ void base_update(void *_) { compass_update(); } -void base_update_49189() { - // Asset was material - if (project_materials->length > _base_material_count) { - gc_unroot(base_drag_material); - base_drag_material = context_raw->material; - gc_root(base_drag_material); - base_material_dropped(); - } -} - void base_material_dropped() { // Material drag and dropped onto viewport or layers tab if (context_in_3d_view()) { @@ -751,6 +751,10 @@ tab_draw_array_t_array_t *ui_base_init_hwnd_tabs() { return r; } +void ui_base_init_on_next_frame(void * _) { + layers_init(); +} + void ui_base_init() { ui_toolbar_init(); context_raw->text_tool_text = string_copy(tr("Text", NULL)); @@ -822,7 +826,7 @@ void ui_base_init() { project_new(false); if (string_equals(project_filepath, "")) { - sys_notify_on_next_frame(&ui_base_init_51221, NULL); + sys_notify_on_next_frame(&ui_base_init_on_next_frame, NULL); } context_raw->project_objects = any_array_create_from_raw((void *[]){}, 0); @@ -834,8 +838,71 @@ void ui_base_init() { operator_register("view_top", ui_base_view_top); } -void ui_base_init_51221(void * _) { - layers_init(); +void ui_base_menu_draw_viewport_mode() { + ui_handle_t *mode_handle = ui_handle(__ID__); + mode_handle->i = context_raw->viewport_mode; + ui_text(tr("Viewport Mode", NULL), UI_ALIGN_RIGHT, 0x00000000); + + string_t_array_t *modes = any_array_create_from_raw( + (void *[]){ + tr("Lit", NULL), + tr("Base Color", NULL), + tr("Normal", NULL), + tr("Occlusion", NULL), + tr("Roughness", NULL), + tr("Metallic", NULL), + tr("Opacity", NULL), + tr("Height", NULL), + tr("Emission", NULL), + tr("Subsurface", NULL), + tr("TexCoord", NULL), + tr("Object Normal", NULL), + tr("Material ID", NULL), + tr("Object ID", NULL), + tr("Mask", NULL), + }, + 15); + string_t_array_t *shortcuts = any_array_create_from_raw( + (void *[]){ + "l", + "b", + "n", + "o", + "r", + "m", + "a", + "h", + "e", + "s", + "t", + "1", + "2", + "3", + "4", + }, + 15); + if (gpu_raytrace_supported()) { + any_array_push(modes, tr("Path Traced", NULL)); + any_array_push(shortcuts, "p"); + } + for (i32 i = 0; i < modes->length; ++i) { + ui_radio(mode_handle, i, modes->buffer[i], shortcuts->buffer[i]); + } + + i32 index = char_ptr_array_index_of(shortcuts, keyboard_key_code(ui->key_code)); + if (ui->is_key_pressed && index != -1) { + mode_handle->i = index; + ui->changed = true; + context_set_viewport_mode(mode_handle->i); + } + else if (mode_handle->changed) { + context_set_viewport_mode(mode_handle->i); + ui->changed = true; + } +} + +void ui_base_update_51603(void * _) { + export_texture_run(context_raw->texture_export_path, false); } void ui_base_update(void * _) { @@ -1131,7 +1198,7 @@ void ui_base_update(void * _) { } else if (operator_shortcut(any_map_get(config_keymap, "viewport_mode"), SHORTCUT_TYPE_STARTED)) { ui->is_key_pressed = false; - ui_menu_draw(&ui_base_update_53274, -1, -1); + ui_menu_draw(&ui_base_menu_draw_viewport_mode, -1, -1); } } if (operator_shortcut(any_map_get(config_keymap, "operator_search"), SHORTCUT_TYPE_STARTED)) { @@ -1255,9 +1322,11 @@ void ui_base_update(void * _) { ray_t *ray = raycast_get_ray(mouse_view_x(), mouse_view_y(), camera); physics_body_apply_impulse(body, vec4_mult(ray->dir, 0.15)); - context_raw->particle_timer = tween_timer(5, &ui_base_update_54293, mo); + context_raw->particle_timer = tween_timer(5, &mesh_object_remove, mo); } + #ifdef arm_physics + physics_pair_t_array_t *pairs = physics_world_get_contact_pairs(world, context_raw->paint_body); if (pairs != NULL) { for (i32 i = 0; i < pairs->length; ++i) { @@ -1272,78 +1341,9 @@ void ui_base_update(void * _) { break; // 1 pair for now } } - } -} -void ui_base_update_54293(mesh_object_t *mo) { - mesh_object_remove(mo); -} - -void ui_base_update_53274() { - ui_handle_t *mode_handle = ui_handle(__ID__); - mode_handle->i = context_raw->viewport_mode; - ui_text(tr("Viewport Mode", NULL), UI_ALIGN_RIGHT, 0x00000000); - - string_t_array_t *modes = any_array_create_from_raw( - (void *[]){ - tr("Lit", NULL), - tr("Base Color", NULL), - tr("Normal", NULL), - tr("Occlusion", NULL), - tr("Roughness", NULL), - tr("Metallic", NULL), - tr("Opacity", NULL), - tr("Height", NULL), - tr("Emission", NULL), - tr("Subsurface", NULL), - tr("TexCoord", NULL), - tr("Object Normal", NULL), - tr("Material ID", NULL), - tr("Object ID", NULL), - tr("Mask", NULL), - }, - 15); - string_t_array_t *shortcuts = any_array_create_from_raw( - (void *[]){ - "l", - "b", - "n", - "o", - "r", - "m", - "a", - "h", - "e", - "s", - "t", - "1", - "2", - "3", - "4", - }, - 15); - if (gpu_raytrace_supported()) { - any_array_push(modes, tr("Path Traced", NULL)); - any_array_push(shortcuts, "p"); + #endif } - for (i32 i = 0; i < modes->length; ++i) { - ui_radio(mode_handle, i, modes->buffer[i], shortcuts->buffer[i]); - } - - i32 index = char_ptr_array_index_of(shortcuts, keyboard_key_code(ui->key_code)); - if (ui->is_key_pressed && index != -1) { - mode_handle->i = index; - ui->changed = true; - context_set_viewport_mode(mode_handle->i); - } - else if (mode_handle->changed) { - context_set_viewport_mode(mode_handle->i); - ui->changed = true; - } -} - -void ui_base_update_51603(void * _) { - export_texture_run(context_raw->texture_export_path, false); } void ui_base_view_top() { @@ -1356,12 +1356,7 @@ void ui_base_view_top() { } } -void ui_base_operator_search() { - _ui_base_operator_search_first = true; - ui_menu_draw(&ui_base_operator_search_54472, -1, -1); -} - -void ui_base_operator_search_54472() { +void ui_base_operator_search_menu_draw() { ui_menu_h = UI_ELEMENT_H() * 8; ui_handle_t *search_handle = ui_handle(__ID__); char *search = ui_text_input(search_handle, "", UI_ALIGN_LEFT, true, true); @@ -1413,6 +1408,11 @@ void ui_base_operator_search_54472() { ui->ops->theme->BUTTON_COL = BUTTON_COL; } +void ui_base_operator_search() { + _ui_base_operator_search_first = true; + ui_menu_draw(&ui_base_operator_search_menu_draw, -1, -1); +} + void ui_base_toggle_distract_free() { ui_base_show = !ui_base_show; base_resize(); @@ -1436,6 +1436,11 @@ rect_t *ui_base_get_brush_stencil_rect() { return r; } +void ui_base_update_ui_on_next_frame(void * _) { + layers_update_fill_layer(true); + make_material_parse_paint_material(false); +} + void ui_base_update_ui() { if (console_message_timer > 0) { console_message_timer -= sys_delta(); @@ -1618,7 +1623,7 @@ void ui_base_update_ui() { // New color id picked, update fill layer if (context_raw->tool == TOOL_TYPE_COLORID && context_raw->layer->fill_layer != NULL) { - sys_notify_on_next_frame(&ui_base_update_ui_56026, NULL); + sys_notify_on_next_frame(&ui_base_update_ui_on_next_frame, NULL); } } @@ -1699,11 +1704,6 @@ void ui_base_update_ui() { gizmo_update(); } -void ui_base_update_ui_56026(void * _) { - layers_update_fill_layer(true); - make_material_parse_paint_material(false); -} - void ui_base_render(void * _) { if (!ui_base_show && config_raw->touch_ui) { ui->input_enabled = true; diff --git a/paint/sources/box_export.c b/paint/sources/box_export.c index 6e294abb..adeb59f2 100644 --- a/paint/sources/box_export.c +++ b/paint/sources/box_export.c @@ -1,11 +1,7 @@ #include "global.h" -void box_export_show_textures() { - ui_box_show_custom(&box_export_show_textures_34135, 600, 400, NULL, true, tr("Export", NULL)); -} - -void box_export_show_textures_34135() { +void box_export_show_textures_box() { if (box_export_files == NULL) { box_export_fetch_presets(); box_export_hpreset->i = char_ptr_array_index_of(box_export_files, "generic"); @@ -24,11 +20,11 @@ void box_export_show_textures_34135() { #endif } -void box_export_show_bake_material() { - ui_box_show_custom(&box_export_show_bake_material_34221, 600, 400, NULL, true, tr("Export", NULL)); +void box_export_show_textures() { + ui_box_show_custom(&box_export_show_textures_box, 600, 400, NULL, true, tr("Export", NULL)); } -void box_export_show_bake_material_34221() { +void box_export_show_bake_material_box() { if (box_export_files == NULL) { box_export_fetch_presets(); box_export_hpreset->i = char_ptr_array_index_of(box_export_files, "generic"); @@ -42,6 +38,26 @@ void box_export_show_bake_material_34221() { box_export_tab_presets(); } +void box_export_show_bake_material() { + ui_box_show_custom(&box_export_show_bake_material_box, 600, 400, NULL, true, tr("Export", NULL)); +} + +void box_export_tab_export_textures_run(void * _) { + export_texture_run(context_raw->texture_export_path, _box_export_bake_material); +} + +void box_export_tab_export_textures_path_picked(char *path) { + context_raw->texture_export_path = string_copy(path); + #if defined(IRON_ANDROID) || defined(IRON_IOS) + console_toast(tr("Exporting textures", NULL)); + #endif + sys_notify_on_next_frame(&box_export_tab_export_textures_run, NULL); +} + +void box_export_tab_export_textures_on_next_frame(void * _) { + layers_set_bits(); +} + void box_export_tab_export_textures(char *title, bool bake_material) { bool tab_vertical = config_raw->touch_ui; if (ui_tab(box_export_htab, title, tab_vertical, -1, false)) { @@ -97,7 +113,7 @@ void box_export_tab_export_textures(char *title, bool bake_material) { ui_combo(base_bits_handle, base_bits_combo, tr("Color", NULL), true, UI_ALIGN_LEFT, true); if (base_bits_handle->changed) { - sys_notify_on_next_frame(&box_export_tab_export_textures_34447, NULL); + sys_notify_on_next_frame(&box_export_tab_export_textures_on_next_frame, NULL); } ui_row2(); @@ -180,12 +196,12 @@ void box_export_tab_export_textures(char *title, bool bake_material) { if (context_raw->layers_destination == EXPORT_DESTINATION_PACK_INTO_PROJECT) { _box_export_bake_material = bake_material; context_raw->texture_export_path = "/"; - sys_notify_on_next_frame(&box_export_tab_export_textures_34832, NULL); + sys_notify_on_next_frame(&box_export_tab_export_textures_run, NULL); } else { char *filters = base_bits_handle->i != TEXTURE_BITS_BITS8 ? "exr" : context_raw->format_type == TEXTURE_LDR_FORMAT_PNG ? "png" : "jpg"; _box_export_bake_material = bake_material; - ui_files_show(filters, true, false, &box_export_tab_export_textures_34883); + ui_files_show(filters, true, false, &box_export_tab_export_textures_path_picked); } } if (ui->is_hovered) { @@ -196,24 +212,50 @@ void box_export_tab_export_textures(char *title, bool bake_material) { } } -void box_export_tab_export_textures_34904(void * _) { - export_texture_run(context_raw->texture_export_path, _box_export_bake_material); +void box_export_tab_presets_menu_draw() { + if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { + array_remove(box_export_preset->textures, _box_export_t); + box_export_save_preset(); + } } -void box_export_tab_export_textures_34883(char *path) { - context_raw->texture_export_path = string_copy(path); - #if defined(IRON_ANDROID) || defined(IRON_IOS) - console_toast(tr("Exporting textures", NULL)); - #endif - sys_notify_on_next_frame(&box_export_tab_export_textures_34904, NULL); +void box_export_tab_presets_import(char *path) { + path = string_copy(to_lower_case(path)); + if (ends_with(path, ".json")) { + char *filename = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_length(path)); + char *dst_path = string_join(string_join(string_join(string_join(path_data(), PATH_SEP), "export_presets"), PATH_SEP), filename); + file_copy(path, dst_path); // Copy to presets folder + box_export_fetch_presets(); + gc_unroot(box_export_preset); + box_export_preset = NULL; + box_export_hpreset->i = char_ptr_array_index_of(box_export_files, substring(filename, 0, string_length(filename) - 5)); // Strip .json + console_info(string_join(string_join(tr("Preset imported:", NULL), " "), filename)); + } + else { + console_error(strings_unknown_asset_format()); + } } -void box_export_tab_export_textures_34832(void * _) { - export_texture_run(context_raw->texture_export_path, _box_export_bake_material); -} - -void box_export_tab_export_textures_34447(void * _) { - layers_set_bits(); +void box_export_tab_presets_new_box() { + bool tab_vertical = config_raw->touch_ui; + if (ui_tab(ui_handle(__ID__), tr("New Preset", NULL), tab_vertical, -1, false)) { + ui_row2(); + ui_handle_t *h_preset = ui_handle(__ID__); + if (h_preset->init) { + h_preset->text = "new_preset"; + } + char *preset_name = ui_text_input(h_preset, tr("Name", NULL), UI_ALIGN_LEFT, true, false); + if (ui_icon_button(tr("OK", NULL), ICON_CHECK, UI_ALIGN_CENTER) || ui->is_return_down) { + box_export_new_preset(preset_name); + box_export_fetch_presets(); + gc_unroot(box_export_preset); + box_export_preset = NULL; + box_export_hpreset->i = char_ptr_array_index_of(box_export_files, preset_name); + ui_box_hide(); + box_export_htab->i = 1; // Presets + box_export_show_textures(); + } + } } void box_export_tab_presets() { @@ -236,11 +278,11 @@ void box_export_tab_presets() { } if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) { - ui_box_show_custom(&box_export_tab_presets_35057, 400, 200, NULL, true, ""); + ui_box_show_custom(&box_export_tab_presets_new_box, 400, 200, NULL, true, ""); } if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { - ui_files_show("json", false, false, &box_export_tab_presets_35201); + ui_files_show("json", false, false, &box_export_tab_presets_import); } if (box_export_preset == NULL) { @@ -269,7 +311,7 @@ void box_export_tab_presets() { gc_unroot(_box_export_t); _box_export_t = t; gc_root(_box_export_t); - ui_menu_draw(&box_export_tab_presets_35468, -1, -1); + ui_menu_draw(&box_export_tab_presets_menu_draw, -1, -1); } ui_handle_t *hr = ui_nest(htex, 0); @@ -334,52 +376,6 @@ void box_export_tab_presets() { } } -void box_export_tab_presets_35468() { - if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { - array_remove(box_export_preset->textures, _box_export_t); - box_export_save_preset(); - } -} - -void box_export_tab_presets_35201(char *path) { - path = string_copy(to_lower_case(path)); - if (ends_with(path, ".json")) { - char *filename = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_length(path)); - char *dst_path = string_join(string_join(string_join(string_join(path_data(), PATH_SEP), "export_presets"), PATH_SEP), filename); - file_copy(path, dst_path); // Copy to presets folder - box_export_fetch_presets(); - gc_unroot(box_export_preset); - box_export_preset = NULL; - box_export_hpreset->i = char_ptr_array_index_of(box_export_files, substring(filename, 0, string_length(filename) - 5)); // Strip .json - console_info(string_join(string_join(tr("Preset imported:", NULL), " "), filename)); - } - else { - console_error(strings_unknown_asset_format()); - } -} - -void box_export_tab_presets_35057() { - bool tab_vertical = config_raw->touch_ui; - if (ui_tab(ui_handle(__ID__), tr("New Preset", NULL), tab_vertical, -1, false)) { - ui_row2(); - ui_handle_t *h_preset = ui_handle(__ID__); - if (h_preset->init) { - h_preset->text = "new_preset"; - } - char *preset_name = ui_text_input(h_preset, tr("Name", NULL), UI_ALIGN_LEFT, true, false); - if (ui_icon_button(tr("OK", NULL), ICON_CHECK, UI_ALIGN_CENTER) || ui->is_return_down) { - box_export_new_preset(preset_name); - box_export_fetch_presets(); - gc_unroot(box_export_preset); - box_export_preset = NULL; - box_export_hpreset->i = char_ptr_array_index_of(box_export_files, preset_name); - ui_box_hide(); - box_export_htab->i = 1; // Presets - box_export_show_textures(); - } - } -} - void box_export_tab_atlases() { bool tab_vertical = config_raw->touch_ui; if (ui_tab(box_export_htab, tr("Atlases", NULL), tab_vertical, -1, false)) { @@ -406,16 +402,44 @@ void box_export_tab_atlases() { } } -void box_export_show_mesh() { - box_export_mesh_handle->i = context_raw->export_mesh_index; - ui_box_show_custom(&box_export_show_mesh_36017, 420, 260, NULL, true, tr("Export", NULL)); -} - -void box_export_show_mesh_36017() { +void box_export_show_mesh_box() { ui_handle_t *htab = ui_handle(__ID__); box_export_tab_export_mesh(htab); } +void box_export_show_mesh() { + box_export_mesh_handle->i = context_raw->export_mesh_index; + ui_box_show_custom(&box_export_show_mesh_box, 420, 260, NULL, true, tr("Export", NULL)); +} + +void box_export_tab_export_mesh_path_picked(char *path) { + #if defined(IRON_ANDROID) || defined(IRON_IOS) + char *f = sys_title(); + #else + char *f = ui_files_filename; + #endif + if (string_equals(f, "")) { + f = string_copy(tr("untitled", NULL)); + } + #if defined(IRON_ANDROID) || defined(IRON_IOS) + console_toast(tr("Exporting mesh", NULL)); + #endif + + mesh_object_t_array_t *paint_objects; + if (box_export_mesh_handle->i == 0) { + paint_objects = NULL; + } + else { + mesh_object_t *po = project_paint_objects->buffer[box_export_mesh_handle->i - 1]; + paint_objects = any_array_create_from_raw( + (void *[]){ + po, + }, + 1); + } + export_mesh_run(string_join(string_join(path, PATH_SEP), f), paint_objects, _box_export_apply_displacement, _box_export_merge_vertices); +} + void box_export_tab_export_mesh(ui_handle_t *htab) { bool tab_vertical = config_raw->touch_ui; if (ui_tab(htab, tr("Export Mesh", NULL), tab_vertical, -1, false)) { @@ -481,56 +505,24 @@ void box_export_tab_export_mesh(ui_handle_t *htab) { ui_box_hide(); _box_export_apply_displacement = apply_displacement; _box_export_merge_vertices = merge_vertices; - ui_files_show(context_raw->export_mesh_format == MESH_FORMAT_OBJ ? "obj" : "arm", true, false, &box_export_tab_export_mesh_36414); + ui_files_show(context_raw->export_mesh_format == MESH_FORMAT_OBJ ? "obj" : "arm", true, false, &box_export_tab_export_mesh_path_picked); } } } -void box_export_tab_export_mesh_36414(char *path) { - #if defined(IRON_ANDROID) || defined(IRON_IOS) - char *f = sys_title(); - #else - char *f = ui_files_filename; - #endif - if (string_equals(f, "")) { - f = string_copy(tr("untitled", NULL)); - } - #if defined(IRON_ANDROID) || defined(IRON_IOS) - console_toast(tr("Exporting mesh", NULL)); - #endif - - mesh_object_t_array_t *paint_objects; - if (box_export_mesh_handle->i == 0) { - paint_objects = NULL; - } - else { - mesh_object_t *po = project_paint_objects->buffer[box_export_mesh_handle->i - 1]; - paint_objects = any_array_create_from_raw( - (void *[]){ - po, - }, - 1); - } - export_mesh_run(string_join(string_join(path, PATH_SEP), f), paint_objects, _box_export_apply_displacement, _box_export_merge_vertices); -} - -void box_export_show_material() { - ui_box_show_custom(&box_export_show_material_36528, 400, 200, NULL, true, ""); -} - -void box_export_show_material_36694(char *path) { +void box_export_show_material_export_on_next_frame(char *path) { export_arm_run_material(path); } -void box_export_show_material_36663(char *path) { +void box_export_show_material_export(char *path) { char *f = ui_files_filename; if (string_equals(f, "")) { f = string_copy(tr("untitled", NULL)); } - sys_notify_on_next_frame(&box_export_show_material_36694, string_join(string_join(path, PATH_SEP), f)); + sys_notify_on_next_frame(&box_export_show_material_export_on_next_frame, string_join(string_join(path, PATH_SEP), f)); } -void box_export_show_material_36528() { +void box_export_show_material_box() { ui_handle_t *htab = ui_handle(__ID__); bool tab_vertical = config_raw->touch_ui; if (ui_tab(htab, tr("Export Material", NULL), tab_vertical, -1, false)) { @@ -546,27 +538,27 @@ void box_export_show_material_36528() { } if (ui_icon_button(tr("Export", NULL), ICON_CHECK, UI_ALIGN_CENTER)) { ui_box_hide(); - ui_files_show("arm", true, false, &box_export_show_material_36663); + ui_files_show("arm", true, false, &box_export_show_material_export); } } } -void box_export_show_brush() { - ui_box_show_custom(&box_export_show_brush_36731, 400, 200, NULL, true, ""); +void box_export_show_material() { + ui_box_show_custom(&box_export_show_material_box, 400, 200, NULL, true, ""); } -void box_export_show_brush_36895(char *path) { +void box_export_show_brush_export_on_next_frame(char *path) { export_arm_run_brush(path); } -void box_export_show_brush_36866(char *path) { +void box_export_show_brush_export(char *path) { char *f = ui_files_filename; if (string_equals(f, "")) f = string_copy(tr("untitled", NULL)); - sys_notify_on_next_frame(&box_export_show_brush_36895, string_join(string_join(path, PATH_SEP), f)); + sys_notify_on_next_frame(&box_export_show_brush_export_on_next_frame, string_join(string_join(path, PATH_SEP), f)); } -void box_export_show_brush_36731() { +void box_export_show_brush_box() { ui_handle_t *htab = ui_handle(__ID__); bool tab_vertical = config_raw->touch_ui; if (ui_tab(htab, tr("Export Brush", NULL), tab_vertical, -1, false)) { @@ -582,11 +574,15 @@ void box_export_show_brush_36731() { } if (ui_icon_button(tr("Export", NULL), ICON_CHECK, UI_ALIGN_CENTER)) { ui_box_hide(); - ui_files_show("arm", true, false, &box_export_show_brush_36866); + ui_files_show("arm", true, false, &box_export_show_brush_export); } } } +void box_export_show_brush() { + ui_box_show_custom(&box_export_show_brush_box, 400, 200, NULL, true, ""); +} + void box_export_fetch_presets() { gc_unroot(box_export_files); box_export_files = file_read_directory(string_join(string_join(path_data(), PATH_SEP), "export_presets")); diff --git a/paint/sources/box_preferences.c b/paint/sources/box_preferences.c index bc4c3147..1efb4e56 100644 --- a/paint/sources/box_preferences.c +++ b/paint/sources/box_preferences.c @@ -1,6 +1,55 @@ #include "global.h" +void box_preferences_interface_tab_reset_layout_menu() { + if (ui_menu_button(tr("Confirm", NULL), "", ICON_CHECK)) { + config_init_layout(); + config_save(); + } +} + +void box_preferences_interface_tab_restore_menu_import_on_next_frame(config_t *raw) { + ui->ops->theme->ELEMENT_H = base_default_element_h; + config_import_from(raw); + box_preferences_set_scale(); + make_material_parse_mesh_material(); + make_material_parse_paint_material(true); +} + +void box_preferences_interface_tab_restore_menu_import(char *path) { + buffer_t *b = data_get_blob(path); + config_t *raw = json_parse(sys_buffer_to_string(b)); + sys_notify_on_next_frame(&box_preferences_interface_tab_restore_menu_import_on_next_frame, raw); +} + +void box_preferences_interface_tab_restore_menu_confirm(void *_) { + ui->ops->theme->ELEMENT_H = base_default_element_h; + config_restore(); + box_preferences_set_scale(); + if (config_raw->plugins != NULL) { + for (i32 i = 0; i < config_raw->plugins->length; ++i) { + char *f = config_raw->plugins->buffer[i]; + plugin_stop(f); + } + } + gc_unroot(box_preferences_files_plugin); + box_preferences_files_plugin = NULL; + gc_unroot(box_preferences_files_keymap); + box_preferences_files_keymap = NULL; + make_material_parse_mesh_material(); + make_material_parse_paint_material(true); + ui_base_set_viewport_col(ui->ops->theme->VIEWPORT_COL); +} + +void box_preferences_interface_tab_restore_menu() { + if (ui_menu_button(tr("Confirm", NULL), "", ICON_CHECK)) { + sys_notify_on_next_frame(&box_preferences_interface_tab_restore_menu_confirm, NULL); + } + if (ui_menu_button(tr("Import...", NULL), "", ICON_IMPORT)) { + ui_files_show("json", false, false, &box_preferences_interface_tab_restore_menu_import); + } +} + void box_preferences_interface_tab() { if (box_preferences_locales == NULL) { gc_unroot(box_preferences_locales); @@ -12,8 +61,8 @@ void box_preferences_interface_tab() { h_locale->i = char_ptr_array_index_of(box_preferences_locales, config_raw->locale); ui_combo(h_locale, box_preferences_locales, tr("Language", NULL), true, UI_ALIGN_LEFT, true); if (h_locale->changed) { - char *locale_code = box_preferences_locales->buffer[h_locale->i]; - config_raw->locale = string_copy(locale_code); + char *locale_code = box_preferences_locales->buffer[h_locale->i]; + config_raw->locale = string_copy(locale_code); translator_load_translations(locale_code); base_redraw_ui(); } @@ -88,72 +137,69 @@ void box_preferences_interface_tab() { h_splash_screen->b = config_raw->splash_screen; config_raw->splash_screen = ui_check(h_splash_screen, tr("Splash Screen", NULL), ""); - ui_handle_t *h_grid_snap = ui_handle(__ID__); - h_grid_snap->b = config_raw->grid_snap; - config_raw->grid_snap = ui_check(h_grid_snap, tr("Grid Snap", NULL), ""); - ui_nodes_grid_snap = config_raw->grid_snap; + ui_handle_t *h_grid_snap = ui_handle(__ID__); + h_grid_snap->b = config_raw->grid_snap; + config_raw->grid_snap = ui_check(h_grid_snap, tr("Grid Snap", NULL), ""); + ui_nodes_grid_snap = config_raw->grid_snap; - ui_handle_t *h_experimental = ui_handle(__ID__); - h_experimental->b = config_raw->experimental; - config_raw->experimental = ui_check(h_experimental, tr("Experimental Features", NULL), ""); + ui_handle_t *h_experimental = ui_handle(__ID__); + h_experimental->b = config_raw->experimental; + config_raw->experimental = ui_check(h_experimental, tr("Experimental Features", NULL), ""); ui_end_element(); ui_row2(); if (ui_icon_button(tr("Restore", NULL), ICON_REPLAY, UI_ALIGN_CENTER) && !ui_menu_show) { - ui_menu_draw(&box_preferences_interface_tab_170050, -1, -1); + ui_menu_draw(&box_preferences_interface_tab_restore_menu, -1, -1); } if (ui_button(tr("Reset Layout", NULL), UI_ALIGN_CENTER, "") && !ui_menu_show) { - ui_menu_draw(&box_preferences_interface_tab_170267, -1, -1); + ui_menu_draw(&box_preferences_interface_tab_reset_layout_menu, -1, -1); } } -void box_preferences_interface_tab_170267() { - if (ui_menu_button(tr("Confirm", NULL), "", ICON_CHECK)) { - config_init_layout(); - config_save(); +void box_preferences_theme_tab_theme_field_menu() { + ui->changed = false; + i32 color = ui_color_wheel(_box_preferences_h, false, -1, 11 * ui->ops->theme->ELEMENT_H * UI_SCALE(), true, NULL, NULL); + u32 *u32_theme = base_theme; + *(u32_theme + _box_preferences_i) = color; + if (ui->changed) { + ui_menu_keep_open = true; } } -void box_preferences_interface_tab_170210(config_t *raw) { - ui->ops->theme->ELEMENT_H = base_default_element_h; - config_import_from(raw); - box_preferences_set_scale(); - make_material_parse_mesh_material(); - make_material_parse_paint_material(true); +void box_preferences_theme_tab_export(char *path) { + path = string_join(path, PATH_SEP); + path = string_join(path, ui_files_filename); + if (!ends_with(path, ".json")) { + path = string_join(path, ".json"); + } + iron_file_save_bytes(path, sys_string_to_buffer(box_preferences_theme_to_json(base_theme)), 0); } -void box_preferences_interface_tab_170178(char *path) { - buffer_t *b = data_get_blob(path); - config_t *raw = json_parse(sys_buffer_to_string(b)); - sys_notify_on_next_frame(&box_preferences_interface_tab_170210, raw); +void box_preferences_theme_tab_import(char *path) { + import_theme_run(path); } -void box_preferences_interface_tab_170071(void * _) { - ui->ops->theme->ELEMENT_H = base_default_element_h; - config_restore(); - box_preferences_set_scale(); - if (config_raw->plugins != NULL) { - for (i32 i = 0; i < config_raw->plugins->length; ++i) { - char *f = config_raw->plugins->buffer[i]; - plugin_stop(f); +void box_preferences_theme_tab_new_box() { + ui_row2(); + ui_handle_t *h = ui_handle(__ID__); + if (h->init) { + h->text = "new_theme"; + } + char *theme_name = ui_text_input(h, tr("Name", NULL), UI_ALIGN_LEFT, true, false); + if (ui_icon_button(tr("OK", NULL), ICON_CHECK, UI_ALIGN_CENTER) || ui->is_return_down) { + char *template = box_preferences_theme_to_json(base_theme); + if (!ends_with(theme_name, ".json")) { + theme_name = string_join(theme_name, ".json"); } - } - gc_unroot(box_preferences_files_plugin); - box_preferences_files_plugin = NULL; - gc_unroot(box_preferences_files_keymap); - box_preferences_files_keymap = NULL; - make_material_parse_mesh_material(); - make_material_parse_paint_material(true); - ui_base_set_viewport_col(ui->ops->theme->VIEWPORT_COL); -} - -void box_preferences_interface_tab_170050() { - if (ui_menu_button(tr("Confirm", NULL), "", ICON_CHECK)) { - sys_notify_on_next_frame(&box_preferences_interface_tab_170071, NULL); - } - if (ui_menu_button(tr("Import...", NULL), "", ICON_IMPORT)) { - ui_files_show("json", false, false, &box_preferences_interface_tab_170178); + char *path = string_join(string_join(string_join(string_join(path_data(), PATH_SEP), "themes"), PATH_SEP), theme_name); + iron_file_save_bytes(path, sys_string_to_buffer(template), 0); + box_preferences_fetch_themes(); // Refresh file list + config_raw->theme = string_copy(theme_name); + box_preferences_h_theme->i = box_preferences_get_theme_index(); + ui_box_hide(); + box_preferences_htab->i = 1; // Themes + box_preferences_show(); } } @@ -176,25 +222,25 @@ void box_preferences_theme_tab() { } if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) { - ui_box_show_custom(&box_preferences_theme_tab_170385, 400, 200, NULL, true, tr("New Theme", NULL)); + ui_box_show_custom(&box_preferences_theme_tab_new_box, 400, 200, NULL, true, tr("New Theme", NULL)); } if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { - ui_files_show("json", false, false, &box_preferences_theme_tab_170563); + ui_files_show("json", false, false, &box_preferences_theme_tab_import); } if (ui_icon_button(tr("Export", NULL), ICON_EXPORT, UI_ALIGN_CENTER)) { - ui_files_show("json", true, false, &box_preferences_theme_tab_170600); + ui_files_show("json", true, false, &box_preferences_theme_tab_export); } ui_end_sticky(); // Theme fields ui_handle_t *h_list = ui_handle(__ID__); - u32 *u32_theme = base_theme; + u32 *u32_theme = base_theme; ui->input_enabled = !ui_menu_show; for (i32 i = 0; i < ui_theme_keys_count; ++i) { - char *key = ui_theme_keys[i]; + char *key = ui_theme_keys[i]; ui_handle_t *h = ui_nest(h_list, i); u32 val = *(u32_theme + i); bool is_hex = ends_with(key, "_COL"); @@ -214,7 +260,7 @@ void box_preferences_theme_tab() { _box_preferences_h = h; gc_root(_box_preferences_h); _box_preferences_i = i; - ui_menu_draw(&box_preferences_theme_tab_170797, -1, -1); + ui_menu_draw(&box_preferences_theme_tab_theme_field_menu, -1, -1); } if (string_equals(key, "VIEWPORT_COL") && ui_base_viewport_col != val) { @@ -226,8 +272,8 @@ void box_preferences_theme_tab() { if (string_equals(key, "FILL_WINDOW_BG") || string_equals(key, "FILL_BUTTON_BG") || string_equals(key, "FULL_TABS") || string_equals(key, "ROUND_CORNERS") || string_equals(key, "SHADOWS")) { - h->b = val > 0; - bool b = ui_check(h, key, ""); + h->b = val > 0; + bool b = ui_check(h, key, ""); *(u32_theme + i) = b; } else if (string_equals(key, "LINK_STYLE")) { @@ -237,8 +283,8 @@ void box_preferences_theme_tab() { tr("Curved", NULL), }, 2); - h->i = val; - i32 pos = ui_combo(h, styles, key, true, UI_ALIGN_LEFT, true); + h->i = val; + i32 pos = ui_combo(h, styles, key, true, UI_ALIGN_LEFT, true); *(u32_theme + i) = pos; } else { @@ -258,52 +304,6 @@ void box_preferences_theme_tab() { ui->input_enabled = true; } -void box_preferences_theme_tab_170797() { - ui->changed = false; - i32 color = ui_color_wheel(_box_preferences_h, false, -1, 11 * ui->ops->theme->ELEMENT_H * UI_SCALE(), true, NULL, NULL); - u32 *u32_theme = base_theme; - *(u32_theme + _box_preferences_i) = color; - if (ui->changed) { - ui_menu_keep_open = true; - } -} - -void box_preferences_theme_tab_170600(char *path) { - path = string_join(path, PATH_SEP); - path = string_join(path, ui_files_filename); - if (!ends_with(path, ".json")) { - path = string_join(path, ".json"); - } - iron_file_save_bytes(path, sys_string_to_buffer(box_preferences_theme_to_json(base_theme)), 0); -} - -void box_preferences_theme_tab_170563(char *path) { - import_theme_run(path); -} - -void box_preferences_theme_tab_170385() { - ui_row2(); - ui_handle_t *h = ui_handle(__ID__); - if (h->init) { - h->text = "new_theme"; - } - char *theme_name = ui_text_input(h, tr("Name", NULL), UI_ALIGN_LEFT, true, false); - if (ui_icon_button(tr("OK", NULL), ICON_CHECK, UI_ALIGN_CENTER) || ui->is_return_down) { - char *template = box_preferences_theme_to_json(base_theme); - if (!ends_with(theme_name, ".json")) { - theme_name = string_join(theme_name, ".json"); - } - char *path = string_join(string_join(string_join(string_join(path_data(), PATH_SEP), "themes"), PATH_SEP), theme_name); - iron_file_save_bytes(path, sys_string_to_buffer(template), 0); - box_preferences_fetch_themes(); // Refresh file list - config_raw->theme = string_copy(theme_name); - box_preferences_h_theme->i = box_preferences_get_theme_index(); - ui_box_hide(); - box_preferences_htab->i = 1; // Themes - box_preferences_show(); - } -} - void box_preferences_usage_tab() { ui_handle_t *h_undo = ui_handle(__ID__); h_undo->f = config_raw->undo_steps; @@ -347,27 +347,27 @@ void box_preferences_usage_tab() { tr("Fly", NULL), }, 3); - config_raw->camera_controls = ui_combo(h_camera_controls, camera_controls_combo, tr("Default Camera Controls", NULL), true, UI_ALIGN_LEFT, true); + config_raw->camera_controls = ui_combo(h_camera_controls, camera_controls_combo, tr("Default Camera Controls", NULL), true, UI_ALIGN_LEFT, true); - ui_handle_t *h_fov = ui_handle(__ID__); - h_fov->f = config_raw->camera_fov; - config_raw->camera_fov = ui_slider(h_fov, tr("Default Camera FoV", NULL), 0.3, 1.4, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *h_fov = ui_handle(__ID__); + h_fov->f = config_raw->camera_fov; + config_raw->camera_fov = ui_slider(h_fov, tr("Default Camera FoV", NULL), 0.3, 1.4, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *h_speed = ui_handle(__ID__); - h_speed->f = config_raw->camera_zoom_speed; - config_raw->camera_zoom_speed = ui_slider(h_speed, tr("Camera Zoom Speed", NULL), 0.1, 4.0, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *h_speed = ui_handle(__ID__); + h_speed->f = config_raw->camera_zoom_speed; + config_raw->camera_zoom_speed = ui_slider(h_speed, tr("Camera Zoom Speed", NULL), 0.1, 4.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - h_speed = ui_handle(__ID__); - h_speed->f = config_raw->camera_rotation_speed; - config_raw->camera_rotation_speed = ui_slider(h_speed, tr("Camera Rotation Speed", NULL), 0.1, 4.0, true, 100.0, true, UI_ALIGN_RIGHT, true); + h_speed = ui_handle(__ID__); + h_speed->f = config_raw->camera_rotation_speed; + config_raw->camera_rotation_speed = ui_slider(h_speed, tr("Camera Rotation Speed", NULL), 0.1, 4.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - h_speed = ui_handle(__ID__); - h_speed->f = config_raw->camera_pan_speed; - config_raw->camera_pan_speed = ui_slider(h_speed, tr("Camera Pan Speed", NULL), 0.1, 4.0, true, 100.0, true, UI_ALIGN_RIGHT, true); + h_speed = ui_handle(__ID__); + h_speed->f = config_raw->camera_pan_speed; + config_raw->camera_pan_speed = ui_slider(h_speed, tr("Camera Pan Speed", NULL), 0.1, 4.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *h_upside_down = ui_handle(__ID__); - h_upside_down->b = config_raw->camera_upside_down; - config_raw->camera_upside_down = ui_check(h_upside_down, tr("Allow Upside Down Camera", NULL), ""); + ui_handle_t *h_upside_down = ui_handle(__ID__); + h_upside_down->b = config_raw->camera_upside_down; + config_raw->camera_upside_down = ui_check(h_upside_down, tr("Allow Upside Down Camera", NULL), ""); ui_handle_t *h_zoom_direction = ui_handle(__ID__); h_zoom_direction->i = config_raw->zoom_direction; @@ -381,11 +381,11 @@ void box_preferences_usage_tab() { tr("Vertical and Horizontal Inverted", NULL), }, 6); - config_raw->zoom_direction = ui_combo(h_zoom_direction, zoom_direction_combo, tr("Direction to Zoom", NULL), true, UI_ALIGN_LEFT, true); + config_raw->zoom_direction = ui_combo(h_zoom_direction, zoom_direction_combo, tr("Direction to Zoom", NULL), true, UI_ALIGN_LEFT, true); - ui_handle_t *h_layer_res = ui_handle(__ID__); - h_layer_res->i = config_raw->layer_res; - #if defined(IRON_ANDROID) || defined(IRON_IOS) + ui_handle_t *h_layer_res = ui_handle(__ID__); + h_layer_res->i = config_raw->layer_res; +#if defined(IRON_ANDROID) || defined(IRON_IOS) string_t_array_t *res_combo = any_array_create_from_raw( (void *[]){ "128", @@ -396,7 +396,7 @@ void box_preferences_usage_tab() { "4096", }, 6); - #else +#else string_t_array_t *res_combo = any_array_create_from_raw( (void *[]){ "128", @@ -409,20 +409,20 @@ void box_preferences_usage_tab() { "16384", }, 8); - #endif - config_raw->layer_res = ui_combo(h_layer_res, res_combo, tr("Default Layer Resolution", NULL), true, UI_ALIGN_LEFT, true); +#endif + config_raw->layer_res = ui_combo(h_layer_res, res_combo, tr("Default Layer Resolution", NULL), true, UI_ALIGN_LEFT, true); ui_handle_t *h_scene_atlas_res = ui_handle(__ID__); h_scene_atlas_res->i = config_raw->scene_atlas_res; config_raw->scene_atlas_res = ui_combo(h_scene_atlas_res, res_combo, tr("Scene Atlas Resolution", NULL), true, UI_ALIGN_LEFT, true); - ui_handle_t *h_server = ui_handle(__ID__); - h_server->text = string_copy(config_raw->server); - config_raw->server = string_copy(ui_text_input(h_server, tr("Cloud Server", NULL), UI_ALIGN_LEFT, true, false)); + ui_handle_t *h_server = ui_handle(__ID__); + h_server->text = string_copy(config_raw->server); + config_raw->server = string_copy(ui_text_input(h_server, tr("Cloud Server", NULL), UI_ALIGN_LEFT, true, false)); - ui_handle_t *h_material_live = ui_handle(__ID__); - h_material_live->b = config_raw->material_live; - config_raw->material_live = ui_check(h_material_live, tr("Live Material Preview", NULL), ""); + ui_handle_t *h_material_live = ui_handle(__ID__); + h_material_live->b = config_raw->material_live; + config_raw->material_live = ui_check(h_material_live, tr("Live Material Preview", NULL), ""); if (ui->is_hovered) { ui_tooltip(tr("Instantly update material preview on node change", NULL)); } @@ -464,7 +464,7 @@ void box_preferences_usage_tab() { make_material_parse_paint_material(true); } - ui->enabled = true; + ui->enabled = true; ui_handle_t *h_alpha_discard = ui_handle(__ID__); h_alpha_discard->f = config_raw->brush_alpha_discard; @@ -476,25 +476,25 @@ void box_preferences_usage_tab() { void box_preferences_pen_tab() { ui_text(tr("Pressure controls", NULL), UI_ALIGN_LEFT, 0x00000000); - ui_handle_t *h_pressure_radius = ui_handle(__ID__); - h_pressure_radius->b = config_raw->pressure_radius; - config_raw->pressure_radius = ui_check(h_pressure_radius, tr("Brush Radius", NULL), ""); + ui_handle_t *h_pressure_radius = ui_handle(__ID__); + h_pressure_radius->b = config_raw->pressure_radius; + config_raw->pressure_radius = ui_check(h_pressure_radius, tr("Brush Radius", NULL), ""); ui_handle_t *h_pressure_sensitivity = ui_handle(__ID__); h_pressure_sensitivity->f = config_raw->pressure_sensitivity; config_raw->pressure_sensitivity = ui_slider(h_pressure_sensitivity, tr("Sensitivity", NULL), 0.0, 10.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *h_pressure_hardness = ui_handle(__ID__); - h_pressure_hardness->b = config_raw->pressure_hardness; - config_raw->pressure_hardness = ui_check(h_pressure_hardness, tr("Brush Hardness", NULL), ""); + ui_handle_t *h_pressure_hardness = ui_handle(__ID__); + h_pressure_hardness->b = config_raw->pressure_hardness; + config_raw->pressure_hardness = ui_check(h_pressure_hardness, tr("Brush Hardness", NULL), ""); - ui_handle_t *h_pressure_opacity = ui_handle(__ID__); - h_pressure_opacity->b = config_raw->pressure_opacity; - config_raw->pressure_opacity = ui_check(h_pressure_opacity, tr("Brush Opacity", NULL), ""); + ui_handle_t *h_pressure_opacity = ui_handle(__ID__); + h_pressure_opacity->b = config_raw->pressure_opacity; + config_raw->pressure_opacity = ui_check(h_pressure_opacity, tr("Brush Opacity", NULL), ""); - ui_handle_t *h_pressure_angle = ui_handle(__ID__); - h_pressure_angle->b = config_raw->pressure_angle; - config_raw->pressure_angle = ui_check(h_pressure_angle, tr("Brush Angle", NULL), ""); + ui_handle_t *h_pressure_angle = ui_handle(__ID__); + h_pressure_angle->b = config_raw->pressure_angle; + config_raw->pressure_angle = ui_check(h_pressure_angle, tr("Brush Angle", NULL), ""); ui_end_element(); f32_array_t *row = f32_array_create_from_raw( @@ -506,8 +506,8 @@ void box_preferences_pen_tab() { if (ui_icon_button(tr("Help", NULL), ICON_LINK, UI_ALIGN_CENTER)) { char *url = "https://github.com/armory3d/"; char *name = to_lower_case(manifest_title); - url = string_join(url, name); - url = string_join(url, "_docs#pen"); + url = string_join(url, name); + url = string_join(url, "_docs#pen"); iron_load_url(url); } } @@ -623,59 +623,7 @@ void box_preferences_viewport_tab() { } } -void box_preferences_keymap_tab() { - if (box_preferences_files_keymap == NULL) { - box_preferences_fetch_keymaps(); - } - - ui_begin_sticky(); - ui_row4(); - - gc_unroot(box_preferences_h_preset); - box_preferences_h_preset = ui_handle(__ID__); - gc_root(box_preferences_h_preset); - box_preferences_h_preset->i = box_preferences_get_preset_index(); - ui_combo(box_preferences_h_preset, box_preferences_files_keymap, tr("Preset", NULL), false, UI_ALIGN_LEFT, true); - if (box_preferences_h_preset->changed) { - config_raw->keymap = string_join(box_preferences_files_keymap->buffer[box_preferences_h_preset->i], ".json"); - config_apply(); - keymap_load(); - } - - if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) { - ui_box_show_custom(&box_preferences_keymap_tab_172800, 400, 200, NULL, true, tr("New Keymap", NULL)); - } - - if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { - ui_files_show("json", false, false, &box_preferences_keymap_tab_172980); - } - - if (ui_icon_button(tr("Export", NULL), ICON_EXPORT, UI_ALIGN_CENTER)) { - ui_files_show("json", true, false, &box_preferences_keymap_tab_173017); - } - - ui_end_sticky(); - - ui_separator(8, false); - - i32 index = 0; - ui->changed = false; - string_t_array_t *keys = map_keys(config_keymap); - array_sort(keys, NULL); - for (i32 i = 0; i < keys->length; ++i) { - char *key = keys->buffer[i]; - ui_handle_t *h = ui_nest(ui_handle(__ID__), index++); - h->text = string_copy(any_map_get(config_keymap, key)); - char *text = ui_text_input(h, key, UI_ALIGN_LEFT, true, false); - any_map_set(config_keymap, key, text); - } - if (ui->changed) { - config_apply(); - keymap_save(); - } -} - -void box_preferences_keymap_tab_173017(char *dest) { +void box_preferences_keymap_tab_export(char *dest) { if (!ends_with(ui_files_filename, ".json")) { gc_unroot(ui_files_filename); ui_files_filename = string_join(ui_files_filename, ".json"); @@ -685,11 +633,11 @@ void box_preferences_keymap_tab_173017(char *dest) { file_copy(path, string_join(string_join(dest, PATH_SEP), ui_files_filename)); } -void box_preferences_keymap_tab_172980(char *path) { +void box_preferences_keymap_tab_import(char *path) { import_keymap_run(path); } -void box_preferences_keymap_tab_172800() { +void box_preferences_keymap_tab_new_box() { ui_row2(); ui_handle_t *h = ui_handle(__ID__); if (h->init) { @@ -712,11 +660,63 @@ void box_preferences_keymap_tab_172800() { } } +void box_preferences_keymap_tab() { + if (box_preferences_files_keymap == NULL) { + box_preferences_fetch_keymaps(); + } + + ui_begin_sticky(); + ui_row4(); + + gc_unroot(box_preferences_h_preset); + box_preferences_h_preset = ui_handle(__ID__); + gc_root(box_preferences_h_preset); + box_preferences_h_preset->i = box_preferences_get_preset_index(); + ui_combo(box_preferences_h_preset, box_preferences_files_keymap, tr("Preset", NULL), false, UI_ALIGN_LEFT, true); + if (box_preferences_h_preset->changed) { + config_raw->keymap = string_join(box_preferences_files_keymap->buffer[box_preferences_h_preset->i], ".json"); + config_apply(); + keymap_load(); + } + + if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) { + ui_box_show_custom(&box_preferences_keymap_tab_new_box, 400, 200, NULL, true, tr("New Keymap", NULL)); + } + + if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { + ui_files_show("json", false, false, &box_preferences_keymap_tab_import); + } + + if (ui_icon_button(tr("Export", NULL), ICON_EXPORT, UI_ALIGN_CENTER)) { + ui_files_show("json", true, false, &box_preferences_keymap_tab_export); + } + + ui_end_sticky(); + + ui_separator(8, false); + + i32 index = 0; + ui->changed = false; + string_t_array_t *keys = map_keys(config_keymap); + array_sort(keys, NULL); + for (i32 i = 0; i < keys->length; ++i) { + char *key = keys->buffer[i]; + ui_handle_t *h = ui_nest(ui_handle(__ID__), index++); + h->text = string_copy(any_map_get(config_keymap, key)); + char *text = ui_text_input(h, key, UI_ALIGN_LEFT, true, false); + any_map_set(config_keymap, key, text); + } + if (ui->changed) { + config_apply(); + keymap_save(); + } +} + void box_preferences_neural_tab() { ui_text(tr("All processing is done locally on device", NULL), UI_ALIGN_LEFT, 0x00000000); - ui_handle_t *h_inference = ui_handle(__ID__); - h_inference->i = config_raw->neural_backend; - #ifdef IRON_WINDOWS + ui_handle_t *h_inference = ui_handle(__ID__); + h_inference->i = config_raw->neural_backend; +#ifdef IRON_WINDOWS string_t_array_t *inference_combo = any_array_create_from_raw( (void *[]){ "CPU", @@ -724,14 +724,14 @@ void box_preferences_neural_tab() { "CUDA", }, 3); - #else +#else string_t_array_t *inference_combo = any_array_create_from_raw( (void *[]){ "CPU", "Vulkan", }, 2); - #endif +#endif config_raw->neural_backend = ui_combo(h_inference, inference_combo, tr("Inference Backend", NULL), true, UI_ALIGN_LEFT, true); if (ui->is_hovered) { ui_tooltip(tr("Backend for neural node processing", NULL)); @@ -793,15 +793,15 @@ void box_preferences_model_panel(neural_node_model_t *m) { char *url = m->urls->buffer[0]; char *file_name = box_preferences_file_name_from_url(url); - bool found = box_preferences_model_exists(file_name); + bool found = box_preferences_model_exists(file_name); if (neural_node_downloading > 0) { - ui->enabled = false; + ui->enabled = false; - u64 u = iron_net_bytes_downloaded; - i32 i = (u / (float)1000000000) * 100; - f32 f = i / (float)100; - char *downloaded = string_join(f32_to_string(f), "GB"); + u64 u = iron_net_bytes_downloaded; + i32 i = (u / (float)1000000000) * 100; + f32 f = i / (float)100; + char *downloaded = string_join(f32_to_string(f), "GB"); ui_box_hwnd->redraws = 2; box_preferences_htab->redraws = 2; iron_delay_idle_sleep(); @@ -809,13 +809,13 @@ void box_preferences_model_panel(neural_node_model_t *m) { i32 _BUTTON_COL = ui->ops->theme->BUTTON_COL; ui->ops->theme->BUTTON_COL = ui->ops->theme->HIGHLIGHT_COL; - ui_handle_t *h = ui_handle(__ID__); - h->f = f / (float)parse_float(m->size); + ui_handle_t *h = ui_handle(__ID__); + h->f = f / (float)parse_float(m->size); ui_slider(h, string_join(string_join(downloaded, " / "), m->size), 0.0, 1.0, true, 100, false, UI_ALIGN_CENTER, true); ui->ops->theme->BUTTON_COL = _BUTTON_COL; - ui->enabled = true; + ui->enabled = true; } else if (!found && ui_icon_button(string_join(string_join(string_join(tr("Download", NULL), " ("), m->size), ")"), ICON_ARROW_DOWN, UI_ALIGN_CENTER)) { neural_node_download_models(m->urls); @@ -831,58 +831,7 @@ void box_preferences_model_panel(neural_node_model_t *m) { } } -void box_preferences_plugins_tab() { - ui_begin_sticky(); - f32_array_t *row = f32_array_create_from_raw( - (f32[]){ - 1 / (float)4, - 1 / (float)4, - }, - 2); - ui_row(row); - if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) { - ui_box_show_custom(&box_preferences_plugins_tab_173894, 400, 200, NULL, true, tr("New Plugin", NULL)); - } - if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { - ui_files_show("js,zip", false, false, &box_preferences_plugins_tab_174059); - } - ui_end_sticky(); - - if (box_preferences_files_plugin == NULL) { - box_preferences_fetch_plugins(); - } - - if (config_raw->plugins == NULL) { - config_raw->plugins = any_array_create_from_raw((void *[]){}, 0); - } - ui_handle_t *h = ui_handle(__ID__); - if (h->init) { - h->b = false; - } - for (i32 i = 0; i < box_preferences_files_plugin->length; ++i) { - char *f = box_preferences_files_plugin->buffer[i]; - bool is_js = ends_with(f, ".js"); - if (!is_js) { - continue; - } - bool enabled = char_ptr_array_index_of(config_raw->plugins, f) >= 0; - h->b = enabled; - char *tag = is_js ? string_split(f, ".")->buffer[0] : f; - ui_check(h, tag, ""); - if (h->changed && h->b != enabled) { - h->b ? config_enable_plugin(f) : config_disable_plugin(f); - base_redraw_ui(); - } - if (ui->is_hovered && ui->input_released_r) { - gc_unroot(_box_preferences_f); - _box_preferences_f = string_copy(f); - gc_root(_box_preferences_f); - ui_menu_draw(&box_preferences_plugins_tab_174255, -1, -1); - } - } -} - -void box_preferences_plugins_tab_174362(char *dest) { +void box_preferences_plugins_tab_plugin_menu_export(char *dest) { if (!ends_with(ui_files_filename, ".js")) { gc_unroot(ui_files_filename); ui_files_filename = string_join(ui_files_filename, ".js"); @@ -892,7 +841,7 @@ void box_preferences_plugins_tab_174362(char *dest) { file_copy(path, string_join(string_join(dest, PATH_SEP), ui_files_filename)); } -void box_preferences_plugins_tab_174255() { +void box_preferences_plugins_tab_plugin_menu() { char *path = string_join(string_join(string_join(string_join(path_data(), PATH_SEP), "plugins"), PATH_SEP), _box_preferences_f); if (ui_menu_button(tr("Edit in Text Editor", NULL), "", ICON_NONE)) { file_start(path); @@ -904,7 +853,7 @@ void box_preferences_plugins_tab_174255() { console_info(tr("Script opened", NULL)); } if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { - ui_files_show("js", true, false, &box_preferences_plugins_tab_174362); + ui_files_show("js", true, false, &box_preferences_plugins_tab_plugin_menu_export); } if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { if (char_ptr_array_index_of(config_raw->plugins, _box_preferences_f) >= 0) { @@ -916,11 +865,11 @@ void box_preferences_plugins_tab_174255() { } } -void box_preferences_plugins_tab_174059(char *path) { +void box_preferences_plugins_tab_import(char *path) { import_plugin_run(path); } -void box_preferences_plugins_tab_173894() { +void box_preferences_plugins_tab_new_box() { ui_row2(); ui_handle_t *h = ui_handle(__ID__); if (h->init) { @@ -951,15 +900,62 @@ plugin_notify_on_ui(plugin, function() {\ } } -void box_preferences_show() { - ui_box_show_custom(&box_preferences_show_174484, 720, 520, &box_preferences_show_174671, true, tr("Preferences", NULL)); +void box_preferences_plugins_tab() { + ui_begin_sticky(); + f32_array_t *row = f32_array_create_from_raw( + (f32[]){ + 1 / (float)4, + 1 / (float)4, + }, + 2); + ui_row(row); + if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) { + ui_box_show_custom(&box_preferences_plugins_tab_new_box, 400, 200, NULL, true, tr("New Plugin", NULL)); + } + if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { + ui_files_show("js,zip", false, false, &box_preferences_plugins_tab_import); + } + ui_end_sticky(); + + if (box_preferences_files_plugin == NULL) { + box_preferences_fetch_plugins(); + } + + if (config_raw->plugins == NULL) { + config_raw->plugins = any_array_create_from_raw((void *[]){}, 0); + } + ui_handle_t *h = ui_handle(__ID__); + if (h->init) { + h->b = false; + } + for (i32 i = 0; i < box_preferences_files_plugin->length; ++i) { + char *f = box_preferences_files_plugin->buffer[i]; + bool is_js = ends_with(f, ".js"); + if (!is_js) { + continue; + } + bool enabled = char_ptr_array_index_of(config_raw->plugins, f) >= 0; + h->b = enabled; + char *tag = is_js ? string_split(f, ".")->buffer[0] : f; + ui_check(h, tag, ""); + if (h->changed && h->b != enabled) { + h->b ? config_enable_plugin(f) : config_disable_plugin(f); + base_redraw_ui(); + } + if (ui->is_hovered && ui->input_released_r) { + gc_unroot(_box_preferences_f); + _box_preferences_f = string_copy(f); + gc_root(_box_preferences_f); + ui_menu_draw(&box_preferences_plugins_tab_plugin_menu, -1, -1); + } + } } -void box_preferences_show_174671() { +void box_preferences_show_on_hide() { config_save(); } -void box_preferences_show_174484() { +void box_preferences_show_box() { if (ui_tab(box_preferences_htab, tr("Interface", NULL), true, -1, false)) { box_preferences_interface_tab(); } @@ -970,11 +966,11 @@ void box_preferences_show_174484() { box_preferences_usage_tab(); } - #ifdef IRON_IOS +#ifdef IRON_IOS char *pen_name = tr("Pencil", NULL); - #else +#else char *pen_name = tr("Pen", NULL); - #endif +#endif if (ui_tab(box_preferences_htab, pen_name, true, -1, false)) { box_preferences_pen_tab(); } @@ -985,22 +981,26 @@ void box_preferences_show_174484() { if (ui_tab(box_preferences_htab, tr("Keymap", NULL), true, -1, false)) { box_preferences_keymap_tab(); } - #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) +#if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) if (ui_tab(box_preferences_htab, tr("Neural", NULL), true, -1, false)) { box_preferences_neural_tab(); } - #endif +#endif if (ui_tab(box_preferences_htab, tr("Plugins", NULL), true, -1, false)) { box_preferences_plugins_tab(); } } +void box_preferences_show() { + ui_box_show_custom(&box_preferences_show_box, 720, 520, &box_preferences_show_on_hide, true, tr("Preferences", NULL)); +} + void box_preferences_fetch_themes() { gc_unroot(box_preferences_themes); box_preferences_themes = file_read_directory(string_join(string_join(path_data(), PATH_SEP), "themes")); gc_root(box_preferences_themes); for (i32 i = 0; i < box_preferences_themes->length; ++i) { - char *s = box_preferences_themes->buffer[i]; + char *s = box_preferences_themes->buffer[i]; box_preferences_themes->buffer[i] = substring(box_preferences_themes->buffer[i], 0, string_length(s) - 5); // Strip .json } array_insert(box_preferences_themes, 0, "default"); @@ -1011,7 +1011,7 @@ void box_preferences_fetch_keymaps() { box_preferences_files_keymap = file_read_directory(string_join(string_join(path_data(), PATH_SEP), "keymap_presets")); gc_root(box_preferences_files_keymap); for (i32 i = 0; i < box_preferences_files_keymap->length; ++i) { - char *s = box_preferences_files_keymap->buffer[i]; + char *s = box_preferences_files_keymap->buffer[i]; box_preferences_files_keymap->buffer[i] = substring(box_preferences_files_keymap->buffer[i], 0, string_length(s) - 5); // Strip .json } array_insert(box_preferences_files_keymap, 0, "default"); @@ -1047,7 +1047,7 @@ char *box_preferences_theme_to_json(ui_theme_t *theme) { u32 *u32_theme = theme; for (i32 i = 0; i < ui_theme_keys_count; ++i) { char *key = ui_theme_keys[i]; - u32 val = *(u32_theme + i); + u32 val = *(u32_theme + i); json_encode_i32(key, val); } return json_encode_end(); diff --git a/paint/sources/box_projects.c b/paint/sources/box_projects.c index 963e805f..4f29c713 100644 --- a/paint/sources/box_projects.c +++ b/paint/sources/box_projects.c @@ -1,6 +1,19 @@ #include "global.h" +void box_projects_show_box() { + #if defined(IRON_ANDROID) || defined(IRON_IOS) + box_projects_align_to_fullscreen(); + #endif + + #if defined(IRON_ANDROID) || defined(IRON_IOS) + box_projects_tab(); + box_projects_get_started_tab(); + #else + box_projects_recent_tab(); + #endif +} + void box_projects_show() { if (box_projects_icon_map != NULL) { string_t_array_t *keys = map_keys(box_projects_icon_map); @@ -19,20 +32,28 @@ 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_box, 600, 400, NULL, draggable, ""); } -void box_projects_show_74688() { - #if defined(IRON_ANDROID) || defined(IRON_IOS) - box_projects_align_to_fullscreen(); - #endif +void box_projects_tab_menu_on_next_frame(void * _) { + iron_delete_file(_box_projects_path); + iron_delete_file(_box_projects_icon_path); + 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); +} - #if defined(IRON_ANDROID) || defined(IRON_IOS) - box_projects_tab(); - box_projects_get_started_tab(); - #else - box_projects_recent_tab(); - #endif +void box_projects_tab_menu() { + // 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_menu_on_next_frame, NULL); + } +} + +void box_projects_tab_on_next_frame(char *path) { + ui_box_hide(); + import_arm_run_project(path); } void box_projects_tab() { @@ -132,7 +153,7 @@ void box_projects_tab() { #if defined(IRON_ANDROID) || defined(IRON_IOS) console_toast(tr("Opening project", NULL)); #endif - sys_notify_on_next_frame(&box_projects_tab_75329, path); + sys_notify_on_next_frame(&box_projects_tab_on_next_frame, path); } char *name = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_last_index_of(path, ".")); @@ -144,7 +165,7 @@ void box_projects_tab() { _box_projects_icon_path = string_copy(icon_path); gc_root(_box_projects_icon_path); _box_projects_i = i; - ui_menu_draw(&box_projects_tab_75398, -1, -1); + ui_menu_draw(&box_projects_tab_menu, -1, -1); } if (show_asset_names) { @@ -174,27 +195,6 @@ void box_projects_tab() { } } -void box_projects_tab_75419(void * _) { - iron_delete_file(_box_projects_path); - iron_delete_file(_box_projects_icon_path); - 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); -} - -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); - } -} - -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)) { diff --git a/paint/sources/context.c b/paint/sources/context.c index 6525101e..cd0c97e4 100644 --- a/paint/sources/context.c +++ b/paint/sources/context.c @@ -11,7 +11,7 @@ context_t *context_create() { c->split_view = false; c->view_index = -1; c->view_index_last = -1; - c->picked_color = make_swatch(0xffffffff); + c->picked_color = project_make_swatch(0xffffffff); c->envmap_loaded = false; c->show_envmap = false; c->show_envmap_handle = ui_handle_create(); @@ -191,6 +191,10 @@ void context_select_material(i32 i) { context_set_material(project_materials->buffer[i]); } +void context_set_material_on_next_frame(void * _) { + util_render_make_decal_preview(); +} + void context_set_material(slot_material_t *m) { if (array_index_of(project_materials, m) == -1) { return; @@ -206,14 +210,10 @@ void context_set_material(slot_material_t *m) { bool decal = context_is_decal(); if (decal) { - sys_notify_on_next_frame(&context_set_material_62876, NULL); + sys_notify_on_next_frame(&context_set_material_on_next_frame, NULL); } } -void context_set_material_62876(void * _) { - util_render_make_decal_preview(); -} - void context_select_brush(i32 i) { if (project_brushes->length <= i) { return; @@ -498,6 +498,10 @@ void context_set_viewport_shader(void * viewport_shader) { // JSValue * -> (ns: context_set_render_path(); } +void context_set_render_path_on_next_frame(void * _) { + make_material_parse_mesh_material(); +} + void context_set_render_path() { if (config_raw->render_mode == RENDER_MODE_FORWARD || context_raw->viewport_shader != NULL) { gc_unroot(render_path_commands); @@ -509,11 +513,7 @@ void context_set_render_path() { render_path_commands = render_path_deferred_commands; gc_root(render_path_commands); } - sys_notify_on_next_frame(&context_set_render_path_64096, NULL); -} - -void context_set_render_path_64096(void * _) { - make_material_parse_mesh_material(); + sys_notify_on_next_frame(&context_set_render_path_on_next_frame, NULL); } bool context_enable_import_plugin(char *file) { diff --git a/paint/sources/functions.c b/paint/sources/functions.c index 123c3fbd..c52ce210 100644 --- a/paint/sources/functions.c +++ b/paint/sources/functions.c @@ -1,3 +1,6 @@ + +#include "global.h" + f32 ui_MENUBAR_H(ui_t *ui); f32 ui_nodes_INPUT_Y(ui_node_canvas_t *canvas, ui_node_t *node, i32 pos); ui_handle_t *ui_handle(char *s); @@ -10,11 +13,6 @@ void ui_set_font(ui_t *ui, draw_font_t *font); void tab_swatches_empty_set(gpu_texture_t *image); gpu_texture_t *tab_swatches_empty_get(); void tab_swatches_draw(ui_handle_t *htab); -void tab_swatches_draw_15862(); -void tab_swatches_draw_16422(); -void tab_swatches_draw_16464(); -void tab_swatches_draw_16479(swatch_color_t *color); -void tab_swatches_draw_16719(); void tab_swatches_accept_swatch_drop(swatch_color_t *swatch); void tab_swatches_delete_swatch(swatch_color_t *swatch); slot_brush_t *slot_brush_create(ui_node_canvas_t *c); @@ -28,7 +26,6 @@ void slot_layer_apply_mask(slot_layer_t *raw); slot_layer_t *slot_layer_duplicate(slot_layer_t *raw); void slot_layer_resize_and_set_bits(slot_layer_t *raw); void slot_layer_to_fill_layer(slot_layer_t *raw); -void slot_layer_to_fill_layer_19750(void *_); void slot_layer_to_paint_layer(slot_layer_t *raw); bool slot_layer_is_visible(slot_layer_t *raw); slot_layer_t_array_t *slot_layer_get_children(slot_layer_t *raw); @@ -48,7 +45,6 @@ bool slot_layer_can_move(slot_layer_t *raw, i32 to); void slot_layer_move(slot_layer_t *raw, i32 to); void layers_init(); void layers_resize(); -void layers_resize_21670(slot_layer_t *l); void layers_set_bits(); void layers_make_temp_img(); void layers_make_temp_mask_img(); @@ -61,15 +57,11 @@ void layers_update_fill_layers(); void layers_update_fill_layer(bool parse_paint); void layers_set_object_mask(); slot_layer_t *layers_new_layer(bool clear, i32 position); -void layers_new_layer_23812(slot_layer_t *l); slot_layer_t *layers_new_mask(bool clear, slot_layer_t *parent, i32 position); -void layers_new_mask_23923(slot_layer_t *l); slot_layer_t *layers_new_group(); void layers_create_fill_layer(uv_type_t uv_type, mat4_t decal_mat, i32 position); -void layers_create_fill_layer_24041(void *_); void layers_create_image_mask(asset_t *asset); void layers_create_color_layer(i32 base_color, f32 occlusion, f32 roughness, f32 metallic, i32 position); -void layers_create_color_layer_24217(void *_); void layers_duplicate_layer(slot_layer_t *l); void layers_apply_masks(slot_layer_t *l); void layers_merge_down(); @@ -77,7 +69,6 @@ slot_layer_t *layers_merge_group(slot_layer_t *l); void layers_merge_layer(slot_layer_t *l0, slot_layer_t *l1, bool use_mask); slot_layer_t *layers_flatten(bool height_to_normal, slot_layer_t_array_t *layers); void layers_on_resized(); -void layers_on_resized_26530(void *_); slot_font_t *slot_font_create(char *name, draw_font_t *font, char *file); buffer_t *util_encode_scene(scene_t *raw); void util_encode_node_canvas(ui_node_canvas_t *c); @@ -125,52 +116,25 @@ void physics_body_apply_impulse(physics_body_t *body, vec4_ void physics_body_sync_transform(physics_body_t *body); void physics_body_update(physics_body_t *body); void box_export_show_textures(); -void box_export_show_textures_34135(); void box_export_show_bake_material(); -void box_export_show_bake_material_34221(); void box_export_tab_export_textures(char *title, bool bake_material); -void box_export_tab_export_textures_34447(void *_); -void box_export_tab_export_textures_34832(void *_); -void box_export_tab_export_textures_34883(char *path); -void box_export_tab_export_textures_34904(void *_); void box_export_tab_presets(); -void box_export_tab_presets_35057(); -void box_export_tab_presets_35201(char *path); -void box_export_tab_presets_35468(); void box_export_tab_atlases(); void box_export_show_mesh(); -void box_export_show_mesh_36017(); void box_export_tab_export_mesh(ui_handle_t *htab); -void box_export_tab_export_mesh_36414(char *path); void box_export_show_material(); -void box_export_show_material_36528(); -void box_export_show_material_36663(char *path); -void box_export_show_material_36694(char *path); void box_export_show_brush(); -void box_export_show_brush_36731(); -void box_export_show_brush_36866(char *path); -void box_export_show_brush_36895(char *path); void box_export_fetch_presets(); void box_export_parse_preset(); void box_export_new_preset(char *name); void box_export_save_preset(); char *box_export_preset_to_json(export_preset_t *p); void import_blend_mesh_ui(); -void import_blend_mesh_ui_37327(char *path); void import_blend_mesh_run(char *path, bool replace_existing); void tab_console_draw(ui_handle_t *htab); -void tab_console_draw_37642(char *path); void tab_textures_draw(ui_handle_t *htab); -void tab_textures_draw_37950(char *path); -void tab_textures_draw_38621(); -void tab_textures_draw_38648(char *path); -void tab_textures_draw_38661(void *_); -void tab_textures_draw_38721(gpu_texture_t *target); -void tab_textures_draw_38855(void *_); -void tab_textures_draw_38888(void *_); void tab_textures_update_texture_pointers(ui_node_t_array_t *nodes, i32 index); void tab_textures_delete_texture(asset_t *asset); -void tab_textures_delete_texture_39524(void *_); void render_path_forward_init(); void render_path_forward_commands(); void render_path_forward_draw_forward(); @@ -183,38 +147,22 @@ void slot_material_unload(slot_material_t *raw); void slot_material_delete(slot_material_t *raw); void make_clone_run(node_shader_t *kong); void tab_brushes_draw(ui_handle_t *htab); -void tab_brushes_draw_41711(); -void tab_brushes_draw_41764(void *_); -void tab_brushes_draw_41872(void *_); void tab_brushes_delete_brush(slot_brush_t *b); gpu_pipeline_t *_pipes_make_merge(bool red, bool green, bool blue, bool alpha); void pipes_init(); i32 pipes_get_constant_location(char *type); void make_brush_run(node_shader_t *kong); void import_blend_material_run(char *path); -void import_blend_material_run_43663(); void _import_blend_material(); -void _import_blend_material_43775(void *_); void import_texture_run(char *path, bool hdr_as_envmap); -void import_texture_run_44011(import_texture_data_t *itd); -void import_texture_run_44274(import_texture_data_t *itd); gpu_texture_t *import_texture_default_importer(char *path); void ui_files_show(char *filters, bool is_save, bool open_multiple, void (*files_done)(char *)); void ui_files_release_keys(); draw_cloud_icon_data_t *make_draw_cloud_icon_data(char *f, gpu_texture_t *image); char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, bool refresh, void (*context_menu)(char *)); -void ui_files_file_browser_44862(); -void ui_files_file_browser_45653(char *abs); -void ui_files_file_browser_45742(draw_cloud_icon_data_t *data); void ui_files_make_icon(ui_files_make_icon_t *args); void ui_files_go_up(ui_handle_t *handle); void base_init(); -void base_init_47689(char *drop_path); -void base_init_47715(); -void base_init_47733(); -void base_init_47739(); -void base_init_47745(); -void base_init_47765(); void base_save_and_quit_callback(bool save); i32 base_w(); i32 base_view3d_w(); @@ -225,7 +173,6 @@ void base_on_resize(); void base_save_window_rect(); void base_resize(); void base_update(void *_); -void base_update_49189(); void base_material_dropped(); void base_handle_drop_paths(); rect_t *base_get_drag_background(); @@ -243,20 +190,14 @@ ui_handle_t_array_t *ui_base_init_htabs(); tab_draw_t *_draw_callback_create(void (*f)(ui_handle_t *)); tab_draw_array_t_array_t *ui_base_init_hwnd_tabs(); void ui_base_init(); -void ui_base_init_51221(void *_); void ui_base_update(void *_); -void ui_base_update_51603(void *_); -void ui_base_update_53274(); -void ui_base_update_54293(mesh_object_t *mo); void ui_base_view_top(); void ui_base_operator_search(); -void ui_base_operator_search_54472(); void ui_base_toggle_distract_free(); f32 ui_base_get_radius_increment(); bool ui_base_hit_rect(f32 mx, f32 my, i32 x, i32 y, i32 w, i32 h); rect_t *ui_base_get_brush_stencil_rect(); void ui_base_update_ui(); -void ui_base_update_ui_56026(void *_); void ui_base_render(void *_); void ui_base_render_cursor(void *_); void ui_base_show_material_nodes(); @@ -277,7 +218,6 @@ void context_init(); bool context_use_deferred(); void context_select_material(i32 i); void context_set_material(slot_material_t *m); -void context_set_material_62876(void *_); void context_select_brush(i32 i); void context_set_brush(slot_brush_t *b); void context_select_font(i32 i); @@ -309,7 +249,6 @@ void context_load_envmap(); void context_update_envmap(); void context_set_viewport_shader(void *viewport_shader); void context_set_render_path(); -void context_set_render_path_64096(void *_); bool context_enable_import_plugin(char *file); void context_set_swatch(swatch_color_t *s); node_shader_t *node_shader_create(node_shader_context_t *context); @@ -335,13 +274,11 @@ void node_shader_context_add_texture_unit(node_shader_conte node_shader_t *node_shader_context_make_kong(node_shader_context_t *raw); void ui_toolbar_init(); void ui_toolbar_draw_tool(i32 tool, gpu_texture_t *img, i32 icon_accent); -void ui_toolbar_draw_tool_66386(void *_); i32 ui_toolbar_w(bool screen_size_request); i32 ui_toolbar_x(); void ui_toolbar_draw_show_3d_view(); void ui_toolbar_render_ui(); void ui_toolbar_tool_properties_menu(); -void ui_toolbar_tool_properties_menu_67427(); void ui_toolbar_draw_highlight(); void export_arm_run_mesh(char *path, mesh_object_t_array_t *paint_objects); void export_arm_run_project(); @@ -359,29 +296,21 @@ void export_arm_run_swatches(char *path); f32_array_t *export_arm_vec3f32(vec4_t v); buffer_t *export_arm_rgba64_to_rgba32(buffer_t *buffer); void import_asset_run(char *path, f32 drop_x, f32 drop_y, bool show_box, bool hdr_as_envmap, void (*done)(void)); -void import_asset_run_70884(char *abs); void make_particle_mask(node_shader_t *kong); void uniforms_ext_init(); i32 uniforms_ext_i32_link(object_t *object, material_data_t *mat, char *link); f32 uniforms_ext_f32_link(object_t *object, material_data_t *mat, char *link); vec2_t uniforms_ext_vec2_link(object_t *object, material_data_t *mat, char *link); vec4_t uniforms_ext_vec3_link(object_t *object, material_data_t *mat, char *link); -f32 vec2d(f32 x); +f32 uniforms_ext_vec2d(f32 x); vec4_t uniforms_ext_vec4_link(object_t *object, material_data_t *mat, char *link); mat4_t uniforms_ext_mat4_link(object_t *object, material_data_t *mat, char *link); gpu_texture_t *uniforms_ext_tex_link(object_t *object, material_data_t *mat, char *link); -void uniforms_ext_tex_link_73441(void *_); -void uniforms_ext_tex_link_73476(void *_); -void uniforms_ext_tex_link_73505(void *_); void render_path_deferred_init(); void render_path_deferred_commands(); void render_path_deferred_draw_deferred(); void box_projects_show(); -void box_projects_show_74688(); void box_projects_tab(); -void box_projects_tab_75329(char *path); -void box_projects_tab_75398(); -void box_projects_tab_75419(void *_); void box_projects_recent_tab(); void box_projects_draw_badge(); void box_projects_get_started_tab(); @@ -389,18 +318,7 @@ void box_projects_align_to_fullscreen(); node_shader_context_t *make_node_preview_run(material_t *data, material_context_t *matcon, ui_node_t *node, ui_node_canvas_t *group, ui_node_t_array_t *parents); void history_undo(); -void history_undo_76821(void *_); -void history_undo_77442(history_step_t *step); void history_redo(); -void history_redo_78106(slot_layer_t *l); -void history_redo_78139(slot_layer_t *l); -void history_redo_78179(slot_layer_t *l); -void history_redo_78330(void *_); -void history_redo_78447(void *_); -void history_redo_78524(void *_); -void history_redo_78540(void *_); -void history_redo_78638(void *_); -void history_redo_78676(history_step_t *step); void history_reset(); void history_edit_nodes(ui_node_canvas_t *canvas, i32 canvas_type, i32 canvas_group); void history_paint(); @@ -428,7 +346,6 @@ void history_delete_material(); void history_duplicate_material(); void history_delete_material_group(node_group_t *group); history_step_t *history_push(char *name); -void history_redo_merge_layers(); void history_copy_merging_layers(); void history_copy_merging_layers2(slot_layer_t_array_t *layers); void history_swap_active(); @@ -437,9 +354,6 @@ ui_node_canvas_t *history_get_canvas(history_step_t *step); void history_set_canvas(history_step_t *step, ui_node_canvas_t *canvas); void history_swap_canvas(history_step_t *step); void tab_scripts_draw(ui_handle_t *htab); -void tab_scripts_draw_80816(); -void tab_scripts_draw_80863(char *path); -void tab_scripts_draw_80919(char *path); ui_text_coloring_t *tab_scripts_get_text_coloring(); void render_path_preview_init(); void render_path_preview_commands_preview(); @@ -450,12 +364,7 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *m node_shader_context_t *make_mesh_preview_run(material_t *data, material_context_t *matcon); void import_mesh_run(char *path, bool _clear_layers, bool replace_existing); void import_mesh_finish_import(); -i32 import_mesh_finish_import_85673(void **pa, void **pb); void _import_mesh_make_mesh(raw_mesh_t *mesh); -void _import_mesh_make_mesh_85887(mesh_data_t *md); -void _import_mesh_make_mesh_86005(void *_); -void _import_mesh_make_mesh_86033(void *_); -void _import_mesh_make_mesh_86052(void *_); void import_mesh_first_unwrap_done(raw_mesh_t *mesh); void import_mesh_make_mesh(raw_mesh_t *mesh); bool _import_mesh_is_unique_name(char *s); @@ -468,22 +377,14 @@ i32 ui_menu_panel_x(); i32 ui_menu_top_y(); i32 ui_menu_panel_y(); void ui_menubar_render_ui(); -void ui_menubar_render_ui_87020(void *_); -void ui_menubar_render_ui_87029(void *_); void ui_menubar_draw_tab_header(); void ui_menubar_draw_category_items(); -void ui_menubar_draw_category_items_87924(char *path); -void ui_menubar_draw_category_items_89069(void *_); -void ui_menubar_draw_category_items_90507(char *url, buffer_t *buffer); -void ui_menubar_draw_category_items_90774(); void ui_menubar_show_menu(i32 category); bool ui_menubar_icon_button(i32 i); char *_tr(char *s); char *tr(char *id, any_map_t *vars); void translator_load_translations(char *new_locale); -void translator_load_translations_91848(char *url); void translator_init_font(bool cjk, char *font_path, f32 font_scale); -void translator_init_font_91962(void *_); void translator_extended_glyphs(); string_t_array_t *translator_get_supported_locales(); logic_node_t *logic_node_create(logic_node_ext_t *ext); @@ -498,17 +399,13 @@ logic_node_value_t *logic_node_input_get(logic_node_input_t *self); gpu_texture_t *logic_node_input_get_as_image(logic_node_input_t *self); void logic_node_input_set(logic_node_input_t *self, f32_array_t *value); void import_arm_run_project(char *path); -void import_arm_run_project_94619(void *_); void import_arm_run_mesh(project_format_t *raw); -void import_arm_run_mesh_94821(void *_); void import_arm_run_material(char *path); void import_arm_run_material_from_project(project_format_t *project, char *path); -void import_arm_run_material_from_project_95252(slot_material_t_array_t *imported); bool import_arm_group_exists(ui_node_canvas_t *c); void import_arm_rename_group(char *name, slot_material_t_array_t *materials, ui_node_canvas_t_array_t *groups); void import_arm_run_brush(char *path); void import_arm_run_brush_from_project(project_format_t *project, char *path); -void import_arm_run_brush_from_project_95818(slot_brush_t_array_t *imported); void import_arm_run_swatches(char *path, bool replace_existing); void import_arm_run_swatches_from_project(project_format_t *project, char *path, bool replace_existing); void import_arm_make_pink(char *abs); @@ -524,12 +421,7 @@ void viewport_zoom(f32 f); void viewport_update_camera_type(i32 camera_type); void viewport_capture_screenshot(); void tab_fonts_draw(ui_handle_t *htab); -void tab_fonts_draw_97837(void *_); -void tab_fonts_draw_97897(void *_); -void tab_fonts_draw_97911(); -void tab_fonts_draw_97983(void *_); void tab_fonts_delete_font(slot_font_t *font); -void tab_fonts_delete_font_98187(slot_font_t *font); physics_world_t *physics_world_create(); void physics_world_update(physics_world_t *world); physics_pair_t_array_t *physics_world_get_contact_pairs(physics_world_t *world, physics_body_t *body); @@ -577,53 +469,35 @@ char *strings_asset_already_imported(); char *strings_graphics_api(); void tab_history_draw(ui_handle_t *htab); void project_open(); -void project_open_102526(char *path); void project_save(bool save_and_quit); -void project_save_102708(void *_); void project_save_as(bool save_and_quit); -void project_save_as_102755(char *path); void project_fetch_default_meshes(); void project_new_box(); -void project_new_box_102911(); void project_cleanup(); void project_new(bool reset_layers); -void project_new_103839(void *_); -void project_new_103856(void *_); -void project_new_103903(void *_); void project_set_default_envmap(); void project_import_material(); -void project_import_material_103991(char *path); ui_node_link_t *project_create_node_link(ui_node_link_t_array_t *links, i32 from_id, i32 from_socket, i32 to_id, i32 to_socket); void project_import_brush(); -void project_import_brush_104110(char *path); -void project_import_brush_104258(void *_); void project_import_mesh(bool replace_existing, void (*done)(void)); -void project_import_mesh_104385(char *path); void project_append_mesh(); void project_import_mesh_box(char *path, bool replace_existing, bool clear_layers, void (*done)(void)); -void project_import_mesh_box_104467(); void project_reimport_mesh(); string_t_array_t *project_get_unwrap_plugins(); void project_unwrap_mesh_box(raw_mesh_t *mesh, void (*done)(raw_mesh_t *), bool skip_ui); -void project_unwrap_mesh_box_104919(); void project_unwrap_mesh(raw_mesh_t *mesh, void (*done)(raw_mesh_t *)); void project_import_asset(char *filters, bool hdr_as_envmap); -void project_import_asset_105217(char *path); void project_import_swatches(bool replace_existing); -void project_import_swatches_105263(char *path); void project_reimport_textures(); void project_reimport_texture_load(char *path, asset_t *asset); -void project_reimport_texture_load_105445(void *_); void project_reimport_texture(asset_t *asset); -void project_reimport_texture_105515(char *path); gpu_texture_t *project_get_image(asset_t *asset); string_t_array_t *project_get_used_atlases(); bool project_is_atlas_object(mesh_object_t *p); mesh_object_t_array_t *project_get_atlas_objects(i32 object_mask); bool project_packed_asset_exists(packed_asset_t_array_t *packed_assets, char *name); void project_export_swatches(); -void project_export_swatches_105968(char *path); -swatch_color_t *make_swatch(i32 base); +swatch_color_t *project_make_swatch(i32 base); swatch_color_t *project_clone_swatch(swatch_color_t *swatch); void project_set_default_swatches(); node_group_t *project_get_material_group_by_name(char *group_name); @@ -635,7 +509,6 @@ any_map_t *keymap_get_default(); void ui_view2d_init(); void ui_view2d_draw_image(gpu_texture_t *image, f32 dx, f32 dy, f32 dw, f32 dh, i32 channel); void ui_view2d_render(void *_); -void ui_view2d_render_109006(void *_); void ui_view2d_update(void *_); void make_colorid_picker_run(node_shader_t *kong); void sim_init(); @@ -683,14 +556,11 @@ bind_tex_t *parser_material_make_bind_tex(char *tex_name, char *fi char *u8_array_string_at(u8_array_t *a, i32 i); void args_parse(); void args_run(); -void args_run_115314(void *_); -void args_run_115626(void *_); void util_render_make_material_preview(); void util_render_make_decal_preview(); void util_render_make_text_preview(); void util_render_make_font_preview(); void util_render_make_brush_preview(); -void util_render_make_brush_preview_117467(void *_); void util_render_make_node_preview(ui_node_canvas_t *canvas, ui_node_t *node, gpu_texture_t *image, ui_node_canvas_t *group, ui_node_t_array_t *parents); void util_render_pick_pos_nor_tex(); mat4_t util_render_get_decal_mat(); @@ -700,55 +570,32 @@ void tab_materials_draw_mini(ui_handle_t *htab); void tab_materials_draw_full(ui_handle_t *htab); void tab_materials_button_nodes(); void tab_materials_draw_slots(bool mini); -void tab_materials_draw_slots_119149(void *_); -void tab_materials_draw_slots_119244(); -void tab_materials_draw_slots_119357(void *_); void tab_materials_button_new(char *text); -void tab_materials_button_new_120110(void *_); void tab_materials_update_material(); void tab_materials_update_material_pointers(ui_node_t_array_t *nodes, i32 i); void tab_materials_accept_swatch_drop(swatch_color_t *swatch); void tab_materials_delete_material(slot_material_t *m); void tab_browser_show_directory(char *directory); void tab_browser_draw(ui_handle_t *htab); -void tab_browser_draw_121079(); -void tab_browser_draw_121442(char *file); -void tab_browser_draw_121455(); -void tab_browser_draw_121522(); -void tab_browser_draw_121528(void *_); -void tab_browser_draw_121639(); -void tab_browser_draw_121645(void *_); -void tab_browser_draw_121751(); -void tab_browser_draw_121757(void *_); -void tab_browser_draw_121898(char *path); -void tab_browser_draw_122149(); void tab_browser_go_to_cloud(); void tab_browser_go_to_disk(); -void tab_browser_go_to_disk_122217(); void util_mesh_merge(mesh_object_t_array_t *paint_objects); void util_mesh_remove_merged(); void util_mesh_swap_axis(i32 a, i32 b); void util_mesh_flip_normals(); void util_mesh_calc_normals(bool smooth); -i32 util_mesh_calc_normals_123905(i32 *pa, i32 *pb); void util_mesh_to_origin(); void util_mesh_apply_displacement(gpu_texture_t *texpaint_pack, f32 strength, f32 uv_scale); void util_mesh_equirect_unwrap(raw_mesh_t *mesh); bool util_mesh_pnpoly(f32 v0x, f32 v0y, f32 v1x, f32 v1y, f32 v2x, f32 v2y, f32 px, f32 py); vec4_t util_mesh_calc_normal(vec4_t p0, vec4_t p1, vec4_t p2); void util_mesh_decimate(f32 strength); -i32 util_mesh_decimate_126650(i32 *pa, i32 *pb); i32 _util_mesh_unique_data_count(); void util_mesh_pack_uvs(i16_array_t *texa); mesh_object_t_array_t *util_mesh_get_unique(); void ui_header_init(); void ui_header_render_ui(); void ui_header_draw_tool_properties(); -void ui_header_draw_tool_properties_128014(char *path); -void ui_header_draw_tool_properties_128151(slot_layer_t *m); -void ui_header_draw_tool_properties_128370(); -void ui_header_draw_tool_properties_128541(); -void ui_header_draw_tool_properties_128937(void *_); plugin_t *plugin_create(); void plugin_start(char *plugin); void plugin_stop(char *plugin); @@ -773,7 +620,6 @@ gpu_texture_t *resource_get(char *name); rect_t *resource_tile50(gpu_texture_t *img, i32 i); rect_t *resource_tile18(gpu_texture_t *img, i32 i); bool render_path_raytrace_bake_commands(void (*parse_paint_material)(bool)); -void render_path_raytrace_bake_commands_134003(void (*parse_paint_material)(bool)); char *render_path_raytrace_bake_get_bake_shader_name(); bool make_material_get_mout(); void make_material_parse_mesh_material(); @@ -788,26 +634,12 @@ char *make_material_blend_mode(node_shader_t *kong, i32 b char *make_material_blend_mode_mask(node_shader_t *kong, i32 blending, char *cola, char *colb, char *opac); f32 make_material_get_displace_strength(); void make_material_delete_context(shader_context_t *c); -void make_material_delete_context_137861(shader_context_t *c); void ui_viewnodes_init(); void ui_viewnodes_on_node_remove(ui_node_t *n); void ui_viewnodes_on_node_changed(ui_node_t *n); void ui_viewnodes_on_link_drag(i32 link_drag_id, bool is_new_link); -void ui_viewnodes_on_link_drag_138508(); void ui_viewnodes_on_socket_released(i32 socket_id); -void ui_viewnodes_on_socket_released_138790(void *_); -void ui_viewnodes_on_socket_released_138799(); -void ui_viewnodes_on_socket_released_138920(void *_); -void ui_viewnodes_on_socket_released_138933(); void ui_viewnodes_on_canvas_released(); -void ui_viewnodes_on_canvas_released_139616(); -void ui_viewnodes_on_canvas_released_139678(void *_); -void ui_viewnodes_on_canvas_released_139722(void *_); -void ui_viewnodes_on_canvas_released_139764(void *_); -void ui_viewnodes_on_canvas_released_139809(void *_); -void ui_viewnodes_on_canvas_released_139818(void *_); -void ui_viewnodes_on_canvas_released_139861(void *_); -void ui_viewnodes_on_canvas_released_139995(void *_); ui_canvas_control_t *ui_viewnodes_on_canvas_control(); ui_canvas_control_t *ui_nodes_get_canvas_control(bool controls_down); f32 ui_nodes_get_zoom_delta(); @@ -818,17 +650,14 @@ ui_nodes_t *ui_nodes_get_nodes(); void ui_nodes_update(void *_); void ui_nodes_canvas_changed(); void ui_nodes_node_search(i32 x, i32 y, void (*done)(void)); -void ui_nodes_node_search_141325(); i32 ui_nodes_get_node_x(); i32 ui_nodes_get_node_y(); gpu_texture_t *ui_nodes_draw_grid(f32 zoom); void ui_nodes_recompile(); void ui_nodes_get_linked_nodes(ui_node_t_array_t *linked_nodes, ui_node_t *n, ui_node_canvas_t *c); void ui_nodes_render(void *_); -void ui_nodes_render_143289(swatch_color_t *color); gpu_texture_t *ui_nodes_get_node_preview_image(ui_node_t *n); void ui_nodes_draw_menubar(); -void ui_nodes_draw_menubar_145222(void *_); bool ui_nodes_contains_node_group_recursive(node_group_t *group, char *group_name); bool ui_nodes_can_place_group(char *group_name); void ui_nodes_push_undo(ui_node_canvas_t *last_canvas); @@ -896,7 +725,6 @@ void export_obj_run(char *path, mesh_object_t_array_t *p void export_obj_run_fast(char *path, mesh_object_t_array_t *paint_objects); void make_blur_run(node_shader_t *kong); void import_font_run(char *path); -void import_font_run_158599(slot_font_t_array_t *font_slots); void export_exr_write_string(u8_array_t *out, char *str); void export_exr_write_line16(i32 byte_pos); void export_exr_write_line32(i32 byte_pos); @@ -929,36 +757,18 @@ void camera_pan_action(bool modif, bool default_keymap); f32 camera_get_zoom_delta(); void camera_set_pivot_center_to_mouse(); void box_preferences_interface_tab(); -void box_preferences_interface_tab_170050(); -void box_preferences_interface_tab_170071(void *_); -void box_preferences_interface_tab_170178(char *path); -void box_preferences_interface_tab_170210(config_t *raw); -void box_preferences_interface_tab_170267(); void box_preferences_theme_tab(); -void box_preferences_theme_tab_170385(); -void box_preferences_theme_tab_170563(char *path); -void box_preferences_theme_tab_170600(char *path); -void box_preferences_theme_tab_170797(); void box_preferences_usage_tab(); void box_preferences_pen_tab(); void box_preferences_viewport_tab(); void box_preferences_keymap_tab(); -void box_preferences_keymap_tab_172800(); -void box_preferences_keymap_tab_172980(char *path); -void box_preferences_keymap_tab_173017(char *dest); void box_preferences_neural_tab(); bool box_preferences_model_exists(char *file_name); char *box_preferences_file_name_from_url(char *url); char *box_preferneces_model_url_from_name(char *name); void box_preferences_model_panel(neural_node_model_t *m); void box_preferences_plugins_tab(); -void box_preferences_plugins_tab_173894(); -void box_preferences_plugins_tab_174059(char *path); -void box_preferences_plugins_tab_174255(); -void box_preferences_plugins_tab_174362(char *dest); void box_preferences_show(); -void box_preferences_show_174484(); -void box_preferences_show_174671(); void box_preferences_fetch_themes(); void box_preferences_fetch_keymaps(); void box_preferences_fetch_plugins(); @@ -980,12 +790,9 @@ void render_path_paint_begin(); void render_path_paint_end(); void _render_path_paint_final(); void _render_path_paint_deriv(); -void _render_path_paint_deriv_178293(void *_); bool render_path_paint_is_rt_bake(); void render_path_paint_update_bake_layer(texture_bits_t bits); void render_path_paint_draw(); -void render_path_paint_draw_178546(void *_); -void render_path_paint_draw_178565(void *_); void render_path_paint_set_plane_mesh(); void render_path_paint_restore_plane_mesh(); void render_path_paint_bind_layers(); @@ -1012,19 +819,12 @@ void ui_box_tween_out(); void ui_box_tween_tick(); void ui_box_window_border(); void tab_meshes_draw(ui_handle_t *htab); -void tab_meshes_draw_185838(); -void tab_meshes_draw_185904(); -void tab_meshes_draw_185981(); -void tab_meshes_draw_186425(); void tab_meshes_draw_properties(mesh_object_t *o); void tab_meshes_append_shape(char *mesh_name); void tab_scene_select_object(mesh_object_t *mo); void tab_scene_sort(); -i32 tab_scene_sort_187924(void **pa, void **pb); void tab_scene_import_mesh_done(); -void tab_scene_import_mesh_done_188032(void *_); void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object); -void tab_scene_draw_list_188308(); void tab_scene_draw(ui_handle_t *htab); void util_particle_init(); void util_particle_init_physics(); @@ -1036,14 +836,6 @@ void tab_layers_button_2d_view(); void tab_layers_draw_slots(bool mini); void tab_layers_highlight_odd_lines(); void tab_layers_button_new(char *text); -void tab_layers_button_new_189383(); -void tab_layers_button_new_189418(void *_); -void tab_layers_button_new_189550(slot_layer_t *m); -void tab_layers_button_new_189579(void *_); -void tab_layers_button_new_189641(slot_layer_t *m); -void tab_layers_button_new_189670(void *_); -void tab_layers_button_new_189732(slot_layer_t *m); -void tab_layers_button_new_189759(void *_); void tab_layers_combo_filter(); void tab_layers_remap_layer_pointers(ui_node_t_array_t *nodes, i32_imap_t *pointer_map); i32_map_t *tab_layers_init_layer_map(); @@ -1052,9 +844,7 @@ void tab_layers_set_drag_layer(slot_layer_t *layer, f32 void tab_layers_draw_layer_slot(slot_layer_t *l, i32 i, bool mini); void tab_layers_draw_layer_slot_mini(slot_layer_t *l, i32 i); void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i); -void tab_layers_draw_layer_slot_full_191697(void *_); ui_handle_t *tab_layers_combo_object(slot_layer_t *l, bool label); -void tab_layers_combo_object_192061(slot_layer_t *l); ui_handle_t *tab_layers_combo_blending(slot_layer_t *l, bool label); void tab_layers_layer_toggle_visible(slot_layer_t *l); void tab_layers_draw_layer_highlight(slot_layer_t *l, bool mini); @@ -1062,23 +852,7 @@ void tab_layers_handle_layer_icon_state(slot_layer_t *l, ui_state_t tab_layers_draw_layer_icon(slot_layer_t *l, i32 i, f32 uix, f32 uiy, bool mini); bool tab_layers_can_merge_down(slot_layer_t *l); void tab_layers_draw_layer_context_menu(slot_layer_t *l, bool mini); -void tab_layers_draw_layer_context_menu_193275(); -void tab_layers_draw_layer_context_menu_193420(char *path); -void tab_layers_draw_layer_context_menu_193575(void *_); -void tab_layers_draw_layer_context_menu_193629(void *_); -void tab_layers_draw_layer_context_menu_193690(void *_); -void tab_layers_draw_layer_context_menu_193736(void *_); -void tab_layers_draw_layer_context_menu_193857(void *_); -void tab_layers_draw_layer_context_menu_193911(void *_); -void tab_layers_draw_layer_context_menu_193973(void *_); -void tab_layers_draw_layer_context_menu_194020(void *_); -void tab_layers_draw_layer_context_menu_194083(void *_); -void tab_layers_draw_layer_context_menu_194437(void *_); -void tab_layers_draw_layer_context_menu_194526(void *_); -void tab_layers_draw_layer_context_menu_194609(void *_); -void tab_layers_draw_layer_context_menu_194707(void *_); void tab_layers_make_mask_preview_rgba32(slot_layer_t *l); -void tab_layers_make_mask_preview_rgba32_195198(void *_); void tab_layers_delete_layer(slot_layer_t *l); bool tab_layers_can_delete(slot_layer_t *l); bool tab_layers_can_drop_new_layer(i32 position); @@ -1129,7 +903,6 @@ void blur_node_init(); char *blur_node_vector(ui_node_t *node, ui_node_socket_t *socket); void text_texture_node_init(); void _parser_material_cache_tex_text_node(char *file, char *text); -void _parser_material_cache_tex_text_node_205902(char *text); char *text_texture_node_vector(ui_node_t *node, ui_node_socket_t *socket); char *text_texture_node_value(ui_node_t *node, ui_node_socket_t *socket); void gradient_texture_node_init(); @@ -1261,15 +1034,9 @@ char *image_to_pbr_node_vector(ui_node_t *node, ui_node_socket_t * char *image_to_pbr_node_value(ui_node_t *node, ui_node_socket_t *socket); void image_to_pbr_node_run_sd(char *model, char *prompt, void (*done)(gpu_texture_t *)); void image_to_pbr_node_button(i32 node_id); -void image_to_pbr_node_button_233087(gpu_texture_t *tex); -void image_to_pbr_node_button_233104(gpu_texture_t *tex); -void image_to_pbr_node_button_233121(gpu_texture_t *tex); -void image_to_pbr_node_button_233138(gpu_texture_t *tex); -void image_to_pbr_node_button_233151(void *_); void image_to_pbr_node_check_result(void (*done)(gpu_texture_t *)); void inpaint_image_node_init(); void inpaint_image_node_button(i32 node_id); -void inpaint_image_node_button_234029(ui_node_t *node); void text_to_image_node_init(); string_t_array_t *text_to_image_node_sd_args(char *dir, char *prompt); string_t_array_t *text_to_image_node_zimage_args(char *dir, char *prompt); @@ -1278,33 +1045,27 @@ string_t_array_t *text_to_image_node_wan_args(char *dir, char *prompt); void text_to_image_node_button(i32 node_id); void outpaint_image_node_init(); void outpaint_image_node_button(i32 node_id); -void outpaint_image_node_button_235809(ui_node_t *node); char *neural_node_vector(ui_node_t *node, ui_node_socket_t *socket); char *neural_node_value(ui_node_t *node, ui_node_socket_t *socket); ui_node_t *neural_from_node(ui_node_socket_t *inp, i32 socket); bool neural_node_button(ui_node_t *node, char *model); -void neural_node_button_236824(void *_); void neural_node_check_result(ui_node_t *node); char *neural_node_sd_bin_ext(); char *neural_node_sd_bin(); char *neural_node_dir(); void neural_node_download(char *url); -void neural_node_download_237123(char *url); -void neural_node_download_237227(void *_); void neural_node_download_models(string_t_array_t *models); void neural_node_models_init(); void edit_image_node_init(); void edit_image_node_button(i32 node_id); void tile_image_node_init(); void tile_image_node_button(i32 node_id); -void tile_image_node_button_238443(ui_node_t *node); void image_to_3d_mesh_node_init(); buffer_t *image_to_3d_mesh_node_remove_background(buffer_t *buffer); void image_to_3d_mesh_node_button(i32 node_id); void image_to_3d_mesh_node_check_result(ui_node_t *node); void vary_image_node_init(); void vary_image_node_button(i32 node_id); -void vary_image_node_button_240006(ui_node_t *node); void image_to_normal_map_node_init(); void image_to_normal_map_node_button(i32 node_id); void image_to_depth_node_init(); diff --git a/paint/sources/history.c b/paint/sources/history.c index 006dcb31..d173079c 100644 --- a/paint/sources/history.c +++ b/paint/sources/history.c @@ -1,6 +1,23 @@ #include "global.h" +void history_undo_invert_mask(history_step_t *step) { + context_raw->layer = project_layers->buffer[step->layer]; + slot_layer_invert_mask(context_raw->layer); +} + +void history_undo_delete_layer_group(void *_) { + i32 active = history_steps->length - 1 - history_redos; + // 1. Undo deleting group masks + i32 n = 1; + while (history_steps->buffer[active - n]->layer_type == LAYER_SLOT_TYPE_MASK) { + history_undo(); + ++n; + } + // 2. Undo a mask to have a non empty group + history_undo(); +} + void history_undo() { if (history_undos > 0) { i32 active = history_steps->length - 1 - history_redos; @@ -37,7 +54,7 @@ void history_undo() { // Undo at least second time in order to avoid empty groups if (step->layer_type == LAYER_SLOT_TYPE_GROUP) { - sys_notify_on_next_frame(&history_undo_76821, NULL); + sys_notify_on_next_frame(&history_undo_delete_layer_group, NULL); } } else if (string_equals(step->name, tr("Clear Layer", NULL))) { @@ -131,7 +148,7 @@ void history_undo() { context_set_layer(context_raw->layer); } else if (string_equals(step->name, tr("Invert Mask", NULL))) { - sys_notify_on_next_frame(&history_undo_77442, step); + sys_notify_on_next_frame(&history_undo_invert_mask, step); } else if (string_equals(step->name, "Apply Filter")) { history_undo_i = history_undo_i - 1 < 0 ? config_raw->undo_steps - 1 : history_undo_i - 1; @@ -216,21 +233,50 @@ void history_undo() { } } -void history_undo_77442(history_step_t *step) { +void history_redo_invert_mask(history_step_t *step) { context_raw->layer = project_layers->buffer[step->layer]; slot_layer_invert_mask(context_raw->layer); } -void history_undo_76821(void * _) { - i32 active = history_steps->length - 1 - history_redos; - // 1. Undo deleting group masks - i32 n = 1; - while (history_steps->buffer[active - n]->layer_type == LAYER_SLOT_TYPE_MASK) { - history_undo(); +void history_redo_apply_mask(void *_) { + slot_layer_apply_mask(context_raw->layer); + context_set_layer(context_raw->layer); + context_raw->layers_preview_dirty = true; +} + +void history_redo_merge_layers2(void *_) { + layers_merge_down(); +} + +void history_redo_merge_layers(void *_) { + history_copy_merging_layers(); +} + +void history_redo_duplicate_layer(void *_) { + layers_duplicate_layer(context_raw->layer); +} + +void history_redo_delete_layer(void *_) { + i32 active = history_steps->length - history_redos; + i32 n = 1; + while (history_steps->buffer[active + n]->layer_type == LAYER_SLOT_TYPE_MASK) { ++n; } - // 2. Undo a mask to have a non empty group - history_undo(); + for (i32 i = 0; i < n; ++i) { + history_redo(); + } +} + +void history_redo_new_fill_mask(slot_layer_t *l) { + slot_layer_to_fill_layer(l); +} + +void history_redo_new_white_mask(slot_layer_t *l) { + slot_layer_clear(l, 0xffffffff, NULL, 1.0, layers_default_rough, 0.0); +} + +void history_redo_new_black_mask(slot_layer_t *l) { + slot_layer_clear(l, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); } void history_redo() { @@ -247,14 +293,14 @@ void history_redo() { slot_layer_t *l = slot_layer_create("", step->layer_type, parent); array_insert(project_layers, step->layer, l); if (string_equals(step->name, tr("New Black Mask", NULL))) { - sys_notify_on_next_frame(&history_redo_78106, l); + sys_notify_on_next_frame(&history_redo_new_black_mask, l); } else if (string_equals(step->name, tr("New White Mask", NULL))) { - sys_notify_on_next_frame(&history_redo_78139, l); + sys_notify_on_next_frame(&history_redo_new_white_mask, l); } else if (string_equals(step->name, tr("New Fill Mask", NULL))) { context_raw->material = project_materials->buffer[step->material]; - sys_notify_on_next_frame(&history_redo_78179, l); + sys_notify_on_next_frame(&history_redo_new_fill_mask, l); } context_raw->layer_preview_dirty = true; context_set_layer(l); @@ -277,7 +323,7 @@ void history_redo() { if (step->layer_type == LAYER_SLOT_TYPE_LAYER && history_steps->length >= active + 2 && (history_steps->buffer[active + 1]->layer_type == LAYER_SLOT_TYPE_GROUP || history_steps->buffer[active + 1]->layer_type == LAYER_SLOT_TYPE_MASK)) { - sys_notify_on_next_frame(&history_redo_78330, NULL); + sys_notify_on_next_frame(&history_redo_delete_layer, NULL); } } else if (string_equals(step->name, tr("Clear Layer", NULL))) { @@ -288,7 +334,7 @@ void history_redo() { } else if (string_equals(step->name, tr("Duplicate Layer", NULL))) { context_raw->layer = project_layers->buffer[step->layer]; - sys_notify_on_next_frame(&history_redo_78447, NULL); + sys_notify_on_next_frame(&history_redo_duplicate_layer, NULL); } else if (string_equals(step->name, tr("Order Layers", NULL))) { slot_layer_t *target = project_layers->buffer[step->prev_order]; @@ -297,8 +343,8 @@ void history_redo() { } else if (string_equals(step->name, tr("Merge Layers", NULL))) { context_raw->layer = project_layers->buffer[step->layer + 1]; - sys_notify_on_next_frame(&history_redo_78524, NULL); - sys_notify_on_next_frame(&history_redo_78540, NULL); + sys_notify_on_next_frame(&history_redo_merge_layers, NULL); + sys_notify_on_next_frame(&history_redo_merge_layers2, NULL); } else if (string_equals(step->name, tr("Apply Mask", NULL))) { context_raw->layer = project_layers->buffer[step->layer]; @@ -318,10 +364,10 @@ void history_redo() { history_copy_merging_layers2(layers); } - sys_notify_on_next_frame(&history_redo_78638, NULL); + sys_notify_on_next_frame(&history_redo_apply_mask, NULL); } else if (string_equals(step->name, tr("Invert Mask", NULL))) { - sys_notify_on_next_frame(&history_redo_78676, step); + sys_notify_on_next_frame(&history_redo_invert_mask, step); } else if (string_equals(step->name, tr("Apply Filter", NULL))) { slot_layer_t *lay = history_undo_layers->buffer[history_undo_i]; @@ -407,52 +453,6 @@ void history_redo() { } } -void history_redo_78676(history_step_t *step) { - context_raw->layer = project_layers->buffer[step->layer]; - slot_layer_invert_mask(context_raw->layer); -} - -void history_redo_78638(void * _) { - slot_layer_apply_mask(context_raw->layer); - context_set_layer(context_raw->layer); - context_raw->layers_preview_dirty = true; -} - -void history_redo_78540(void * _) { - layers_merge_down(); -} - -void history_redo_78524(void * _) { - history_redo_merge_layers(); -} - -void history_redo_78447(void * _) { - layers_duplicate_layer(context_raw->layer); -} - -void history_redo_78330(void * _) { - i32 active = history_steps->length - history_redos; - i32 n = 1; - while (history_steps->buffer[active + n]->layer_type == LAYER_SLOT_TYPE_MASK) { - ++n; - } - for (i32 i = 0; i < n; ++i) { - history_redo(); - } -} - -void history_redo_78179(slot_layer_t *l) { - slot_layer_to_fill_layer(l); -} - -void history_redo_78139(slot_layer_t *l) { - slot_layer_clear(l, 0xffffffff, NULL, 1.0, layers_default_rough, 0.0); -} - -void history_redo_78106(slot_layer_t *l) { - slot_layer_clear(l, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); -} - void history_reset() { gc_unroot(history_steps); history_steps = any_array_create_from_raw( @@ -621,12 +621,12 @@ void history_delete_material_group(node_group_t *group) { } history_step_t *history_push(char *name) { - #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) +#if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) char *filename = string_equals(project_filepath, "") - ? ui_files_filename - : substring(project_filepath, string_last_index_of(project_filepath, PATH_SEP) + 1, string_length(project_filepath) - 4); + ? ui_files_filename + : substring(project_filepath, string_last_index_of(project_filepath, PATH_SEP) + 1, string_length(project_filepath) - 4); sys_title_set(string_join(string_join(filename, "* - "), manifest_title)); - #endif +#endif if (config_raw->touch_ui) { // Refresh undo & redo buttons @@ -670,10 +670,6 @@ history_step_t *history_push(char *name) { return history_steps->buffer[history_steps->length - 1]; } -void history_redo_merge_layers() { - history_copy_merging_layers(); -} - void history_copy_merging_layers() { slot_layer_t *lay = context_raw->layer; history_copy_to_undo(lay->id, history_undo_i, slot_layer_is_mask(context_raw->layer)); @@ -725,8 +721,8 @@ void history_copy_to_undo(i32 from_id, i32 to_id, bool is_mask) { : GPU_TEXTURE_FORMAT_RGBA128; char *pipe = format == GPU_TEXTURE_FORMAT_RGBA32 ? "copy_mrt3_pass" - : format == GPU_TEXTURE_FORMAT_RGBA64 ? "copy_mrt3RGBA64_pass" - : "copy_mrt3RGBA128_pass"; + : format == GPU_TEXTURE_FORMAT_RGBA64 ? "copy_mrt3RGBA64_pass" + : "copy_mrt3RGBA128_pass"; render_path_draw_shader(string_join("Scene/copy_mrt3_pass/", pipe)); } history_undo_i = (history_undo_i + 1) % config_raw->undo_steps; diff --git a/paint/sources/import_arm.c b/paint/sources/import_arm.c index 0a6c339c..c47dfc1a 100644 --- a/paint/sources/import_arm.c +++ b/paint/sources/import_arm.c @@ -1,6 +1,16 @@ #include "global.h" +void import_arm_run_project_on_next_frame(void *_) { + // Once envmap is imported + scene_world->strength = project_raw->envmap_strength; + context_raw->envmap_angle = project_raw->envmap_angle; + context_raw->show_envmap_blur = project_raw->envmap_blur; + if (context_raw->show_envmap_blur) { + scene_world->_->envmap = scene_world->_->radiance_mipmaps->buffer[0]; + } +} + void import_arm_run_project(char *path) { buffer_t *b = data_get_blob(path); project_format_t *project; @@ -45,11 +55,11 @@ void import_arm_run_project(char *path) { gc_unroot(ui_files_filename); ui_files_filename = string_copy(substring(path, string_last_index_of(path, PATH_SEP) + 1, string_last_index_of(path, "."))); gc_root(ui_files_filename); - #if defined(IRON_ANDROID) || defined(IRON_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) sys_title_set(ui_files_filename); - #else +#else sys_title_set(string_join(string_join(ui_files_filename, " - "), manifest_title)); - #endif +#endif // Import as mesh instead if (import_as_mesh) { @@ -57,15 +67,15 @@ void import_arm_run_project(char *path) { return; } - // Save to recent - #ifdef IRON_IOS +// Save to recent +#ifdef IRON_IOS char *recent_path = substring(path, string_last_index_of(path, "/") + 1, string_length(path)); - #else +#else char *recent_path = path; - #endif - #ifdef IRON_WINDOWS +#endif +#ifdef IRON_WINDOWS recent_path = string_copy(string_replace_all(recent_path, "\\", "/")); - #endif +#endif string_t_array_t *recent = config_raw->recent_projects; char_ptr_array_remove(recent, recent_path); array_insert(recent, 0, recent_path); @@ -84,11 +94,11 @@ void import_arm_run_project(char *path) { char *base = path_base_dir(path); if (project_raw->envmap != NULL) { project_raw->envmap = data_is_abs(project_raw->envmap) ? project_raw->envmap : string_join(base, project_raw->envmap); - #ifdef IRON_WINDOWS +#ifdef IRON_WINDOWS project_raw->envmap = string_copy(string_replace_all(project_raw->envmap, "/", "\\")); - #else +#else project_raw->envmap = string_copy(string_replace_all(project_raw->envmap, "\\", "/")); - #endif +#endif } if (project_raw->camera_world != NULL) { @@ -102,11 +112,11 @@ void import_arm_run_project(char *path) { for (i32 i = 0; i < project->assets->length; ++i) { char *file = project->assets->buffer[i]; - #ifdef IRON_WINDOWS +#ifdef IRON_WINDOWS file = string_copy(string_replace_all(file, "/", "\\")); - #else +#else file = string_copy(string_replace_all(file, "\\", "/")); - #endif +#endif // Convert image path from relative to absolute char *abs = data_is_abs(file) ? file : string_join(base, file); if (project->packed_assets != NULL) { @@ -123,11 +133,11 @@ void import_arm_run_project(char *path) { if (project->font_assets != NULL) { for (i32 i = 0; i < project->font_assets->length; ++i) { char *file = project->font_assets->buffer[i]; - #ifdef IRON_WINDOWS +#ifdef IRON_WINDOWS file = string_copy(string_replace_all(file, "/", "\\")); - #else +#else file = string_copy(string_replace_all(file, "\\", "/")); - #endif +#endif // Convert font path from relative to absolute char *abs = data_is_abs(file) ? file : string_join(base, file); if (iron_file_exists(abs)) { @@ -373,7 +383,7 @@ void import_arm_run_project(char *path) { } } - sys_notify_on_next_frame(&import_arm_run_project_94619, NULL); + sys_notify_on_next_frame(&import_arm_run_project_on_next_frame, NULL); ui_base_hwnds->buffer[TAB_AREA_SIDEBAR0]->redraws = 2; ui_base_hwnds->buffer[TAB_AREA_SIDEBAR1]->redraws = 2; @@ -381,14 +391,8 @@ void import_arm_run_project(char *path) { data_delete_blob(path); } -void import_arm_run_project_94619(void * _) { - // Once envmap is imported - scene_world->strength = project_raw->envmap_strength; - context_raw->envmap_angle = project_raw->envmap_angle; - context_raw->show_envmap_blur = project_raw->envmap_blur; - if (context_raw->show_envmap_blur) { - scene_world->_->envmap = scene_world->_->radiance_mipmaps->buffer[0]; - } +void import_arm_run_mesh_on_next_frame(void *_) { + layers_init(); } void import_arm_run_mesh(project_format_t *raw) { @@ -416,14 +420,10 @@ void import_arm_run_mesh(project_format_t *raw) { util_mesh_merge(NULL); viewport_scale_to_bounds(2.0); } - sys_notify_on_next_frame(&import_arm_run_mesh_94821, NULL); + sys_notify_on_next_frame(&import_arm_run_mesh_on_next_frame, NULL); history_reset(); } -void import_arm_run_mesh_94821(void * _) { - layers_init(); -} - void import_arm_run_material(char *path) { buffer_t *b = data_get_blob(path); project_format_t *project; @@ -441,15 +441,24 @@ void import_arm_run_material(char *path) { import_arm_run_material_from_project(project, path); } +void import_arm_run_material_from_project_on_next_frame(slot_material_t_array_t *imported) { + for (i32 i = 0; i < imported->length; ++i) { + slot_material_t *m = imported->buffer[i]; + context_set_material(m); + make_material_parse_paint_material(true); + util_render_make_material_preview(); + } +} + void import_arm_run_material_from_project(project_format_t *project, char *path) { char *base = path_base_dir(path); for (i32 i = 0; i < project->assets->length; ++i) { char *file = project->assets->buffer[i]; - #ifdef IRON_WINDOWS +#ifdef IRON_WINDOWS file = string_copy(string_replace_all(file, "/", "\\")); - #else +#else file = string_copy(string_replace_all(file, "\\", "/")); - #endif +#endif // Convert image path from relative to absolute char *abs = data_is_abs(file) ? file : string_join(base, file); if (project->packed_assets != NULL) { @@ -490,7 +499,7 @@ void import_arm_run_material_from_project(project_format_t *project, char *path) } } - sys_notify_on_next_frame(&import_arm_run_material_from_project_95252, imported); + sys_notify_on_next_frame(&import_arm_run_material_from_project_on_next_frame, imported); gc_unroot(ui_nodes_group_stack); ui_nodes_group_stack = any_array_create_from_raw((void *[]){}, 0); gc_root(ui_nodes_group_stack); @@ -498,19 +507,10 @@ void import_arm_run_material_from_project(project_format_t *project, char *path) data_delete_blob(path); } -void import_arm_run_material_from_project_95252(slot_material_t_array_t *imported) { - for (i32 i = 0; i < imported->length; ++i) { - slot_material_t *m = imported->buffer[i]; - context_set_material(m); - make_material_parse_paint_material(true); - util_render_make_material_preview(); - } -} - bool import_arm_group_exists(ui_node_canvas_t *c) { for (i32 i = 0; i < project_material_groups->length; ++i) { node_group_t *g = project_material_groups->buffer[i]; - char *cname = g->canvas->name; + char *cname = g->canvas->name; if (string_equals(cname, c->name)) { return true; } @@ -552,15 +552,24 @@ void import_arm_run_brush(char *path) { import_arm_run_brush_from_project(project, path); } +void import_arm_run_brush_from_project_on_next_frame(slot_brush_t_array_t *imported) { + for (i32 i = 0; i < imported->length; ++i) { + slot_brush_t *b = imported->buffer[i]; + context_set_brush(b); + make_material_parse_brush(); + util_render_make_brush_preview(); + } +} + void import_arm_run_brush_from_project(project_format_t *project, char *path) { char *base = path_base_dir(path); for (i32 i = 0; i < project->assets->length; ++i) { char *file = project->assets->buffer[i]; - #ifdef IRON_WINDOWS +#ifdef IRON_WINDOWS file = string_copy(string_replace_all(file, "/", "\\")); - #else +#else file = string_copy(string_replace_all(file, "\\", "/")); - #endif +#endif // Convert image path from relative to absolute char *abs = data_is_abs(file) ? file : string_join(base, file); if (project->packed_assets != NULL) { @@ -583,20 +592,11 @@ void import_arm_run_brush_from_project(project_format_t *project, char *path) { any_array_push(imported, context_raw->brush); } - sys_notify_on_next_frame(&import_arm_run_brush_from_project_95818, imported); + sys_notify_on_next_frame(&import_arm_run_brush_from_project_on_next_frame, imported); ui_base_hwnds->buffer[TAB_AREA_SIDEBAR1]->redraws = 2; data_delete_blob(path); } -void import_arm_run_brush_from_project_95818(slot_brush_t_array_t *imported) { - for (i32 i = 0; i < imported->length; ++i) { - slot_brush_t *b = imported->buffer[i]; - context_set_brush(b); - make_material_parse_brush(); - util_render_make_brush_preview(); - } -} - void import_arm_run_swatches(char *path, bool replace_existing) { buffer_t *b = data_get_blob(path); project_format_t *project = armpack_decode(b); @@ -612,7 +612,7 @@ void import_arm_run_swatches_from_project(project_format_t *project, char *path, project_raw->swatches = any_array_create_from_raw((void *[]){}, 0); if (project->swatches == NULL) { // No swatches contained - any_array_push(project_raw->swatches, make_swatch(0xffffffff)); + any_array_push(project_raw->swatches, project_make_swatch(0xffffffff)); } } @@ -653,11 +653,11 @@ void import_arm_unpack_asset(project_format_t *project, char *abs, char *file, b } for (i32 i = 0; i < project->packed_assets->length; ++i) { packed_asset_t *pa = project->packed_assets->buffer[i]; - #ifdef IRON_WINDOWS +#ifdef IRON_WINDOWS pa->name = string_copy(string_replace_all(pa->name, "/", "\\")); - #else +#else pa->name = string_copy(string_replace_all(pa->name, "\\", "/")); - #endif +#endif pa->name = string_copy(path_normalize(pa->name)); if (string_equals(pa->name, file)) { pa->name = string_copy(abs); // From relative to absolute diff --git a/paint/sources/import_asset.c b/paint/sources/import_asset.c index 0a654b72..f72ce02a 100644 --- a/paint/sources/import_asset.c +++ b/paint/sources/import_asset.c @@ -1,6 +1,13 @@ #include "global.h" +void import_asset_run_cache_cloud_done(char *abs) { + if (abs == NULL) { + return; + } + import_asset_run(abs, _import_asset_drop_x, _import_asset_drop_y, _import_asset_show_box, _import_asset_hdr_as_envmap, _import_asset_done); +} + void import_asset_run(char *path, f32 drop_x, f32 drop_y, bool show_box, bool hdr_as_envmap, void (*done)(void)) { if (starts_with(path, "cloud")) { #ifdef IRON_ANDROID @@ -16,7 +23,7 @@ void import_asset_run(char *path, f32 drop_x, f32 drop_y, bool show_box, bool hd gc_unroot(_import_asset_done); _import_asset_done = done; gc_root(_import_asset_done); - file_cache_cloud(path, &import_asset_run_70884, config_raw->server); + file_cache_cloud(path, &import_asset_run_cache_cloud_done, config_raw->server); return; } @@ -84,10 +91,3 @@ void import_asset_run(char *path, f32 drop_x, f32 drop_y, bool show_box, bool hd done(); } } - -void import_asset_run_70884(char *abs) { - if (abs == NULL) { - return; - } - import_asset_run(abs, _import_asset_drop_x, _import_asset_drop_y, _import_asset_show_box, _import_asset_hdr_as_envmap, _import_asset_done); -} diff --git a/paint/sources/import_blend_material.c b/paint/sources/import_blend_material.c index cdfd6069..c7e86daf 100644 --- a/paint/sources/import_blend_material.c +++ b/paint/sources/import_blend_material.c @@ -1,15 +1,7 @@ #include "global.h" -void import_blend_material_run(char *path) { - gc_unroot(_import_blend_material_path); - _import_blend_material_path = string_copy(path); - gc_root(_import_blend_material_path); - - ui_box_show_custom(&import_blend_material_run_43663, 400, 200, NULL, true, ""); -} - -void import_blend_material_run_43663() { +void import_blend_material_run_box() { if (ui_tab(ui_handle(__ID__), tr("Import Material", NULL), false, -1, false)) { import_blend_mesh_ui(); @@ -30,13 +22,15 @@ void import_blend_material_run_43663() { } } -void _import_blend_material() { - console_toast(tr("Baking material", NULL)); +void import_blend_material_run(char *path) { + gc_unroot(_import_blend_material_path); + _import_blend_material_path = string_copy(path); + gc_root(_import_blend_material_path); - sys_notify_on_next_frame(&_import_blend_material_43775, NULL); + ui_box_show_custom(&import_blend_material_run_box, 400, 200, NULL, true, ""); } -void _import_blend_material_43775(void * _) { +void _import_blend_material_on_next_frame(void * _) { char *save; if (path_is_protected()) { save = string_copy(iron_internal_save_path()); @@ -86,3 +80,8 @@ for mat in bpy.data.materials:\n\ "\"")); import_folder_run(save); } + +void _import_blend_material() { + console_toast(tr("Baking material", NULL)); + sys_notify_on_next_frame(&_import_blend_material_on_next_frame, NULL); +} diff --git a/paint/sources/import_blend_mesh.c b/paint/sources/import_blend_mesh.c index 6791666c..da2ec952 100644 --- a/paint/sources/import_blend_mesh.c +++ b/paint/sources/import_blend_mesh.c @@ -1,6 +1,14 @@ #include "global.h" +void import_blend_mesh_ui_blender_folder_picked(char *path) { + #ifdef IRON_WINDOWS + path = string_copy(string_replace_all(path, "\\", "/")); + #endif + config_raw->blender = string_copy(path); + config_save(); +} + void import_blend_mesh_ui() { if (config_raw->blender == NULL) { config_raw->blender = ""; @@ -20,18 +28,10 @@ void import_blend_mesh_ui() { h->text = string_copy(config_raw->blender); config_raw->blender = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false)); if (ui_icon_button("", ICON_FOLDER_OPEN, UI_ALIGN_CENTER)) { - ui_files_show("", false, false, &import_blend_mesh_ui_37327); + ui_files_show("", false, false, &import_blend_mesh_ui_blender_folder_picked); } } -void import_blend_mesh_ui_37327(char *path) { - #ifdef IRON_WINDOWS - path = string_copy(string_replace_all(path, "\\", "/")); - #endif - config_raw->blender = string_copy(path); - config_save(); -} - void import_blend_mesh_run(char *path, bool replace_existing) { if (config_raw->blender == NULL || string_equals(config_raw->blender, "")) { console_error(tr("Blender executable path not set", NULL)); diff --git a/paint/sources/import_font.c b/paint/sources/import_font.c index 6538fb17..97028c13 100644 --- a/paint/sources/import_font.c +++ b/paint/sources/import_font.c @@ -1,6 +1,15 @@ #include "global.h" +void import_font_run_on_next_frame(slot_font_t_array_t *font_slots) { + for (i32 i = 0; i < font_slots->length; ++i) { + slot_font_t *f = font_slots->buffer[i]; + context_raw->font = f; + any_array_push(project_fonts, f); + util_render_make_font_preview(); + } +} + void import_font_run(char *path) { for (i32 i = 0; i < project_fonts->length; ++i) { slot_font_t *f = project_fonts->buffer[i]; @@ -29,16 +38,7 @@ void import_font_run(char *path) { any_array_push(font_slots, font_slot); } - sys_notify_on_next_frame(&import_font_run_158599, font_slots); + sys_notify_on_next_frame(&import_font_run_on_next_frame, font_slots); ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 2; } - -void import_font_run_158599(slot_font_t_array_t *font_slots) { - for (i32 i = 0; i < font_slots->length; ++i) { - slot_font_t *f = font_slots->buffer[i]; - context_raw->font = f; - any_array_push(project_fonts, f); - util_render_make_font_preview(); - } -} diff --git a/paint/sources/import_mesh.c b/paint/sources/import_mesh.c index b6f72b6a..736cbf93 100644 --- a/paint/sources/import_mesh.c +++ b/paint/sources/import_mesh.c @@ -56,6 +56,12 @@ void import_mesh_run(char *path, bool _clear_layers, bool replace_existing) { #endif } +i32 import_mesh_finish_import_sort(void **pa, void **pb) { + mesh_object_t *a = *(pa); + mesh_object_t *b = *(pb); + return strcmp(a->base->name, b->base->name); +} + void import_mesh_finish_import() { if (context_raw->merged_object != NULL) { mesh_data_delete(context_raw->merged_object->data); @@ -73,7 +79,7 @@ void import_mesh_finish_import() { if (project_paint_objects->length > 1) { // Sort by name - array_sort(project_paint_objects, &import_mesh_finish_import_85673); + array_sort(project_paint_objects, &import_mesh_finish_import_sort); if (context_raw->merged_object == NULL) { util_mesh_merge(NULL); @@ -94,10 +100,12 @@ void import_mesh_finish_import() { context_raw->paint_body = NULL; } -i32 import_mesh_finish_import_85673(void **pa, void **pb) { - mesh_object_t *a = *(pa); - mesh_object_t *b = *(pb); - return strcmp(a->base->name, b->base->name); +void _import_mesh_make_mesh_finish_import(void * _) { + import_mesh_finish_import(); +} + +void _import_mesh_make_mesh_clear_layers(void * _) { + layers_init(); } void _import_mesh_make_mesh(raw_mesh_t *mesh) { @@ -120,7 +128,7 @@ void _import_mesh_make_mesh(raw_mesh_t *mesh) { char *handle = context_raw->paint_object->data->_->handle; if (!string_equals(handle, "SceneSphere") && !string_equals(handle, "ScenePlane")) { - sys_notify_on_next_frame(&_import_mesh_make_mesh_85887, context_raw->paint_object->data); + sys_notify_on_next_frame(&mesh_data_delete, context_raw->paint_object->data); } mesh_object_set_data(context_raw->paint_object, md); @@ -150,33 +158,12 @@ void _import_mesh_make_mesh(raw_mesh_t *mesh) { slot_layer_unload(l); } layers_new_layer(false, -1); - sys_notify_on_next_frame(&_import_mesh_make_mesh_86005, NULL); + sys_notify_on_next_frame(&_import_mesh_make_mesh_clear_layers, NULL); history_reset(); } // Wait for add_mesh calls to finish - if (import_mesh_meshes_to_unwrap != NULL) { - sys_notify_on_next_frame(&_import_mesh_make_mesh_86033, NULL); - } - else { - sys_notify_on_next_frame(&_import_mesh_make_mesh_86052, NULL); - } -} - -void _import_mesh_make_mesh_86052(void * _) { - import_mesh_finish_import(); -} - -void _import_mesh_make_mesh_86033(void * _) { - import_mesh_finish_import(); -} - -void _import_mesh_make_mesh_86005(void * _) { - layers_init(); -} - -void _import_mesh_make_mesh_85887(mesh_data_t *md) { - mesh_data_delete(md); + sys_notify_on_next_frame(&_import_mesh_make_mesh_finish_import, NULL); } void import_mesh_first_unwrap_done(raw_mesh_t *mesh) { diff --git a/paint/sources/import_texture.c b/paint/sources/import_texture.c index b95161a5..fbd722be 100644 --- a/paint/sources/import_texture.c +++ b/paint/sources/import_texture.c @@ -1,6 +1,10 @@ #include "global.h" +void import_texture_run_on_next_frame(import_texture_data_t *itd) { + import_envmap_run(itd->path, itd->image); +} + void import_texture_run(char *path, bool hdr_as_envmap) { if (!path_is_texture(path)) { if (!context_enable_import_plugin(path)) { @@ -17,7 +21,7 @@ void import_texture_run(char *path, bool hdr_as_envmap) { if (hdr_as_envmap && ends_with(to_lower_case(path), ".hdr")) { gpu_texture_t *image = data_get_image(path); import_texture_data_t *itd = GC_ALLOC_INIT(import_texture_data_t, {.path = path, .image = image}); - sys_notify_on_next_frame(&import_texture_run_44011, itd); // Make sure file browser process did finish + sys_notify_on_next_frame(&import_texture_run_on_next_frame, itd); // Make sure file browser process did finish } console_info(strings_asset_already_imported()); return; @@ -55,18 +59,10 @@ void import_texture_run(char *path, bool hdr_as_envmap) { // Set as envmap if (hdr_as_envmap && ends_with(to_lower_case(path), ".hdr")) { import_texture_data_t *itd = GC_ALLOC_INIT(import_texture_data_t, {.path = path, .image = image}); - sys_notify_on_next_frame(&import_texture_run_44274, itd); // Make sure file browser process did finish + sys_notify_on_next_frame(&import_texture_run_on_next_frame, itd); // Make sure file browser process did finish } } -void import_texture_run_44274(import_texture_data_t *itd) { - import_envmap_run(itd->path, itd->image); -} - -void import_texture_run_44011(import_texture_data_t *itd) { - import_envmap_run(itd->path, itd->image); -} - gpu_texture_t *import_texture_default_importer(char *path) { return data_get_image(path); } diff --git a/paint/sources/make_material.c b/paint/sources/make_material.c index def85eeb..f3e8e382 100644 --- a/paint/sources/make_material.c +++ b/paint/sources/make_material.c @@ -54,7 +54,7 @@ void make_material_parse_mesh_material() { } } - material_t *mm = GC_ALLOC_INIT(material_t, {.name = "Material", .canvas = NULL}); + material_t *mm = GC_ALLOC_INIT(material_t, {.name = "Material", .canvas = NULL}); node_shader_context_t *con = make_mesh_run(mm, 0); shader_context_load(con->data); @@ -71,7 +71,7 @@ void make_material_parse_mesh_material() { any_array_push(m->contexts, mcon); } - context_raw->ddirty = 2; + context_raw->ddirty = 2; render_path_raytrace_dirty = 1; } @@ -156,12 +156,12 @@ void make_material_parse_paint_material(bool bake_previews) { } } - material_t *sdata = GC_ALLOC_INIT(material_t, {.name = "Material", .canvas = context_raw->material->canvas}); - material_context_t *tmcon = GC_ALLOC_INIT(material_context_t, {.name = "paint", .bind_textures = any_array_create_from_raw((void *[]){}, 0)}); - node_shader_context_t *con = make_paint_run(sdata, tmcon); + material_t *sdata = GC_ALLOC_INIT(material_t, {.name = "Material", .canvas = context_raw->material->canvas}); + material_context_t *tmcon = GC_ALLOC_INIT(material_context_t, {.name = "paint", .bind_textures = any_array_create_from_raw((void *[]){}, 0)}); + node_shader_context_t *con = make_paint_run(sdata, tmcon); - bool compile_error = false; - shader_context_t *scon; + bool compile_error = false; + shader_context_t *scon; shader_context_load(con->data); if (con->data == NULL) { compile_error = true; @@ -214,7 +214,7 @@ void make_material_traverse_nodes(ui_node_t_array_t *nodes, ui_node_canvas_t *gr if (string_equals(node->type, "GROUP")) { for (i32 j = 0; j < project_material_groups->length; ++j) { node_group_t *g = project_material_groups->buffer[j]; - char *cname = g->canvas->name; + char *cname = g->canvas->name; if (string_equals(cname, node->name)) { any_array_push(parents, node); make_material_traverse_nodes(g->canvas->nodes, g->canvas, parents); @@ -228,7 +228,7 @@ void make_material_traverse_nodes(ui_node_t_array_t *nodes, ui_node_canvas_t *gr void make_material_bake_node_preview(ui_node_t *node, ui_node_canvas_t *group, ui_node_t_array_t *parents) { if (string_equals(node->type, "BLUR")) { - char *id = parser_material_node_name(node, parents); + char *id = parser_material_node_name(node, parents); gpu_texture_t *image = any_map_get(context_raw->node_previews, id); any_array_push(context_raw->node_previews_used, id); i32 res_x = math_floor(config_get_texture_res_x() / (float)4); @@ -246,7 +246,7 @@ void make_material_bake_node_preview(ui_node_t *node, ui_node_canvas_t *group, u parser_material_blur_passthrough = false; } else if (string_equals(node->type, "DIRECT_WARP")) { - char *id = parser_material_node_name(node, parents); + char *id = parser_material_node_name(node, parents); gpu_texture_t *image = any_map_get(context_raw->node_previews, id); any_array_push(context_raw->node_previews_used, id); i32 res_x = math_floor(config_get_texture_res_x()); @@ -264,7 +264,7 @@ void make_material_bake_node_preview(ui_node_t *node, ui_node_canvas_t *group, u parser_material_warp_passthrough = false; } else if (string_equals(node->type, "BAKE_CURVATURE")) { - char *id = parser_material_node_name(node, parents); + char *id = parser_material_node_name(node, parents); gpu_texture_t *image = any_map_get(context_raw->node_previews, id); any_array_push(context_raw->node_previews_used, id); i32 res_x = math_floor(config_get_texture_res_x()); @@ -766,10 +766,11 @@ f32 make_material_get_displace_strength() { return config_raw->displace_strength * 0.02 * sc.x; } -void make_material_delete_context(shader_context_t *c) { - sys_notify_on_next_frame(&make_material_delete_context_137861, c); // Ensure pipeline is no longer in use -} - -void make_material_delete_context_137861(shader_context_t *c) { +void make_material_delete_context_on_next_frame(shader_context_t *c) { shader_context_delete(c); } + +void make_material_delete_context(shader_context_t *c) { + // Ensure pipeline is no longer in use + sys_notify_on_next_frame(&make_material_delete_context_on_next_frame, c); +} diff --git a/paint/sources/material_nodes/group_node.c b/paint/sources/material_nodes/group_node.c index a1c9caa4..baca99a2 100644 --- a/paint/sources/material_nodes/group_node.c +++ b/paint/sources/material_nodes/group_node.c @@ -105,7 +105,7 @@ void nodes_material_group_output_button(i32 node_id) { nodes_material_add_socket_button(nodes, node, node->inputs); } -void nodes_material_add_socket_menu() { +void nodes_material_add_socket_menu_draw() { ui_nodes_t *nodes = _nodes_material_nodes; ui_node_t *node = _nodes_material_node; ui_node_socket_t_array_t *sockets = _nodes_material_sockets; @@ -136,7 +136,7 @@ void nodes_material_add_socket_button(ui_nodes_t *nodes, ui_node_t *node, ui_nod gc_unroot(_nodes_material_sockets); _nodes_material_sockets = sockets; gc_root(_nodes_material_sockets); - ui_menu_draw(&nodes_material_add_socket_menu, -1, -1); + ui_menu_draw(&nodes_material_add_socket_menu_draw, -1, -1); } } diff --git a/paint/sources/material_nodes/text_texture_node.c b/paint/sources/material_nodes/text_texture_node.c index ac282ca3..01da14a5 100644 --- a/paint/sources/material_nodes/text_texture_node.c +++ b/paint/sources/material_nodes/text_texture_node.c @@ -7,13 +7,7 @@ void text_texture_node_init() { any_map_set(parser_material_node_values, "TEX_TEXT", text_texture_node_value); } -void _parser_material_cache_tex_text_node(char *file, char *text) { - if (any_map_get(data_cached_images, file) == NULL) { - sys_notify_on_next_frame(&_parser_material_cache_tex_text_node_205902, text); - } -} - -void _parser_material_cache_tex_text_node_205902(char *text) { +void _parser_material_cache_tex_text_node_on_next_frame(char *text) { char *_text_tool_text = context_raw->text_tool_text; gpu_texture_t *_text_tool_image = context_raw->text_tool_image; context_raw->text_tool_text = string_copy(text); @@ -26,6 +20,12 @@ void _parser_material_cache_tex_text_node_205902(char *text) { context_raw->text_tool_image = _text_tool_image; } +void _parser_material_cache_tex_text_node(char *file, char *text) { + if (any_map_get(data_cached_images, file) == NULL) { + sys_notify_on_next_frame(&_parser_material_cache_tex_text_node_on_next_frame, text); + } +} + char *text_texture_node_vector(ui_node_t *node, ui_node_socket_t *socket) { char *tex_name = parser_material_node_name(node, NULL); buffer_t *text_buffer = node->buttons->buffer[0]->default_value; diff --git a/paint/sources/neural_nodes/image_to_pbr_node.c b/paint/sources/neural_nodes/image_to_pbr_node.c index 6b298f12..3ef2c350 100644 --- a/paint/sources/neural_nodes/image_to_pbr_node.c +++ b/paint/sources/neural_nodes/image_to_pbr_node.c @@ -84,36 +84,7 @@ void image_to_pbr_node_run_sd(char *model, char *prompt, void (*done)(gpu_textur sys_notify_on_update(image_to_pbr_node_check_result, done); } -void image_to_pbr_node_button(i32 node_id) { - ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); - ui_node_t *node = ui_get_node(canvas->nodes, node_id); - char *node_name = parser_material_node_name(node, NULL); - ui_handle_t *h = ui_handle(node_name); - string_t_array_t *models = any_array_create_from_raw( - (void *[]){ - "Marigold", - }, - 1); - i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); - if (neural_node_button(node, models->buffer[model])) { - ui_node_t *from_node = neural_from_node(node->inputs->buffer[0], 0); - gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); - if (input != NULL) { - char *dir = neural_node_dir(); - - #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip - #else - buffer_t *input_buf = gpu_get_texture_pixels(input); - #endif - iron_write_png(string_join(string_join(dir, PATH_SEP), "input.png"), input_buf, input->width, input->height, 0); - - image_to_pbr_node_run_sd("marigold-normals-v1-1.q8_0.gguf", "_normals", &image_to_pbr_node_button_233087); - } - } -} - -void image_to_pbr_node_button_233151(void * _) { +void image_to_pbr_node_all_done(void * _) { render_target_t *occmap; { render_target_t *t = render_target_create(); @@ -154,33 +125,62 @@ void image_to_pbr_node_button_233151(void * _) { // blur } -void image_to_pbr_node_button_233138(gpu_texture_t *tex) { +void image_to_pbr_node_roughness_done(gpu_texture_t *tex) { gc_unroot(image_to_pbr_node_result_roughness); image_to_pbr_node_result_roughness = tex; gc_root(image_to_pbr_node_result_roughness); // image_to_pbr_node_run_sd("marigold-iid-lighting-v1-1.q8_0.gguf", "_diffuse_shading", function(tex: gpu_texture_t) { - sys_notify_on_next_frame(&image_to_pbr_node_button_233151, NULL); + sys_notify_on_next_frame(&image_to_pbr_node_all_done, NULL); } -void image_to_pbr_node_button_233121(gpu_texture_t *tex) { +void image_to_pbr_node_base_done(gpu_texture_t *tex) { gc_unroot(image_to_pbr_node_result_base); image_to_pbr_node_result_base = tex; gc_root(image_to_pbr_node_result_base); - image_to_pbr_node_run_sd("marigold-iid-appearance-v1-1.q8_0.gguf", "_roughness", &image_to_pbr_node_button_233138); + image_to_pbr_node_run_sd("marigold-iid-appearance-v1-1.q8_0.gguf", "_roughness", &image_to_pbr_node_roughness_done); } -void image_to_pbr_node_button_233104(gpu_texture_t *tex) { +void image_to_pbr_node_height_done(gpu_texture_t *tex) { gc_unroot(image_to_pbr_node_result_height); image_to_pbr_node_result_height = tex; gc_root(image_to_pbr_node_result_height); - image_to_pbr_node_run_sd("marigold-iid-lighting-v1-1.q8_0.gguf", "_base", &image_to_pbr_node_button_233121); + image_to_pbr_node_run_sd("marigold-iid-lighting-v1-1.q8_0.gguf", "_base", &image_to_pbr_node_base_done); } -void image_to_pbr_node_button_233087(gpu_texture_t *tex) { +void image_to_pbr_node_normals_done(gpu_texture_t *tex) { gc_unroot(image_to_pbr_node_result_normal); image_to_pbr_node_result_normal = tex; gc_root(image_to_pbr_node_result_normal); - image_to_pbr_node_run_sd("marigold-depth-v1-1.q8_0.gguf", "_height", &image_to_pbr_node_button_233104); + image_to_pbr_node_run_sd("marigold-depth-v1-1.q8_0.gguf", "_height", &image_to_pbr_node_height_done); +} + +void image_to_pbr_node_button(i32 node_id) { + ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); + ui_node_t *node = ui_get_node(canvas->nodes, node_id); + char *node_name = parser_material_node_name(node, NULL); + ui_handle_t *h = ui_handle(node_name); + string_t_array_t *models = any_array_create_from_raw( + (void *[]){ + "Marigold", + }, + 1); + i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); + if (neural_node_button(node, models->buffer[model])) { + ui_node_t *from_node = neural_from_node(node->inputs->buffer[0], 0); + gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); + if (input != NULL) { + char *dir = neural_node_dir(); + + #ifdef IRON_BGRA + buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + #else + buffer_t *input_buf = gpu_get_texture_pixels(input); + #endif + iron_write_png(string_join(string_join(dir, PATH_SEP), "input.png"), input_buf, input->width, input->height, 0); + + image_to_pbr_node_run_sd("marigold-normals-v1-1.q8_0.gguf", "_normals", &image_to_pbr_node_normals_done); + } + } } void image_to_pbr_node_check_result(void (*done)(gpu_texture_t *)) { diff --git a/paint/sources/neural_nodes/inpaint_image_node.c b/paint/sources/neural_nodes/inpaint_image_node.c index 966d95b8..c647b90e 100644 --- a/paint/sources/neural_nodes/inpaint_image_node.c +++ b/paint/sources/neural_nodes/inpaint_image_node.c @@ -7,27 +7,7 @@ void inpaint_image_node_init() { any_map_set(ui_nodes_custom_buttons, "inpaint_image_node_button", inpaint_image_node_button); } -void inpaint_image_node_button(i32 node_id) { - ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); - ui_node_t *node = ui_get_node(canvas->nodes, node_id); - char *node_name = parser_material_node_name(node, NULL); - ui_handle_t *h = ui_handle(node_name); - string_t_array_t *models = any_array_create_from_raw( - (void *[]){ - "Stable Diffusion", - "Qwen Image Edit", - }, - 2); - i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); - char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); - node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; - - if (neural_node_button(node, models->buffer[model])) { - sys_notify_on_next_frame(&inpaint_image_node_button_234029, node); - } -} - -void inpaint_image_node_button_234029(ui_node_t *node) { +void inpaint_image_node_button_on_next_frame(ui_node_t *node) { ui_node_t *from_node = neural_from_node(node->inputs->buffer[0], 0); ui_node_t *mask_node = neural_from_node(node->inputs->buffer[1], 1); gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); @@ -134,3 +114,23 @@ void inpaint_image_node_button_234029(ui_node_t *node) { sys_notify_on_update(neural_node_check_result, node); } } + +void inpaint_image_node_button(i32 node_id) { + ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); + ui_node_t *node = ui_get_node(canvas->nodes, node_id); + char *node_name = parser_material_node_name(node, NULL); + ui_handle_t *h = ui_handle(node_name); + string_t_array_t *models = any_array_create_from_raw( + (void *[]){ + "Stable Diffusion", + "Qwen Image Edit", + }, + 2); + i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); + char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); + node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; + + if (neural_node_button(node, models->buffer[model])) { + sys_notify_on_next_frame(&inpaint_image_node_button_on_next_frame, node); + } +} diff --git a/paint/sources/neural_nodes/neural_node.c b/paint/sources/neural_nodes/neural_node.c index 51ba1b03..97ffe988 100644 --- a/paint/sources/neural_nodes/neural_node.c +++ b/paint/sources/neural_nodes/neural_node.c @@ -38,6 +38,11 @@ ui_node_t *neural_from_node(ui_node_socket_t *inp, i32 socket) { return result; } +void neural_node_button_on_next_frame(void * _) { + box_preferences_htab->i = PREFERENCE_TAB_NEURAL; + box_preferences_show(); +} + bool neural_node_button(ui_node_t *node, char *model) { char *url = box_preferneces_model_url_from_name(model); char *file_name = box_preferences_file_name_from_url(url); @@ -52,7 +57,7 @@ bool neural_node_button(ui_node_t *node, char *model) { } } else if (!found && ui_button(tr("Setup", NULL), UI_ALIGN_CENTER, "")) { - sys_notify_on_next_frame(&neural_node_button_236824, NULL); + sys_notify_on_next_frame(&neural_node_button_on_next_frame, NULL); } else if (found && ui_button(tr("Run", NULL), UI_ALIGN_CENTER, "")) { return true; @@ -60,11 +65,6 @@ bool neural_node_button(ui_node_t *node, char *model) { return false; } -void neural_node_button_236824(void * _) { - box_preferences_htab->i = PREFERENCE_TAB_NEURAL; - box_preferences_show(); -} - void neural_node_check_result(ui_node_t *node) { gc_unroot(neural_node_current); neural_node_current = node; @@ -111,24 +111,16 @@ char *neural_node_dir() { return dir; } -void neural_node_download(char *url) { - char *file_name = substring(url, string_last_index_of(url, "/") + 1, string_length(url)); - char *file_path = string_join(string_join(neural_node_dir(), PATH_SEP), file_name); - bool found = iron_file_exists(file_path); - if (found) { - return; - } +#ifdef WITH_COMPRESS - neural_node_downloading++; - file_download_to(url, file_path, &neural_node_download_237123, 0); -} - -void neural_node_download_237227(void * _) { +void neural_node_download_done_untar(void * _) { char *tar = string_join(neural_node_dir(), "/Hunyuan3D_win64.tar"); untar_here(tar); } -void neural_node_download_237123(char *url) { +#endif + +void neural_node_download_done(char *url) { neural_node_downloading--; console_log(string_join(string_join(tr("Downloaded file from", NULL), " "), url)); @@ -147,11 +139,23 @@ void neural_node_download_237123(char *url) { #ifdef WITH_COMPRESS if (ends_with(url, "Hunyuan3D_win64.tar")) { console_toast(tr("Unpacking Hunyuan3D_win64.tar", NULL)); - sys_notify_on_next_frame(&neural_node_download_237227, NULL); + sys_notify_on_next_frame(&neural_node_download_done_untar, NULL); } #endif } +void neural_node_download(char *url) { + char *file_name = substring(url, string_last_index_of(url, "/") + 1, string_length(url)); + char *file_path = string_join(string_join(neural_node_dir(), PATH_SEP), file_name); + bool found = iron_file_exists(file_path); + if (found) { + return; + } + + neural_node_downloading++; + file_download_to(url, file_path, &neural_node_download_done, 0); +} + void neural_node_download_models(string_t_array_t *models) { if (string_equals(file_read_directory(neural_node_dir())->buffer[0], "")) { iron_create_directory(neural_node_dir()); diff --git a/paint/sources/neural_nodes/outpaint_image_node.c b/paint/sources/neural_nodes/outpaint_image_node.c index 98433a49..25e52bc6 100644 --- a/paint/sources/neural_nodes/outpaint_image_node.c +++ b/paint/sources/neural_nodes/outpaint_image_node.c @@ -7,27 +7,7 @@ void outpaint_image_node_init() { any_map_set(ui_nodes_custom_buttons, "outpaint_image_node_button", outpaint_image_node_button); } -void outpaint_image_node_button(i32 node_id) { - ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); - ui_node_t *node = ui_get_node(canvas->nodes, node_id); - char *node_name = parser_material_node_name(node, NULL); - ui_handle_t *h = ui_handle(node_name); - string_t_array_t *models = any_array_create_from_raw( - (void *[]){ - "Stable Diffusion", - "Qwen Image Edit", - }, - 2); - i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); - char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); - node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; - - if (neural_node_button(node, models->buffer[model])) { - sys_notify_on_next_frame(&outpaint_image_node_button_235809, node); - } -} - -void outpaint_image_node_button_235809(ui_node_t *node) { +void outpaint_image_node_button_on_next_frame(ui_node_t *node) { ui_node_t *from_node = neural_from_node(node->inputs->buffer[0], 0); gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); if (input != NULL) { @@ -133,3 +113,23 @@ void outpaint_image_node_button_235809(ui_node_t *node) { sys_notify_on_update(neural_node_check_result, node); } } + +void outpaint_image_node_button(i32 node_id) { + ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); + ui_node_t *node = ui_get_node(canvas->nodes, node_id); + char *node_name = parser_material_node_name(node, NULL); + ui_handle_t *h = ui_handle(node_name); + string_t_array_t *models = any_array_create_from_raw( + (void *[]){ + "Stable Diffusion", + "Qwen Image Edit", + }, + 2); + i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); + char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); + node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; + + if (neural_node_button(node, models->buffer[model])) { + sys_notify_on_next_frame(&outpaint_image_node_button_on_next_frame, node); + } +} diff --git a/paint/sources/neural_nodes/tile_image_node.c b/paint/sources/neural_nodes/tile_image_node.c index c083e50b..07fe6440 100644 --- a/paint/sources/neural_nodes/tile_image_node.c +++ b/paint/sources/neural_nodes/tile_image_node.c @@ -7,27 +7,7 @@ void tile_image_node_init() { any_map_set(ui_nodes_custom_buttons, "tile_image_node_button", tile_image_node_button); } -void tile_image_node_button(i32 node_id) { - ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); - ui_node_t *node = ui_get_node(canvas->nodes, node_id); - char *node_name = parser_material_node_name(node, NULL); - ui_handle_t *h = ui_handle(node_name); - string_t_array_t *models = any_array_create_from_raw( - (void *[]){ - "Stable Diffusion", - "Qwen Image Edit", - }, - 2); - i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); - char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); - node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; - - if (neural_node_button(node, models->buffer[model])) { - sys_notify_on_next_frame(&tile_image_node_button_238443, node); - } -} - -void tile_image_node_button_238443(ui_node_t *node) { +void tile_image_node_button_on_next_frame(ui_node_t *node) { ui_node_t *from_node = neural_from_node(node->inputs->buffer[0], 0); gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); if (input != NULL) { @@ -132,3 +112,23 @@ void tile_image_node_button_238443(ui_node_t *node) { sys_notify_on_update(neural_node_check_result, node); } } + +void tile_image_node_button(i32 node_id) { + ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); + ui_node_t *node = ui_get_node(canvas->nodes, node_id); + char *node_name = parser_material_node_name(node, NULL); + ui_handle_t *h = ui_handle(node_name); + string_t_array_t *models = any_array_create_from_raw( + (void *[]){ + "Stable Diffusion", + "Qwen Image Edit", + }, + 2); + i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); + char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); + node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; + + if (neural_node_button(node, models->buffer[model])) { + sys_notify_on_next_frame(&tile_image_node_button_on_next_frame, node); + } +} diff --git a/paint/sources/neural_nodes/vary_image_node.c b/paint/sources/neural_nodes/vary_image_node.c index 05d1d2b5..b30a67a3 100644 --- a/paint/sources/neural_nodes/vary_image_node.c +++ b/paint/sources/neural_nodes/vary_image_node.c @@ -7,27 +7,7 @@ void vary_image_node_init() { any_map_set(ui_nodes_custom_buttons, "vary_image_node_button", vary_image_node_button); } -void vary_image_node_button(i32 node_id) { - ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); - ui_node_t *node = ui_get_node(canvas->nodes, node_id); - char *node_name = parser_material_node_name(node, NULL); - ui_handle_t *h = ui_handle(node_name); - string_t_array_t *models = any_array_create_from_raw( - (void *[]){ - "Stable Diffusion", - "Qwen Image Edit", - }, - 2); - i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); - char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); - node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; - - if (neural_node_button(node, models->buffer[model])) { - sys_notify_on_next_frame(&vary_image_node_button_240006, node); - } -} - -void vary_image_node_button_240006(ui_node_t *node) { +void vary_image_node_button_on_next_frame(ui_node_t *node) { ui_node_t *from_node = neural_from_node(node->inputs->buffer[0], 0); gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); if (input != NULL) { @@ -130,3 +110,23 @@ void vary_image_node_button_240006(ui_node_t *node) { sys_notify_on_update(neural_node_check_result, node); } } + +void vary_image_node_button(i32 node_id) { + ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); + ui_node_t *node = ui_get_node(canvas->nodes, node_id); + char *node_name = parser_material_node_name(node, NULL); + ui_handle_t *h = ui_handle(node_name); + string_t_array_t *models = any_array_create_from_raw( + (void *[]){ + "Stable Diffusion", + "Qwen Image Edit", + }, + 2); + i32 model = ui_combo(ui_nest(h, 0), models, tr("Model", NULL), false, UI_ALIGN_LEFT, true); + char *prompt = ui_text_area(ui_nest(h, 1), UI_ALIGN_LEFT, true, tr("prompt", NULL), true); + node->buttons->buffer[0]->height = string_split(prompt, "\n")->length + 2; + + if (neural_node_button(node, models->buffer[model])) { + sys_notify_on_next_frame(&vary_image_node_button_on_next_frame, node); + } +} diff --git a/paint/sources/project.c b/paint/sources/project.c index 6b6766e6..14b797a1 100644 --- a/paint/sources/project.c +++ b/paint/sources/project.c @@ -1,11 +1,7 @@ #include "global.h" -void project_open() { - ui_files_show("arm", false, false, &project_open_102526); -} - -void project_open_102526(char *path) { +void project_open_on_file_picked(char *path) { if (!ends_with(path, ".arm")) { console_error(strings_arm_file_expected()); return; @@ -21,47 +17,46 @@ void project_open_102526(char *path) { draw_begin(current, false, 0); } -void project_save(bool save_and_quit) { - if (string_equals(project_filepath, "")) { - #ifdef IRON_IOS - char *document_directory = iron_save_dialog("", ""); - document_directory = string_copy(substring(document_directory, 0, string_length(document_directory) - 8)); // Strip /"untitled" - gc_unroot(project_filepath); - project_filepath = string_join(string_join(string_join(document_directory, "/"), sys_title()), ".arm"); - gc_root(project_filepath); - #elif defined(IRON_ANDROID) - gc_unroot(project_filepath); - project_filepath = string_join(string_join(string_join(iron_internal_save_path(), "/"), sys_title()), ".arm"); - gc_root(project_filepath); - #else - project_save_as(save_and_quit); - return; - #endif - } - - #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) - char *filename = substring(project_filepath, string_last_index_of(project_filepath, PATH_SEP) + 1, string_length(project_filepath) - 4); - sys_title_set(string_join(string_join(filename, " - "), manifest_title)); - #endif - - _project_save_and_quit = save_and_quit; - - sys_notify_on_next_frame(&project_save_102708, NULL); +void project_open() { + ui_files_show("arm", false, false, &project_open_on_file_picked); } -void project_save_102708(void * _) { +void project_save_on_next_frame(void *_) { export_arm_run_project(); if (_project_save_and_quit) { iron_stop(); } } -void project_save_as(bool save_and_quit) { +void project_save(bool save_and_quit) { + if (string_equals(project_filepath, "")) { +#ifdef IRON_IOS + char *document_directory = iron_save_dialog("", ""); + document_directory = string_copy(substring(document_directory, 0, string_length(document_directory) - 8)); // Strip /"untitled" + gc_unroot(project_filepath); + project_filepath = string_join(string_join(string_join(document_directory, "/"), sys_title()), ".arm"); + gc_root(project_filepath); +#elif defined(IRON_ANDROID) + gc_unroot(project_filepath); + project_filepath = string_join(string_join(string_join(iron_internal_save_path(), "/"), sys_title()), ".arm"); + gc_root(project_filepath); +#else + project_save_as(save_and_quit); + return; +#endif + } + +#if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) + char *filename = substring(project_filepath, string_last_index_of(project_filepath, PATH_SEP) + 1, string_length(project_filepath) - 4); + sys_title_set(string_join(string_join(filename, " - "), manifest_title)); +#endif + _project_save_and_quit = save_and_quit; - ui_files_show("arm", true, false, &project_save_as_102755); + + sys_notify_on_next_frame(&project_save_on_next_frame, NULL); } -void project_save_as_102755(char *path) { +void project_save_as_on_file_picked(char *path) { char *f = ui_files_filename; if (string_equals(f, "")) { f = string_copy(tr("untitled", NULL)); @@ -77,13 +72,18 @@ void project_save_as_102755(char *path) { project_save(_project_save_and_quit); } +void project_save_as(bool save_and_quit) { + _project_save_and_quit = save_and_quit; + ui_files_show("arm", true, false, &project_save_as_on_file_picked); +} + void project_fetch_default_meshes() { if (project_mesh_list == NULL) { gc_unroot(project_mesh_list); project_mesh_list = file_read_directory(string_join(string_join(path_data(), PATH_SEP), "meshes")); gc_root(project_mesh_list); for (i32 i = 0; i < project_mesh_list->length; ++i) { - char *s = project_mesh_list->buffer[i]; + char *s = project_mesh_list->buffer[i]; project_mesh_list->buffer[i] = substring(project_mesh_list->buffer[i], 0, string_length(s) - 4); // Trim .arm } any_array_push(project_mesh_list, "plane"); @@ -91,11 +91,7 @@ void project_fetch_default_meshes() { } } -void project_new_box() { - ui_box_show_custom(&project_new_box_102911, 400, 200, NULL, true, tr("New Project", NULL)); -} - -void project_new_box_102911() { +void project_new_box_draw() { project_fetch_default_meshes(); ui_row2(); ui_handle_t *h_project_type = ui_handle(__ID__); @@ -126,6 +122,10 @@ void project_new_box_102911() { } } +void project_new_box() { + ui_box_show_custom(&project_new_box_draw, 400, 200, NULL, true, tr("New Project", NULL)); +} + void project_cleanup() { if (context_raw->merged_object != NULL) { mesh_object_remove(context_raw->merged_object); @@ -166,6 +166,20 @@ void project_cleanup() { } } +void project_new_on_next_frame(void *_) { + // Once layers and meshes are populated on project open + util_render_make_material_preview(); + context_raw->ddirty = 4; +} + +void project_new_reset_layers(void *_) { + layers_init(); +} + +void project_new_resize_layers(void *_) { + layers_resize(); +} + void project_new(bool reset_layers) { if (context_raw->paint_object != NULL) { project_cleanup(); @@ -187,7 +201,7 @@ void project_new(bool reset_layers) { gc_root(project_mesh_assets); mesh_data_t *raw = NULL; - char *mesh_name = project_mesh_list == NULL ? "box_bevel" : project_mesh_list->buffer[context_raw->project_type]; + char *mesh_name = project_mesh_list == NULL ? "box_bevel" : project_mesh_list->buffer[context_raw->project_type]; if (string_equals(mesh_name, "sphere")) { raw_mesh_t *mesh = geom_make_uv_sphere(1, 512, 256, true, 1.0); @@ -271,7 +285,7 @@ void project_new(bool reset_layers) { context_raw->font = project_fonts->buffer[0]; project_set_default_swatches(); context_raw->swatch = project_raw->swatches->buffer[0]; - context_raw->picked_color = make_swatch(0xffffffff); + context_raw->picked_color = project_make_swatch(0xffffffff); context_raw->color_picker_callback = NULL; history_reset(); @@ -303,9 +317,9 @@ void project_new(bool reset_layers) { any_array_push(project_layers, layer); context_set_layer(layer); if (aspect_ratio_changed) { - sys_notify_on_next_frame(&project_new_103839, NULL); + sys_notify_on_next_frame(&project_new_resize_layers, NULL); } - sys_notify_on_next_frame(&project_new_103856, NULL); + sys_notify_on_next_frame(&project_new_reset_layers, NULL); } if (in_use) @@ -317,21 +331,7 @@ void project_new(bool reset_layers) { viewport_scale_to_bounds(1.8); render_path_raytrace_ready = false; - sys_notify_on_next_frame(&project_new_103903, NULL); -} - -void project_new_103903(void * _) { - // Once layers and meshes are populated on project open - util_render_make_material_preview(); - context_raw->ddirty = 4; -} - -void project_new_103856(void * _) { - layers_init(); -} - -void project_new_103839(void * _) { - layers_resize(); + sys_notify_on_next_frame(&project_new_on_next_frame, NULL); } void project_set_default_envmap() { @@ -349,12 +349,12 @@ void project_set_default_envmap() { project_raw->envmap = NULL; } -void project_import_material() { - ui_files_show("arm,blend", false, true, &project_import_material_103991); +void project_import_material_on_file_picked(char *path) { + ends_with(path, ".blend") ? import_blend_material_run(path) : import_arm_run_material(path); } -void project_import_material_103991(char *path) { - ends_with(path, ".blend") ? import_blend_material_run(path) : import_arm_run_material(path); +void project_import_material() { + ui_files_show("arm,blend", false, true, &project_import_material_on_file_picked); } ui_node_link_t *project_create_node_link(ui_node_link_t_array_t *links, i32 from_id, i32 from_socket, i32 to_id, i32 to_socket) { @@ -363,16 +363,11 @@ ui_node_link_t *project_create_node_link(ui_node_link_t_array_t *links, i32 from return link; } -void project_import_brush() { - char *formats = string_array_join(path_texture_formats(), ","); - ui_files_show(string_join("arm,", formats), false, true, &project_import_brush_104110); -} - -void project_import_brush_104258(void * _) { +void project_import_brush_make_brush_preview(void *_) { util_render_make_brush_preview(); } -void project_import_brush_104110(char *path) { +void project_import_brush_on_file_picked(char *path) { // Create brush from texture if (path_is_texture(path)) { // Import texture @@ -401,7 +396,7 @@ void project_import_brush_104110(char *path) { // Parse brush make_material_parse_brush(); ui_nodes_hwnd->redraws = 2; - sys_notify_on_next_frame(&project_import_brush_104258, NULL); + sys_notify_on_next_frame(&project_import_brush_make_brush_preview, NULL); } // Import from project file else { @@ -409,6 +404,15 @@ void project_import_brush_104110(char *path) { } } +void project_import_brush() { + char *formats = string_array_join(path_texture_formats(), ","); + ui_files_show(string_join("arm,", formats), false, true, &project_import_brush_on_file_picked); +} + +void project_import_mesh_on_file_picked(char *path) { + project_import_mesh_box(path, _project_import_mesh_replace_existing, true, _project_import_mesh_done); +} + void project_import_mesh(bool replace_existing, void (*done)(void)) { _project_import_mesh_replace_existing = replace_existing; gc_unroot(_project_import_mesh_done); @@ -425,35 +429,18 @@ void project_import_mesh(bool replace_existing, void (*done)(void)) { if (string_index_of(formats, "glb") == -1) { formats = string_join(formats, ",glb"); } - ui_files_show(formats, false, false, &project_import_mesh_104385); -} - -void project_import_mesh_104385(char *path) { - project_import_mesh_box(path, _project_import_mesh_replace_existing, true, _project_import_mesh_done); + ui_files_show(formats, false, false, &project_import_mesh_on_file_picked); } void project_append_mesh() { project_import_mesh(false, import_mesh_finish_import); } -void project_import_mesh_box(char *path, bool replace_existing, bool clear_layers, void (*done)(void)) { - gc_unroot(_project_import_mesh_box_path); - _project_import_mesh_box_path = string_copy(path); - gc_root(_project_import_mesh_box_path); - _project_import_mesh_box_replace_existing = replace_existing; - _project_import_mesh_box_clear_layers = clear_layers; - gc_unroot(_project_import_mesh_box_done); - _project_import_mesh_box_done = done; - gc_root(_project_import_mesh_box_done); - ui_box_show_custom(&project_import_mesh_box_104467, 400, 200, NULL, true, tr("Import Mesh", NULL)); - ui_box_click_to_hide = false; // Prevent closing when going back to window from file browser -} - -void project_import_mesh_box_104467() { +void project_import_mesh_box_draw() { char *path = _project_import_mesh_box_path; - bool replace_existing = _project_import_mesh_box_replace_existing; - bool clear_layers = _project_import_mesh_box_clear_layers; - void (*done)(void) = _project_import_mesh_box_done; + bool replace_existing = _project_import_mesh_box_replace_existing; + bool clear_layers = _project_import_mesh_box_clear_layers; + void (*done)(void) = _project_import_mesh_box_done; if (ends_with(to_lower_case(path), ".obj")) { string_t_array_t *split_by_combo = any_array_create_from_raw( @@ -489,9 +476,9 @@ void project_import_mesh_box_104467() { if (ui_icon_button(tr("Import", NULL), ICON_CHECK, UI_ALIGN_CENTER) || ui->is_return_down) { ui_box_hide(); - #if defined(IRON_ANDROID) || defined(IRON_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) console_toast(tr("Importing mesh", NULL)); - #endif +#endif import_mesh_run(path, clear_layers, replace_existing); if (done != NULL) { @@ -503,6 +490,19 @@ void project_import_mesh_box_104467() { } } +void project_import_mesh_box(char *path, bool replace_existing, bool clear_layers, void (*done)(void)) { + gc_unroot(_project_import_mesh_box_path); + _project_import_mesh_box_path = string_copy(path); + gc_root(_project_import_mesh_box_path); + _project_import_mesh_box_replace_existing = replace_existing; + _project_import_mesh_box_clear_layers = clear_layers; + gc_unroot(_project_import_mesh_box_done); + _project_import_mesh_box_done = done; + gc_root(_project_import_mesh_box_done); + ui_box_show_custom(&project_import_mesh_box_draw, 400, 200, NULL, true, tr("Import Mesh", NULL)); + ui_box_click_to_hide = false; // Prevent closing when going back to window from file browser +} + void project_reimport_mesh() { if (project_mesh_assets != NULL && project_mesh_assets->length > 0 && iron_file_exists(project_mesh_assets->buffer[0])) { project_import_mesh_box(project_mesh_assets->buffer[0], true, false, NULL); @@ -527,6 +527,28 @@ string_t_array_t *project_get_unwrap_plugins() { return unwrap_plugins; } +void project_unwrap_mesh_box_draw() { + raw_mesh_t *mesh = _project_unwrap_mesh_box_mesh; + void (*done)(raw_mesh_t *) = _project_unwrap_mesh_box_done; + + string_t_array_t *unwrap_plugins = project_get_unwrap_plugins(); + _project_unwrap_by = ui_combo(ui_handle(__ID__), unwrap_plugins, tr("Plugin", NULL), true, UI_ALIGN_LEFT, true); + + ui_row2(); + if (ui_icon_button(tr("Cancel", NULL), ICON_CLOSE, UI_ALIGN_CENTER)) { + ui_box_hide(); + } + if (ui_icon_button(tr("Unwrap", NULL), ICON_CHECK, UI_ALIGN_CENTER) || ui->is_return_down) { + ui_box_hide(); + +#if defined(IRON_ANDROID) || defined(IRON_IOS) + console_toast(tr("Unwrapping mesh", NULL)); +#endif + + project_unwrap_mesh(mesh, done); + } +} + void project_unwrap_mesh_box(raw_mesh_t *mesh, void (*done)(raw_mesh_t *), bool skip_ui) { gc_unroot(_project_unwrap_mesh_box_mesh); _project_unwrap_mesh_box_mesh = mesh; @@ -540,29 +562,7 @@ void project_unwrap_mesh_box(raw_mesh_t *mesh, void (*done)(raw_mesh_t *), bool return; } - ui_box_show_custom(&project_unwrap_mesh_box_104919, 400, 200, NULL, true, tr("Unwrap Mesh", NULL)); -} - -void project_unwrap_mesh_box_104919() { - raw_mesh_t *mesh = _project_unwrap_mesh_box_mesh; - void (*done)(raw_mesh_t *) = _project_unwrap_mesh_box_done; - - string_t_array_t *unwrap_plugins = project_get_unwrap_plugins(); - _project_unwrap_by = ui_combo(ui_handle(__ID__), unwrap_plugins, tr("Plugin", NULL), true, UI_ALIGN_LEFT, true); - - ui_row2(); - if (ui_icon_button(tr("Cancel", NULL), ICON_CLOSE, UI_ALIGN_CENTER)) { - ui_box_hide(); - } - if (ui_icon_button(tr("Unwrap", NULL), ICON_CHECK, UI_ALIGN_CENTER) || ui->is_return_down) { - ui_box_hide(); - - #if defined(IRON_ANDROID) || defined(IRON_IOS) - console_toast(tr("Unwrapping mesh", NULL)); - #endif - - project_unwrap_mesh(mesh, done); - } + ui_box_show_custom(&project_unwrap_mesh_box_draw, 400, 200, NULL, true, tr("Unwrap Mesh", NULL)); } void project_unwrap_mesh(raw_mesh_t *mesh, void (*done)(raw_mesh_t *)) { @@ -577,12 +577,16 @@ void project_unwrap_mesh(raw_mesh_t *mesh, void (*done)(raw_mesh_t *)) { config_enable_plugin(f); console_info(string_join(string_join(f, " "), tr("plugin enabled", NULL))); } - void * cb = any_map_get(util_mesh_unwrappers, f); // JSValue * -> (a: raw_mesh_t)=>void + void *cb = any_map_get(util_mesh_unwrappers, f); // JSValue * -> (a: raw_mesh_t)=>void js_call_ptr(cb, mesh); } done(mesh); } +void project_import_asset_on_file_picked(char *path) { + import_asset_run(path, -1.0, -1.0, true, _project_import_asset_hdr_as_envmap, NULL); +} + void project_import_asset(char *filters, bool hdr_as_envmap) { if (filters == NULL) { filters = string_join(string_join(string_array_join(path_texture_formats(), ","), ","), string_array_join(path_mesh_formats(), ",")); @@ -590,19 +594,10 @@ void project_import_asset(char *filters, bool hdr_as_envmap) { _project_import_asset_hdr_as_envmap = hdr_as_envmap; - ui_files_show(filters, false, true, &project_import_asset_105217); + ui_files_show(filters, false, true, &project_import_asset_on_file_picked); } -void project_import_asset_105217(char *path) { - import_asset_run(path, -1.0, -1.0, true, _project_import_asset_hdr_as_envmap, NULL); -} - -void project_import_swatches(bool replace_existing) { - _project_import_swatches_replace_existing = replace_existing; - ui_files_show("arm,gpl", false, false, &project_import_swatches_105263); -} - -void project_import_swatches_105263(char *path) { +void project_import_swatches_on_file_picked(char *path) { if (path_is_gimp_color_palette(path)) { // import_gpl_run(path, _project_import_swatches_replace_existing); } @@ -611,6 +606,11 @@ void project_import_swatches_105263(char *path) { } } +void project_import_swatches(bool replace_existing) { + _project_import_swatches_replace_existing = replace_existing; + ui_files_show("arm,gpl", false, false, &project_import_swatches_on_file_picked); +} + void project_reimport_textures() { for (i32 i = 0; i < project_assets->length; ++i) { asset_t *asset = project_assets->buffer[i]; @@ -618,6 +618,12 @@ void project_reimport_textures() { } } +void project_reimport_texture_load_on_next_frame(void *_) { + make_material_parse_paint_material(true); + util_render_make_material_preview(); + ui_base_hwnds->buffer[TAB_AREA_SIDEBAR1]->redraws = 2; +} + void project_reimport_texture_load(char *path, asset_t *asset) { asset->file = string_copy(path); i32 i = array_index_of(project_assets, asset); @@ -634,13 +640,11 @@ void project_reimport_texture_load(char *path, asset_t *asset) { context_raw->texture = project_assets->buffer[i]; } - sys_notify_on_next_frame(&project_reimport_texture_load_105445, NULL); + sys_notify_on_next_frame(&project_reimport_texture_load_on_next_frame, NULL); } -void project_reimport_texture_load_105445(void * _) { - make_material_parse_paint_material(true); - util_render_make_material_preview(); - ui_base_hwnds->buffer[TAB_AREA_SIDEBAR1]->redraws = 2; +void project_reimport_texture_on_file_picked(char *path) { + project_reimport_texture_load(path, _project_reimport_texture_asset); } void project_reimport_texture(asset_t *asset) { @@ -649,17 +653,13 @@ void project_reimport_texture(asset_t *asset) { gc_unroot(_project_reimport_texture_asset); _project_reimport_texture_asset = asset; gc_root(_project_reimport_texture_asset); - ui_files_show(filters, false, false, &project_reimport_texture_105515); + ui_files_show(filters, false, false, &project_reimport_texture_on_file_picked); } else { project_reimport_texture_load(asset->file, asset); } } -void project_reimport_texture_105515(char *path) { - project_reimport_texture_load(path, _project_reimport_texture_asset); -} - gpu_texture_t *project_get_image(asset_t *asset) { return asset != NULL ? any_imap_get(project_asset_map, asset->id) : NULL; } @@ -692,7 +692,7 @@ bool project_is_atlas_object(mesh_object_t *p) { return false; } char *atlas_name = project_get_used_atlases()->buffer[context_raw->layer_filter - project_paint_objects->length - 1]; - i32 atlas_i = char_ptr_array_index_of(project_atlas_names, atlas_name); + i32 atlas_i = char_ptr_array_index_of(project_atlas_names, atlas_name); return atlas_i == project_atlas_objects->buffer[array_index_of(project_paint_objects, p)]; } @@ -702,7 +702,7 @@ mesh_object_t_array_t *project_get_atlas_objects(i32 object_mask) { if (atlases == NULL || i >= atlases->length) { return project_paint_objects; } - char *atlas_name = atlases->buffer[i]; + char *atlas_name = atlases->buffer[i]; i32 atlas_i = char_ptr_array_index_of(project_atlas_names, atlas_name); mesh_object_t_array_t *visibles = any_array_create_from_raw((void *[]){}, 0); for (i32 i = 0; i < project_paint_objects->length; ++i) { @@ -723,11 +723,7 @@ bool project_packed_asset_exists(packed_asset_t_array_t *packed_assets, char *na return false; } -void project_export_swatches() { - ui_files_show("arm,gpl", true, false, &project_export_swatches_105968); -} - -void project_export_swatches_105968(char *path) { +void project_export_swatches_on_file_picked(char *path) { char *f = ui_files_filename; if (string_equals(f, "")) { f = string_copy(tr("untitled", NULL)); @@ -740,7 +736,11 @@ void project_export_swatches_105968(char *path) { } } -swatch_color_t *make_swatch(i32 base) { +void project_export_swatches() { + ui_files_show("arm,gpl", true, false, &project_export_swatches_on_file_picked); +} + +swatch_color_t *project_make_swatch(i32 base) { swatch_color_t *s = GC_ALLOC_INIT(swatch_color_t, {.base = base, .opacity = 1.0, .occlusion = 1.0, @@ -779,7 +779,7 @@ void project_set_default_swatches() { 31); for (i32 i = 0; i < colors->length; ++i) { i32 c = colors->buffer[i]; - any_array_push(project_raw->swatches, make_swatch(c)); + any_array_push(project_raw->swatches, project_make_swatch(c)); } } @@ -807,7 +807,7 @@ bool project_is_material_group_in_use(node_group_t *group) { ui_node_canvas_t *canvas = canvases->buffer[i]; for (i32 i = 0; i < canvas->nodes->length; ++i) { ui_node_t *n = canvas->nodes->buffer[i]; - char *cname = group->canvas->name; + char *cname = group->canvas->name; if (string_equals(n->type, "GROUP") && string_equals(n->name, cname)) { return true; } diff --git a/paint/sources/render_path_paint.c b/paint/sources/render_path_paint.c index b2b52b8d..eaa4e95f 100644 --- a/paint/sources/render_path_paint.c +++ b/paint/sources/render_path_paint.c @@ -595,6 +595,10 @@ void _render_path_paint_final() { render_path_paint_update_bake_layer(TEXTURE_BITS_BITS8); } +void _render_path_paint_deriv_on_next_frame(void * _) { + _render_path_paint_final(); +} + void _render_path_paint_deriv() { context_raw->bake_type = BAKE_TYPE_HEIGHT; make_material_parse_paint_material(true); @@ -604,11 +608,7 @@ void _render_path_paint_deriv() { if (render_path_paint_push_undo_last) { history_paint(); } - sys_notify_on_next_frame(&_render_path_paint_deriv_178293, NULL); -} - -void _render_path_paint_deriv_178293(void * _) { - _render_path_paint_final(); + sys_notify_on_next_frame(&_render_path_paint_deriv_on_next_frame, NULL); } bool render_path_paint_is_rt_bake() { @@ -623,6 +623,14 @@ void render_path_paint_update_bake_layer(texture_bits_t bits) { } } +void render_path_paint_draw_bake(void * _) { + _render_path_paint_final(); +} + +void render_path_paint_draw_bake_derivative(void * _) { + _render_path_paint_deriv(); +} + void render_path_paint_draw() { if (!render_path_paint_paint_enabled()) { return; @@ -664,10 +672,10 @@ void render_path_paint_draw() { context_select_paint_object(_paint_object); if (context_raw->bake_type == BAKE_TYPE_DERIVATIVE) { - sys_notify_on_next_frame(&render_path_paint_draw_178546, NULL); + sys_notify_on_next_frame(&render_path_paint_draw_bake_derivative, NULL); } else { - sys_notify_on_next_frame(&render_path_paint_draw_178565, NULL); + sys_notify_on_next_frame(&render_path_paint_draw_bake, NULL); } } } @@ -719,14 +727,6 @@ void render_path_paint_draw() { } } -void render_path_paint_draw_178565(void * _) { - _render_path_paint_final(); -} - -void render_path_paint_draw_178546(void * _) { - _render_path_paint_deriv(); -} - void render_path_paint_set_plane_mesh() { context_raw->paint2d_view = true; gc_unroot(render_path_paint_painto); diff --git a/paint/sources/render_path_raytrace_bake.c b/paint/sources/render_path_raytrace_bake.c index d0d922c5..d6c4fea0 100644 --- a/paint/sources/render_path_raytrace_bake.c +++ b/paint/sources/render_path_raytrace_bake.c @@ -1,6 +1,10 @@ #include "global.h" +void render_path_raytrace_bake_commands_parse_paint_material(void (*parse_paint_material)(bool)) { + parse_paint_material(true); +} + bool render_path_raytrace_bake_commands(void (*parse_paint_material)(bool)) { if (!render_path_raytrace_ready || !render_path_raytrace_is_bake || render_path_raytrace_bake_last_bake_type != context_raw->bake_type) { @@ -61,7 +65,7 @@ bool render_path_raytrace_bake_commands(void (*parse_paint_material)(bool)) { render_path_set_target("baketex0", additional, NULL, GPU_CLEAR_NONE, 0, 0.0); render_path_draw_meshes("paint"); context_raw->bake_type = _bake_type; - sys_notify_on_next_frame(&render_path_raytrace_bake_commands_134003, parse_paint_material); + sys_notify_on_next_frame(&render_path_raytrace_bake_commands_parse_paint_material, parse_paint_material); render_path_raytrace_init_shader = true; render_path_raytrace_raytrace_init(render_path_raytrace_bake_get_bake_shader_name(), rebuild); @@ -159,10 +163,6 @@ bool render_path_raytrace_bake_commands(void (*parse_paint_material)(bool)) { } } -void render_path_raytrace_bake_commands_134003(void (*parse_paint_material)(bool)) { - parse_paint_material(true); -} - char *render_path_raytrace_bake_get_bake_shader_name() { return context_raw->bake_type == BAKE_TYPE_AO ? string_join("raytrace_bake_ao", render_path_raytrace_ext) : context_raw->bake_type == BAKE_TYPE_LIGHTMAP ? string_join("raytrace_bake_light", render_path_raytrace_ext) diff --git a/paint/sources/slot_layer.c b/paint/sources/slot_layer.c index b0386dab..4e25e706 100644 --- a/paint/sources/slot_layer.c +++ b/paint/sources/slot_layer.c @@ -402,17 +402,17 @@ void slot_layer_resize_and_set_bits(slot_layer_t *raw) { } } +void slot_layer_to_fill_layer_on_next_frame(void * _) { + make_material_parse_paint_material(true); + context_raw->layer_preview_dirty = true; + ui_base_hwnds->buffer[TAB_AREA_SIDEBAR0]->redraws = 2; +} + void slot_layer_to_fill_layer(slot_layer_t *raw) { context_set_layer(raw); raw->fill_layer = context_raw->material; layers_update_fill_layer(true); - sys_notify_on_next_frame(&slot_layer_to_fill_layer_19750, NULL); -} - -void slot_layer_to_fill_layer_19750(void * _) { - make_material_parse_paint_material(true); - context_raw->layer_preview_dirty = true; - ui_base_hwnds->buffer[TAB_AREA_SIDEBAR0]->redraws = 2; + sys_notify_on_next_frame(&slot_layer_to_fill_layer_on_next_frame, NULL); } void slot_layer_to_paint_layer(slot_layer_t *raw) { @@ -744,7 +744,7 @@ void layers_resize() { config_raw->undo_steps = 1; while (history_undo_layers->length > config_raw->undo_steps) { slot_layer_t *l = array_pop(history_undo_layers); - sys_notify_on_next_frame(&layers_resize_21670, l); + sys_notify_on_next_frame(&slot_layer_unload, l); } } for (i32 i = 0; i < project_layers->length; ++i) { @@ -791,10 +791,6 @@ void layers_resize() { context_raw->ddirty = 2; } -void layers_resize_21670(slot_layer_t *l) { - slot_layer_unload(l); -} - void layers_set_bits() { for (i32 i = 0; i < project_layers->length; ++i) { slot_layer_t *l = project_layers->buffer[i]; @@ -1145,6 +1141,10 @@ void layers_set_object_mask() { util_uv_dilatemap_cached = false; } +void layers_new_layer_clear(slot_layer_t *l) { + slot_layer_clear(l, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); +} + slot_layer_t *layers_new_layer(bool clear, i32 position) { if (project_layers->length > layers_max_layers) { return NULL; @@ -1171,13 +1171,13 @@ slot_layer_t *layers_new_layer(bool clear, i32 position) { } } if (clear) { - sys_notify_on_next_frame(&layers_new_layer_23812, l); + sys_notify_on_next_frame(&layers_new_layer_clear, l); } context_raw->layer_preview_dirty = true; return l; } -void layers_new_layer_23812(slot_layer_t *l) { +void layers_new_mask_clear(slot_layer_t *l) { slot_layer_clear(l, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); } @@ -1193,16 +1193,12 @@ slot_layer_t *layers_new_mask(bool clear, slot_layer_t *parent, i32 position) { array_insert(project_layers, position, l); context_set_layer(l); if (clear) { - sys_notify_on_next_frame(&layers_new_mask_23923, l); + sys_notify_on_next_frame(&layers_new_mask_clear, l); } context_raw->layer_preview_dirty = true; return l; } -void layers_new_mask_23923(slot_layer_t *l) { - slot_layer_clear(l, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); -} - slot_layer_t *layers_new_group() { if (project_layers->length > layers_max_layers) { return NULL; @@ -1214,18 +1210,7 @@ slot_layer_t *layers_new_group() { return l; } -void layers_create_fill_layer(uv_type_t uv_type, mat4_t decal_mat, i32 position) { - if (context_raw->tool == TOOL_TYPE_GIZMO) { - return; - } - - _layers_uv_type = uv_type; - _layers_decal_mat = decal_mat; - _layers_position = position; - sys_notify_on_next_frame(&layers_create_fill_layer_24041, NULL); -} - -void layers_create_fill_layer_24041(void * _) { +void layers_create_fill_layer_on_next_frame(void * _) { slot_layer_t *l = layers_new_layer(false, _layers_position); history_new_layer(); l->uv_type = _layers_uv_type; @@ -1237,6 +1222,17 @@ void layers_create_fill_layer_24041(void * _) { slot_layer_to_fill_layer(l); } +void layers_create_fill_layer(uv_type_t uv_type, mat4_t decal_mat, i32 position) { + if (context_raw->tool == TOOL_TYPE_GIZMO) { + return; + } + + _layers_uv_type = uv_type; + _layers_decal_mat = decal_mat; + _layers_position = position; + sys_notify_on_next_frame(&layers_create_fill_layer_on_next_frame, NULL); +} + void layers_create_image_mask(asset_t *asset) { slot_layer_t *l = context_raw->layer; if (slot_layer_is_mask(l) || slot_layer_is_group(l)) { @@ -1249,6 +1245,14 @@ void layers_create_image_mask(asset_t *asset) { context_raw->layer_preview_dirty = true; } +void layers_create_color_layer_on_next_frame(void * _) { + slot_layer_t *l = layers_new_layer(false, _layers_position); + history_new_layer(); + l->uv_type = UV_TYPE_UVMAP; + l->object_mask = context_raw->layer_filter; + slot_layer_clear(l, _layers_base_color, NULL, _layers_occlusion, _layers_roughness, _layers_metallic); +} + void layers_create_color_layer(i32 base_color, f32 occlusion, f32 roughness, f32 metallic, i32 position) { _layers_base_color = base_color; _layers_occlusion = occlusion; @@ -1256,15 +1260,7 @@ void layers_create_color_layer(i32 base_color, f32 occlusion, f32 roughness, f32 _layers_metallic = metallic; _layers_position = position; - sys_notify_on_next_frame(&layers_create_color_layer_24217, NULL); -} - -void layers_create_color_layer_24217(void * _) { - slot_layer_t *l = layers_new_layer(false, _layers_position); - history_new_layer(); - l->uv_type = UV_TYPE_UVMAP; - l->object_mask = context_raw->layer_filter; - slot_layer_clear(l, _layers_base_color, NULL, _layers_occlusion, _layers_roughness, _layers_metallic); + sys_notify_on_next_frame(&layers_create_color_layer_on_next_frame, NULL); } void layers_duplicate_layer(slot_layer_t *l) { @@ -1654,19 +1650,7 @@ slot_layer_t *layers_flatten(bool height_to_normal, slot_layer_t_array_t *layers return l0; } -void layers_on_resized() { - sys_notify_on_next_frame(&layers_on_resized_26530, NULL); - gc_unroot(util_uv_uvmap); - util_uv_uvmap = NULL; - util_uv_uvmap_cached = false; - gc_unroot(util_uv_trianglemap); - util_uv_trianglemap = NULL; - util_uv_trianglemap_cached = false; - util_uv_dilatemap_cached = false; - render_path_raytrace_ready = false; -} - -void layers_on_resized_26530(void * _) { +void layers_on_resized_on_next_frame(void * _) { layers_resize(); slot_layer_t *_layer = context_raw->layer; slot_material_t *_material = context_raw->material; @@ -1682,3 +1666,15 @@ void layers_on_resized_26530(void * _) { context_raw->material = _material; make_material_parse_paint_material(true); } + +void layers_on_resized() { + sys_notify_on_next_frame(&layers_on_resized_on_next_frame, NULL); + gc_unroot(util_uv_uvmap); + util_uv_uvmap = NULL; + util_uv_uvmap_cached = false; + gc_unroot(util_uv_trianglemap); + util_uv_trianglemap = NULL; + util_uv_trianglemap_cached = false; + util_uv_dilatemap_cached = false; + render_path_raytrace_ready = false; +} diff --git a/paint/sources/tab_browser.c b/paint/sources/tab_browser.c index 756faafa..840f1ea4 100644 --- a/paint/sources/tab_browser.c +++ b/paint/sources/tab_browser.c @@ -8,6 +8,118 @@ void tab_browser_show_directory(char *directory) { config_raw->layout_tabs->buffer[TAB_AREA_STATUS] = 0; } +void tab_browser_draw_bookmark_menu() { + if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { + char_ptr_array_remove(config_raw->bookmarks, _tab_browser_draw_b); + config_save(); + } +} + +void tab_browser_draw_import_asset(char *path) { + import_asset_run(path, -1.0, -1.0, true, true, NULL); +} + +void tab_browser_draw_set_as_color_id_map_on_next_frame(void * _) { + char *file = _tab_browser_draw_file; + i32 asset_index = -1; + for (i32 i = 0; i < project_assets->length; ++i) { + if (string_equals(project_assets->buffer[i]->file, file)) { + asset_index = i; + break; + } + } + + if (asset_index != -1) { + context_raw->colorid_handle->i = asset_index; + context_raw->colorid_picked = false; + ui_toolbar_handle->redraws = 1; + if (context_raw->tool == TOOL_TYPE_COLORID) { + ui_header_handle->redraws = 2; + context_raw->ddirty = 2; + } + } +} + +void tab_browser_draw_set_as_color_id_map() { + sys_notify_on_next_frame(&tab_browser_draw_set_as_color_id_map_on_next_frame, NULL); +} + +void tab_browser_draw_set_as_mask_on_next_frame(void * _) { + char *file = _tab_browser_draw_file; + i32 asset_index = -1; + for (i32 i = 0; i < project_assets->length; ++i) { + if (string_equals(project_assets->buffer[i]->file, file)) { + asset_index = i; + break; + } + } + if (asset_index != -1) { + layers_create_image_mask(project_assets->buffer[asset_index]); + } +} + +void tab_browser_draw_set_as_mask() { + sys_notify_on_next_frame(&tab_browser_draw_set_as_mask_on_next_frame, NULL); +} + +void tab_browser_draw_set_as_envmap_on_next_frame(void * _) { + char *file = _tab_browser_draw_file; + i32 asset_index = -1; + for (i32 i = 0; i < project_assets->length; ++i) { + if (string_equals(project_assets->buffer[i]->file, file)) { + asset_index = i; + break; + } + } + + if (asset_index != -1) { + import_envmap_run(file, project_get_image(project_assets->buffer[asset_index])); + } +} + +void tab_browser_draw_set_as_envmap() { + sys_notify_on_next_frame(&tab_browser_draw_set_as_envmap_on_next_frame, NULL); +} + +void tab_browser_draw_context_menu_draw() { + char *file = _tab_browser_draw_file; + if (ui_menu_button(tr("Import", NULL), "", ICON_IMPORT)) { + import_asset_run(file, -1.0, -1.0, true, true, NULL); + } + if (path_is_texture(file)) { + if (ui_menu_button(tr("Set as Envmap", NULL), "", ICON_LANDSCAPE)) { + import_asset_run(file, -1.0, -1.0, true, true, &tab_browser_draw_set_as_envmap); + } + if (ui_menu_button(tr("Set as Mask", NULL), "", ICON_MASK)) { + import_asset_run(file, -1.0, -1.0, true, true, &tab_browser_draw_set_as_mask); + } + if (ui_menu_button(tr("Set as Color ID Map", NULL), "", ICON_COLOR_ID)) { + import_asset_run(file, -1.0, -1.0, true, true, &tab_browser_draw_set_as_color_id_map); + } + } + if (ui_menu_button(tr("Open Externally", NULL), "", ICON_NONE)) { + file_start(file); + } +} + +void tab_browser_draw_context_menu(char *file) { + gc_unroot(_tab_browser_draw_file); + _tab_browser_draw_file = string_copy(file); + gc_root(_tab_browser_draw_file); + + // Context menu + ui_menu_draw(&tab_browser_draw_context_menu_draw, -1, -1); +} + +void tab_browser_draw_side_menu() { + if (ui_menu_button(tr("Cloud", NULL), "", ICON_CLOUD)) { + tab_browser_go_to_cloud(); + } + if (ui_menu_button(tr("Disk", NULL), "", ICON_STORAGE)) { + tab_browser_go_to_disk(); + } +} + void tab_browser_draw(ui_handle_t *htab) { char *title = tr("Browser", NULL); @@ -90,7 +202,7 @@ void tab_browser_draw(ui_handle_t *htab) { 3); ui_row(row); if (ui_icon_button("", ICON_MENU, UI_ALIGN_CENTER)) { - ui_menu_draw(&tab_browser_draw_121079, -1, -1); + ui_menu_draw(&tab_browser_draw_side_menu, -1, -1); } } @@ -157,13 +269,13 @@ void tab_browser_draw(ui_handle_t *htab) { ui->_w -= bookmarks_w; } - ui_files_file_browser(tab_browser_hpath, true, tab_browser_hsearch->text, tab_browser_refresh, &tab_browser_draw_121442); + ui_files_file_browser(tab_browser_hpath, true, tab_browser_hsearch->text, tab_browser_refresh, &tab_browser_draw_context_menu); tab_browser_refresh = false; if (tab_browser_known) { char *path = tab_browser_hpath->text; - sys_notify_on_next_frame(&tab_browser_draw_121898, path); + sys_notify_on_next_frame(&tab_browser_draw_import_asset, path); tab_browser_hpath->text = string_copy(substring(tab_browser_hpath->text, 0, string_last_index_of(tab_browser_hpath->text, PATH_SEP))); } char *hpath_text = tab_browser_hpath->text; @@ -207,7 +319,7 @@ void tab_browser_draw(ui_handle_t *htab) { gc_unroot(_tab_browser_draw_b); _tab_browser_draw_b = string_copy(b); gc_root(_tab_browser_draw_b); - ui_menu_draw(&tab_browser_draw_122149, -1, -1); + ui_menu_draw(&tab_browser_draw_bookmark_menu, -1, -1); } } if (ui->_y < bottom_y) { @@ -217,131 +329,13 @@ void tab_browser_draw(ui_handle_t *htab) { } } -void tab_browser_draw_122149() { - if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { - char_ptr_array_remove(config_raw->bookmarks, _tab_browser_draw_b); - config_save(); - } -} - -void tab_browser_draw_121898(char *path) { - import_asset_run(path, -1.0, -1.0, true, true, NULL); -} - -void tab_browser_draw_121757(void * _) { - char *file = _tab_browser_draw_file; - i32 asset_index = -1; - for (i32 i = 0; i < project_assets->length; ++i) { - if (string_equals(project_assets->buffer[i]->file, file)) { - asset_index = i; - break; - } - } - - if (asset_index != -1) { - context_raw->colorid_handle->i = asset_index; - context_raw->colorid_picked = false; - ui_toolbar_handle->redraws = 1; - if (context_raw->tool == TOOL_TYPE_COLORID) { - ui_header_handle->redraws = 2; - context_raw->ddirty = 2; - } - } -} - -void tab_browser_draw_121751() { - sys_notify_on_next_frame(&tab_browser_draw_121757, NULL); -} - -void tab_browser_draw_121645(void * _) { - char *file = _tab_browser_draw_file; - i32 asset_index = -1; - for (i32 i = 0; i < project_assets->length; ++i) { - if (string_equals(project_assets->buffer[i]->file, file)) { - asset_index = i; - break; - } - } - if (asset_index != -1) { - layers_create_image_mask(project_assets->buffer[asset_index]); - } -} - -void tab_browser_draw_121639() { - sys_notify_on_next_frame(&tab_browser_draw_121645, NULL); -} - -void tab_browser_draw_121528(void * _) { - char *file = _tab_browser_draw_file; - i32 asset_index = -1; - for (i32 i = 0; i < project_assets->length; ++i) { - if (string_equals(project_assets->buffer[i]->file, file)) { - asset_index = i; - break; - } - } - - if (asset_index != -1) { - import_envmap_run(file, project_get_image(project_assets->buffer[asset_index])); - } -} - -void tab_browser_draw_121522() { - sys_notify_on_next_frame(&tab_browser_draw_121528, NULL); -} - -void tab_browser_draw_121455() { - char *file = _tab_browser_draw_file; - if (ui_menu_button(tr("Import", NULL), "", ICON_IMPORT)) { - import_asset_run(file, -1.0, -1.0, true, true, NULL); - } - if (path_is_texture(file)) { - if (ui_menu_button(tr("Set as Envmap", NULL), "", ICON_LANDSCAPE)) { - import_asset_run(file, -1.0, -1.0, true, true, &tab_browser_draw_121522); - } - if (ui_menu_button(tr("Set as Mask", NULL), "", ICON_MASK)) { - import_asset_run(file, -1.0, -1.0, true, true, &tab_browser_draw_121639); - } - if (ui_menu_button(tr("Set as Color ID Map", NULL), "", ICON_COLOR_ID)) { - import_asset_run(file, -1.0, -1.0, true, true, &tab_browser_draw_121751); - } - } - if (ui_menu_button(tr("Open Externally", NULL), "", ICON_NONE)) { - file_start(file); - } -} - -void tab_browser_draw_121442(char *file) { - gc_unroot(_tab_browser_draw_file); - _tab_browser_draw_file = string_copy(file); - gc_root(_tab_browser_draw_file); - - // Context menu - ui_menu_draw(&tab_browser_draw_121455, -1, -1); -} - -void tab_browser_draw_121079() { - if (ui_menu_button(tr("Cloud", NULL), "", ICON_CLOUD)) { - tab_browser_go_to_cloud(); - } - if (ui_menu_button(tr("Disk", NULL), "", ICON_STORAGE)) { - tab_browser_go_to_disk(); - } -} - void tab_browser_go_to_cloud() { tab_browser_hpath->text = "cloud"; } -void tab_browser_go_to_disk() { - #ifdef IRON_ANDROID - ui_menu_draw(&tab_browser_go_to_disk_122217, -1, -1); - #else - tab_browser_hpath->text = string_copy(ui_files_default_path); - #endif -} +#ifdef IRON_ANDROID -void tab_browser_go_to_disk_122217() { +void tab_browser_go_to_disk_android_menu() { if (ui_menu_button(tr("Download", NULL), "", ICON_FOLDER)) { tab_browser_hpath->text = string_copy(ui_files_default_path); } @@ -355,3 +349,13 @@ void tab_browser_go_to_disk_122217() { tab_browser_hpath->text = string_copy(iron_internal_save_path()); } } + +#endif + +void tab_browser_go_to_disk() { + #ifdef IRON_ANDROID + ui_menu_draw(&tab_browser_go_to_disk_android_menu, -1, -1); + #else + tab_browser_hpath->text = string_copy(ui_files_default_path); + #endif +} diff --git a/paint/sources/tab_brushes.c b/paint/sources/tab_brushes.c index 7427f953..3b4e31b3 100644 --- a/paint/sources/tab_brushes.c +++ b/paint/sources/tab_brushes.c @@ -1,6 +1,43 @@ #include "global.h" +void tab_brushes_draw_make_brush_preview(void * _) { + i32 i = _tab_brushes_draw_i; + slot_brush_t *_brush = context_raw->brush; + context_raw->brush = project_brushes->buffer[i]; + make_material_parse_brush(); + util_render_make_brush_preview(); + context_raw->brush = _brush; +} + +void tab_brushes_draw_duplicate(void * _) { + i32 i = _tab_brushes_draw_i; + context_raw->brush = slot_brush_create(NULL); + any_array_push(project_brushes, context_raw->brush); + void * cloned = util_clone_canvas(project_brushes->buffer[i]->canvas); + context_raw->brush->canvas = cloned; + context_set_brush(context_raw->brush); + util_render_make_brush_preview(); +} + +void tab_brushes_draw_context_menu() { + i32 i = _tab_brushes_draw_i; + // let b: slot_brush_t = brushes[i]; + + if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { + context_select_brush(i); + box_export_show_brush(); + } + + if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { + sys_notify_on_next_frame(&tab_brushes_draw_duplicate, NULL); + } + + if (project_brushes->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { + tab_brushes_delete_brush(project_brushes->buffer[i]); + } +} + void tab_brushes_draw(ui_handle_t *htab) { if (ui_tab(htab, tr("Brushes", NULL), false, -1, false)) { ui_begin_sticky(); @@ -95,13 +132,13 @@ void tab_brushes_draw(ui_handle_t *htab) { _tab_brushes_draw_i = i; - ui_menu_draw(&tab_brushes_draw_41711, -1, -1); + ui_menu_draw(&tab_brushes_draw_context_menu, -1, -1); } if (ui->is_hovered) { if (img_full == NULL) { _tab_brushes_draw_i = i; - sys_notify_on_next_frame(&tab_brushes_draw_41872, NULL); + sys_notify_on_next_frame(&tab_brushes_draw_make_brush_preview, NULL); } else { ui_tooltip_image(img_full, 0); @@ -135,43 +172,6 @@ void tab_brushes_draw(ui_handle_t *htab) { } } -void tab_brushes_draw_41872(void * _) { - i32 i = _tab_brushes_draw_i; - slot_brush_t *_brush = context_raw->brush; - context_raw->brush = project_brushes->buffer[i]; - make_material_parse_brush(); - util_render_make_brush_preview(); - context_raw->brush = _brush; -} - -void tab_brushes_draw_41764(void * _) { - i32 i = _tab_brushes_draw_i; - context_raw->brush = slot_brush_create(NULL); - any_array_push(project_brushes, context_raw->brush); - void * cloned = util_clone_canvas(project_brushes->buffer[i]->canvas); - context_raw->brush->canvas = cloned; - context_set_brush(context_raw->brush); - util_render_make_brush_preview(); -} - -void tab_brushes_draw_41711() { - i32 i = _tab_brushes_draw_i; - // let b: slot_brush_t = brushes[i]; - - if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { - context_select_brush(i); - box_export_show_brush(); - } - - if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { - sys_notify_on_next_frame(&tab_brushes_draw_41764, NULL); - } - - if (project_brushes->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { - tab_brushes_delete_brush(project_brushes->buffer[i]); - } -} - void tab_brushes_delete_brush(slot_brush_t *b) { i32 i = array_index_of(project_brushes, b); context_select_brush(i == project_brushes->length - 1 ? i - 1 : i + 1); diff --git a/paint/sources/tab_console.c b/paint/sources/tab_console.c index 2c6ab9b5..69c494aa 100644 --- a/paint/sources/tab_console.c +++ b/paint/sources/tab_console.c @@ -1,6 +1,19 @@ #include "global.h" +void tab_console_draw_export_on_file_picked(char *path) { + char *str = string_array_join(console_last_traces, "\n"); + char *f = ui_files_filename; + if (string_equals(f, "")) { + f = string_copy(tr("untitled", NULL)); + } + path = string_join(string_join(path, PATH_SEP), f); + if (!ends_with(path, ".txt")) { + path = string_join(path, ".txt"); + } + iron_file_save_bytes(path, sys_string_to_buffer(str), 0); +} + void tab_console_draw(ui_handle_t *htab) { char *title = console_message_timer > 0 ? string_join(console_message, " ") : tr("Console", NULL); i32 color = console_message_timer > 0 ? console_message_color : -1; @@ -32,7 +45,7 @@ void tab_console_draw(ui_handle_t *htab) { gc_root(console_last_traces); } if (ui_icon_button(tr("Export", NULL), ICON_EXPORT, UI_ALIGN_CENTER)) { - ui_files_show("txt", true, false, &tab_console_draw_37642); + ui_files_show("txt", true, false, &tab_console_draw_export_on_file_picked); } #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) if (ui_icon_button(tr("Copy", NULL), ICON_COPY, UI_ALIGN_CENTER)) { @@ -56,16 +69,3 @@ void tab_console_draw(ui_handle_t *htab) { ui->font_size = _font_size; } } - -void tab_console_draw_37642(char *path) { - char *str = string_array_join(console_last_traces, "\n"); - char *f = ui_files_filename; - if (string_equals(f, "")) { - f = string_copy(tr("untitled", NULL)); - } - path = string_join(string_join(path, PATH_SEP), f); - if (!ends_with(path, ".txt")) { - path = string_join(path, ".txt"); - } - iron_file_save_bytes(path, sys_string_to_buffer(str), 0); -} diff --git a/paint/sources/tab_fonts.c b/paint/sources/tab_fonts.c index c0cd9b4b..07f08d22 100644 --- a/paint/sources/tab_fonts.c +++ b/paint/sources/tab_fonts.c @@ -1,6 +1,31 @@ #include "global.h" +void tab_fonts_draw_make_font_preview(void * _) { + i32 i = _tab_fonts_draw_i; + slot_font_t *_font = context_raw->font; + context_raw->font = project_fonts->buffer[i]; + util_render_make_font_preview(); + context_raw->font = _font; +} + +void tab_fonts_draw_context_menu_draw() { + i32 i = _tab_fonts_draw_i; + if (project_fonts->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE) && !string_equals(project_fonts->buffer[i]->file, "")) { + tab_fonts_delete_font(project_fonts->buffer[i]); + } +} + +void tab_fonts_draw_context_menu(void * _) { + context_select_font(_tab_fonts_draw_i); + ui_menu_draw(&tab_fonts_draw_context_menu_draw, -1, -1); +} + +void tab_fonts_draw_select_font(void * _) { + i32 i = _tab_fonts_draw_i; + context_select_font(i); +} + void tab_fonts_draw(ui_handle_t *htab) { if (ui_tab(htab, tr("Fonts", NULL), false, -1, false) && ui->_window_h > ui_statusbar_default_h * UI_SCALE()) { @@ -88,7 +113,7 @@ void tab_fonts_draw(ui_handle_t *htab) { if (context_raw->font != project_fonts->buffer[i]) { _tab_fonts_draw_i = i; - sys_notify_on_next_frame(&tab_fonts_draw_97837, NULL); + sys_notify_on_next_frame(&tab_fonts_draw_select_font, NULL); } if (sys_time() - context_raw->select_time < 0.2) { ui_base_show_2d_view(VIEW_2D_TYPE_FONT); @@ -97,12 +122,12 @@ void tab_fonts_draw(ui_handle_t *htab) { } if (ui->is_hovered && ui->input_released_r) { _tab_fonts_draw_i = i; - sys_notify_on_next_frame(&tab_fonts_draw_97897, NULL); + sys_notify_on_next_frame(&tab_fonts_draw_context_menu, NULL); } if (ui->is_hovered) { if (img == NULL) { _tab_fonts_draw_i = i; - sys_notify_on_next_frame(&tab_fonts_draw_97983, NULL); + sys_notify_on_next_frame(&tab_fonts_draw_make_font_preview, NULL); } else { ui_tooltip_image(img, 0); @@ -136,40 +161,14 @@ void tab_fonts_draw(ui_handle_t *htab) { } } -void tab_fonts_draw_97983(void * _) { - i32 i = _tab_fonts_draw_i; - slot_font_t *_font = context_raw->font; - context_raw->font = project_fonts->buffer[i]; - util_render_make_font_preview(); - context_raw->font = _font; -} - -void tab_fonts_draw_97911() { - i32 i = _tab_fonts_draw_i; - if (project_fonts->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE) && !string_equals(project_fonts->buffer[i]->file, "")) { - tab_fonts_delete_font(project_fonts->buffer[i]); - } -} - -void tab_fonts_draw_97897(void * _) { - context_select_font(_tab_fonts_draw_i); - ui_menu_draw(&tab_fonts_draw_97911, -1, -1); -} - -void tab_fonts_draw_97837(void * _) { - i32 i = _tab_fonts_draw_i; - context_select_font(i); -} - -void tab_fonts_delete_font(slot_font_t *font) { - sys_notify_on_next_frame(&tab_fonts_delete_font_98187, font); - - ui_base_hwnds->buffer[2]->redraws = 2; -} - -void tab_fonts_delete_font_98187(slot_font_t *font) { +void tab_fonts_delete_font_on_next_frame(slot_font_t *font) { i32 i = array_index_of(project_fonts, font); context_select_font(i == project_fonts->length - 1 ? i - 1 : i + 1); data_delete_font(project_fonts->buffer[i]->file); array_splice(project_fonts, i, 1); } + +void tab_fonts_delete_font(slot_font_t *font) { + sys_notify_on_next_frame(&tab_fonts_delete_font_on_next_frame, font); + ui_base_hwnds->buffer[2]->redraws = 2; +} diff --git a/paint/sources/tab_layers.c b/paint/sources/tab_layers.c index ac533b6f..9249b516 100644 --- a/paint/sources/tab_layers.c +++ b/paint/sources/tab_layers.c @@ -82,45 +82,31 @@ void tab_layers_highlight_odd_lines() { } } -void tab_layers_button_new(char *text) { - if (ui_icon_button(text, ICON_PLUS, UI_ALIGN_CENTER)) { - ui_menu_draw(&tab_layers_button_new_189383, -1, -1); - } -} - -void tab_layers_button_new_189759(void * _) { - layers_update_fill_layers(); -} - -void tab_layers_button_new_189732(slot_layer_t *m) { +void tab_layers_button_new_to_fill_layer(slot_layer_t *m) { slot_layer_to_fill_layer(m); } -void tab_layers_button_new_189670(void * _) { - layers_update_fill_layers(); -} - -void tab_layers_button_new_189641(slot_layer_t *m) { +void tab_layers_button_new_layer_clear(slot_layer_t *m) { slot_layer_clear(m, 0xffffffff, NULL, 1.0, layers_default_rough, 0.0); } -void tab_layers_button_new_189579(void * _) { +void tab_layers_button_new_update_fill_layers(void * _) { layers_update_fill_layers(); } -void tab_layers_button_new_189550(slot_layer_t *m) { +void tab_layers_button_new_black_mask(slot_layer_t *m) { slot_layer_clear(m, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); } -void tab_layers_button_new_189418(void * _) { +void tab_layers_button_new_sculpt_layer(void * _) { sculpt_layers_create_sculpt_layer(); } -void tab_layers_button_new_189383() { +void tab_layers_button_new_menu() { slot_layer_t *l = context_raw->layer; if (config_raw->workspace == WORKSPACE_SCULPT) { if (ui_menu_button(tr("Sculpt Layer", NULL), "", ICON_PAINT)) { - sys_notify_on_next_frame(&tab_layers_button_new_189418, NULL); + sys_notify_on_next_frame(&tab_layers_button_new_sculpt_layer, NULL); } } else { @@ -142,10 +128,10 @@ void tab_layers_button_new_189383() { l = context_raw->layer; slot_layer_t *m = layers_new_mask(false, l, -1); - sys_notify_on_next_frame(&tab_layers_button_new_189550, m); + sys_notify_on_next_frame(&tab_layers_button_new_black_mask, m); context_raw->layer_preview_dirty = true; history_new_black_mask(); - sys_notify_on_next_frame(&tab_layers_button_new_189579, NULL); + sys_notify_on_next_frame(&tab_layers_button_new_update_fill_layers, NULL); } if (ui_menu_button(tr("White Mask", NULL), "", ICON_MASK_WHITE)) { if (slot_layer_is_mask(l)) { @@ -154,10 +140,10 @@ void tab_layers_button_new_189383() { l = context_raw->layer; slot_layer_t *m = layers_new_mask(false, l, -1); - sys_notify_on_next_frame(&tab_layers_button_new_189641, m); + sys_notify_on_next_frame(&tab_layers_button_new_layer_clear, m); context_raw->layer_preview_dirty = true; history_new_white_mask(); - sys_notify_on_next_frame(&tab_layers_button_new_189670, NULL); + sys_notify_on_next_frame(&tab_layers_button_new_update_fill_layers, NULL); } if (ui_menu_button(tr("Fill Mask", NULL), "", ICON_MASK_FILL)) { if (slot_layer_is_mask(l)) { @@ -166,10 +152,10 @@ void tab_layers_button_new_189383() { l = context_raw->layer; slot_layer_t *m = layers_new_mask(false, l, -1); - sys_notify_on_next_frame(&tab_layers_button_new_189732, m); + sys_notify_on_next_frame(&tab_layers_button_new_to_fill_layer, m); context_raw->layer_preview_dirty = true; history_new_fill_mask(); - sys_notify_on_next_frame(&tab_layers_button_new_189759, NULL); + sys_notify_on_next_frame(&tab_layers_button_new_to_fill_layer, NULL); } ui->enabled = !slot_layer_is_group(context_raw->layer) && !slot_layer_is_in_group(context_raw->layer); if (ui_menu_button(tr("Group", NULL), "", ICON_FOLDER)) { @@ -197,6 +183,12 @@ void tab_layers_button_new_189383() { ui->enabled = true; } +void tab_layers_button_new(char *text) { + if (ui_icon_button(text, ICON_PLUS, UI_ALIGN_CENTER)) { + ui_menu_draw(&tab_layers_button_new_menu, -1, -1); + } +} + void tab_layers_combo_filter() { string_t_array_t *ar = any_array_create_from_raw( (void *[]){ @@ -353,6 +345,10 @@ void tab_layers_draw_layer_slot_mini(slot_layer_t *l, i32 i) { ui->_y = uiy + ui->ops->theme->ELEMENT_H * 2 * UI_SCALE(); } +void tab_layers_draw_layer_slot_full_delete_layer(void * _) { + tab_layers_delete_layer(context_raw->layer); +} + void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { i32 step = ui->ops->theme->ELEMENT_H; f32 center = (step / (float)2) * UI_SCALE(); @@ -440,7 +436,7 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { ui->input_y < ui->_window_y + ui->_window_h; if (in_focus && ui->is_delete_down && tab_layers_can_delete(context_raw->layer)) { ui->is_delete_down = false; - sys_notify_on_next_frame(&tab_layers_draw_layer_slot_full_191697, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_slot_full_delete_layer, NULL); } } @@ -478,8 +474,10 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { ui->_w = uiw; } -void tab_layers_draw_layer_slot_full_191697(void * _) { - tab_layers_delete_layer(context_raw->layer); +void tab_layers_combo_object_layer_clear(slot_layer_t *l) { + context_raw->material = l->fill_layer; + slot_layer_clear(l, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); + layers_update_fill_layers(); } ui_handle_t *tab_layers_combo_object(slot_layer_t *l, bool label) { @@ -506,7 +504,7 @@ ui_handle_t *tab_layers_combo_object(slot_layer_t *l, bool label) { context_set_layer(l); make_material_parse_mesh_material(); if (l->fill_layer != NULL) { // Fill layer - sys_notify_on_next_frame(&tab_layers_combo_object_192061, l); + sys_notify_on_next_frame(&tab_layers_combo_object_layer_clear, l); } else { layers_set_object_mask(); @@ -515,12 +513,6 @@ ui_handle_t *tab_layers_combo_object(slot_layer_t *l, bool label) { return object_handle; } -void tab_layers_combo_object_192061(slot_layer_t *l) { - context_raw->material = l->fill_layer; - slot_layer_clear(l, 0x00000000, NULL, 1.0, layers_default_rough, 0.0); - layers_update_fill_layers(); -} - ui_handle_t *tab_layers_combo_blending(slot_layer_t *l, bool label) { ui_handle_t *blending_handle = ui_nest(ui_handle(__ID__), l->id); blending_handle->i = l->blending; @@ -724,39 +716,22 @@ bool tab_layers_can_merge_down(slot_layer_t *l) { return true; } -void tab_layers_draw_layer_context_menu(slot_layer_t *l, bool mini) { - gc_unroot(tab_layers_l); - tab_layers_l = l; - gc_root(tab_layers_l); - tab_layers_mini = mini; - - ui_menu_draw(&tab_layers_draw_layer_context_menu_193275, -1, -1); -} - -void tab_layers_draw_layer_context_menu_194707(void * _) { +void tab_layers_draw_layer_context_menu_update_fill_layers(void * _) { layers_update_fill_layers(); } -void tab_layers_draw_layer_context_menu_194609(void * _) { - layers_update_fill_layers(); -} - -void tab_layers_draw_layer_context_menu_194526(void * _) { - layers_update_fill_layers(); -} - -void tab_layers_draw_layer_context_menu_194437(void * _) { +void tab_layers_draw_layer_context_menu_set_bits(void * _) { layers_set_bits(); } -void tab_layers_draw_layer_context_menu_194083(void * _) { +void tab_layers_draw_layer_context_menu_duplicate(void * _) { slot_layer_t *l = tab_layers_l; context_set_layer(l); history_duplicate_layer(); layers_duplicate_layer(l); } -void tab_layers_draw_layer_context_menu_194020(void * _) { +void tab_layers_draw_layer_context_menu_merge_down(void * _) { slot_layer_t *l = tab_layers_l; context_set_layer(l); history_merge_layers(); @@ -765,12 +740,12 @@ void tab_layers_draw_layer_context_menu_194020(void * _) { slot_layer_to_paint_layer(context_raw->layer); } -void tab_layers_draw_layer_context_menu_193973(void * _) { +void tab_layers_draw_layer_context_menu_merge_group(void * _) { slot_layer_t *l = tab_layers_l; layers_merge_group(l); } -void tab_layers_draw_layer_context_menu_193911(void * _) { +void tab_layers_draw_layer_context_menu_apply(void * _) { slot_layer_t *l = tab_layers_l; context_raw->layer = l; history_apply_mask(); @@ -780,14 +755,14 @@ void tab_layers_draw_layer_context_menu_193911(void * _) { context_raw->layers_preview_dirty = true; } -void tab_layers_draw_layer_context_menu_193857(void * _) { +void tab_layers_draw_layer_context_menu_invert(void * _) { slot_layer_t *l = tab_layers_l; context_set_layer(l); history_invert_mask(); slot_layer_invert_mask(l); } -void tab_layers_draw_layer_context_menu_193736(void * _) { +void tab_layers_draw_layer_context_menu_clear(void * _) { slot_layer_t *l = tab_layers_l; if (!slot_layer_is_group(l)) { history_clear_layer(); @@ -805,23 +780,23 @@ void tab_layers_draw_layer_context_menu_193736(void * _) { } } -void tab_layers_draw_layer_context_menu_193690(void * _) { +void tab_layers_draw_layer_context_menu_delete(void * _) { tab_layers_delete_layer(context_raw->layer); } -void tab_layers_draw_layer_context_menu_193629(void * _) { +void tab_layers_draw_layer_context_menu_to_paint_layer(void * _) { slot_layer_t *l = tab_layers_l; slot_layer_is_layer(l) ? history_to_paint_layer() : history_to_paint_mask(); slot_layer_to_paint_layer(l); } -void tab_layers_draw_layer_context_menu_193575(void * _) { +void tab_layers_draw_layer_context_menu_to_fill_layer(void * _) { slot_layer_t *l = tab_layers_l; slot_layer_is_layer(l) ? history_to_fill_layer() : history_to_fill_mask(); slot_layer_to_fill_layer(l); } -void tab_layers_draw_layer_context_menu_193420(char *path) { +void tab_layers_draw_layer_context_menu_export_on_file_picked(char *path) { slot_layer_t *l = tab_layers_l; char *f = ui_files_filename; if (string_equals(f, "")) { @@ -833,7 +808,7 @@ void tab_layers_draw_layer_context_menu_193420(char *path) { iron_write_png(string_join(string_join(path, PATH_SEP), f), gpu_get_texture_pixels(l->texpaint), l->texpaint->width, l->texpaint->height, 3); // RRR1 } -void tab_layers_draw_layer_context_menu_193275() { +void tab_layers_draw_layer_context_menu_draw() { slot_layer_t *l = tab_layers_l; bool mini = tab_layers_mini; @@ -860,7 +835,7 @@ void tab_layers_draw_layer_context_menu_193275() { if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { if (slot_layer_is_mask(l)) { - ui_files_show("png", true, false, &tab_layers_draw_layer_context_menu_193420); + ui_files_show("png", true, false, &tab_layers_draw_layer_context_menu_export_on_file_picked); } else { context_raw->layers_export = EXPORT_MODE_SELECTED; @@ -873,41 +848,41 @@ void tab_layers_draw_layer_context_menu_193275() { char *to_paint_string = slot_layer_is_layer(l) ? tr("To Paint Layer", NULL) : tr("To Paint Mask", NULL); if (l->fill_layer == NULL && ui_menu_button(to_fill_string, "", ICON_SPHERE)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_193575, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_to_fill_layer, NULL); } if (l->fill_layer != NULL && ui_menu_button(to_paint_string, "", ICON_PAINT)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_193629, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_to_paint_layer, NULL); } } ui->enabled = tab_layers_can_delete(l); if (ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_193690, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_delete, NULL); } ui->enabled = true; if (l->fill_layer == NULL && ui_menu_button(tr("Clear", NULL), "", ICON_ERASE)) { context_set_layer(l); - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_193736, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_clear, NULL); } if (slot_layer_is_mask(l) && l->fill_layer == NULL && ui_menu_button(tr("Invert", NULL), "", ICON_INVERT)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_193857, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_invert, NULL); } if (slot_layer_is_mask(l) && ui_menu_button(tr("Apply", NULL), "", ICON_CHECK)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_193911, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_apply, NULL); } if (slot_layer_is_group(l) && ui_menu_button(tr("Merge Group", NULL), "", ICON_NONE)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_193973, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_merge_group, NULL); } ui->enabled = tab_layers_can_merge_down(l); if (ui_menu_button(tr("Merge Down", NULL), "", ICON_ARROW_DOWN)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_194020, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_merge_down, NULL); } ui->enabled = true; if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_194083, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_duplicate, NULL); } ui_menu_align(); @@ -998,7 +973,7 @@ void tab_layers_draw_layer_context_menu_193275() { ui_inline_radio(base_bits_handle, bits_items, UI_ALIGN_LEFT); #endif if (base_bits_handle->changed) { - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_194437, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_set_bits, NULL); make_material_parse_paint_material(true); ui_menu_keep_open = true; } @@ -1011,7 +986,7 @@ void tab_layers_draw_layer_context_menu_193275() { if (scale_handle->changed) { context_set_material(l->fill_layer); context_set_layer(l); - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_194526, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_update_fill_layers, NULL); ui_menu_keep_open = true; } @@ -1023,7 +998,7 @@ void tab_layers_draw_layer_context_menu_193275() { context_set_material(l->fill_layer); context_set_layer(l); make_material_parse_paint_material(true); - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_194609, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_update_fill_layers, NULL); ui_menu_keep_open = true; } @@ -1042,7 +1017,7 @@ void tab_layers_draw_layer_context_menu_193275() { context_set_material(l->fill_layer); context_set_layer(l); make_material_parse_paint_material(true); - sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_194707, NULL); + sys_notify_on_next_frame(&tab_layers_draw_layer_context_menu_update_fill_layers, NULL); ui_menu_keep_open = true; } } @@ -1099,6 +1074,25 @@ void tab_layers_draw_layer_context_menu_193275() { } } +void tab_layers_draw_layer_context_menu(slot_layer_t *l, bool mini) { + gc_unroot(tab_layers_l); + tab_layers_l = l; + gc_root(tab_layers_l); + tab_layers_mini = mini; + + ui_menu_draw(&tab_layers_draw_layer_context_menu_draw, -1, -1); +} + +void tab_layers_make_mask_preview_rgba32_on_next_frame(void * _) { + slot_layer_t *l = tab_layers_l; + draw_begin(context_raw->mask_preview_rgba32, false, 0); + draw_set_pipeline(ui_view2d_pipe); + gpu_set_int(ui_view2d_channel_loc, 1); + draw_image(l->texpaint_preview, 0, 0); + draw_end(); + draw_set_pipeline(NULL); +} + void tab_layers_make_mask_preview_rgba32(slot_layer_t *l) { if (context_raw->mask_preview_rgba32 == NULL) { context_raw->mask_preview_rgba32 = gpu_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, GPU_TEXTURE_FORMAT_RGBA32); @@ -1109,20 +1103,10 @@ void tab_layers_make_mask_preview_rgba32(slot_layer_t *l) { gc_unroot(tab_layers_l); tab_layers_l = l; gc_root(tab_layers_l); - sys_notify_on_next_frame(&tab_layers_make_mask_preview_rgba32_195198, NULL); + sys_notify_on_next_frame(&tab_layers_make_mask_preview_rgba32_on_next_frame, NULL); } } -void tab_layers_make_mask_preview_rgba32_195198(void * _) { - slot_layer_t *l = tab_layers_l; - draw_begin(context_raw->mask_preview_rgba32, false, 0); - draw_set_pipeline(ui_view2d_pipe); - gpu_set_int(ui_view2d_channel_loc, 1); - draw_image(l->texpaint_preview, 0, 0); - draw_end(); - draw_set_pipeline(NULL); -} - void tab_layers_delete_layer(slot_layer_t *l) { i32_map_t *pointers = tab_layers_init_layer_map(); diff --git a/paint/sources/tab_materials.c b/paint/sources/tab_materials.c index 3a2e7919..c9871c70 100644 --- a/paint/sources/tab_materials.c +++ b/paint/sources/tab_materials.c @@ -53,6 +53,116 @@ void tab_materials_button_nodes() { } } +void tab_materials_draw_slots_duplicate(void * _) { + i32 i = _tab_materials_draw_slots; + context_raw->material = slot_material_create(project_materials->buffer[0]->data, NULL); + any_array_push(project_materials, context_raw->material); + ui_node_canvas_t *cloned = util_clone_canvas(project_materials->buffer[i]->canvas); + context_raw->material->canvas = cloned; + tab_materials_update_material(); + history_duplicate_material(); +} + +void tab_materials_draw_slots_menu() { + i32 i = _tab_materials_draw_slots; + slot_material_t *m = project_materials->buffer[i]; + + if (ui_menu_button(tr("To Fill Layer", NULL), "", ICON_SPHERE)) { + context_select_material(i); + layers_create_fill_layer(UV_TYPE_UVMAP, mat4nan, -1); + } + + if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { + context_select_material(i); + box_export_show_material(); + } + + if (ui_menu_button(tr("Bake", NULL), "", ICON_BAKE)) { + context_select_material(i); + box_export_show_bake_material(); + } + + if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { + sys_notify_on_next_frame(&tab_materials_draw_slots_duplicate, NULL); + } + + if (project_materials->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { + tab_materials_delete_material(m); + } + + ui_handle_t *base_handle = ui_nest(ui_handle(__ID__), m->id); + if (base_handle->init) { + base_handle->b = m->paint_base; + } + + ui_handle_t *opac_handle = ui_nest(ui_handle(__ID__), m->id); + if (opac_handle->init) { + opac_handle->b = m->paint_opac; + } + + ui_handle_t *nor_handle = ui_nest(ui_handle(__ID__), m->id); + if (nor_handle->init) { + nor_handle->b = m->paint_nor; + } + + ui_handle_t *occ_handle = ui_nest(ui_handle(__ID__), m->id); + if (occ_handle->init) { + occ_handle->b = m->paint_occ; + } + + ui_handle_t *rough_handle = ui_nest(ui_handle(__ID__), m->id); + if (rough_handle->init) { + rough_handle->b = m->paint_rough; + } + + ui_handle_t *met_handle = ui_nest(ui_handle(__ID__), m->id); + if (met_handle->init) { + met_handle->b = m->paint_met; + } + + ui_handle_t *height_handle = ui_nest(ui_handle(__ID__), m->id); + if (height_handle->init) { + height_handle->b = m->paint_height; + } + + ui_handle_t *emis_handle = ui_nest(ui_handle(__ID__), m->id); + if (emis_handle->init) { + emis_handle->b = m->paint_emis; + } + + ui_handle_t *subs_handle = ui_nest(ui_handle(__ID__), m->id); + if (subs_handle->init) { + subs_handle->b = m->paint_subs; + } + + ui_menu_separator(); + ui_menu_align(); + ui_menu_label(tr("Channels", NULL), NULL); + ui_menu_align(); + ui_row2(); + m->paint_base = ui_check(base_handle, tr("Base Color", NULL), ""); + m->paint_opac = ui_check(opac_handle, tr("Opacity", NULL), ""); + ui_row2(); + m->paint_nor = ui_check(nor_handle, tr("Normal", NULL), ""); + m->paint_height = ui_check(height_handle, tr("Height", NULL), ""); + ui_row2(); + m->paint_rough = ui_check(rough_handle, tr("Roughness", NULL), ""); + m->paint_met = ui_check(met_handle, tr("Metallic", NULL), ""); + ui_row2(); + m->paint_emis = ui_check(emis_handle, tr("Emission", NULL), ""); + m->paint_subs = ui_check(subs_handle, tr("Subsurface", NULL), ""); + m->paint_occ = ui_check(occ_handle, tr("Occlusion", NULL), ""); + if (base_handle->changed || opac_handle->changed || nor_handle->changed || occ_handle->changed || rough_handle->changed || met_handle->changed || + height_handle->changed || emis_handle->changed || subs_handle->changed) { + make_material_parse_paint_material(true); + ui_menu_keep_open = true; + } +} + +void tab_materials_draw_slots_update_fill_layers(void * _) { + layers_update_fill_layers(); +} + void tab_materials_draw_slots(bool mini) { i32 slotw = math_floor(51 * UI_SCALE() + config_raw->window_scale * 2); i32 num = math_floor(ui->_window_w / (float)slotw); @@ -130,7 +240,7 @@ void tab_materials_draw_slots(bool mini) { if (context_raw->material != project_materials->buffer[i]) { context_select_material(i); if (context_raw->tool == TOOL_TYPE_MATERIAL) { - sys_notify_on_next_frame(&tab_materials_draw_slots_119149, NULL); + sys_notify_on_next_frame(&tab_materials_draw_slots_update_fill_layers, NULL); } } base_drag_off_x = -(mouse_x - uix - ui->_window_x - 3); @@ -152,7 +262,7 @@ void tab_materials_draw_slots(bool mini) { if (ui->is_hovered && ui->input_released_r) { context_select_material(i); _tab_materials_draw_slots = i; - ui_menu_draw(&tab_materials_draw_slots_119244, -1, -1); + ui_menu_draw(&tab_materials_draw_slots_menu, -1, -1); } if (ui->is_hovered) { ui_tooltip_image(img_full, 0); @@ -203,129 +313,19 @@ void tab_materials_draw_slots(bool mini) { } } -void tab_materials_draw_slots_119357(void * _) { - i32 i = _tab_materials_draw_slots; - context_raw->material = slot_material_create(project_materials->buffer[0]->data, NULL); - any_array_push(project_materials, context_raw->material); - ui_node_canvas_t *cloned = util_clone_canvas(project_materials->buffer[i]->canvas); - context_raw->material->canvas = cloned; - tab_materials_update_material(); - history_duplicate_material(); -} - -void tab_materials_draw_slots_119244() { - i32 i = _tab_materials_draw_slots; - slot_material_t *m = project_materials->buffer[i]; - - if (ui_menu_button(tr("To Fill Layer", NULL), "", ICON_SPHERE)) { - context_select_material(i); - layers_create_fill_layer(UV_TYPE_UVMAP, mat4nan, -1); - } - - if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { - context_select_material(i); - box_export_show_material(); - } - - if (ui_menu_button(tr("Bake", NULL), "", ICON_BAKE)) { - context_select_material(i); - box_export_show_bake_material(); - } - - if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { - sys_notify_on_next_frame(&tab_materials_draw_slots_119357, NULL); - } - - if (project_materials->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { - tab_materials_delete_material(m); - } - - ui_handle_t *base_handle = ui_nest(ui_handle(__ID__), m->id); - if (base_handle->init) { - base_handle->b = m->paint_base; - } - - ui_handle_t *opac_handle = ui_nest(ui_handle(__ID__), m->id); - if (opac_handle->init) { - opac_handle->b = m->paint_opac; - } - - ui_handle_t *nor_handle = ui_nest(ui_handle(__ID__), m->id); - if (nor_handle->init) { - nor_handle->b = m->paint_nor; - } - - ui_handle_t *occ_handle = ui_nest(ui_handle(__ID__), m->id); - if (occ_handle->init) { - occ_handle->b = m->paint_occ; - } - - ui_handle_t *rough_handle = ui_nest(ui_handle(__ID__), m->id); - if (rough_handle->init) { - rough_handle->b = m->paint_rough; - } - - ui_handle_t *met_handle = ui_nest(ui_handle(__ID__), m->id); - if (met_handle->init) { - met_handle->b = m->paint_met; - } - - ui_handle_t *height_handle = ui_nest(ui_handle(__ID__), m->id); - if (height_handle->init) { - height_handle->b = m->paint_height; - } - - ui_handle_t *emis_handle = ui_nest(ui_handle(__ID__), m->id); - if (emis_handle->init) { - emis_handle->b = m->paint_emis; - } - - ui_handle_t *subs_handle = ui_nest(ui_handle(__ID__), m->id); - if (subs_handle->init) { - subs_handle->b = m->paint_subs; - } - - ui_menu_separator(); - ui_menu_align(); - ui_menu_label(tr("Channels", NULL), NULL); - ui_menu_align(); - ui_row2(); - m->paint_base = ui_check(base_handle, tr("Base Color", NULL), ""); - m->paint_opac = ui_check(opac_handle, tr("Opacity", NULL), ""); - ui_row2(); - m->paint_nor = ui_check(nor_handle, tr("Normal", NULL), ""); - m->paint_height = ui_check(height_handle, tr("Height", NULL), ""); - ui_row2(); - m->paint_rough = ui_check(rough_handle, tr("Roughness", NULL), ""); - m->paint_met = ui_check(met_handle, tr("Metallic", NULL), ""); - ui_row2(); - m->paint_emis = ui_check(emis_handle, tr("Emission", NULL), ""); - m->paint_subs = ui_check(subs_handle, tr("Subsurface", NULL), ""); - m->paint_occ = ui_check(occ_handle, tr("Occlusion", NULL), ""); - if (base_handle->changed || opac_handle->changed || nor_handle->changed || occ_handle->changed || rough_handle->changed || met_handle->changed || - height_handle->changed || emis_handle->changed || subs_handle->changed) { - make_material_parse_paint_material(true); - ui_menu_keep_open = true; - } -} - -void tab_materials_draw_slots_119149(void * _) { - layers_update_fill_layers(); -} - -void tab_materials_button_new(char *text) { - if (ui_icon_button(text, ICON_PLUS, UI_ALIGN_CENTER)) { - sys_notify_on_next_frame(&tab_materials_button_new_120110, NULL); - } -} - -void tab_materials_button_new_120110(void * _) { +void tab_materials_button_new_on_next_frame(void * _) { context_raw->material = slot_material_create(project_materials->buffer[0]->data, NULL); any_array_push(project_materials, context_raw->material); tab_materials_update_material(); history_new_material(); } +void tab_materials_button_new(char *text) { + if (ui_icon_button(text, ICON_PLUS, UI_ALIGN_CENTER)) { + sys_notify_on_next_frame(&tab_materials_button_new_on_next_frame, NULL); + } +} + void tab_materials_update_material() { ui_header_handle->redraws = 2; ui_nodes_hwnd->redraws = 2; diff --git a/paint/sources/tab_meshes.c b/paint/sources/tab_meshes.c index f958d95a..3fc0eddc 100644 --- a/paint/sources/tab_meshes.c +++ b/paint/sources/tab_meshes.c @@ -1,70 +1,7 @@ #include "global.h" -void tab_meshes_draw(ui_handle_t *htab) { - if (ui_tab(htab, tr("Meshes", NULL), false, -1, false) && ui->_window_h > ui_statusbar_default_h * UI_SCALE()) { - - ui_begin_sticky(); - f32_array_t *row = f32_array_create_from_raw( - (f32[]){ - -100, - -100, - }, - 2); - ui_row(row); - - if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { - ui_menu_draw(&tab_meshes_draw_185838, -1, -1); - } - if (ui->is_hovered) - ui_tooltip(tr("Import mesh file", NULL)); - - if (ui_icon_button(tr("Edit", NULL), ICON_EDIT, UI_ALIGN_CENTER)) { - ui_menu_draw(&tab_meshes_draw_185981, -1, -1); - } - - ui_end_sticky(); - - for (i32 i = 0; i < project_paint_objects->length; ++i) { - - f32_array_t *row = f32_array_create_from_raw( - (f32[]){ - -30, - 1.0, - }, - 2); - ui_row(row); - gpu_texture_t *icons = resource_get("icons05x.k"); - rect_t *rect = resource_tile50(icons, ICON_CUBE); - i32 icon_h = 25 * UI_SCALE(); - ui_sub_image(icons, ui->ops->theme->LABEL_COL - 0x00333333, icon_h, rect->x / (float)2, rect->y / (float)2, rect->w / (float)2, rect->h / (float)2); - - mesh_object_t *o = project_paint_objects->buffer[i]; - ui_handle_t *h = ui_handle(__ID__); - h->b = o->base->visible; - o->base->visible = ui_check(h, o->base->name, ""); - - if (ui->is_hovered && ui->input_released_r) { - _tab_meshes_draw_i = i; - - ui_menu_draw(&tab_meshes_draw_186425, -1, -1); - } - if (h->changed) { - mesh_object_t_array_t *visibles = any_array_create_from_raw((void *[]){}, 0); - for (i32 i = 0; i < project_paint_objects->length; ++i) { - mesh_object_t *p = project_paint_objects->buffer[i]; - if (p->base->visible) { - any_array_push(visibles, p); - } - } - util_mesh_merge(visibles); - context_raw->ddirty = 2; - } - } - } -} - -void tab_meshes_draw_186425() { +void tab_meshes_draw_context_menu() { i32 i = _tab_meshes_draw_i; mesh_object_t *o = project_paint_objects->buffer[i]; @@ -100,7 +37,7 @@ void tab_meshes_draw_186425() { } } -void tab_meshes_draw_185981() { +void tab_meshes_draw_edit() { if (ui_menu_button(tr("Flip Normals", NULL), "", ICON_NONE)) { util_mesh_flip_normals(); context_raw->ddirty = 2; @@ -160,7 +97,7 @@ void tab_meshes_draw_185981() { } } -void tab_meshes_draw_185904() { +void tab_meshes_draw_append_shape() { for (i32 i = 0; i < project_mesh_list->length; ++i) { if (ui_menu_button(project_mesh_list->buffer[i], "", ICON_NONE)) { tab_meshes_append_shape(project_mesh_list->buffer[i]); @@ -168,7 +105,7 @@ void tab_meshes_draw_185904() { } } -void tab_meshes_draw_185838() { +void tab_meshes_draw_import() { if (ui_menu_button(tr("Replace Existing", NULL), any_map_get(config_keymap, "file_import_assets"), ICON_NONE)) { project_import_mesh(true, NULL); } @@ -179,7 +116,70 @@ void tab_meshes_draw_185838() { if (config_raw->experimental) { project_fetch_default_meshes(); if (ui_menu_button(tr("Append Shape", NULL), "", ICON_NONE)) { - ui_menu_draw(&tab_meshes_draw_185904, -1, -1); + ui_menu_draw(&tab_meshes_draw_append_shape, -1, -1); + } + } +} + +void tab_meshes_draw(ui_handle_t *htab) { + if (ui_tab(htab, tr("Meshes", NULL), false, -1, false) && ui->_window_h > ui_statusbar_default_h * UI_SCALE()) { + + ui_begin_sticky(); + f32_array_t *row = f32_array_create_from_raw( + (f32[]){ + -100, + -100, + }, + 2); + ui_row(row); + + if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { + ui_menu_draw(&tab_meshes_draw_import, -1, -1); + } + if (ui->is_hovered) + ui_tooltip(tr("Import mesh file", NULL)); + + if (ui_icon_button(tr("Edit", NULL), ICON_EDIT, UI_ALIGN_CENTER)) { + ui_menu_draw(&tab_meshes_draw_edit, -1, -1); + } + + ui_end_sticky(); + + for (i32 i = 0; i < project_paint_objects->length; ++i) { + + f32_array_t *row = f32_array_create_from_raw( + (f32[]){ + -30, + 1.0, + }, + 2); + ui_row(row); + gpu_texture_t *icons = resource_get("icons05x.k"); + rect_t *rect = resource_tile50(icons, ICON_CUBE); + i32 icon_h = 25 * UI_SCALE(); + ui_sub_image(icons, ui->ops->theme->LABEL_COL - 0x00333333, icon_h, rect->x / (float)2, rect->y / (float)2, rect->w / (float)2, rect->h / (float)2); + + mesh_object_t *o = project_paint_objects->buffer[i]; + ui_handle_t *h = ui_handle(__ID__); + h->b = o->base->visible; + o->base->visible = ui_check(h, o->base->name, ""); + + if (ui->is_hovered && ui->input_released_r) { + _tab_meshes_draw_i = i; + + ui_menu_draw(&tab_meshes_draw_context_menu, -1, -1); + } + if (h->changed) { + mesh_object_t_array_t *visibles = any_array_create_from_raw((void *[]){}, 0); + for (i32 i = 0; i < project_paint_objects->length; ++i) { + mesh_object_t *p = project_paint_objects->buffer[i]; + if (p->base->visible) { + any_array_push(visibles, p); + } + } + util_mesh_merge(visibles); + context_raw->ddirty = 2; + } } } } @@ -432,17 +432,23 @@ void tab_scene_select_object(mesh_object_t *mo) { context_select_paint_object(mo); } -void tab_scene_sort() { - object_t *scene = _scene_root->children->buffer[0]; - array_sort(scene->children, &tab_scene_sort_187924); -} - -i32 tab_scene_sort_187924(void **pa, void **pb) { +i32 tab_scene_sort_compare(void **pa, void **pb) { object_t *a = *(pa); object_t *b = *(pb); return strcmp(a->name, b->name); } +void tab_scene_sort() { + object_t *scene = _scene_root->children->buffer[0]; + array_sort(scene->children, &tab_scene_sort_compare); +} + +void tab_scene_import_mesh_done_on_next_frame(void * _) { + util_mesh_merge(NULL); + tab_scene_select_object(context_raw->selected_object->ext); + tab_scene_sort(); +} + void tab_scene_import_mesh_done() { i32 count = project_paint_objects->length - _tab_scene_paint_object_length; _tab_scene_paint_object_length = project_paint_objects->length; @@ -453,13 +459,16 @@ void tab_scene_import_mesh_done() { tab_scene_select_object(mo); } - sys_notify_on_next_frame(&tab_scene_import_mesh_done_188032, NULL); + sys_notify_on_next_frame(&tab_scene_import_mesh_done_on_next_frame, NULL); } -void tab_scene_import_mesh_done_188032(void * _) { - util_mesh_merge(NULL); - tab_scene_select_object(context_raw->selected_object->ext); - tab_scene_sort(); +void tab_scene_draw_list_context_menu() { + if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { + sim_duplicate(); + } + if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { + sim_delete(); + } } void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object) { @@ -521,7 +530,7 @@ void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object) { if (ui->is_hovered && ui->input_released_r) { tab_scene_select_object(current_object->ext); - ui_menu_draw(&tab_scene_draw_list_188308, -1, -1); + ui_menu_draw(&tab_scene_draw_list_context_menu, -1, -1); } if (b) { @@ -540,15 +549,6 @@ void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object) { } } -void tab_scene_draw_list_188308() { - if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { - sim_duplicate(); - } - if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { - sim_delete(); - } -} - void tab_scene_draw(ui_handle_t *htab) { if (ui_tab(htab, tr("Scene", NULL), false, -1, false)) { diff --git a/paint/sources/tab_scripts.c b/paint/sources/tab_scripts.c index f3464fe1..ad710270 100644 --- a/paint/sources/tab_scripts.c +++ b/paint/sources/tab_scripts.c @@ -1,6 +1,37 @@ #include "global.h" +void tab_scripts_draw_export(char *path) { + char *str = tab_scripts_hscript->text; + char *f = ui_files_filename; + if (string_equals(f, "")) { + f = string_copy(tr("untitled", NULL)); + } + path = string_join(string_join(path, PATH_SEP), f); + if (!ends_with(path, ".js")) { + path = string_join(path, ".js"); + } + iron_file_save_bytes(path, sys_string_to_buffer(str), 0); +} + +void tab_scripts_draw_import(char *path) { + buffer_t *b = data_get_blob(path); + tab_scripts_hscript->text = string_copy(sys_buffer_to_string(b)); + data_delete_blob(path); +} + +void tab_scripts_draw_edit() { + if (ui_menu_button(tr("Clear", NULL), "", ICON_ERASE)) { + tab_scripts_hscript->text = ""; + } + if (ui_menu_button(tr("Import", NULL), "", ICON_IMPORT)) { + ui_files_show("js", false, false, &tab_scripts_draw_import); + } + if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { + ui_files_show("js", true, false, &tab_scripts_draw_export); + } +} + void tab_scripts_draw(ui_handle_t *htab) { if (ui_tab(htab, tr("Scripts", NULL), false, -1, false)) { @@ -19,7 +50,7 @@ void tab_scripts_draw(ui_handle_t *htab) { } if (ui_icon_button(tr("Edit", NULL), ICON_EDIT, UI_ALIGN_CENTER)) { - ui_menu_draw(&tab_scripts_draw_80816, -1, -1); + ui_menu_draw(&tab_scripts_draw_edit, -1, -1); } string_t_array_t *ar = any_array_create_from_raw( @@ -52,37 +83,6 @@ void tab_scripts_draw(ui_handle_t *htab) { } } -void tab_scripts_draw_80919(char *path) { - char *str = tab_scripts_hscript->text; - char *f = ui_files_filename; - if (string_equals(f, "")) { - f = string_copy(tr("untitled", NULL)); - } - path = string_join(string_join(path, PATH_SEP), f); - if (!ends_with(path, ".js")) { - path = string_join(path, ".js"); - } - iron_file_save_bytes(path, sys_string_to_buffer(str), 0); -} - -void tab_scripts_draw_80863(char *path) { - buffer_t *b = data_get_blob(path); - tab_scripts_hscript->text = string_copy(sys_buffer_to_string(b)); - data_delete_blob(path); -} - -void tab_scripts_draw_80816() { - if (ui_menu_button(tr("Clear", NULL), "", ICON_ERASE)) { - tab_scripts_hscript->text = ""; - } - if (ui_menu_button(tr("Import", NULL), "", ICON_IMPORT)) { - ui_files_show("js", false, false, &tab_scripts_draw_80863); - } - if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { - ui_files_show("js", true, false, &tab_scripts_draw_80919); - } -} - ui_text_coloring_t *tab_scripts_get_text_coloring() { if (tab_scripts_text_coloring == NULL) { buffer_t *blob = data_get_blob("text_coloring.json"); diff --git a/paint/sources/tab_swatches.c b/paint/sources/tab_swatches.c index 8112eb4c..9b8049f8 100644 --- a/paint/sources/tab_swatches.c +++ b/paint/sources/tab_swatches.c @@ -21,6 +21,89 @@ gpu_texture_t *tab_swatches_empty_get() { return _tab_swatches_empty; } +void tab_swatches_draw_16719() { + i32 i = _tab_swatches_draw_i; + + if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { + context_set_swatch(project_clone_swatch(context_raw->swatch)); + any_array_push(project_raw->swatches, context_raw->swatch); + } + #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) + else if (ui_menu_button(tr("Copy Hex Code", NULL), "", ICON_HASH)) { + i32 color = context_raw->swatch->base; + color = color_set_ab(color, context_raw->swatch->opacity * 255); + u32 val = color; + iron_copy_to_clipboard(i32_to_string(val)); + } + #endif + else if (project_raw->swatches->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { + tab_swatches_delete_swatch(project_raw->swatches->buffer[i]); + } + else if (ui_menu_button(tr("Create Material", NULL), "", ICON_SPHERE)) { + tab_materials_accept_swatch_drop(project_raw->swatches->buffer[i]); + } + else if (ui_menu_button(tr("Create Color Layer", NULL), "", ICON_LAYERS)) { + i32 color = project_raw->swatches->buffer[i]->base; + color = color_set_ab(color, project_raw->swatches->buffer[i]->opacity * 255); + layers_create_color_layer(color, project_raw->swatches->buffer[i]->occlusion, project_raw->swatches->buffer[i]->roughness, + project_raw->swatches->buffer[i]->metallic, -1); + } +} + +void tab_swatches_draw_color_picker_callback(swatch_color_t *color) { + i32 i = _tab_swatches_draw_i; + project_raw->swatches->buffer[i] = project_clone_swatch(color); +} + +void tab_swatches_draw_color_picker() { + context_raw->color_picker_previous_tool = context_raw->tool; + context_select_tool(TOOL_TYPE_PICKER); + context_raw->color_picker_callback = &tab_swatches_draw_color_picker_callback; +} + +void tab_swatches_draw_edit_menu() { + ui->changed = false; + ui_handle_t *h = ui_handle(__ID__); + h->color = context_raw->swatch->base; + + context_raw->swatch->base = ui_color_wheel(h, false, -1, 11 * ui->ops->theme->ELEMENT_H * UI_SCALE(), true, &tab_swatches_draw_color_picker, NULL); + + ui_handle_t *hopacity = ui_handle(__ID__); + hopacity->f = context_raw->swatch->opacity; + context_raw->swatch->opacity = ui_slider(hopacity, "Opacity", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *hocclusion = ui_handle(__ID__); + hocclusion->f = context_raw->swatch->occlusion; + context_raw->swatch->occlusion = ui_slider(hocclusion, "Occlusion", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *hroughness = ui_handle(__ID__); + hroughness->f = context_raw->swatch->roughness; + context_raw->swatch->roughness = ui_slider(hroughness, "Roughness", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *hmetallic = ui_handle(__ID__); + hmetallic->f = context_raw->swatch->metallic; + context_raw->swatch->metallic = ui_slider(hmetallic, "Metallic", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *hheight = ui_handle(__ID__); + hheight->f = context_raw->swatch->height; + context_raw->swatch->height = ui_slider(hheight, "Height", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); + + if (ui->changed || ui->is_typing) { + ui_menu_keep_open = true; + } + if (ui->input_released) { + context_set_swatch(context_raw->swatch); // Trigger material preview update + context_raw->picked_color = util_clone_swatch_color(context_raw->swatch); + ui_header_handle->redraws = 2; + } +} + +void tab_swatches_draw_import() { + if (ui_menu_button(tr("Replace Existing", NULL), "", ICON_NONE)) { + project_import_swatches(true); + context_set_swatch(project_raw->swatches->buffer[0]); + } + if (ui_menu_button(tr("Append", NULL), "", ICON_NONE)) { + project_import_swatches(false); + } +} + void tab_swatches_draw(ui_handle_t *htab) { if (ui_tab(htab, tr("Swatches", NULL), false, -1, false) && ui->_window_h > ui_statusbar_default_h * UI_SCALE()) { @@ -37,7 +120,7 @@ void tab_swatches_draw(ui_handle_t *htab) { ui_row(row); if (ui_icon_button(tr("New", NULL), ICON_PLUS, UI_ALIGN_CENTER)) { - context_set_swatch(make_swatch(0xffffffff)); + context_set_swatch(project_make_swatch(0xffffffff)); any_array_push(project_raw->swatches, context_raw->swatch); } if (ui->is_hovered) { @@ -45,7 +128,7 @@ void tab_swatches_draw(ui_handle_t *htab) { } if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { - ui_menu_draw(&tab_swatches_draw_15862, -1, -1); + ui_menu_draw(&tab_swatches_draw_import, -1, -1); } if (ui->is_hovered) { ui_tooltip(tr("Import swatches", NULL)); @@ -59,7 +142,7 @@ void tab_swatches_draw(ui_handle_t *htab) { } if (ui_icon_button(tr("Clear", NULL), ICON_ERASE, UI_ALIGN_CENTER)) { - context_set_swatch(make_swatch(0xffffffff)); + context_set_swatch(project_make_swatch(0xffffffff)); project_raw->swatches = any_array_create_from_raw( (void *[]){ context_raw->swatch, @@ -139,10 +222,8 @@ void tab_swatches_draw(ui_handle_t *htab) { } else if (state == UI_STATE_RELEASED) { if (sys_time() - context_raw->select_time < 0.2) { - _tab_swatches_draw_i = i; - - ui_menu_draw(&tab_swatches_draw_16422, -1, -1); + ui_menu_draw(&tab_swatches_draw_edit_menu, -1, -1); } context_raw->select_time = sys_time(); @@ -184,90 +265,6 @@ void tab_swatches_draw(ui_handle_t *htab) { } } -void tab_swatches_draw_16719() { - i32 i = _tab_swatches_draw_i; - - if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { - context_set_swatch(project_clone_swatch(context_raw->swatch)); - any_array_push(project_raw->swatches, context_raw->swatch); - } - #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) - else if (ui_menu_button(tr("Copy Hex Code", NULL), "", ICON_HASH)) { - i32 color = context_raw->swatch->base; - color = color_set_ab(color, context_raw->swatch->opacity * 255); - u32 val = color; - iron_copy_to_clipboard(i32_to_string(val)); - } - #endif - else if (project_raw->swatches->length > 1 && ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { - tab_swatches_delete_swatch(project_raw->swatches->buffer[i]); - } - else if (ui_menu_button(tr("Create Material", NULL), "", ICON_SPHERE)) { - tab_materials_accept_swatch_drop(project_raw->swatches->buffer[i]); - } - else if (ui_menu_button(tr("Create Color Layer", NULL), "", ICON_LAYERS)) { - i32 color = project_raw->swatches->buffer[i]->base; - color = color_set_ab(color, project_raw->swatches->buffer[i]->opacity * 255); - layers_create_color_layer(color, project_raw->swatches->buffer[i]->occlusion, project_raw->swatches->buffer[i]->roughness, - project_raw->swatches->buffer[i]->metallic, -1); - } -} - -void tab_swatches_draw_16479(swatch_color_t *color) { - i32 i = _tab_swatches_draw_i; - project_raw->swatches->buffer[i] = project_clone_swatch(color); -} - -void tab_swatches_draw_16464() { - context_raw->color_picker_previous_tool = context_raw->tool; - context_select_tool(TOOL_TYPE_PICKER); - context_raw->color_picker_callback = &tab_swatches_draw_16479; - ; -} - -void tab_swatches_draw_16422() { - ui->changed = false; - ui_handle_t *h = ui_handle(__ID__); - h->color = context_raw->swatch->base; - - context_raw->swatch->base = ui_color_wheel(h, false, -1, 11 * ui->ops->theme->ELEMENT_H * UI_SCALE(), true, &tab_swatches_draw_16464, NULL); - - ui_handle_t *hopacity = ui_handle(__ID__); - hopacity->f = context_raw->swatch->opacity; - context_raw->swatch->opacity = ui_slider(hopacity, "Opacity", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hocclusion = ui_handle(__ID__); - hocclusion->f = context_raw->swatch->occlusion; - context_raw->swatch->occlusion = ui_slider(hocclusion, "Occlusion", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hroughness = ui_handle(__ID__); - hroughness->f = context_raw->swatch->roughness; - context_raw->swatch->roughness = ui_slider(hroughness, "Roughness", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hmetallic = ui_handle(__ID__); - hmetallic->f = context_raw->swatch->metallic; - context_raw->swatch->metallic = ui_slider(hmetallic, "Metallic", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hheight = ui_handle(__ID__); - hheight->f = context_raw->swatch->height; - context_raw->swatch->height = ui_slider(hheight, "Height", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); - - if (ui->changed || ui->is_typing) { - ui_menu_keep_open = true; - } - if (ui->input_released) { - context_set_swatch(context_raw->swatch); // Trigger material preview update - context_raw->picked_color = util_clone_swatch_color(context_raw->swatch); - ui_header_handle->redraws = 2; - } -} - -void tab_swatches_draw_15862() { - if (ui_menu_button(tr("Replace Existing", NULL), "", ICON_NONE)) { - project_import_swatches(true); - context_set_swatch(project_raw->swatches->buffer[0]); - } - if (ui_menu_button(tr("Append", NULL), "", ICON_NONE)) { - project_import_swatches(false); - } -} - void tab_swatches_accept_swatch_drop(swatch_color_t *swatch) { // No valid position available if (tab_swatches_drag_pos == -1) { diff --git a/paint/sources/tab_textures.c b/paint/sources/tab_textures.c index 7c86fae9..fd445c59 100644 --- a/paint/sources/tab_textures.c +++ b/paint/sources/tab_textures.c @@ -1,6 +1,84 @@ #include "global.h" +void tab_textures_draw_set_as_envmap(void * _) { + import_envmap_run(_tab_textures_draw_asset->file, _tab_textures_draw_img); +} + +void tab_textures_draw_to_mask(void * _) { + layers_create_image_mask(_tab_textures_draw_asset); +} + +void tab_textures_draw_export_on_next_frame2(gpu_texture_t *target) { + char *path = _tab_textures_draw_path; + char *f = ui_files_filename; + if (string_equals(f, "")) { + f = string_copy(tr("untitled", NULL)); + } + if (!ends_with(f, ".png")) { + f = string_join(f, ".png"); + } + buffer_t *buf = gpu_get_texture_pixels(target); + iron_write_png(string_join(string_join(path, PATH_SEP), f), buf, target->width, target->height, 0); + gpu_delete_texture(target); +} + +void tab_textures_draw_export_on_next_frame(void * _) { + gpu_texture_t *img = _tab_textures_draw_img; + gpu_texture_t *target = gpu_create_render_target(img->width, img->height, GPU_TEXTURE_FORMAT_RGBA32); + draw_begin(target, false, 0); + draw_set_pipeline(pipes_copy); + draw_scaled_image(img, 0, 0, target->width, target->height); + draw_set_pipeline(NULL); + draw_end(); + sys_notify_on_next_frame(&tab_textures_draw_export_on_next_frame2, target); +} + +void tab_textures_draw_export(char *path) { + gc_unroot(_tab_textures_draw_path); + _tab_textures_draw_path = string_copy(path); + gc_root(_tab_textures_draw_path); + sys_notify_on_next_frame(&tab_textures_draw_export_on_next_frame, NULL); +} + +void tab_textures_draw_context_menu() { + if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { + ui_files_show("png", true, false, &tab_textures_draw_export); + } + if (ui_menu_button(tr("Reimport", NULL), "", ICON_SYNC)) { + project_reimport_texture(_tab_textures_draw_asset); + } + if (ui_menu_button(tr("To Mask", NULL), "", ICON_MASK)) { + sys_notify_on_next_frame(&tab_textures_draw_to_mask, NULL); + } + if (ui_menu_button(tr("Set as Envmap", NULL), "", ICON_LANDSCAPE)) { + sys_notify_on_next_frame(&tab_textures_draw_set_as_envmap, NULL); + } + if (ui_menu_button(tr("Set as Color ID Map", NULL), "", ICON_COLOR_ID)) { + context_raw->colorid_handle->i = _tab_textures_draw_i; + context_raw->colorid_picked = false; + ui_toolbar_handle->redraws = 1; + if (context_raw->tool == TOOL_TYPE_COLORID) { + ui_header_handle->redraws = 2; + context_raw->ddirty = 2; + } + } + if (ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { + tab_textures_delete_texture(_tab_textures_draw_asset); + } + if (!_tab_textures_draw_is_packed && ui_menu_button(tr("Open Containing Directory...", NULL), "", ICON_FOLDER_OPEN)) { + file_start(substring(_tab_textures_draw_asset->file, 0, string_last_index_of(_tab_textures_draw_asset->file, PATH_SEP))); + } + if (!_tab_textures_draw_is_packed && ui_menu_button(tr("Open in Browser", NULL), "", ICON_NONE)) { + tab_browser_show_directory(substring(_tab_textures_draw_asset->file, 0, string_last_index_of(_tab_textures_draw_asset->file, PATH_SEP))); + } +} + +void tab_textures_draw_import(char *path) { + import_asset_run(path, -1.0, -1.0, true, false, NULL); + ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 2; +} + void tab_textures_draw(ui_handle_t *htab) { if (ui_tab(htab, tr("Textures", NULL), false, -1, false) && ui->_window_h > ui_statusbar_default_h * UI_SCALE()) { @@ -16,7 +94,7 @@ void tab_textures_draw(ui_handle_t *htab) { ui_row(row); if (ui_icon_button(tr("Import", NULL), ICON_IMPORT, UI_ALIGN_CENTER)) { - ui_files_show(string_array_join(path_texture_formats(), ","), false, true, &tab_textures_draw_37950); + ui_files_show(string_array_join(path_texture_formats(), ","), false, true, &tab_textures_draw_import); } if (ui->is_hovered) { ui_tooltip(string_join(string_join(string_join(tr("Import texture file", NULL), " ("), any_map_get(config_keymap, "file_import_assets")), ")")); @@ -121,7 +199,7 @@ void tab_textures_draw(ui_handle_t *htab) { gc_root(_tab_textures_draw_asset); _tab_textures_draw_i = i; _tab_textures_draw_is_packed = is_packed; - ui_menu_draw(&tab_textures_draw_38621, -1, -1); + ui_menu_draw(&tab_textures_draw_context_menu, -1, -1); } if (config_raw->show_asset_names) { @@ -157,84 +235,6 @@ void tab_textures_draw(ui_handle_t *htab) { } } -void tab_textures_draw_38888(void * _) { - import_envmap_run(_tab_textures_draw_asset->file, _tab_textures_draw_img); -} - -void tab_textures_draw_38855(void * _) { - layers_create_image_mask(_tab_textures_draw_asset); -} - -void tab_textures_draw_38721(gpu_texture_t *target) { - char *path = _tab_textures_draw_path; - char *f = ui_files_filename; - if (string_equals(f, "")) { - f = string_copy(tr("untitled", NULL)); - } - if (!ends_with(f, ".png")) { - f = string_join(f, ".png"); - } - buffer_t *buf = gpu_get_texture_pixels(target); - iron_write_png(string_join(string_join(path, PATH_SEP), f), buf, target->width, target->height, 0); - gpu_delete_texture(target); -} - -void tab_textures_draw_38661(void * _) { - gpu_texture_t *img = _tab_textures_draw_img; - gpu_texture_t *target = gpu_create_render_target(img->width, img->height, GPU_TEXTURE_FORMAT_RGBA32); - draw_begin(target, false, 0); - draw_set_pipeline(pipes_copy); - draw_scaled_image(img, 0, 0, target->width, target->height); - draw_set_pipeline(NULL); - draw_end(); - sys_notify_on_next_frame(&tab_textures_draw_38721, target); -} - -void tab_textures_draw_38648(char *path) { - gc_unroot(_tab_textures_draw_path); - _tab_textures_draw_path = string_copy(path); - gc_root(_tab_textures_draw_path); - sys_notify_on_next_frame(&tab_textures_draw_38661, NULL); -} - -void tab_textures_draw_38621() { - if (ui_menu_button(tr("Export", NULL), "", ICON_EXPORT)) { - ui_files_show("png", true, false, &tab_textures_draw_38648); - } - if (ui_menu_button(tr("Reimport", NULL), "", ICON_SYNC)) { - project_reimport_texture(_tab_textures_draw_asset); - } - if (ui_menu_button(tr("To Mask", NULL), "", ICON_MASK)) { - sys_notify_on_next_frame(&tab_textures_draw_38855, NULL); - } - if (ui_menu_button(tr("Set as Envmap", NULL), "", ICON_LANDSCAPE)) { - sys_notify_on_next_frame(&tab_textures_draw_38888, NULL); - } - if (ui_menu_button(tr("Set as Color ID Map", NULL), "", ICON_COLOR_ID)) { - context_raw->colorid_handle->i = _tab_textures_draw_i; - context_raw->colorid_picked = false; - ui_toolbar_handle->redraws = 1; - if (context_raw->tool == TOOL_TYPE_COLORID) { - ui_header_handle->redraws = 2; - context_raw->ddirty = 2; - } - } - if (ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { - tab_textures_delete_texture(_tab_textures_draw_asset); - } - if (!_tab_textures_draw_is_packed && ui_menu_button(tr("Open Containing Directory...", NULL), "", ICON_FOLDER_OPEN)) { - file_start(substring(_tab_textures_draw_asset->file, 0, string_last_index_of(_tab_textures_draw_asset->file, PATH_SEP))); - } - if (!_tab_textures_draw_is_packed && ui_menu_button(tr("Open in Browser", NULL), "", ICON_NONE)) { - tab_browser_show_directory(substring(_tab_textures_draw_asset->file, 0, string_last_index_of(_tab_textures_draw_asset->file, PATH_SEP))); - } -} - -void tab_textures_draw_37950(char *path) { - import_asset_run(path, -1.0, -1.0, true, false, NULL); - ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 2; -} - void tab_textures_update_texture_pointers(ui_node_t_array_t *nodes, i32 index) { for (i32 i = 0; i < nodes->length; ++i) { ui_node_t *n = nodes->buffer[i]; @@ -249,6 +249,12 @@ void tab_textures_update_texture_pointers(ui_node_t_array_t *nodes, i32 index) { } } +void tab_textures_delete_texture_on_next_frame(void * _) { + make_material_parse_paint_material(true); + util_render_make_material_preview(); + ui_base_hwnds->buffer[TAB_AREA_SIDEBAR1]->redraws = 2; +} + void tab_textures_delete_texture(asset_t *asset) { i32 index = array_index_of(project_assets, asset); if (project_assets->length > 1) { @@ -281,7 +287,7 @@ void tab_textures_delete_texture(asset_t *asset) { imap_delete(project_asset_map, asset->id); array_splice(project_assets, index, 1); array_splice(project_asset_names, index, 1); - sys_notify_on_next_frame(&tab_textures_delete_texture_39524, NULL); + sys_notify_on_next_frame(&tab_textures_delete_texture_on_next_frame, NULL); for (i32 i = 0; i < project_materials->length; ++i) { slot_material_t *m = project_materials->buffer[i]; @@ -293,9 +299,3 @@ void tab_textures_delete_texture(asset_t *asset) { tab_textures_update_texture_pointers(b->canvas->nodes, index); } } - -void tab_textures_delete_texture_39524(void * _) { - make_material_parse_paint_material(true); - util_render_make_material_preview(); - ui_base_hwnds->buffer[TAB_AREA_SIDEBAR1]->redraws = 2; -} diff --git a/paint/sources/translator.c b/paint/sources/translator.c index b9b15e95..15d1e701 100644 --- a/paint/sources/translator.c +++ b/paint/sources/translator.c @@ -37,6 +37,21 @@ char *tr(char *id, any_map_t *vars) { return translation; } +void translator_load_translations_on_cjk_downloaded(char *url) { + if (!iron_file_exists(_translator_load_translations_cjk_font_disk_path)) { + // Fall back to English + config_raw->locale = "en"; + translator_extended_glyphs(); + gc_unroot(translator_translations); + translator_translations = any_map_create(); + gc_root(translator_translations); + translator_init_font(false, "font.ttf", 1.0); + } + else { + translator_init_font(true, _translator_load_translations_cjk_font_path, 1.4); + } +} + // (Re)loads translations for the specified locale void translator_load_translations(char *new_locale) { @@ -132,7 +147,7 @@ void translator_load_translations(char *new_locale) { if (!iron_file_exists(_translator_load_translations_cjk_font_disk_path)) { file_download_to("https://github.com/armory3d/armorbase/raw/main/Assets/common/extra/font_cjk.ttc", - _translator_load_translations_cjk_font_disk_path, &translator_load_translations_91848, 20332392); + _translator_load_translations_cjk_font_disk_path, &translator_load_translations_on_cjk_downloaded, 20332392); } else { translator_init_font(true, _translator_load_translations_cjk_font_path, 1.4); @@ -143,33 +158,7 @@ void translator_load_translations(char *new_locale) { } } -void translator_load_translations_91848(char *url) { - if (!iron_file_exists(_translator_load_translations_cjk_font_disk_path)) { - // Fall back to English - config_raw->locale = "en"; - translator_extended_glyphs(); - gc_unroot(translator_translations); - translator_translations = any_map_create(); - gc_root(translator_translations); - translator_init_font(false, "font.ttf", 1.0); - } - else { - translator_init_font(true, _translator_load_translations_cjk_font_path, 1.4); - } -} - -void translator_init_font(bool cjk, char *font_path, f32 font_scale) { - _translator_init_font_cjk = cjk; - gc_unroot(_translator_init_font_font_path); - _translator_init_font_font_path = string_copy(font_path); - gc_root(_translator_init_font_font_path); - _translator_init_font_font_scale = font_scale; - - // Load and assign font with cjk characters - sys_notify_on_next_frame(&translator_init_font_91962, NULL); -} - -void translator_init_font_91962(void * _) { +void translator_init_font_on_next_frame(void * _) { bool cjk = _translator_init_font_cjk; char *font_path = _translator_init_font_font_path; f32 font_scale = _translator_init_font_font_scale; @@ -193,6 +182,17 @@ void translator_init_font_91962(void * _) { ui_set_scale(UI_SCALE()); } +void translator_init_font(bool cjk, char *font_path, f32 font_scale) { + _translator_init_font_cjk = cjk; + gc_unroot(_translator_init_font_font_path); + _translator_init_font_font_path = string_copy(font_path); + gc_root(_translator_init_font_font_path); + _translator_init_font_font_scale = font_scale; + + // Load and assign font with cjk characters + sys_notify_on_next_frame(&translator_init_font_on_next_frame, NULL); +} + void translator_extended_glyphs() { // Basic Latin + Latin-1 Supplement + Latin Extended-A draw_font_init_glyphs(32, 383); diff --git a/paint/sources/ui_files.c b/paint/sources/ui_files.c index 11de6859..ac3504ae 100644 --- a/paint/sources/ui_files.c +++ b/paint/sources/ui_files.c @@ -60,6 +60,46 @@ draw_cloud_icon_data_t *make_draw_cloud_icon_data(char *f, gpu_texture_t *image) return data; } +void ui_files_file_browser_on_cache_cloud_done_on_next_frame(draw_cloud_icon_data_t *data) { + gpu_texture_t *icon = gpu_create_render_target(data->image->width, data->image->height, GPU_TEXTURE_FORMAT_RGBA32); + if (ends_with(data->f, ".arm")) { // Used for material sphere alpha cutout + draw_begin(icon, false, 0); + draw_image(project_materials->buffer[0]->image, 0, 0); + } + else { + draw_begin(icon, true, 0xffffffff); + } + draw_set_pipeline(pipes_copy_rgb); + draw_image(data->image, 0, 0); + draw_set_pipeline(NULL); + draw_end(); + any_map_set(ui_files_icon_map, string_join(string_join(_ui_files_file_browser_handle->text, PATH_SEP), data->f), icon); + ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 3; +} + +void ui_files_file_browser_on_cache_cloud_done(char *abs) { + if (abs != NULL) { + gpu_texture_t *image = data_get_image(abs); + if (image != NULL) { + #ifdef IRON_WINDOWS + abs = string_copy(string_replace_all(abs, "\\", "/")); + #endif + char *icon_file = substring(abs, string_last_index_of(abs, "/") + 1, string_length(abs)); + char *f = any_map_get(ui_files_icon_file_map, icon_file); + draw_cloud_icon_data_t *data = make_draw_cloud_icon_data(f, image); + sys_notify_on_next_frame(&ui_files_file_browser_on_cache_cloud_done_on_next_frame, data); + } + } + else { + ui_files_offline = true; + } +} + +void ui_files_file_browser_on_init_cloud_done() { + ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 3; + tab_browser_refresh = true; +} + char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, bool refresh, void (*context_menu)(char *)) { gpu_texture_t *icons = resource_get("icons.k"); @@ -70,7 +110,7 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, bool is_cloud = starts_with(handle->text, "cloud"); if (is_cloud && file_cloud == NULL) { - file_init_cloud(&ui_files_file_browser_44862, config_raw->server); + file_init_cloud(&ui_files_file_browser_on_init_cloud_done, config_raw->server); } if (is_cloud && file_read_directory("cloud")->length == 0) { return handle->text; @@ -210,7 +250,7 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, gc_root(_ui_files_file_browser_handle); any_map_set(ui_files_icon_file_map, icon_file, f); - file_cache_cloud(string_join(string_join(handle->text, PATH_SEP), icon_file), &ui_files_file_browser_45653, config_raw->server); + file_cache_cloud(string_join(string_join(handle->text, PATH_SEP), icon_file), &ui_files_file_browser_on_cache_cloud_done, config_raw->server); } } } @@ -421,46 +461,6 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, return handle->text; } -void ui_files_file_browser_45742(draw_cloud_icon_data_t *data) { - gpu_texture_t *icon = gpu_create_render_target(data->image->width, data->image->height, GPU_TEXTURE_FORMAT_RGBA32); - if (ends_with(data->f, ".arm")) { // Used for material sphere alpha cutout - draw_begin(icon, false, 0); - draw_image(project_materials->buffer[0]->image, 0, 0); - } - else { - draw_begin(icon, true, 0xffffffff); - } - draw_set_pipeline(pipes_copy_rgb); - draw_image(data->image, 0, 0); - draw_set_pipeline(NULL); - draw_end(); - any_map_set(ui_files_icon_map, string_join(string_join(_ui_files_file_browser_handle->text, PATH_SEP), data->f), icon); - ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 3; -} - -void ui_files_file_browser_45653(char *abs) { - if (abs != NULL) { - gpu_texture_t *image = data_get_image(abs); - if (image != NULL) { - #ifdef IRON_WINDOWS - abs = string_copy(string_replace_all(abs, "\\", "/")); - #endif - char *icon_file = substring(abs, string_last_index_of(abs, "/") + 1, string_length(abs)); - char *f = any_map_get(ui_files_icon_file_map, icon_file); - draw_cloud_icon_data_t *data = make_draw_cloud_icon_data(f, image); - sys_notify_on_next_frame(&ui_files_file_browser_45742, data); - } - } - else { - ui_files_offline = true; - } -} - -void ui_files_file_browser_44862() { - ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 3; - tab_browser_refresh = true; -} - void ui_files_make_icon(ui_files_make_icon_t *args) { i32 w = args->w; gpu_texture_t *image = args->image; diff --git a/paint/sources/ui_header.c b/paint/sources/ui_header.c index c3415e6f..337ed120 100644 --- a/paint/sources/ui_header.c +++ b/paint/sources/ui_header.c @@ -31,6 +31,65 @@ void ui_header_render_ui() { } } +void ui_header_draw_tool_properties_layer_preview_dirty(void * _) { + context_raw->layer_preview_dirty = true; +} + +void ui_header_draw_tool_properties_color_picker_normal() { + ui_fill(0, 0, ui->_w / (float)UI_SCALE(), ui->ops->theme->ELEMENT_H * 9, ui->ops->theme->SEPARATOR_COL); + ui->changed = false; + ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * ui->ops->theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); + if (ui->changed) { + context_raw->picked_color->normal = _ui_header_draw_tool_properties_h->color; + ui_header_handle->redraws = 2; + ui_menu_keep_open = true; + } +} + +void ui_header_draw_tool_properties_color_picker_base() { + ui_fill(0, 0, ui->_w / (float)UI_SCALE(), ui->ops->theme->ELEMENT_H * 9, ui->ops->theme->SEPARATOR_COL); + ui->changed = false; + ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * ui->ops->theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); + if (ui->changed) { + context_raw->picked_color->base = _ui_header_draw_tool_properties_h->color; + ui_header_handle->redraws = 2; + ui_menu_keep_open = true; + } +} + +void ui_header_draw_tool_properties_to_mask(slot_layer_t *m) { + _gpu_begin(m->texpaint, NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); + gpu_set_pipeline(pipes_colorid_to_mask); + render_target_t *rt = any_map_get(render_path_render_targets, "texpaint_colorid"); + gpu_set_texture(pipes_texpaint_colorid, rt->_image); + gpu_set_texture(pipes_tex_colorid, project_get_image(project_assets->buffer[context_raw->colorid_handle->i])); + gpu_set_vertex_buffer(const_data_screen_aligned_vb); + gpu_set_index_buffer(const_data_screen_aligned_ib); + gpu_draw(); + gpu_end(); + context_raw->colorid_picked = false; + ui_toolbar_handle->redraws = 1; + ui_header_handle->redraws = 1; + context_raw->layer_preview_dirty = true; + layers_update_fill_layers(); +} + +void ui_header_draw_tool_properties_import(char *path) { + import_asset_run(path, -1.0, -1.0, true, false, NULL); + context_raw->colorid_handle->i = project_asset_names->length - 1; + for (i32 i = 0; i < project_assets->length; ++i) { + asset_t *a = project_assets->buffer[i]; + // Already imported + if (string_equals(a->file, path)) { + context_raw->colorid_handle->i = array_index_of(project_assets, a); + } + } + context_raw->ddirty = 2; + context_raw->colorid_picked = false; + ui_toolbar_handle->redraws = 1; + ui_base_hwnds->buffer[2]->redraws = 2; +} + void ui_header_draw_tool_properties() { if (context_raw->tool == TOOL_TYPE_COLORID) { ui_text(tr("Picked Color", NULL), UI_ALIGN_LEFT, 0x00000000); @@ -58,7 +117,7 @@ void ui_header_draw_tool_properties() { } } if (ui_button(tr("Import", NULL), UI_ALIGN_CENTER, "")) { - ui_files_show(string_array_join(path_texture_formats(), ","), false, true, &ui_header_draw_tool_properties_128014); + ui_files_show(string_array_join(path_texture_formats(), ","), false, true, &ui_header_draw_tool_properties_import); } ui->enabled = context_raw->colorid_picked; if (ui_button(tr("To Mask", NULL), UI_ALIGN_CENTER, "")) { @@ -66,7 +125,7 @@ void ui_header_draw_tool_properties() { context_set_layer(context_raw->layer->parent); } slot_layer_t *m = layers_new_mask(false, context_raw->layer, -1); - sys_notify_on_next_frame(&ui_header_draw_tool_properties_128151, m); + sys_notify_on_next_frame(&ui_header_draw_tool_properties_to_mask, m); history_new_white_mask(); } ui->enabled = true; @@ -91,7 +150,7 @@ void ui_header_draw_tool_properties() { gc_unroot(_ui_header_draw_tool_properties_h); _ui_header_draw_tool_properties_h = h_color; gc_root(_ui_header_draw_tool_properties_h); - ui_menu_draw(&ui_header_draw_tool_properties_128370, -1, -1); + ui_menu_draw(&ui_header_draw_tool_properties_color_picker_base, -1, -1); } if (ui_button(tr("Add Swatch", NULL), UI_ALIGN_CENTER, "")) { swatch_color_t *new_swatch = project_clone_swatch(context_raw->picked_color); @@ -112,7 +171,7 @@ void ui_header_draw_tool_properties() { gc_unroot(_ui_header_draw_tool_properties_h); _ui_header_draw_tool_properties_h = h_normal; gc_root(_ui_header_draw_tool_properties_h); - ui_menu_draw(&ui_header_draw_tool_properties_128541, -1, -1); + ui_menu_draw(&ui_header_draw_tool_properties_color_picker_normal, -1, -1); } ui_text(tr("Normal", NULL), UI_ALIGN_LEFT, 0x00000000); ui->_w = _w; @@ -167,7 +226,7 @@ void ui_header_draw_tool_properties() { if (!baking && ui_button(tr("Bake", NULL), UI_ALIGN_CENTER, "")) { context_raw->pdirty = rt_bake ? context_raw->bake_samples : 1; context_raw->rdirty = 3; - sys_notify_on_next_frame(&ui_header_draw_tool_properties_128937, NULL); + sys_notify_on_next_frame(&ui_header_draw_tool_properties_layer_preview_dirty, NULL); ui_base_hwnds->buffer[0]->redraws = 2; history_push_undo = true; render_path_raytrace_bake_current_sample = 0; @@ -574,62 +633,3 @@ void ui_header_draw_tool_properties() { // sim_record = ui_check(h_record, tr("Record")); } } - -void ui_header_draw_tool_properties_128937(void * _) { - context_raw->layer_preview_dirty = true; -} - -void ui_header_draw_tool_properties_128541() { - ui_fill(0, 0, ui->_w / (float)UI_SCALE(), ui->ops->theme->ELEMENT_H * 9, ui->ops->theme->SEPARATOR_COL); - ui->changed = false; - ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * ui->ops->theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); - if (ui->changed) { - context_raw->picked_color->normal = _ui_header_draw_tool_properties_h->color; - ui_header_handle->redraws = 2; - ui_menu_keep_open = true; - } -} - -void ui_header_draw_tool_properties_128370() { - ui_fill(0, 0, ui->_w / (float)UI_SCALE(), ui->ops->theme->ELEMENT_H * 9, ui->ops->theme->SEPARATOR_COL); - ui->changed = false; - ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * ui->ops->theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); - if (ui->changed) { - context_raw->picked_color->base = _ui_header_draw_tool_properties_h->color; - ui_header_handle->redraws = 2; - ui_menu_keep_open = true; - } -} - -void ui_header_draw_tool_properties_128151(slot_layer_t *m) { - _gpu_begin(m->texpaint, NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); - gpu_set_pipeline(pipes_colorid_to_mask); - render_target_t *rt = any_map_get(render_path_render_targets, "texpaint_colorid"); - gpu_set_texture(pipes_texpaint_colorid, rt->_image); - gpu_set_texture(pipes_tex_colorid, project_get_image(project_assets->buffer[context_raw->colorid_handle->i])); - gpu_set_vertex_buffer(const_data_screen_aligned_vb); - gpu_set_index_buffer(const_data_screen_aligned_ib); - gpu_draw(); - gpu_end(); - context_raw->colorid_picked = false; - ui_toolbar_handle->redraws = 1; - ui_header_handle->redraws = 1; - context_raw->layer_preview_dirty = true; - layers_update_fill_layers(); -} - -void ui_header_draw_tool_properties_128014(char *path) { - import_asset_run(path, -1.0, -1.0, true, false, NULL); - context_raw->colorid_handle->i = project_asset_names->length - 1; - for (i32 i = 0; i < project_assets->length; ++i) { - asset_t *a = project_assets->buffer[i]; - // Already imported - if (string_equals(a->file, path)) { - context_raw->colorid_handle->i = array_index_of(project_assets, a); - } - } - context_raw->ddirty = 2; - context_raw->colorid_picked = false; - ui_toolbar_handle->redraws = 1; - ui_base_hwnds->buffer[2]->redraws = 2; -} diff --git a/paint/sources/ui_menubar.c b/paint/sources/ui_menubar.c index da46b219..f437b021 100644 --- a/paint/sources/ui_menubar.c +++ b/paint/sources/ui_menubar.c @@ -50,6 +50,15 @@ i32 ui_menu_panel_y() { return panel_y; } +void ui_menubar_render_ui_save_project_on_next_frame(void * _) { + project_save(false); + box_projects_show(); +} + +void ui_menubar_render_ui_save_project(void * _) { + sys_notify_on_end_frame(&ui_menubar_render_ui_save_project_on_next_frame, NULL); +} + void ui_menubar_render_ui() { if (config_raw->touch_ui && !base_view3d_show) { return; @@ -77,7 +86,7 @@ void ui_menubar_render_ui() { // Save project icon in lit mode context_set_viewport_mode(VIEWPORT_MODE_LIT); console_toast(tr("Saving project", NULL)); - sys_notify_on_next_frame(&ui_menubar_render_ui_87020, NULL); + sys_notify_on_next_frame(&ui_menubar_render_ui_save_project, NULL); } if (ui_menubar_icon_button(ICON_IMPORT)) { project_import_asset(NULL, true); @@ -170,15 +179,6 @@ void ui_menubar_render_ui() { } } -void ui_menubar_render_ui_87029(void * _) { - project_save(false); - box_projects_show(); -} - -void ui_menubar_render_ui_87020(void * _) { - sys_notify_on_end_frame(&ui_menubar_render_ui_87029, NULL); -} - void ui_menubar_draw_tab_header() { i32 item_w = ui_toolbar_w(false); i32 nodesw = (ui_nodes_show || ui_view2d_show) ? config_raw->layout->buffer[LAYOUT_SIZE_NODES_W] : 0; @@ -210,6 +210,73 @@ void ui_menubar_draw_tab_header() { } } +void ui_menubar_draw_category_items_about_box() { + gpu_texture_t *img = data_get_image("badge.k"); + ui_image(img, 0xffffffff, -1.0); + ui_end_element(); + + ui_handle_t *h = ui_handle(__ID__); + if (h->init) { + h->text = string_copy(_ui_menu_render_msg); + } + ui_text_area(h, UI_ALIGN_LEFT, false, "", false); + + ui_row3(); + + #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) + if (ui_icon_button(tr("Copy", NULL), ICON_COPY, UI_ALIGN_CENTER)) { + iron_copy_to_clipboard(_ui_menu_render_msg); + } + #else + ui_end_element(); + #endif + + if (ui_icon_button(tr("Contributors", NULL), ICON_LINK, UI_ALIGN_CENTER)) { + iron_load_url("https://github.com/armory3d/armortools/graphs/contributors"); + } + if (ui_icon_button(tr("OK", NULL), ICON_CHECK, UI_ALIGN_CENTER)) { + ui_box_hide(); + } +} + +void ui_menubar_draw_category_items_on_check_for_updates_downloaded(char *url, buffer_t *buffer) { + if (buffer != NULL) { + // Compare versions + update_info_t *update = json_parse(sys_buffer_to_string(buffer)); + i32 update_version = math_floor(update->version); + if (update_version > 0) { + char *date = config_get_date(); // 2019 -> 19 + date = string_copy(substring(date, 2, string_length(date))); + i32 date_int = parse_int(string_replace_all(date, "-", "")); + if (update_version > date_int) { + any_map_t *vars = any_map_create(); + any_map_set(vars, "url", manifest_url); + ui_box_show_message(tr("Update", NULL), tr("Update is available!\nPlease visit {url}.", vars), false); + } + else { + ui_box_show_message(tr("Update", NULL), tr("You are up to date!", NULL), false); + } + } + } + else { + any_map_t *vars = any_map_create(); + any_map_set(vars, "url", manifest_url); + ui_box_show_message(tr("Update", NULL), tr("Unable to check for updates.\nPlease visit {url}.", vars), false); + } +} + +void ui_menubar_draw_category_items_capture_screenshot(void * _) { + viewport_capture_screenshot(); +} + +void ui_menubar_draw_category_items_import_envmap(char *path) { + if (!ends_with(path, ".hdr")) { + console_error(tr("Error: .hdr file expected", NULL)); + return; + } + import_asset_run(path, -1.0, -1.0, true, true, NULL); +} + void ui_menubar_draw_category_items() { if (ui_menubar_category == MENUBAR_CATEGORY_FILE) { if (ui_menu_button(tr("New Project...", NULL), any_map_get(config_keymap, "file_new"), ICON_FILE_NEW)) { @@ -234,7 +301,7 @@ void ui_menubar_draw_category_items() { project_import_asset(string_array_join(path_texture_formats(), ","), false); } if (ui_menu_button(tr("Envmap...", NULL), "", ICON_LANDSCAPE)) { - ui_files_show("hdr", false, false, &ui_menubar_draw_category_items_87924); + ui_files_show("hdr", false, false, &ui_menubar_draw_category_items_import_envmap); } if (ui_menu_button(tr("Font...", NULL), "", ICON_FONT)) { project_import_asset("ttf,ttc,otf", true); @@ -423,7 +490,7 @@ void ui_menubar_draw_category_items() { } if (ui_menu_button(tr("Capture Screenshot", NULL), "", ICON_PHOTO)) { - sys_notify_on_next_frame(&ui_menubar_draw_category_items_89069, NULL); + sys_notify_on_next_frame(&ui_menubar_draw_category_items_capture_screenshot, NULL); ui->changed = false; // Close menu } @@ -706,7 +773,7 @@ void ui_menubar_draw_category_items() { iron_load_url(manifest_url_ios); #else // Retrieve latest version number - iron_file_download("https://check-for-updates.armory3d.workers.dev", &ui_menubar_draw_category_items_90507, 0, NULL); + iron_file_download("https://check-for-updates.armory3d.workers.dev", &ui_menubar_draw_category_items_on_check_for_updates_downloaded, 0, NULL); #endif } @@ -726,7 +793,7 @@ void ui_menubar_draw_category_items() { gc_unroot(_ui_menu_render_msg); _ui_menu_render_msg = string_copy(msg); gc_root(_ui_menu_render_msg); - ui_box_show_custom(&ui_menubar_draw_category_items_90774, 400, 320, NULL, true, tr("About", NULL)); + ui_box_show_custom(&ui_menubar_draw_category_items_about_box, 400, 320, NULL, true, tr("About", NULL)); } } else if (ui_menubar_category == MENUBAR_CATEGORY_WORKSPACE) { @@ -754,73 +821,6 @@ void ui_menubar_draw_category_items() { } } -void ui_menubar_draw_category_items_90774() { - gpu_texture_t *img = data_get_image("badge.k"); - ui_image(img, 0xffffffff, -1.0); - ui_end_element(); - - ui_handle_t *h = ui_handle(__ID__); - if (h->init) { - h->text = string_copy(_ui_menu_render_msg); - } - ui_text_area(h, UI_ALIGN_LEFT, false, "", false); - - ui_row3(); - - #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) - if (ui_icon_button(tr("Copy", NULL), ICON_COPY, UI_ALIGN_CENTER)) { - iron_copy_to_clipboard(_ui_menu_render_msg); - } - #else - ui_end_element(); - #endif - - if (ui_icon_button(tr("Contributors", NULL), ICON_LINK, UI_ALIGN_CENTER)) { - iron_load_url("https://github.com/armory3d/armortools/graphs/contributors"); - } - if (ui_icon_button(tr("OK", NULL), ICON_CHECK, UI_ALIGN_CENTER)) { - ui_box_hide(); - } -} - -void ui_menubar_draw_category_items_90507(char *url, buffer_t *buffer) { - if (buffer != NULL) { - // Compare versions - update_info_t *update = json_parse(sys_buffer_to_string(buffer)); - i32 update_version = math_floor(update->version); - if (update_version > 0) { - char *date = config_get_date(); // 2019 -> 19 - date = string_copy(substring(date, 2, string_length(date))); - i32 date_int = parse_int(string_replace_all(date, "-", "")); - if (update_version > date_int) { - any_map_t *vars = any_map_create(); - any_map_set(vars, "url", manifest_url); - ui_box_show_message(tr("Update", NULL), tr("Update is available!\nPlease visit {url}.", vars), false); - } - else { - ui_box_show_message(tr("Update", NULL), tr("You are up to date!", NULL), false); - } - } - } - else { - any_map_t *vars = any_map_create(); - any_map_set(vars, "url", manifest_url); - ui_box_show_message(tr("Update", NULL), tr("Unable to check for updates.\nPlease visit {url}.", vars), false); - } -} - -void ui_menubar_draw_category_items_89069(void * _) { - viewport_capture_screenshot(); -} - -void ui_menubar_draw_category_items_87924(char *path) { - if (!ends_with(path, ".hdr")) { - console_error(tr("Error: .hdr file expected", NULL)); - return; - } - import_asset_run(path, -1.0, -1.0, true, true, NULL); -} - void ui_menubar_show_menu(i32 category) { if (ui_menu_show && ui_menubar_category == category) { return; diff --git a/paint/sources/ui_nodes.c b/paint/sources/ui_nodes.c index 175f7052..6ade7bd5 100644 --- a/paint/sources/ui_nodes.c +++ b/paint/sources/ui_nodes.c @@ -41,6 +41,39 @@ void ui_viewnodes_on_node_changed(ui_node_t *n) { gc_root(ui_nodes_node_changed); } +void ui_viewnodes_on_link_drag_on_node_search_done() { + ui_nodes_t *ui_nodes = ui_nodes_get_nodes(); + + i32 node_selected_id = _ui_nodes_on_link_drag_node->id; + if (ui_nodes->nodes_selected_id->length > 0) { + node_selected_id = ui_nodes->nodes_selected_id->buffer[0]; + } + + ui_node_link_t *link_drag = _ui_nodes_on_link_drag_link_drag; + ui_node_t_array_t *nodes = ui_nodes_get_canvas(true)->nodes; + ui_node_t *n = ui_get_node(nodes, node_selected_id); + if (link_drag->to_id == -1 && n->inputs->length > 0) { + link_drag->to_id = n->id; + char *from_type = _ui_nodes_on_link_drag_node->outputs->buffer[link_drag->from_socket]->type; + // Connect to the first socket + link_drag->to_socket = 0; + // Try to find the first type-matching socket and use it if present + for (i32 i = 0; i < n->inputs->length; ++i) { + ui_node_socket_t *socket = n->inputs->buffer[i]; + if (string_equals(socket->type, from_type)) { + link_drag->to_socket = array_index_of(n->inputs, socket); + break; + } + } + any_array_push(ui_nodes_get_canvas(true)->links, link_drag); + } + else if (link_drag->from_id == -1 && n->outputs->length > 0) { + link_drag->from_id = n->id; + link_drag->from_socket = 0; + any_array_push(ui_nodes_get_canvas(true)->links, link_drag); + } +} + void ui_viewnodes_on_link_drag(i32 link_drag_id, bool is_new_link) { if (!is_new_link) { return; @@ -68,7 +101,7 @@ void ui_viewnodes_on_link_drag(i32 link_drag_id, bool is_new_link) { gc_unroot(_ui_nodes_on_link_drag_node); _ui_nodes_on_link_drag_node = node; gc_root(_ui_nodes_on_link_drag_node); - ui_nodes_node_search(-1, -1, &ui_viewnodes_on_link_drag_138508); + ui_nodes_node_search(-1, -1, &ui_viewnodes_on_link_drag_on_node_search_done); } // Selecting which node socket to preview else if (link_drag->from_id > -1) { @@ -79,69 +112,7 @@ void ui_viewnodes_on_link_drag(i32 link_drag_id, bool is_new_link) { } } -void ui_viewnodes_on_link_drag_138508() { - ui_nodes_t *ui_nodes = ui_nodes_get_nodes(); - - i32 node_selected_id = _ui_nodes_on_link_drag_node->id; - if (ui_nodes->nodes_selected_id->length > 0) { - node_selected_id = ui_nodes->nodes_selected_id->buffer[0]; - } - - ui_node_link_t *link_drag = _ui_nodes_on_link_drag_link_drag; - ui_node_t_array_t *nodes = ui_nodes_get_canvas(true)->nodes; - ui_node_t *n = ui_get_node(nodes, node_selected_id); - if (link_drag->to_id == -1 && n->inputs->length > 0) { - link_drag->to_id = n->id; - char *from_type = _ui_nodes_on_link_drag_node->outputs->buffer[link_drag->from_socket]->type; - // Connect to the first socket - link_drag->to_socket = 0; - // Try to find the first type-matching socket and use it if present - for (i32 i = 0; i < n->inputs->length; ++i) { - ui_node_socket_t *socket = n->inputs->buffer[i]; - if (string_equals(socket->type, from_type)) { - link_drag->to_socket = array_index_of(n->inputs, socket); - break; - } - } - any_array_push(ui_nodes_get_canvas(true)->links, link_drag); - } - else if (link_drag->from_id == -1 && n->outputs->length > 0) { - link_drag->from_id = n->id; - link_drag->from_socket = 0; - any_array_push(ui_nodes_get_canvas(true)->links, link_drag); - } -} - -void ui_viewnodes_on_socket_released(i32 socket_id) { - ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); - ui_node_socket_t *socket = ui_get_socket(canvas->nodes, socket_id); - ui_node_t *node = ui_get_node(canvas->nodes, socket->node_id); - if (ui->input_released_r) { - if (string_equals(node->type, "GROUP_INPUT") || string_equals(node->type, "GROUP_OUTPUT")) { - - gc_unroot(_ui_nodes_on_socket_released_socket); - _ui_nodes_on_socket_released_socket = socket; - gc_root(_ui_nodes_on_socket_released_socket); - gc_unroot(_ui_nodes_on_socket_released_node); - _ui_nodes_on_socket_released_node = node; - gc_root(_ui_nodes_on_socket_released_node); - sys_notify_on_next_frame(&ui_viewnodes_on_socket_released_138790, NULL); - } - else { - ui_viewnodes_on_canvas_released(); - } - } - // Selecting which node socket to preview - // else { - // let i: i32 = array_index_of(node.outputs, socket); - // if (i > -1) { - // i32_imap_set(context_raw.node_preview_socket_map, node.id, i); - // ui_nodes_node_changed = node; - // } - // } -} - -void ui_viewnodes_on_socket_released_138933() { +void ui_viewnodes_on_socket_released_group_edit_box() { ui_node_socket_t *socket = _ui_nodes_on_socket_released_socket; ui_node_t *node = _ui_nodes_on_socket_released_node; string_t_array_t *type_combo = any_array_create_from_raw( @@ -155,7 +126,7 @@ void ui_viewnodes_on_socket_released_138933() { if (_ui_nodes_htype->changed) { _ui_nodes_hname->text = type == 0 ? tr("Color", NULL) : type == 1 ? tr("Vector", NULL) : tr("Value", NULL); } - char *name = ui_text_input(_ui_nodes_hname, tr("Name", NULL), UI_ALIGN_LEFT, true, false); + char *name = ui_text_input(_ui_nodes_hname, tr("Name", NULL), UI_ALIGN_LEFT, true, false); f32 min = ui_float_input(_ui_nodes_hmin, tr("Min", NULL), UI_ALIGN_LEFT, 1000.0); f32 max = ui_float_input(_ui_nodes_hmax, tr("Max", NULL), UI_ALIGN_LEFT, 1000.0); f32_array_t *default_value = NULL; @@ -191,12 +162,12 @@ void ui_viewnodes_on_socket_released_138933() { } } -void ui_viewnodes_on_socket_released_138920(void * _) { +void ui_viewnodes_on_socket_released_group_edit(void *_) { ui_end_input(); - ui_box_show_custom(&ui_viewnodes_on_socket_released_138933, 400, 250, NULL, true, tr("Socket", NULL)); + ui_box_show_custom(&ui_viewnodes_on_socket_released_group_edit_box, 400, 250, NULL, true, tr("Socket", NULL)); } -void ui_viewnodes_on_socket_released_138799() { +void ui_viewnodes_on_socket_released_group_menu_draw() { ui_node_socket_t *socket = _ui_nodes_on_socket_released_socket; ui_node_t *node = _ui_nodes_on_socket_released_node; if (ui_menu_button(tr("Edit", NULL), "", ICON_EDIT)) { @@ -215,7 +186,7 @@ void ui_viewnodes_on_socket_released_138799() { else { _ui_nodes_hval0->f = socket->default_value->buffer[0]; } - sys_notify_on_next_frame(&ui_viewnodes_on_socket_released_138920, NULL); + sys_notify_on_next_frame(&ui_viewnodes_on_socket_released_group_edit, NULL); } if (ui_menu_button(tr("Delete", NULL), "", ICON_DELETE)) { i32 i = 0; @@ -238,8 +209,120 @@ void ui_viewnodes_on_socket_released_138799() { } } -void ui_viewnodes_on_socket_released_138790(void * _) { - ui_menu_draw(&ui_viewnodes_on_socket_released_138799, -1, -1); +void ui_viewnodes_on_socket_released_group_menu(void *_) { + ui_menu_draw(&ui_viewnodes_on_socket_released_group_menu_draw, -1, -1); +} + +void ui_viewnodes_on_socket_released(i32 socket_id) { + ui_node_canvas_t *canvas = ui_nodes_get_canvas(true); + ui_node_socket_t *socket = ui_get_socket(canvas->nodes, socket_id); + ui_node_t *node = ui_get_node(canvas->nodes, socket->node_id); + if (ui->input_released_r) { + if (string_equals(node->type, "GROUP_INPUT") || string_equals(node->type, "GROUP_OUTPUT")) { + + gc_unroot(_ui_nodes_on_socket_released_socket); + _ui_nodes_on_socket_released_socket = socket; + gc_root(_ui_nodes_on_socket_released_socket); + gc_unroot(_ui_nodes_on_socket_released_node); + _ui_nodes_on_socket_released_node = node; + gc_root(_ui_nodes_on_socket_released_node); + sys_notify_on_next_frame(&ui_viewnodes_on_socket_released_group_menu, NULL); + } + else { + ui_viewnodes_on_canvas_released(); + } + } + // Selecting which node socket to preview + // else { + // let i: i32 = array_index_of(node.outputs, socket); + // if (i > -1) { + // i32_imap_set(context_raw.node_preview_socket_map, node.id, i); + // ui_nodes_node_changed = node; + // } + // } +} + +void ui_viewnodes_on_canvas_capture_output(void *_) { + ui_nodes_capture_output(); +} + +void ui_viewnodes_on_canvas_released_duplicate(void *_) { + ui_nodes_hwnd->redraws = 2; + ui_is_copy = true; + ui_is_paste = true; + ui_nodes_is_node_menu_op = true; +} + +void ui_viewnodes_on_canvas_delete_on_next_frame(void *_) { + ui_nodes_hwnd->redraws = 2; + ui->is_delete_down = true; + ui_nodes_is_node_menu_op = true; +} + +void ui_viewnodes_on_canvas_delete(void *_) { + sys_notify_on_end_frame(&ui_viewnodes_on_canvas_delete_on_next_frame, NULL); +} + +void ui_viewnodes_on_canvas_paste(void *_) { + ui_nodes_hwnd->redraws = 2; + ui_is_paste = true; + ui_nodes_is_node_menu_op = true; +} + +void ui_viewnodes_on_canvas_copy(void *_) { + ui_is_copy = true; + ui_nodes_is_node_menu_op = true; +} + +void ui_viewnodes_on_canvas_cut(void *_) { + ui_nodes_hwnd->redraws = 2; + ui_is_copy = true; + ui_is_cut = true; + ui_nodes_is_node_menu_op = true; +} + +void ui_viewnodes_on_canvas_context_menu() { + ui_node_t *selected = _ui_nodes_on_canvas_released_selected; + ui->_y += 1; + bool is_protected = selected == NULL || string_equals(selected->type, "OUTPUT_MATERIAL_PBR") || string_equals(selected->type, "GROUP_INPUT") || + string_equals(selected->type, "GROUP_OUTPUT") || string_equals(selected->type, "brush_output_node"); + ui->enabled = !is_protected; + if (ui_menu_button(tr("Cut", NULL), "ctrl+x", ICON_CUT)) { + sys_notify_on_next_frame(&ui_viewnodes_on_canvas_cut, NULL); + } + if (ui_menu_button(tr("Copy", NULL), "ctrl+c", ICON_COPY)) { + sys_notify_on_next_frame(&ui_viewnodes_on_canvas_copy, NULL); + } + ui->enabled = !string_equals(ui_clipboard, ""); + if (ui_menu_button(tr("Paste", NULL), "ctrl+v", ICON_PASTE)) { + sys_notify_on_next_frame(&ui_viewnodes_on_canvas_paste, NULL); + } + ui->enabled = !is_protected; + if (ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { + sys_notify_on_next_frame(&ui_viewnodes_on_canvas_delete, NULL); + } + if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { + sys_notify_on_next_frame(&ui_viewnodes_on_canvas_released_duplicate, NULL); + } + if (selected != NULL && string_equals(selected->type, "RGB")) { + if (ui_menu_button(tr("Add Swatch", NULL), "", ICON_PALETTE)) { + f32_array_t *color = selected->outputs->buffer[0]->default_value; + swatch_color_t *new_swatch = project_make_swatch(color_from_floats(color->buffer[0], color->buffer[1], color->buffer[2], color->buffer[3])); + context_set_swatch(new_swatch); + any_array_push(project_raw->swatches, new_swatch); + ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 1; + } + } + if (ui_menu_button(tr("Capture Output", NULL), "", ICON_PHOTO)) { + sys_notify_on_next_frame(&ui_viewnodes_on_canvas_capture_output, NULL); + } + if (ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL) { + ui_menu_separator(); + if (ui_menu_button(tr("2D View", NULL), "", ICON_NONE)) { + ui_base_show_2d_view(VIEW_2D_TYPE_NODE); + } + } + ui->enabled = true; } void ui_viewnodes_on_canvas_released() { @@ -273,7 +356,7 @@ void ui_viewnodes_on_canvas_released() { gc_unroot(_ui_nodes_on_canvas_released_selected); _ui_nodes_on_canvas_released_selected = selected; gc_root(_ui_nodes_on_canvas_released_selected); - ui_menu_draw(&ui_viewnodes_on_canvas_released_139616, -1, -1); + ui_menu_draw(&ui_viewnodes_on_canvas_context_menu, -1, -1); } } @@ -295,89 +378,6 @@ void ui_viewnodes_on_canvas_released() { } } -void ui_viewnodes_on_canvas_released_139995(void * _) { - ui_nodes_capture_output(); -} - -void ui_viewnodes_on_canvas_released_139861(void * _) { - ui_nodes_hwnd->redraws = 2; - ui_is_copy = true; - ui_is_paste = true; - ui_nodes_is_node_menu_op = true; -} - -void ui_viewnodes_on_canvas_released_139818(void * _) { - ui_nodes_hwnd->redraws = 2; - ui->is_delete_down = true; - ui_nodes_is_node_menu_op = true; -} - -void ui_viewnodes_on_canvas_released_139809(void * _) { - sys_notify_on_end_frame(&ui_viewnodes_on_canvas_released_139818, NULL); -} - -void ui_viewnodes_on_canvas_released_139764(void * _) { - ui_nodes_hwnd->redraws = 2; - ui_is_paste = true; - ui_nodes_is_node_menu_op = true; -} - -void ui_viewnodes_on_canvas_released_139722(void * _) { - ui_is_copy = true; - ui_nodes_is_node_menu_op = true; -} - -void ui_viewnodes_on_canvas_released_139678(void * _) { - ui_nodes_hwnd->redraws = 2; - ui_is_copy = true; - ui_is_cut = true; - ui_nodes_is_node_menu_op = true; -} - -void ui_viewnodes_on_canvas_released_139616() { - ui_node_t *selected = _ui_nodes_on_canvas_released_selected; - ui->_y += 1; - bool is_protected = selected == NULL || string_equals(selected->type, "OUTPUT_MATERIAL_PBR") || string_equals(selected->type, "GROUP_INPUT") || - string_equals(selected->type, "GROUP_OUTPUT") || string_equals(selected->type, "brush_output_node"); - ui->enabled = !is_protected; - if (ui_menu_button(tr("Cut", NULL), "ctrl+x", ICON_CUT)) { - sys_notify_on_next_frame(&ui_viewnodes_on_canvas_released_139678, NULL); - } - if (ui_menu_button(tr("Copy", NULL), "ctrl+c", ICON_COPY)) { - sys_notify_on_next_frame(&ui_viewnodes_on_canvas_released_139722, NULL); - } - ui->enabled = !string_equals(ui_clipboard, ""); - if (ui_menu_button(tr("Paste", NULL), "ctrl+v", ICON_PASTE)) { - sys_notify_on_next_frame(&ui_viewnodes_on_canvas_released_139764, NULL); - } - ui->enabled = !is_protected; - if (ui_menu_button(tr("Delete", NULL), "delete", ICON_DELETE)) { - sys_notify_on_next_frame(&ui_viewnodes_on_canvas_released_139809, NULL); - } - if (ui_menu_button(tr("Duplicate", NULL), "", ICON_DUPLICATE)) { - sys_notify_on_next_frame(&ui_viewnodes_on_canvas_released_139861, NULL); - } - if (selected != NULL && string_equals(selected->type, "RGB")) { - if (ui_menu_button(tr("Add Swatch", NULL), "", ICON_PALETTE)) { - f32_array_t *color = selected->outputs->buffer[0]->default_value; - swatch_color_t *new_swatch = make_swatch(color_from_floats(color->buffer[0], color->buffer[1], color->buffer[2], color->buffer[3])); - context_set_swatch(new_swatch); - any_array_push(project_raw->swatches, new_swatch); - ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 1; - } - } - if (ui_menu_button(tr("Capture Output", NULL), "", ICON_PHOTO)) { - sys_notify_on_next_frame(&ui_viewnodes_on_canvas_released_139995, NULL); - } - if (ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL) { - ui_menu_separator(); - if (ui_menu_button(tr("2D View", NULL), "", ICON_NONE)) { - ui_base_show_2d_view(VIEW_2D_TYPE_NODE); - } - } - ui->enabled = true; -} - ui_canvas_control_t *ui_viewnodes_on_canvas_control() { ui_canvas_control_t *control = ui_nodes_get_canvas_control(ui_nodes_controls_down); ui_nodes_controls_down = control->controls_down; @@ -442,7 +442,7 @@ f32 ui_nodes_get_zoom_delta() { bool ui_nodes_is_tab_selected() { return ui_nodes_htab->i > 0 && ui_nodes_htab->i % 2 == 1 && // [tab0, tab1, x, tab2, x, +] - ui_nodes_tabs->length >= ui_nodes_htab->i / (float)2; + ui_nodes_tabs->length >= ui_nodes_htab->i / (float)2; } i32 ui_nodes_tab_index() { @@ -483,7 +483,7 @@ ui_nodes_t *ui_nodes_get_nodes() { } } -void ui_nodes_update(void * _) { +void ui_nodes_update(void *_) { if (!ui_nodes_show || !base_ui_enabled) { return; } @@ -575,18 +575,10 @@ void ui_nodes_canvas_changed() { ui_nodes_recompile_mat_final = true; } -void ui_nodes_node_search(i32 x, i32 y, void (*done)(void)) { - _ui_nodes_node_search_first = true; - gc_unroot(_ui_nodes_node_search_done); - _ui_nodes_node_search_done = done; - gc_root(_ui_nodes_node_search_done); - ui_menu_draw(&ui_nodes_node_search_141325, x, y); -} - -void ui_nodes_node_search_141325() { +void ui_nodes_node_search_menu() { ui_menu_h = UI_ELEMENT_H() * 8; ui_handle_t *search_handle = ui_handle(__ID__); - char *search = to_lower_case(ui_text_input(search_handle, "", UI_ALIGN_LEFT, true, true)); + char *search = to_lower_case(ui_text_input(search_handle, "", UI_ALIGN_LEFT, true, true)); ui->changed = false; if (_ui_nodes_node_search_first) { _ui_nodes_node_search_first = false; @@ -661,6 +653,14 @@ void ui_nodes_node_search_141325() { ui->ops->theme->FILL_BUTTON_BG = FILL_BUTTON_BG; } +void ui_nodes_node_search(i32 x, i32 y, void (*done)(void)) { + _ui_nodes_node_search_first = true; + gc_unroot(_ui_nodes_node_search_done); + _ui_nodes_node_search_done = done; + gc_root(_ui_nodes_node_search_done); + ui_menu_draw(&ui_nodes_node_search_menu, x, y); +} + i32 ui_nodes_get_node_x() { return math_floor((mouse_x - ui_nodes_wx - UI_NODES_PAN_X()) / (float)UI_NODES_SCALE()); } @@ -780,7 +780,16 @@ void ui_nodes_get_linked_nodes(ui_node_t_array_t *linked_nodes, ui_node_t *n, ui } } -void ui_nodes_render(void * _) { +void ui_nodes_render_color_picker_callback(swatch_color_t *color) { + _ui_nodes_render_tmp(color->base); + ui_nodes_hwnd->redraws = 2; + bool material_live = config_raw->material_live; + if (material_live) { + ui_nodes_canvas_changed(); + } +} + +void ui_nodes_render(void *_) { ui_nodes_recompile(); ui_nodes_t *ui_nodes = ui_nodes_get_nodes(); @@ -947,7 +956,7 @@ void ui_nodes_render(void * _) { gc_unroot(_ui_nodes_render_tmp); _ui_nodes_render_tmp = ui_nodes->color_picker_callback; gc_root(_ui_nodes_render_tmp); - context_raw->color_picker_callback = &ui_nodes_render_143289; + context_raw->color_picker_callback = &ui_nodes_render_color_picker_callback; ; ui_nodes->color_picker_callback = NULL; } @@ -1130,15 +1139,6 @@ void ui_nodes_render(void * _) { ui->input_enabled = true; } -void ui_nodes_render_143289(swatch_color_t *color) { - _ui_nodes_render_tmp(color->base); - ui_nodes_hwnd->redraws = 2; - bool material_live = config_raw->material_live; - if (material_live) { - ui_nodes_canvas_changed(); - } -} - gpu_texture_t *ui_nodes_get_node_preview_image(ui_node_t *n) { if (n == NULL) { return NULL; @@ -1166,7 +1166,7 @@ gpu_texture_t *ui_nodes_get_node_preview_image(ui_node_t *n) { i32 i = n->buttons->buffer[0]->default_value->buffer[0]; if (i <= 9000) { // 9999 - Texture deleted char *filepath = parser_material_enum_data(base_enum_texts(n->type)->buffer[i]); - i32 asset_index = -1; + i32 asset_index = -1; for (i32 i = 0; i < project_assets->length; ++i) { if (string_equals(project_assets->buffer[i]->file, filepath)) { asset_index = i; @@ -1187,6 +1187,10 @@ gpu_texture_t *ui_nodes_get_node_preview_image(ui_node_t *n) { return img; } +void ui_nodes_draw_menubar_search(void *_) { + ui_nodes_node_search(math_floor(ui_nodes_node_search_x), math_floor(ui_nodes_node_search_y), NULL); +} + void ui_nodes_draw_menubar() { ui_node_canvas_t *c = ui_nodes_get_canvas(true); i32 ew = math_floor(UI_ELEMENT_W() * 0.7); @@ -1201,9 +1205,9 @@ void ui_nodes_draw_menubar() { ui->_w = ew; // Editable canvas name - ui_handle_t *h = ui_handle(__ID__); - h->text = string_copy(c->name); - ui->_w = math_floor(math_min(draw_string_width(ui->ops->font, ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE())); + ui_handle_t *h = ui_handle(__ID__); + h->text = string_copy(c->name); + ui->_w = math_floor(math_min(draw_string_width(ui->ops->font, ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE())); char *new_name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false); ui->_x += ui->_w + 3; ui->_y = 2 + start_y; @@ -1218,7 +1222,7 @@ void ui_nodes_draw_menubar() { } } if (can_rename) { - char *old_name = c->name; + char *old_name = c->name; c->name = string_copy(new_name); ui_node_canvas_t_array_t *canvases = any_array_create_from_raw((void *[]){}, 0); for (i32 i = 0; i < project_materials->length; ++i) { @@ -1279,7 +1283,7 @@ void ui_nodes_draw_menubar() { ui_nodes_node_search_x = ui->_window_x + ui->_x; ui_nodes_node_search_y = ui->_window_y + ui->_y; // Allow for node menu to be closed first - sys_notify_on_next_frame(&ui_nodes_draw_menubar_145222, NULL); + sys_notify_on_next_frame(&ui_nodes_draw_menubar_search, NULL); } } if (ui->is_hovered) { @@ -1295,10 +1299,6 @@ void ui_nodes_draw_menubar() { } } -void ui_nodes_draw_menubar_145222(void * _) { - ui_nodes_node_search(math_floor(ui_nodes_node_search_x), math_floor(ui_nodes_node_search_y), NULL); -} - bool ui_nodes_contains_node_group_recursive(node_group_t *group, char *group_name) { if (string_equals(group->canvas->name, group_name)) { return true; @@ -1480,7 +1480,7 @@ ui_node_t *ui_nodes_make_group_node(ui_node_canvas_t *group_canvas, ui_nodes_t * ui_node_t *group_output = NULL; for (i32 i = 0; i < project_material_groups->length; ++i) { node_group_t *g = project_material_groups->buffer[i]; - char *cname = g->canvas->name; + char *cname = g->canvas->name; if (string_equals(cname, node->name)) { for (i32 i = 0; i < g->canvas->nodes->length; ++i) { ui_node_t *n = g->canvas->nodes->buffer[i]; @@ -1585,7 +1585,7 @@ void ui_nodes_capture_output() { project_raw->packed_assets = any_array_create_from_raw((void *[]){}, 0); } - i32 num = 0; + i32 num = 0; char *abs = "/packed/node_preview0.png"; for (i32 i = 0; i < project_raw->packed_assets->length; ++i) { packed_asset_t *pa = project_raw->packed_assets->buffer[i]; diff --git a/paint/sources/ui_toolbar.c b/paint/sources/ui_toolbar.c index 9e631a33..659bb163 100644 --- a/paint/sources/ui_toolbar.c +++ b/paint/sources/ui_toolbar.c @@ -3,6 +3,10 @@ void ui_toolbar_init() {} +void ui_toolbar_draw_tool_select_tool(void * _) { + context_select_tool(_ui_toolbar_i); +} + void ui_toolbar_draw_tool(i32 tool, gpu_texture_t *img, i32 icon_accent) { ui->_x += 2; if (context_raw->tool == tool) { @@ -24,7 +28,7 @@ void ui_toolbar_draw_tool(i32 tool, gpu_texture_t *img, i32 icon_accent) { ui_state_t image_state = ui_sub_image(img, icon_accent, -1.0, rect->x, rect->y, rect->w, rect->h); if (image_state == UI_STATE_STARTED && visible) { _ui_toolbar_i = tool; - sys_notify_on_next_frame(&ui_toolbar_draw_tool_66386, NULL); + sys_notify_on_next_frame(&ui_toolbar_draw_tool_select_tool, NULL); } else if (image_state == UI_STATE_RELEASED && context_is_floating_toolbar() && visible) { if (ui_toolbar_last_tool == tool) { @@ -54,10 +58,6 @@ void ui_toolbar_draw_tool(i32 tool, gpu_texture_t *img, i32 icon_accent) { ui->_y += 2; } -void ui_toolbar_draw_tool_66386(void * _) { - context_select_tool(_ui_toolbar_i); -} - i32 ui_toolbar_w(bool screen_size_request) { if (screen_size_request && context_is_floating_toolbar()) { return 0; @@ -213,22 +213,7 @@ void ui_toolbar_render_ui() { } } -void ui_toolbar_tool_properties_menu() { - i32 y = ui->_y - 2 * UI_SCALE(); - if (!base_view3d_show) { - y += ui_toolbar_w(false); - } - - #ifdef IRON_IOS - if (config_is_iphone() && base_view3d_show) { - y += ui_toolbar_w(false); - } - #endif - - ui_menu_draw(&ui_toolbar_tool_properties_menu_67427, ui->_x + ui->_w + 6 * UI_SCALE(), y); -} - -void ui_toolbar_tool_properties_menu_67427() { +void ui_toolbar_tool_properties_menu_draw() { ui->changed = false; ui_header_draw_tool_properties(); if (ui->changed || ui->is_typing) { @@ -242,6 +227,21 @@ void ui_toolbar_tool_properties_menu_67427() { } } +void ui_toolbar_tool_properties_menu() { + i32 y = ui->_y - 2 * UI_SCALE(); + if (!base_view3d_show) { + y += ui_toolbar_w(false); + } + + #ifdef IRON_IOS + if (config_is_iphone() && base_view3d_show) { + y += ui_toolbar_w(false); + } + #endif + + ui_menu_draw(&ui_toolbar_tool_properties_menu_draw, ui->_x + ui->_w + 6 * UI_SCALE(), y); +} + void ui_toolbar_draw_highlight() { i32 size = ui_toolbar_w(false) - 4; draw_set_color(ui->ops->theme->HIGHLIGHT_COL); diff --git a/paint/sources/ui_view2d.c b/paint/sources/ui_view2d.c index 5827f8a3..293f64f2 100644 --- a/paint/sources/ui_view2d.c +++ b/paint/sources/ui_view2d.c @@ -28,6 +28,33 @@ void ui_view2d_draw_image(gpu_texture_t *image, f32 dx, f32 dy, f32 dw, f32 dh, draw_scaled_image(image, dx, dy, dw, dh); } +void ui_view2d_render_color_pick(void * _) { + render_target_t *rt = any_map_get(render_path_render_targets, "texpaint_picker"); + gpu_texture_t *texpaint_picker = rt->_image; + draw_begin(texpaint_picker, false, 0); + draw_scaled_image(_ui_view2d_render_tex, -_ui_view2d_render_x, -_ui_view2d_render_y, _ui_view2d_render_tw, _ui_view2d_render_th); + draw_end(); + buffer_t *a = gpu_get_texture_pixels(texpaint_picker); + #ifdef IRON_BGRA + i32 i0 = 2; + i32 i1 = 1; + i32 i2 = 0; + #else + i32 i0 = 0; + i32 i1 = 1; + i32 i2 = 2; + #endif + + context_raw->picked_color->base = color_set_rb(context_raw->picked_color->base, buffer_get_u8(a, i0)); + context_raw->picked_color->base = color_set_gb(context_raw->picked_color->base, buffer_get_u8(a, i1)); + context_raw->picked_color->base = color_set_bb(context_raw->picked_color->base, buffer_get_u8(a, i2)); + ui_header_handle->redraws = 2; + + if (context_raw->color_picker_callback != NULL) { + context_raw->color_picker_callback(context_raw->picked_color); + } +} + void ui_view2d_render(void * _) { ui_view2d_ww = config_raw->layout->buffer[LAYOUT_SIZE_NODES_W]; ui_view2d_wx = math_floor(sys_w()) + ui_toolbar_w(true); @@ -216,7 +243,7 @@ void ui_view2d_render(void * _) { _ui_view2d_render_y = ui->input_y - ty - ui_view2d_wy; _ui_view2d_render_tw = tw; _ui_view2d_render_th = th; - sys_notify_on_next_frame(&ui_view2d_render_109006, NULL); + sys_notify_on_next_frame(&ui_view2d_render_color_pick, NULL); } } @@ -379,33 +406,6 @@ void ui_view2d_render(void * _) { ui_end(); } -void ui_view2d_render_109006(void * _) { - render_target_t *rt = any_map_get(render_path_render_targets, "texpaint_picker"); - gpu_texture_t *texpaint_picker = rt->_image; - draw_begin(texpaint_picker, false, 0); - draw_scaled_image(_ui_view2d_render_tex, -_ui_view2d_render_x, -_ui_view2d_render_y, _ui_view2d_render_tw, _ui_view2d_render_th); - draw_end(); - buffer_t *a = gpu_get_texture_pixels(texpaint_picker); - #ifdef IRON_BGRA - i32 i0 = 2; - i32 i1 = 1; - i32 i2 = 0; - #else - i32 i0 = 0; - i32 i1 = 1; - i32 i2 = 2; - #endif - - context_raw->picked_color->base = color_set_rb(context_raw->picked_color->base, buffer_get_u8(a, i0)); - context_raw->picked_color->base = color_set_gb(context_raw->picked_color->base, buffer_get_u8(a, i1)); - context_raw->picked_color->base = color_set_bb(context_raw->picked_color->base, buffer_get_u8(a, i2)); - ui_header_handle->redraws = 2; - - if (context_raw->color_picker_callback != NULL) { - context_raw->color_picker_callback(context_raw->picked_color); - } -} - void ui_view2d_update(void * _) { f32 headerh = UI_ELEMENT_H() * 1.4; diff --git a/paint/sources/uniforms_ext.c b/paint/sources/uniforms_ext.c index 95548520..deced19b 100644 --- a/paint/sources/uniforms_ext.c +++ b/paint/sources/uniforms_ext.c @@ -194,8 +194,8 @@ vec4_t uniforms_ext_vec3_link(object_t *object, material_data_t *mat, char *link f32 lastx = context_raw->prev_paint_vec_x; f32 lasty = context_raw->prev_paint_vec_y; if (context_raw->paint2d) { - x = vec2d(x); - lastx = vec2d(lastx); + x = uniforms_ext_vec2d(x); + lastx = uniforms_ext_vec2d(lastx); } f32 angle = math_atan2(-y + lasty, x - lastx) - math_pi() / (float)2; v = vec4_create(math_cos(angle), math_sin(angle), allow_paint ? 1 : 0, 1.0); @@ -239,7 +239,7 @@ vec4_t uniforms_ext_vec3_link(object_t *object, material_data_t *mat, char *link return v; } -f32 vec2d(f32 x) { +f32 uniforms_ext_vec2d(f32 x) { // Transform from 3d viewport coord to 2d view coord context_raw->paint2d_view = false; f32 res = (x * base_w() - base_w()) / (float)ui_view2d_ww; @@ -252,7 +252,7 @@ vec4_t uniforms_ext_vec4_link(object_t *object, material_data_t *mat, char *link bool down = mouse_down("left") || pen_down("tip"); vec4_t v = vec4_create(context_raw->paint_vec.x, context_raw->paint_vec.y, down ? 1.0 : 0.0, context_raw->paint2d ? 1.0 : 0.0); if (context_raw->paint2d) { - v.x = vec2d(v.x); + v.x = uniforms_ext_vec2d(v.x); } return v; @@ -261,7 +261,7 @@ vec4_t uniforms_ext_vec4_link(object_t *object, material_data_t *mat, char *link bool down = mouse_down("left") || pen_down("tip"); vec4_t v = vec4_create(context_raw->last_paint_vec_x, context_raw->last_paint_vec_y, down ? 1.0 : 0.0, context_raw->paint2d ? 1.0 : 0.0); if (context_raw->paint2d) { - v.x = vec2d(v.x); + v.x = uniforms_ext_vec2d(v.x); } return v; @@ -276,7 +276,7 @@ vec4_t uniforms_ext_vec4_link(object_t *object, material_data_t *mat, char *link else if (string_equals(link, "_stencil_transform")) { vec4_t v = vec4_create(context_raw->brush_stencil_x, context_raw->brush_stencil_y, context_raw->brush_stencil_scale, context_raw->brush_stencil_angle); if (context_raw->paint2d) { - v.x = vec2d(v.x); + v.x = uniforms_ext_vec2d(v.x); } return v; @@ -288,7 +288,7 @@ vec4_t uniforms_ext_vec4_link(object_t *object, material_data_t *mat, char *link val *= scale2d; // Projection ratio vec4_t v = vec4_create(context_raw->decal_x, context_raw->decal_y, decal_mask ? 1 : 0, val); if (context_raw->paint2d) { - v.x = vec2d(v.x); + v.x = uniforms_ext_vec2d(v.x); } return v; @@ -309,6 +309,18 @@ mat4_t uniforms_ext_mat4_link(object_t *object, material_data_t *mat, char *link return mat4_nan(); } +void uniforms_ext_cache_uv_island_map(void * _) { + util_uv_cache_uv_island_map(); +} + +void uniforms_ext_cache_triangle_map(void * _) { + util_uv_cache_triangle_map(); +} + +void uniforms_ext_cache_uv_map(void * _) { + util_uv_cache_uv_map(); +} + gpu_texture_t *uniforms_ext_tex_link(object_t *object, material_data_t *mat, char *link) { if (string_equals(link, "_texpaint_undo")) { i32 i = history_undo_i - 1 < 0 ? config_raw->undo_steps - 1 : history_undo_i - 1; @@ -354,18 +366,18 @@ gpu_texture_t *uniforms_ext_tex_link(object_t *object, material_data_t *mat, cha } else if (string_equals(link, "_texuvmap")) { if (!util_uv_uvmap_cached) { - sys_notify_on_next_frame(&uniforms_ext_tex_link_73441, NULL); + sys_notify_on_next_frame(&uniforms_ext_cache_uv_map, NULL); } return util_uv_uvmap; } else if (string_equals(link, "_textrianglemap")) { if (!util_uv_trianglemap_cached) { - sys_notify_on_next_frame(&uniforms_ext_tex_link_73476, NULL); + sys_notify_on_next_frame(&uniforms_ext_cache_triangle_map, NULL); } return util_uv_trianglemap; } else if (string_equals(link, "_texuvislandmap")) { - sys_notify_on_next_frame(&uniforms_ext_tex_link_73505, NULL); + sys_notify_on_next_frame(&uniforms_ext_cache_uv_island_map, NULL); if (util_uv_uvislandmap_cached) { return util_uv_uvislandmap; } @@ -438,15 +450,3 @@ gpu_texture_t *uniforms_ext_tex_link(object_t *object, material_data_t *mat, cha } return NULL; } - -void uniforms_ext_tex_link_73505(void * _) { - util_uv_cache_uv_island_map(); -} - -void uniforms_ext_tex_link_73476(void * _) { - util_uv_cache_triangle_map(); -} - -void uniforms_ext_tex_link_73441(void * _) { - util_uv_cache_uv_map(); -} diff --git a/paint/sources/util_mesh.c b/paint/sources/util_mesh.c index 30cda3b2..e178503d 100644 --- a/paint/sources/util_mesh.c +++ b/paint/sources/util_mesh.c @@ -171,6 +171,18 @@ void util_mesh_flip_normals() { render_path_raytrace_ready = false; } +i32 util_mesh_calc_normals_sort(i32 *pa, i32 *pb) { + i32 a = *(pa); + i32 b = *(pb); + i32 diff = util_mesh_va0->buffer[a * 4] - util_mesh_va0->buffer[b * 4]; + if (diff != 0) + return diff; + diff = util_mesh_va0->buffer[a * 4 + 1] - util_mesh_va0->buffer[b * 4 + 1]; + if (diff != 0) + return diff; + return util_mesh_va0->buffer[a * 4 + 2] - util_mesh_va0->buffer[b * 4 + 2]; +} + void util_mesh_calc_normals(bool smooth) { vec4_t va = vec4_create(0.0, 0.0, 0.0, 1.0); vec4_t vb = vec4_create(0.0, 0.0, 0.0, 1.0); @@ -197,7 +209,7 @@ void util_mesh_calc_normals(bool smooth) { gc_unroot(util_mesh_va0); util_mesh_va0 = va0; gc_root(util_mesh_va0); - i32_array_sort(indices, &util_mesh_calc_normals_123905); + i32_array_sort(indices, &util_mesh_calc_normals_sort); if (indices->length > 0) { i32 unique_id = indices->buffer[0]; vert_map->buffer[indices->buffer[0]] = unique_id; @@ -286,18 +298,6 @@ void util_mesh_calc_normals(bool smooth) { render_path_raytrace_ready = false; } -i32 util_mesh_calc_normals_123905(i32 *pa, i32 *pb) { - i32 a = *(pa); - i32 b = *(pb); - i32 diff = util_mesh_va0->buffer[a * 4] - util_mesh_va0->buffer[b * 4]; - if (diff != 0) - return diff; - diff = util_mesh_va0->buffer[a * 4 + 1] - util_mesh_va0->buffer[b * 4 + 1]; - if (diff != 0) - return diff; - return util_mesh_va0->buffer[a * 4 + 2] - util_mesh_va0->buffer[b * 4 + 2]; -} - void util_mesh_to_origin() { f32 dx = 0.0; f32 dy = 0.0; @@ -437,6 +437,18 @@ vec4_t util_mesh_calc_normal(vec4_t p0, vec4_t p1, vec4_t p2) { return cb; } +i32 util_mesh_decimate_sort(i32 *pa, i32 *pb) { + i32 a = *(pa); + i32 b = *(pb); + i32 diff = util_mesh_quantized->buffer[a * 3] - util_mesh_quantized->buffer[b * 3]; + if (diff != 0) + return diff; + diff = util_mesh_quantized->buffer[a * 3 + 1] - util_mesh_quantized->buffer[b * 3 + 1]; + if (diff != 0) + return diff; + return util_mesh_quantized->buffer[a * 3 + 2] - util_mesh_quantized->buffer[b * 3 + 2]; +} + void util_mesh_decimate(f32 strength) { mesh_object_t_array_t *objects = project_paint_objects; mesh_object_t *o = objects->buffer[0]; @@ -490,7 +502,7 @@ void util_mesh_decimate(f32 strength) { i32_array_push(indices, i); } - i32_array_sort(indices, &util_mesh_decimate_126650); + i32_array_sort(indices, &util_mesh_decimate_sort); i32_array_t *remap = i32_array_create(num_verts); i32 new_verts_count = 0; i32_array_t *unique_indices = i32_array_create_from_raw((i32[]){}, 0); @@ -568,18 +580,6 @@ void util_mesh_decimate(f32 strength) { plugin_uv_unwrap_button(); } -i32 util_mesh_decimate_126650(i32 *pa, i32 *pb) { - i32 a = *(pa); - i32 b = *(pb); - i32 diff = util_mesh_quantized->buffer[a * 3] - util_mesh_quantized->buffer[b * 3]; - if (diff != 0) - return diff; - diff = util_mesh_quantized->buffer[a * 3 + 1] - util_mesh_quantized->buffer[b * 3 + 1]; - if (diff != 0) - return diff; - return util_mesh_quantized->buffer[a * 3 + 2] - util_mesh_quantized->buffer[b * 3 + 2]; -} - i32 _util_mesh_unique_data_count() { return util_mesh_get_unique()->length; } diff --git a/paint/sources/util_render.c b/paint/sources/util_render.c index 55c275be..9c36cf1a 100644 --- a/paint/sources/util_render.c +++ b/paint/sources/util_render.c @@ -213,6 +213,10 @@ void util_render_make_font_preview() { draw_begin(current, false, 0); } +void util_render_make_brush_preview_parse_paint_material(void * _) { + make_material_parse_paint_material(false); +} + void util_render_make_brush_preview() { if (render_path_paint_live_layer_locked) { return; @@ -371,7 +375,7 @@ void util_render_make_brush_preview() { context_raw->layer = _layer; context_raw->material = _material; context_raw->tool = _tool; - sys_notify_on_next_frame(&util_render_make_brush_preview_117467, NULL); + sys_notify_on_next_frame(&util_render_make_brush_preview_parse_paint_material, NULL); // Restore paint mesh context_raw->material_preview = false; @@ -414,10 +418,6 @@ void util_render_make_brush_preview() { draw_begin(current, false, 0); } -void util_render_make_brush_preview_117467(void * _) { - make_material_parse_paint_material(false); -} - void util_render_make_node_preview(ui_node_canvas_t *canvas, ui_node_t *node, gpu_texture_t *image, ui_node_canvas_t *group, ui_node_t_array_t *parents) { parse_node_preview_result_t *res = make_material_parse_node_preview_material(node, group, parents); if (res == NULL || res->scon == NULL) {