diff options
-rw-r--r-- | main/main.cpp | 8 | ||||
-rw-r--r-- | scene/2d/camera_2d.cpp | 39 |
2 files changed, 38 insertions, 9 deletions
diff --git a/main/main.cpp b/main/main.cpp index 9c98e3780d..532e8708a6 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -919,14 +919,16 @@ Error Main::setup2() { MAIN_PRINT("Main: Image"); VisualServer::get_singleton()->set_boot_image(splash, boot_splash_bg_color,false); #endif - MAIN_PRINT("Main: DCC"); - VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3))); - MAIN_PRINT("Main: END"); } Image icon(app_icon_png); OS::get_singleton()->set_icon(icon); } + + MAIN_PRINT("Main: DCC"); + VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3))); + MAIN_PRINT("Main: END"); + GLOBAL_DEF("application/icon",String()); Globals::get_singleton()->set_custom_property_info("application/icon",PropertyInfo(Variant::STRING,"application/icon",PROPERTY_HINT_FILE,"*.png,*.webp")); diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index ea0fe2b0d6..68d8b09e04 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -37,8 +37,7 @@ void Camera2D::_update_scroll() { return; if (get_tree()->is_editor_hint()) { - // update(); //will just be drawn - //?? + update(); //will just be drawn return; } @@ -85,7 +84,7 @@ Matrix32 Camera2D::get_camera_transform() { if (anchor_mode==ANCHOR_MODE_DRAG_CENTER) { - if (h_drag_enabled) { + if (h_drag_enabled && !get_tree()->is_editor_hint()) { camera_pos.x = MIN( camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT])); camera_pos.x = MAX( camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * drag_margin[MARGIN_LEFT])); } else { @@ -97,7 +96,7 @@ Matrix32 Camera2D::get_camera_transform() { } } - if (v_drag_enabled) { + if (v_drag_enabled && !get_tree()->is_editor_hint()) { camera_pos.y = MIN( camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM])); camera_pos.y = MAX( camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * drag_margin[MARGIN_TOP])); @@ -118,7 +117,7 @@ Matrix32 Camera2D::get_camera_transform() { - if (smoothing_enabled) { + if (smoothing_enabled && !get_tree()->is_editor_hint()) { float c = smoothing*get_fixed_process_delta_time(); smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos; @@ -258,6 +257,34 @@ void Camera2D::_notification(int p_what) { viewport=NULL; } break; + case NOTIFICATION_DRAW: { + + if (!is_inside_tree() || !get_tree()->is_editor_hint()) + break; + + Color area_axis_color(0.5, 0.42, 0.87, 0.63); + float area_axis_width = 1; + if(current) + area_axis_width = 3; + + Matrix32 inv_camera_transform = get_camera_transform().affine_inverse(); + Size2 screen_size = get_viewport_rect().size; + + Vector2 screen_endpoints[4]= { + inv_camera_transform.xform(Vector2(0, 0)), + inv_camera_transform.xform(Vector2(screen_size.width,0)), + inv_camera_transform.xform(Vector2(screen_size.width, screen_size.height)), + inv_camera_transform.xform(Vector2(0, screen_size.height)) + }; + + Matrix32 inv_transform = get_transform().affine_inverse(); // undo global space + draw_set_transform(inv_transform.get_origin(), inv_transform.get_rotation(), inv_transform.get_scale()); + + for(int i=0;i<4;i++) { + draw_line(screen_endpoints[i], screen_endpoints[(i+1)%4], area_axis_color, area_axis_width); + } + + } break; } } @@ -383,7 +410,7 @@ void Camera2D::force_update_scroll() { void Camera2D::set_follow_smoothing(float p_speed) { smoothing=p_speed; - if (smoothing>0) + if (smoothing>0 && !(is_inside_tree() && get_tree()->is_editor_hint())) set_fixed_process(true); else set_fixed_process(false); |