From 304328ad1b216d59c879dbed8e2287d033562076 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 16 Mar 2026 20:03:41 +0100 Subject: [PATCH] paint: add player workspace --- paint/sources/base.c | 42 +++++++++++++++++++++++++++++++++----- paint/sources/compass.c | 2 +- paint/sources/enums.h | 1 + paint/sources/gizmo.c | 2 +- paint/sources/globals.h | 1 + paint/sources/operator.c | 2 +- paint/sources/ui_menubar.c | 1 + 7 files changed, 43 insertions(+), 8 deletions(-) diff --git a/paint/sources/base.c b/paint/sources/base.c index 9dd4fb74..3eca810b 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -29,6 +29,10 @@ void base_on_drop_files(char *drop_path) { any_array_push(base_drop_paths, drop_path); } +void base_init_on_start_arm(void *_) { + import_arm_run_project(project_filepath); +} + void base_init() { base_last_window_width = iron_window_width(); base_last_window_height = iron_window_height(); @@ -37,7 +41,6 @@ void base_init() { 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); - base_font = data_get_font("font.ttf"); gc_root(base_font); @@ -66,7 +69,6 @@ void base_init() { draw_font_init(base_font); } - ui_nodes_enum_texts = base_enum_texts; gc_root(ui_nodes_enum_texts); @@ -77,6 +79,7 @@ void base_init() { plugin_start(plugin); } } + args_parse(); camera_init(); ui_base_init(); @@ -115,6 +118,20 @@ void base_init() { if (config_raw->splash_screen && has_projects) { box_projects_show(); } + + // Startup project + char *start_arm = string("%s/start.arm", iron_internal_files_location()); + if (iron_file_exists(start_arm)) { + gc_unroot(project_filepath); + project_filepath = start_arm; + gc_root(project_filepath); + sys_notify_on_next_frame(&base_init_on_start_arm, NULL); + context_raw->tool = TOOL_TYPE_GIZMO; + make_material_parse_paint_material(true); + config_raw->workspace = WORKSPACE_PLAYER; + base_update_workspace(); + base_player_lock = true; + } } void base_save_and_quit_callback(bool save) { @@ -988,6 +1005,10 @@ void ui_base_update(void *_) { if (keyboard_started(any_map_get(config_keymap, "view_distract_free")) || (keyboard_started("escape") && !ui_base_show && !ui_box_show)) { ui_base_toggle_distract_free(); } + if (keyboard_started("f5") && config_raw->workspace != WORKSPACE_PLAYER) { + config_raw->workspace = WORKSPACE_PLAYER; + base_update_workspace(); + } #ifdef IRON_LINUX if (operator_shortcut("alt+enter", SHORTCUT_TYPE_STARTED)) { @@ -1420,7 +1441,15 @@ void ui_base_operator_search() { } void ui_base_toggle_distract_free() { + if (base_player_lock) { + return; + } + ui_base_show = !ui_base_show; + if (ui_base_show) { + config_raw->workspace = WORKSPACE_PAINT_3D; + base_update_workspace(); + } base_resize(); } @@ -1823,8 +1852,8 @@ void ui_base_render_cursor(void *_) { // Clone source cursor if (context_raw->tool == TOOL_TYPE_CLONE && !keyboard_down("alt") && (mouse_down("left") || pen_down("tip"))) { draw_set_color(0x66ffffff); - draw_scaled_image(cursor_img, mx + context_raw->clone_delta_x * sys_w() - psize / 2.0, - my + context_raw->clone_delta_y * sys_h() - psize / 2.0, psize, psize); + draw_scaled_image(cursor_img, mx + context_raw->clone_delta_x * sys_w() - psize / 2.0, my + context_raw->clone_delta_y * sys_h() - psize / 2.0, psize, + psize); draw_set_color(0xffffffff); } @@ -2146,10 +2175,13 @@ void base_update_workspace() { config_raw->layout->buffer[LAYOUT_SIZE_STATUS_H] = iron_window_height() * 0.3; config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = iron_window_width() * 0.52; - float h = UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 2; + float h = UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 2; config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_H0] = iron_window_height() - h; config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_H1] = h; } + else if (config_raw->workspace == WORKSPACE_PLAYER) { + ui_base_show = false; + } base_resize(); } diff --git a/paint/sources/compass.c b/paint/sources/compass.c index f27163c3..7a75c3dc 100644 --- a/paint/sources/compass.c +++ b/paint/sources/compass.c @@ -2,7 +2,7 @@ #include "global.h" void compass_render() { - if (!context_raw->show_compass) { + if (!context_raw->show_compass || config_raw->workspace == WORKSPACE_PLAYER) { return; } diff --git a/paint/sources/enums.h b/paint/sources/enums.h index dc9ac2d2..617e7e63 100644 --- a/paint/sources/enums.h +++ b/paint/sources/enums.h @@ -75,6 +75,7 @@ typedef enum { WORKSPACE_NODES = 2, WORKSPACE_SCRIPT = 3, WORKSPACE_SCULPT = 4, + WORKSPACE_PLAYER = 5, } workspace_t; typedef enum { diff --git a/paint/sources/gizmo.c b/paint/sources/gizmo.c index 1e0b97ab..b812e4c2 100644 --- a/paint/sources/gizmo.c +++ b/paint/sources/gizmo.c @@ -7,7 +7,7 @@ void gizmo_update() { object_t *gizmo = context_raw->gizmo; bool hide = operator_shortcut(any_map_get(config_keymap, "stencil_hide"), SHORTCUT_TYPE_DOWN); - gizmo->visible = (is_object || is_decal) && !hide; + gizmo->visible = (is_object || is_decal) && !hide && config_raw->workspace != WORKSPACE_PLAYER; if (!gizmo->visible) { return; } diff --git a/paint/sources/globals.h b/paint/sources/globals.h index bcf13b78..55517ab4 100644 --- a/paint/sources/globals.h +++ b/paint/sources/globals.h @@ -163,6 +163,7 @@ i32 base_last_window_width = 0; i32 base_last_window_height = 0; slot_material_t *base_drag_material = NULL; slot_layer_t *base_drag_layer = NULL; +bool base_player_lock = false; i32 _base_material_count; ui_t *ui; bool ui_base_show = true; diff --git a/paint/sources/operator.c b/paint/sources/operator.c index 05e93623..cb51ffea 100644 --- a/paint/sources/operator.c +++ b/paint/sources/operator.c @@ -25,7 +25,7 @@ void operator_update() { } bool operator_shortcut(char *s, shortcut_type_t type) { - if (string_equals(s, "")) { + if (string_equals(s, "") || base_player_lock) { return false; } bool shift = string_index_of(s, "shift") >= 0; diff --git a/paint/sources/ui_menubar.c b/paint/sources/ui_menubar.c index 10d075fb..fd2e5bfd 100644 --- a/paint/sources/ui_menubar.c +++ b/paint/sources/ui_menubar.c @@ -864,6 +864,7 @@ void ui_menubar_draw_category_items() { if (config_raw->experimental) { any_array_push(modes, tr("Sculpt")); + any_array_push(modes, tr("Player")); } for (i32 i = 0; i < modes->length; ++i) {