summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp35
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.h4
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp45
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.h4
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp67
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.h4
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp50
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h6
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp80
-rw-r--r--editor/plugins/animation_player_editor_plugin.h7
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp67
-rw-r--r--editor/plugins/animation_state_machine_editor.h4
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp18
-rw-r--r--editor/plugins/animation_tree_editor_plugin.h4
-rw-r--r--editor/plugins/animation_tree_player_editor_plugin.cpp1449
-rw-r--r--editor/plugins/animation_tree_player_editor_plugin.h184
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp163
-rw-r--r--editor/plugins/asset_library_editor_plugin.h27
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp22
-rw-r--r--editor/plugins/audio_stream_editor_plugin.h4
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.cpp6
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.h6
-rw-r--r--editor/plugins/camera_editor_plugin.cpp6
-rw-r--r--editor/plugins/camera_editor_plugin.h4
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp556
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h22
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.h4
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp47
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.h8
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp14
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h4
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp32
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.h4
-rw-r--r--editor/plugins/cpu_particles_editor_plugin.cpp17
-rw-r--r--editor/plugins/cpu_particles_editor_plugin.h5
-rw-r--r--editor/plugins/curve_editor_plugin.cpp61
-rw-r--r--editor/plugins/curve_editor_plugin.h7
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp51
-rw-r--r--editor/plugins/debugger_editor_plugin.h50
-rw-r--r--editor/plugins/editor_preview_plugins.cpp144
-rw-r--r--editor/plugins/editor_preview_plugins.h26
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp79
-rw-r--r--editor/plugins/gi_probe_editor_plugin.h10
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp9
-rw-r--r--editor/plugins/gradient_editor_plugin.h4
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp17
-rw-r--r--editor/plugins/item_list_editor_plugin.h20
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.h4
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/line_2d_editor_plugin.h4
-rw-r--r--editor/plugins/material_editor_plugin.cpp34
-rw-r--r--editor/plugins/material_editor_plugin.h10
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp10
-rw-r--r--editor/plugins/mesh_editor_plugin.h5
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.cpp95
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.h8
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp18
-rw-r--r--editor/plugins/mesh_library_editor_plugin.h4
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp26
-rw-r--r--editor/plugins/multimesh_editor_plugin.h4
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp4
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h4
-rw-r--r--editor/plugins/particles_2d_editor_plugin.cpp44
-rw-r--r--editor/plugins/particles_2d_editor_plugin.h4
-rw-r--r--editor/plugins/particles_editor_plugin.cpp74
-rw-r--r--editor/plugins/particles_editor_plugin.h10
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp41
-rw-r--r--editor/plugins/path_2d_editor_plugin.h4
-rw-r--r--editor/plugins/path_editor_plugin.cpp30
-rw-r--r--editor/plugins/path_editor_plugin.h4
-rw-r--r--editor/plugins/physical_bone_plugin.cpp6
-rw-r--r--editor/plugins/physical_bone_plugin.h4
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp131
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h14
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp17
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.h4
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp18
-rw-r--r--editor/plugins/root_motion_editor_plugin.h4
-rw-r--r--editor/plugins/script_editor_plugin.cpp372
-rw-r--r--editor/plugins/script_editor_plugin.h30
-rw-r--r--editor/plugins/script_text_editor.cpp158
-rw-r--r--editor/plugins/script_text_editor.h10
-rw-r--r--editor/plugins/shader_editor_plugin.cpp37
-rw-r--r--editor/plugins/shader_editor_plugin.h4
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.cpp6
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.h4
-rw-r--r--editor/plugins/skeleton_editor_plugin.cpp20
-rw-r--r--editor/plugins/skeleton_editor_plugin.h4
-rw-r--r--editor/plugins/skeleton_ik_editor_plugin.cpp17
-rw-r--r--editor/plugins/skeleton_ik_editor_plugin.h5
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp509
-rw-r--r--editor/plugins/spatial_editor_plugin.h46
-rw-r--r--editor/plugins/sprite_editor_plugin.cpp106
-rw-r--r--editor/plugins/sprite_editor_plugin.h4
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp94
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h6
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp22
-rw-r--r--editor/plugins/style_box_editor_plugin.h4
-rw-r--r--editor/plugins/text_editor.cpp39
-rw-r--r--editor/plugins/text_editor.h9
-rw-r--r--editor/plugins/texture_editor_plugin.cpp13
-rw-r--r--editor/plugins/texture_editor_plugin.h10
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp138
-rw-r--r--editor/plugins/texture_region_editor_plugin.h4
-rw-r--r--editor/plugins/theme_editor_plugin.cpp34
-rw-r--r--editor/plugins/theme_editor_plugin.h4
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp144
-rw-r--r--editor/plugins/tile_map_editor_plugin.h14
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp286
-rw-r--r--editor/plugins/tile_set_editor_plugin.h20
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp36
-rw-r--r--editor/plugins/version_control_editor_plugin.h6
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp596
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h21
116 files changed, 2941 insertions, 3999 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 7f023af848..6f29b6c76a 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
AbstractPolygon2DEditor::Vertex::Vertex() :
polygon(-1),
@@ -149,7 +150,7 @@ void AbstractPolygon2DEditor::_action_add_polygon(const Variant &p_polygon) {
void AbstractPolygon2DEditor::_action_remove_polygon(int p_idx) {
- _action_set_polygon(p_idx, _get_polygon(p_idx), PoolVector<Vector2>());
+ _action_set_polygon(p_idx, _get_polygon(p_idx), Vector<Vector2>());
}
void AbstractPolygon2DEditor::_action_set_polygon(int p_idx, const Variant &p_polygon) {
@@ -208,8 +209,8 @@ void AbstractPolygon2DEditor::_notification(int p_what) {
button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
button_edit->set_pressed(true);
- get_tree()->connect("node_removed", this, "_node_removed");
- create_resource->connect("confirmed", this, "_create_resource");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
+ create_resource->connect_compat("confirmed", this, "_create_resource");
} break;
}
}
@@ -255,7 +256,7 @@ void AbstractPolygon2DEditor::_wip_close() {
undo_redo->create_action(TTR("Create Polygon"));
_action_add_polygon(wip);
if (_has_uv()) {
- undo_redo->add_do_method(_get_node(), "set_uv", PoolVector<Vector2>());
+ undo_redo->add_do_method(_get_node(), "set_uv", Vector<Vector2>());
undo_redo->add_undo_method(_get_node(), "set_uv", _get_node()->get("uv"));
}
_commit_action();
@@ -572,7 +573,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
// All polygon points are sharp, so use the sharp handle icon
- const Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
+ const Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
const Vertex active_point = get_active_point();
const int n_polygons = _get_polygon_count();
@@ -583,7 +584,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
if (wip_active && wip_destructive && j != -1)
continue;
- PoolVector<Vector2> points;
+ Vector<Vector2> points;
Vector2 offset;
if (wip_active && j == edited_point.polygon) {
@@ -611,7 +612,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
Vector2 point = xform.xform(p);
Vector2 next_point = xform.xform(p2);
- p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE), true);
+ p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE));
}
}
@@ -635,7 +636,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
p2 = points[(i + 1) % n_points] + offset;
const Vector2 next_point = xform.xform(p2);
- p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE), true);
+ p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE));
}
}
@@ -660,7 +661,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
if (edge_point.valid()) {
- Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
+ Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5);
}
}
@@ -702,7 +703,7 @@ void AbstractPolygon2DEditor::_bind_methods() {
void AbstractPolygon2DEditor::remove_point(const Vertex &p_vertex) {
- PoolVector<Vector2> vertices = _get_polygon(p_vertex.polygon);
+ Vector<Vector2> vertices = _get_polygon(p_vertex.polygon);
if (vertices.size() > (_is_line() ? 2 : 3)) {
@@ -743,7 +744,7 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const
for (int j = 0; j < n_polygons; j++) {
- PoolVector<Vector2> points = _get_polygon(j);
+ Vector<Vector2> points = _get_polygon(j);
const Vector2 offset = _get_offset(j);
const int n_points = points.size();
@@ -776,7 +777,7 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c
for (int j = 0; j < n_polygons; j++) {
- PoolVector<Vector2> points = _get_polygon(j);
+ Vector<Vector2> points = _get_polygon(j);
const Vector2 offset = _get_offset(j);
const int n_points = points.size();
const int n_segments = n_points - (_is_line() ? 1 : 0);
@@ -819,17 +820,17 @@ AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wi
add_child(memnew(VSeparator));
button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
+ button_create->connect_compat("pressed", this, "_menu_option", varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
+ button_edit->connect_compat("pressed", this, "_menu_option", varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
button_delete = memnew(ToolButton);
add_child(button_delete);
- button_delete->connect("pressed", this, "_menu_option", varray(MODE_DELETE));
+ button_delete->connect_compat("pressed", this, "_menu_option", varray(MODE_DELETE));
button_delete->set_toggle_mode(true);
create_resource = memnew(ConfirmationDialog);
diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h
index a00cdd0cf6..6ed6d0a257 100644
--- a/editor/plugins/abstract_polygon_2d_editor.h
+++ b/editor/plugins/abstract_polygon_2d_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index e07f041eb1..c955f2b806 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,7 @@
#include "animation_blend_space_1d_editor.h"
#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
#include "scene/animation/animation_blend_tree.h"
StringName AnimationNodeBlendSpace1DEditor::get_blend_position_path() const {
@@ -201,8 +202,8 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
linecolor_soft.a *= 0.5;
Ref<Font> font = get_font("font", "Label");
- Ref<Texture> icon = get_icon("KeyValue", "EditorIcons");
- Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons");
+ Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons");
+ Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons");
Size2 s = blend_space_draw->get_size();
@@ -621,28 +622,28 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
top_hb->add_child(tool_blend);
tool_blend->set_pressed(true);
tool_blend->set_tooltip(TTR("Set the blending position within the space"));
- tool_blend->connect("pressed", this, "_tool_switch", varray(3));
+ tool_blend->connect_compat("pressed", this, "_tool_switch", varray(3));
tool_select = memnew(ToolButton);
tool_select->set_toggle_mode(true);
tool_select->set_button_group(bg);
top_hb->add_child(tool_select);
tool_select->set_tooltip(TTR("Select and move points, create points with RMB."));
- tool_select->connect("pressed", this, "_tool_switch", varray(0));
+ tool_select->connect_compat("pressed", this, "_tool_switch", varray(0));
tool_create = memnew(ToolButton);
tool_create->set_toggle_mode(true);
tool_create->set_button_group(bg);
top_hb->add_child(tool_create);
tool_create->set_tooltip(TTR("Create points."));
- tool_create->connect("pressed", this, "_tool_switch", varray(1));
+ tool_create->connect_compat("pressed", this, "_tool_switch", varray(1));
tool_erase_sep = memnew(VSeparator);
top_hb->add_child(tool_erase_sep);
tool_erase = memnew(ToolButton);
top_hb->add_child(tool_erase);
tool_erase->set_tooltip(TTR("Erase points."));
- tool_erase->connect("pressed", this, "_erase_selected");
+ tool_erase->connect_compat("pressed", this, "_erase_selected");
top_hb->add_child(memnew(VSeparator));
@@ -651,7 +652,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
top_hb->add_child(snap);
snap->set_pressed(true);
snap->set_tooltip(TTR("Enable snap and show grid."));
- snap->connect("pressed", this, "_snap_toggled");
+ snap->connect_compat("pressed", this, "_snap_toggled");
snap_value = memnew(SpinBox);
top_hb->add_child(snap_value);
@@ -669,12 +670,12 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
edit_value->set_min(-1000);
edit_value->set_max(1000);
edit_value->set_step(0.01);
- edit_value->connect("value_changed", this, "_edit_point_pos");
+ edit_value->connect_compat("value_changed", this, "_edit_point_pos");
open_editor = memnew(Button);
edit_hb->add_child(open_editor);
open_editor->set_text(TTR("Open Editor"));
- open_editor->connect("pressed", this, "_open_editor", varray(), CONNECT_DEFERRED);
+ open_editor->connect_compat("pressed", this, "_open_editor", varray(), CONNECT_DEFERRED);
edit_hb->hide();
open_editor->hide();
@@ -690,8 +691,8 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
panel->set_v_size_flags(SIZE_EXPAND_FILL);
blend_space_draw = memnew(Control);
- blend_space_draw->connect("gui_input", this, "_blend_space_gui_input");
- blend_space_draw->connect("draw", this, "_blend_space_draw");
+ blend_space_draw->connect_compat("gui_input", this, "_blend_space_gui_input");
+ blend_space_draw->connect_compat("draw", this, "_blend_space_draw");
blend_space_draw->set_focus_mode(FOCUS_ALL);
panel->add_child(blend_space_draw);
@@ -702,13 +703,13 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
bottom_hb->set_h_size_flags(SIZE_EXPAND_FILL);
min_value = memnew(SpinBox);
- min_value->set_max(0);
min_value->set_min(-10000);
+ min_value->set_max(0);
min_value->set_step(0.01);
max_value = memnew(SpinBox);
- max_value->set_max(10000);
max_value->set_min(0.01);
+ max_value->set_max(10000);
max_value->set_step(0.01);
label_value = memnew(LineEdit);
@@ -723,10 +724,10 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
bottom_hb->add_child(max_value);
}
- snap_value->connect("value_changed", this, "_config_changed");
- min_value->connect("value_changed", this, "_config_changed");
- max_value->connect("value_changed", this, "_config_changed");
- label_value->connect("text_changed", this, "_labels_changed");
+ snap_value->connect_compat("value_changed", this, "_config_changed");
+ min_value->connect_compat("value_changed", this, "_config_changed");
+ max_value->connect_compat("value_changed", this, "_config_changed");
+ label_value->connect_compat("text_changed", this, "_labels_changed");
error_panel = memnew(PanelContainer);
add_child(error_panel);
@@ -739,18 +740,18 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed", this, "_add_menu_type");
+ menu->connect_compat("id_pressed", this, "_add_menu_type");
animations_menu = memnew(PopupMenu);
menu->add_child(animations_menu);
animations_menu->set_name("animations");
- animations_menu->connect("index_pressed", this, "_add_animation_type");
+ animations_menu->connect_compat("index_pressed", this, "_add_animation_type");
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- open_file->connect("file_selected", this, "_file_opened");
+ open_file->connect_compat("file_selected", this, "_file_opened");
undo_redo = EditorNode::get_undo_redo();
selected_point = -1;
diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h
index 4a924b46c1..346ad36cff 100644
--- a/editor/plugins/animation_blend_space_1d_editor.h
+++ b/editor/plugins/animation_blend_space_1d_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index b422e3e927..d2306a5d6b 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,6 +35,7 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
+#include "editor/editor_scale.h"
#include "scene/animation/animation_blend_tree.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
@@ -54,12 +55,12 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_changed() {
void AnimationNodeBlendSpace2DEditor::edit(const Ref<AnimationNode> &p_node) {
if (blend_space.is_valid()) {
- blend_space->disconnect("triangles_updated", this, "_blend_space_changed");
+ blend_space->disconnect_compat("triangles_updated", this, "_blend_space_changed");
}
blend_space = p_node;
if (!blend_space.is_null()) {
- blend_space->connect("triangles_updated", this, "_blend_space_changed");
+ blend_space->connect_compat("triangles_updated", this, "_blend_space_changed");
_update_space();
}
}
@@ -409,8 +410,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
Color linecolor_soft = linecolor;
linecolor_soft.a *= 0.5;
Ref<Font> font = get_font("font", "Label");
- Ref<Texture> icon = get_icon("KeyValue", "EditorIcons");
- Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons");
+ Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons");
+ Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons");
Size2 s = blend_space_draw->get_size();
@@ -496,7 +497,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
for (int j = 0; j < 3; j++) {
- blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, 1, true);
+ blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, 1);
}
Color color;
@@ -552,9 +553,9 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
for (int i = 0; i < points.size() - 1; i++) {
- blend_space_draw->draw_line(points[i], points[i + 1], linecolor, 2, true);
+ blend_space_draw->draw_line(points[i], points[i + 1], linecolor, 2);
}
- blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, 2, true);
+ blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, 2);
}
///draw cursor position
@@ -869,42 +870,42 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
top_hb->add_child(tool_blend);
tool_blend->set_pressed(true);
tool_blend->set_tooltip(TTR("Set the blending position within the space"));
- tool_blend->connect("pressed", this, "_tool_switch", varray(3));
+ tool_blend->connect_compat("pressed", this, "_tool_switch", varray(3));
tool_select = memnew(ToolButton);
tool_select->set_toggle_mode(true);
tool_select->set_button_group(bg);
top_hb->add_child(tool_select);
tool_select->set_tooltip(TTR("Select and move points, create points with RMB."));
- tool_select->connect("pressed", this, "_tool_switch", varray(0));
+ tool_select->connect_compat("pressed", this, "_tool_switch", varray(0));
tool_create = memnew(ToolButton);
tool_create->set_toggle_mode(true);
tool_create->set_button_group(bg);
top_hb->add_child(tool_create);
tool_create->set_tooltip(TTR("Create points."));
- tool_create->connect("pressed", this, "_tool_switch", varray(1));
+ tool_create->connect_compat("pressed", this, "_tool_switch", varray(1));
tool_triangle = memnew(ToolButton);
tool_triangle->set_toggle_mode(true);
tool_triangle->set_button_group(bg);
top_hb->add_child(tool_triangle);
tool_triangle->set_tooltip(TTR("Create triangles by connecting points."));
- tool_triangle->connect("pressed", this, "_tool_switch", varray(2));
+ tool_triangle->connect_compat("pressed", this, "_tool_switch", varray(2));
tool_erase_sep = memnew(VSeparator);
top_hb->add_child(tool_erase_sep);
tool_erase = memnew(ToolButton);
top_hb->add_child(tool_erase);
tool_erase->set_tooltip(TTR("Erase points and triangles."));
- tool_erase->connect("pressed", this, "_erase_selected");
+ tool_erase->connect_compat("pressed", this, "_erase_selected");
tool_erase->set_disabled(true);
top_hb->add_child(memnew(VSeparator));
auto_triangles = memnew(ToolButton);
top_hb->add_child(auto_triangles);
- auto_triangles->connect("pressed", this, "_auto_triangles_toggled");
+ auto_triangles->connect_compat("pressed", this, "_auto_triangles_toggled");
auto_triangles->set_toggle_mode(true);
auto_triangles->set_tooltip(TTR("Generate blend triangles automatically (instead of manually)"));
@@ -915,7 +916,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
top_hb->add_child(snap);
snap->set_pressed(true);
snap->set_tooltip(TTR("Enable snap and show grid."));
- snap->connect("pressed", this, "_snap_toggled");
+ snap->connect_compat("pressed", this, "_snap_toggled");
snap_x = memnew(SpinBox);
top_hb->add_child(snap_x);
@@ -936,7 +937,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
top_hb->add_child(memnew(Label(TTR("Blend:"))));
interpolation = memnew(OptionButton);
top_hb->add_child(interpolation);
- interpolation->connect("item_selected", this, "_config_changed");
+ interpolation->connect_compat("item_selected", this, "_config_changed");
edit_hb = memnew(HBoxContainer);
top_hb->add_child(edit_hb);
@@ -947,17 +948,17 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
edit_x->set_min(-1000);
edit_x->set_step(0.01);
edit_x->set_max(1000);
- edit_x->connect("value_changed", this, "_edit_point_pos");
+ edit_x->connect_compat("value_changed", this, "_edit_point_pos");
edit_y = memnew(SpinBox);
edit_hb->add_child(edit_y);
edit_y->set_min(-1000);
edit_y->set_step(0.01);
edit_y->set_max(1000);
- edit_y->connect("value_changed", this, "_edit_point_pos");
+ edit_y->connect_compat("value_changed", this, "_edit_point_pos");
open_editor = memnew(Button);
edit_hb->add_child(open_editor);
open_editor->set_text(TTR("Open Editor"));
- open_editor->connect("pressed", this, "_open_editor", varray(), CONNECT_DEFERRED);
+ open_editor->connect_compat("pressed", this, "_open_editor", varray(), CONNECT_DEFERRED);
edit_hb->hide();
open_editor->hide();
@@ -998,8 +999,8 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
panel->set_h_size_flags(SIZE_EXPAND_FILL);
blend_space_draw = memnew(Control);
- blend_space_draw->connect("gui_input", this, "_blend_space_gui_input");
- blend_space_draw->connect("draw", this, "_blend_space_draw");
+ blend_space_draw->connect_compat("gui_input", this, "_blend_space_gui_input");
+ blend_space_draw->connect_compat("draw", this, "_blend_space_draw");
blend_space_draw->set_focus_mode(FOCUS_ALL);
panel->add_child(blend_space_draw);
@@ -1028,14 +1029,14 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
min_x_value->set_step(0.01);
}
- snap_x->connect("value_changed", this, "_config_changed");
- snap_y->connect("value_changed", this, "_config_changed");
- max_x_value->connect("value_changed", this, "_config_changed");
- min_x_value->connect("value_changed", this, "_config_changed");
- max_y_value->connect("value_changed", this, "_config_changed");
- min_y_value->connect("value_changed", this, "_config_changed");
- label_x->connect("text_changed", this, "_labels_changed");
- label_y->connect("text_changed", this, "_labels_changed");
+ snap_x->connect_compat("value_changed", this, "_config_changed");
+ snap_y->connect_compat("value_changed", this, "_config_changed");
+ max_x_value->connect_compat("value_changed", this, "_config_changed");
+ min_x_value->connect_compat("value_changed", this, "_config_changed");
+ max_y_value->connect_compat("value_changed", this, "_config_changed");
+ min_y_value->connect_compat("value_changed", this, "_config_changed");
+ label_x->connect_compat("text_changed", this, "_labels_changed");
+ label_y->connect_compat("text_changed", this, "_labels_changed");
error_panel = memnew(PanelContainer);
add_child(error_panel);
@@ -1049,18 +1050,18 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed", this, "_add_menu_type");
+ menu->connect_compat("id_pressed", this, "_add_menu_type");
animations_menu = memnew(PopupMenu);
menu->add_child(animations_menu);
animations_menu->set_name("animations");
- animations_menu->connect("index_pressed", this, "_add_animation_type");
+ animations_menu->connect_compat("index_pressed", this, "_add_animation_type");
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- open_file->connect("file_selected", this, "_file_opened");
+ open_file->connect_compat("file_selected", this, "_file_opened");
undo_redo = EditorNode::get_undo_redo();
selected_point = -1;
diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h
index 850a6201bb..50b0d9a06c 100644
--- a/editor/plugins/animation_blend_space_2d_editor.h
+++ b/editor/plugins/animation_blend_space_2d_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index e147206ec4..f2daa809b4 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,9 +35,11 @@
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_inspector.h"
+#include "editor/editor_scale.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
+#include "scene/gui/progress_bar.h"
#include "scene/main/viewport.h"
void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script) {
@@ -144,11 +146,11 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
name->set_expand_to_text_length(true);
node->add_child(name);
node->set_slot(0, false, 0, Color(), true, 0, get_color("font_color", "Label"));
- name->connect("text_entered", this, "_node_renamed", varray(agnode));
- name->connect("focus_exited", this, "_node_renamed_focus_out", varray(name, agnode));
+ name->connect_compat("text_entered", this, "_node_renamed", varray(agnode));
+ name->connect_compat("focus_exited", this, "_node_renamed_focus_out", varray(name, agnode), CONNECT_DEFERRED);
base = 1;
node->set_show_close_button(true);
- node->connect("close_request", this, "_delete_request", varray(E->get()), CONNECT_DEFERRED);
+ node->connect_compat("close_request", this, "_delete_request", varray(E->get()), CONNECT_DEFERRED);
}
for (int i = 0; i < agnode->get_input_count(); i++) {
@@ -171,13 +173,13 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
prop->set_object_and_property(AnimationTreeEditor::get_singleton()->get_tree(), base_path);
prop->update_property();
prop->set_name_split_ratio(0);
- prop->connect("property_changed", this, "_property_changed");
+ prop->connect_compat("property_changed", this, "_property_changed");
node->add_child(prop);
visible_properties.push_back(prop);
}
}
- node->connect("dragged", this, "_node_dragged", varray(E->get()));
+ node->connect_compat("dragged", this, "_node_dragged", varray(E->get()));
if (AnimationTreeEditor::get_singleton()->can_edit(agnode)) {
node->add_child(memnew(HSeparator));
@@ -185,7 +187,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
open_in_editor->set_text(TTR("Open Editor"));
open_in_editor->set_icon(get_icon("Edit", "EditorIcons"));
node->add_child(open_in_editor);
- open_in_editor->connect("pressed", this, "_open_in_editor", varray(E->get()), CONNECT_DEFERRED);
+ open_in_editor->connect_compat("pressed", this, "_open_in_editor", varray(E->get()), CONNECT_DEFERRED);
open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER);
}
@@ -196,7 +198,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
edit_filters->set_text(TTR("Edit Filters"));
edit_filters->set_icon(get_icon("AnimationFilter", "EditorIcons"));
node->add_child(edit_filters);
- edit_filters->connect("pressed", this, "_edit_filters", varray(E->get()), CONNECT_DEFERRED);
+ edit_filters->connect_compat("pressed", this, "_edit_filters", varray(E->get()), CONNECT_DEFERRED);
edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER);
}
@@ -236,7 +238,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
animations[E->get()] = pb;
node->add_child(pb);
- mb->get_popup()->connect("index_pressed", this, "_anim_selected", varray(options, E->get()), CONNECT_DEFERRED);
+ mb->get_popup()->connect_compat("index_pressed", this, "_anim_selected", varray(options, E->get()), CONNECT_DEFERRED);
}
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
@@ -310,7 +312,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instance(base_type));
ERR_FAIL_COND(!an);
anode = Ref<AnimationNode>(an);
- anode->set_script(add_options[p_idx].script.get_ref_ptr());
+ anode->set_script(add_options[p_idx].script);
base_name = add_options[p_idx].name;
}
@@ -909,7 +911,7 @@ bool AnimationNodeBlendTreeEditor::can_edit(const Ref<AnimationNode> &p_node) {
void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) {
if (blend_tree.is_valid()) {
- blend_tree->disconnect("removed_from_graph", this, "_removed_from_graph");
+ blend_tree->disconnect_compat("removed_from_graph", this, "_removed_from_graph");
}
blend_tree = p_node;
@@ -917,7 +919,7 @@ void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) {
if (blend_tree.is_null()) {
hide();
} else {
- blend_tree->connect("removed_from_graph", this, "_removed_from_graph");
+ blend_tree->connect_compat("removed_from_graph", this, "_removed_from_graph");
_update_graph();
}
@@ -934,12 +936,12 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
graph->add_valid_right_disconnect_type(0);
graph->add_valid_left_disconnect_type(0);
graph->set_v_size_flags(SIZE_EXPAND_FILL);
- graph->connect("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED);
- graph->connect("disconnection_request", this, "_disconnection_request", varray(), CONNECT_DEFERRED);
- graph->connect("node_selected", this, "_node_selected");
- graph->connect("scroll_offset_changed", this, "_scroll_changed");
- graph->connect("delete_nodes_request", this, "_delete_nodes_request");
- graph->connect("popup_request", this, "_popup_request");
+ graph->connect_compat("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED);
+ graph->connect_compat("disconnection_request", this, "_disconnection_request", varray(), CONNECT_DEFERRED);
+ graph->connect_compat("node_selected", this, "_node_selected");
+ graph->connect_compat("scroll_offset_changed", this, "_scroll_changed");
+ graph->connect_compat("delete_nodes_request", this, "_delete_nodes_request");
+ graph->connect_compat("popup_request", this, "_popup_request");
VSeparator *vs = memnew(VSeparator);
graph->get_zoom_hbox()->add_child(vs);
@@ -949,8 +951,8 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
graph->get_zoom_hbox()->add_child(add_node);
add_node->set_text(TTR("Add Node..."));
graph->get_zoom_hbox()->move_child(add_node, 0);
- add_node->get_popup()->connect("id_pressed", this, "_add_node");
- add_node->connect("about_to_show", this, "_update_options_menu");
+ add_node->get_popup()->connect_compat("id_pressed", this, "_add_node");
+ add_node->connect_compat("about_to_show", this, "_update_options_menu");
add_options.push_back(AddOption("Animation", "AnimationNodeAnimation"));
add_options.push_back(AddOption("OneShot", "AnimationNodeOneShot"));
@@ -982,19 +984,19 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
filter_enabled = memnew(CheckBox);
filter_enabled->set_text(TTR("Enable Filtering"));
- filter_enabled->connect("pressed", this, "_filter_toggled");
+ filter_enabled->connect_compat("pressed", this, "_filter_toggled");
filter_vbox->add_child(filter_enabled);
filters = memnew(Tree);
filter_vbox->add_child(filters);
filters->set_v_size_flags(SIZE_EXPAND_FILL);
filters->set_hide_root(true);
- filters->connect("item_edited", this, "_filter_edited");
+ filters->connect_compat("item_edited", this, "_filter_edited");
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- open_file->connect("file_selected", this, "_file_opened");
+ open_file->connect_compat("file_selected", this, "_file_opened");
undo_redo = EditorNode::get_undo_redo();
}
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h
index 77b57a50d0..4f5badea9f 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.h
+++ b/editor/plugins/animation_blend_tree_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,6 +41,8 @@
#include "scene/gui/popup.h"
#include "scene/gui/tree.h"
+class ProgressBar;
+
class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin {
GDCLASS(AnimationNodeBlendTreeEditor, AnimationTreeNodeEditorPlugin);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 80353bab01..0f2a7376f5 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,11 +36,10 @@
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/animation_track_editor.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
-
-// For onion skinning.
-#include "editor/plugins/canvas_item_editor_plugin.h"
-#include "editor/plugins/spatial_editor_plugin.h"
+#include "editor/plugins/canvas_item_editor_plugin.h" // For onion skinning.
+#include "editor/plugins/spatial_editor_plugin.h" // For onion skinning.
#include "scene/main/viewport.h"
#include "servers/visual_server.h"
@@ -85,6 +84,9 @@ void AnimationPlayerEditor::_notification(int p_what) {
track_editor->set_anim_pos(player->get_current_animation_position());
EditorNode::get_singleton()->get_inspector()->refresh();
+ } else if (!player->is_valid()) {
+ // Reset timeline when the player has been stopped externally
+ frame->set_value(0);
} else if (last_active) {
// Need the last frame after it stopped.
frame->set_value(player->get_current_animation_position());
@@ -95,13 +97,13 @@ void AnimationPlayerEditor::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
- tool_anim->get_popup()->connect("id_pressed", this, "_animation_tool_menu");
+ tool_anim->get_popup()->connect_compat("id_pressed", this, "_animation_tool_menu");
- onion_skinning->get_popup()->connect("id_pressed", this, "_onion_skinning_menu");
+ onion_skinning->get_popup()->connect_compat("id_pressed", this, "_onion_skinning_menu");
- blend_editor.next->connect("item_selected", this, "_blend_editor_next_changed");
+ blend_editor.next->connect_compat("item_selected", this, "_blend_editor_next_changed");
- get_tree()->connect("node_removed", this, "_node_removed");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel"));
} break;
@@ -371,8 +373,7 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
if (err != OK) {
- accept->set_text(TTR("Error saving resource!"));
- accept->popup_centered_minsize();
+ EditorNode::get_singleton()->show_warning(TTR("Error saving resource!"));
return;
}
@@ -993,9 +994,9 @@ void AnimationPlayerEditor::_animation_duplicate() {
String new_name = current;
while (player->has_animation(new_name)) {
-
new_name = new_name + " (copy)";
}
+ new_anim->set_name(new_name);
undo_redo->create_action(TTR("Duplicate Animation"));
undo_redo->add_do_method(player, "add_animation", new_name, new_anim);
@@ -1089,8 +1090,6 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag)
if (!player->has_animation(player->get_assigned_animation()))
return;
- Ref<Animation> anim = player->get_animation(player->get_assigned_animation());
-
updating = true;
frame->set_value(Math::stepify(p_pos, _get_editor_step()));
updating = false;
@@ -1320,11 +1319,10 @@ void AnimationPlayerEditor::_allocate_onion_layers() {
// Each capture is a viewport with a canvas item attached that renders a full-size rect with the contents of the main viewport.
onion.captures.write[i] = VS::get_singleton()->viewport_create();
- VS::get_singleton()->viewport_set_usage(onion.captures[i], VS::VIEWPORT_USAGE_2D);
+
VS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height);
VS::get_singleton()->viewport_set_update_mode(onion.captures[i], VS::VIEWPORT_UPDATE_ALWAYS);
VS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present);
- VS::get_singleton()->viewport_set_vflip(onion.captures[i], true);
VS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas);
}
@@ -1503,16 +1501,16 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
void AnimationPlayerEditor::_start_onion_skinning() {
// FIXME: Using "idle_frame" makes onion layers update one frame behind the current.
- if (!get_tree()->is_connected("idle_frame", this, "call_deferred")) {
- get_tree()->connect("idle_frame", this, "call_deferred", varray("_prepare_onion_layers_1"));
+ if (!get_tree()->is_connected_compat("idle_frame", this, "call_deferred")) {
+ get_tree()->connect_compat("idle_frame", this, "call_deferred", varray("_prepare_onion_layers_1"));
}
}
void AnimationPlayerEditor::_stop_onion_skinning() {
- if (get_tree()->is_connected("idle_frame", this, "call_deferred")) {
+ if (get_tree()->is_connected_compat("idle_frame", this, "call_deferred")) {
- get_tree()->disconnect("idle_frame", this, "call_deferred");
+ get_tree()->disconnect_compat("idle_frame", this, "call_deferred");
_free_onion_layers();
@@ -1627,13 +1625,9 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
scale->set_tooltip(TTR("Scale animation playback globally for the node."));
scale->hide();
- accept = memnew(AcceptDialog);
- add_child(accept);
- accept->connect("confirmed", this, "_menu_confirm_current");
-
delete_dialog = memnew(ConfirmationDialog);
add_child(delete_dialog);
- delete_dialog->connect("confirmed", this, "_animation_remove_confirmed");
+ delete_dialog->connect_compat("confirmed", this, "_animation_remove_confirmed");
tool_anim = memnew(MenuButton);
tool_anim->set_flat(false);
@@ -1678,7 +1672,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
onion_toggle = memnew(ToolButton);
onion_toggle->set_toggle_mode(true);
onion_toggle->set_tooltip(TTR("Enable Onion Skinning"));
- onion_toggle->connect("pressed", this, "_onion_skinning_menu", varray(ONION_SKINNING_ENABLE));
+ onion_toggle->connect_compat("pressed", this, "_onion_skinning_menu", varray(ONION_SKINNING_ENABLE));
hb->add_child(onion_toggle);
onion_skinning = memnew(MenuButton);
@@ -1704,7 +1698,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
pin->set_toggle_mode(true);
pin->set_tooltip(TTR("Pin AnimationPlayer"));
hb->add_child(pin);
- pin->connect("pressed", this, "_pin_pressed");
+ pin->connect_compat("pressed", this, "_pin_pressed");
file = memnew(EditorFileDialog);
add_child(file);
@@ -1728,7 +1722,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
error_dialog->set_title(TTR("Error!"));
add_child(error_dialog);
- name_dialog->connect("confirmed", this, "_animation_name_edited");
+ name_dialog->connect_compat("confirmed", this, "_animation_name_edited");
blend_editor.dialog = memnew(AcceptDialog);
add_child(blend_editor.dialog);
@@ -1744,21 +1738,21 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
blend_editor.dialog->set_title(TTR("Cross-Animation Blend Times"));
updating_blends = false;
- blend_editor.tree->connect("item_edited", this, "_blend_edited");
+ blend_editor.tree->connect_compat("item_edited", this, "_blend_edited");
- autoplay->connect("pressed", this, "_autoplay_pressed");
+ autoplay->connect_compat("pressed", this, "_autoplay_pressed");
autoplay->set_toggle_mode(true);
- play->connect("pressed", this, "_play_pressed");
- play_from->connect("pressed", this, "_play_from_pressed");
- play_bw->connect("pressed", this, "_play_bw_pressed");
- play_bw_from->connect("pressed", this, "_play_bw_from_pressed");
- stop->connect("pressed", this, "_stop_pressed");
+ play->connect_compat("pressed", this, "_play_pressed");
+ play_from->connect_compat("pressed", this, "_play_from_pressed");
+ play_bw->connect_compat("pressed", this, "_play_bw_pressed");
+ play_bw_from->connect_compat("pressed", this, "_play_bw_from_pressed");
+ stop->connect_compat("pressed", this, "_stop_pressed");
- animation->connect("item_selected", this, "_animation_selected", Vector<Variant>(), true);
+ animation->connect_compat("item_selected", this, "_animation_selected", Vector<Variant>(), true);
- file->connect("file_selected", this, "_dialog_action");
- frame->connect("value_changed", this, "_seek_value_changed", Vector<Variant>(), true);
- scale->connect("text_entered", this, "_scale_changed", Vector<Variant>(), true);
+ file->connect_compat("file_selected", this, "_dialog_action");
+ frame->connect_compat("value_changed", this, "_seek_value_changed", Vector<Variant>(), true);
+ scale->connect_compat("text_entered", this, "_scale_changed", Vector<Variant>(), true);
renaming = false;
last_active = false;
@@ -1768,14 +1762,14 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
add_child(track_editor);
track_editor->set_v_size_flags(SIZE_EXPAND_FILL);
- track_editor->connect("timeline_changed", this, "_animation_key_editor_seek");
- track_editor->connect("animation_len_changed", this, "_animation_key_editor_anim_len_changed");
+ track_editor->connect_compat("timeline_changed", this, "_animation_key_editor_seek");
+ track_editor->connect_compat("animation_len_changed", this, "_animation_key_editor_anim_len_changed");
_update_player();
// Onion skinning.
- track_editor->connect("visibility_changed", this, "_editor_visibility_changed");
+ track_editor->connect_compat("visibility_changed", this, "_editor_visibility_changed");
onion.enabled = false;
onion.past = true;
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 663ffd57f3..40815151a3 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -105,12 +105,11 @@ class AnimationPlayerEditor : public VBoxContainer {
LineEdit *name;
Label *name_title;
UndoRedo *undo_redo;
- Ref<Texture> autoplay_icon;
+ Ref<Texture2D> autoplay_icon;
bool last_active;
float timeline_position;
EditorFileDialog *file;
- AcceptDialog *accept;
ConfirmationDialog *delete_dialog;
int current_option;
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index ce400ad6dd..6f29aba356 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,6 +35,7 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
+#include "editor/editor_scale.h"
#include "scene/animation/animation_blend_tree.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
@@ -262,7 +263,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
if (connecting_to_node != StringName()) {
if (state_machine->has_transition(connecting_from, connecting_to_node)) {
- EditorNode::get_singleton()->show_warning("Transition exists!");
+ EditorNode::get_singleton()->show_warning(TTR("Transition exists!"));
} else {
@@ -513,7 +514,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
accent.a *= 0.6;
}
- Ref<Texture> icons[6] = {
+ Ref<Texture2D> icons[6] = {
get_icon("TransitionImmediateBig", "EditorIcons"),
get_icon("TransitionSyncBig", "EditorIcons"),
get_icon("TransitionEndBig", "EditorIcons"),
@@ -523,16 +524,16 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
};
if (p_selected) {
- state_machine_draw->draw_line(p_from, p_to, accent, 6, true);
+ state_machine_draw->draw_line(p_from, p_to, accent, 6);
}
if (p_travel) {
linecolor = accent;
linecolor.set_hsv(1.0, linecolor.get_s(), linecolor.get_v());
}
- state_machine_draw->draw_line(p_from, p_to, linecolor, 2, true);
+ state_machine_draw->draw_line(p_from, p_to, linecolor, 2);
- Ref<Texture> icon = icons[p_mode + (p_auto_advance ? 3 : 0)];
+ Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)];
Transform2D xf;
xf.elements[0] = (p_to - p_from).normalized();
@@ -577,9 +578,9 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<Font> font = get_font("title_font", "GraphNode");
Color font_color = get_color("title_color", "GraphNode");
- Ref<Texture> play = get_icon("Play", "EditorIcons");
- Ref<Texture> auto_play = get_icon("AutoPlay", "EditorIcons");
- Ref<Texture> edit = get_icon("Edit", "EditorIcons");
+ Ref<Texture2D> play = get_icon("Play", "EditorIcons");
+ Ref<Texture2D> auto_play = get_icon("AutoPlay", "EditorIcons");
+ Ref<Texture2D> edit = get_icon("Edit", "EditorIcons");
Color accent = get_color("accent_color", "Editor");
Color linecolor = get_color("font_color", "Label");
linecolor.a *= 0.3;
@@ -685,7 +686,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
_connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()), true, false, false, false);
}
- Ref<Texture> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons");
+ Ref<Texture2D> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons");
float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8);
//draw transition lines
@@ -795,7 +796,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
nr.play.position = offset + Vector2(0, (h - play->get_height()) / 2).floor();
nr.play.size = play->get_size();
- Ref<Texture> play_tex = onstart ? auto_play : play;
+ Ref<Texture2D> play_tex = onstart ? auto_play : play;
if (over_node == name && over_node_what == 0) {
state_machine_draw->draw_texture(play_tex, nr.play.position, accent);
@@ -917,14 +918,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
transition_mode->add_icon_item(get_icon("TransitionSync", "EditorIcons"), TTR("Sync"));
transition_mode->add_icon_item(get_icon("TransitionEnd", "EditorIcons"), TTR("At End"));
- //force filter on those, so they deform better
- get_icon("TransitionImmediateBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
- get_icon("TransitionEndBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
- get_icon("TransitionSyncBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
- get_icon("TransitionImmediateAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
- get_icon("TransitionEndAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
- get_icon("TransitionSyncAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
-
tool_erase->set_icon(get_icon("Remove", "EditorIcons"));
tool_autoplay->set_icon(get_icon("AutoPlay", "EditorIcons"));
tool_end->set_icon(get_icon("AutoEnd", "EditorIcons"));
@@ -1283,21 +1276,21 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
tool_select->set_button_group(bg);
tool_select->set_pressed(true);
tool_select->set_tooltip(TTR("Select and move nodes.\nRMB to add new nodes.\nShift+LMB to create connections."));
- tool_select->connect("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);
+ tool_select->connect_compat("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);
tool_create = memnew(ToolButton);
top_hb->add_child(tool_create);
tool_create->set_toggle_mode(true);
tool_create->set_button_group(bg);
tool_create->set_tooltip(TTR("Create new nodes."));
- tool_create->connect("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);
+ tool_create->connect_compat("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);
tool_connect = memnew(ToolButton);
top_hb->add_child(tool_connect);
tool_connect->set_toggle_mode(true);
tool_connect->set_button_group(bg);
tool_connect->set_tooltip(TTR("Connect nodes."));
- tool_connect->connect("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);
+ tool_connect->connect_compat("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);
tool_erase_hb = memnew(HBoxContainer);
top_hb->add_child(tool_erase_hb);
@@ -1305,7 +1298,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
tool_erase = memnew(ToolButton);
tool_erase->set_tooltip(TTR("Remove selected node or transition."));
tool_erase_hb->add_child(tool_erase);
- tool_erase->connect("pressed", this, "_erase_selected");
+ tool_erase->connect_compat("pressed", this, "_erase_selected");
tool_erase->set_disabled(true);
tool_erase_hb->add_child(memnew(VSeparator));
@@ -1313,13 +1306,13 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
tool_autoplay = memnew(ToolButton);
tool_autoplay->set_tooltip(TTR("Toggle autoplay this animation on start, restart or seek to zero."));
tool_erase_hb->add_child(tool_autoplay);
- tool_autoplay->connect("pressed", this, "_autoplay_selected");
+ tool_autoplay->connect_compat("pressed", this, "_autoplay_selected");
tool_autoplay->set_disabled(true);
tool_end = memnew(ToolButton);
tool_end->set_tooltip(TTR("Set the end animation. This is useful for sub-transitions."));
tool_erase_hb->add_child(tool_end);
- tool_end->connect("pressed", this, "_end_selected");
+ tool_end->connect_compat("pressed", this, "_end_selected");
tool_end->set_disabled(true);
top_hb->add_child(memnew(VSeparator));
@@ -1329,7 +1322,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
top_hb->add_spacer();
- top_hb->add_child(memnew(Label("Play Mode:")));
+ top_hb->add_child(memnew(Label(TTR("Play Mode:"))));
play_mode = memnew(OptionButton);
top_hb->add_child(play_mode);
@@ -1340,26 +1333,26 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
state_machine_draw = memnew(Control);
panel->add_child(state_machine_draw);
- state_machine_draw->connect("gui_input", this, "_state_machine_gui_input");
- state_machine_draw->connect("draw", this, "_state_machine_draw");
+ state_machine_draw->connect_compat("gui_input", this, "_state_machine_gui_input");
+ state_machine_draw->connect_compat("draw", this, "_state_machine_draw");
state_machine_draw->set_focus_mode(FOCUS_ALL);
state_machine_play_pos = memnew(Control);
state_machine_draw->add_child(state_machine_play_pos);
state_machine_play_pos->set_mouse_filter(MOUSE_FILTER_PASS); //pass all to parent
state_machine_play_pos->set_anchors_and_margins_preset(PRESET_WIDE);
- state_machine_play_pos->connect("draw", this, "_state_machine_pos_draw");
+ state_machine_play_pos->connect_compat("draw", this, "_state_machine_pos_draw");
v_scroll = memnew(VScrollBar);
state_machine_draw->add_child(v_scroll);
v_scroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
- v_scroll->connect("value_changed", this, "_scroll_changed");
+ v_scroll->connect_compat("value_changed", this, "_scroll_changed");
h_scroll = memnew(HScrollBar);
state_machine_draw->add_child(h_scroll);
h_scroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
h_scroll->set_margin(MARGIN_RIGHT, -v_scroll->get_size().x * EDSCALE);
- h_scroll->connect("value_changed", this, "_scroll_changed");
+ h_scroll->connect_compat("value_changed", this, "_scroll_changed");
error_panel = memnew(PanelContainer);
add_child(error_panel);
@@ -1373,25 +1366,25 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed", this, "_add_menu_type");
+ menu->connect_compat("id_pressed", this, "_add_menu_type");
animations_menu = memnew(PopupMenu);
menu->add_child(animations_menu);
animations_menu->set_name("animations");
- animations_menu->connect("index_pressed", this, "_add_animation_type");
+ animations_menu->connect_compat("index_pressed", this, "_add_animation_type");
name_edit = memnew(LineEdit);
state_machine_draw->add_child(name_edit);
name_edit->hide();
- name_edit->connect("text_entered", this, "_name_edited");
- name_edit->connect("focus_exited", this, "_name_edited_focus_out");
+ name_edit->connect_compat("text_entered", this, "_name_edited");
+ name_edit->connect_compat("focus_exited", this, "_name_edited_focus_out");
name_edit->set_as_toplevel(true);
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- open_file->connect("file_selected", this, "_file_opened");
+ open_file->connect_compat("file_selected", this, "_file_opened");
undo_redo = EditorNode::get_undo_redo();
over_text = false;
diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h
index 8b0a5a0b00..132e66b28d 100644
--- a/editor/plugins/animation_state_machine_editor.h
+++ b/editor/plugins/animation_state_machine_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 28dc5bf5c8..8900882725 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,6 +39,7 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
+#include "editor/editor_scale.h"
#include "scene/animation/animation_blend_tree.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
@@ -58,7 +59,7 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) {
path = tree->get_meta("_tree_edit_path");
edit_path(path);
} else {
- current_root = 0;
+ current_root = ObjectID();
}
}
@@ -84,7 +85,7 @@ void AnimationTreeEditor::_update_path() {
b->set_button_group(group);
b->set_pressed(true);
b->set_focus_mode(FOCUS_NONE);
- b->connect("pressed", this, "_path_button_pressed", varray(-1));
+ b->connect_compat("pressed", this, "_path_button_pressed", varray(-1));
path_hb->add_child(b);
for (int i = 0; i < button_path.size(); i++) {
b = memnew(Button);
@@ -94,7 +95,7 @@ void AnimationTreeEditor::_update_path() {
path_hb->add_child(b);
b->set_pressed(true);
b->set_focus_mode(FOCUS_NONE);
- b->connect("pressed", this, "_path_button_pressed", varray(i));
+ b->connect_compat("pressed", this, "_path_button_pressed", varray(i));
}
}
@@ -127,7 +128,7 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
}
}
} else {
- current_root = 0;
+ current_root = ObjectID();
edited_path = button_path;
}
@@ -150,7 +151,7 @@ void AnimationTreeEditor::_about_to_show_root() {
void AnimationTreeEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) {
- ObjectID root = 0;
+ ObjectID root;
if (tree && tree->get_tree_root().is_valid()) {
root = tree->get_tree_root()->get_instance_id();
}
@@ -241,7 +242,6 @@ AnimationTreeEditor::AnimationTreeEditor() {
add_child(memnew(HSeparator));
- current_root = 0;
singleton = this;
editor_base = memnew(PanelContainer);
editor_base->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -284,7 +284,7 @@ AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) {
editor = p_node;
anim_tree_editor = memnew(AnimationTreeEditor);
- anim_tree_editor->set_custom_minimum_size(Size2(0, 300));
+ anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor);
button->hide();
diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h
index 4ecbf2e05e..0b93b0fd8e 100644
--- a/editor/plugins/animation_tree_editor_plugin.h
+++ b/editor/plugins/animation_tree_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_tree_player_editor_plugin.cpp b/editor/plugins/animation_tree_player_editor_plugin.cpp
deleted file mode 100644
index c99ad7f441..0000000000
--- a/editor/plugins/animation_tree_player_editor_plugin.cpp
+++ /dev/null
@@ -1,1449 +0,0 @@
-/*************************************************************************/
-/* animation_tree_player_editor_plugin.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "animation_tree_player_editor_plugin.h"
-
-#include "core/io/resource_loader.h"
-#include "core/os/input.h"
-#include "core/os/keyboard.h"
-#include "core/project_settings.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/panel.h"
-#include "scene/main/viewport.h"
-
-void AnimationTreePlayerEditor::edit(AnimationTreePlayer *p_anim_tree) {
-
- anim_tree = p_anim_tree;
-
- if (!anim_tree) {
- hide();
- } else {
- order.clear();
- p_anim_tree->get_node_list(&order);
- /*
- for(List<StringName>::Element* E=order.front();E;E=E->next()) {
-
- if (E->get() >= (int)last_id)
- last_id=E->get()+1;
- }*/
- play_button->set_pressed(p_anim_tree->is_active());
- //read the orders
- }
-}
-
-Size2 AnimationTreePlayerEditor::_get_maximum_size() {
-
- Size2 max;
-
- for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
-
- Point2 pos = anim_tree->node_get_position(E->get());
-
- if (click_type == CLICK_NODE && click_node == E->get()) {
-
- pos += click_motion - click_pos;
- }
- pos += get_node_size(E->get());
- if (pos.x > max.x)
- max.x = pos.x;
- if (pos.y > max.y)
- max.y = pos.y;
- }
-
- return max;
-}
-
-const char *AnimationTreePlayerEditor::_node_type_names[] = { "Output", "Animation", "OneShot", "Mix", "Blend2", "Blend3", "Blend4", "TimeScale", "TimeSeek", "Transition" };
-
-Size2 AnimationTreePlayerEditor::get_node_size(const StringName &p_node) const {
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
-
- Size2 size = style->get_minimum_size();
-
- int count = 2; // title and name
- int inputs = anim_tree->node_get_input_count(p_node);
- count += inputs ? inputs : 1;
- String name = p_node;
-
- float name_w = font->get_string_size(name).width;
- float type_w = font->get_string_size(String(_node_type_names[type])).width;
- float max_w = MAX(name_w, type_w);
-
- switch (type) {
- case AnimationTreePlayer::NODE_TIMESEEK:
- case AnimationTreePlayer::NODE_OUTPUT: {
- } break;
- case AnimationTreePlayer::NODE_ANIMATION:
- case AnimationTreePlayer::NODE_ONESHOT:
- case AnimationTreePlayer::NODE_MIX:
- case AnimationTreePlayer::NODE_BLEND2:
- case AnimationTreePlayer::NODE_BLEND3:
- case AnimationTreePlayer::NODE_BLEND4:
- case AnimationTreePlayer::NODE_TIMESCALE:
- case AnimationTreePlayer::NODE_TRANSITION: {
-
- size.height += font->get_height();
- } break;
- case AnimationTreePlayer::NODE_MAX: {
- }
- }
-
- size.x += max_w + 20;
- size.y += count * (font->get_height() + get_constant("vseparation", "PopupMenu"));
-
- return size;
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changede(String) {
-
- edit_dialog->hide();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changeds(String s) {
-
- _edit_dialog_changed();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changedf(float) {
-
- _edit_dialog_changed();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changed() {
-
- if (updating_edit)
- return;
-
- if (renaming_edit) {
-
- if (anim_tree->node_rename(edited_node, edit_line[0]->get_text()) == OK) {
- for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
-
- if (E->get() == edited_node)
- E->get() = edit_line[0]->get_text();
- }
- edited_node = edit_line[0]->get_text();
- }
- update();
- return;
- }
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
-
- switch (type) {
-
- case AnimationTreePlayer::NODE_TIMESCALE:
- anim_tree->timescale_node_set_scale(edited_node, edit_line[0]->get_text().to_double());
- break;
- case AnimationTreePlayer::NODE_ONESHOT:
- anim_tree->oneshot_node_set_fadein_time(edited_node, edit_line[0]->get_text().to_double());
- anim_tree->oneshot_node_set_fadeout_time(edited_node, edit_line[1]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart_delay(edited_node, edit_line[2]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart_random_delay(edited_node, edit_line[3]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart(edited_node, edit_check->is_pressed());
- anim_tree->oneshot_node_set_mix_mode(edited_node, edit_option->get_selected());
-
- break;
-
- case AnimationTreePlayer::NODE_MIX:
-
- anim_tree->mix_node_set_amount(edited_node, edit_scroll[0]->get_value());
- break;
- case AnimationTreePlayer::NODE_BLEND2:
- anim_tree->blend2_node_set_amount(edited_node, edit_scroll[0]->get_value());
-
- break;
-
- case AnimationTreePlayer::NODE_BLEND3:
- anim_tree->blend3_node_set_amount(edited_node, edit_scroll[0]->get_value());
-
- break;
- case AnimationTreePlayer::NODE_BLEND4:
-
- anim_tree->blend4_node_set_amount(edited_node, Point2(edit_scroll[0]->get_value(), edit_scroll[1]->get_value()));
-
- break;
-
- case AnimationTreePlayer::NODE_TRANSITION: {
- anim_tree->transition_node_set_xfade_time(edited_node, edit_line[0]->get_text().to_double());
- if (anim_tree->transition_node_get_current(edited_node) != edit_option->get_selected())
- anim_tree->transition_node_set_current(edited_node, edit_option->get_selected());
- } break;
- default: {
- }
- }
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_animation_changed() {
-
- Ref<Animation> anim = property_editor->get_variant().operator RefPtr();
- anim_tree->animation_node_set_animation(edited_node, anim);
- update();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_edit_animation() {
-
- if (Engine::get_singleton()->is_editor_hint()) {
- get_tree()->get_root()->get_child(0)->call("_resource_selected", property_editor->get_variant().operator RefPtr());
- };
-};
-
-void AnimationTreePlayerEditor::_edit_oneshot_start() {
-
- anim_tree->oneshot_node_start(edited_node);
-}
-
-void AnimationTreePlayerEditor::_play_toggled() {
-
- anim_tree->set_active(play_button->is_pressed());
-}
-
-void AnimationTreePlayerEditor::_master_anim_menu_item(int p_item) {
-
- if (p_item == 0)
- _edit_filters();
- else {
-
- String str = master_anim_popup->get_item_text(p_item);
- anim_tree->animation_node_set_master_animation(edited_node, str);
- }
- update();
-}
-
-void AnimationTreePlayerEditor::_popup_edit_dialog() {
-
- updating_edit = true;
-
- for (int i = 0; i < 2; i++)
- edit_scroll[i]->hide();
-
- for (int i = 0; i < 4; i++) {
-
- edit_line[i]->hide();
- edit_label[i]->hide();
- }
-
- edit_option->hide();
- edit_button->hide();
- filter_button->hide();
- edit_check->hide();
-
- Point2 pos = anim_tree->node_get_position(edited_node) - Point2(h_scroll->get_value(), v_scroll->get_value());
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Size2 size = get_node_size(edited_node);
- Point2 popup_pos(pos.x + style->get_margin(MARGIN_LEFT), pos.y + size.y - style->get_margin(MARGIN_BOTTOM));
- popup_pos += get_global_position();
-
- if (renaming_edit) {
-
- edit_label[0]->set_text(TTR("New name:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(edited_node);
- edit_line[0]->show();
- edit_dialog->set_size(Size2(150, 50));
-
- } else {
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
-
- switch (type) {
-
- case AnimationTreePlayer::NODE_ANIMATION:
-
- if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()))) {
-
- AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()));
- master_anim_popup->clear();
- master_anim_popup->add_item(TTR("Edit Filters"));
- master_anim_popup->add_separator();
- List<StringName> sn;
- ap->get_animation_list(&sn);
- sn.sort_custom<StringName::AlphCompare>();
- for (List<StringName>::Element *E = sn.front(); E; E = E->next()) {
- master_anim_popup->add_item(E->get());
- }
-
- master_anim_popup->set_position(popup_pos);
- master_anim_popup->popup();
- } else {
- property_editor->edit(this, "", Variant::OBJECT, anim_tree->animation_node_get_animation(edited_node), PROPERTY_HINT_RESOURCE_TYPE, "Animation");
- property_editor->set_position(popup_pos);
- property_editor->popup();
- updating_edit = false;
- }
- return;
- case AnimationTreePlayer::NODE_TIMESCALE:
- edit_label[0]->set_text(TTR("Scale:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(rtos(anim_tree->timescale_node_get_scale(edited_node)));
- edit_line[0]->show();
- edit_dialog->set_size(Size2(150, 50));
- break;
- case AnimationTreePlayer::NODE_ONESHOT:
- edit_label[0]->set_text(TTR("Fade In (s):"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(rtos(anim_tree->oneshot_node_get_fadein_time(edited_node)));
- edit_line[0]->show();
- edit_label[1]->set_text(TTR("Fade Out (s):"));
- edit_label[1]->set_position(Point2(5, 55));
- edit_label[1]->show();
- edit_line[1]->set_begin(Point2(15, 75));
- edit_line[1]->set_text(rtos(anim_tree->oneshot_node_get_fadeout_time(edited_node)));
- edit_line[1]->show();
-
- edit_option->clear();
- edit_option->add_item(TTR("Blend"), 0);
- edit_option->add_item(TTR("Mix"), 1);
- edit_option->set_begin(Point2(15, 105));
-
- edit_option->select(anim_tree->oneshot_node_get_mix_mode(edited_node));
- edit_option->show();
-
- edit_check->set_text(TTR("Auto Restart:"));
- edit_check->set_begin(Point2(15, 125));
- edit_check->set_pressed(anim_tree->oneshot_node_has_autorestart(edited_node));
- edit_check->show();
-
- edit_label[2]->set_text(TTR("Restart (s):"));
- edit_label[2]->set_position(Point2(5, 145));
- edit_label[2]->show();
- edit_line[2]->set_begin(Point2(15, 165));
- edit_line[2]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_delay(edited_node)));
- edit_line[2]->show();
- edit_label[3]->set_text(TTR("Random Restart (s):"));
- edit_label[3]->set_position(Point2(5, 195));
- edit_label[3]->show();
- edit_line[3]->set_begin(Point2(15, 215));
- edit_line[3]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_random_delay(edited_node)));
- edit_line[3]->show();
-
- filter_button->set_begin(Point2(10, 245));
- filter_button->show();
-
- edit_button->set_begin(Point2(10, 268));
- edit_button->set_text(TTR("Start!"));
-
- edit_button->show();
-
- edit_dialog->set_size(Size2(180, 293));
-
- break;
-
- case AnimationTreePlayer::NODE_MIX:
-
- edit_label[0]->set_text(TTR("Amount:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->mix_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- edit_dialog->set_size(Size2(150, 50));
-
- break;
- case AnimationTreePlayer::NODE_BLEND2:
- edit_label[0]->set_text(TTR("Blend:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->blend2_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- filter_button->set_begin(Point2(10, 47));
- filter_button->show();
- edit_dialog->set_size(Size2(150, 74));
-
- break;
-
- case AnimationTreePlayer::NODE_BLEND3:
- edit_label[0]->set_text(TTR("Blend:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(-1);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->blend3_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- edit_dialog->set_size(Size2(150, 50));
-
- break;
- case AnimationTreePlayer::NODE_BLEND4:
-
- edit_label[0]->set_text(TTR("Blend 0:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->blend4_node_get_amount(edited_node).x);
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- edit_label[1]->set_text(TTR("Blend 1:"));
- edit_label[1]->set_position(Point2(5, 55));
- edit_label[1]->show();
- edit_scroll[1]->set_min(0);
- edit_scroll[1]->set_max(1);
- edit_scroll[1]->set_step(0.01);
- edit_scroll[1]->set_value(anim_tree->blend4_node_get_amount(edited_node).y);
- edit_scroll[1]->set_begin(Point2(15, 75));
- edit_scroll[1]->show();
- edit_dialog->set_size(Size2(150, 100));
-
- break;
-
- case AnimationTreePlayer::NODE_TRANSITION: {
-
- edit_label[0]->set_text(TTR("X-Fade Time (s):"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(rtos(anim_tree->transition_node_get_xfade_time(edited_node)));
- edit_line[0]->show();
-
- edit_label[1]->set_text(TTR("Current:"));
- edit_label[1]->set_position(Point2(5, 55));
- edit_label[1]->show();
- edit_option->set_begin(Point2(15, 75));
-
- edit_option->clear();
-
- for (int i = 0; i < anim_tree->transition_node_get_input_count(edited_node); i++) {
- edit_option->add_item(itos(i), i);
- }
-
- edit_option->select(anim_tree->transition_node_get_current(edited_node));
- edit_option->show();
- edit_dialog->set_size(Size2(150, 100));
-
- } break;
- default: {
- }
- }
- }
-
- edit_dialog->set_position(popup_pos);
- edit_dialog->popup();
-
- updating_edit = false;
-}
-
-void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
-
- RID ci = get_canvas_item();
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
- Color font_color = get_color("font_color", "PopupMenu");
- Color font_color_title = get_color("font_color_hover", "PopupMenu");
- font_color_title.a *= 0.8;
- Ref<Texture> slot_icon = get_icon("VisualShaderPort", "EditorIcons");
-
- Size2 size = get_node_size(p_node);
- Point2 pos = anim_tree->node_get_position(p_node);
- if (click_type == CLICK_NODE && click_node == p_node) {
-
- pos += click_motion - click_pos;
- if (pos.x < 5)
- pos.x = 5;
- if (pos.y < 5)
- pos.y = 5;
- }
-
- pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
-
- style->draw(ci, Rect2(pos, size));
-
- float w = size.width - style->get_minimum_size().width;
- float h = font->get_height() + get_constant("vseparation", "PopupMenu");
-
- Point2 ofs = style->get_offset() + pos;
- Point2 ascofs(0, font->get_ascent());
-
- Color bx = font_color_title;
- bx.a *= 0.1;
- draw_rect(Rect2(ofs, Size2(size.width - style->get_minimum_size().width, font->get_height())), bx);
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, String(_node_type_names[type]), font_color_title);
-
- ofs.y += h;
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, p_node, font_color);
- ofs.y += h;
-
- int inputs = anim_tree->node_get_input_count(p_node);
-
- float icon_h_ofs = Math::floor((font->get_height() - slot_icon->get_height()) / 2.0) + 1;
-
- if (type != AnimationTreePlayer::NODE_OUTPUT)
- slot_icon->draw(ci, ofs + Point2(w, icon_h_ofs)); //output
-
- if (inputs) {
- for (int i = 0; i < inputs; i++) {
-
- slot_icon->draw(ci, ofs + Point2(-slot_icon->get_width(), icon_h_ofs));
- String text;
- switch (type) {
-
- case AnimationTreePlayer::NODE_TIMESCALE:
- case AnimationTreePlayer::NODE_TIMESEEK: text = "in"; break;
- case AnimationTreePlayer::NODE_OUTPUT: text = "out"; break;
- case AnimationTreePlayer::NODE_ANIMATION: break;
- case AnimationTreePlayer::NODE_ONESHOT: text = (i == 0 ? "in" : "add"); break;
- case AnimationTreePlayer::NODE_BLEND2:
- case AnimationTreePlayer::NODE_MIX: text = (i == 0 ? "a" : "b"); break;
- case AnimationTreePlayer::NODE_BLEND3:
- switch (i) {
- case 0: text = "b-"; break;
- case 1: text = "a"; break;
- case 2: text = "b+"; break;
- }
- break;
-
- case AnimationTreePlayer::NODE_BLEND4:
- switch (i) {
- case 0: text = "a0"; break;
- case 1: text = "b0"; break;
- case 2: text = "a1"; break;
- case 3: text = "b1"; break;
- }
- break;
-
- case AnimationTreePlayer::NODE_TRANSITION:
- text = itos(i);
- if (anim_tree->transition_node_has_input_auto_advance(p_node, i))
- text += "->";
-
- break;
- default: {
- }
- }
- font->draw(ci, ofs + ascofs + Point2(3, 0), text, font_color);
-
- ofs.y += h;
- }
- } else {
- ofs.y += h;
- }
-
- Ref<StyleBox> pg_bg = get_stylebox("bg", "ProgressBar");
- Ref<StyleBox> pg_fill = get_stylebox("fill", "ProgressBar");
- Rect2 pg_rect(ofs, Size2(w, h));
-
- bool editable = true;
- switch (type) {
- case AnimationTreePlayer::NODE_ANIMATION: {
-
- Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
- String text;
- if (anim_tree->animation_node_get_master_animation(p_node) != "")
- text = anim_tree->animation_node_get_master_animation(p_node);
- else if (anim.is_null())
- text = "load...";
- else
- text = anim->get_name();
-
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, text, font_color_title);
-
- } break;
- case AnimationTreePlayer::NODE_ONESHOT:
- case AnimationTreePlayer::NODE_MIX:
- case AnimationTreePlayer::NODE_BLEND2:
- case AnimationTreePlayer::NODE_BLEND3:
- case AnimationTreePlayer::NODE_BLEND4:
- case AnimationTreePlayer::NODE_TIMESCALE:
- case AnimationTreePlayer::NODE_TRANSITION: {
-
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, "edit...", font_color_title);
- } break;
- default: editable = false;
- }
-
- if (editable) {
-
- Ref<Texture> arrow = get_icon("GuiDropdown", "EditorIcons");
- Point2 arrow_ofs(w - arrow->get_width(), Math::floor((h - arrow->get_height()) / 2));
- arrow->draw(ci, ofs + arrow_ofs);
- }
-}
-
-AnimationTreePlayerEditor::ClickType AnimationTreePlayerEditor::_locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const {
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
-
- float h = (font->get_height() + get_constant("vseparation", "PopupMenu"));
-
- for (const List<StringName>::Element *E = order.back(); E; E = E->prev()) {
-
- const StringName &node = E->get();
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(node);
-
- Point2 pos = anim_tree->node_get_position(node);
- Size2 size = get_node_size(node);
-
- pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
-
- if (!Rect2(pos, size).has_point(p_click))
- continue;
-
- if (p_node_id)
- *p_node_id = node;
-
- pos = p_click - pos;
-
- float y = pos.y - style->get_offset().height;
-
- if (y < 2 * h)
- return CLICK_NODE;
- y -= 2 * h;
-
- int inputs = anim_tree->node_get_input_count(node);
- int count = MAX(inputs, 1);
-
- if (inputs == 0 || (pos.x > size.width / 2 && type != AnimationTreePlayer::NODE_OUTPUT)) {
-
- if (y < count * h) {
-
- if (p_slot_index)
- *p_slot_index = 0;
- return CLICK_OUTPUT_SLOT;
- }
- }
-
- for (int i = 0; i < count; i++) {
-
- if (y < h) {
- if (p_slot_index)
- *p_slot_index = i;
- return CLICK_INPUT_SLOT;
- }
- y -= h;
- }
-
- bool has_parameters = type != AnimationTreePlayer::NODE_OUTPUT && type != AnimationTreePlayer::NODE_TIMESEEK;
- return has_parameters ? CLICK_PARAMETER : CLICK_NODE;
- }
-
- return CLICK_NONE;
-}
-
-Point2 AnimationTreePlayerEditor::_get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot) {
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
- Ref<Texture> slot_icon = get_icon("VisualShaderPort", "EditorIcons");
-
- Size2 size = get_node_size(p_node_id);
- Point2 pos = anim_tree->node_get_position(p_node_id);
-
- if (click_type == CLICK_NODE && click_node == p_node_id) {
-
- pos += click_motion - click_pos;
- if (pos.x < 5)
- pos.x = 5;
- if (pos.y < 5)
- pos.y = 5;
- }
-
- pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
-
- float w = size.width - style->get_minimum_size().width;
- float h = font->get_height() + get_constant("vseparation", "PopupMenu");
-
- pos += style->get_offset();
-
- pos.y += h * 2;
-
- pos.y += h * p_slot;
-
- pos += Point2(-slot_icon->get_width() / 2.0, h / 2.0).floor();
-
- if (!p_input) {
- pos.x += w + slot_icon->get_width();
- }
-
- return pos;
-}
-
-void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
-
- Ref<InputEventMouseButton> mb = p_event;
-
- if (mb.is_valid()) {
-
- if (mb->is_pressed()) {
-
- if (mb->get_button_index() == 1) {
- click_pos = Point2(mb->get_position().x, mb->get_position().y);
- click_motion = click_pos;
- click_type = _locate_click(click_pos, &click_node, &click_slot);
- if (click_type != CLICK_NONE) {
-
- order.erase(click_node);
- order.push_back(click_node);
- update();
- }
-
- switch (click_type) {
- case CLICK_INPUT_SLOT: {
- click_pos = _get_slot_pos(click_node, true, click_slot);
- } break;
- case CLICK_OUTPUT_SLOT: {
- click_pos = _get_slot_pos(click_node, false, click_slot);
- } break;
- case CLICK_PARAMETER: {
-
- edited_node = click_node;
- renaming_edit = false;
- _popup_edit_dialog();
- //open editor
- //_node_edit_property(click_node);
- } break;
- default: {
- }
- }
- }
- if (mb->get_button_index() == 2) {
-
- if (click_type != CLICK_NONE) {
- click_type = CLICK_NONE;
- update();
- } else {
- // try to disconnect/remove
-
- Point2 rclick_pos = Point2(mb->get_position().x, mb->get_position().y);
- rclick_type = _locate_click(rclick_pos, &rclick_node, &rclick_slot);
- if (rclick_type == CLICK_INPUT_SLOT || rclick_type == CLICK_OUTPUT_SLOT) {
-
- node_popup->clear();
- node_popup->set_size(Size2(1, 1));
- node_popup->add_item(TTR("Disconnect"), NODE_DISCONNECT);
- if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION) {
- node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT);
- if (rclick_type == CLICK_INPUT_SLOT) {
- if (anim_tree->transition_node_has_input_auto_advance(rclick_node, rclick_slot))
- node_popup->add_item(TTR("Clear Auto-Advance"), NODE_CLEAR_AUTOADVANCE);
- else
- node_popup->add_item(TTR("Set Auto-Advance"), NODE_SET_AUTOADVANCE);
- node_popup->add_item(TTR("Delete Input"), NODE_DELETE_INPUT);
- }
- }
-
- node_popup->set_position(rclick_pos + get_global_position());
- node_popup->popup();
- }
-
- if (rclick_type == CLICK_NODE) {
- node_popup->clear();
- node_popup->set_size(Size2(1, 1));
- node_popup->add_item(TTR("Rename"), NODE_RENAME);
- node_popup->add_item(TTR("Remove"), NODE_ERASE);
- if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION)
- node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT);
- node_popup->set_position(rclick_pos + get_global_position());
- node_popup->popup();
- }
- }
- }
- } else {
-
- if (mb->get_button_index() == 1 && click_type != CLICK_NONE) {
-
- switch (click_type) {
- case CLICK_INPUT_SLOT:
- case CLICK_OUTPUT_SLOT: {
-
- Point2 dst_click_pos = Point2(mb->get_position().x, mb->get_position().y);
- StringName id;
- int slot;
- ClickType dst_click_type = _locate_click(dst_click_pos, &id, &slot);
-
- if (dst_click_type == CLICK_INPUT_SLOT && click_type == CLICK_OUTPUT_SLOT) {
-
- anim_tree->connect_nodes(click_node, id, slot);
- }
- if (click_type == CLICK_INPUT_SLOT && dst_click_type == CLICK_OUTPUT_SLOT) {
-
- anim_tree->connect_nodes(id, click_node, click_slot);
- }
-
- } break;
- case CLICK_NODE: {
- Point2 new_pos = anim_tree->node_get_position(click_node) + (click_motion - click_pos);
- if (new_pos.x < 5)
- new_pos.x = 5;
- if (new_pos.y < 5)
- new_pos.y = 5;
- anim_tree->node_set_position(click_node, new_pos);
-
- } break;
- default: {
- }
- }
-
- click_type = CLICK_NONE;
- update();
- }
- }
- }
-
- Ref<InputEventMouseMotion> mm = p_event;
-
- if (mm.is_valid()) {
-
- if (mm->get_button_mask() & 1 && click_type != CLICK_NONE) {
-
- click_motion = Point2(mm->get_position().x, mm->get_position().y);
- update();
- }
- if (mm->get_button_mask() & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
-
- h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
- v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
- update();
- }
- }
-}
-
-void AnimationTreePlayerEditor::_draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color) {
-
- static const int steps = 20;
-
- Rect2 r;
- r.position = p_from;
- r.expand_to(p_to);
- Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1);
- bool flip = sign.x * sign.y < 0;
-
- Vector2 prev;
- for (int i = 0; i <= steps; i++) {
-
- float d = i / float(steps);
- float c = -Math::cos(d * Math_PI) * 0.5 + 0.5;
- if (flip)
- c = 1.0 - c;
- Vector2 p = r.position + Vector2(d * r.size.width, c * r.size.height);
-
- if (i > 0) {
-
- draw_line(prev, p, p_color, 2);
- }
-
- prev = p;
- }
-}
-
-void AnimationTreePlayerEditor::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- play_button->set_icon(get_icon("Play", "EditorIcons"));
- add_menu->set_icon(get_icon("Add", "EditorIcons"));
- } break;
- case NOTIFICATION_DRAW: {
-
- _update_scrollbars();
- //VisualServer::get_singleton()->canvas_item_add_rect(get_canvas_item(),Rect2(Point2(),get_size()),Color(0,0,0,1));
- get_stylebox("bg", "Tree")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
-
- for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
-
- _draw_node(E->get());
- }
-
- if (click_type == CLICK_INPUT_SLOT || click_type == CLICK_OUTPUT_SLOT) {
-
- _draw_cos_line(click_pos, click_motion, Color(0.5, 1, 0.5, 0.8));
- }
-
- List<AnimationTreePlayer::Connection> connections;
- anim_tree->get_connection_list(&connections);
-
- for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
-
- const AnimationTreePlayer::Connection &c = E->get();
- Point2 source = _get_slot_pos(c.src_node, false, 0);
- Point2 dest = _get_slot_pos(c.dst_node, true, c.dst_input);
- Color col = Color(1, 1, 0.5, 0.8);
- /*
- if (click_type==CLICK_NODE && click_node==c.src_node) {
-
- source+=click_motion-click_pos;
- }
-
- if (click_type==CLICK_NODE && click_node==c.dst_node) {
-
- dest+=click_motion-click_pos;
- }*/
-
- _draw_cos_line(source, dest, col);
- }
-
- switch (anim_tree->get_last_error()) {
-
- case AnimationTreePlayer::CONNECT_OK: {
-
- Ref<Font> f = get_font("font", "Label");
- f->draw(get_canvas_item(), Point2(5, 25 + f->get_ascent()), TTR("Animation tree is valid."), Color(0, 1, 0.6, 0.8));
- } break;
- default: {
-
- Ref<Font> f = get_font("font", "Label");
- f->draw(get_canvas_item(), Point2(5, 25 + f->get_ascent()), TTR("Animation tree is invalid."), Color(1, 0.6, 0.0, 0.8));
- } break;
- }
-
- } break;
- }
-}
-
-void AnimationTreePlayerEditor::_update_scrollbars() {
-
- Size2 size = get_size();
- Size2 hmin = h_scroll->get_combined_minimum_size();
- Size2 vmin = v_scroll->get_combined_minimum_size();
-
- v_scroll->set_begin(Point2(size.width - vmin.width, 0));
- v_scroll->set_end(Point2(size.width, size.height));
-
- h_scroll->set_begin(Point2(0, size.height - hmin.height));
- h_scroll->set_end(Point2(size.width - vmin.width, size.height));
-
- Size2 min = _get_maximum_size();
-
- if (min.height < size.height - hmin.height) {
-
- v_scroll->hide();
- offset.y = 0;
- } else {
-
- v_scroll->show();
- v_scroll->set_max(min.height);
- v_scroll->set_page(size.height - hmin.height);
- offset.y = v_scroll->get_value();
- }
-
- if (min.width < size.width - vmin.width) {
-
- h_scroll->hide();
- offset.x = 0;
- } else {
-
- h_scroll->show();
- h_scroll->set_max(min.width);
- h_scroll->set_page(size.width - vmin.width);
- offset.x = h_scroll->get_value();
- }
-}
-
-void AnimationTreePlayerEditor::_scroll_moved(float) {
-
- offset.x = h_scroll->get_value();
- offset.y = v_scroll->get_value();
- update();
-}
-
-void AnimationTreePlayerEditor::_node_menu_item(int p_item) {
-
- switch (p_item) {
-
- case NODE_DISCONNECT: {
-
- if (rclick_type == CLICK_INPUT_SLOT) {
-
- anim_tree->disconnect_nodes(rclick_node, rclick_slot);
- update();
- }
-
- if (rclick_type == CLICK_OUTPUT_SLOT) {
-
- List<AnimationTreePlayer::Connection> connections;
- anim_tree->get_connection_list(&connections);
-
- for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
-
- const AnimationTreePlayer::Connection &c = E->get();
- if (c.dst_node == rclick_node) {
-
- anim_tree->disconnect_nodes(c.dst_node, c.dst_input);
- }
- }
- update();
- }
-
- } break;
- case NODE_RENAME: {
-
- renaming_edit = true;
- edited_node = rclick_node;
- _popup_edit_dialog();
-
- } break;
- case NODE_ADD_INPUT: {
-
- anim_tree->transition_node_set_input_count(rclick_node, anim_tree->transition_node_get_input_count(rclick_node) + 1);
- update();
- } break;
- case NODE_DELETE_INPUT: {
-
- anim_tree->transition_node_delete_input(rclick_node, rclick_slot);
- update();
- } break;
- case NODE_SET_AUTOADVANCE: {
-
- anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, true);
- update();
-
- } break;
- case NODE_CLEAR_AUTOADVANCE: {
-
- anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, false);
- update();
-
- } break;
-
- case NODE_ERASE: {
-
- if (rclick_node == "out")
- break;
- order.erase(rclick_node);
- anim_tree->remove_node(rclick_node);
- update();
- } break;
- }
-}
-
-StringName AnimationTreePlayerEditor::_add_node(int p_item) {
-
- static const char *bname[] = {
- "out",
- "anim",
- "oneshot",
- "mix",
- "blend2",
- "blend3",
- "blend4",
- "scale",
- "seek",
- "transition"
- };
-
- String name;
- int idx = 1;
-
- while (true) {
-
- name = bname[p_item];
- if (idx > 1)
- name += " " + itos(idx);
- if (anim_tree->node_exists(name))
- idx++;
- else
- break;
- }
-
- anim_tree->add_node((AnimationTreePlayer::NodeType)p_item, name);
- anim_tree->node_set_position(name, Point2(last_x, last_y));
- order.push_back(name);
- last_x += 10;
- last_y += 10;
- last_x = last_x % (int)get_size().width;
- last_y = last_y % (int)get_size().height;
- update();
-
- return name;
-};
-
-void AnimationTreePlayerEditor::_file_dialog_selected(String p_path) {
-
- switch (file_op) {
-
- case MENU_IMPORT_ANIMATIONS: {
- Vector<String> files = file_dialog->get_selected_files();
-
- for (int i = 0; i < files.size(); i++) {
-
- StringName node = _add_node(AnimationTreePlayer::NODE_ANIMATION);
-
- RES anim = ResourceLoader::load(files[i]);
- anim_tree->animation_node_set_animation(node, anim);
- //anim_tree->node_set_name(node, files[i].get_file());
- };
- } break;
-
- default:
- break;
- };
-};
-
-void AnimationTreePlayerEditor::_add_menu_item(int p_item) {
-
- if (p_item == MENU_GRAPH_CLEAR) {
-
- //clear
- } else if (p_item == MENU_IMPORT_ANIMATIONS) {
-
- file_op = MENU_IMPORT_ANIMATIONS;
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- file_dialog->popup_centered_ratio();
-
- } else {
-
- _add_node(p_item);
- }
-}
-
-Size2 AnimationTreePlayerEditor::get_minimum_size() const {
-
- return Size2(10, 200);
-}
-
-void AnimationTreePlayerEditor::_find_paths_for_filter(const StringName &p_node, Set<String> &paths) {
-
- ERR_FAIL_COND(!anim_tree->node_exists(p_node));
-
- for (int i = 0; i < anim_tree->node_get_input_count(p_node); i++) {
-
- StringName port = anim_tree->node_get_input_source(p_node, i);
- if (port == StringName())
- continue;
- _find_paths_for_filter(port, paths);
- }
-
- if (anim_tree->node_get_type(p_node) == AnimationTreePlayer::NODE_ANIMATION) {
-
- Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
- if (anim.is_valid()) {
-
- for (int i = 0; i < anim->get_track_count(); i++) {
- paths.insert(anim->track_get_path(i));
- }
- }
- }
-}
-
-void AnimationTreePlayerEditor::_filter_edited() {
-
- TreeItem *ed = filter->get_edited();
- if (!ed)
- return;
-
- if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ONESHOT) {
- anim_tree->oneshot_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_BLEND2) {
- anim_tree->blend2_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ANIMATION) {
- anim_tree->animation_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
- }
-}
-
-void AnimationTreePlayerEditor::_edit_filters() {
-
- filter_dialog->popup_centered_ratio();
- filter->clear();
-
- Set<String> npb;
- _find_paths_for_filter(edited_node, npb);
-
- TreeItem *root = filter->create_item();
- filter->set_hide_root(true);
- Map<String, TreeItem *> pm;
-
- Node *base = anim_tree->get_node(anim_tree->get_base_path());
-
- for (Set<String>::Element *E = npb.front(); E; E = E->next()) {
-
- TreeItem *parent = root;
- String descr = E->get();
- if (base) {
- NodePath np = E->get();
-
- if (np.get_subname_count() == 1) {
- Node *n = base->get_node(np);
- Skeleton *s = Object::cast_to<Skeleton>(n);
- if (s) {
-
- String skelbase = E->get().substr(0, E->get().find(":"));
-
- int bidx = s->find_bone(np.get_subname(0));
-
- if (bidx != -1) {
- int bparent = s->get_bone_parent(bidx);
- //
- if (bparent != -1) {
-
- String bpn = skelbase + ":" + s->get_bone_name(bparent);
- if (pm.has(bpn)) {
- parent = pm[bpn];
- descr = np.get_subname(0);
- }
- } else {
-
- if (pm.has(skelbase)) {
- parent = pm[skelbase];
- }
- }
- }
- }
- }
- }
-
- TreeItem *it = filter->create_item(parent);
- it->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
- it->set_text(0, descr);
- it->set_metadata(0, NodePath(E->get()));
- it->set_editable(0, true);
- if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ONESHOT) {
- it->set_checked(0, anim_tree->oneshot_node_is_path_filtered(edited_node, E->get()));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_BLEND2) {
- it->set_checked(0, anim_tree->blend2_node_is_path_filtered(edited_node, E->get()));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ANIMATION) {
- it->set_checked(0, anim_tree->animation_node_is_path_filtered(edited_node, E->get()));
- }
- pm[E->get()] = it;
- }
-}
-
-void AnimationTreePlayerEditor::_bind_methods() {
-
- ClassDB::bind_method("_add_menu_item", &AnimationTreePlayerEditor::_add_menu_item);
- ClassDB::bind_method("_node_menu_item", &AnimationTreePlayerEditor::_node_menu_item);
- ClassDB::bind_method("_gui_input", &AnimationTreePlayerEditor::_gui_input);
- //ClassDB::bind_method( "_node_param_changed", &AnimationTreeEditor::_node_param_changed );
- ClassDB::bind_method("_scroll_moved", &AnimationTreePlayerEditor::_scroll_moved);
- ClassDB::bind_method("_edit_dialog_changeds", &AnimationTreePlayerEditor::_edit_dialog_changeds);
- ClassDB::bind_method("_edit_dialog_changede", &AnimationTreePlayerEditor::_edit_dialog_changede);
- ClassDB::bind_method("_edit_dialog_changedf", &AnimationTreePlayerEditor::_edit_dialog_changedf);
- ClassDB::bind_method("_edit_dialog_changed", &AnimationTreePlayerEditor::_edit_dialog_changed);
- ClassDB::bind_method("_edit_dialog_animation_changed", &AnimationTreePlayerEditor::_edit_dialog_animation_changed);
- ClassDB::bind_method("_edit_dialog_edit_animation", &AnimationTreePlayerEditor::_edit_dialog_edit_animation);
- ClassDB::bind_method("_play_toggled", &AnimationTreePlayerEditor::_play_toggled);
- ClassDB::bind_method("_edit_oneshot_start", &AnimationTreePlayerEditor::_edit_oneshot_start);
- ClassDB::bind_method("_file_dialog_selected", &AnimationTreePlayerEditor::_file_dialog_selected);
- ClassDB::bind_method("_master_anim_menu_item", &AnimationTreePlayerEditor::_master_anim_menu_item);
- ClassDB::bind_method("_edit_filters", &AnimationTreePlayerEditor::_edit_filters);
- ClassDB::bind_method("_filter_edited", &AnimationTreePlayerEditor::_filter_edited);
-}
-
-AnimationTreePlayerEditor::AnimationTreePlayerEditor() {
-
- set_focus_mode(FOCUS_ALL);
-
- PopupMenu *p;
- List<PropertyInfo> defaults;
-
- add_menu = memnew(MenuButton);
- //add_menu->set_
- add_menu->set_position(Point2(0, 0));
- add_menu->set_size(Point2(25, 15));
- add_child(add_menu);
-
- p = add_menu->get_popup();
- p->add_item(TTR("Animation Node"), AnimationTreePlayer::NODE_ANIMATION);
- p->add_item(TTR("OneShot Node"), AnimationTreePlayer::NODE_ONESHOT);
- p->add_item(TTR("Mix Node"), AnimationTreePlayer::NODE_MIX);
- p->add_item(TTR("Blend2 Node"), AnimationTreePlayer::NODE_BLEND2);
- p->add_item(TTR("Blend3 Node"), AnimationTreePlayer::NODE_BLEND3);
- p->add_item(TTR("Blend4 Node"), AnimationTreePlayer::NODE_BLEND4);
- p->add_item(TTR("TimeScale Node"), AnimationTreePlayer::NODE_TIMESCALE);
- p->add_item(TTR("TimeSeek Node"), AnimationTreePlayer::NODE_TIMESEEK);
- p->add_item(TTR("Transition Node"), AnimationTreePlayer::NODE_TRANSITION);
- p->add_separator();
- p->add_item(TTR("Import Animations..."), MENU_IMPORT_ANIMATIONS); // wtf
- p->add_separator();
- p->add_item(TTR("Clear"), MENU_GRAPH_CLEAR);
-
- p->connect("id_pressed", this, "_add_menu_item");
-
- play_button = memnew(Button);
- play_button->set_position(Point2(25, 0));
- play_button->set_size(Point2(25, 15));
- add_child(play_button);
- play_button->set_toggle_mode(true);
- play_button->connect("pressed", this, "_play_toggled");
-
- last_x = 50;
- last_y = 50;
-
- property_editor = memnew(CustomPropertyEditor);
- add_child(property_editor);
- property_editor->connect("variant_changed", this, "_edit_dialog_animation_changed");
- property_editor->connect("resource_edit_request", this, "_edit_dialog_edit_animation");
-
- h_scroll = memnew(HScrollBar);
- v_scroll = memnew(VScrollBar);
-
- add_child(h_scroll);
- add_child(v_scroll);
-
- h_scroll->connect("value_changed", this, "_scroll_moved");
- v_scroll->connect("value_changed", this, "_scroll_moved");
-
- node_popup = memnew(PopupMenu);
- add_child(node_popup);
- node_popup->set_as_toplevel(true);
-
- master_anim_popup = memnew(PopupMenu);
- add_child(master_anim_popup);
- master_anim_popup->connect("id_pressed", this, "_master_anim_menu_item");
-
- node_popup->connect("id_pressed", this, "_node_menu_item");
-
- updating_edit = false;
-
- edit_dialog = memnew(PopupPanel);
- //edit_dialog->get_ok()->hide();
- //edit_dialog->get_cancel()->hide();
- add_child(edit_dialog);
-
- edit_option = memnew(OptionButton);
- edit_option->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_option->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_option);
- edit_option->connect("item_selected", this, "_edit_dialog_changedf");
- edit_option->hide();
-
- for (int i = 0; i < 2; i++) {
- edit_scroll[i] = memnew(HSlider);
- edit_scroll[i]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_scroll[i]->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_scroll[i]);
- edit_scroll[i]->hide();
- edit_scroll[i]->connect("value_changed", this, "_edit_dialog_changedf");
- }
- for (int i = 0; i < 4; i++) {
- edit_line[i] = memnew(LineEdit);
- edit_line[i]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_line[i]->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_line[i]);
- edit_line[i]->hide();
- edit_line[i]->connect("text_changed", this, "_edit_dialog_changeds");
- edit_line[i]->connect("text_entered", this, "_edit_dialog_changede");
- edit_label[i] = memnew(Label);
- edit_dialog->add_child(edit_label[i]);
- edit_label[i]->hide();
- }
-
- edit_button = memnew(Button);
- edit_button->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_button->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_button);
- edit_button->hide();
- edit_button->connect("pressed", this, "_edit_oneshot_start");
-
- edit_check = memnew(CheckButton);
- edit_check->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_check->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_check);
- edit_check->hide();
- edit_check->connect("pressed", this, "_edit_dialog_changed");
-
- file_dialog = memnew(EditorFileDialog);
- file_dialog->set_enable_multiple_selection(true);
- file_dialog->set_current_dir(ProjectSettings::get_singleton()->get_resource_path());
- add_child(file_dialog);
- file_dialog->connect("file_selected", this, "_file_dialog_selected");
-
- filter_dialog = memnew(AcceptDialog);
- filter_dialog->set_title(TTR("Edit Node Filters"));
- add_child(filter_dialog);
-
- filter = memnew(Tree);
- filter_dialog->add_child(filter);
- //filter_dialog->set_child_rect(filter);
- filter->connect("item_edited", this, "_filter_edited");
-
- filter_button = memnew(Button);
- filter_button->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- filter_button->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(filter_button);
- filter_button->hide();
- filter_button->set_text(TTR("Filters..."));
- filter_button->connect("pressed", this, "_edit_filters");
-
- set_clip_contents(true);
-}
-
-void AnimationTreePlayerEditorPlugin::edit(Object *p_object) {
-
- anim_tree_editor->edit(Object::cast_to<AnimationTreePlayer>(p_object));
-}
-
-bool AnimationTreePlayerEditorPlugin::handles(Object *p_object) const {
-
- return p_object->is_class("AnimationTreePlayer");
-}
-
-void AnimationTreePlayerEditorPlugin::make_visible(bool p_visible) {
-
- if (p_visible) {
- //editor->hide_animation_player_editors();
- //editor->animation_panel_make_visible(true);
- button->show();
- editor->make_bottom_panel_item_visible(anim_tree_editor);
- anim_tree_editor->set_physics_process(true);
- } else {
-
- if (anim_tree_editor->is_visible_in_tree())
- editor->hide_bottom_panel();
- button->hide();
- anim_tree_editor->set_physics_process(false);
- }
-}
-
-AnimationTreePlayerEditorPlugin::AnimationTreePlayerEditorPlugin(EditorNode *p_node) {
-
- editor = p_node;
- anim_tree_editor = memnew(AnimationTreePlayerEditor);
- anim_tree_editor->set_custom_minimum_size(Size2(0, 300));
-
- button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor);
- button->hide();
-}
-
-AnimationTreePlayerEditorPlugin::~AnimationTreePlayerEditorPlugin() {
-}
diff --git a/editor/plugins/animation_tree_player_editor_plugin.h b/editor/plugins/animation_tree_player_editor_plugin.h
deleted file mode 100644
index 03bc559b86..0000000000
--- a/editor/plugins/animation_tree_player_editor_plugin.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*************************************************************************/
-/* animation_tree_player_editor_plugin.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H
-#define ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H
-
-#include "editor/editor_node.h"
-#include "editor/editor_plugin.h"
-#include "editor/property_editor.h"
-#include "scene/animation/animation_tree_player.h"
-#include "scene/gui/button.h"
-#include "scene/gui/popup.h"
-#include "scene/gui/tree.h"
-
-class AnimationTreePlayerEditor : public Control {
-
- GDCLASS(AnimationTreePlayerEditor, Control);
-
- static const char *_node_type_names[];
-
- enum ClickType {
- CLICK_NONE,
- CLICK_NAME,
- CLICK_NODE,
- CLICK_INPUT_SLOT,
- CLICK_OUTPUT_SLOT,
- CLICK_PARAMETER
- };
-
- enum {
-
- MENU_GRAPH_CLEAR = 100,
- MENU_IMPORT_ANIMATIONS = 101,
- NODE_DISCONNECT,
- NODE_RENAME,
- NODE_ERASE,
- NODE_ADD_INPUT,
- NODE_DELETE_INPUT,
- NODE_SET_AUTOADVANCE,
- NODE_CLEAR_AUTOADVANCE
- };
-
- bool renaming_edit;
- StringName edited_node;
- bool updating_edit;
- Popup *edit_dialog;
- HSlider *edit_scroll[2];
- LineEdit *edit_line[4];
- OptionButton *edit_option;
- Label *edit_label[4];
- Button *edit_button;
- Button *filter_button;
- CheckButton *edit_check;
- EditorFileDialog *file_dialog;
- int file_op;
-
- void _popup_edit_dialog();
-
- void _setup_edit_dialog(const StringName &p_node);
- PopupMenu *master_anim_popup;
- PopupMenu *node_popup;
- PopupMenu *add_popup;
- HScrollBar *h_scroll;
- VScrollBar *v_scroll;
- MenuButton *add_menu;
-
- CustomPropertyEditor *property_editor;
-
- AnimationTreePlayer *anim_tree;
- List<StringName> order;
- Set<StringName> active_nodes;
-
- int last_x, last_y;
-
- Point2 offset;
- ClickType click_type;
- Point2 click_pos;
- StringName click_node;
- int click_slot;
- Point2 click_motion;
- ClickType rclick_type;
- StringName rclick_node;
- int rclick_slot;
-
- Button *play_button;
-
- Size2 _get_maximum_size();
- Size2 get_node_size(const StringName &p_node) const;
- void _draw_node(const StringName &p_node);
-
- AcceptDialog *filter_dialog;
- Tree *filter;
-
- void _draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color);
- void _update_scrollbars();
- void _scroll_moved(float);
- void _play_toggled();
- /*
- void _node_param_changed();
- void _node_add_callback();
- void _node_add(VisualServer::AnimationTreeNodeType p_type);
- void _node_edit_property(const StringName& p_node);
-*/
-
- void _master_anim_menu_item(int p_item);
- void _node_menu_item(int p_item);
- void _add_menu_item(int p_item);
-
- void _filter_edited();
- void _find_paths_for_filter(const StringName &p_node, Set<String> &paths);
- void _edit_filters();
-
- void _edit_oneshot_start();
- void _edit_dialog_animation_changed();
- void _edit_dialog_edit_animation();
- void _edit_dialog_changeds(String);
- void _edit_dialog_changede(String);
- void _edit_dialog_changedf(float);
- void _edit_dialog_changed();
- void _dialog_changed() const;
- ClickType _locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const;
- Point2 _get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot);
-
- StringName _add_node(int p_item);
- void _file_dialog_selected(String p_path);
-
-protected:
- void _notification(int p_what);
- void _gui_input(Ref<InputEvent> p_event);
- static void _bind_methods();
-
-public:
- virtual Size2 get_minimum_size() const;
- void edit(AnimationTreePlayer *p_anim_tree);
- AnimationTreePlayerEditor();
-};
-
-class AnimationTreePlayerEditorPlugin : public EditorPlugin {
-
- GDCLASS(AnimationTreePlayerEditorPlugin, EditorPlugin);
-
- AnimationTreePlayerEditor *anim_tree_editor;
- EditorNode *editor;
- Button *button;
-
-public:
- virtual String get_name() const { return "AnimTree"; }
- bool has_main_screen() const { return false; }
- virtual void edit(Object *p_object);
- virtual bool handles(Object *p_object) const;
- virtual void make_visible(bool p_visible);
-
- AnimationTreePlayerEditorPlugin(EditorNode *p_node);
- ~AnimationTreePlayerEditorPlugin();
-};
-
-#endif // ANIMATION_TREE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 95767a96d8..01c3c33995 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,9 +31,13 @@
#include "asset_library_editor_plugin.h"
#include "core/io/json.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
#include "core/version.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/project_settings_editor.h"
void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) {
@@ -46,7 +50,7 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co
price->set_text(p_cost);
}
-void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture> &p_image) {
+void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) {
ERR_FAIL_COND(p_type != EditorAssetLibrary::IMAGE_QUEUE_ICON);
ERR_FAIL_COND(p_index != 0);
@@ -108,7 +112,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
icon = memnew(TextureButton);
icon->set_custom_minimum_size(Size2(64, 64) * EDSCALE);
icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
- icon->connect("pressed", this, "_asset_clicked");
+ icon->connect_compat("pressed", this, "_asset_clicked");
hb->add_child(icon);
@@ -119,17 +123,17 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
title = memnew(LinkButton);
title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- title->connect("pressed", this, "_asset_clicked");
+ title->connect_compat("pressed", this, "_asset_clicked");
vb->add_child(title);
category = memnew(LinkButton);
category->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- category->connect("pressed", this, "_category_clicked");
+ category->connect_compat("pressed", this, "_category_clicked");
vb->add_child(category);
author = memnew(LinkButton);
author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- author->connect("pressed", this, "_author_clicked");
+ author->connect_compat("pressed", this, "_author_clicked");
vb->add_child(author);
price = memnew(Label);
@@ -137,13 +141,11 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
set_custom_minimum_size(Size2(250, 100) * EDSCALE);
set_h_size_flags(SIZE_EXPAND_FILL);
-
- set_mouse_filter(MOUSE_FILTER_PASS);
}
//////////////////////////////////////////////////////////////////////////////
-void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture> &p_image) {
+void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) {
switch (p_type) {
@@ -160,13 +162,12 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
Ref<Image> overlay = get_icon("PlayOverlay", "EditorIcons")->get_data();
Ref<Image> thumbnail = p_image->get_data();
thumbnail = thumbnail->duplicate();
- Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width() / 2) / 2, (thumbnail->get_height() - overlay->get_height() / 2) / 2);
+ Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2);
// Overlay and thumbnail need the same format for `blend_rect` to work.
thumbnail->convert(Image::FORMAT_RGBA8);
- thumbnail->lock();
+
thumbnail->blend_rect(overlay, overlay->get_used_rect(), overlay_pos);
- thumbnail->unlock();
Ref<ImageTexture> tex;
tex.instance();
@@ -262,7 +263,7 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons
preview.button->set_flat(true);
preview.button->set_icon(get_icon("ThumbnailWait", "EditorIcons"));
preview.button->set_toggle_mode(true);
- preview.button->connect("pressed", this, "_preview_click", varray(p_id));
+ preview.button->connect_compat("pressed", this, "_preview_click", varray(p_id));
preview_hb->add_child(preview.button);
if (!p_video) {
preview.image = get_icon("ThumbnailWait", "EditorIcons");
@@ -289,7 +290,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
description = memnew(RichTextLabel);
desc_vbox->add_child(description);
description->set_v_size_flags(SIZE_EXPAND_FILL);
- description->connect("meta_clicked", this, "_link_click");
+ description->connect_compat("meta_clicked", this, "_link_click");
description->add_constant_override("line_separation", Math::round(5 * EDSCALE));
VBoxContainer *previews_vbox = memnew(VBoxContainer);
@@ -320,7 +321,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
}
///////////////////////////////////////////////////////////////////////////////////
-void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {
+void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
String error_text;
@@ -391,7 +392,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int
set_process(false);
}
-void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash) {
+void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash) {
title->set_text(p_title);
icon->set_texture(p_preview);
@@ -433,7 +434,10 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
String::humanize_size(download->get_body_size())));
} else {
// Total file size is unknown, so it cannot be displayed.
- status->set_text(TTR("Downloading..."));
+ progress->set_modulate(Color(0, 0, 0, 0));
+ status->set_text(vformat(
+ TTR("Downloading...") + " (%s)",
+ String::humanize_size(download->get_downloaded_bytes())));
}
}
@@ -522,7 +526,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
title->set_h_size_flags(SIZE_EXPAND_FILL);
dismiss = memnew(TextureButton);
- dismiss->connect("pressed", this, "_close");
+ dismiss->connect_compat("pressed", this, "_close");
title_hb->add_child(dismiss);
title->set_clip_text(true);
@@ -542,11 +546,11 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
install = memnew(Button);
install->set_text(TTR("Install..."));
install->set_disabled(true);
- install->connect("pressed", this, "_install");
+ install->connect_compat("pressed", this, "_install");
retry = memnew(Button);
retry->set_text(TTR("Retry"));
- retry->connect("pressed", this, "_make_request");
+ retry->connect_compat("pressed", this, "_make_request");
hb2->add_child(retry);
hb2->add_child(install);
@@ -554,7 +558,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
download = memnew(HTTPRequest);
add_child(download);
- download->connect("request_completed", this, "_http_download_completed");
+ download->connect_compat("request_completed", this, "_http_download_completed");
download->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
download_error = memnew(AcceptDialog);
@@ -563,7 +567,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
asset_installer = memnew(EditorAssetInstaller);
add_child(asset_installer);
- asset_installer->connect("confirmed", this, "_close");
+ asset_installer->connect_compat("confirmed", this, "_close");
prev_status = -1;
@@ -617,6 +621,21 @@ void EditorAssetLibrary::_notification(int p_what) {
}
}
+void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) {
+
+ const Ref<InputEventKey> key = p_event;
+
+ if (key.is_valid() && key->is_pressed()) {
+
+ if (key->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) {
+
+ filter->grab_focus();
+ filter->select_all();
+ accept_event();
+ }
+ }
+}
+
void EditorAssetLibrary::_install_asset() {
ERR_FAIL_COND(!description);
@@ -638,7 +657,7 @@ void EditorAssetLibrary::_install_asset() {
if (templates_only) {
download->set_external_install(true);
- download->connect("install_asset", this, "_install_external_asset");
+ download->connect_compat("install_asset", this, "_install_external_asset");
}
}
@@ -652,12 +671,12 @@ const char *EditorAssetLibrary::sort_key[SORT_MAX] = {
};
const char *EditorAssetLibrary::sort_text[SORT_MAX] = {
- "Recently Updated",
- "Least Recently Updated",
- "Name (A-Z)",
- "Name (Z-A)",
- "License (A-Z)", // "cost" stores the SPDX license name in the Godot Asset Library.
- "License (Z-A)", // "cost" stores the SPDX license name in the Godot Asset Library.
+ TTRC("Recently Updated"),
+ TTRC("Least Recently Updated"),
+ TTRC("Name (A-Z)"),
+ TTRC("Name (Z-A)"),
+ TTRC("License (A-Z)"), // "cost" stores the SPDX license name in the Godot Asset Library.
+ TTRC("License (Z-A)"), // "cost" stores the SPDX license name in the Godot Asset Library.
};
const char *EditorAssetLibrary::support_key[SUPPORT_MAX] = {
@@ -690,12 +709,12 @@ void EditorAssetLibrary::_select_asset(int p_id) {
_api_request("asset/" + itos(p_id), REQUESTING_ASSET);
}
-void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByteArray &p_data, int p_queue_id) {
+void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedByteArray &p_data, int p_queue_id) {
Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target);
if (obj) {
bool image_set = false;
- PoolByteArray image_data = p_data;
+ PackedByteArray image_data = p_data;
if (use_cache) {
String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text());
@@ -703,12 +722,12 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt
FileAccess *file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ);
if (file) {
- PoolByteArray cached_data;
+ PackedByteArray cached_data;
int len = file->get_32();
cached_data.resize(len);
- PoolByteArray::Write w = cached_data.write();
- file->get_buffer(w.ptr(), len);
+ uint8_t *w = cached_data.ptrw();
+ file->get_buffer(w, len);
image_data = cached_data;
file->close();
@@ -717,17 +736,17 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt
}
int len = image_data.size();
- PoolByteArray::Read r = image_data.read();
+ const uint8_t *r = image_data.ptr();
Ref<Image> image = Ref<Image>(memnew(Image));
uint8_t png_signature[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
uint8_t jpg_signature[3] = { 255, 216, 255 };
- if (r.ptr()) {
- if (memcmp(&r[0], &png_signature[0], 8) == 0) {
- image->copy_internals_from(Image::_png_mem_loader_func(r.ptr(), len));
- } else if (memcmp(&r[0], &jpg_signature[0], 3) == 0) {
- image->copy_internals_from(Image::_jpg_mem_loader_func(r.ptr(), len));
+ if (r) {
+ if ((memcmp(&r[0], &png_signature[0], 8) == 0) && Image::_png_mem_loader_func) {
+ image->copy_internals_from(Image::_png_mem_loader_func(r, len));
+ } else if ((memcmp(&r[0], &jpg_signature[0], 3) == 0) && Image::_jpg_mem_loader_func) {
+ image->copy_internals_from(Image::_jpg_mem_loader_func(r, len));
}
}
@@ -770,7 +789,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt
}
}
-void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data, int p_queue_id) {
+void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data, int p_queue_id) {
ERR_FAIL_COND(!image_queue.has(p_queue_id));
@@ -791,11 +810,11 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
}
int len = p_data.size();
- PoolByteArray::Read r = p_data.read();
+ const uint8_t *r = p_data.ptr();
file = FileAccess::open(cache_filename_base + ".data", FileAccess::WRITE);
if (file) {
file->store_32(len);
- file->store_buffer(r.ptr(), len);
+ file->store_buffer(r, len);
file->close();
memdelete(file);
}
@@ -807,7 +826,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
_image_update(p_code == HTTPClient::RESPONSE_NOT_MODIFIED, true, p_data, p_queue_id);
} else {
- WARN_PRINTS("Error getting image file from URL: " + image_queue[p_queue_id].image_url);
+ WARN_PRINT("Error getting image file from URL: " + image_queue[p_queue_id].image_url);
Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target);
if (obj) {
obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_icon("FileBrokenBigThumb", "EditorIcons"));
@@ -873,13 +892,13 @@ void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, Imag
iq.queue_id = ++last_queue_id;
iq.active = false;
- iq.request->connect("request_completed", this, "_image_request_completed", varray(iq.queue_id));
+ iq.request->connect_compat("request_completed", this, "_image_request_completed", varray(iq.queue_id));
image_queue[iq.queue_id] = iq;
add_child(iq.request);
- _image_update(true, false, PoolByteArray(), iq.queue_id);
+ _image_update(true, false, PackedByteArray(), iq.queue_id);
_update_image_queue();
}
@@ -972,7 +991,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
Button *first = memnew(Button);
first->set_text(TTR("First"));
if (p_page != 0) {
- first->connect("pressed", this, "_search", varray(0));
+ first->connect_compat("pressed", this, "_search", varray(0));
} else {
first->set_disabled(true);
first->set_focus_mode(Control::FOCUS_NONE);
@@ -982,7 +1001,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
Button *prev = memnew(Button);
prev->set_text(TTR("Previous"));
if (p_page > 0) {
- prev->connect("pressed", this, "_search", varray(p_page - 1));
+ prev->connect_compat("pressed", this, "_search", varray(p_page - 1));
} else {
prev->set_disabled(true);
prev->set_focus_mode(Control::FOCUS_NONE);
@@ -1004,7 +1023,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
Button *current = memnew(Button);
current->set_text(itos(i + 1));
- current->connect("pressed", this, "_search", varray(i));
+ current->connect_compat("pressed", this, "_search", varray(i));
hbc->add_child(current);
}
@@ -1013,7 +1032,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
Button *next = memnew(Button);
next->set_text(TTR("Next"));
if (p_page < p_page_count - 1) {
- next->connect("pressed", this, "_search", varray(p_page + 1));
+ next->connect_compat("pressed", this, "_search", varray(p_page + 1));
} else {
next->set_disabled(true);
next->set_focus_mode(Control::FOCUS_NONE);
@@ -1024,7 +1043,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
Button *last = memnew(Button);
last->set_text(TTR("Last"));
if (p_page != p_page_count - 1) {
- last->connect("pressed", this, "_search", varray(p_page_count - 1));
+ last->connect_compat("pressed", this, "_search", varray(p_page_count - 1));
} else {
last->set_disabled(true);
last->set_focus_mode(Control::FOCUS_NONE);
@@ -1048,14 +1067,14 @@ void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_req
request->request(host + "/" + p_request + p_arguments);
}
-void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {
+void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
String str;
{
int datalen = p_data.size();
- PoolByteArray::Read r = p_data.read();
- str.parse_utf8((const char *)r.ptr(), datalen);
+ const uint8_t *r = p_data.ptr();
+ str.parse_utf8((const char *)r, datalen);
}
bool error_abort = true;
@@ -1210,9 +1229,9 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
EditorAssetLibraryItem *item = memnew(EditorAssetLibraryItem);
asset_items->add_child(item);
item->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"]);
- item->connect("asset_selected", this, "_select_asset");
- item->connect("author_selected", this, "_select_author");
- item->connect("category_selected", this, "_select_category");
+ item->connect_compat("asset_selected", this, "_select_asset");
+ item->connect_compat("author_selected", this, "_select_author");
+ item->connect_compat("category_selected", this, "_select_category");
if (r.has("icon_url") && r["icon_url"] != "") {
_request_image(item->get_instance_id(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
@@ -1243,7 +1262,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
description = memnew(EditorAssetLibraryItemDescription);
add_child(description);
description->popup_centered_minsize();
- description->connect("confirmed", this, "_install_asset");
+ description->connect_compat("confirmed", this, "_install_asset");
description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]);
@@ -1317,6 +1336,7 @@ void EditorAssetLibrary::disable_community_support() {
void EditorAssetLibrary::_bind_methods() {
+ ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input);
ClassDB::bind_method("_http_request_completed", &EditorAssetLibrary::_http_request_completed);
ClassDB::bind_method("_select_asset", &EditorAssetLibrary::_select_asset);
ClassDB::bind_method("_select_author", &EditorAssetLibrary::_select_author);
@@ -1354,9 +1374,9 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
filter = memnew(LineEdit);
search_hb->add_child(filter);
filter->set_h_size_flags(SIZE_EXPAND_FILL);
- filter->connect("text_entered", this, "_search_text_entered");
+ filter->connect_compat("text_entered", this, "_search_text_entered");
search = memnew(Button(TTR("Search")));
- search->connect("pressed", this, "_search");
+ search->connect_compat("pressed", this, "_search");
search_hb->add_child(search);
if (!p_templates_only)
@@ -1365,12 +1385,12 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
Button *open_asset = memnew(Button);
open_asset->set_text(TTR("Import..."));
search_hb->add_child(open_asset);
- open_asset->connect("pressed", this, "_asset_open");
+ open_asset->connect_compat("pressed", this, "_asset_open");
Button *plugins = memnew(Button);
plugins->set_text(TTR("Plugins..."));
search_hb->add_child(plugins);
- plugins->connect("pressed", this, "_manage_plugins");
+ plugins->connect_compat("pressed", this, "_manage_plugins");
if (p_templates_only) {
open_asset->hide();
@@ -1383,13 +1403,13 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(memnew(Label(TTR("Sort:") + " ")));
sort = memnew(OptionButton);
for (int i = 0; i < SORT_MAX; i++) {
- sort->add_item(sort_text[i]);
+ sort->add_item(TTRGET(sort_text[i]));
}
search_hb2->add_child(sort);
sort->set_h_size_flags(SIZE_EXPAND_FILL);
- sort->connect("item_selected", this, "_rerun_search");
+ sort->connect_compat("item_selected", this, "_rerun_search");
search_hb2->add_child(memnew(VSeparator));
@@ -1398,7 +1418,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
categories->add_item(TTR("All"));
search_hb2->add_child(categories);
categories->set_h_size_flags(SIZE_EXPAND_FILL);
- categories->connect("item_selected", this, "_rerun_search");
+ categories->connect_compat("item_selected", this, "_rerun_search");
search_hb2->add_child(memnew(VSeparator));
@@ -1410,7 +1430,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
repository->add_item("localhost");
repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api");
- repository->connect("item_selected", this, "_repository_changed");
+ repository->connect_compat("item_selected", this, "_repository_changed");
search_hb2->add_child(repository);
repository->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1425,7 +1445,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
support->get_popup()->add_check_item(TTR("Testing"), SUPPORT_TESTING);
support->get_popup()->set_item_checked(SUPPORT_OFFICIAL, true);
support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, true);
- support->get_popup()->connect("id_pressed", this, "_support_toggled");
+ support->get_popup()->connect_compat("id_pressed", this, "_support_toggled");
/////////
@@ -1450,7 +1470,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_scroll->add_child(library_vb_border);
library_vb_border->add_style_override("panel", border2);
library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL);
- library_vb_border->set_mouse_filter(MOUSE_FILTER_PASS);
library_vb = memnew(VBoxContainer);
library_vb->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1482,7 +1501,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
request = memnew(HTTPRequest);
add_child(request);
request->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
- request->connect("request_completed", this, "_http_request_completed");
+ request->connect_compat("request_completed", this, "_http_request_completed");
last_queue_id = 0;
@@ -1494,11 +1513,13 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
error_label->add_color_override("color", get_color("error_color", "Editor"));
error_hb->add_child(error_label);
error_tr = memnew(TextureRect);
+ error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
error_hb->add_child(error_tr);
description = NULL;
set_process(true);
+ set_process_unhandled_input(true);
downloads_scroll = memnew(ScrollContainer);
downloads_scroll->set_enable_h_scroll(true);
@@ -1513,7 +1534,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
asset_open->add_filter("*.zip ; " + TTR("Assets ZIP File"));
asset_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
add_child(asset_open);
- asset_open->connect("file_selected", this, "_asset_file_selected");
+ asset_open->connect_compat("file_selected", this, "_asset_file_selected");
asset_installer = NULL;
}
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index 70ffbd9eed..536a855d03 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -68,7 +68,7 @@ class EditorAssetLibraryItem : public PanelContainer {
void _category_clicked();
void _author_clicked();
- void set_image(int p_type, int p_index, const Ref<Texture> &p_image);
+ void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image);
protected:
void _notification(int p_what);
@@ -95,19 +95,19 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog {
bool is_video;
String video_link;
Button *button;
- Ref<Texture> image;
+ Ref<Texture2D> image;
};
Vector<Preview> preview_images;
TextureRect *preview;
- void set_image(int p_type, int p_index, const Ref<Texture> &p_image);
+ void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image);
int asset_id;
String download_url;
String title;
String sha256;
- Ref<Texture> icon;
+ Ref<Texture2D> icon;
void _link_click(const String &p_url);
void _preview_click(int p_id);
@@ -121,7 +121,7 @@ public:
void add_preview(int p_id, bool p_video, const String &p_url);
String get_title() { return title; }
- Ref<Texture> get_preview_icon() { return icon; }
+ Ref<Texture2D> get_preview_icon() { return icon; }
String get_download_url() { return download_url; }
int get_asset_id() { return asset_id; }
String get_sha256() { return sha256; }
@@ -156,7 +156,7 @@ class EditorAssetLibraryItemDownload : public PanelContainer {
void _close();
void _install();
void _make_request();
- void _http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
+ void _http_download_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
protected:
void _notification(int p_what);
@@ -165,7 +165,7 @@ protected:
public:
void set_external_install(bool p_enable) { external_install = p_enable; }
int get_asset_id() { return asset_id; }
- void configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash);
+ void configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash);
EditorAssetLibraryItemDownload();
};
@@ -250,8 +250,8 @@ class EditorAssetLibrary : public PanelContainer {
int last_queue_id;
Map<int, ImageQueue> image_queue;
- void _image_update(bool use_cache, bool final, const PoolByteArray &p_data, int p_queue_id);
- void _image_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data, int p_queue_id);
+ void _image_update(bool use_cache, bool final, const PackedByteArray &p_data, int p_queue_id);
+ void _image_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data, int p_queue_id);
void _request_image(ObjectID p_for, String p_image_url, ImageType p_type, int p_image_index);
void _update_image_queue();
@@ -286,8 +286,8 @@ class EditorAssetLibrary : public PanelContainer {
void _rerun_search(int p_ignore);
void _search_text_entered(const String &p_text = "");
void _api_request(const String &p_request, RequestType p_request_type, const String &p_arguments = "");
- void _http_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
- void _http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
+ void _http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
+ void _http_download_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
void _repository_changed(int p_repository_id);
void _support_toggled(int p_support);
@@ -300,6 +300,7 @@ class EditorAssetLibrary : public PanelContainer {
protected:
static void _bind_methods();
void _notification(int p_what);
+ void _unhandled_input(const Ref<InputEvent> &p_event);
public:
void disable_community_support();
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index 0ab3d26c85..e4a9c38a99 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,12 +32,14 @@
#include "core/io/resource_loader.h"
#include "core/project_settings.h"
+#include "editor/audio_stream_preview.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
void AudioStreamEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", this, "_preview_changed");
+ AudioStreamPreviewGenerator::get_singleton()->connect_compat("preview_updated", this, "_preview_changed");
}
if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
@@ -207,12 +209,12 @@ void AudioStreamEditor::_bind_methods() {
AudioStreamEditor::AudioStreamEditor() {
- set_custom_minimum_size(Size2(1, 100));
+ set_custom_minimum_size(Size2(1, 100) * EDSCALE);
_current = 0;
_dragging = false;
_player = memnew(AudioStreamPlayer);
- _player->connect("finished", this, "_on_finished");
+ _player->connect_compat("finished", this, "_on_finished");
add_child(_player);
VBoxContainer *vbox = memnew(VBoxContainer);
@@ -221,13 +223,13 @@ AudioStreamEditor::AudioStreamEditor() {
_preview = memnew(ColorRect);
_preview->set_v_size_flags(SIZE_EXPAND_FILL);
- _preview->connect("draw", this, "_draw_preview");
+ _preview->connect_compat("draw", this, "_draw_preview");
vbox->add_child(_preview);
_indicator = memnew(Control);
_indicator->set_anchors_and_margins_preset(PRESET_WIDE);
- _indicator->connect("draw", this, "_draw_indicator");
- _indicator->connect("gui_input", this, "_on_input_indicator");
+ _indicator->connect_compat("draw", this, "_draw_indicator");
+ _indicator->connect_compat("gui_input", this, "_on_input_indicator");
_preview->add_child(_indicator);
HBoxContainer *hbox = memnew(HBoxContainer);
@@ -237,12 +239,12 @@ AudioStreamEditor::AudioStreamEditor() {
_play_button = memnew(ToolButton);
hbox->add_child(_play_button);
_play_button->set_focus_mode(Control::FOCUS_NONE);
- _play_button->connect("pressed", this, "_play");
+ _play_button->connect_compat("pressed", this, "_play");
_stop_button = memnew(ToolButton);
hbox->add_child(_stop_button);
_stop_button->set_focus_mode(Control::FOCUS_NONE);
- _stop_button->connect("pressed", this, "_stop");
+ _stop_button->connect_compat("pressed", this, "_stop");
_current_label = memnew(Label);
_current_label->set_align(Label::ALIGN_RIGHT);
diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h
index 12e4faef94..2191b541f6 100644
--- a/editor/plugins/audio_stream_editor_plugin.h
+++ b/editor/plugins/audio_stream_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp
index d75f06de12..6bc9562c5a 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.cpp
+++ b/editor/plugins/baked_lightmap_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#if 0
#include "baked_lightmap_editor_plugin.h"
void BakedLightmapEditorPlugin::_bake() {
@@ -124,3 +125,4 @@ BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) {
BakedLightmapEditorPlugin::~BakedLightmapEditorPlugin() {
}
+#endif
diff --git a/editor/plugins/baked_lightmap_editor_plugin.h b/editor/plugins/baked_lightmap_editor_plugin.h
index ff4b59244f..818cdfe8fa 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.h
+++ b/editor/plugins/baked_lightmap_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#if 0
#ifndef BAKED_LIGHTMAP_EDITOR_PLUGIN_H
#define BAKED_LIGHTMAP_EDITOR_PLUGIN_H
@@ -67,3 +68,4 @@ public:
};
#endif // BAKED_LIGHTMAP_EDITOR_PLUGIN_H
+#endif
diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_editor_plugin.cpp
index 2531d59d1b..0440785eaf 100644
--- a/editor/plugins/camera_editor_plugin.cpp
+++ b/editor/plugins/camera_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -81,7 +81,7 @@ CameraEditor::CameraEditor() {
preview->set_margin(MARGIN_RIGHT, 0);
preview->set_margin(MARGIN_TOP, 0);
preview->set_margin(MARGIN_BOTTOM, 10);
- preview->connect("pressed", this, "_pressed");
+ preview->connect_compat("pressed", this, "_pressed");
}
void CameraEditorPlugin::edit(Object *p_object) {
diff --git a/editor/plugins/camera_editor_plugin.h b/editor/plugins/camera_editor_plugin.h
index 400aee132d..9758a1ffbd 100644
--- a/editor/plugins/camera_editor_plugin.h
+++ b/editor/plugins/camera_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 7170ce30cc..f5cc0ccf2a 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,11 +34,12 @@
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/project_settings.h"
+#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
-#include "editor/script_editor_debugger.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/polygon_2d.h"
@@ -47,6 +48,7 @@
#include "scene/2d/touch_screen_button.h"
#include "scene/gui/grid_container.h"
#include "scene/gui/nine_patch_rect.h"
+#include "scene/gui/viewport_container.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
@@ -54,8 +56,9 @@
#define MIN_ZOOM 0.01
#define MAX_ZOOM 100
-#define RULER_WIDTH 15 * EDSCALE
+#define RULER_WIDTH (15 * EDSCALE)
#define SCALE_HANDLE_DISTANCE 25
+#define MOVE_HANDLE_DISTANCE 25
class SnapDialog : public ConfirmationDialog {
@@ -603,7 +606,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
}
}
-void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items) {
+void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, bool p_allow_locked) {
Node *scene = editor->get_edited_scene();
@@ -618,14 +621,16 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
node = node->get_parent();
};
- // Replace the node by the group if grouped
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(node);
- while (node && node != scene->get_parent()) {
- CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
- if (canvas_item_tmp && node->has_meta("_edit_group_")) {
- canvas_item = canvas_item_tmp;
+ if (!p_allow_locked) {
+ // Replace the node by the group if grouped
+ while (node && node != scene->get_parent()) {
+ CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
+ if (canvas_item_tmp && node->has_meta("_edit_group_")) {
+ canvas_item = canvas_item_tmp;
+ }
+ node = node->get_parent();
}
- node = node->get_parent();
}
// Check if the canvas item is already in the list (for groups or scenes)
@@ -638,7 +643,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
}
//Remove the item if invalid
- if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || _is_node_locked(canvas_item)) {
+ if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (!p_allow_locked && _is_node_locked(canvas_item))) {
r_items.remove(i);
i--;
} else {
@@ -794,6 +799,7 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po
editor_selection->add_node(item);
// Reselect
if (Engine::get_singleton()->is_editor_hint()) {
+ selected_from_canvas = true;
editor->call("edit_node", item);
}
}
@@ -1110,7 +1116,11 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
if (dragged_guide_index >= 0) {
vguides.remove(dragged_guide_index);
undo_redo->create_action(TTR("Remove Vertical Guide"));
- undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides);
+ if (vguides.empty()) {
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "remove_meta", "_edit_vertical_guides_");
+ } else {
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides);
+ }
undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides);
undo_redo->add_undo_method(viewport, "update");
undo_redo->commit_action();
@@ -1139,7 +1149,11 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
if (dragged_guide_index >= 0) {
hguides.remove(dragged_guide_index);
undo_redo->create_action(TTR("Remove Horizontal Guide"));
- undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides);
+ if (hguides.empty()) {
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "remove_meta", "_edit_horizontal_guides_");
+ } else {
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides);
+ }
undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides);
undo_redo->add_undo_method(viewport, "update");
undo_redo->commit_action();
@@ -1481,7 +1495,9 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get();
drag_to = transform.affine_inverse().xform(m->get_position());
- canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation()));
+ //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements
+ bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0);
+ canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation()));
viewport->update();
}
return true;
@@ -1737,8 +1753,18 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse();
- Point2 drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
- Point2 drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
+ Point2 drag_to_snapped_begin;
+ Point2 drag_to_snapped_end;
+
+ // last call decides which snapping lines are drawn
+ if (drag_type == DRAG_LEFT || drag_type == DRAG_TOP || drag_type == DRAG_TOP_LEFT) {
+ drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
+ drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
+ } else {
+ drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
+ drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item);
+ }
+
Point2 drag_begin = xform.xform(drag_to_snapped_begin);
Point2 drag_end = xform.xform(drag_to_snapped_end);
@@ -1843,14 +1869,16 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
drag_type = DRAG_SCALE_BOTH;
- Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
- Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
- drag_type = DRAG_SCALE_X;
- }
- Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
- drag_type = DRAG_SCALE_Y;
+ if (show_transformation_gizmos) {
+ Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
+ Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
+ drag_type = DRAG_SCALE_X;
+ }
+ Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
+ drag_type = DRAG_SCALE_Y;
+ }
}
drag_from = transform.affine_inverse().xform(b->get_position());
@@ -1901,7 +1929,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
scale.y = scale.x * ratio;
}
} else if (drag_type == DRAG_SCALE_Y) {
- scale.y += scale_factor.y;
+ scale.y -= scale_factor.y;
if (uniform) {
scale.x = scale.y / ratio;
}
@@ -1960,6 +1988,24 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if (selection.size() > 0) {
drag_type = DRAG_MOVE;
+
+ CanvasItem *canvas_item = selection[0];
+ Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse();
+ Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized();
+ Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
+
+ if (show_transformation_gizmos) {
+ Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE);
+ Rect2 x_handle_rect = Rect2(move_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
+ drag_type = DRAG_MOVE_X;
+ }
+ Rect2 y_handle_rect = Rect2(-5 * EDSCALE, move_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
+ drag_type = DRAG_MOVE_Y;
+ }
+ }
+
drag_from = transform.affine_inverse().xform(b->get_position());
drag_selection = selection;
_save_canvas_item_state(drag_selection);
@@ -1969,7 +2015,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
}
- if (drag_type == DRAG_MOVE) {
+ if (drag_type == DRAG_MOVE || drag_type == DRAG_MOVE_X || drag_type == DRAG_MOVE_Y) {
// Move the nodes
if (m.is_valid()) {
@@ -1991,7 +2037,15 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
} else {
previous_pos = _get_encompassing_rect_from_list(drag_selection).position;
}
+
Point2 new_pos = snap_point(previous_pos + (drag_to - drag_from), SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL | SNAP_NODE_PARENT | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES, 0, NULL, drag_selection);
+
+ if (drag_type == DRAG_MOVE_X) {
+ new_pos.y = previous_pos.y;
+ } else if (drag_type == DRAG_MOVE_Y) {
+ new_pos.x = previous_pos.x;
+ }
+
bool single_axis = m->get_shift();
if (single_axis) {
if (ABS(new_pos.x - previous_pos.x) > ABS(new_pos.y - previous_pos.y)) {
@@ -2054,7 +2108,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
// Move the canvas items with the arrow keys
- if (k.is_valid() && k->is_pressed() && tool == TOOL_SELECT &&
+ if (k.is_valid() && k->is_pressed() && (tool == TOOL_SELECT || tool == TOOL_MOVE) &&
(k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)) {
if (!k->is_echo()) {
// Start moving the canvas items with the keyboard
@@ -2171,7 +2225,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
// Popup the selection menu list
Point2 click = transform.affine_inverse().xform(b->get_position());
- _get_canvas_items_at_pos(click, selection_results);
+ _get_canvas_items_at_pos(click, selection_results, b->get_alt() && tool != TOOL_LIST_SELECT);
if (selection_results.size() == 1) {
CanvasItem *item = selection_results[0].item;
@@ -2190,10 +2244,32 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
for (int i = 0; i < selection_results.size(); i++) {
CanvasItem *item = selection_results[i].item;
- Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(item, "Node");
+ Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(item, "Node");
String node_path = "/" + root_name + "/" + root_path.rel_path_to(item->get_path());
- selection_menu->add_item(item->get_name());
+ int locked = 0;
+ if (_is_node_locked(item)) {
+ locked = 1;
+ } else {
+ Node *scene = editor->get_edited_scene();
+ Node *node = item;
+
+ while (node && node != scene->get_parent()) {
+ CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
+ if (canvas_item_tmp && node->has_meta("_edit_group_")) {
+ locked = 2;
+ }
+ node = node->get_parent();
+ }
+ }
+
+ String suffix = String();
+ if (locked == 1) {
+ suffix = " (" + TTR("Locked") + ")";
+ } else if (locked == 2) {
+ suffix = " (" + TTR("Grouped") + ")";
+ }
+ selection_menu->add_item((String)item->get_name() + suffix);
selection_menu->set_item_icon(i, icon);
selection_menu->set_item_metadata(i, node_path);
selection_menu->set_item_tooltip(i, String(item->get_name()) + "\nType: " + item->get_class() + "\nPath: " + node_path);
@@ -2237,6 +2313,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
// Clear the selection if not additive
editor_selection->clear();
viewport->update();
+ selected_from_canvas = true;
};
drag_from = click;
@@ -2575,14 +2652,14 @@ void CanvasItemEditor::_draw_guides() {
Color text_color = get_color("font_color", "Editor");
text_color.a = 0.5;
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) {
- String str = vformat("%d px", xform.affine_inverse().xform(dragged_guide_pos).x);
+ String str = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x));
Ref<Font> font = get_font("font", "Label");
Size2 text_size = font->get_string_size(str);
viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, text_color);
viewport->draw_line(Point2(dragged_guide_pos.x, 0), Point2(dragged_guide_pos.x, viewport->get_size().y), guide_color, Math::round(EDSCALE));
}
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_H_GUIDE) {
- String str = vformat("%d px", xform.affine_inverse().xform(dragged_guide_pos).y);
+ String str = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y));
Ref<Font> font = get_font("font", "Label");
Size2 text_size = font->get_string_size(str);
viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, text_color);
@@ -2782,7 +2859,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
bool draw_secondary_lines = !(Math::is_equal_approx(begin.y, corner.y) || Math::is_equal_approx(end.x, corner.x));
- viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3), true);
+ viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3));
if (draw_secondary_lines) {
viewport->draw_line(begin, corner, ruler_secondary_color, Math::round(EDSCALE));
viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE));
@@ -2889,7 +2966,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
} else {
if (grid_snap_active) {
- Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons");
+ Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons");
viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}
}
@@ -3023,7 +3100,7 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
case DRAG_TOP_LEFT:
case DRAG_BOTTOM_LEFT:
_draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM);
- FALLTHROUGH;
+ [[fallthrough]];
case DRAG_MOVE:
start = Vector2(node_pos_in_parent[0], Math::lerp(node_pos_in_parent[1], node_pos_in_parent[3], ratio));
end = start - Vector2(control->get_margin(MARGIN_LEFT), 0);
@@ -3038,7 +3115,7 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
case DRAG_TOP_RIGHT:
case DRAG_BOTTOM_RIGHT:
_draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM);
- FALLTHROUGH;
+ [[fallthrough]];
case DRAG_MOVE:
start = Vector2(node_pos_in_parent[2], Math::lerp(node_pos_in_parent[3], node_pos_in_parent[1], ratio));
end = start - Vector2(control->get_margin(MARGIN_RIGHT), 0);
@@ -3053,7 +3130,7 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
case DRAG_TOP_LEFT:
case DRAG_TOP_RIGHT:
_draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), MARGIN_RIGHT);
- FALLTHROUGH;
+ [[fallthrough]];
case DRAG_MOVE:
start = Vector2(Math::lerp(node_pos_in_parent[0], node_pos_in_parent[2], ratio), node_pos_in_parent[1]);
end = start - Vector2(0, control->get_margin(MARGIN_TOP));
@@ -3068,7 +3145,7 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
case DRAG_BOTTOM_LEFT:
case DRAG_BOTTOM_RIGHT:
_draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), MARGIN_RIGHT);
- FALLTHROUGH;
+ [[fallthrough]];
case DRAG_MOVE:
start = Vector2(Math::lerp(node_pos_in_parent[2], node_pos_in_parent[0], ratio), node_pos_in_parent[3]);
end = start - Vector2(0, control->get_margin(MARGIN_BOTTOM));
@@ -3102,9 +3179,9 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
}
void CanvasItemEditor::_draw_selection() {
- Ref<Texture> pivot_icon = get_icon("EditorPivot", "EditorIcons");
- Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons");
- Ref<Texture> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons");
+ Ref<Texture2D> pivot_icon = get_icon("EditorPivot", "EditorIcons");
+ Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons");
+ Ref<Texture2D> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons");
RID ci = viewport->get_canvas_item();
@@ -3133,7 +3210,7 @@ void CanvasItemEditor::_draw_selection() {
};
for (int i = 0; i < 4; i++) {
- viewport->draw_line(pre_drag_endpoints[i], pre_drag_endpoints[(i + 1) % 4], pre_drag_color, Math::round(2 * EDSCALE), true);
+ viewport->draw_line(pre_drag_endpoints[i], pre_drag_endpoints[(i + 1) % 4], pre_drag_color, Math::round(2 * EDSCALE));
}
} else {
viewport->draw_texture(previous_position_icon, (pre_drag_xform.xform(Point2()) - (previous_position_icon->get_size() / 2)).floor());
@@ -3155,7 +3232,7 @@ void CanvasItemEditor::_draw_selection() {
Color c = Color(1, 0.6, 0.4, 0.7);
for (int i = 0; i < 4; i++) {
- viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE), true);
+ viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE));
}
} else {
@@ -3200,7 +3277,7 @@ void CanvasItemEditor::_draw_selection() {
int next = (i + 1) % 4;
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
- ofs *= 1.4144 * (select_handle->get_size().width / 2);
+ ofs *= Math_SQRT2 * (select_handle->get_size().width / 2);
select_handle->draw(ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor());
@@ -3211,10 +3288,39 @@ void CanvasItemEditor::_draw_selection() {
}
}
- // Draw the rescale handles
+ // Draw the move handles
bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
- if ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) {
+ if (tool == TOOL_MOVE && show_transformation_gizmos) {
+ if (_is_node_movable(canvas_item)) {
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
+ Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
+
+ Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE);
+ viewport->draw_set_transform_matrix(simple_xform);
+
+ Vector<Point2> points;
+ points.push_back(Vector2(move_factor.x * EDSCALE, 5 * EDSCALE));
+ points.push_back(Vector2(move_factor.x * EDSCALE, -5 * EDSCALE));
+ points.push_back(Vector2((move_factor.x + 10) * EDSCALE, 0));
+
+ viewport->draw_colored_polygon(points, get_color("axis_x_color", "Editor"));
+ viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE));
+
+ points.clear();
+ points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE));
+ points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE));
+ points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE));
+
+ viewport->draw_colored_polygon(points, get_color("axis_y_color", "Editor"));
+ viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE));
+
+ viewport->draw_set_transform_matrix(viewport->get_transform());
+ }
+ }
+
+ // Draw the rescale handles
+ if (show_transformation_gizmos && ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y)) {
if (_is_node_movable(canvas_item)) {
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
@@ -3229,20 +3335,20 @@ void CanvasItemEditor::_draw_selection() {
scale_factor.y += offset.x;
}
} else if (drag_type == DRAG_SCALE_Y) {
- scale_factor.y -= offset.y;
+ scale_factor.y += offset.y;
if (uniform) {
- scale_factor.x -= offset.y;
+ scale_factor.x += offset.y;
}
}
viewport->draw_set_transform_matrix(simple_xform);
Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
viewport->draw_rect(x_handle_rect, get_color("axis_x_color", "Editor"));
- viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE), true);
+ viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE));
- Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
viewport->draw_rect(y_handle_rect, get_color("axis_y_color", "Editor"));
- viewport->draw_line(Point2(), Point2(0, -scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE), true);
+ viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE));
viewport->draw_set_transform_matrix(viewport->get_transform());
}
@@ -3272,8 +3378,7 @@ void CanvasItemEditor::_draw_selection() {
transform.xform(drag_rotation_center),
transform.xform(drag_to),
get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
- Math::round(2 * EDSCALE),
- true);
+ Math::round(2 * EDSCALE));
}
}
@@ -3434,7 +3539,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
Transform2D xform = transform * canvas_xform * parent_xform;
// Draw the node's position
- Ref<Texture> position_icon = get_icon("EditorPositionUnselected", "EditorIcons");
+ Ref<Texture2D> position_icon = get_icon("EditorPositionUnselected", "EditorIcons");
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
@@ -3448,7 +3553,7 @@ void CanvasItemEditor::_draw_hover() {
for (int i = 0; i < hovering_results.size(); i++) {
- Ref<Texture> node_icon = hovering_results[i].icon;
+ Ref<Texture2D> node_icon = hovering_results[i].icon;
String node_name = hovering_results[i].name;
Ref<Font> font = get_font("font", "Label");
@@ -3502,13 +3607,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
if (canvas_item) {
float offset = 0;
- Ref<Texture> lock = get_icon("LockViewport", "EditorIcons");
+ Ref<Texture2D> lock = get_icon("LockViewport", "EditorIcons");
if (p_node->has_meta("_edit_lock_") && show_edit_locks) {
lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
offset += lock->get_size().x;
}
- Ref<Texture> group = get_icon("GroupViewport", "EditorIcons");
+ Ref<Texture2D> group = get_icon("GroupViewport", "EditorIcons");
if (canvas_item->has_meta("_edit_group_") && show_edit_locks) {
group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
//offset += group->get_size().x;
@@ -3554,7 +3659,7 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
// Add a last bone if the Bone2D has no Bone2D child
BoneKey bk;
bk.from = canvas_item->get_instance_id();
- bk.to = 0;
+ bk.to = ObjectID();
if (!bone_list.has(bk)) {
BoneList b;
b.length = 0;
@@ -3671,7 +3776,7 @@ void CanvasItemEditor::_notification(int p_what) {
int nb_having_pivot = 0;
// Update the viewport if the canvas_item changes
- List<CanvasItem *> selection = _get_edited_canvas_items();
+ List<CanvasItem *> selection = _get_edited_canvas_items(true);
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get();
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
@@ -3786,10 +3891,10 @@ void CanvasItemEditor::_notification(int p_what) {
select_sb->set_default_margin(Margin(i), 4);
}
- AnimationPlayerEditor::singleton->get_track_editor()->connect("visibility_changed", this, "_keying_changed");
+ AnimationPlayerEditor::singleton->get_track_editor()->connect_compat("visibility_changed", this, "_keying_changed");
_keying_changed();
- get_tree()->connect("node_added", this, "_tree_changed", varray());
- get_tree()->connect("node_removed", this, "_tree_changed", varray());
+ get_tree()->connect_compat("node_added", this, "_tree_changed", varray());
+ get_tree()->connect_compat("node_removed", this, "_tree_changed", varray());
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
@@ -3797,8 +3902,8 @@ void CanvasItemEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
- get_tree()->disconnect("node_added", this, "_tree_changed");
- get_tree()->disconnect("node_removed", this, "_tree_changed");
+ get_tree()->disconnect_compat("node_added", this, "_tree_changed");
+ get_tree()->disconnect_compat("node_removed", this, "_tree_changed");
}
if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
@@ -3826,6 +3931,7 @@ void CanvasItemEditor::_notification(int p_what) {
key_scale_button->set_icon(get_icon("KeyScale", "EditorIcons"));
key_insert_button->set_icon(get_icon("Key", "EditorIcons"));
key_auto_insert_button->set_icon(get_icon("AutoKey", "EditorIcons"));
+ animation_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
zoom_minus->set_icon(get_icon("ZoomLess", "EditorIcons"));
zoom_plus->set_icon(get_icon("ZoomMore", "EditorIcons"));
@@ -3834,57 +3940,57 @@ void CanvasItemEditor::_notification(int p_what) {
PopupMenu *p = presets_menu->get_popup();
p->clear();
- p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), "Top Left", ANCHORS_AND_MARGINS_PRESET_TOP_LEFT);
- p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), "Top Right", ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), "Bottom Right", ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), "Bottom Left", ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT);
+ p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_MARGINS_PRESET_TOP_LEFT);
+ p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT);
+ p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT);
+ p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), "Center Left", ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT);
- p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), "Center Top", ANCHORS_AND_MARGINS_PRESET_CENTER_TOP);
- p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), "Center Right", ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), "Center Bottom", ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM);
- p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), "Center", ANCHORS_AND_MARGINS_PRESET_CENTER);
+ p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT);
+ p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_MARGINS_PRESET_CENTER_TOP);
+ p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT);
+ p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM);
+ p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_MARGINS_PRESET_CENTER);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), "Left Wide", ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE);
- p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), "Top Wide", ANCHORS_AND_MARGINS_PRESET_TOP_WIDE);
- p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), "Right Wide", ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE);
- p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), "Bottom Wide", ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE);
- p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), "VCenter Wide ", ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE);
- p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE);
+ p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE);
+ p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_MARGINS_PRESET_TOP_WIDE);
+ p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE);
+ p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE);
+ p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE);
+ p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHORS_AND_MARGINS_PRESET_WIDE);
- p->add_icon_item(get_icon("Anchor", "EditorIcons"), "Keep Ratio", ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO);
+ p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_MARGINS_PRESET_WIDE);
+ p->add_icon_item(get_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO);
p->add_separator();
p->add_submenu_item(TTR("Anchors only"), "Anchors");
p->set_item_icon(21, get_icon("Anchor", "EditorIcons"));
anchors_popup->clear();
- anchors_popup->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), "Top Left", ANCHORS_PRESET_TOP_LEFT);
- anchors_popup->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), "Top Right", ANCHORS_PRESET_TOP_RIGHT);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), "Bottom Right", ANCHORS_PRESET_BOTTOM_RIGHT);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), "Bottom Left", ANCHORS_PRESET_BOTTOM_LEFT);
+ anchors_popup->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT);
+ anchors_popup->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT);
+ anchors_popup->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT);
+ anchors_popup->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT);
anchors_popup->add_separator();
- anchors_popup->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), "Center Left", ANCHORS_PRESET_CENTER_LEFT);
- anchors_popup->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), "Center Top", ANCHORS_PRESET_CENTER_TOP);
- anchors_popup->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), "Center Right", ANCHORS_PRESET_CENTER_RIGHT);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), "Center Bottom", ANCHORS_PRESET_CENTER_BOTTOM);
- anchors_popup->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), "Center", ANCHORS_PRESET_CENTER);
+ anchors_popup->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT);
+ anchors_popup->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP);
+ anchors_popup->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT);
+ anchors_popup->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM);
+ anchors_popup->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_PRESET_CENTER);
anchors_popup->add_separator();
- anchors_popup->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), "Left Wide", ANCHORS_PRESET_LEFT_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), "Top Wide", ANCHORS_PRESET_TOP_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), "Right Wide", ANCHORS_PRESET_RIGHT_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), "Bottom Wide", ANCHORS_PRESET_BOTTOM_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), "VCenter Wide ", ANCHORS_PRESET_VCENTER_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHORS_PRESET_HCENTER_WIDE);
+ anchors_popup->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE);
+ anchors_popup->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE);
+ anchors_popup->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE);
+ anchors_popup->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE);
+ anchors_popup->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE);
+ anchors_popup->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE);
anchors_popup->add_separator();
- anchors_popup->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHORS_PRESET_WIDE);
+ anchors_popup->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_PRESET_WIDE);
anchor_mode_button->set_icon(get_icon("Anchor", "EditorIcons"));
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (!is_visible() && override_camera_button->is_pressed()) {
- ScriptEditorDebugger *debugger = ScriptEditor::get_singleton()->get_debugger();
+ EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_NONE);
override_camera_button->set_pressed(false);
@@ -3911,6 +4017,11 @@ void CanvasItemEditor::_selection_changed() {
}
anchors_mode = (nbValidControls == nbAnchorsMode);
anchor_mode_button->set_pressed(anchors_mode);
+
+ if (!selected_from_canvas) {
+ drag_type = DRAG_NONE;
+ }
+ selected_from_canvas = false;
}
void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
@@ -3970,29 +4081,21 @@ void CanvasItemEditor::_update_scrollbars() {
updating_scroll = true;
- // Move the zoom buttons
- Point2 zoom_hb_begin = Point2(5, 5);
- zoom_hb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2();
- zoom_hb->set_begin(zoom_hb_begin);
+ // Move the zoom buttons.
+ Point2 controls_vb_begin = Point2(5, 5);
+ controls_vb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2();
+ controls_vb->set_begin(controls_vb_begin);
- // Move and resize the scrollbars
- Size2 size = viewport->get_size();
Size2 hmin = h_scroll->get_minimum_size();
Size2 vmin = v_scroll->get_minimum_size();
- v_scroll->set_begin(Point2(size.width - vmin.width, (show_rulers) ? RULER_WIDTH : 0));
- v_scroll->set_end(Point2(size.width, size.height));
-
- h_scroll->set_begin(Point2((show_rulers) ? RULER_WIDTH : 0, size.height - hmin.height));
- h_scroll->set_end(Point2(size.width - vmin.width, size.height));
-
- // Get the visible frame
+ // Get the visible frame.
Size2 screen_rect = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height));
_queue_update_bone_list();
- // Calculate scrollable area
+ // Calculate scrollable area.
Rect2 canvas_item_rect = Rect2(Point2(), screen_rect);
if (editor->get_edited_scene()) {
Rect2 content_rect = _get_encompassing_rect(editor->get_edited_scene());
@@ -4002,7 +4105,8 @@ void CanvasItemEditor::_update_scrollbars() {
canvas_item_rect.size += screen_rect * 2;
canvas_item_rect.position -= screen_rect;
- // Constraints the view offset and updates the scrollbars
+ // Constraints the view offset and updates the scrollbars.
+ Size2 size = viewport->get_size();
Point2 begin = canvas_item_rect.position;
Point2 end = canvas_item_rect.position + canvas_item_rect.size - local_rect.size / zoom;
bool constrain_editor_view = bool(EditorSettings::get_singleton()->get("editors/2d/constrain_editor_view"));
@@ -4049,7 +4153,13 @@ void CanvasItemEditor::_update_scrollbars() {
h_scroll->set_page(screen_rect.x);
}
- // Calculate scrollable area
+ // Move and resize the scrollbars, avoiding overlap.
+ v_scroll->set_begin(Point2(size.width - vmin.width, (show_rulers) ? RULER_WIDTH : 0));
+ v_scroll->set_end(Point2(size.width, size.height - (h_scroll->is_visible() ? hmin.height : 0)));
+ h_scroll->set_begin(Point2((show_rulers) ? RULER_WIDTH : 0, size.height - hmin.height));
+ h_scroll->set_end(Point2(size.width - (v_scroll->is_visible() ? vmin.width : 0), size.height));
+
+ // Calculate scrollable area.
v_scroll->set_value(view_offset.y);
h_scroll->set_value(view_offset.x);
@@ -4061,10 +4171,9 @@ void CanvasItemEditor::_popup_warning_depop(Control *p_control) {
ERR_FAIL_COND(!popup_temporarily_timers.has(p_control));
Timer *timer = popup_temporarily_timers[p_control];
+ timer->queue_delete();
p_control->hide();
- remove_child(timer);
popup_temporarily_timers.erase(p_control);
- memdelete(timer);
info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
}
@@ -4072,7 +4181,7 @@ void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const floa
Timer *timer;
if (!popup_temporarily_timers.has(p_control)) {
timer = memnew(Timer);
- timer->connect("timeout", this, "_popup_warning_depop", varray(p_control));
+ timer->connect_compat("timeout", this, "_popup_warning_depop", varray(p_control));
timer->set_one_shot(true);
add_child(timer);
@@ -4200,11 +4309,15 @@ void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) {
void CanvasItemEditor::_update_zoom_label() {
String zoom_text;
+ // The zoom level displayed is relative to the editor scale
+ // (like in most image editors). Its lower bound is clamped to 1 as some people
+ // lower the editor scale to increase the available real estate,
+ // even if their display doesn't have a particularly low DPI.
if (zoom >= 10) {
- // Don't show a decimal when the zoom level is higher than 1000 %
- zoom_text = rtos(Math::round(zoom * 100)) + " %";
+ // Don't show a decimal when the zoom level is higher than 1000 %.
+ zoom_text = rtos(Math::round((zoom / MAX(1, EDSCALE)) * 100)) + " %";
} else {
- zoom_text = rtos(Math::stepify(zoom * 100, 0.1)) + " %";
+ zoom_text = rtos(Math::stepify((zoom / MAX(1, EDSCALE)) * 100, 0.1)) + " %";
}
zoom_reset->set_text(zoom_text);
@@ -4215,7 +4328,7 @@ void CanvasItemEditor::_button_zoom_minus() {
}
void CanvasItemEditor::_button_zoom_reset() {
- _zoom_on_position(1.0, viewport_scrollable->get_size() / 2.0);
+ _zoom_on_position(1.0 * MAX(1, EDSCALE), viewport_scrollable->get_size() / 2.0);
}
void CanvasItemEditor::_button_zoom_plus() {
@@ -4232,7 +4345,7 @@ void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) {
viewport->update();
}
void CanvasItemEditor::_button_override_camera(bool p_pressed) {
- ScriptEditorDebugger *debugger = ScriptEditor::get_singleton()->get_debugger();
+ EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
if (p_pressed) {
debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_2D);
@@ -4349,10 +4462,8 @@ void CanvasItemEditor::_update_override_camera_button(bool p_game_running) {
}
void CanvasItemEditor::_popup_callback(int p_op) {
-
last_option = MenuOption(p_op);
switch (p_op) {
-
case SHOW_GRID: {
show_grid = !show_grid;
int idx = view_menu->get_popup()->get_item_index(SHOW_GRID);
@@ -4377,6 +4488,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
view_menu->get_popup()->set_item_checked(idx, show_edit_locks);
viewport->update();
} break;
+ case SHOW_TRANSFORMATION_GIZMOS: {
+ show_transformation_gizmos = !show_transformation_gizmos;
+ int idx = view_menu->get_popup()->get_item_index(SHOW_TRANSFORMATION_GIZMOS);
+ view_menu->get_popup()->set_item_checked(idx, show_transformation_gizmos);
+ viewport->update();
+ } break;
case SNAP_USE_NODE_PARENT: {
snap_node_parent = !snap_node_parent;
int idx = smartsnap_config_popup->get_item_index(SNAP_USE_NODE_PARENT);
@@ -4745,19 +4862,21 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case CLEAR_GUIDES: {
- if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_") || EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) {
+ Node *const root = EditorNode::get_singleton()->get_edited_scene();
+
+ if (root && (root->has_meta("_edit_horizontal_guides_") || root->has_meta("_edit_vertical_guides_"))) {
undo_redo->create_action(TTR("Clear Guides"));
- if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_")) {
- Array hguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_horizontal_guides_");
+ if (root->has_meta("_edit_horizontal_guides_")) {
+ Array hguides = root->get_meta("_edit_horizontal_guides_");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", Array());
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides);
+ undo_redo->add_do_method(root, "remove_meta", "_edit_horizontal_guides_");
+ undo_redo->add_undo_method(root, "set_meta", "_edit_horizontal_guides_", hguides);
}
- if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) {
- Array vguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_vertical_guides_");
+ if (root->has_meta("_edit_vertical_guides_")) {
+ Array vguides = root->get_meta("_edit_vertical_guides_");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", Array());
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides);
+ undo_redo->add_do_method(root, "remove_meta", "_edit_vertical_guides_");
+ undo_redo->add_undo_method(root, "set_meta", "_edit_vertical_guides_", vguides);
}
undo_redo->add_undo_method(viewport, "update");
undo_redo->commit_action();
@@ -4921,8 +5040,8 @@ void CanvasItemEditor::_focus_selection(int p_op) {
center = rect.position + rect.size / 2;
Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center);
- view_offset.x -= offset.x / zoom;
- view_offset.y -= offset.y / zoom;
+ view_offset.x -= Math::round(offset.x / zoom);
+ view_offset.y -= Math::round(offset.y / zoom);
update_viewport();
} else { // VIEW_FRAME_TO_SELECTION
@@ -4933,6 +5052,7 @@ void CanvasItemEditor::_focus_selection(int p_op) {
zoom = scale_x < scale_y ? scale_x : scale_y;
zoom *= 0.90;
viewport->update();
+ _update_zoom_label();
call_deferred("_popup_callback", VIEW_CENTER_TO_SELECTION);
}
}
@@ -4975,7 +5095,8 @@ void CanvasItemEditor::_bind_methods() {
Dictionary CanvasItemEditor::get_state() const {
Dictionary state;
- state["zoom"] = zoom;
+ // Take the editor scale into account.
+ state["zoom"] = zoom / MAX(1, EDSCALE);
state["ofs"] = view_offset;
state["grid_offset"] = grid_offset;
state["grid_step"] = grid_step;
@@ -4999,6 +5120,7 @@ Dictionary CanvasItemEditor::get_state() const {
state["show_helpers"] = show_helpers;
state["show_zoom_control"] = zoom_hb->is_visible();
state["show_edit_locks"] = show_edit_locks;
+ state["show_transformation_gizmos"] = show_transformation_gizmos;
state["snap_rotation"] = snap_rotation;
state["snap_scale"] = snap_scale;
state["snap_relative"] = snap_relative;
@@ -5012,7 +5134,9 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
bool update_scrollbars = false;
Dictionary state = p_state;
if (state.has("zoom")) {
- zoom = p_state["zoom"];
+ // Compensate the editor scale, so that the editor scale can be changed
+ // and the zoom level will still be the same (relative to the editor scale).
+ zoom = float(p_state["zoom"]) * MAX(1, EDSCALE);
_update_zoom_label();
}
@@ -5135,6 +5259,12 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
view_menu->get_popup()->set_item_checked(idx, show_edit_locks);
}
+ if (state.has("show_transformation_gizmos")) {
+ show_transformation_gizmos = state["show_transformation_gizmos"];
+ int idx = view_menu->get_popup()->get_item_index(SHOW_TRANSFORMATION_GIZMOS);
+ view_menu->get_popup()->set_item_checked(idx, show_transformation_gizmos);
+ }
+
if (state.has("show_zoom_control")) {
// This one is not user-controllable, but instrumentable
zoom_hb->set_visible(state["show_zoom_control"]);
@@ -5227,12 +5357,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
show_helpers = false;
show_rulers = true;
show_guides = true;
+ show_transformation_gizmos = true;
show_edit_locks = true;
- zoom = 1;
+ zoom = 1.0 / MAX(1, EDSCALE);
view_offset = Point2(-150 - RULER_WIDTH, -95 - RULER_WIDTH);
previous_update_view_offset = view_offset; // Moves the view a little bit to the left so that (0,0) is visible. The values a relative to a 16/10 screen
grid_offset = Point2();
- grid_step = Point2(10, 10);
+ grid_step = Point2(8, 8); // A power-of-two value works better as a default
primary_grid_steps = 8; // A power-of-two value works better as a default
grid_step_multiplier = 0;
snap_rotation_offset = 0;
@@ -5253,6 +5384,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
+ selected_from_canvas = false;
anchors_mode = false;
skeleton_show_bones = true;
@@ -5262,6 +5394,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
drag_to = Vector2();
dragged_guide_pos = Point2();
dragged_guide_index = -1;
+ is_hovering_h_guide = false;
+ is_hovering_v_guide = false;
panning = false;
pan_pressed = false;
@@ -5276,11 +5410,11 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
editor = p_editor;
editor_selection = p_editor->get_editor_selection();
editor_selection->add_editor_plugin(this);
- editor_selection->connect("selection_changed", this, "update");
- editor_selection->connect("selection_changed", this, "_selection_changed");
+ editor_selection->connect_compat("selection_changed", this, "update");
+ editor_selection->connect_compat("selection_changed", this, "_selection_changed");
- editor->call_deferred("connect", "play_pressed", this, "_update_override_camera_button", make_binds(true));
- editor->call_deferred("connect", "stop_pressed", this, "_update_override_camera_button", make_binds(false));
+ editor->call_deferred("connect", make_binds("play_pressed", Callable(this, "_update_override_camera_button"), true));
+ editor->call_deferred("connect", make_binds("stop_pressed", Callable(this, "_update_override_camera_button"), false));
hb = memnew(HBoxContainer);
add_child(hb);
@@ -5300,7 +5434,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
viewport_scrollable->set_clip_contents(true);
viewport_scrollable->set_v_size_flags(SIZE_EXPAND_FILL);
viewport_scrollable->set_h_size_flags(SIZE_EXPAND_FILL);
- viewport_scrollable->connect("draw", this, "_update_scrollbars");
+ viewport_scrollable->connect_compat("draw", this, "_update_scrollbars");
ViewportContainer *scene_tree = memnew(ViewportContainer);
viewport_scrollable->add_child(scene_tree);
@@ -5308,14 +5442,22 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE);
scene_tree->add_child(p_editor->get_scene_root());
+ controls_vb = memnew(VBoxContainer);
+ controls_vb->set_begin(Point2(5, 5));
+
+ zoom_hb = memnew(HBoxContainer);
+ // Bring the zoom percentage closer to the zoom buttons
+ zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE));
+ controls_vb->add_child(zoom_hb);
+
viewport = memnew(CanvasItemEditorViewport(p_editor, this));
viewport_scrollable->add_child(viewport);
viewport->set_mouse_filter(MOUSE_FILTER_PASS);
viewport->set_anchors_and_margins_preset(Control::PRESET_WIDE);
viewport->set_clip_contents(true);
viewport->set_focus_mode(FOCUS_ALL);
- viewport->connect("draw", this, "_draw_viewport");
- viewport->connect("gui_input", this, "_gui_input_viewport");
+ viewport->connect_compat("draw", this, "_draw_viewport");
+ viewport->connect_compat("gui_input", this, "_gui_input_viewport");
info_overlay = memnew(VBoxContainer);
info_overlay->set_anchors_and_margins_preset(Control::PRESET_BOTTOM_LEFT);
@@ -5343,29 +5485,25 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
h_scroll = memnew(HScrollBar);
viewport->add_child(h_scroll);
- h_scroll->connect("value_changed", this, "_update_scroll");
+ h_scroll->connect_compat("value_changed", this, "_update_scroll");
h_scroll->hide();
v_scroll = memnew(VScrollBar);
viewport->add_child(v_scroll);
- v_scroll->connect("value_changed", this, "_update_scroll");
+ v_scroll->connect_compat("value_changed", this, "_update_scroll");
v_scroll->hide();
- zoom_hb = memnew(HBoxContainer);
- viewport->add_child(zoom_hb);
- zoom_hb->set_begin(Point2(5, 5));
- // Bring the zoom percentage closer to the zoom buttons
- zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE));
+ viewport->add_child(controls_vb);
zoom_minus = memnew(ToolButton);
zoom_hb->add_child(zoom_minus);
- zoom_minus->connect("pressed", this, "_button_zoom_minus");
+ zoom_minus->connect_compat("pressed", this, "_button_zoom_minus");
zoom_minus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_minus", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS));
zoom_minus->set_focus_mode(FOCUS_NONE);
zoom_reset = memnew(ToolButton);
zoom_hb->add_child(zoom_reset);
- zoom_reset->connect("pressed", this, "_button_zoom_reset");
+ zoom_reset->connect_compat("pressed", this, "_button_zoom_reset");
zoom_reset->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset"), KEY_MASK_CMD | KEY_0));
zoom_reset->set_focus_mode(FOCUS_NONE);
zoom_reset->set_text_align(Button::TextAlign::ALIGN_CENTER);
@@ -5374,7 +5512,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
zoom_plus = memnew(ToolButton);
zoom_hb->add_child(zoom_plus);
- zoom_plus->connect("pressed", this, "_button_zoom_plus");
+ zoom_plus->connect_compat("pressed", this, "_button_zoom_plus");
zoom_plus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_plus", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL)); // Usually direct access key for PLUS
zoom_plus->set_focus_mode(FOCUS_NONE);
@@ -5383,7 +5521,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
select_button = memnew(ToolButton);
hb->add_child(select_button);
select_button->set_toggle_mode(true);
- select_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_SELECT));
+ select_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_SELECT));
select_button->set_pressed(true);
select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q));
select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection"));
@@ -5393,21 +5531,21 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
move_button = memnew(ToolButton);
hb->add_child(move_button);
move_button->set_toggle_mode(true);
- move_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_MOVE));
+ move_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_MOVE));
move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode", TTR("Move Mode"), KEY_W));
move_button->set_tooltip(TTR("Move Mode"));
rotate_button = memnew(ToolButton);
hb->add_child(rotate_button);
rotate_button->set_toggle_mode(true);
- rotate_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_ROTATE));
+ rotate_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_ROTATE));
rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode", TTR("Rotate Mode"), KEY_E));
rotate_button->set_tooltip(TTR("Rotate Mode"));
scale_button = memnew(ToolButton);
hb->add_child(scale_button);
scale_button->set_toggle_mode(true);
- scale_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_SCALE));
+ scale_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_SCALE));
scale_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scale_mode", TTR("Scale Mode"), KEY_S));
scale_button->set_tooltip(TTR("Scale Mode"));
@@ -5416,25 +5554,25 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
list_select_button = memnew(ToolButton);
hb->add_child(list_select_button);
list_select_button->set_toggle_mode(true);
- list_select_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_LIST_SELECT));
+ list_select_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_LIST_SELECT));
list_select_button->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode)."));
pivot_button = memnew(ToolButton);
hb->add_child(pivot_button);
pivot_button->set_toggle_mode(true);
- pivot_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_EDIT_PIVOT));
+ pivot_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_EDIT_PIVOT));
pivot_button->set_tooltip(TTR("Click to change object's rotation pivot."));
pan_button = memnew(ToolButton);
hb->add_child(pan_button);
pan_button->set_toggle_mode(true);
- pan_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_PAN));
+ pan_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_PAN));
pan_button->set_tooltip(TTR("Pan Mode"));
ruler_button = memnew(ToolButton);
hb->add_child(ruler_button);
ruler_button->set_toggle_mode(true);
- ruler_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_RULER));
+ ruler_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_RULER));
ruler_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/ruler_mode", TTR("Ruler Mode"), KEY_R));
ruler_button->set_tooltip(TTR("Ruler Mode"));
@@ -5443,14 +5581,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
smart_snap_button = memnew(ToolButton);
hb->add_child(smart_snap_button);
smart_snap_button->set_toggle_mode(true);
- smart_snap_button->connect("toggled", this, "_button_toggle_smart_snap");
+ smart_snap_button->connect_compat("toggled", this, "_button_toggle_smart_snap");
smart_snap_button->set_tooltip(TTR("Toggle smart snapping."));
smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTR("Use Smart Snap"), KEY_MASK_SHIFT | KEY_S));
grid_snap_button = memnew(ToolButton);
hb->add_child(grid_snap_button);
grid_snap_button->set_toggle_mode(true);
- grid_snap_button->connect("toggled", this, "_button_toggle_grid_snap");
+ grid_snap_button->connect_compat("toggled", this, "_button_toggle_grid_snap");
grid_snap_button->set_tooltip(TTR("Toggle grid snapping."));
grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTR("Use Grid Snap"), KEY_MASK_SHIFT | KEY_G));
@@ -5461,7 +5599,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
snap_config_menu->set_switch_on_hover(true);
PopupMenu *p = snap_config_menu->get_popup();
- p->connect("id_pressed", this, "_popup_callback");
+ p->connect_compat("id_pressed", this, "_popup_callback");
p->set_hide_on_checkable_item_selection(false);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_rotation_snap", TTR("Use Rotation Snap")), SNAP_USE_ROTATION);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_scale_snap", TTR("Use Scale Snap")), SNAP_USE_SCALE);
@@ -5475,7 +5613,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
smartsnap_config_popup = memnew(PopupMenu);
p->add_child(smartsnap_config_popup);
smartsnap_config_popup->set_name("SmartSnapping");
- smartsnap_config_popup->connect("id_pressed", this, "_popup_callback");
+ smartsnap_config_popup->connect_compat("id_pressed", this, "_popup_callback");
smartsnap_config_popup->set_hide_on_checkable_item_selection(false);
smartsnap_config_popup->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_node_parent", TTR("Snap to Parent")), SNAP_USE_NODE_PARENT);
smartsnap_config_popup->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_node_anchors", TTR("Snap to Node Anchor")), SNAP_USE_NODE_ANCHORS);
@@ -5489,22 +5627,22 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
lock_button = memnew(ToolButton);
hb->add_child(lock_button);
- lock_button->connect("pressed", this, "_popup_callback", varray(LOCK_SELECTED));
+ lock_button->connect_compat("pressed", this, "_popup_callback", varray(LOCK_SELECTED));
lock_button->set_tooltip(TTR("Lock the selected object in place (can't be moved)."));
unlock_button = memnew(ToolButton);
hb->add_child(unlock_button);
- unlock_button->connect("pressed", this, "_popup_callback", varray(UNLOCK_SELECTED));
+ unlock_button->connect_compat("pressed", this, "_popup_callback", varray(UNLOCK_SELECTED));
unlock_button->set_tooltip(TTR("Unlock the selected object (can be moved)."));
group_button = memnew(ToolButton);
hb->add_child(group_button);
- group_button->connect("pressed", this, "_popup_callback", varray(GROUP_SELECTED));
+ group_button->connect_compat("pressed", this, "_popup_callback", varray(GROUP_SELECTED));
group_button->set_tooltip(TTR("Makes sure the object's children are not selectable."));
ungroup_button = memnew(ToolButton);
hb->add_child(ungroup_button);
- ungroup_button->connect("pressed", this, "_popup_callback", varray(UNGROUP_SELECTED));
+ ungroup_button->connect_compat("pressed", this, "_popup_callback", varray(UNGROUP_SELECTED));
ungroup_button->set_tooltip(TTR("Restores the object's children's ability to be selected."));
hb->add_child(memnew(VSeparator));
@@ -5523,13 +5661,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Custom Bone(s) from Node(s)"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B), SKELETON_MAKE_BONES);
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Custom Bones")), SKELETON_CLEAR_BONES);
- p->connect("id_pressed", this, "_popup_callback");
+ p->connect_compat("id_pressed", this, "_popup_callback");
hb->add_child(memnew(VSeparator));
override_camera_button = memnew(ToolButton);
hb->add_child(override_camera_button);
- override_camera_button->connect("toggled", this, "_button_override_camera");
+ override_camera_button->connect_compat("toggled", this, "_button_override_camera");
override_camera_button->set_toggle_mode(true);
override_camera_button->set_disabled(true);
_update_override_camera_button(false);
@@ -5539,7 +5677,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
hb->add_child(view_menu);
- view_menu->get_popup()->connect("id_pressed", this, "_popup_callback");
+ view_menu->get_popup()->connect_compat("id_pressed", this, "_popup_callback");
view_menu->set_switch_on_hover(true);
p = view_menu->get_popup();
@@ -5551,6 +5689,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_origin", TTR("Show Origin")), SHOW_ORIGIN);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_viewport", TTR("Show Viewport")), SHOW_VIEWPORT);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_edit_locks", TTR("Show Group And Lock Icons")), SHOW_EDIT_LOCKS);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_transformation_gizmos", TTR("Show Transformation Gizmos")), SHOW_TRANSFORMATION_GIZMOS);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION);
@@ -5566,18 +5705,18 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
presets_menu->set_switch_on_hover(true);
p = presets_menu->get_popup();
- p->connect("id_pressed", this, "_popup_callback");
+ p->connect_compat("id_pressed", this, "_popup_callback");
anchors_popup = memnew(PopupMenu);
p->add_child(anchors_popup);
anchors_popup->set_name("Anchors");
- anchors_popup->connect("id_pressed", this, "_popup_callback");
+ anchors_popup->connect_compat("id_pressed", this, "_popup_callback");
anchor_mode_button = memnew(ToolButton);
hb->add_child(anchor_mode_button);
anchor_mode_button->set_toggle_mode(true);
anchor_mode_button->hide();
- anchor_mode_button->connect("toggled", this, "_button_toggle_anchor_mode");
+ anchor_mode_button->connect_compat("toggled", this, "_button_toggle_anchor_mode");
animation_hb = memnew(HBoxContainer);
hb->add_child(animation_hb);
@@ -5589,7 +5728,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_loc_button->set_flat(true);
key_loc_button->set_pressed(true);
key_loc_button->set_focus_mode(FOCUS_NONE);
- key_loc_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_POS));
+ key_loc_button->connect_compat("pressed", this, "_popup_callback", varray(ANIM_INSERT_POS));
key_loc_button->set_tooltip(TTR("Translation mask for inserting keys."));
animation_hb->add_child(key_loc_button);
key_rot_button = memnew(Button);
@@ -5597,20 +5736,20 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_rot_button->set_flat(true);
key_rot_button->set_pressed(true);
key_rot_button->set_focus_mode(FOCUS_NONE);
- key_rot_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_ROT));
+ key_rot_button->connect_compat("pressed", this, "_popup_callback", varray(ANIM_INSERT_ROT));
key_rot_button->set_tooltip(TTR("Rotation mask for inserting keys."));
animation_hb->add_child(key_rot_button);
key_scale_button = memnew(Button);
key_scale_button->set_toggle_mode(true);
key_scale_button->set_flat(true);
key_scale_button->set_focus_mode(FOCUS_NONE);
- key_scale_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_SCALE));
+ key_scale_button->connect_compat("pressed", this, "_popup_callback", varray(ANIM_INSERT_SCALE));
key_scale_button->set_tooltip(TTR("Scale mask for inserting keys."));
animation_hb->add_child(key_scale_button);
key_insert_button = memnew(Button);
key_insert_button->set_flat(true);
key_insert_button->set_focus_mode(FOCUS_NONE);
- key_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
+ key_insert_button->connect_compat("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
key_insert_button->set_tooltip(TTR("Insert keys (based on mask)."));
key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT));
animation_hb->add_child(key_insert_button);
@@ -5624,9 +5763,9 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
animation_hb->add_child(key_auto_insert_button);
animation_menu = memnew(MenuButton);
- animation_menu->set_text(TTR("Animation"));
+ animation_menu->set_tooltip(TTR("Animation Key and Pose Options"));
animation_hb->add_child(animation_menu);
- animation_menu->get_popup()->connect("id_pressed", this, "_popup_callback");
+ animation_menu->get_popup()->connect_compat("id_pressed", this, "_popup_callback");
animation_menu->set_switch_on_hover(true);
p = animation_menu->get_popup();
@@ -5639,7 +5778,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_clear_pose", TTR("Clear Pose"), KEY_MASK_SHIFT | KEY_K), ANIM_CLEAR_POSE);
snap_dialog = memnew(SnapDialog);
- snap_dialog->connect("confirmed", this, "_snap_changed");
+ snap_dialog->connect_compat("confirmed", this, "_snap_changed");
add_child(snap_dialog);
select_sb = Ref<StyleBoxTexture>(memnew(StyleBoxTexture));
@@ -5647,8 +5786,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
selection_menu = memnew(PopupMenu);
add_child(selection_menu);
selection_menu->set_custom_minimum_size(Vector2(100, 0));
- selection_menu->connect("id_pressed", this, "_selection_result_pressed");
- selection_menu->connect("popup_hide", this, "_selection_menu_hide");
+ selection_menu->connect_compat("id_pressed", this, "_selection_result_pressed");
+ selection_menu->connect_compat("popup_hide", this, "_selection_menu_hide");
multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY);
divide_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/divide_grid_step", TTR("Divide grid step by 2"), KEY_KP_DIVIDE);
@@ -5742,14 +5881,12 @@ void CanvasItemEditorViewport::_on_change_type_closed() {
}
void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const {
- label->set_position(get_global_position() + Point2(14, 14) * EDSCALE);
- label_desc->set_position(label->get_position() + Point2(0, label->get_size().height));
bool add_preview = false;
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
ERR_FAIL_COND(res.is_null());
- Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
+ Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) {
if (texture != NULL) {
@@ -5806,7 +5943,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe
void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
child->set_name(path.get_file().get_basename());
- Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(ResourceCache::get(path)));
+ Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(ResourceCache::get(path)));
Size2 texture_size = texture->get_size();
if (parent) {
@@ -5823,9 +5960,9 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &
if (parent) {
String new_name = parent->validate_child_name(child);
- ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed, "live_debug_create_node", editor->get_edited_scene()->get_path_to(parent), child->get_class(), new_name);
- editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
+ EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
+ editor_data->get_undo_redo().add_do_method(ed, "live_debug_create_node", editor->get_edited_scene()->get_path_to(parent), child->get_class(), new_name);
+ editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
}
// handle with different property for texture
@@ -5850,7 +5987,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &
if (default_type == "NinePatchRect") {
editor_data->get_undo_redo().add_do_property(child, "rect/size", texture_size);
} else if (default_type == "Polygon2D") {
- PoolVector<Vector2> list;
+ Vector<Vector2> list;
list.push_back(Vector2(0, 0));
list.push_back(Vector2(texture_size.width, 0));
list.push_back(Vector2(texture_size.width, texture_size.height));
@@ -5893,9 +6030,9 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
String new_name = parent->validate_child_name(instanced_scene);
- ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
- editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
+ EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
+ editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
+ editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
CanvasItem *parent_ci = Object::cast_to<CanvasItem>(parent);
if (parent_ci) {
@@ -5943,7 +6080,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
}
}
} else {
- Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
+ Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
if (texture != NULL && texture.is_valid()) {
Node *child;
if (default_type == "Light2D")
@@ -5998,7 +6135,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
continue;
}
memdelete(instanced_scene);
- } else if (type == "Texture" ||
+ } else if (type == "Texture2D" ||
type == "ImageTexture" ||
type == "ViewportTexture" ||
type == "CurveTexture" ||
@@ -6006,7 +6143,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
type == "StreamTexture" ||
type == "AtlasTexture" ||
type == "LargeTexture") {
- Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
+ Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
if (!texture.is_valid()) {
continue;
}
@@ -6097,11 +6234,11 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
void CanvasItemEditorViewport::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- connect("mouse_exited", this, "_on_mouse_exit");
+ connect_compat("mouse_exited", this, "_on_mouse_exit");
label->add_color_override("font_color", get_color("warning_color", "Editor"));
} break;
case NOTIFICATION_EXIT_TREE: {
- disconnect("mouse_exited", this, "_on_mouse_exit");
+ disconnect_compat("mouse_exited", this, "_on_mouse_exit");
} break;
default: break;
@@ -6139,8 +6276,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
selector = memnew(AcceptDialog);
editor->get_gui_base()->add_child(selector);
selector->set_title(TTR("Change Default Type"));
- selector->connect("confirmed", this, "_on_change_type_confirmed");
- selector->connect("popup_hide", this, "_on_change_type_closed");
+ selector->connect_compat("confirmed", this, "_on_change_type_confirmed");
+ selector->connect_compat("popup_hide", this, "_on_change_type_closed");
VBoxContainer *vbc = memnew(VBoxContainer);
selector->add_child(vbc);
@@ -6157,7 +6294,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
CheckBox *check = memnew(CheckBox);
btn_group->add_child(check);
check->set_text(types[i]);
- check->connect("button_down", this, "_on_select_type", varray(check));
+ check->connect_compat("button_down", this, "_on_select_type", varray(check));
check->set_button_group(button_group);
}
@@ -6165,7 +6302,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
label->add_color_override("font_color_shadow", Color(0, 0, 0, 1));
label->add_constant_override("shadow_as_outline", 1 * EDSCALE);
label->hide();
- editor->get_gui_base()->add_child(label);
+ canvas_item_editor->get_controls_container()->add_child(label);
label_desc = memnew(Label);
label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type"));
@@ -6174,7 +6311,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
label_desc->add_constant_override("shadow_as_outline", 1 * EDSCALE);
label_desc->add_constant_override("line_spacing", 0);
label_desc->hide();
- editor->get_gui_base()->add_child(label_desc);
+ canvas_item_editor->get_controls_container()->add_child(label_desc);
+
VS::get_singleton()->canvas_set_disable_scale(true);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 3fdf00d611..3c4cacf5c8 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -119,6 +119,7 @@ private:
SHOW_ORIGIN,
SHOW_VIEWPORT,
SHOW_EDIT_LOCKS,
+ SHOW_TRANSFORMATION_GIZMOS,
LOCK_SELECTED,
UNLOCK_SELECTED,
GROUP_SELECTED,
@@ -189,7 +190,6 @@ private:
SKELETON_SHOW_BONES,
SKELETON_SET_IK_CHAIN,
SKELETON_CLEAR_IK_CHAIN
-
};
enum DragType {
@@ -209,6 +209,8 @@ private:
DRAG_ANCHOR_BOTTOM_LEFT,
DRAG_ANCHOR_ALL,
DRAG_MOVE,
+ DRAG_MOVE_X,
+ DRAG_MOVE_Y,
DRAG_SCALE_X,
DRAG_SCALE_Y,
DRAG_SCALE_BOTH,
@@ -248,10 +250,13 @@ private:
bool show_viewport;
bool show_helpers;
bool show_edit_locks;
+ bool show_transformation_gizmos;
+
float zoom;
Point2 view_offset;
Point2 previous_update_view_offset;
+ bool selected_from_canvas;
bool anchors_mode;
Point2 grid_offset;
@@ -301,7 +306,7 @@ private:
struct _HoverResult {
Point2 position;
- Ref<Texture> icon;
+ Ref<Texture2D> icon;
String name;
};
Vector<_HoverResult> hovering_results;
@@ -401,8 +406,8 @@ private:
Point2 box_selecting_to;
Ref<StyleBoxTexture> select_sb;
- Ref<Texture> select_handle;
- Ref<Texture> anchor_handle;
+ Ref<Texture2D> select_handle;
+ Ref<Texture2D> anchor_handle;
Ref<ShortCut> drag_pivot_shortcut;
Ref<ShortCut> set_pivot_shortcut;
@@ -413,7 +418,7 @@ private:
bool _is_node_locked(const Node *p_node);
bool _is_node_movable(const Node *p_node, bool p_popup_warning = false);
void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
- void _get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items);
+ void _get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, bool p_allow_locked = false);
void _get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items);
void _find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_node, List<CanvasItem *> *r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
@@ -530,6 +535,7 @@ private:
void _button_toggle_anchor_mode(bool p_status);
+ VBoxContainer *controls_vb;
HBoxContainer *zoom_hb;
void _zoom_on_position(float p_zoom, Point2 p_position = Point2());
void _update_zoom_label();
@@ -627,6 +633,8 @@ public:
Control *get_viewport_control() { return viewport; }
+ Control *get_controls_container() { return controls_vb; }
+
void update_viewport();
Tool get_current_tool() { return tool; }
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 0179adc148..3d32c0b698 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h
index 3f0734fb19..a4fa7c7b3b 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.h
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index 8cf09406c7..59bbe031ed 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,7 +47,7 @@ void Polygon3DEditor::_notification(int p_what) {
button_create->set_icon(get_icon("Edit", "EditorIcons"));
button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
- get_tree()->connect("node_removed", this, "_node_removed");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
} break;
case NOTIFICATION_PROCESS: {
@@ -384,7 +384,7 @@ void Polygon3DEditor::_polygon_draw() {
imgeom->clear();
imgeom->set_material_override(line_material);
- imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture>());
+ imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture2D>());
Rect2 rect;
@@ -463,20 +463,18 @@ void Polygon3DEditor::_polygon_draw() {
imgeom->end();
- while (m->get_surface_count()) {
- m->surface_remove(0);
- }
+ m->clear_surfaces();
if (poly.size() == 0)
return;
Array a;
a.resize(Mesh::ARRAY_MAX);
- PoolVector<Vector3> va;
+ Vector<Vector3> va;
{
va.resize(poly.size());
- PoolVector<Vector3>::Write w = va.write();
+ Vector3 *w = va.ptrw();
for (int i = 0; i < poly.size(); i++) {
Vector2 p, p2;
@@ -534,12 +532,12 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
add_child(memnew(VSeparator));
button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
+ button_create->connect_compat("pressed", this, "_menu_option", varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
+ button_edit->connect_compat("pressed", this, "_menu_option", varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
mode = MODE_EDIT;
@@ -547,23 +545,22 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
imgeom = memnew(ImmediateGeometry);
imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));
- line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
line_material->set_albedo(Color(1, 1, 1));
- handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
- handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- Ref<Texture> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons");
+ handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
+ handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ Ref<Texture2D> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons");
handle_material->set_point_size(handle->get_width());
- handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle);
+ handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle);
pointsm = memnew(MeshInstance);
imgeom->add_child(pointsm);
diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h
index 2a904a53ba..3b6c25ac17 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -57,8 +57,8 @@ class Polygon3DEditor : public HBoxContainer {
ToolButton *button_create;
ToolButton *button_edit;
- Ref<SpatialMaterial> line_material;
- Ref<SpatialMaterial> handle_material;
+ Ref<StandardMaterial3D> line_material;
+ Ref<StandardMaterial3D> handle_material;
EditorNode *editor;
Panel *panel;
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index c8561d22a4..01b4a61a85 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -435,7 +435,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture> h = get_icon("EditorHandle", "EditorIcons");
+ Ref<Texture2D> h = get_icon("EditorHandle", "EditorIcons");
Vector2 size = h->get_size() * 0.5;
handles.clear();
@@ -448,8 +448,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
float radius = shape->get_radius();
float height = shape->get_height() / 2;
- handles.write[0] = Point2(radius, -height);
- handles.write[1] = Point2(0, -(height + radius));
+ handles.write[0] = Point2(radius, height);
+ handles.write[1] = Point2(0, height + radius);
p_overlay->draw_texture(h, gt.xform(handles[0]) - size);
p_overlay->draw_texture(h, gt.xform(handles[1]) - size);
@@ -502,8 +502,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
handles.resize(3);
Vector2 ext = shape->get_extents();
handles.write[0] = Point2(ext.x, 0);
- handles.write[1] = Point2(0, -ext.y);
- handles.write[2] = Point2(ext.x, -ext.y);
+ handles.write[1] = Point2(0, ext.y);
+ handles.write[2] = Point2(ext.x, ext.y);
p_overlay->draw_texture(h, gt.xform(handles[0]) - size);
p_overlay->draw_texture(h, gt.xform(handles[1]) - size);
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index 10a1a6bd98..025420a886 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index 374900d4c7..ad3f01ec37 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -118,8 +118,8 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
int vpc = 0;
{
- PoolVector<uint8_t> data = img->get_data();
- PoolVector<uint8_t>::Read r = data.read();
+ Vector<uint8_t> data = img->get_data();
+ const uint8_t *r = data.ptr();
for (int i = 0; i < s.width; i++) {
for (int j = 0; j < s.height; j++) {
@@ -198,9 +198,9 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
ERR_FAIL_COND_MSG(valid_positions.size() == 0, "No pixels with transparency > 128 in image...");
if (capture_colors) {
- PoolColorArray pca;
+ PackedColorArray pca;
pca.resize(vpc);
- PoolColorArray::Write pcaw = pca.write();
+ Color *pcaw = pca.ptrw();
for (int i = 0; i < vpc; i += 1) {
Color color;
color.r = valid_colors[i * 4 + 0] / 255.0f;
@@ -214,9 +214,9 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
if (valid_normals.size()) {
particles->set_emission_shape(CPUParticles2D::EMISSION_SHAPE_DIRECTED_POINTS);
- PoolVector2Array norms;
+ PackedVector2Array norms;
norms.resize(valid_normals.size());
- PoolVector2Array::Write normsw = norms.write();
+ Vector2 *normsw = norms.ptrw();
for (int i = 0; i < valid_normals.size(); i += 1) {
normsw[i] = valid_normals[i];
}
@@ -226,9 +226,9 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
}
{
- PoolVector2Array points;
+ PackedVector2Array points;
points.resize(valid_positions.size());
- PoolVector2Array::Write pointsw = points.write();
+ Vector2 *pointsw = points.ptrw();
for (int i = 0; i < valid_positions.size(); i += 1) {
pointsw[i] = valid_positions[i];
}
@@ -240,9 +240,9 @@ void CPUParticles2DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- menu->get_popup()->connect("id_pressed", this, "_menu_callback");
+ menu->get_popup()->connect_compat("id_pressed", this, "_menu_callback");
menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
- file->connect("file_selected", this, "_file_selected");
+ file->connect_compat("file_selected", this, "_file_selected");
}
}
@@ -296,16 +296,16 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
emission_mask->add_child(emvb);
emission_mask_mode = memnew(OptionButton);
emvb->add_margin_child(TTR("Emission Mask"), emission_mask_mode);
- emission_mask_mode->add_item("Solid Pixels", EMISSION_MODE_SOLID);
- emission_mask_mode->add_item("Border Pixels", EMISSION_MODE_BORDER);
- emission_mask_mode->add_item("Directed Border Pixels", EMISSION_MODE_BORDER_DIRECTED);
+ emission_mask_mode->add_item(TTR("Solid Pixels"), EMISSION_MODE_SOLID);
+ emission_mask_mode->add_item(TTR("Border Pixels"), EMISSION_MODE_BORDER);
+ emission_mask_mode->add_item(TTR("Directed Border Pixels"), EMISSION_MODE_BORDER_DIRECTED);
emission_colors = memnew(CheckBox);
emission_colors->set_text(TTR("Capture from Pixel"));
emvb->add_margin_child(TTR("Emission Colors"), emission_colors);
toolbar->add_child(emission_mask);
- emission_mask->connect("confirmed", this, "_generate_emission_mask");
+ emission_mask->connect_compat("confirmed", this, "_generate_emission_mask");
}
CPUParticles2DEditorPlugin::~CPUParticles2DEditorPlugin() {
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.h b/editor/plugins/cpu_particles_2d_editor_plugin.h
index 84bbfff095..21b06b6489 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.h
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/cpu_particles_editor_plugin.cpp b/editor/plugins/cpu_particles_editor_plugin.cpp
index 93ffce41fa..3d438226d2 100644
--- a/editor/plugins/cpu_particles_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -51,12 +51,6 @@ void CPUParticlesEditor::_menu_option(int p_option) {
switch (p_option) {
- case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: {
-
- emission_file_dialog->popup_centered_ratio();
-
- } break;
-
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
emission_tree_dialog->popup_centered_ratio();
@@ -80,8 +74,8 @@ void CPUParticlesEditor::edit(CPUParticles *p_particles) {
void CPUParticlesEditor::_generate_emission_points() {
/// hacer codigo aca
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
if (!_generate(points, normals)) {
return;
@@ -112,11 +106,10 @@ CPUParticlesEditor::CPUParticlesEditor() {
particles_editor_hb->hide();
options->set_text(TTR("CPUParticles"));
- options->get_popup()->add_item(TTR("Create Emission Points From Mesh"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH);
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
- options->get_popup()->connect("id_pressed", this, "_menu_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_menu_option");
}
void CPUParticlesEditorPlugin::edit(Object *p_object) {
diff --git a/editor/plugins/cpu_particles_editor_plugin.h b/editor/plugins/cpu_particles_editor_plugin.h
index 674f00dc9f..4cf143fc0c 100644
--- a/editor/plugins/cpu_particles_editor_plugin.h
+++ b/editor/plugins/cpu_particles_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,6 @@ class CPUParticlesEditor : public ParticlesEditorBase {
enum Menu {
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE,
- MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH,
MENU_OPTION_CLEAR_EMISSION_VOLUME,
MENU_OPTION_RESTART
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 727d92ba05..5f4fb19d9e 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,6 +34,7 @@
#include "core/core_string_names.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
CurveEditor::CurveEditor() {
_selected_point = -1;
@@ -48,7 +49,7 @@ CurveEditor::CurveEditor() {
set_clip_contents(true);
_context_menu = memnew(PopupMenu);
- _context_menu->connect("id_pressed", this, "_on_context_menu_item_selected");
+ _context_menu->connect_compat("id_pressed", this, "_on_context_menu_item_selected");
add_child(_context_menu);
_presets_menu = memnew(PopupMenu);
@@ -59,7 +60,7 @@ CurveEditor::CurveEditor() {
_presets_menu->add_item(TTR("Ease In"), PRESET_EASE_IN);
_presets_menu->add_item(TTR("Ease Out"), PRESET_EASE_OUT);
_presets_menu->add_item(TTR("Smoothstep"), PRESET_SMOOTHSTEP);
- _presets_menu->connect("id_pressed", this, "_on_preset_item_selected");
+ _presets_menu->connect_compat("id_pressed", this, "_on_preset_item_selected");
_context_menu->add_child(_presets_menu);
}
@@ -69,15 +70,15 @@ void CurveEditor::set_curve(Ref<Curve> curve) {
return;
if (_curve_ref.is_valid()) {
- _curve_ref->disconnect(CoreStringNames::get_singleton()->changed, this, "_curve_changed");
- _curve_ref->disconnect(Curve::SIGNAL_RANGE_CHANGED, this, "_curve_changed");
+ _curve_ref->disconnect_compat(CoreStringNames::get_singleton()->changed, this, "_curve_changed");
+ _curve_ref->disconnect_compat(Curve::SIGNAL_RANGE_CHANGED, this, "_curve_changed");
}
_curve_ref = curve;
if (_curve_ref.is_valid()) {
- _curve_ref->connect(CoreStringNames::get_singleton()->changed, this, "_curve_changed");
- _curve_ref->connect(Curve::SIGNAL_RANGE_CHANGED, this, "_curve_changed");
+ _curve_ref->connect_compat(CoreStringNames::get_singleton()->changed, this, "_curve_changed");
+ _curve_ref->connect_compat(Curve::SIGNAL_RANGE_CHANGED, this, "_curve_changed");
}
_selected_point = -1;
@@ -510,8 +511,8 @@ void CurveEditor::set_hover_point_index(int index) {
}
void CurveEditor::update_view_transform() {
- Vector2 control_size = get_size();
- const real_t margin = 24;
+ Ref<Font> font = get_font("font", "Label");
+ const real_t margin = font->get_height() + 2 * EDSCALE;
float min_y = 0;
float max_y = 1;
@@ -521,15 +522,19 @@ void CurveEditor::update_view_transform() {
max_y = _curve_ref->get_max_value();
}
- Rect2 world_rect = Rect2(Curve::MIN_X, min_y, Curve::MAX_X, max_y - min_y);
- Vector2 wm = Vector2(margin, margin) / control_size;
- wm.y *= (max_y - min_y);
- world_rect.position -= wm;
- world_rect.size += 2.0 * wm;
+ const Rect2 world_rect = Rect2(Curve::MIN_X, min_y, Curve::MAX_X, max_y - min_y);
+ const Size2 view_margin(margin, margin);
+ const Size2 view_size = get_size() - view_margin * 2;
+ const Vector2 scale = view_size / world_rect.size;
+
+ Transform2D world_trans;
+ world_trans.translate(-world_rect.position - Vector2(0, world_rect.size.y));
+ world_trans.scale(Vector2(scale.x, -scale.y));
+
+ Transform2D view_trans;
+ view_trans.translate(view_margin);
- _world_to_view = Transform2D();
- _world_to_view.translate(-world_rect.position - Vector2(0, world_rect.size.y));
- _world_to_view.scale(Vector2(control_size.x, -control_size.y) / world_rect.size);
+ _world_to_view = view_trans * world_trans;
}
Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const {
@@ -607,7 +612,7 @@ struct CanvasItemPlotCurve {
void operator()(Vector2 pos0, Vector2 pos1, bool in_definition) {
// FIXME: Using a line width greater than 1 breaks curve rendering
- ci.draw_line(pos0, pos1, in_definition ? color1 : color2, 1, true);
+ ci.draw_line(pos0, pos1, in_definition ? color1 : color2, 1);
}
};
@@ -688,13 +693,13 @@ void CurveEditor::_draw() {
if (i != 0) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_LEFT);
- draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE), true);
+ draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE));
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color);
}
if (i != curve.get_point_count() - 1) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_RIGHT);
- draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE), true);
+ draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE));
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color);
}
}
@@ -735,10 +740,10 @@ void CurveEditor::_draw() {
if (_selected_point > 0 && _selected_point + 1 < curve.get_point_count()) {
text_color.a *= 0.4;
- draw_string(font, Vector2(50, font_height), TTR("Hold Shift to edit tangents individually"), text_color);
+ draw_string(font, Vector2(50 * EDSCALE, font_height), TTR("Hold Shift to edit tangents individually"), text_color);
} else if (curve.get_point_count() == 0) {
text_color.a *= 0.4;
- draw_string(font, Vector2(50, font_height), TTR("Right click to add point"), text_color);
+ draw_string(font, Vector2(50 * EDSCALE, font_height), TTR("Right click to add point"), text_color);
}
}
@@ -782,10 +787,10 @@ bool CurvePreviewGenerator::handles(const String &p_type) const {
return p_type == "Curve";
}
-Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
+Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Curve> curve_ref = p_from;
- ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture>(), "It's not a reference to a valid Resource object.");
+ ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture2D>(), "It's not a reference to a valid Resource object.");
Curve &curve = **curve_ref;
// FIXME: Should be ported to use p_size as done in b2633a97
@@ -797,8 +802,6 @@ Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const
im.create(thumbnail_size, thumbnail_size / 2, 0, Image::FORMAT_RGBA8);
- im.lock();
-
Color bg_color(0.1, 0.1, 0.1, 1.0);
for (int i = 0; i < thumbnail_size; i++) {
for (int j = 0; j < thumbnail_size / 2; j++) {
@@ -839,10 +842,8 @@ Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const
prev_y = y;
}
- im.unlock();
-
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
- ptex->create_from_image(img_ref, 0);
+ ptex->create_from_image(img_ref);
return ptex;
}
diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h
index 9071146863..c00aa3eca5 100644
--- a/editor/plugins/curve_editor_plugin.h
+++ b/editor/plugins/curve_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,7 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
+#include "editor/editor_resource_preview.h"
#include "scene/resources/curve.h"
// Edits a y(x) curve
@@ -140,7 +141,7 @@ class CurvePreviewGenerator : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
};
#endif // CURVE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
new file mode 100644
index 0000000000..2534a2cc17
--- /dev/null
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -0,0 +1,51 @@
+/*************************************************************************/
+/* debugger_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "debugger_editor_plugin.h"
+
+#include "core/os/keyboard.h"
+#include "editor/debugger/editor_debugger_node.h"
+
+DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor) {
+ ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11);
+ ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10);
+ ED_SHORTCUT("debugger/break", TTR("Break"));
+ ED_SHORTCUT("debugger/continue", TTR("Continue"), KEY_F12);
+ ED_SHORTCUT("debugger/keep_debugger_open", TTR("Keep Debugger Open"));
+ ED_SHORTCUT("debugger/debug_with_external_editor", TTR("Debug with External Editor"));
+
+ EditorDebuggerNode *debugger = memnew(EditorDebuggerNode);
+ Button *db = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Debugger"), debugger);
+ debugger->set_tool_button(db);
+}
+
+DebuggerEditorPlugin::~DebuggerEditorPlugin() {
+ // Should delete debugger?
+}
diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h
new file mode 100644
index 0000000000..05d6ece72d
--- /dev/null
+++ b/editor/plugins/debugger_editor_plugin.h
@@ -0,0 +1,50 @@
+/*************************************************************************/
+/* debugger_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef DEBUGGER_EDITOR_PLUGIN_H
+#define DEBUGGER_EDITOR_PLUGIN_H
+
+#include "editor/debugger/editor_debugger_node.h"
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+
+class DebuggerEditorPlugin : public EditorPlugin {
+
+ GDCLASS(DebuggerEditorPlugin, EditorPlugin);
+
+public:
+ virtual String get_name() const { return "Debugger"; }
+ bool has_main_screen() const { return false; }
+
+ DebuggerEditorPlugin(EditorNode *p_node);
+ ~DebuggerEditorPlugin();
+};
+
+#endif // DEBUGGER_EDITOR_PLUGIN_H
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 007ce58bd7..3c173ab783 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -40,14 +40,13 @@
#include "scene/resources/dynamic_font.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
+#include "servers/audio/audio_stream.h"
void post_process_preview(Ref<Image> p_image) {
if (p_image->get_format() != Image::FORMAT_RGBA8)
p_image->convert(Image::FORMAT_RGBA8);
- p_image->lock();
-
const int w = p_image->get_width();
const int h = p_image->get_height();
@@ -69,40 +68,38 @@ void post_process_preview(Ref<Image> p_image) {
}
}
}
-
- p_image->unlock();
}
bool EditorTexturePreviewPlugin::handles(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "Texture");
+ return ClassDB::is_parent_class(p_type, "Texture2D");
}
bool EditorTexturePreviewPlugin::generate_small_preview_automatically() const {
return true;
}
-Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Image> img;
Ref<AtlasTexture> atex = p_from;
Ref<LargeTexture> ltex = p_from;
if (atex.is_valid()) {
- Ref<Texture> tex = atex->get_atlas();
+ Ref<Texture2D> tex = atex->get_atlas();
if (!tex.is_valid()) {
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
Ref<Image> atlas = tex->get_data();
if (!atlas.is_valid()) {
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
img = atlas->get_rect(atex->get_region());
} else if (ltex.is_valid()) {
img = ltex->to_image();
} else {
- Ref<Texture> tex = p_from;
+ Ref<Texture2D> tex = p_from;
if (tex.is_valid()) {
img = tex->get_data();
if (img.is_valid()) {
@@ -112,13 +109,13 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2
}
if (img.is_null() || img->empty())
- return Ref<Texture>();
+ return Ref<Texture2D>();
img->clear_mipmaps();
if (img->is_compressed()) {
if (img->decompress() != OK)
- return Ref<Texture>();
+ return Ref<Texture2D>();
} else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8);
}
@@ -136,7 +133,7 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
}
@@ -150,7 +147,7 @@ bool EditorImagePreviewPlugin::handles(const String &p_type) const {
return p_type == "Image";
}
-Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Image> img = p_from;
@@ -181,7 +178,7 @@ Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &
Ref<ImageTexture> ptex;
ptex.instance();
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
}
@@ -198,27 +195,27 @@ bool EditorBitmapPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "BitMap");
}
-Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<BitMap> bm = p_from;
if (bm->get_size() == Size2()) {
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(bm->get_size().width * bm->get_size().height);
{
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
for (int i = 0; i < bm->get_size().width; i++) {
for (int j = 0; j < bm->get_size().height; j++) {
if (bm->get_bit(Point2i(i, j))) {
- w[j * bm->get_size().width + i] = 255;
+ w[j * (int)bm->get_size().width + i] = 255;
} else {
- w[j * bm->get_size().width + i] = 0;
+ w[j * (int)bm->get_size().width + i] = 0;
}
}
}
@@ -230,7 +227,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2
if (img->is_compressed()) {
if (img->decompress() != OK)
- return Ref<Texture>();
+ return Ref<Texture2D>();
} else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8);
}
@@ -248,7 +245,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
}
@@ -265,12 +262,13 @@ bool EditorPackedScenePreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "PackedScene");
}
-Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+
+Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
return generate_from_path(p_from->get_path(), p_size);
}
-Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
+Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
String temp_path = EditorSettings::get_singleton()->get_cache_dir();
String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text();
@@ -281,7 +279,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_
String path = cache_base + ".png";
if (!FileAccess::exists(path))
- return Ref<Texture>();
+ return Ref<Texture2D>();
Ref<Image> img;
img.instance();
@@ -291,11 +289,11 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
post_process_preview(img);
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
} else {
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
}
@@ -323,10 +321,10 @@ bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const {
return true;
}
-Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Material> material = p_from;
- ERR_FAIL_COND_V(material.is_null(), Ref<Texture>());
+ ERR_FAIL_COND_V(material.is_null(), Ref<Texture2D>());
if (material->get_shader_mode() == Shader::MODE_SPATIAL) {
@@ -341,7 +339,7 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size
OS::get_singleton()->delay_usec(10);
}
- Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
+ Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID());
ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>());
@@ -351,11 +349,11 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size
img->resize(thumbnail_size, thumbnail_size, Image::INTERPOLATE_CUBIC);
post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
}
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
@@ -368,7 +366,6 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
VS::get_singleton()->viewport_set_size(viewport, 128, 128);
VS::get_singleton()->viewport_set_transparent_background(viewport, true);
VS::get_singleton()->viewport_set_active(viewport, true);
- VS::get_singleton()->viewport_set_vflip(viewport, true);
viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
camera = VS::get_singleton()->camera_create();
@@ -395,10 +392,10 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
int lons = 32;
float radius = 1.0;
- PoolVector<Vector3> vertices;
- PoolVector<Vector3> normals;
- PoolVector<Vector2> uvs;
- PoolVector<float> tangents;
+ Vector<Vector3> vertices;
+ Vector<Vector3> normals;
+ Vector<Vector2> uvs;
+ Vector<float> tangents;
Basis tt = Basis(Vector3(0, 1, 0), Math_PI * 0.5);
for (int i = 1; i <= lats; i++) {
@@ -489,15 +486,15 @@ bool EditorScriptPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Script");
}
-Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Script> scr = p_from;
if (scr.is_null())
- return Ref<Texture>();
+ return Ref<Texture2D>();
String code = scr->get_source_code().strip_edges();
if (code == "")
- return Ref<Texture>();
+ return Ref<Texture2D>();
List<String> kwors;
scr->get_language()->get_reserved_words(&kwors);
@@ -521,8 +518,6 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2
Color text_color = EditorSettings::get_singleton()->get("text_editor/highlighting/text_color");
Color symbol_color = EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color");
- img->lock();
-
if (bg_color.a == 0)
bg_color = Color(0, 0, 0, 0);
bg_color.a = MAX(bg_color.a, 0.2); // some background
@@ -592,13 +587,11 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2
col++;
}
- img->unlock();
-
post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
}
@@ -611,22 +604,22 @@ bool EditorAudioStreamPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "AudioStream");
}
-Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<AudioStream> stream = p_from;
- ERR_FAIL_COND_V(stream.is_null(), Ref<Texture>());
+ ERR_FAIL_COND_V(stream.is_null(), Ref<Texture2D>());
- PoolVector<uint8_t> img;
+ Vector<uint8_t> img;
int w = p_size.x;
int h = p_size.y;
img.resize(w * h * 3);
- PoolVector<uint8_t>::Write imgdata = img.write();
- uint8_t *imgw = imgdata.ptr();
+ uint8_t *imgdata = img.ptrw();
+ uint8_t *imgw = imgdata;
Ref<AudioStreamPlayback> playback = stream->instance_playback();
- ERR_FAIL_COND_V(playback.is_null(), Ref<Texture>());
+ ERR_FAIL_COND_V(playback.is_null(), Ref<Texture2D>());
float len_s = stream->get_length();
if (len_s == 0) {
@@ -679,14 +672,13 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S
}
}
- imgdata.release();
//post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
Ref<Image> image;
image.instance();
image->create(w, h, false, Image::FORMAT_RGB8, img);
- ptex->create_from_image(image, 0);
+ ptex->create_from_image(image);
return ptex;
}
@@ -709,10 +701,10 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh
}
-Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Mesh> mesh = p_from;
- ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture>());
+ ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>());
VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid());
@@ -725,7 +717,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p
AABB rot_aabb = xform.xform(aabb);
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
if (m == 0)
- return Ref<Texture>();
+ return Ref<Texture2D>();
m = 1.0 / m;
m *= 0.5;
xform.basis.scale(Vector3(m, m, m));
@@ -742,7 +734,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p
OS::get_singleton()->delay_usec(10);
}
- Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
+ Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
VS::get_singleton()->instance_set_base(mesh_instance, RID());
@@ -761,7 +753,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p
post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
}
@@ -771,7 +763,6 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
viewport = VS::get_singleton()->viewport_create();
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED);
- VS::get_singleton()->viewport_set_vflip(viewport, true);
VS::get_singleton()->viewport_set_scenario(viewport, scenario);
VS::get_singleton()->viewport_set_size(viewport, 128, 128);
VS::get_singleton()->viewport_set_transparent_background(viewport, true);
@@ -827,19 +818,23 @@ void EditorFontPreviewPlugin::_bind_methods() {
bool EditorFontPreviewPlugin::handles(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "DynamicFontData");
+ return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont");
}
-Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
-
- Ref<DynamicFontData> SampledFont;
- SampledFont.instance();
- SampledFont->set_font_path(p_path);
+Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
+ RES res = ResourceLoader::load(p_path);
Ref<DynamicFont> sampled_font;
- sampled_font.instance();
+ if (res->is_class("DynamicFont")) {
+ sampled_font = res->duplicate();
+ if (sampled_font->get_outline_color() == Color(1, 1, 1, 1)) {
+ sampled_font->set_outline_color(Color(0, 0, 0, 1));
+ }
+ } else if (res->is_class("DynamicFontData")) {
+ sampled_font.instance();
+ sampled_font->set_font_data(res);
+ }
sampled_font->set_size(50);
- sampled_font->set_font_data(SampledFont);
String sampled_text = "Abg";
Vector2 size = sampled_font->get_string_size(sampled_text);
@@ -863,7 +858,7 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c
VS::get_singleton()->canvas_item_clear(canvas_item);
- Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
+ Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
img->convert(Image::FORMAT_RGBA8);
@@ -880,16 +875,16 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c
post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
- ptex->create_from_image(img, 0);
+ ptex->create_from_image(img);
return ptex;
}
-Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
+Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
String path = p_from->get_path();
if (!FileAccess::exists(path)) {
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
return generate_from_path(path, p_size);
}
@@ -898,7 +893,6 @@ EditorFontPreviewPlugin::EditorFontPreviewPlugin() {
viewport = VS::get_singleton()->viewport_create();
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED);
- VS::get_singleton()->viewport_set_vflip(viewport, true);
VS::get_singleton()->viewport_set_size(viewport, 128, 128);
VS::get_singleton()->viewport_set_active(viewport, true);
viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h
index 71a6c0fc08..840fa2410a 100644
--- a/editor/plugins/editor_preview_plugins.h
+++ b/editor/plugins/editor_preview_plugins.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@ class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorTexturePreviewPlugin();
};
@@ -52,7 +52,7 @@ class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorImagePreviewPlugin();
};
@@ -63,7 +63,7 @@ class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorBitmapPreviewPlugin();
};
@@ -72,8 +72,8 @@ class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
- virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const;
EditorPackedScenePreviewPlugin();
};
@@ -102,7 +102,7 @@ protected:
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorMaterialPreviewPlugin();
~EditorMaterialPreviewPlugin();
@@ -111,7 +111,7 @@ public:
class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorScriptPreviewPlugin();
};
@@ -119,7 +119,7 @@ public:
class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorAudioStreamPreviewPlugin();
};
@@ -146,7 +146,7 @@ protected:
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorMeshPreviewPlugin();
~EditorMeshPreviewPlugin();
@@ -169,8 +169,8 @@ protected:
public:
virtual bool handles(const String &p_type) const;
- virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
- virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
+ virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const;
EditorFontPreviewPlugin();
~EditorFontPreviewPlugin();
diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index a6125af1f7..9231d38a02 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,18 @@
void GIProbeEditorPlugin::_bake() {
if (gi_probe) {
+ if (gi_probe->get_probe_data().is_null()) {
+ String path = get_tree()->get_edited_scene_root()->get_filename();
+ if (path == String()) {
+ path = "res://" + gi_probe->get_name() + "_data.res";
+ } else {
+ String ext = path.get_extension();
+ path = path.get_basename() + "." + gi_probe->get_name() + "_data.res";
+ }
+ probe_file->set_current_path(path);
+ probe_file->popup_centered_ratio();
+ return;
+ }
gi_probe->bake();
}
}
@@ -51,13 +63,42 @@ bool GIProbeEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("GIProbe");
}
+void GIProbeEditorPlugin::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_PROCESS) {
+ if (!gi_probe) {
+ return;
+ }
+
+ String text;
+
+ Vector3i size = gi_probe->get_estimated_cell_size();
+ text = itos(size.x) + ", " + itos(size.y) + ", " + itos(size.z);
+ int data_size = 4;
+ if (GLOBAL_GET("rendering/quality/gi_probes/anisotropic")) {
+ data_size += 4;
+ }
+ text += " - VRAM Size: " + String::num(size.x * size.y * size.z * data_size / (1024.0 * 1024.0), 2) + " Mb.";
+
+ if (bake_info->get_text() == text) {
+ return;
+ }
+
+ bake_info->add_color_override("font_color", bake_info->get_color("success_color", "Editor"));
+
+ bake_info->set_text(text);
+ }
+}
+
void GIProbeEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- bake->show();
+ bake_hb->show();
+ set_process(true);
} else {
- bake->hide();
+ bake_hb->hide();
+ set_process(false);
}
}
@@ -82,21 +123,45 @@ void GIProbeEditorPlugin::bake_func_end() {
tmp_progress = NULL;
}
+void GIProbeEditorPlugin::_giprobe_save_path_and_bake(const String &p_path) {
+ probe_file->hide();
+ if (gi_probe) {
+ gi_probe->bake();
+ ERR_FAIL_COND(gi_probe->get_probe_data().is_null());
+ ResourceSaver::save(p_path, gi_probe->get_probe_data(), ResourceSaver::FLAG_CHANGE_PATH);
+ }
+}
+
void GIProbeEditorPlugin::_bind_methods() {
ClassDB::bind_method("_bake", &GIProbeEditorPlugin::_bake);
+ ClassDB::bind_method("_giprobe_save_path_and_bake", &GIProbeEditorPlugin::_giprobe_save_path_and_bake);
}
GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
editor = p_node;
+ bake_hb = memnew(HBoxContainer);
+ bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ bake_hb->hide();
bake = memnew(ToolButton);
bake->set_icon(editor->get_gui_base()->get_icon("Bake", "EditorIcons"));
bake->set_text(TTR("Bake GI Probe"));
- bake->hide();
- bake->connect("pressed", this, "_bake");
- add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake);
+ bake->connect_compat("pressed", this, "_bake");
+ bake_hb->add_child(bake);
+ bake_info = memnew(Label);
+ bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ bake_info->set_clip_text(true);
+ bake_hb->add_child(bake_info);
+
+ add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb);
gi_probe = NULL;
+ probe_file = memnew(EditorFileDialog);
+ probe_file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ probe_file->add_filter("*.res");
+ probe_file->connect_compat("file_selected", this, "_giprobe_save_path_and_bake");
+ get_editor_interface()->get_base_control()->add_child(probe_file);
+ probe_file->set_title(TTR("Select path for GIProbe Data File"));
GIProbe::bake_begin_function = bake_func_begin;
GIProbe::bake_step_function = bake_func_step;
diff --git a/editor/plugins/gi_probe_editor_plugin.h b/editor/plugins/gi_probe_editor_plugin.h
index c33668ae19..2068ebaaa8 100644
--- a/editor/plugins/gi_probe_editor_plugin.h
+++ b/editor/plugins/gi_probe_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,18 +42,24 @@ class GIProbeEditorPlugin : public EditorPlugin {
GIProbe *gi_probe;
+ HBoxContainer *bake_hb;
+ Label *bake_info;
ToolButton *bake;
EditorNode *editor;
+ EditorFileDialog *probe_file;
+
static EditorProgress *tmp_progress;
static void bake_func_begin(int p_steps);
static void bake_func_step(int p_step, const String &p_description);
static void bake_func_end();
void _bake();
+ void _giprobe_save_path_and_bake(const String &p_path);
protected:
static void _bind_methods();
+ void _notification(int p_what);
public:
virtual String get_name() const { return "GIProbe"; }
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index e85c475ad7..b36782ee14 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,7 @@
#include "gradient_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "editor/editor_scale.h"
#include "spatial_editor_plugin.h"
Size2 GradientEditor::get_minimum_size() const {
@@ -68,8 +69,8 @@ void GradientEditor::_bind_methods() {
void GradientEditor::set_gradient(const Ref<Gradient> &p_gradient) {
gradient = p_gradient;
- connect("ramp_changed", this, "_ramp_changed");
- gradient->connect("changed", this, "_gradient_changed");
+ connect_compat("ramp_changed", this, "_ramp_changed");
+ gradient->connect_compat("changed", this, "_gradient_changed");
set_points(gradient->get_points());
}
diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h
index a87a5fe0ba..9ebd9610e5 100644
--- a/editor/plugins/gradient_editor_plugin.h
+++ b/editor/plugins/gradient_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index b3f3ccf501..b872a2d932 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,7 @@
#include "item_list_editor_plugin.h"
#include "core/io/resource_loader.h"
+#include "editor/editor_scale.h"
bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) {
@@ -104,7 +105,7 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
String base = itos(i) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, base + "text"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"));
int flags = get_flags();
@@ -267,7 +268,7 @@ void ItemListEditor::_notification(int p_notification) {
del_button->set_icon(get_icon("Remove", "EditorIcons"));
} else if (p_notification == NOTIFICATION_READY) {
- get_tree()->connect("node_removed", this, "_node_removed");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
}
}
@@ -301,7 +302,7 @@ void ItemListEditor::_delete_pressed() {
void ItemListEditor::_edit_items() {
- dialog->popup_centered(Vector2(300, 400) * EDSCALE);
+ dialog->popup_centered_clamped(Vector2(425, 1200) * EDSCALE, 0.8);
}
void ItemListEditor::edit(Node *p_item_list) {
@@ -358,7 +359,7 @@ ItemListEditor::ItemListEditor() {
toolbar_button = memnew(ToolButton);
toolbar_button->set_text(TTR("Items"));
add_child(toolbar_button);
- toolbar_button->connect("pressed", this, "_edit_items");
+ toolbar_button->connect_compat("pressed", this, "_edit_items");
dialog = memnew(AcceptDialog);
dialog->set_title(TTR("Item List Editor"));
@@ -375,14 +376,14 @@ ItemListEditor::ItemListEditor() {
add_button = memnew(Button);
add_button->set_text(TTR("Add"));
hbc->add_child(add_button);
- add_button->connect("pressed", this, "_add_button");
+ add_button->connect_compat("pressed", this, "_add_button");
hbc->add_spacer();
del_button = memnew(Button);
del_button->set_text(TTR("Delete"));
hbc->add_child(del_button);
- del_button->connect("pressed", this, "_delete_button");
+ del_button->connect_compat("pressed", this, "_delete_button");
property_editor = memnew(EditorInspector);
vbc->add_child(property_editor);
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 78b176620e..8dcf938139 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -66,8 +66,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) {}
virtual String get_item_text(int p_idx) const { return ""; };
- virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) {}
- virtual Ref<Texture> get_item_icon(int p_idx) const { return Ref<Texture>(); };
+ virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) {}
+ virtual Ref<Texture2D> get_item_icon(int p_idx) const { return Ref<Texture2D>(); };
virtual void set_item_checkable(int p_idx, bool p_check) {}
virtual void set_item_radio_checkable(int p_idx, bool p_check) {}
@@ -109,8 +109,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) { ob->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return ob->get_item_text(p_idx); }
- virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { ob->set_item_icon(p_idx, p_tex); }
- virtual Ref<Texture> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); }
+ virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { ob->set_item_icon(p_idx, p_tex); }
+ virtual Ref<Texture2D> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); }
virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); }
@@ -139,8 +139,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
- virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
- virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
+ virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
+ virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx, p_check); }
virtual void set_item_radio_checkable(int p_idx, bool p_check) { pp->set_item_as_radio_checkable(p_idx, p_check); }
@@ -182,8 +182,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
- virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
- virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
+ virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
+ virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index d8f6259598..22df287f97 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h
index 95fa0df2c1..74ae9e0889 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.h
+++ b/editor/plugins/light_occluder_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 368cf719c6..4ac9d0af3b 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h
index a7a9813cb5..ef54dbc3f7 100644
--- a/editor/plugins/line_2d_editor_plugin.h
+++ b/editor/plugins/line_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index e125c18ef1..bca0bde441 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,6 +30,8 @@
#include "material_editor_plugin.h"
+#include "editor/editor_scale.h"
+#include "scene/gui/viewport_container.h"
#include "scene/resources/particles_material.h"
void MaterialEditor::_notification(int p_what) {
@@ -57,7 +59,7 @@ void MaterialEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
+ Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
@@ -169,13 +171,13 @@ MaterialEditor::MaterialEditor() {
sphere_switch->set_toggle_mode(true);
sphere_switch->set_pressed(true);
vb_shape->add_child(sphere_switch);
- sphere_switch->connect("pressed", this, "_button_pressed", varray(sphere_switch));
+ sphere_switch->connect_compat("pressed", this, "_button_pressed", varray(sphere_switch));
box_switch = memnew(TextureButton);
box_switch->set_toggle_mode(true);
box_switch->set_pressed(false);
vb_shape->add_child(box_switch);
- box_switch->connect("pressed", this, "_button_pressed", varray(box_switch));
+ box_switch->connect_compat("pressed", this, "_button_pressed", varray(box_switch));
hb->add_spacer();
@@ -185,12 +187,12 @@ MaterialEditor::MaterialEditor() {
light_1_switch = memnew(TextureButton);
light_1_switch->set_toggle_mode(true);
vb_light->add_child(light_1_switch);
- light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));
+ light_1_switch->connect_compat("pressed", this, "_button_pressed", varray(light_1_switch));
light_2_switch = memnew(TextureButton);
light_2_switch->set_toggle_mode(true);
vb_light->add_child(light_2_switch);
- light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));
+ light_2_switch->connect_compat("pressed", this, "_button_pressed", varray(light_2_switch));
first_enter = true;
}
@@ -223,7 +225,9 @@ EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() {
env.instance();
Ref<ProceduralSky> proc_sky = memnew(ProceduralSky(true));
env->set_sky(proc_sky);
- env->set_background(Environment::BG_COLOR_SKY);
+ env->set_background(Environment::BG_COLOR);
+ env->set_ambient_source(Environment::AMBIENT_SOURCE_SKY);
+ env->set_reflection_source(Environment::REFLECTION_SOURCE_SKY);
}
MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
@@ -233,18 +237,18 @@ MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
add_inspector_plugin(plugin);
}
-String SpatialMaterialConversionPlugin::converts_to() const {
+String StandardMaterial3DConversionPlugin::converts_to() const {
return "ShaderMaterial";
}
-bool SpatialMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool StandardMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource) const {
- Ref<SpatialMaterial> mat = p_resource;
+ Ref<StandardMaterial3D> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const {
- Ref<SpatialMaterial> mat = p_resource;
+ Ref<StandardMaterial3D> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
@@ -264,9 +268,9 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
- // Texture parameter has to be treated specially since SpatialMaterial saved it
+ // Texture parameter has to be treated specially since StandardMaterial3D saved it
// as RID but ShaderMaterial needs Texture itself
- Ref<Texture> texture = mat->get_texture_by_name(E->get().name);
+ Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name);
if (texture.is_valid()) {
smat->set_shader_param(E->get().name, texture);
} else {
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 1405127ab3..95a6c4bf8f 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,6 +41,8 @@
#include "scene/3d/mesh_instance.h"
#include "scene/resources/material.h"
+class ViewportContainer;
+
class MaterialEditor : public Control {
GDCLASS(MaterialEditor, Control);
@@ -98,8 +100,8 @@ public:
MaterialEditorPlugin(EditorNode *p_node);
};
-class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin {
- GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin);
+class StandardMaterial3DConversionPlugin : public EditorResourceConversionPlugin {
+ GDCLASS(StandardMaterial3DConversionPlugin, EditorResourceConversionPlugin);
public:
virtual String converts_to() const;
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 442110cc84..2b25a2328c 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,6 +30,8 @@
#include "mesh_editor_plugin.h"
+#include "editor/editor_scale.h"
+
void MeshEditor::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventMouseMotion> mm = p_event;
@@ -155,12 +157,12 @@ MeshEditor::MeshEditor() {
light_1_switch = memnew(TextureButton);
light_1_switch->set_toggle_mode(true);
vb_light->add_child(light_1_switch);
- light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));
+ light_1_switch->connect_compat("pressed", this, "_button_pressed", varray(light_1_switch));
light_2_switch = memnew(TextureButton);
light_2_switch->set_toggle_mode(true);
vb_light->add_child(light_2_switch);
- light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));
+ light_2_switch->connect_compat("pressed", this, "_button_pressed", varray(light_2_switch));
first_enter = true;
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 4c2a81ed70..87c4a1776b 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,6 +36,7 @@
#include "scene/3d/camera.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
+#include "scene/gui/viewport_container.h"
#include "scene/resources/material.h"
class MeshEditor : public ViewportContainer {
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index 22df8fd8f4..182a8600e4 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,8 +30,9 @@
#include "mesh_instance_editor_plugin.h"
+#include "editor/editor_scale.h"
#include "scene/3d/collision_shape.h"
-#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/navigation_mesh_instance.h"
#include "scene/3d/physics_body.h"
#include "scene/gui/box_container.h"
#include "spatial_editor_plugin.h"
@@ -59,10 +60,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
}
switch (p_option) {
- case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY:
- case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: {
-
- bool trimesh_shape = (p_option == MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
+ case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: {
EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
@@ -70,9 +68,12 @@ void MeshInstanceEditor::_menu_option(int p_option) {
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
- Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape();
- if (shape.is_null())
+ Ref<Shape> shape = mesh->create_trimesh_shape();
+ if (shape.is_null()) {
+ err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
+ err_dialog->popup_centered_minsize();
return;
+ }
CollisionShape *cshape = memnew(CollisionShape);
cshape->set_shape(shape);
@@ -81,11 +82,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
- if (trimesh_shape)
- ur->create_action(TTR("Create Static Trimesh Body"));
- else
- ur->create_action(TTR("Create Static Convex Body"));
-
+ ur->create_action(TTR("Create Static Trimesh Body"));
ur->add_do_method(node, "add_child", body);
ur->add_do_method(body, "set_owner", owner);
ur->add_do_method(cshape, "set_owner", owner);
@@ -107,7 +104,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (m.is_null())
continue;
- Ref<Shape> shape = trimesh_shape ? m->create_trimesh_shape() : m->create_convex_shape();
+ Ref<Shape> shape = m->create_trimesh_shape();
if (shape.is_null())
continue;
@@ -157,10 +154,44 @@ void MeshInstanceEditor::_menu_option(int p_option) {
ur->add_undo_method(node->get_parent(), "remove_child", cshape);
ur->commit_action();
} break;
- case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: {
+ case MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE: {
if (node == get_tree()->get_edited_scene_root()) {
- err_dialog->set_text(TTR("This doesn't work on scene root!"));
+ err_dialog->set_text(TTR("Can't create a single convex collision shape for the scene root."));
+ err_dialog->popup_centered_minsize();
+ return;
+ }
+
+ Ref<Shape> shape = mesh->create_convex_shape();
+
+ if (shape.is_null()) {
+ err_dialog->set_text(TTR("Couldn't create a single convex collision shape."));
+ err_dialog->popup_centered_minsize();
+ return;
+ }
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+
+ ur->create_action(TTR("Create Single Convex Shape"));
+
+ CollisionShape *cshape = memnew(CollisionShape);
+ cshape->set_shape(shape);
+ cshape->set_transform(node->get_transform());
+
+ Node *owner = node->get_owner();
+
+ ur->add_do_method(node->get_parent(), "add_child", cshape);
+ ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1);
+ ur->add_do_method(cshape, "set_owner", owner);
+ ur->add_do_reference(cshape);
+ ur->add_undo_method(node->get_parent(), "remove_child", cshape);
+
+ ur->commit_action();
+
+ } break;
+ case MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES: {
+
+ if (node == get_tree()->get_edited_scene_root()) {
+ err_dialog->set_text(TTR("Can't create multiple convex collision shapes for the scene root."));
err_dialog->popup_centered_minsize();
return;
}
@@ -168,13 +199,13 @@ void MeshInstanceEditor::_menu_option(int p_option) {
Vector<Ref<Shape> > shapes = mesh->convex_decompose();
if (!shapes.size()) {
- err_dialog->set_text(TTR("Failed creating shapes!"));
+ err_dialog->set_text(TTR("Couldn't create any collision shapes."));
err_dialog->popup_centered_minsize();
return;
}
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action(TTR("Create Convex Shape(s)"));
+ ur->create_action(TTR("Create Multiple Convex Shapes"));
for (int i = 0; i < shapes.size(); i++) {
@@ -296,24 +327,24 @@ void MeshInstanceEditor::_create_uv_lines(int p_layer) {
continue;
Array a = mesh->surface_get_arrays(i);
- PoolVector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2];
+ Vector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2];
if (uv.size() == 0) {
err_dialog->set_text(TTR("Model has no UV in this layer"));
err_dialog->popup_centered_minsize();
return;
}
- PoolVector<Vector2>::Read r = uv.read();
+ const Vector2 *r = uv.ptr();
- PoolVector<int> indices = a[Mesh::ARRAY_INDEX];
- PoolVector<int>::Read ri;
+ Vector<int> indices = a[Mesh::ARRAY_INDEX];
+ const int *ri;
int ic;
bool use_indices;
if (indices.size()) {
ic = indices.size();
- ri = indices.read();
+ ri = indices.ptr();
use_indices = true;
} else {
ic = uv.size();
@@ -420,19 +451,25 @@ MeshInstanceEditor::MeshInstanceEditor() {
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance", "EditorIcons"));
options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
- options->get_popup()->add_item(TTR("Create Convex Collision Sibling(s)"), MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection."));
+ options->get_popup()->add_item(TTR("Create Single Convex Collision Siblings"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a single convex collision shape.\nThis is the fastest (but least accurate) option for collision detection."));
+ options->get_popup()->add_item(TTR("Create Multiple Convex Collision Siblings"), MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between the two above options."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the SpatialMaterial Grow property when using that property isn't possible."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1);
options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2);
options->get_popup()->add_item(TTR("Unwrap UV2 for Lightmap/AO"), MENU_OPTION_CREATE_UV2);
- options->get_popup()->connect("id_pressed", this, "_menu_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_menu_option");
outline_dialog = memnew(ConfirmationDialog);
outline_dialog->set_title(TTR("Create Outline Mesh"));
@@ -450,17 +487,17 @@ MeshInstanceEditor::MeshInstanceEditor() {
outline_dialog_vbc->add_margin_child(TTR("Outline Size:"), outline_size);
add_child(outline_dialog);
- outline_dialog->connect("confirmed", this, "_create_outline_mesh");
+ outline_dialog->connect_compat("confirmed", this, "_create_outline_mesh");
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
debug_uv_dialog = memnew(AcceptDialog);
- debug_uv_dialog->set_title("UV Channel Debug");
+ debug_uv_dialog->set_title(TTR("UV Channel Debug"));
add_child(debug_uv_dialog);
debug_uv = memnew(Control);
debug_uv->set_custom_minimum_size(Size2(600, 600) * EDSCALE);
- debug_uv->connect("draw", this, "_debug_uv_draw");
+ debug_uv->connect_compat("draw", this, "_debug_uv_draw");
debug_uv_dialog->add_child(debug_uv);
}
diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_editor_plugin.h
index d82af621df..5ca9aa3fec 100644
--- a/editor/plugins/mesh_instance_editor_plugin.h
+++ b/editor/plugins/mesh_instance_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,9 +43,9 @@ class MeshInstanceEditor : public Control {
enum Menu {
MENU_OPTION_CREATE_STATIC_TRIMESH_BODY,
- MENU_OPTION_CREATE_STATIC_CONVEX_BODY,
MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE,
- MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE,
+ MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE,
+ MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES,
MENU_OPTION_CREATE_NAVMESH,
MENU_OPTION_CREATE_OUTLINE_MESH,
MENU_OPTION_CREATE_UV2,
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index 7fbb35e565..ea8842a56f 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
#include "editor/editor_settings.h"
#include "main/main.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/navigation_mesh_instance.h"
#include "scene/3d/physics_body.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
@@ -182,7 +182,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
}
}
- Vector<Ref<Texture> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size"));
+ Vector<Ref<Texture2D> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size"));
int j = 0;
for (int i = 0; i < ids.size(); i++) {
@@ -241,7 +241,7 @@ void MeshLibraryEditor::_menu_cbk(int p_option) {
} break;
case MENU_OPTION_UPDATE_FROM_SCENE: {
- cd->set_text("Update from existing scene?:\n" + String(mesh_library->get_meta("_editor_source_scene")));
+ cd->set_text(vformat(TTR("Update from existing scene?:\n%s"), String(mesh_library->get_meta("_editor_source_scene"))));
cd->popup_centered(Size2(500, 60));
} break;
}
@@ -268,12 +268,12 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
add_child(file);
- file->connect("file_selected", this, "_import_scene_cbk");
+ file->connect_compat("file_selected", this, "_import_scene_cbk");
menu = memnew(MenuButton);
SpatialEditor::get_singleton()->add_control_to_menu_panel(menu);
menu->set_position(Point2(1, 1));
- menu->set_text("Mesh Library");
+ menu->set_text(TTR("Mesh Library"));
menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshLibrary", "EditorIcons"));
menu->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM);
menu->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM);
@@ -281,13 +281,13 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
menu->get_popup()->add_item(TTR("Import from Scene"), MENU_OPTION_IMPORT_FROM_SCENE);
menu->get_popup()->add_item(TTR("Update from Scene"), MENU_OPTION_UPDATE_FROM_SCENE);
menu->get_popup()->set_item_disabled(menu->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), true);
- menu->get_popup()->connect("id_pressed", this, "_menu_cbk");
+ menu->get_popup()->connect_compat("id_pressed", this, "_menu_cbk");
menu->hide();
editor = p_editor;
cd = memnew(ConfirmationDialog);
add_child(cd);
- cd->get_ok()->connect("pressed", this, "_menu_confirm");
+ cd->get_ok()->connect_compat("pressed", this, "_menu_confirm");
}
void MeshLibraryEditorPlugin::edit(Object *p_node) {
diff --git a/editor/plugins/mesh_library_editor_plugin.h b/editor/plugins/mesh_library_editor_plugin.h
index 8121ff52bd..74b0a280e3 100644
--- a/editor/plugins/mesh_library_editor_plugin.h
+++ b/editor/plugins/mesh_library_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index 3ea014a38d..b2ce01b8d8 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -124,7 +124,7 @@ void MultiMeshEditor::_populate() {
Transform geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform();
- PoolVector<Face3> geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID);
+ Vector<Face3> geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID);
if (geometry.size() == 0) {
@@ -136,7 +136,7 @@ void MultiMeshEditor::_populate() {
//make all faces local
int gc = geometry.size();
- PoolVector<Face3>::Write w = geometry.write();
+ Face3 *w = geometry.ptrw();
for (int i = 0; i < gc; i++) {
for (int j = 0; j < 3; j++) {
@@ -144,13 +144,11 @@ void MultiMeshEditor::_populate() {
}
}
- w.release();
-
- PoolVector<Face3> faces = geometry;
+ Vector<Face3> faces = geometry;
int facecount = faces.size();
ERR_FAIL_COND_MSG(!facecount, "Parent has no solid faces to populate.");
- PoolVector<Face3>::Read r = faces.read();
+ const Face3 *r = faces.ptr();
float area_accum = 0;
Map<float, int> triangle_area_map;
@@ -172,7 +170,7 @@ void MultiMeshEditor::_populate() {
int instance_count = populate_amount->get_value();
multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
- multimesh->set_color_format(MultiMesh::COLOR_NONE);
+ multimesh->set_use_colors(false);
multimesh->set_instance_count(instance_count);
float _tilt_random = populate_tilt_random->get_value();
@@ -297,7 +295,7 @@ MultiMeshEditor::MultiMeshEditor() {
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance", "EditorIcons"));
options->get_popup()->add_item(TTR("Populate Surface"));
- options->get_popup()->connect("id_pressed", this, "_menu_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_menu_option");
populate_dialog = memnew(ConfirmationDialog);
populate_dialog->set_title(TTR("Populate MultiMesh"));
@@ -315,7 +313,7 @@ MultiMeshEditor::MultiMeshEditor() {
Button *b = memnew(Button);
hbc->add_child(b);
b->set_text("..");
- b->connect("pressed", this, "_browse", make_binds(false));
+ b->connect_compat("pressed", this, "_browse", make_binds(false));
vbc->add_margin_child(TTR("Target Surface:"), hbc);
@@ -327,7 +325,7 @@ MultiMeshEditor::MultiMeshEditor() {
hbc->add_child(b);
b->set_text("..");
vbc->add_margin_child(TTR("Source Mesh:"), hbc);
- b->connect("pressed", this, "_browse", make_binds(true));
+ b->connect_compat("pressed", this, "_browse", make_binds(true));
populate_axis = memnew(OptionButton);
populate_axis->add_item(TTR("X-Axis"));
@@ -373,10 +371,10 @@ MultiMeshEditor::MultiMeshEditor() {
populate_dialog->get_ok()->set_text(TTR("Populate"));
- populate_dialog->get_ok()->connect("pressed", this, "_populate");
+ populate_dialog->get_ok()->connect_compat("pressed", this, "_populate");
std = memnew(SceneTreeDialog);
populate_dialog->add_child(std);
- std->connect("selected", this, "_browsed");
+ std->connect_compat("selected", this, "_browsed");
_last_pp_node = NULL;
diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h
index 5323441bd8..2c7b98cfbc 100644
--- a/editor/plugins/multimesh_editor_plugin.h
+++ b/editor/plugins/multimesh_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index 0d6b649526..c4e61f2488 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 2a387a8b1e..1cab336381 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp
index 957ce42304..ab23cb9054 100644
--- a/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/editor/plugins/particles_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -191,8 +191,8 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
int vpc = 0;
{
- PoolVector<uint8_t> data = img->get_data();
- PoolVector<uint8_t>::Read r = data.read();
+ Vector<uint8_t> data = img->get_data();
+ const uint8_t *r = data.ptr();
for (int i = 0; i < s.width; i++) {
for (int j = 0; j < s.height; j++) {
@@ -270,7 +270,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
ERR_FAIL_COND_MSG(valid_positions.size() == 0, "No pixels with transparency > 128 in image...");
- PoolVector<uint8_t> texdata;
+ Vector<uint8_t> texdata;
int w = 2048;
int h = (vpc / 2048) + 1;
@@ -278,8 +278,8 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
texdata.resize(w * h * 2 * sizeof(float));
{
- PoolVector<uint8_t>::Write tw = texdata.write();
- float *twf = (float *)tw.ptr();
+ uint8_t *tw = texdata.ptrw();
+ float *twf = (float *)tw;
for (int i = 0; i < vpc; i++) {
twf[i * 2 + 0] = valid_positions[i].x;
@@ -292,18 +292,18 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
Ref<ImageTexture> imgt;
imgt.instance();
- imgt->create_from_image(img, 0);
+ imgt->create_from_image(img);
pm->set_emission_point_texture(imgt);
pm->set_emission_point_count(vpc);
if (capture_colors) {
- PoolVector<uint8_t> colordata;
+ Vector<uint8_t> colordata;
colordata.resize(w * h * 4); //use RG texture
{
- PoolVector<uint8_t>::Write tw = colordata.write();
+ uint8_t *tw = colordata.ptrw();
for (int i = 0; i < vpc * 4; i++) {
tw[i] = valid_colors[i];
@@ -314,19 +314,19 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
img->create(w, h, false, Image::FORMAT_RGBA8, colordata);
imgt.instance();
- imgt->create_from_image(img, 0);
+ imgt->create_from_image(img);
pm->set_emission_color_texture(imgt);
}
if (valid_normals.size()) {
pm->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_DIRECTED_POINTS);
- PoolVector<uint8_t> normdata;
+ Vector<uint8_t> normdata;
normdata.resize(w * h * 2 * sizeof(float)); //use RG texture
{
- PoolVector<uint8_t>::Write tw = normdata.write();
- float *twf = (float *)tw.ptr();
+ uint8_t *tw = normdata.ptrw();
+ float *twf = (float *)tw;
for (int i = 0; i < vpc; i++) {
twf[i * 2 + 0] = valid_normals[i].x;
twf[i * 2 + 1] = valid_normals[i].y;
@@ -337,7 +337,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
img->create(w, h, false, Image::FORMAT_RGF, normdata);
imgt.instance();
- imgt->create_from_image(img, 0);
+ imgt->create_from_image(img);
pm->set_emission_normal_texture(imgt);
} else {
@@ -349,9 +349,9 @@ void Particles2DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- menu->get_popup()->connect("id_pressed", this, "_menu_callback");
+ menu->get_popup()->connect_compat("id_pressed", this, "_menu_callback");
menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
- file->connect("file_selected", this, "_file_selected");
+ file->connect_compat("file_selected", this, "_file_selected");
}
}
@@ -416,7 +416,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
toolbar->add_child(generate_visibility_rect);
- generate_visibility_rect->connect("confirmed", this, "_generate_visibility_rect");
+ generate_visibility_rect->connect_compat("confirmed", this, "_generate_visibility_rect");
emission_mask = memnew(ConfirmationDialog);
emission_mask->set_title(TTR("Load Emission Mask"));
@@ -424,16 +424,16 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
emission_mask->add_child(emvb);
emission_mask_mode = memnew(OptionButton);
emvb->add_margin_child(TTR("Emission Mask"), emission_mask_mode);
- emission_mask_mode->add_item("Solid Pixels", EMISSION_MODE_SOLID);
- emission_mask_mode->add_item("Border Pixels", EMISSION_MODE_BORDER);
- emission_mask_mode->add_item("Directed Border Pixels", EMISSION_MODE_BORDER_DIRECTED);
+ emission_mask_mode->add_item(TTR("Solid Pixels"), EMISSION_MODE_SOLID);
+ emission_mask_mode->add_item(TTR("Border Pixels"), EMISSION_MODE_BORDER);
+ emission_mask_mode->add_item(TTR("Directed Border Pixels"), EMISSION_MODE_BORDER_DIRECTED);
emission_colors = memnew(CheckBox);
emission_colors->set_text(TTR("Capture from Pixel"));
emvb->add_margin_child(TTR("Emission Colors"), emission_colors);
toolbar->add_child(emission_mask);
- emission_mask->connect("confirmed", this, "_generate_emission_mask");
+ emission_mask->connect_compat("confirmed", this, "_generate_emission_mask");
}
Particles2DEditorPlugin::~Particles2DEditorPlugin() {
diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/particles_2d_editor_plugin.h
index 0f092aaa4f..29652a1826 100644
--- a/editor/plugins/particles_2d_editor_plugin.h
+++ b/editor/plugins/particles_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index 31b0539bfe..7020abc301 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
#include "scene/3d/cpu_particles.h"
#include "scene/resources/particles_material.h"
-bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vector3> &normals) {
+bool ParticlesEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) {
bool use_normals = emission_fill->get_selected() == 1;
@@ -93,7 +93,7 @@ bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vect
return false;
}
- PoolVector<Face3>::Read r = geometry.read();
+ const Face3 *r = geometry.ptr();
AABB aabb;
@@ -191,7 +191,7 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
Transform geom_xform = base_node->get_global_transform().affine_inverse() * vi->get_global_transform();
int gc = geometry.size();
- PoolVector<Face3>::Write w = geometry.write();
+ Face3 *w = geometry.ptrw();
for (int i = 0; i < gc; i++) {
for (int j = 0; j < 3; j++) {
@@ -199,8 +199,6 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
}
}
- w.release();
-
emission_dialog->popup_centered(Size2(300, 130));
}
@@ -231,25 +229,11 @@ ParticlesEditorBase::ParticlesEditorBase() {
emd_vb->add_margin_child(TTR("Emission Source: "), emission_fill);
emission_dialog->get_ok()->set_text(TTR("Create"));
- emission_dialog->connect("confirmed", this, "_generate_emission_points");
+ emission_dialog->connect_compat("confirmed", this, "_generate_emission_points");
- emission_file_dialog = memnew(EditorFileDialog);
- add_child(emission_file_dialog);
- emission_file_dialog->connect("file_selected", this, "_resource_seleted");
emission_tree_dialog = memnew(SceneTreeDialog);
add_child(emission_tree_dialog);
- emission_tree_dialog->connect("selected", this, "_node_selected");
-
- List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Mesh", &extensions);
-
- emission_file_dialog->clear_filters();
- for (int i = 0; i < extensions.size(); i++) {
-
- emission_file_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
- }
-
- emission_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ emission_tree_dialog->connect_compat("selected", this, "_node_selected");
}
void ParticlesEditor::_node_removed(Node *p_node) {
@@ -264,7 +248,7 @@ void ParticlesEditor::_notification(int p_notification) {
if (p_notification == NOTIFICATION_ENTER_TREE) {
options->set_icon(options->get_popup()->get_icon("Particles", "EditorIcons"));
- get_tree()->connect("node_removed", this, "_node_removed");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
}
}
@@ -281,17 +265,6 @@ void ParticlesEditor::_menu_option(int p_option) {
generate_seconds->set_value(trunc(gen_time) + 1.0);
generate_aabb->popup_centered_minsize();
} break;
- case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: {
-
- Ref<ParticlesMaterial> material = node->get_process_material();
- if (material.is_null()) {
- EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticlesMaterial' is required."));
- return;
- }
- emission_file_dialog->popup_centered_ratio();
-
- } break;
-
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
Ref<ParticlesMaterial> material = node->get_process_material();
if (material.is_null()) {
@@ -379,8 +352,8 @@ void ParticlesEditor::edit(Particles *p_particles) {
void ParticlesEditor::_generate_emission_points() {
/// hacer codigo aca
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
if (!_generate(points, normals)) {
return;
@@ -391,14 +364,14 @@ void ParticlesEditor::_generate_emission_points() {
int w = 2048;
int h = (point_count / 2048) + 1;
- PoolVector<uint8_t> point_img;
+ Vector<uint8_t> point_img;
point_img.resize(w * h * 3 * sizeof(float));
{
- PoolVector<uint8_t>::Write iw = point_img.write();
- zeromem(iw.ptr(), w * h * 3 * sizeof(float));
- PoolVector<Vector3>::Read r = points.read();
- float *wf = (float *)iw.ptr();
+ uint8_t *iw = point_img.ptrw();
+ zeromem(iw, w * h * 3 * sizeof(float));
+ const Vector3 *r = points.ptr();
+ float *wf = (float *)iw;
for (int i = 0; i < point_count; i++) {
wf[i * 3 + 0] = r[i].x;
wf[i * 3 + 1] = r[i].y;
@@ -410,7 +383,6 @@ void ParticlesEditor::_generate_emission_points() {
Ref<ImageTexture> tex;
tex.instance();
- tex->create_from_image(image, Texture::FLAG_FILTER);
Ref<ParticlesMaterial> material = node->get_process_material();
ERR_FAIL_COND(material.is_null());
@@ -421,14 +393,14 @@ void ParticlesEditor::_generate_emission_points() {
material->set_emission_point_count(point_count);
material->set_emission_point_texture(tex);
- PoolVector<uint8_t> point_img2;
+ Vector<uint8_t> point_img2;
point_img2.resize(w * h * 3 * sizeof(float));
{
- PoolVector<uint8_t>::Write iw = point_img2.write();
- zeromem(iw.ptr(), w * h * 3 * sizeof(float));
- PoolVector<Vector3>::Read r = normals.read();
- float *wf = (float *)iw.ptr();
+ uint8_t *iw = point_img2.ptrw();
+ zeromem(iw, w * h * 3 * sizeof(float));
+ const Vector3 *r = normals.ptr();
+ float *wf = (float *)iw;
for (int i = 0; i < point_count; i++) {
wf[i * 3 + 0] = r[i].x;
wf[i * 3 + 1] = r[i].y;
@@ -440,7 +412,6 @@ void ParticlesEditor::_generate_emission_points() {
Ref<ImageTexture> tex2;
tex2.instance();
- tex2->create_from_image(image2, Texture::FLAG_FILTER);
material->set_emission_normal_texture(tex2);
} else {
@@ -471,14 +442,13 @@ ParticlesEditor::ParticlesEditor() {
options->set_text(TTR("Particles"));
options->get_popup()->add_item(TTR("Generate AABB"), MENU_OPTION_GENERATE_AABB);
options->get_popup()->add_separator();
- options->get_popup()->add_item(TTR("Create Emission Points From Mesh"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH);
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
- options->get_popup()->connect("id_pressed", this, "_menu_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_menu_option");
generate_aabb = memnew(ConfirmationDialog);
generate_aabb->set_title(TTR("Generate Visibility AABB"));
@@ -492,7 +462,7 @@ ParticlesEditor::ParticlesEditor() {
add_child(generate_aabb);
- generate_aabb->connect("confirmed", this, "_generate_aabb");
+ generate_aabb->connect_compat("confirmed", this, "_generate_aabb");
}
void ParticlesEditorPlugin::edit(Object *p_object) {
diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/particles_editor_plugin.h
index 1b3a1877a4..fb5ce17560 100644
--- a/editor/plugins/particles_editor_plugin.h
+++ b/editor/plugins/particles_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -46,16 +46,15 @@ protected:
MenuButton *options;
HBoxContainer *particles_editor_hb;
- EditorFileDialog *emission_file_dialog;
SceneTreeDialog *emission_tree_dialog;
ConfirmationDialog *emission_dialog;
SpinBox *emission_amount;
OptionButton *emission_fill;
- PoolVector<Face3> geometry;
+ Vector<Face3> geometry;
- bool _generate(PoolVector<Vector3> &points, PoolVector<Vector3> &normals);
+ bool _generate(Vector<Vector3> &points, Vector<Vector3> &normals);
virtual void _generate_emission_points() = 0;
void _node_selected(const NodePath &p_path);
@@ -77,7 +76,6 @@ class ParticlesEditor : public ParticlesEditorBase {
MENU_OPTION_GENERATE_AABB,
MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE,
- MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH,
MENU_OPTION_CLEAR_EMISSION_VOLUME,
MENU_OPTION_CONVERT_TO_CPU_PARTICLES,
MENU_OPTION_RESTART,
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index f02dc0bd6d..e642233c64 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
void Path2DEditor::_notification(int p_what) {
@@ -372,12 +373,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- const Ref<Texture> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons");
- const Ref<Texture> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons");
+ const Ref<Texture2D> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons");
+ const Ref<Texture2D> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons");
// Both handle icons must be of the same size
const Size2 handle_size = path_sharp_handle->get_size();
- const Ref<Texture> curve_handle = get_icon("EditorCurveHandle", "EditorIcons");
+ const Ref<Texture2D> curve_handle = get_icon("EditorCurveHandle", "EditorIcons");
const Size2 curve_handle_size = curve_handle->get_size();
Ref<Curve2D> curve = node->get_curve();
@@ -395,8 +396,8 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
if (point != pointout) {
smooth = true;
// Draw the line with a dark and light color to be visible on all backgrounds
- vpc->draw_line(point, pointout, Color(0, 0, 0, 0.5), Math::round(EDSCALE), true);
- vpc->draw_line(point, pointout, Color(1, 1, 1, 0.5), Math::round(EDSCALE), true);
+ vpc->draw_line(point, pointout, Color(0, 0, 0, 0.5), Math::round(EDSCALE));
+ vpc->draw_line(point, pointout, Color(1, 1, 1, 0.5), Math::round(EDSCALE));
vpc->draw_texture_rect(curve_handle, Rect2(pointout - curve_handle_size * 0.5, curve_handle_size), false, Color(1, 1, 1, 0.75));
}
}
@@ -406,8 +407,8 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
if (point != pointin) {
smooth = true;
// Draw the line with a dark and light color to be visible on all backgrounds
- vpc->draw_line(point, pointin, Color(0, 0, 0, 0.5), Math::round(EDSCALE), true);
- vpc->draw_line(point, pointin, Color(1, 1, 1, 0.5), Math::round(EDSCALE), true);
+ vpc->draw_line(point, pointin, Color(0, 0, 0, 0.5), Math::round(EDSCALE));
+ vpc->draw_line(point, pointin, Color(1, 1, 1, 0.5), Math::round(EDSCALE));
vpc->draw_texture_rect(curve_handle, Rect2(pointin - curve_handle_size * 0.5, curve_handle_size), false, Color(1, 1, 1, 0.75));
}
}
@@ -419,7 +420,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
if (on_edge) {
- Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
+ Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5);
}
}
@@ -440,14 +441,14 @@ void Path2DEditor::edit(Node *p_path2d) {
if (p_path2d) {
node = Object::cast_to<Path2D>(p_path2d);
- if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
- node->connect("visibility_changed", this, "_node_visibility_changed");
+ if (!node->is_connected_compat("visibility_changed", this, "_node_visibility_changed"))
+ node->connect_compat("visibility_changed", this, "_node_visibility_changed");
} else {
// node may have been deleted at this point
- if (node && node->is_connected("visibility_changed", this, "_node_visibility_changed"))
- node->disconnect("visibility_changed", this, "_node_visibility_changed");
+ if (node && node->is_connected_compat("visibility_changed", this, "_node_visibility_changed"))
+ node->disconnect_compat("visibility_changed", this, "_node_visibility_changed");
node = NULL;
}
}
@@ -554,34 +555,34 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
curve_edit->set_toggle_mode(true);
curve_edit->set_focus_mode(Control::FOCUS_NONE);
curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Left Click: Split Segment (in curve)") + "\n" + TTR("Right Click: Delete Point"));
- curve_edit->connect("pressed", this, "_mode_selected", varray(MODE_EDIT));
+ curve_edit->connect_compat("pressed", this, "_mode_selected", varray(MODE_EDIT));
base_hb->add_child(curve_edit);
curve_edit_curve = memnew(ToolButton);
curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCurve", "EditorIcons"));
curve_edit_curve->set_toggle_mode(true);
curve_edit_curve->set_focus_mode(Control::FOCUS_NONE);
curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)"));
- curve_edit_curve->connect("pressed", this, "_mode_selected", varray(MODE_EDIT_CURVE));
+ curve_edit_curve->connect_compat("pressed", this, "_mode_selected", varray(MODE_EDIT_CURVE));
base_hb->add_child(curve_edit_curve);
curve_create = memnew(ToolButton);
curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
curve_create->set_toggle_mode(true);
curve_create->set_focus_mode(Control::FOCUS_NONE);
curve_create->set_tooltip(TTR("Add Point (in empty space)"));
- curve_create->connect("pressed", this, "_mode_selected", varray(MODE_CREATE));
+ curve_create->connect_compat("pressed", this, "_mode_selected", varray(MODE_CREATE));
base_hb->add_child(curve_create);
curve_del = memnew(ToolButton);
curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
curve_del->set_toggle_mode(true);
curve_del->set_focus_mode(Control::FOCUS_NONE);
curve_del->set_tooltip(TTR("Delete Point"));
- curve_del->connect("pressed", this, "_mode_selected", varray(MODE_DELETE));
+ curve_del->connect_compat("pressed", this, "_mode_selected", varray(MODE_DELETE));
base_hb->add_child(curve_del);
curve_close = memnew(ToolButton);
curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons"));
curve_close->set_focus_mode(Control::FOCUS_NONE);
curve_close->set_tooltip(TTR("Close Curve"));
- curve_close->connect("pressed", this, "_mode_selected", varray(ACTION_CLOSE));
+ curve_close->connect_compat("pressed", this, "_mode_selected", varray(ACTION_CLOSE));
base_hb->add_child(curve_close);
PopupMenu *menu;
@@ -595,7 +596,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
menu->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle);
menu->add_check_item(TTR("Mirror Handle Lengths"));
menu->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length);
- menu->connect("id_pressed", this, "_handle_option_pressed");
+ menu->connect_compat("id_pressed", this, "_handle_option_pressed");
base_hb->hide();
diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h
index ecec5f5253..aae0e11c99 100644
--- a/editor/plugins/path_2d_editor_plugin.h
+++ b/editor/plugins/path_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index 2493380585..b955bf7f41 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -221,22 +221,22 @@ void PathSpatialGizmo::redraw() {
clear();
- Ref<SpatialMaterial> path_material = gizmo_plugin->get_material("path_material", this);
- Ref<SpatialMaterial> path_thin_material = gizmo_plugin->get_material("path_thin_material", this);
- Ref<SpatialMaterial> handles_material = gizmo_plugin->get_material("handles");
+ Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this);
+ Ref<StandardMaterial3D> path_thin_material = gizmo_plugin->get_material("path_thin_material", this);
+ Ref<StandardMaterial3D> handles_material = gizmo_plugin->get_material("handles");
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
return;
- PoolVector<Vector3> v3a = c->tessellate();
- //PoolVector<Vector3> v3a=c->get_baked_points();
+ Vector<Vector3> v3a = c->tessellate();
+ //Vector<Vector3> v3a=c->get_baked_points();
int v3s = v3a.size();
if (v3s == 0)
return;
Vector<Vector3> v3p;
- PoolVector<Vector3>::Read r = v3a.read();
+ const Vector3 *r = v3a.ptr();
// BUG: the following won't work when v3s, avoid drawing as a temporary workaround.
for (int i = 0; i < v3s - 1; i++) {
@@ -315,7 +315,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->get_control()))) {
//click into curve, break it down
- PoolVector<Vector3> v3a = c->tessellate();
+ Vector<Vector3> v3a = c->tessellate();
int idx = 0;
int rc = v3a.size();
int closest_seg = -1;
@@ -323,7 +323,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
float closest_d = 1e20;
if (rc >= 2) {
- PoolVector<Vector3>::Read r = v3a.read();
+ const Vector3 *r = v3a.ptr();
if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist)
return false; //nope, existing
@@ -543,10 +543,10 @@ void PathEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- curve_create->connect("pressed", this, "_mode_changed", make_binds(0));
- curve_edit->connect("pressed", this, "_mode_changed", make_binds(1));
- curve_del->connect("pressed", this, "_mode_changed", make_binds(2));
- curve_close->connect("pressed", this, "_close_curve");
+ curve_create->connect_compat("pressed", this, "_mode_changed", make_binds(0));
+ curve_edit->connect_compat("pressed", this, "_mode_changed", make_binds(1));
+ curve_del->connect_compat("pressed", this, "_mode_changed", make_binds(2));
+ curve_close->connect_compat("pressed", this, "_close_curve");
}
}
@@ -614,7 +614,7 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
menu->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle);
menu->add_check_item(TTR("Mirror Handle Lengths"));
menu->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length);
- menu->connect("id_pressed", this, "_handle_option_pressed");
+ menu->connect_compat("id_pressed", this, "_handle_option_pressed");
curve_edit->set_pressed(true);
/*
diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_editor_plugin.h
index 5482d09377..8ff83911f8 100644
--- a/editor/plugins/path_editor_plugin.h
+++ b/editor/plugins/path_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/physical_bone_plugin.cpp b/editor/plugins/physical_bone_plugin.cpp
index 96681a105f..4b63d82961 100644
--- a/editor/plugins/physical_bone_plugin.cpp
+++ b/editor/plugins/physical_bone_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -64,7 +64,7 @@ PhysicalBoneEditor::PhysicalBoneEditor(EditorNode *p_editor) :
button_transform_joint->set_text(TTR("Move Joint"));
button_transform_joint->set_icon(SpatialEditor::get_singleton()->get_icon("PhysicalBone", "EditorIcons"));
button_transform_joint->set_toggle_mode(true);
- button_transform_joint->connect("toggled", this, "_on_toggle_button_transform_joint");
+ button_transform_joint->connect_compat("toggled", this, "_on_toggle_button_transform_joint");
hide();
}
diff --git a/editor/plugins/physical_bone_plugin.h b/editor/plugins/physical_bone_plugin.h
index 78c1c331a0..459a67db05 100644
--- a/editor/plugins/physical_bone_plugin.h
+++ b/editor/plugins/physical_bone_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index bd532a6418..91c0222f6d 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,6 +34,7 @@
#include "core/os/file_access.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "scene/2d/skeleton_2d.h"
@@ -91,6 +92,9 @@ void Polygon2DEditor::_notification(int p_what) {
b_snap_grid->set_icon(get_icon("Grid", "EditorIcons"));
b_snap_enable->set_icon(get_icon("SnapGrid", "EditorIcons"));
uv_icon_zoom->set_texture(get_icon("Zoom", "EditorIcons"));
+
+ uv_vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
+ uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -121,12 +125,12 @@ void Polygon2DEditor::_sync_bones() {
} else {
for (int i = 0; i < skeleton->get_bone_count(); i++) {
NodePath path = skeleton->get_path_to(skeleton->get_bone(i));
- PoolVector<float> weights;
+ Vector<float> weights;
int wc = node->get_polygon().size();
for (int j = 0; j < prev_bones.size(); j += 2) {
NodePath pvp = prev_bones[j];
- PoolVector<float> pv = prev_bones[j + 1];
+ Vector<float> pv = prev_bones[j + 1];
if (pvp == path && pv.size() == wc) {
weights = pv;
}
@@ -134,7 +138,7 @@ void Polygon2DEditor::_sync_bones() {
if (weights.size() == 0) { //create them
weights.resize(node->get_polygon().size());
- PoolVector<float>::Write w = weights.write();
+ float *w = weights.ptrw();
for (int j = 0; j < wc; j++) {
w[j] = 0.0;
}
@@ -188,7 +192,7 @@ void Polygon2DEditor::_update_bone_list() {
if (np == selected || bone_scroll_vb->get_child_count() < 2)
cb->set_pressed(true);
- cb->connect("pressed", this, "_bone_paint_selected", varray(i));
+ cb->connect_compat("pressed", this, "_bone_paint_selected", varray(i));
}
uv_edit_draw->update();
@@ -289,8 +293,8 @@ void Polygon2DEditor::_menu_option(int p_option) {
return;
}
- PoolVector<Vector2> points = node->get_polygon();
- PoolVector<Vector2> uvs = node->get_uv();
+ Vector<Vector2> points = node->get_polygon();
+ Vector<Vector2> uvs = node->get_uv();
if (uvs.size() != points.size()) {
undo_redo->create_action(TTR("Create UV Map"));
undo_redo->add_do_method(node, "set_uv", points);
@@ -308,10 +312,10 @@ void Polygon2DEditor::_menu_option(int p_option) {
} break;
case UVEDIT_POLYGON_TO_UV: {
- PoolVector<Vector2> points = node->get_polygon();
+ Vector<Vector2> points = node->get_polygon();
if (points.size() == 0)
break;
- PoolVector<Vector2> uvs = node->get_uv();
+ Vector<Vector2> uvs = node->get_uv();
undo_redo->create_action(TTR("Create UV Map"));
undo_redo->add_do_method(node, "set_uv", points);
undo_redo->add_undo_method(node, "set_uv", uvs);
@@ -321,8 +325,8 @@ void Polygon2DEditor::_menu_option(int p_option) {
} break;
case UVEDIT_UV_TO_POLYGON: {
- PoolVector<Vector2> points = node->get_polygon();
- PoolVector<Vector2> uvs = node->get_uv();
+ Vector<Vector2> points = node->get_polygon();
+ Vector<Vector2> uvs = node->get_uv();
if (uvs.size() == 0)
break;
@@ -335,11 +339,11 @@ void Polygon2DEditor::_menu_option(int p_option) {
} break;
case UVEDIT_UV_CLEAR: {
- PoolVector<Vector2> uvs = node->get_uv();
+ Vector<Vector2> uvs = node->get_uv();
if (uvs.size() == 0)
break;
undo_redo->create_action(TTR("Create UV Map"));
- undo_redo->add_do_method(node, "set_uv", PoolVector<Vector2>());
+ undo_redo->add_do_method(node, "set_uv", Vector<Vector2>());
undo_redo->add_undo_method(node, "set_uv", uvs);
undo_redo->add_do_method(uv_edit_draw, "update");
undo_redo->add_undo_method(uv_edit_draw, "update");
@@ -563,7 +567,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
undo_redo->add_do_method(node, "set_vertex_colors", uv_create_colors_prev);
undo_redo->add_undo_method(node, "set_vertex_colors", node->get_vertex_colors());
for (int i = 0; i < node->get_bone_count(); i++) {
- PoolVector<float> bonew = node->get_bone_weights(i);
+ Vector<float> bonew = node->get_bone_weights(i);
bonew.push_back(0);
undo_redo->add_do_method(node, "set_bone_weights", i, bonew);
undo_redo->add_undo_method(node, "set_bone_weights", i, node->get_bone_weights(i));
@@ -618,7 +622,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
undo_redo->add_do_method(node, "set_vertex_colors", uv_create_colors_prev);
undo_redo->add_undo_method(node, "set_vertex_colors", node->get_vertex_colors());
for (int i = 0; i < node->get_bone_count(); i++) {
- PoolVector<float> bonew = node->get_bone_weights(i);
+ Vector<float> bonew = node->get_bone_weights(i);
bonew.remove(closest);
undo_redo->add_do_method(node, "set_bone_weights", i, bonew);
undo_redo->add_undo_method(node, "set_bone_weights", i, node->get_bone_weights(i));
@@ -708,7 +712,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
int erase_index = -1;
for (int i = polygons.size() - 1; i >= 0; i--) {
- PoolVector<int> points = polygons[i];
+ Vector<int> points = polygons[i];
Vector<Vector2> polys;
polys.resize(points.size());
for (int j = 0; j < polys.size(); j++) {
@@ -828,7 +832,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
} break;
case UV_MODE_EDIT_POINT: {
- PoolVector<Vector2> uv_new = points_prev;
+ Vector<Vector2> uv_new = points_prev;
uv_new.set(point_drag_index, uv_new[point_drag_index] + drag);
if (uv_edit_mode[0]->is_pressed()) { //edit uv
@@ -839,7 +843,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
} break;
case UV_MODE_MOVE: {
- PoolVector<Vector2> uv_new = points_prev;
+ Vector<Vector2> uv_new = points_prev;
for (int i = 0; i < uv_new.size(); i++)
uv_new.set(i, uv_new[i] + drag);
@@ -852,7 +856,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
case UV_MODE_ROTATE: {
Vector2 center;
- PoolVector<Vector2> uv_new = points_prev;
+ Vector<Vector2> uv_new = points_prev;
for (int i = 0; i < uv_new.size(); i++)
center += points_prev[i];
@@ -875,7 +879,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
case UV_MODE_SCALE: {
Vector2 center;
- PoolVector<Vector2> uv_new = points_prev;
+ Vector<Vector2> uv_new = points_prev;
for (int i = 0; i < uv_new.size(); i++)
center += points_prev[i];
@@ -910,7 +914,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (bone_painting) {
- PoolVector<float> painted_weights = node->get_bone_weights(bone_painting_bone);
+ Vector<float> painted_weights = node->get_bone_weights(bone_painting_bone);
{
int pc = painted_weights.size();
@@ -921,9 +925,9 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
amount = -amount;
}
- PoolVector<float>::Write w = painted_weights.write();
- PoolVector<float>::Read r = prev_weights.read();
- PoolVector<Vector2>::Read rv = points_prev.read();
+ float *w = painted_weights.ptrw();
+ const float *r = prev_weights.ptr();
+ const Vector2 *rv = points_prev.ptr();
for (int i = 0; i < pc; i++) {
if (mtx.xform(rv[i]).distance_to(bone_paint_pos) < radius) {
@@ -976,7 +980,7 @@ void Polygon2DEditor::_uv_draw() {
if (!uv_edit->is_visible() || !_get_node())
return;
- Ref<Texture> base_tex = node->get_texture();
+ Ref<Texture2D> base_tex = node->get_texture();
if (base_tex.is_null())
return;
@@ -1020,14 +1024,14 @@ void Polygon2DEditor::_uv_draw() {
Array polygons = node->get_polygons();
- PoolVector<Vector2> uvs;
+ Vector<Vector2> uvs;
if (uv_edit_mode[0]->is_pressed()) { //edit uv
uvs = node->get_uv();
} else { //edit polygon
uvs = node->get_polygon();
}
- PoolVector<float>::Read weight_r;
+ const float *weight_r;
if (uv_edit_mode[3]->is_pressed()) {
int bone_selected = -1;
@@ -1041,12 +1045,12 @@ void Polygon2DEditor::_uv_draw() {
if (bone_selected != -1 && node->get_bone_weights(bone_selected).size() == uvs.size()) {
- weight_r = node->get_bone_weights(bone_selected).read();
+ weight_r = node->get_bone_weights(bone_selected).ptr();
}
}
// All UV points are sharp, so use the sharp handle icon
- Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
+ Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
Color poly_line_color = Color(0.9, 0.5, 0.5);
if (polygons.size() || polygon_create.size()) {
@@ -1074,7 +1078,7 @@ void Polygon2DEditor::_uv_draw() {
int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0;
if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) {
- uv_edit_draw->draw_line(mtx.xform(points_prev[i]), mtx.xform(points_prev[next]), prev_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(points_prev[i]), mtx.xform(points_prev[next]), prev_color, Math::round(EDSCALE));
}
Vector2 next_point = uvs[next];
@@ -1082,7 +1086,7 @@ void Polygon2DEditor::_uv_draw() {
next_point = uv_create_to;
}
if (i < uv_draw_max /*&& polygons.size() == 0 && polygon_create.size() == 0*/) { //if using or creating polygons, do not show outline (will show polygons instead)
- uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE));
}
rect.expand_to(mtx.basis_xform(uvs[i]));
@@ -1090,7 +1094,7 @@ void Polygon2DEditor::_uv_draw() {
for (int i = 0; i < polygons.size(); i++) {
- PoolVector<int> points = polygons[i];
+ Vector<int> points = polygons[i];
Vector<Vector2> polypoints;
for (int j = 0; j < points.size(); j++) {
int next = (j + 1) % points.size();
@@ -1103,7 +1107,7 @@ void Polygon2DEditor::_uv_draw() {
if (idx_next < 0 || idx_next >= uvs.size())
continue;
- uv_edit_draw->draw_line(mtx.xform(uvs[idx]), mtx.xform(uvs[idx_next]), polygon_line_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(uvs[idx]), mtx.xform(uvs[idx_next]), polygon_line_color, Math::round(EDSCALE));
}
if (points.size() >= 3) {
uv_edit_draw->draw_polygon(polypoints, polygon_fill_color);
@@ -1112,7 +1116,7 @@ void Polygon2DEditor::_uv_draw() {
for (int i = 0; i < uvs.size(); i++) {
- if (weight_r.ptr()) {
+ if (weight_r) {
Vector2 draw_pos = mtx.xform(uvs[i]);
float weight = weight_r[i];
uv_edit_draw->draw_rect(Rect2(draw_pos - Vector2(2, 2) * EDSCALE, Vector2(5, 5) * EDSCALE), Color(weight, weight, weight, 1.0), Math::round(EDSCALE));
@@ -1130,7 +1134,7 @@ void Polygon2DEditor::_uv_draw() {
for (int i = 0; i < polygon_create.size(); i++) {
Vector2 from = uvs[polygon_create[i]];
Vector2 to = (i + 1) < polygon_create.size() ? uvs[polygon_create[i + 1]] : uv_create_to;
- uv_edit_draw->draw_line(mtx.xform(from), mtx.xform(to), polygon_line_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(from), mtx.xform(to), polygon_line_color, Math::round(EDSCALE));
}
}
@@ -1195,7 +1199,9 @@ void Polygon2DEditor::_uv_draw() {
rect.position -= uv_edit_draw->get_size();
rect.size += uv_edit_draw->get_size() * 2.0;
+
updating_uv_scroll = true;
+
uv_hscroll->set_min(rect.position.x);
uv_hscroll->set_max(rect.position.x + rect.size.x);
if (ABS(rect.position.x - (rect.position.x + rect.size.x)) <= uv_edit_draw->get_size().x) {
@@ -1215,6 +1221,14 @@ void Polygon2DEditor::_uv_draw() {
uv_vscroll->set_page(uv_edit_draw->get_size().y);
uv_vscroll->set_value(uv_draw_ofs.y);
}
+
+ Size2 hmin = uv_hscroll->get_combined_minimum_size();
+ Size2 vmin = uv_vscroll->get_combined_minimum_size();
+
+ // Avoid scrollbar overlapping.
+ uv_hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, uv_vscroll->is_visible() ? -vmin.width : 0);
+ uv_vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, uv_hscroll->is_visible() ? -hmin.height : 0);
+
updating_uv_scroll = false;
}
@@ -1259,14 +1273,14 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
button_uv = memnew(ToolButton);
add_child(button_uv);
button_uv->set_tooltip(TTR("Open Polygon 2D UV editor."));
- button_uv->connect("pressed", this, "_menu_option", varray(MODE_EDIT_UV));
+ button_uv->connect_compat("pressed", this, "_menu_option", varray(MODE_EDIT_UV));
uv_mode = UV_MODE_EDIT_POINT;
uv_edit = memnew(AcceptDialog);
add_child(uv_edit);
uv_edit->set_title(TTR("Polygon 2D UV Editor"));
uv_edit->set_resizable(true);
- uv_edit->connect("popup_hide", this, "_uv_edit_popup_hide");
+ uv_edit->connect_compat("popup_hide", this, "_uv_edit_popup_hide");
VBoxContainer *uv_main_vb = memnew(VBoxContainer);
uv_edit->add_child(uv_main_vb);
@@ -1298,10 +1312,10 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_edit_mode[2]->set_button_group(uv_edit_group);
uv_edit_mode[3]->set_button_group(uv_edit_group);
- uv_edit_mode[0]->connect("pressed", this, "_uv_edit_mode_select", varray(0));
- uv_edit_mode[1]->connect("pressed", this, "_uv_edit_mode_select", varray(1));
- uv_edit_mode[2]->connect("pressed", this, "_uv_edit_mode_select", varray(2));
- uv_edit_mode[3]->connect("pressed", this, "_uv_edit_mode_select", varray(3));
+ uv_edit_mode[0]->connect_compat("pressed", this, "_uv_edit_mode_select", varray(0));
+ uv_edit_mode[1]->connect_compat("pressed", this, "_uv_edit_mode_select", varray(1));
+ uv_edit_mode[2]->connect_compat("pressed", this, "_uv_edit_mode_select", varray(2));
+ uv_edit_mode[3]->connect_compat("pressed", this, "_uv_edit_mode_select", varray(3));
uv_mode_hb->add_child(memnew(VSeparator));
@@ -1311,7 +1325,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_button[i] = memnew(ToolButton);
uv_button[i]->set_toggle_mode(true);
uv_mode_hb->add_child(uv_button[i]);
- uv_button[i]->connect("pressed", this, "_uv_mode", varray(i));
+ uv_button[i]->connect_compat("pressed", this, "_uv_mode", varray(i));
uv_button[i]->set_focus_mode(FOCUS_NONE);
}
@@ -1374,7 +1388,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_menu->get_popup()->add_item(TTR("Clear UV"), UVEDIT_UV_CLEAR);
uv_menu->get_popup()->add_separator();
uv_menu->get_popup()->add_item(TTR("Grid Settings"), UVEDIT_GRID_SETTINGS);
- uv_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ uv_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
uv_mode_hb->add_child(memnew(VSeparator));
@@ -1385,7 +1399,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
b_snap_enable->set_toggle_mode(true);
b_snap_enable->set_pressed(use_snap);
b_snap_enable->set_tooltip(TTR("Enable Snap"));
- b_snap_enable->connect("toggled", this, "_set_use_snap");
+ b_snap_enable->connect_compat("toggled", this, "_set_use_snap");
b_snap_grid = memnew(ToolButton);
uv_mode_hb->add_child(b_snap_grid);
@@ -1394,7 +1408,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
b_snap_grid->set_toggle_mode(true);
b_snap_grid->set_pressed(snap_show_grid);
b_snap_grid->set_tooltip(TTR("Show Grid"));
- b_snap_grid->connect("toggled", this, "_set_show_grid");
+ b_snap_grid->connect_compat("toggled", this, "_set_show_grid");
grid_settings = memnew(AcceptDialog);
grid_settings->set_title(TTR("Configure Grid:"));
@@ -1408,7 +1422,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
sb_off_x->set_step(1);
sb_off_x->set_value(snap_offset.x);
sb_off_x->set_suffix("px");
- sb_off_x->connect("value_changed", this, "_set_snap_off_x");
+ sb_off_x->connect_compat("value_changed", this, "_set_snap_off_x");
grid_settings_vb->add_margin_child(TTR("Grid Offset X:"), sb_off_x);
SpinBox *sb_off_y = memnew(SpinBox);
@@ -1417,7 +1431,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
sb_off_y->set_step(1);
sb_off_y->set_value(snap_offset.y);
sb_off_y->set_suffix("px");
- sb_off_y->connect("value_changed", this, "_set_snap_off_y");
+ sb_off_y->connect_compat("value_changed", this, "_set_snap_off_y");
grid_settings_vb->add_margin_child(TTR("Grid Offset Y:"), sb_off_y);
SpinBox *sb_step_x = memnew(SpinBox);
@@ -1426,7 +1440,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
sb_step_x->set_step(1);
sb_step_x->set_value(snap_step.x);
sb_step_x->set_suffix("px");
- sb_step_x->connect("value_changed", this, "_set_snap_step_x");
+ sb_step_x->connect_compat("value_changed", this, "_set_snap_step_x");
grid_settings_vb->add_margin_child(TTR("Grid Step X:"), sb_step_x);
SpinBox *sb_step_y = memnew(SpinBox);
@@ -1435,7 +1449,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
sb_step_y->set_step(1);
sb_step_y->set_value(snap_step.y);
sb_step_y->set_suffix("px");
- sb_step_y->connect("value_changed", this, "_set_snap_step_y");
+ sb_step_y->connect_compat("value_changed", this, "_set_snap_step_y");
grid_settings_vb->add_margin_child(TTR("Grid Step Y:"), sb_step_y);
uv_mode_hb->add_child(memnew(VSeparator));
@@ -1444,7 +1458,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_mode_hb->add_child(uv_icon_zoom);
uv_zoom = memnew(HSlider);
uv_zoom->set_min(0.01);
- uv_zoom->set_max(4);
+ uv_zoom->set_max(16);
uv_zoom->set_value(1);
uv_zoom->set_step(0.01);
uv_zoom->set_v_size_flags(SIZE_SHRINK_CENTER);
@@ -1455,19 +1469,16 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_zoom->share(uv_zoom_value);
uv_zoom_value->set_custom_minimum_size(Size2(50, 0));
uv_mode_hb->add_child(uv_zoom_value);
- uv_zoom->connect("value_changed", this, "_uv_scroll_changed");
+ uv_zoom->connect_compat("value_changed", this, "_uv_scroll_changed");
uv_vscroll = memnew(VScrollBar);
uv_vscroll->set_step(0.001);
uv_edit_draw->add_child(uv_vscroll);
- uv_vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
- uv_vscroll->connect("value_changed", this, "_uv_scroll_changed");
+ uv_vscroll->connect_compat("value_changed", this, "_uv_scroll_changed");
uv_hscroll = memnew(HScrollBar);
uv_hscroll->set_step(0.001);
uv_edit_draw->add_child(uv_hscroll);
- uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
- uv_hscroll->set_margin(MARGIN_RIGHT, -uv_vscroll->get_size().x * EDSCALE);
- uv_hscroll->connect("value_changed", this, "_uv_scroll_changed");
+ uv_hscroll->connect_compat("value_changed", this, "_uv_scroll_changed");
bone_scroll_main_vb = memnew(VBoxContainer);
bone_scroll_main_vb->hide();
@@ -1475,7 +1486,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
sync_bones = memnew(Button(TTR("Sync Bones to Polygon")));
bone_scroll_main_vb->add_child(sync_bones);
sync_bones->set_h_size_flags(0);
- sync_bones->connect("pressed", this, "_sync_bones");
+ sync_bones->connect_compat("pressed", this, "_sync_bones");
uv_main_hsc->add_child(bone_scroll_main_vb);
bone_scroll = memnew(ScrollContainer);
bone_scroll->set_v_scroll(true);
@@ -1485,8 +1496,8 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
bone_scroll_vb = memnew(VBoxContainer);
bone_scroll->add_child(bone_scroll_vb);
- uv_edit_draw->connect("draw", this, "_uv_draw");
- uv_edit_draw->connect("gui_input", this, "_uv_input");
+ uv_edit_draw->connect_compat("draw", this, "_uv_draw");
+ uv_edit_draw->connect_compat("gui_input", this, "_uv_input");
uv_draw_zoom = 1.0;
point_drag_index = -1;
uv_drag = false;
diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h
index 009501a70c..2b00b50e5c 100644
--- a/editor/plugins/polygon_2d_editor_plugin.h
+++ b/editor/plugins/polygon_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -88,7 +88,7 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
Label *bone_paint_radius_label;
bool bone_painting;
int bone_painting_bone;
- PoolVector<float> prev_weights;
+ Vector<float> prev_weights;
Vector2 bone_paint_pos;
AcceptDialog *grid_settings;
@@ -97,10 +97,10 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
Vector2 uv_draw_ofs;
float uv_draw_zoom;
- PoolVector<Vector2> points_prev;
- PoolVector<Vector2> uv_create_uv_prev;
- PoolVector<Vector2> uv_create_poly_prev;
- PoolVector<Color> uv_create_colors_prev;
+ Vector<Vector2> points_prev;
+ Vector<Vector2> uv_create_uv_prev;
+ Vector<Vector2> uv_create_poly_prev;
+ Vector<Color> uv_create_colors_prev;
int uv_create_prev_internal_vertices;
Array uv_create_bones_prev;
Array polygons_prev;
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index 620bf28415..12b8ac9008 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "core/io/resource_loader.h"
#include "core/project_settings.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) {
@@ -381,7 +382,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
add_child(file);
tree = memnew(Tree);
- tree->connect("button_pressed", this, "_cell_button_pressed");
+ tree->connect_compat("button_pressed", this, "_cell_button_pressed");
tree->set_columns(2);
tree->set_column_min_width(0, 2);
tree->set_column_min_width(1, 3);
@@ -395,10 +396,10 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
dialog = memnew(AcceptDialog);
add_child(dialog);
- load->connect("pressed", this, "_load_pressed");
- paste->connect("pressed", this, "_paste_pressed");
- file->connect("files_selected", this, "_files_load_request");
- tree->connect("item_edited", this, "_item_edited");
+ load->connect_compat("pressed", this, "_load_pressed");
+ paste->connect_compat("pressed", this, "_paste_pressed");
+ file->connect_compat("files_selected", this, "_files_load_request");
+ tree->connect_compat("item_edited", this, "_item_edited");
loading_scene = false;
}
@@ -438,7 +439,7 @@ ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node)
editor = p_node;
preloader_editor = memnew(ResourcePreloaderEditor);
- preloader_editor->set_custom_minimum_size(Size2(0, 250));
+ preloader_editor->set_custom_minimum_size(Size2(0, 250) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("ResourcePreloader"), preloader_editor);
button->hide();
diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h
index 346249b1c5..88e9cf4956 100644
--- a/editor/plugins/resource_preloader_editor_plugin.h
+++ b/editor/plugins/resource_preloader_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index 05f682f469..132ec40dd2 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -205,7 +205,7 @@ void EditorPropertyRootMotion::update_property() {
assign->set_tooltip(p);
if (p == NodePath()) {
- assign->set_icon(Ref<Texture>());
+ assign->set_icon(Ref<Texture2D>());
assign->set_text(TTR("Assign..."));
assign->set_flat(false);
return;
@@ -222,7 +222,7 @@ void EditorPropertyRootMotion::update_property() {
}
if (!base_node || !base_node->has_node(p)) {
- assign->set_icon(Ref<Texture>());
+ assign->set_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
@@ -242,7 +242,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) {
void EditorPropertyRootMotion::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture> t = get_icon("Clear", "EditorIcons");
+ Ref<Texture2D> t = get_icon("Clear", "EditorIcons");
clear->set_icon(t);
}
}
@@ -262,24 +262,24 @@ EditorPropertyRootMotion::EditorPropertyRootMotion() {
assign->set_flat(true);
assign->set_h_size_flags(SIZE_EXPAND_FILL);
assign->set_clip_text(true);
- assign->connect("pressed", this, "_node_assign");
+ assign->connect_compat("pressed", this, "_node_assign");
hbc->add_child(assign);
clear = memnew(Button);
clear->set_flat(true);
- clear->connect("pressed", this, "_node_clear");
+ clear->connect_compat("pressed", this, "_node_clear");
hbc->add_child(clear);
filter_dialog = memnew(ConfirmationDialog);
add_child(filter_dialog);
filter_dialog->set_title(TTR("Edit Filtered Tracks:"));
- filter_dialog->connect("confirmed", this, "_confirmed");
+ filter_dialog->connect_compat("confirmed", this, "_confirmed");
filters = memnew(Tree);
filter_dialog->add_child(filters);
filters->set_v_size_flags(SIZE_EXPAND_FILL);
filters->set_hide_root(true);
- filters->connect("item_activated", this, "_confirmed");
+ filters->connect_compat("item_activated", this, "_confirmed");
//filters->connect("item_edited", this, "_filter_edited");
}
//////////////////////////
diff --git a/editor/plugins/root_motion_editor_plugin.h b/editor/plugins/root_motion_editor_plugin.h
index af5d8fc122..8a7691de5d 100644
--- a/editor/plugins/root_motion_editor_plugin.h
+++ b/editor/plugins/root_motion_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index f7e997a269..9dc98dc2a0 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,12 +36,16 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
+#include "editor/debugger/editor_debugger_node.h"
+#include "editor/debugger/script_editor_debugger.h"
#include "editor/editor_node.h"
+#include "editor/editor_run_script.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/filesystem_dock.h"
#include "editor/find_in_files.h"
#include "editor/node_dock.h"
#include "editor/plugins/shader_editor_plugin.h"
-#include "editor/script_editor_debugger.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
#include "script_text_editor.h"
@@ -59,6 +63,7 @@ void ScriptEditorBase::_bind_methods() {
ADD_SIGNAL(MethodInfo("go_to_help", PropertyInfo(Variant::STRING, "what")));
// TODO: This signal is no use for VisualScript.
ADD_SIGNAL(MethodInfo("search_in_files_requested", PropertyInfo(Variant::STRING, "text")));
+ ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text")));
}
static bool _is_built_in_script(Script *p_script) {
@@ -206,16 +211,16 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- connect("confirmed", this, "_confirmed");
+ connect_compat("confirmed", this, "_confirmed");
search_box->set_clear_button_enabled(true);
- FALLTHROUGH;
+ [[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
search_box->set_right_icon(get_icon("Search", "EditorIcons"));
} break;
case NOTIFICATION_EXIT_TREE: {
- disconnect("confirmed", this, "_confirmed");
+ disconnect_compat("confirmed", this, "_confirmed");
} break;
}
}
@@ -235,15 +240,15 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() {
add_child(vbc);
search_box = memnew(LineEdit);
vbc->add_margin_child(TTR("Search:"), search_box);
- search_box->connect("text_changed", this, "_text_changed");
- search_box->connect("gui_input", this, "_sbox_input");
+ search_box->connect_compat("text_changed", this, "_text_changed");
+ search_box->connect_compat("gui_input", this, "_sbox_input");
search_options = memnew(Tree);
vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Open"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
- search_options->connect("item_activated", this, "_confirmed");
+ search_options->connect_compat("item_activated", this, "_confirmed");
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
search_options->add_constant_override("draw_guides", 1);
@@ -257,7 +262,7 @@ ScriptEditor *ScriptEditor::script_editor = NULL;
String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
- String val = debugger->get_var_value(p_text);
+ String val = EditorDebuggerNode::get_singleton()->get_var_value(p_text);
if (val != String()) {
return p_text + ": " + val;
} else {
@@ -272,11 +277,6 @@ void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
return;
}
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), !(p_breaked && p_can_debug));
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), !(p_breaked && p_can_debug));
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), p_breaked);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), !p_breaked);
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
@@ -288,11 +288,6 @@ void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
}
}
-void ScriptEditor::_show_debugger(bool p_show) {
-
- //debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), p_show);
-}
-
void ScriptEditor::_script_created(Ref<Script> p_script) {
editor->push_item(p_script.operator->());
}
@@ -839,7 +834,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
void ScriptEditor::_live_auto_reload_running_scripts() {
pending_auto_reload = false;
- debugger->reload_scripts();
+ EditorDebuggerNode::get_singleton()->reload_scripts();
}
bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
@@ -905,7 +900,7 @@ void ScriptEditor::_file_dialog_action(String p_file) {
}
file->close();
memdelete(file);
- FALLTHROUGH;
+ [[fallthrough]];
}
case FILE_OPEN: {
@@ -987,12 +982,22 @@ Array ScriptEditor::_get_open_scripts() const {
return ret;
}
+bool ScriptEditor::toggle_scripts_panel() {
+ list_split->set_visible(!list_split->is_visible());
+ return list_split->is_visible();
+}
+
+bool ScriptEditor::is_scripts_panel_toggled() {
+ return list_split->is_visible();
+}
+
void ScriptEditor::_menu_option(int p_option) {
+ ScriptEditorBase *current = _get_current_editor();
switch (p_option) {
case FILE_NEW: {
- script_create_dialog->config("Node", "new_script");
- script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE);
+ script_create_dialog->config("Node", "new_script", false, false);
+ script_create_dialog->popup_centered();
} break;
case FILE_NEW_TEXTFILE: {
file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
@@ -1080,6 +1085,10 @@ void ScriptEditor::_menu_option(int p_option) {
_on_find_in_files_requested("");
} break;
+ case REPLACE_IN_FILES: {
+
+ _on_replace_in_files_requested("");
+ } break;
case SEARCH_HELP: {
help_search_dialog->popup_dialog();
@@ -1105,33 +1114,19 @@ void ScriptEditor::_menu_option(int p_option) {
_sort_list_on_update = true;
_update_script_names();
} break;
- case DEBUG_SHOW: {
- if (debugger) {
- bool visible = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW));
- debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible);
- if (visible)
- debugger->hide();
- else
- debugger->show();
- }
- } break;
- case DEBUG_SHOW_KEEP_OPEN: {
- bool visible = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN));
- if (debugger)
- debugger->set_hide_on_stop(visible);
- debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible);
- } break;
- case DEBUG_WITH_EXTERNAL_EDITOR: {
- bool debug_with_external_editor = !debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR));
- debugger->set_debug_with_external_editor(debug_with_external_editor);
- debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), debug_with_external_editor);
- } break;
case TOGGLE_SCRIPTS_PANEL: {
- list_split->set_visible(!list_split->is_visible());
+ if (current) {
+ ScriptTextEditor *editor = Object::cast_to<ScriptTextEditor>(current);
+ toggle_scripts_panel();
+ if (editor) {
+ editor->update_toggle_scripts_button();
+ }
+ } else {
+ toggle_scripts_panel();
+ }
}
}
- ScriptEditorBase *current = _get_current_editor();
if (current) {
switch (p_option) {
@@ -1208,7 +1203,7 @@ void ScriptEditor::_menu_option(int p_option) {
Ref<Script> scr = current->get_edited_resource();
if (scr == NULL || scr.is_null()) {
- EditorNode::get_singleton()->show_warning("Can't obtain the script for running.");
+ EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for running."));
break;
}
@@ -1216,23 +1211,23 @@ void ScriptEditor::_menu_option(int p_option) {
Error err = scr->reload(false); //hard reload script before running always
if (err != OK) {
- EditorNode::get_singleton()->show_warning("Script failed reloading, check console for errors.");
+ EditorNode::get_singleton()->show_warning(TTR("Script failed reloading, check console for errors."));
return;
}
if (!scr->is_tool()) {
- EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run.");
+ EditorNode::get_singleton()->show_warning(TTR("Script is not in tool mode, will not be able to run."));
return;
}
if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) {
- EditorNode::get_singleton()->show_warning("To run this script, it must inherit EditorScript and be set to tool mode.");
+ EditorNode::get_singleton()->show_warning(TTR("To run this script, it must inherit EditorScript and be set to tool mode."));
return;
}
Ref<EditorScript> es = memnew(EditorScript);
- es->set_script(scr.get_ref_ptr());
+ es->set_script(scr);
es->set_editor(EditorNode::get_singleton());
es->_run();
@@ -1250,12 +1245,15 @@ void ScriptEditor::_menu_option(int p_option) {
_copy_script_path();
} break;
case SHOW_IN_FILE_SYSTEM: {
- RES script = current->get_edited_resource();
- FileSystemDock *file_system_dock = EditorNode::get_singleton()->get_filesystem_dock();
- file_system_dock->navigate_to_path(script->get_path());
- // Ensure that the FileSystem dock is visible.
- TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
- tab_container->set_current_tab(file_system_dock->get_position_in_parent());
+ const RES script = current->get_edited_resource();
+ const String path = script->get_path();
+ if (!path.empty()) {
+ FileSystemDock *file_system_dock = EditorNode::get_singleton()->get_filesystem_dock();
+ file_system_dock->navigate_to_path(path);
+ // Ensure that the FileSystem dock is visible.
+ TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
+ tab_container->set_current_tab(file_system_dock->get_position_in_parent());
+ }
} break;
case CLOSE_DOCS: {
_close_docs_tab();
@@ -1266,29 +1264,6 @@ void ScriptEditor::_menu_option(int p_option) {
case CLOSE_ALL: {
_close_all_tabs();
} break;
- case DEBUG_NEXT: {
-
- if (debugger)
- debugger->debug_next();
- } break;
- case DEBUG_STEP: {
-
- if (debugger)
- debugger->debug_step();
-
- } break;
- case DEBUG_BREAK: {
-
- if (debugger)
- debugger->debug_break();
-
- } break;
- case DEBUG_CONTINUE: {
-
- if (debugger)
- debugger->debug_continue();
-
- } break;
case WINDOW_MOVE_UP: {
if (tab_container->get_current_tab() > 0) {
@@ -1411,19 +1386,17 @@ void ScriptEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- editor->connect("play_pressed", this, "_editor_play");
- editor->connect("pause_pressed", this, "_editor_pause");
- editor->connect("stop_pressed", this, "_editor_stop");
- editor->connect("script_add_function_request", this, "_add_callback");
- editor->connect("resource_saved", this, "_res_saved_callback");
- script_list->connect("item_selected", this, "_script_selected");
+ editor->connect_compat("stop_pressed", this, "_editor_stop");
+ editor->connect_compat("script_add_function_request", this, "_add_callback");
+ editor->connect_compat("resource_saved", this, "_res_saved_callback");
+ script_list->connect_compat("item_selected", this, "_script_selected");
- members_overview->connect("item_selected", this, "_members_overview_selected");
- help_overview->connect("item_selected", this, "_help_overview_selected");
- script_split->connect("dragged", this, "_script_split_dragged");
+ members_overview->connect_compat("item_selected", this, "_members_overview_selected");
+ help_overview->connect_compat("item_selected", this, "_help_overview_selected");
+ script_split->connect_compat("dragged", this, "_script_split_dragged");
- EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
- FALLTHROUGH;
+ EditorSettings::get_singleton()->connect_compat("settings_changed", this, "_editor_settings_changed");
+ [[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
@@ -1446,16 +1419,14 @@ void ScriptEditor::_notification(int p_what) {
case NOTIFICATION_READY: {
- get_tree()->connect("tree_changed", this, "_tree_changed");
- editor->get_inspector_dock()->connect("request_help", this, "_request_help");
- editor->connect("request_help_search", this, "_help_search");
+ get_tree()->connect_compat("tree_changed", this, "_tree_changed");
+ editor->get_inspector_dock()->connect_compat("request_help", this, "_request_help");
+ editor->connect_compat("request_help_search", this, "_help_search");
} break;
case NOTIFICATION_EXIT_TREE: {
- editor->disconnect("play_pressed", this, "_editor_play");
- editor->disconnect("pause_pressed", this, "_editor_pause");
- editor->disconnect("stop_pressed", this, "_editor_stop");
+ editor->disconnect_compat("stop_pressed", this, "_editor_stop");
} break;
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
@@ -1624,7 +1595,7 @@ struct _ScriptEditorItemData {
String name;
String sort_key;
- Ref<Texture> icon;
+ Ref<Texture2D> icon;
int index;
String tooltip;
bool used;
@@ -1809,7 +1780,7 @@ void ScriptEditor::_update_script_names() {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
- Ref<Texture> icon = se->get_icon();
+ Ref<Texture2D> icon = se->get_icon();
String path = se->get_edited_resource()->get_path();
bool built_in = !path.is_resource_file();
String name;
@@ -1870,7 +1841,7 @@ void ScriptEditor::_update_script_names() {
if (eh) {
String name = eh->get_class();
- Ref<Texture> icon = get_icon("Help", "EditorIcons");
+ Ref<Texture2D> icon = get_icon("Help", "EditorIcons");
String tooltip = vformat(TTR("%s Class Reference"), name);
_ScriptEditorItemData sd;
@@ -2034,7 +2005,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
return false;
}
- if ((debugger->get_dump_stack_script() != p_resource || debugger->get_debug_with_external_editor()) &&
+ if ((EditorDebuggerNode::get_singleton()->get_dump_stack_script() != p_resource || EditorDebuggerNode::get_singleton()->get_debug_with_external_editor()) &&
p_resource->get_path().is_resource_file() &&
p_resource->get_class_name() != StringName("VisualScript") &&
bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
@@ -2166,13 +2137,14 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
_sort_list_on_update = true;
_update_script_names();
_save_layout();
- se->connect("name_changed", this, "_update_script_names");
- se->connect("edited_script_changed", this, "_script_changed");
- se->connect("request_help", this, "_help_search");
- se->connect("request_open_script_at_line", this, "_goto_script_line");
- se->connect("go_to_help", this, "_help_class_goto");
- se->connect("request_save_history", this, "_save_history");
- se->connect("search_in_files_requested", this, "_on_find_in_files_requested");
+ se->connect_compat("name_changed", this, "_update_script_names");
+ se->connect_compat("edited_script_changed", this, "_script_changed");
+ se->connect_compat("request_help", this, "_help_search");
+ se->connect_compat("request_open_script_at_line", this, "_goto_script_line");
+ se->connect_compat("go_to_help", this, "_help_class_goto");
+ se->connect_compat("request_save_history", this, "_save_history");
+ se->connect_compat("search_in_files_requested", this, "_on_find_in_files_requested");
+ se->connect_compat("replace_in_files_requested", this, "_on_replace_in_files_requested");
//test for modification, maybe the script was not edited but was loaded
@@ -2248,26 +2220,7 @@ void ScriptEditor::open_script_create_dialog(const String &p_base_name, const St
script_create_dialog->config(p_base_name, p_base_path);
}
-void ScriptEditor::_editor_play() {
-
- debugger->start();
- debug_menu->get_popup()->grab_focus();
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), false);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
-}
-
-void ScriptEditor::_editor_pause() {
-}
void ScriptEditor::_editor_stop() {
-
- debugger->stop();
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
@@ -2280,7 +2233,7 @@ void ScriptEditor::_editor_stop() {
}
}
-void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PoolStringArray &p_args) {
+void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) {
ERR_FAIL_COND(!p_obj);
Ref<Script> script = p_obj->get_script();
@@ -2393,7 +2346,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
HBoxContainer *drag_preview = memnew(HBoxContainer);
String preview_name = "";
- Ref<Texture> preview_icon;
+ Ref<Texture2D> preview_icon;
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node);
if (se) {
@@ -2497,7 +2450,10 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node);
EditorHelp *eh = Object::cast_to<EditorHelp>(node);
if (se || eh) {
- int new_index = script_list->get_item_metadata(script_list->get_item_at_position(p_point));
+ int new_index = 0;
+ if (script_list->get_item_count() > 0) {
+ new_index = script_list->get_item_metadata(script_list->get_item_at_position(p_point));
+ }
tab_container->move_child(node, new_index);
tab_container->set_current_tab(new_index);
_update_script_names();
@@ -2514,7 +2470,10 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node);
EditorHelp *eh = Object::cast_to<EditorHelp>(node);
if (se || eh) {
- int new_index = script_list->get_item_metadata(script_list->get_item_at_position(p_point));
+ int new_index = 0;
+ if (script_list->get_item_count() > 0) {
+ new_index = script_list->get_item_metadata(script_list->get_item_at_position(p_point));
+ }
tab_container->move_child(node, new_index);
tab_container->set_current_tab(new_index);
_update_script_names();
@@ -2525,7 +2484,10 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
Vector<String> files = d["files"];
- int new_index = script_list->get_item_metadata(script_list->get_item_at_position(p_point));
+ int new_index = 0;
+ if (script_list->get_item_count() > 0) {
+ new_index = script_list->get_item_metadata(script_list->get_item_at_position(p_point));
+ }
int num_tabs_before = tab_container->get_child_count();
for (int i = 0; i < files.size(); i++) {
String file = files[i];
@@ -2551,16 +2513,20 @@ void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo())
return;
if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
- int next_tab = script_list->get_current() + 1;
- next_tab %= script_list->get_item_count();
- _go_to_tab(script_list->get_item_metadata(next_tab));
- _update_script_names();
+ if (script_list->get_item_count() > 1) {
+ int next_tab = script_list->get_current() + 1;
+ next_tab %= script_list->get_item_count();
+ _go_to_tab(script_list->get_item_metadata(next_tab));
+ _update_script_names();
+ }
}
if (ED_IS_SHORTCUT("script_editor/prev_script", p_event)) {
- int next_tab = script_list->get_current() - 1;
- next_tab = next_tab >= 0 ? next_tab : script_list->get_item_count() - 1;
- _go_to_tab(script_list->get_item_metadata(next_tab));
- _update_script_names();
+ if (script_list->get_item_count() > 1) {
+ int next_tab = script_list->get_current() - 1;
+ next_tab = next_tab >= 0 ? next_tab : script_list->get_item_count() - 1;
+ _go_to_tab(script_list->get_item_metadata(next_tab));
+ _update_script_names();
+ }
}
if (ED_IS_SHORTCUT("script_editor/window_move_up", p_event)) {
_menu_option(WINDOW_MOVE_UP);
@@ -2771,7 +2737,7 @@ void ScriptEditor::_help_class_open(const String &p_class) {
tab_container->add_child(eh);
_go_to_tab(tab_container->get_tab_count() - 1);
eh->go_to_class(p_class, 0);
- eh->connect("go_to_help", this, "_help_class_goto");
+ eh->connect_compat("go_to_help", this, "_help_class_goto");
_add_recent_script(p_class);
_sort_list_on_update = true;
_update_script_names();
@@ -2801,7 +2767,7 @@ void ScriptEditor::_help_class_goto(const String &p_desc) {
tab_container->add_child(eh);
_go_to_tab(tab_container->get_tab_count() - 1);
eh->go_to_help(p_desc);
- eh->connect("go_to_help", this, "_help_class_goto");
+ eh->connect_compat("go_to_help", this, "_help_class_goto");
_add_recent_script(eh->get_class());
_sort_list_on_update = true;
_update_script_names();
@@ -2989,10 +2955,19 @@ void ScriptEditor::_script_changed() {
void ScriptEditor::_on_find_in_files_requested(String text) {
+ find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::SEARCH_MODE);
find_in_files_dialog->set_search_text(text);
find_in_files_dialog->popup_centered_minsize();
}
+void ScriptEditor::_on_replace_in_files_requested(String text) {
+
+ find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::REPLACE_MODE);
+ find_in_files_dialog->set_search_text(text);
+ find_in_files_dialog->set_replace_text("");
+ find_in_files_dialog->popup_centered_minsize();
+}
+
void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) {
if (ResourceLoader::exists(fpath)) {
@@ -3042,12 +3017,13 @@ void ScriptEditor::_start_find_in_files(bool with_replace) {
f->set_filter(find_in_files_dialog->get_filter());
find_in_files->set_with_replace(with_replace);
+ find_in_files->set_replace_text(find_in_files_dialog->get_replace_text());
find_in_files->start_search();
editor->make_bottom_panel_item_visible(find_in_files);
}
-void ScriptEditor::_on_find_in_files_modified_files(PoolStringArray paths) {
+void ScriptEditor::_on_find_in_files_modified_files(PackedStringArray paths) {
_test_script_times_on_disk();
_update_modified_scripts_for_external_editor();
@@ -3073,8 +3049,6 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_close_other_tabs", &ScriptEditor::_close_other_tabs);
ClassDB::bind_method("_open_recent_script", &ScriptEditor::_open_recent_script);
ClassDB::bind_method("_theme_option", &ScriptEditor::_theme_option);
- ClassDB::bind_method("_editor_play", &ScriptEditor::_editor_play);
- ClassDB::bind_method("_editor_pause", &ScriptEditor::_editor_pause);
ClassDB::bind_method("_editor_stop", &ScriptEditor::_editor_stop);
ClassDB::bind_method("_add_callback", &ScriptEditor::_add_callback);
ClassDB::bind_method("_reload_scripts", &ScriptEditor::_reload_scripts);
@@ -3089,7 +3063,6 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_copy_script_path", &ScriptEditor::_copy_script_path);
ClassDB::bind_method("_breaked", &ScriptEditor::_breaked);
- ClassDB::bind_method("_show_debugger", &ScriptEditor::_show_debugger);
ClassDB::bind_method("_get_debug_tooltip", &ScriptEditor::_get_debug_tooltip);
ClassDB::bind_method("_autosave_scripts", &ScriptEditor::_autosave_scripts);
ClassDB::bind_method("_update_autosave_timer", &ScriptEditor::_update_autosave_timer);
@@ -3117,6 +3090,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_filter_methods_text_changed", &ScriptEditor::_filter_methods_text_changed);
ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts);
ClassDB::bind_method("_on_find_in_files_requested", &ScriptEditor::_on_find_in_files_requested);
+ ClassDB::bind_method("_on_replace_in_files_requested", &ScriptEditor::_on_replace_in_files_requested);
ClassDB::bind_method("_start_find_in_files", &ScriptEditor::_start_find_in_files);
ClassDB::bind_method("_on_find_in_files_result_selected", &ScriptEditor::_on_find_in_files_result_selected);
ClassDB::bind_method("_on_find_in_files_modified_files", &ScriptEditor::_on_find_in_files_modified_files);
@@ -3168,22 +3142,22 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
filter_scripts = memnew(LineEdit);
filter_scripts->set_placeholder(TTR("Filter scripts"));
filter_scripts->set_clear_button_enabled(true);
- filter_scripts->connect("text_changed", this, "_filter_scripts_text_changed");
+ filter_scripts->connect_compat("text_changed", this, "_filter_scripts_text_changed");
scripts_vbox->add_child(filter_scripts);
script_list = memnew(ItemList);
scripts_vbox->add_child(script_list);
- script_list->set_custom_minimum_size(Size2(150, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
+ script_list->set_custom_minimum_size(Size2(150, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
script_list->set_v_size_flags(SIZE_EXPAND_FILL);
script_split->set_split_offset(140);
_sort_list_on_update = true;
- script_list->connect("gui_input", this, "_script_list_gui_input", varray(), CONNECT_DEFERRED);
+ script_list->connect_compat("gui_input", this, "_script_list_gui_input", varray(), CONNECT_DEFERRED);
script_list->set_allow_rmb_select(true);
script_list->set_drag_forwarding(this);
context_menu = memnew(PopupMenu);
add_child(context_menu);
- context_menu->connect("id_pressed", this, "_menu_option");
+ context_menu->connect_compat("id_pressed", this, "_menu_option");
context_menu->set_hide_on_window_lose_focus(true);
overview_vbox = memnew(VBoxContainer);
@@ -3204,28 +3178,28 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
members_overview_alphabeta_sort_button->set_tooltip(TTR("Toggle alphabetical sorting of the method list."));
members_overview_alphabeta_sort_button->set_toggle_mode(true);
members_overview_alphabeta_sort_button->set_pressed(EditorSettings::get_singleton()->get("text_editor/tools/sort_members_outline_alphabetically"));
- members_overview_alphabeta_sort_button->connect("toggled", this, "_toggle_members_overview_alpha_sort");
+ members_overview_alphabeta_sort_button->connect_compat("toggled", this, "_toggle_members_overview_alpha_sort");
buttons_hbox->add_child(members_overview_alphabeta_sort_button);
filter_methods = memnew(LineEdit);
filter_methods->set_placeholder(TTR("Filter methods"));
filter_methods->set_clear_button_enabled(true);
- filter_methods->connect("text_changed", this, "_filter_methods_text_changed");
+ filter_methods->connect_compat("text_changed", this, "_filter_methods_text_changed");
overview_vbox->add_child(filter_methods);
members_overview = memnew(ItemList);
overview_vbox->add_child(members_overview);
members_overview->set_allow_reselect(true);
- members_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
+ members_overview->set_custom_minimum_size(Size2(0, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
members_overview->set_v_size_flags(SIZE_EXPAND_FILL);
members_overview->set_allow_rmb_select(true);
help_overview = memnew(ItemList);
overview_vbox->add_child(help_overview);
help_overview->set_allow_reselect(true);
- help_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
+ help_overview->set_custom_minimum_size(Size2(0, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
help_overview->set_v_size_flags(SIZE_EXPAND_FILL);
tab_container = memnew(TabContainer);
@@ -3238,7 +3212,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
ED_SHORTCUT("script_editor/window_move_up", TTR("Move Up"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_UP);
ED_SHORTCUT("script_editor/window_move_down", TTR("Move Down"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_DOWN);
ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD); // these should be KEY_GREATER and KEY_LESS but those don't work
- ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COLON);
+ ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COMMA);
set_process_unhandled_input(true);
file_menu = memnew(MenuButton);
@@ -3255,7 +3229,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
recent_scripts = memnew(PopupMenu);
recent_scripts->set_name("RecentScripts");
file_menu->get_popup()->add_child(recent_scripts);
- recent_scripts->connect("id_pressed", this, "_open_recent_script");
+ recent_scripts->connect_compat("id_pressed", this, "_open_recent_script");
_update_recent_scripts();
file_menu->get_popup()->add_separator();
@@ -3277,7 +3251,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
theme_submenu = memnew(PopupMenu);
theme_submenu->set_name("Theme");
file_menu->get_popup()->add_child(theme_submenu);
- theme_submenu->connect("id_pressed", this, "_theme_option");
+ theme_submenu->connect_compat("id_pressed", this, "_theme_option");
theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/import_theme", TTR("Import Theme...")), THEME_IMPORT);
theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/reload_theme", TTR("Reload Theme")), THEME_RELOAD);
@@ -3296,35 +3270,25 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KEY_MASK_CMD | KEY_BACKSLASH), TOGGLE_SCRIPTS_PANEL);
- file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ file_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
script_search_menu = memnew(MenuButton);
menu_hb->add_child(script_search_menu);
script_search_menu->set_text(TTR("Search"));
script_search_menu->set_switch_on_hover(true);
script_search_menu->get_popup()->set_hide_on_window_lose_focus(true);
- script_search_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ script_search_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
- debug_menu = memnew(MenuButton);
+ MenuButton *debug_menu = memnew(MenuButton);
menu_hb->add_child(debug_menu);
- debug_menu->set_text(TTR("Debug"));
- debug_menu->set_switch_on_hover(true);
- debug_menu->get_popup()->set_hide_on_window_lose_focus(true);
- debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11), DEBUG_STEP);
- debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10), DEBUG_NEXT);
- debug_menu->get_popup()->add_separator();
- debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/break", TTR("Break")), DEBUG_BREAK);
- debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/continue", TTR("Continue"), KEY_F12), DEBUG_CONTINUE);
- debug_menu->get_popup()->add_separator();
- //debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW);
- debug_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("debugger/keep_debugger_open", TTR("Keep Debugger Open")), DEBUG_SHOW_KEEP_OPEN);
- debug_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("debugger/debug_with_external_editor", TTR("Debug with External Editor")), DEBUG_WITH_EXTERNAL_EDITOR);
- debug_menu->get_popup()->connect("id_pressed", this, "_menu_option");
-
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), true);
- debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
+ debug_menu->hide(); // Handled by EditorDebuggerNode below.
+
+ EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
+ debugger->set_script_debug_button(debug_menu);
+ debugger->connect_compat("goto_script_line", this, "_goto_script_line");
+ debugger->connect_compat("set_execution", this, "_set_execution");
+ debugger->connect_compat("clear_execution", this, "_clear_execution");
+ debugger->connect_compat("breaked", this, "_breaked");
menu_hb->add_spacer();
@@ -3340,64 +3304,58 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
site_search = memnew(ToolButton);
site_search->set_text(TTR("Online Docs"));
- site_search->connect("pressed", this, "_menu_option", varray(SEARCH_WEBSITE));
+ site_search->connect_compat("pressed", this, "_menu_option", varray(SEARCH_WEBSITE));
menu_hb->add_child(site_search);
site_search->set_tooltip(TTR("Open Godot online documentation."));
request_docs = memnew(ToolButton);
request_docs->set_text(TTR("Request Docs"));
- request_docs->connect("pressed", this, "_menu_option", varray(REQUEST_DOCS));
+ request_docs->connect_compat("pressed", this, "_menu_option", varray(REQUEST_DOCS));
menu_hb->add_child(request_docs);
request_docs->set_tooltip(TTR("Help improve the Godot documentation by giving feedback."));
help_search = memnew(ToolButton);
help_search->set_text(TTR("Search Help"));
- help_search->connect("pressed", this, "_menu_option", varray(SEARCH_HELP));
+ help_search->connect_compat("pressed", this, "_menu_option", varray(SEARCH_HELP));
menu_hb->add_child(help_search);
help_search->set_tooltip(TTR("Search the reference documentation."));
menu_hb->add_child(memnew(VSeparator));
script_back = memnew(ToolButton);
- script_back->connect("pressed", this, "_history_back");
+ script_back->connect_compat("pressed", this, "_history_back");
menu_hb->add_child(script_back);
script_back->set_disabled(true);
script_back->set_tooltip(TTR("Go to previous edited document."));
script_forward = memnew(ToolButton);
- script_forward->connect("pressed", this, "_history_forward");
+ script_forward->connect_compat("pressed", this, "_history_forward");
menu_hb->add_child(script_forward);
script_forward->set_disabled(true);
script_forward->set_tooltip(TTR("Go to next edited document."));
- tab_container->connect("tab_changed", this, "_tab_changed");
+ tab_container->connect_compat("tab_changed", this, "_tab_changed");
erase_tab_confirm = memnew(ConfirmationDialog);
erase_tab_confirm->get_ok()->set_text(TTR("Save"));
erase_tab_confirm->add_button(TTR("Discard"), OS::get_singleton()->get_swap_ok_cancel(), "discard");
- erase_tab_confirm->connect("confirmed", this, "_close_current_tab");
- erase_tab_confirm->connect("custom_action", this, "_close_discard_current_tab");
+ erase_tab_confirm->connect_compat("confirmed", this, "_close_current_tab");
+ erase_tab_confirm->connect_compat("custom_action", this, "_close_discard_current_tab");
add_child(erase_tab_confirm);
script_create_dialog = memnew(ScriptCreateDialog);
script_create_dialog->set_title(TTR("Create Script"));
add_child(script_create_dialog);
- script_create_dialog->connect("script_created", this, "_script_created");
+ script_create_dialog->connect_compat("script_created", this, "_script_created");
file_dialog_option = -1;
file_dialog = memnew(EditorFileDialog);
add_child(file_dialog);
- file_dialog->connect("file_selected", this, "_file_dialog_action");
+ file_dialog->connect_compat("file_selected", this, "_file_dialog_action");
error_dialog = memnew(AcceptDialog);
add_child(error_dialog);
- debugger = memnew(ScriptEditorDebugger(editor));
- debugger->connect("goto_script_line", this, "_goto_script_line");
- debugger->connect("set_execution", this, "_set_execution");
- debugger->connect("clear_execution", this, "_clear_execution");
- debugger->connect("show_debugger", this, "_show_debugger");
-
disk_changed = memnew(ConfirmationDialog);
{
VBoxContainer *vbc = memnew(VBoxContainer);
@@ -3411,48 +3369,42 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
vbc->add_child(disk_changed_list);
disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL);
- disk_changed->connect("confirmed", this, "_reload_scripts");
+ disk_changed->connect_compat("confirmed", this, "_reload_scripts");
disk_changed->get_ok()->set_text(TTR("Reload"));
disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave");
- disk_changed->connect("custom_action", this, "_resave_scripts");
+ disk_changed->connect_compat("custom_action", this, "_resave_scripts");
}
add_child(disk_changed);
script_editor = this;
- Button *db = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Debugger"), debugger);
- debugger->set_tool_button(db);
-
- debugger->connect("breaked", this, "_breaked");
-
autosave_timer = memnew(Timer);
autosave_timer->set_one_shot(false);
- autosave_timer->connect(SceneStringNames::get_singleton()->tree_entered, this, "_update_autosave_timer");
- autosave_timer->connect("timeout", this, "_autosave_scripts");
+ autosave_timer->connect_compat(SceneStringNames::get_singleton()->tree_entered, this, "_update_autosave_timer");
+ autosave_timer->connect_compat("timeout", this, "_autosave_scripts");
add_child(autosave_timer);
grab_focus_block = false;
help_search_dialog = memnew(EditorHelpSearch);
add_child(help_search_dialog);
- help_search_dialog->connect("go_to_help", this, "_help_class_goto");
+ help_search_dialog->connect_compat("go_to_help", this, "_help_class_goto");
find_in_files_dialog = memnew(FindInFilesDialog);
- find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_FIND_REQUESTED, this, "_start_find_in_files", varray(false));
- find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, this, "_start_find_in_files", varray(true));
+ find_in_files_dialog->connect_compat(FindInFilesDialog::SIGNAL_FIND_REQUESTED, this, "_start_find_in_files", varray(false));
+ find_in_files_dialog->connect_compat(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, this, "_start_find_in_files", varray(true));
add_child(find_in_files_dialog);
find_in_files = memnew(FindInFilesPanel);
find_in_files_button = editor->add_bottom_panel_item(TTR("Search Results"), find_in_files);
find_in_files->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
- find_in_files->connect(FindInFilesPanel::SIGNAL_RESULT_SELECTED, this, "_on_find_in_files_result_selected");
- find_in_files->connect(FindInFilesPanel::SIGNAL_FILES_MODIFIED, this, "_on_find_in_files_modified_files");
+ find_in_files->connect_compat(FindInFilesPanel::SIGNAL_RESULT_SELECTED, this, "_on_find_in_files_result_selected");
+ find_in_files->connect_compat(FindInFilesPanel::SIGNAL_FILES_MODIFIED, this, "_on_find_in_files_modified_files");
find_in_files->hide();
find_in_files_button->hide();
history_pos = -1;
- //debugger_gui->hide();
edit_pass = 0;
trim_trailing_whitespace_on_save = EditorSettings::get_singleton()->get("text_editor/files/trim_trailing_whitespace_on_save");
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 294294fc56..b4b4f33fc5 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -73,7 +73,7 @@ public:
ScriptEditorQuickOpen();
};
-class ScriptEditorDebugger;
+class EditorDebuggerNode;
class ScriptEditorBase : public VBoxContainer {
@@ -92,7 +92,7 @@ public:
virtual void set_edited_resource(const RES &p_res) = 0;
virtual void reload_text() = 0;
virtual String get_name() = 0;
- virtual Ref<Texture> get_icon() = 0;
+ virtual Ref<Texture2D> get_icon() = 0;
virtual bool is_unsaved() = 0;
virtual Variant get_edit_state() = 0;
virtual void set_edit_state(const Variant &p_state) = 0;
@@ -107,7 +107,7 @@ public:
virtual void tag_saved_version() = 0;
virtual void reload(bool p_soft) {}
virtual void get_breakpoints(List<int> *p_breakpoints) = 0;
- virtual void add_callback(const String &p_function, PoolStringArray p_args) = 0;
+ virtual void add_callback(const String &p_function, PackedStringArray p_args) = 0;
virtual void update_settings() = 0;
virtual void set_debugger_active(bool p_active) = 0;
virtual bool can_lose_focus_on_node_selection() { return true; }
@@ -155,14 +155,8 @@ class ScriptEditor : public PanelContainer {
FILE_COPY_PATH,
FILE_TOOL_RELOAD,
FILE_TOOL_RELOAD_SOFT,
- DEBUG_NEXT,
- DEBUG_STEP,
- DEBUG_BREAK,
- DEBUG_CONTINUE,
- DEBUG_SHOW,
- DEBUG_SHOW_KEEP_OPEN,
- DEBUG_WITH_EXTERNAL_EDITOR,
SEARCH_IN_FILES,
+ REPLACE_IN_FILES,
SEARCH_HELP,
SEARCH_WEBSITE,
REQUEST_DOCS,
@@ -232,7 +226,6 @@ class ScriptEditor : public PanelContainer {
AcceptDialog *error_dialog;
ConfirmationDialog *erase_tab_confirm;
ScriptCreateDialog *script_create_dialog;
- ScriptEditorDebugger *debugger;
ToolButton *scripts_visible;
String current_theme;
@@ -314,13 +307,11 @@ class ScriptEditor : public PanelContainer {
EditorScriptCodeCompletionCache *completion_cache;
- void _editor_play();
- void _editor_pause();
void _editor_stop();
int edit_pass;
- void _add_callback(Object *p_obj, const String &p_function, const PoolStringArray &p_args);
+ void _add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args);
void _res_saved_callback(const Ref<Resource> &p_res);
bool trim_trailing_whitespace_on_save;
@@ -334,7 +325,6 @@ class ScriptEditor : public PanelContainer {
void _set_execution(REF p_script, int p_line);
void _clear_execution(REF p_script);
void _breaked(bool p_breaked, bool p_can_debug);
- void _show_debugger(bool p_show);
void _update_window_menu();
void _script_created(Ref<Script> p_script);
@@ -404,9 +394,10 @@ class ScriptEditor : public PanelContainer {
Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
void _on_find_in_files_requested(String text);
+ void _on_replace_in_files_requested(String text);
void _on_find_in_files_result_selected(String fpath, int line_number, int begin, int end);
void _start_find_in_files(bool with_replace);
- void _on_find_in_files_modified_files(PoolStringArray paths);
+ void _on_find_in_files_modified_files(PackedStringArray paths);
static void _open_script_request(const String &p_path);
@@ -419,6 +410,8 @@ protected:
public:
static ScriptEditor *get_singleton() { return script_editor; }
+ bool toggle_scripts_panel();
+ bool is_scripts_panel_toggled();
void ensure_focus_current();
void apply_scripts() const;
void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
@@ -453,7 +446,6 @@ public:
VSplitContainer *get_left_list_split() { return list_split; }
- ScriptEditorDebugger *get_debugger() { return debugger; }
void set_live_auto_reload_running_scripts(bool p_enabled);
static void register_create_syntax_highlighter_function(CreateSyntaxHighlighterFunc p_func);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index f63445dab8..4e0787c805 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,9 +32,10 @@
#include "core/math/expression.h"
#include "core/os/keyboard.h"
+#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
-#include "editor/script_editor_debugger.h"
void ConnectionInfoDialog::ok_pressed() {
}
@@ -52,30 +53,30 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n
for (List<Connection>::Element *E = all_connections.front(); E; E = E->next()) {
Connection connection = E->get();
- if (connection.method != p_method) {
+ if (connection.callable.get_method() != p_method) {
continue;
}
TreeItem *node_item = tree->create_item(root);
- node_item->set_text(0, Object::cast_to<Node>(connection.source)->get_name());
- node_item->set_icon(0, EditorNode::get_singleton()->get_object_icon(connection.source, "Node"));
+ node_item->set_text(0, Object::cast_to<Node>(connection.signal.get_object())->get_name());
+ node_item->set_icon(0, EditorNode::get_singleton()->get_object_icon(connection.signal.get_object(), "Node"));
node_item->set_selectable(0, false);
node_item->set_editable(0, false);
- node_item->set_text(1, connection.signal);
+ node_item->set_text(1, connection.signal.get_name());
node_item->set_icon(1, get_parent_control()->get_icon("Slot", "EditorIcons"));
node_item->set_selectable(1, false);
node_item->set_editable(1, false);
- node_item->set_text(2, Object::cast_to<Node>(connection.target)->get_name());
- node_item->set_icon(2, EditorNode::get_singleton()->get_object_icon(connection.target, "Node"));
+ node_item->set_text(2, Object::cast_to<Node>(connection.callable.get_object())->get_name());
+ node_item->set_icon(2, EditorNode::get_singleton()->get_object_icon(connection.callable.get_object(), "Node"));
node_item->set_selectable(2, false);
node_item->set_editable(2, false);
}
}
- popup_centered(Size2(400, 300) * EDSCALE);
+ popup_centered(Size2(600, 300) * EDSCALE);
}
ConnectionInfoDialog::ConnectionInfoDialog() {
@@ -305,13 +306,15 @@ void ScriptTextEditor::_set_theme_for_script() {
text_edit->add_keyword_color("RID", basetype_color);
text_edit->add_keyword_color("Dictionary", basetype_color);
text_edit->add_keyword_color("Array", basetype_color);
- text_edit->add_keyword_color("PoolByteArray", basetype_color);
- text_edit->add_keyword_color("PoolIntArray", basetype_color);
- text_edit->add_keyword_color("PoolRealArray", basetype_color);
- text_edit->add_keyword_color("PoolStringArray", basetype_color);
- text_edit->add_keyword_color("PoolVector2Array", basetype_color);
- text_edit->add_keyword_color("PoolVector3Array", basetype_color);
- text_edit->add_keyword_color("PoolColorArray", basetype_color);
+ text_edit->add_keyword_color("PackedByteArray", basetype_color);
+ text_edit->add_keyword_color("PackedInt32Array", basetype_color);
+ text_edit->add_keyword_color("PackedFloat32Array", basetype_color);
+ text_edit->add_keyword_color("PackedInt64Array", basetype_color);
+ text_edit->add_keyword_color("PackedFloat64Array", basetype_color);
+ text_edit->add_keyword_color("PackedStringArray", basetype_color);
+ text_edit->add_keyword_color("PackedVector2Array", basetype_color);
+ text_edit->add_keyword_color("PackedVector3Array", basetype_color);
+ text_edit->add_keyword_color("PackedColorArray", basetype_color);
//colorize engine types
List<StringName> types;
@@ -423,7 +426,7 @@ void ScriptTextEditor::_notification(int p_what) {
}
}
-void ScriptTextEditor::add_callback(const String &p_function, PoolStringArray p_args) {
+void ScriptTextEditor::add_callback(const String &p_function, PackedStringArray p_args) {
String code = code_editor->get_text_edit()->get_text();
int pos = script->get_language()->find_function(p_function, code);
@@ -547,13 +550,13 @@ String ScriptTextEditor::get_name() {
return name;
}
-Ref<Texture> ScriptTextEditor::get_icon() {
+Ref<Texture2D> ScriptTextEditor::get_icon() {
if (get_parent_control() && get_parent_control()->has_icon(script->get_class(), "EditorIcons")) {
return get_parent_control()->get_icon(script->get_class(), "EditorIcons");
}
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
void ScriptTextEditor::_validate_script() {
@@ -602,12 +605,12 @@ void ScriptTextEditor::_validate_script() {
Connection connection = E->get();
String base_path = base->get_name();
- String source_path = base == connection.source ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.source));
- String target_path = base == connection.target ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.target));
+ String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.signal.get_object()));
+ String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object()));
warnings_panel->push_cell();
warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor"));
- warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.method, connection.signal, source_path, target_path));
+ warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.callable.get_method(), connection.signal.get_name(), source_path, target_path));
warnings_panel->pop(); // Color.
warnings_panel->pop(); // Cell.
}
@@ -690,13 +693,16 @@ void ScriptTextEditor::_update_bookmark_list() {
bookmarks_menu->add_separator();
for (int i = 0; i < bookmark_list.size(); i++) {
- String line = code_editor->get_text_edit()->get_line(bookmark_list[i]).strip_edges();
+ // Strip edges to remove spaces or tabs.
+ // Also replace any tabs by spaces, since we can't print tabs in the menu.
+ String line = code_editor->get_text_edit()->get_line(bookmark_list[i]).replace("\t", " ").strip_edges();
+
// Limit the size of the line if too big.
if (line.length() > 50) {
line = line.substr(0, 50);
}
- bookmarks_menu->add_item(String::num((int)bookmark_list[i] + 1) + " - \"" + line + "\"");
+ bookmarks_menu->add_item(String::num((int)bookmark_list[i] + 1) + " - `" + line + "`");
bookmarks_menu->set_item_metadata(bookmarks_menu->get_item_count() - 1, bookmark_list[i]);
}
}
@@ -707,6 +713,7 @@ void ScriptTextEditor::_bookmark_item_pressed(int p_idx) {
_edit_option(bookmarks_menu->get_item_id(p_idx));
} else {
code_editor->goto_line(bookmarks_menu->get_item_metadata(p_idx));
+ code_editor->get_text_edit()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
}
}
@@ -839,13 +846,16 @@ void ScriptTextEditor::_update_breakpoint_list() {
breakpoints_menu->add_separator();
for (int i = 0; i < breakpoint_list.size(); i++) {
- String line = code_editor->get_text_edit()->get_line(breakpoint_list[i]).strip_edges();
+ // Strip edges to remove spaces or tabs.
+ // Also replace any tabs by spaces, since we can't print tabs in the menu.
+ String line = code_editor->get_text_edit()->get_line(breakpoint_list[i]).replace("\t", " ").strip_edges();
+
// Limit the size of the line if too big.
if (line.length() > 50) {
line = line.substr(0, 50);
}
- breakpoints_menu->add_item(String::num((int)breakpoint_list[i] + 1) + " - \"" + line + "\"");
+ breakpoints_menu->add_item(String::num((int)breakpoint_list[i] + 1) + " - `" + line + "`");
breakpoints_menu->set_item_metadata(breakpoints_menu->get_item_count() - 1, breakpoint_list[i]);
}
}
@@ -856,12 +866,13 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
_edit_option(breakpoints_menu->get_item_id(p_idx));
} else {
code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx));
+ code_editor->get_text_edit()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
}
}
void ScriptTextEditor::_breakpoint_toggled(int p_row) {
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row));
+ EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row));
}
void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_column) {
@@ -964,6 +975,12 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
}
}
+void ScriptTextEditor::update_toggle_scripts_button() {
+ if (code_editor != NULL) {
+ code_editor->update_toggle_scripts_button();
+ }
+}
+
void ScriptTextEditor::_update_connected_methods() {
TextEdit *text_edit = code_editor->get_text_edit();
text_edit->clear_info_icons();
@@ -991,24 +1008,24 @@ void ScriptTextEditor::_update_connected_methods() {
}
// As deleted nodes are still accessible via the undo/redo system, check if they're still on the tree.
- Node *source = Object::cast_to<Node>(connection.source);
+ Node *source = Object::cast_to<Node>(connection.signal.get_object());
if (source && !source->is_inside_tree()) {
continue;
}
- if (methods_found.has(connection.method)) {
+ if (methods_found.has(connection.callable.get_method())) {
continue;
}
- if (!ClassDB::has_method(script->get_instance_base_type(), connection.method)) {
+ if (!ClassDB::has_method(script->get_instance_base_type(), connection.callable.get_method())) {
int line = -1;
for (int j = 0; j < functions.size(); j++) {
String name = functions[j].get_slice(":", 0);
- if (name == connection.method) {
+ if (name == connection.callable.get_method()) {
line = functions[j].get_slice(":", 1).to_int();
- text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.method);
- methods_found.insert(connection.method);
+ text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.callable.get_method());
+ methods_found.insert(connection.callable.get_method());
break;
}
}
@@ -1021,7 +1038,7 @@ void ScriptTextEditor::_update_connected_methods() {
bool found_inherited_function = false;
Ref<Script> inherited_script = script->get_base_script();
while (!inherited_script.is_null()) {
- if (inherited_script->has_method(connection.method)) {
+ if (inherited_script->has_method(connection.callable.get_method())) {
found_inherited_function = true;
break;
}
@@ -1197,7 +1214,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
Expression expression;
Vector<String> lines = code_editor->get_text_edit()->get_selection_text().split("\n");
- PoolStringArray results;
+ PackedStringArray results;
for (int i = 0; i < lines.size(); i++) {
String line = lines[i];
@@ -1206,17 +1223,17 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (expression.parse(line) == OK) {
Variant result = expression.execute(Array(), Variant(), false);
if (expression.get_error_text() == "") {
- results.append(whitespace + result.get_construct_string());
+ results.push_back(whitespace + result.get_construct_string());
} else {
- results.append(line);
+ results.push_back(line);
}
} else {
- results.append(line);
+ results.push_back(line);
}
}
code_editor->get_text_edit()->begin_complex_operation(); //prevents creating a two-step undo
- code_editor->get_text_edit()->insert_text_at_cursor(results.join("\n"));
+ code_editor->get_text_edit()->insert_text_at_cursor(String("\n").join(results));
code_editor->get_text_edit()->end_complex_operation();
} break;
case SEARCH_FIND: {
@@ -1243,6 +1260,12 @@ void ScriptTextEditor::_edit_option(int p_op) {
// So this will be delegated to the ScriptEditor.
emit_signal("search_in_files_requested", selected_text);
} break;
+ case REPLACE_IN_FILES: {
+
+ String selected_text = code_editor->get_text_edit()->get_selection_text();
+
+ emit_signal("replace_in_files_requested", selected_text);
+ } break;
case SEARCH_LOCATE_FUNCTION: {
quick_open->popup_dialog(get_functions());
@@ -1273,7 +1296,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
int line = tx->cursor_get_line();
bool dobreak = !tx->is_line_set_as_breakpoint(line);
tx->set_line_as_breakpoint(line, dobreak);
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), line + 1, dobreak);
+ EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak);
} break;
case DEBUG_REMOVE_ALL_BREAKPOINTS: {
@@ -1284,7 +1307,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
int line = E->get();
bool dobreak = !tx->is_line_set_as_breakpoint(line);
tx->set_line_as_breakpoint(line, dobreak);
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), line + 1, dobreak);
+ EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak);
}
} break;
case DEBUG_GOTO_NEXT_BREAKPOINT: {
@@ -1301,12 +1324,14 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (line >= bpoints[bpoints.size() - 1]) {
tx->unfold_line(bpoints[0]);
tx->cursor_set_line(bpoints[0]);
+ tx->center_viewport_to_cursor();
} else {
for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
int bline = E->get();
if (bline > line) {
tx->unfold_line(bline);
tx->cursor_set_line(bline);
+ tx->center_viewport_to_cursor();
return;
}
}
@@ -1326,12 +1351,14 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (line <= bpoints[0]) {
tx->unfold_line(bpoints[bpoints.size() - 1]);
tx->cursor_set_line(bpoints[bpoints.size() - 1]);
+ tx->center_viewport_to_cursor();
} else {
for (List<int>::Element *E = bpoints.back(); E; E = E->prev()) {
int bline = E->get();
if (bline < line) {
tx->unfold_line(bline);
tx->cursor_set_line(bline);
+ tx->center_viewport_to_cursor();
return;
}
}
@@ -1547,7 +1574,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
if (!sn) {
- EditorNode::get_singleton()->show_warning("Can't drop nodes because script '" + get_name() + "' is not used in this scene.");
+ EditorNode::get_singleton()->show_warning(vformat(TTR("Can't drop nodes because script '%s' is not used in this scene."), get_name()));
return;
}
@@ -1749,13 +1776,14 @@ ScriptTextEditor::ScriptTextEditor() {
editor_box->add_child(code_editor);
code_editor->add_constant_override("separation", 2);
code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- code_editor->connect("validate_script", this, "_validate_script");
- code_editor->connect("load_theme_settings", this, "_load_theme_settings");
+ code_editor->connect_compat("validate_script", this, "_validate_script");
+ code_editor->connect_compat("load_theme_settings", this, "_load_theme_settings");
code_editor->set_code_complete_func(_code_complete_scripts, this);
- code_editor->get_text_edit()->connect("breakpoint_toggled", this, "_breakpoint_toggled");
- code_editor->get_text_edit()->connect("symbol_lookup", this, "_lookup_symbol");
- code_editor->get_text_edit()->connect("info_clicked", this, "_lookup_connections");
+ code_editor->get_text_edit()->connect_compat("breakpoint_toggled", this, "_breakpoint_toggled");
+ code_editor->get_text_edit()->connect_compat("symbol_lookup", this, "_lookup_symbol");
+ code_editor->get_text_edit()->connect_compat("info_clicked", this, "_lookup_connections");
code_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ code_editor->show_toggle_scripts_button();
warnings_panel = memnew(RichTextLabel);
editor_box->add_child(warnings_panel);
@@ -1766,9 +1794,9 @@ ScriptTextEditor::ScriptTextEditor() {
warnings_panel->set_focus_mode(FOCUS_CLICK);
warnings_panel->hide();
- code_editor->connect("error_pressed", this, "_error_pressed");
- code_editor->connect("show_warnings_panel", this, "_show_warnings_panel");
- warnings_panel->connect("meta_clicked", this, "_warning_clicked");
+ code_editor->connect_compat("error_pressed", this, "_error_pressed");
+ code_editor->connect_compat("show_warnings_panel", this, "_show_warnings_panel");
+ warnings_panel->connect_compat("meta_clicked", this, "_warning_clicked");
update_settings();
@@ -1778,11 +1806,11 @@ ScriptTextEditor::ScriptTextEditor() {
code_editor->get_text_edit()->set_select_identifiers_on_hover(true);
code_editor->get_text_edit()->set_context_menu_enabled(false);
- code_editor->get_text_edit()->connect("gui_input", this, "_text_edit_gui_input");
+ code_editor->get_text_edit()->connect_compat("gui_input", this, "_text_edit_gui_input");
context_menu = memnew(PopupMenu);
add_child(context_menu);
- context_menu->connect("id_pressed", this, "_edit_option");
+ context_menu->connect_compat("id_pressed", this, "_edit_option");
context_menu->set_hide_on_window_lose_focus(true);
color_panel = memnew(PopupPanel);
@@ -1790,7 +1818,7 @@ ScriptTextEditor::ScriptTextEditor() {
color_picker = memnew(ColorPicker);
color_picker->set_deferred_mode(true);
color_panel->add_child(color_picker);
- color_picker->connect("color_changed", this, "_color_changed");
+ color_picker->connect_compat("color_changed", this, "_color_changed");
// get default color picker mode from editor settings
int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
@@ -1831,7 +1859,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/auto_indent"), EDIT_AUTO_INDENT);
- edit_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+ edit_menu->get_popup()->connect_compat("id_pressed", this, "_edit_option");
edit_menu->get_popup()->add_separator();
PopupMenu *convert_case = memnew(PopupMenu);
@@ -1841,7 +1869,7 @@ ScriptTextEditor::ScriptTextEditor() {
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase"), KEY_MASK_SHIFT | KEY_F4), EDIT_TO_UPPERCASE);
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase"), KEY_MASK_SHIFT | KEY_F5), EDIT_TO_LOWERCASE);
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KEY_MASK_SHIFT | KEY_F6), EDIT_CAPITALIZE);
- convert_case->connect("id_pressed", this, "_edit_option");
+ convert_case->connect_compat("id_pressed", this, "_edit_option");
highlighters[TTR("Standard")] = NULL;
highlighter_menu = memnew(PopupMenu);
@@ -1849,7 +1877,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_menu->get_popup()->add_child(highlighter_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu");
highlighter_menu->add_radio_check_item(TTR("Standard"));
- highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter");
+ highlighter_menu->connect_compat("id_pressed", this, "_change_syntax_highlighter");
search_menu = memnew(MenuButton);
edit_hb->add_child(search_menu);
@@ -1862,9 +1890,10 @@ ScriptTextEditor::ScriptTextEditor() {
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE);
search_menu->get_popup()->add_separator();
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_in_files"), SEARCH_IN_FILES);
+ search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace_in_files"), REPLACE_IN_FILES);
search_menu->get_popup()->add_separator();
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/contextual_help"), HELP_CONTEXTUAL);
- search_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+ search_menu->get_popup()->connect_compat("id_pressed", this, "_edit_option");
edit_hb->add_child(edit_menu);
@@ -1872,7 +1901,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_hb->add_child(goto_menu);
goto_menu->set_text(TTR("Go To"));
goto_menu->set_switch_on_hover(true);
- goto_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+ goto_menu->get_popup()->connect_compat("id_pressed", this, "_edit_option");
goto_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_function"), SEARCH_LOCATE_FUNCTION);
goto_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE);
@@ -1883,20 +1912,20 @@ ScriptTextEditor::ScriptTextEditor() {
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
_update_bookmark_list();
- bookmarks_menu->connect("about_to_show", this, "_update_bookmark_list");
- bookmarks_menu->connect("index_pressed", this, "_bookmark_item_pressed");
+ bookmarks_menu->connect_compat("about_to_show", this, "_update_bookmark_list");
+ bookmarks_menu->connect_compat("index_pressed", this, "_bookmark_item_pressed");
breakpoints_menu = memnew(PopupMenu);
breakpoints_menu->set_name("Breakpoints");
goto_menu->get_popup()->add_child(breakpoints_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Breakpoints"), "Breakpoints");
_update_breakpoint_list();
- breakpoints_menu->connect("about_to_show", this, "_update_breakpoint_list");
- breakpoints_menu->connect("index_pressed", this, "_breakpoint_item_pressed");
+ breakpoints_menu->connect_compat("about_to_show", this, "_update_breakpoint_list");
+ breakpoints_menu->connect_compat("index_pressed", this, "_breakpoint_item_pressed");
quick_open = memnew(ScriptEditorQuickOpen);
add_child(quick_open);
- quick_open->connect("goto_line", this, "_goto_line");
+ quick_open->connect_compat("goto_line", this, "_goto_line");
goto_line_dialog = memnew(GotoLineDialog);
add_child(goto_line_dialog);
@@ -1970,6 +1999,7 @@ void ScriptTextEditor::register_editor() {
#endif
ED_SHORTCUT("script_text_editor/find_in_files", TTR("Find in Files..."), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F);
+ ED_SHORTCUT("script_text_editor/replace_in_files", TTR("Replace in Files..."), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_R);
#ifdef OSX_ENABLED
ED_SHORTCUT("script_text_editor/contextual_help", TTR("Contextual Help"), KEY_MASK_ALT | KEY_MASK_SHIFT | KEY_SPACE);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 2ba0be8feb..e23160d029 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -133,6 +133,7 @@ class ScriptTextEditor : public ScriptEditorBase {
SEARCH_LOCATE_FUNCTION,
SEARCH_GOTO_LINE,
SEARCH_IN_FILES,
+ REPLACE_IN_FILES,
BOOKMARK_TOGGLE,
BOOKMARK_GOTO_NEXT,
BOOKMARK_GOTO_PREV,
@@ -191,6 +192,7 @@ public:
virtual void add_syntax_highlighter(SyntaxHighlighter *p_highlighter);
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
+ void update_toggle_scripts_button();
virtual void apply_code();
virtual RES get_edited_resource() const;
@@ -198,7 +200,7 @@ public:
virtual Vector<String> get_functions();
virtual void reload_text();
virtual String get_name();
- virtual Ref<Texture> get_icon();
+ virtual Ref<Texture2D> get_icon();
virtual bool is_unsaved();
virtual Variant get_edit_state();
virtual void set_edit_state(const Variant &p_state);
@@ -218,7 +220,7 @@ public:
virtual void reload(bool p_soft);
virtual void get_breakpoints(List<int> *p_breakpoints);
- virtual void add_callback(const String &p_function, PoolStringArray p_args);
+ virtual void add_callback(const String &p_function, PackedStringArray p_args);
virtual void update_settings();
virtual bool show_members_overview();
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 97f194e40f..6c20483cf6 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,6 +35,7 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/property_editor.h"
#include "servers/visual/shader_types.h"
@@ -368,6 +369,7 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type"));
shader_editor->get_text_edit()->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent"));
shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
+ shader_editor->get_text_edit()->set_draw_spaces(EditorSettings::get_singleton()->get("text_editor/indent/draw_spaces"));
shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
shader_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
@@ -378,6 +380,11 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
shader_editor->get_text_edit()->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling"));
shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
+ shader_editor->get_text_edit()->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap"));
+ shader_editor->get_text_edit()->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE);
+ shader_editor->get_text_edit()->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guideline"));
+ shader_editor->get_text_edit()->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_column"));
+ shader_editor->get_text_edit()->set_breakpoint_gutter_enabled(false);
}
void ShaderEditor::_bind_methods() {
@@ -600,8 +607,8 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
shader_editor->add_constant_override("separation", 0);
shader_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- shader_editor->connect("script_changed", this, "apply_shaders");
- EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
+ shader_editor->connect_compat("script_changed", this, "apply_shaders");
+ EditorSettings::get_singleton()->connect_compat("settings_changed", this, "_editor_settings_changed");
shader_editor->get_text_edit()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"),
@@ -609,13 +616,13 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
shader_editor->get_text_edit()->set_select_identifiers_on_hover(true);
shader_editor->get_text_edit()->set_context_menu_enabled(false);
- shader_editor->get_text_edit()->connect("gui_input", this, "_text_edit_gui_input");
+ shader_editor->get_text_edit()->connect_compat("gui_input", this, "_text_edit_gui_input");
shader_editor->update_editor_settings();
context_menu = memnew(PopupMenu);
add_child(context_menu);
- context_menu->connect("id_pressed", this, "_menu_option");
+ context_menu->connect_compat("id_pressed", this, "_menu_option");
context_menu->set_hide_on_window_lose_focus(true);
VBoxContainer *main_container = memnew(VBoxContainer);
@@ -643,7 +650,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN);
edit_menu->get_popup()->add_separator();
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/complete_symbol"), EDIT_COMPLETE);
- edit_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ edit_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
search_menu = memnew(MenuButton);
search_menu->set_text(TTR("Search"));
@@ -653,12 +660,12 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE);
- search_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ search_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
MenuButton *goto_menu = memnew(MenuButton);
goto_menu->set_text(TTR("Go To"));
goto_menu->set_switch_on_hover(true);
- goto_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ goto_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
goto_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE);
goto_menu->get_popup()->add_separator();
@@ -668,14 +675,14 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
_update_bookmark_list();
- bookmarks_menu->connect("about_to_show", this, "_update_bookmark_list");
- bookmarks_menu->connect("index_pressed", this, "_bookmark_item_pressed");
+ bookmarks_menu->connect_compat("about_to_show", this, "_update_bookmark_list");
+ bookmarks_menu->connect_compat("index_pressed", this, "_bookmark_item_pressed");
help_menu = memnew(MenuButton);
help_menu->set_text(TTR("Help"));
help_menu->set_switch_on_hover(true);
help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS);
- help_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ help_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
add_child(main_container);
main_container->add_child(hbc);
@@ -698,11 +705,11 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
dl->set_text(TTR("This shader has been modified on on disk.\nWhat action should be taken?"));
vbc->add_child(dl);
- disk_changed->connect("confirmed", this, "_reload_shader_from_disk");
+ disk_changed->connect_compat("confirmed", this, "_reload_shader_from_disk");
disk_changed->get_ok()->set_text(TTR("Reload"));
disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave");
- disk_changed->connect("custom_action", this, "save_external_data");
+ disk_changed->connect_compat("custom_action", this, "save_external_data");
add_child(disk_changed);
@@ -756,7 +763,7 @@ ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) {
editor = p_node;
shader_editor = memnew(ShaderEditor(p_node));
- shader_editor->set_custom_minimum_size(Size2(0, 300));
+ shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("Shader"), shader_editor);
button->hide();
}
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index ca9f489713..900b40bd7a 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp
index 0ccb60e39e..d83a8ddf2d 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -110,7 +110,7 @@ Skeleton2DEditor::Skeleton2DEditor() {
options->get_popup()->add_item(TTR("Set Bones to Rest Pose"), MENU_OPTION_SET_REST);
options->set_switch_on_hover(true);
- options->get_popup()->connect("id_pressed", this, "_menu_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_menu_option");
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
diff --git a/editor/plugins/skeleton_2d_editor_plugin.h b/editor/plugins/skeleton_2d_editor_plugin.h
index d8e2d23257..ebc6746b81 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.h
+++ b/editor/plugins/skeleton_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_editor_plugin.cpp
index cd360d4caf..43ba99317e 100644
--- a/editor/plugins/skeleton_editor_plugin.cpp
+++ b/editor/plugins/skeleton_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -65,7 +65,6 @@ void SkeletonEditor::create_physical_skeleton() {
for (int bone_id = 0; bc > bone_id; ++bone_id) {
const int parent = skeleton->get_bone_parent(bone_id);
- const int parent_parent = skeleton->get_bone_parent(parent);
if (parent < 0) {
@@ -73,6 +72,8 @@ void SkeletonEditor::create_physical_skeleton() {
} else {
+ const int parent_parent = skeleton->get_bone_parent(parent);
+
bones_infos.write[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id);
/// create physical bone on parent
@@ -102,8 +103,10 @@ void SkeletonEditor::create_physical_skeleton() {
PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) {
- real_t half_height(skeleton->get_bone_rest(bone_child_id).origin.length() * 0.5);
- real_t radius(half_height * 0.2);
+ const Transform child_rest = skeleton->get_bone_rest(bone_child_id);
+
+ const real_t half_height(child_rest.origin.length() * 0.5);
+ const real_t radius(half_height * 0.2);
CapsuleShape *bone_shape_capsule = memnew(CapsuleShape);
bone_shape_capsule->set_height((half_height - radius) * 2);
@@ -113,7 +116,8 @@ PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_i
bone_shape->set_shape(bone_shape_capsule);
Transform body_transform;
- body_transform.origin = Vector3(0, 0, -half_height);
+ body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin, Vector3(0, 1, 0));
+ body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height));
Transform joint_transform;
joint_transform.origin = Vector3(0, 0, half_height);
@@ -133,7 +137,7 @@ void SkeletonEditor::edit(Skeleton *p_node) {
void SkeletonEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- get_tree()->connect("node_removed", this, "_node_removed");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
}
}
@@ -160,7 +164,7 @@ SkeletonEditor::SkeletonEditor() {
options->get_popup()->add_item(TTR("Create physical skeleton"), MENU_OPTION_CREATE_PHYSICAL_SKELETON);
- options->get_popup()->connect("id_pressed", this, "_on_click_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_on_click_option");
options->hide();
}
diff --git a/editor/plugins/skeleton_editor_plugin.h b/editor/plugins/skeleton_editor_plugin.h
index 558e954815..1dce6d12ed 100644
--- a/editor/plugins/skeleton_editor_plugin.h
+++ b/editor/plugins/skeleton_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/skeleton_ik_editor_plugin.cpp b/editor/plugins/skeleton_ik_editor_plugin.cpp
index 928171950a..a09dcca279 100644
--- a/editor/plugins/skeleton_ik_editor_plugin.cpp
+++ b/editor/plugins/skeleton_ik_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,21 +41,12 @@ void SkeletonIKEditorPlugin::_play() {
return;
if (play_btn->is_pressed()) {
-
- initial_bone_poses.resize(skeleton_ik->get_parent_skeleton()->get_bone_count());
- for (int i = 0; i < skeleton_ik->get_parent_skeleton()->get_bone_count(); ++i) {
- initial_bone_poses.write[i] = skeleton_ik->get_parent_skeleton()->get_bone_pose(i);
- }
-
skeleton_ik->start();
} else {
skeleton_ik->stop();
- if (initial_bone_poses.size() != skeleton_ik->get_parent_skeleton()->get_bone_count())
- return;
-
for (int i = 0; i < skeleton_ik->get_parent_skeleton()->get_bone_count(); ++i) {
- skeleton_ik->get_parent_skeleton()->set_bone_pose(i, initial_bone_poses[i]);
+ skeleton_ik->get_parent_skeleton()->set_bone_global_pose_override(i, Transform(), 0);
}
}
}
@@ -102,7 +93,7 @@ SkeletonIKEditorPlugin::SkeletonIKEditorPlugin(EditorNode *p_node) {
play_btn->set_text(TTR("Play IK"));
play_btn->set_toggle_mode(true);
play_btn->hide();
- play_btn->connect("pressed", this, "_play");
+ play_btn->connect_compat("pressed", this, "_play");
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, play_btn);
skeleton_ik = NULL;
}
diff --git a/editor/plugins/skeleton_ik_editor_plugin.h b/editor/plugins/skeleton_ik_editor_plugin.h
index d1ef7c99c5..814eb8ff5b 100644
--- a/editor/plugins/skeleton_ik_editor_plugin.h
+++ b/editor/plugins/skeleton_ik_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -44,7 +44,6 @@ class SkeletonIKEditorPlugin : public EditorPlugin {
Button *play_btn;
EditorNode *editor;
- Vector<Transform> initial_bone_poses;
void _play();
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index d187e4ff4a..4c8a0590fd 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,17 +36,19 @@
#include "core/print_string.h"
#include "core/project_settings.h"
#include "core/sort_array.h"
+#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
-#include "editor/script_editor_debugger.h"
#include "editor/spatial_editor_gizmos.h"
#include "scene/3d/camera.h"
#include "scene/3d/collision_shape.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/visual_instance.h"
+#include "scene/gui/viewport_container.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/surface_tool.h"
@@ -248,9 +250,9 @@ void SpatialEditorViewport::_clear_selected() {
editor_selection->clear();
}
-void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
+void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) {
- if (!clicked)
+ if (clicked.is_null())
return;
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked));
@@ -258,17 +260,20 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
if (!selected)
return;
- // Replace the node by the group if grouped
- while (node && node != editor->get_edited_scene()->get_parent()) {
- Spatial *selected_tmp = Object::cast_to<Spatial>(node);
- if (selected_tmp && node->has_meta("_edit_group_")) {
- selected = selected_tmp;
+ if (!p_allow_locked) {
+ // Replace the node by the group if grouped
+ while (node && node != editor->get_edited_scene()->get_parent()) {
+ Spatial *selected_tmp = Object::cast_to<Spatial>(node);
+ if (selected_tmp && node->has_meta("_edit_group_")) {
+ selected = selected_tmp;
+ }
+ node = node->get_parent();
}
- node = node->get_parent();
}
- if (!_is_node_locked(selected))
+ if (p_allow_locked || !_is_node_locked(selected)) {
_select(selected, clicked_wants_append, true);
+ }
}
void SpatialEditorViewport::_select(Node *p_node, bool p_append, bool p_single) {
@@ -298,12 +303,13 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Vector3 ray = _get_ray(p_pos);
Vector3 pos = _get_ray_pos(p_pos);
+ Vector2 shrinked_pos = p_pos / viewport_container->get_stretch_shrink();
Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
Set<Ref<EditorSpatialGizmo> > found_gizmos;
Node *edited_scene = get_tree()->get_edited_scene_root();
- ObjectID closest = 0;
+ ObjectID closest;
Node *item = NULL;
float closest_dist = 1e20;
int selected_handle = -1;
@@ -326,7 +332,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Vector3 normal;
int handle = -1;
- bool inters = seg->intersect_ray(camera, p_pos, point, normal, &handle, p_alt_select);
+ bool inters = seg->intersect_ray(camera, shrinked_pos, point, normal, &handle, p_alt_select);
if (!inters)
continue;
@@ -350,7 +356,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
}
if (!item)
- return 0;
+ return ObjectID();
if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) {
@@ -425,8 +431,7 @@ Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
} else {
cm.set_perspective(get_fov(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar());
}
- float screen_w, screen_h;
- cm.get_viewport_size(screen_w, screen_h);
+ Vector2 screen_he = cm.get_viewport_half_extents();
Transform camera_transform;
camera_transform.translate(cursor.pos);
@@ -434,7 +439,7 @@ Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
camera_transform.translate(0, 0, cursor.distance);
- return camera_transform.xform(Vector3(((p_vector3.x / get_size().width) * 2.0 - 1.0) * screen_w, ((1.0 - (p_vector3.y / get_size().height)) * 2.0 - 1.0) * screen_h, -(get_znear() + p_vector3.z)));
+ return camera_transform.xform(Vector3(((p_vector3.x / get_size().width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (p_vector3.y / get_size().height)) * 2.0 - 1.0) * screen_he.y, -(get_znear() + p_vector3.z)));
}
void SpatialEditorViewport::_select_region() {
@@ -521,7 +526,7 @@ void SpatialEditorViewport::_select_region() {
if (selected.find(item) != -1) continue;
- if (_is_node_locked(Object::cast_to<Spatial>(item))) continue;
+ if (_is_node_locked(item)) continue;
Ref<EditorSpatialGizmo> seg = sp->get_gizmo();
@@ -845,9 +850,9 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
clicked = selection_results[0].item->get_instance_id();
selection_results.clear();
- if (clicked) {
- _select_clicked(clicked_wants_append, true);
- clicked = 0;
+ if (clicked.is_valid()) {
+ _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
+ clicked = ObjectID();
}
} else if (!selection_results.empty()) {
@@ -859,11 +864,33 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
Spatial *spat = selection_results[i].item;
- Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node");
+ Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node");
String node_path = "/" + root_name + "/" + root_path.rel_path_to(spat->get_path());
- selection_menu->add_item(spat->get_name());
+ int locked = 0;
+ if (_is_node_locked(spat)) {
+ locked = 1;
+ } else {
+ Node *ed_scene = editor->get_edited_scene();
+ Node *node = spat;
+
+ while (node && node != ed_scene->get_parent()) {
+ Spatial *selected_tmp = Object::cast_to<Spatial>(node);
+ if (selected_tmp && node->has_meta("_edit_group_")) {
+ locked = 2;
+ }
+ node = node->get_parent();
+ }
+ }
+
+ String suffix = String();
+ if (locked == 1) {
+ suffix = " (" + TTR("Locked") + ")";
+ } else if (locked == 2) {
+ suffix = " (" + TTR("Grouped") + ")";
+ }
+ selection_menu->add_item((String)spat->get_name() + suffix);
selection_menu->set_item_icon(i, icon);
selection_menu->set_item_metadata(i, node_path);
selection_menu->set_item_tooltip(i, String(spat->get_name()) + "\nType: " + spat->get_class() + "\nPath: " + node_path);
@@ -1068,7 +1095,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (_gizmo_select(_edit.mouse_pos))
break;
- clicked = 0;
+ clicked = ObjectID();
clicked_includes_current = false;
if ((spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) {
@@ -1112,7 +1139,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
clicked_wants_append = b->get_shift();
- if (!clicked) {
+ if (clicked.is_null()) {
if (!clicked_wants_append)
_clear_selected();
@@ -1123,7 +1150,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
cursor.region_end = b->get_position();
}
- if (clicked && gizmo_handle >= 0) {
+ if (clicked.is_valid() && gizmo_handle >= 0) {
Spatial *spa = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
if (spa) {
@@ -1148,10 +1175,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_edit.gizmo = Ref<EditorSpatialGizmo>();
break;
}
- if (clicked) {
+ if (clicked.is_valid()) {
_select_clicked(clicked_wants_append, true);
// Processing was deferred.
- clicked = 0;
+ clicked = ObjectID();
}
if (cursor.region_select) {
@@ -1252,7 +1279,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else if (nav_scheme == NAVIGATION_MODO && m->get_alt()) {
nav_mode = NAVIGATION_ORBIT;
} else {
- if (clicked) {
+ if (clicked.is_valid()) {
if (!clicked_includes_current) {
@@ -1261,7 +1288,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
_compute_edit(_edit.mouse_pos);
- clicked = 0;
+ clicked = ObjectID();
_edit.mode = TRANSFORM_TRANSLATE;
}
@@ -2120,6 +2147,8 @@ void SpatialEditorViewport::_notification(int p_what) {
set_process(visible);
if (visible) {
+ orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL));
+ _update_name();
_update_camera(0);
} else {
set_freelook_active(false);
@@ -2132,6 +2161,13 @@ void SpatialEditorViewport::_notification(int p_what) {
call_deferred("update_transform_gizmo_view");
}
+ if (p_what == NOTIFICATION_READY) {
+ // The crosshair icon doesn't depend on the editor theme.
+ crosshair->set_texture(get_icon("Crosshair", "EditorIcons"));
+ // Set the anchors and margins after changing the icon to ensure it's centered correctly.
+ crosshair->set_anchors_and_margins_preset(PRESET_CENTER);
+ }
+
if (p_what == NOTIFICATION_PROCESS) {
real_t delta = get_process_delta_time();
@@ -2151,10 +2187,10 @@ void SpatialEditorViewport::_notification(int p_what) {
if (cam != NULL && cam != previewing) {
//then switch the viewport's camera to the scene's viewport camera
if (previewing != NULL) {
- previewing->disconnect("tree_exited", this, "_preview_exited_scene");
+ previewing->disconnect_compat("tree_exited", this, "_preview_exited_scene");
}
previewing = cam;
- previewing->connect("tree_exited", this, "_preview_exited_scene");
+ previewing->connect_compat("tree_exited", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera());
surface->update();
}
@@ -2238,9 +2274,6 @@ void SpatialEditorViewport::_notification(int p_what) {
int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/filters/msaa");
viewport->set_msaa(Viewport::MSAA(msaa_mode));
- bool hdr = ProjectSettings::get_singleton()->get("rendering/quality/depth/hdr");
- viewport->set_hdr(hdr);
-
bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
info_label->set_visible(show_info);
@@ -2252,6 +2285,10 @@ void SpatialEditorViewport::_notification(int p_what) {
current_camera = camera;
}
+ // Display the crosshair only while freelooking. Hide it otherwise,
+ // as the crosshair can be distracting.
+ crosshair->set_visible(freelook_active);
+
if (show_info) {
String text;
text += "X: " + rtos(current_camera->get_translation().x).pad_decimals(1) + "\n";
@@ -2294,12 +2331,12 @@ void SpatialEditorViewport::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- surface->connect("draw", this, "_draw");
- surface->connect("gui_input", this, "_sinput");
- surface->connect("mouse_entered", this, "_surface_mouse_enter");
- surface->connect("mouse_exited", this, "_surface_mouse_exit");
- surface->connect("focus_entered", this, "_surface_focus_enter");
- surface->connect("focus_exited", this, "_surface_focus_exit");
+ surface->connect_compat("draw", this, "_draw");
+ surface->connect_compat("gui_input", this, "_sinput");
+ surface->connect_compat("mouse_entered", this, "_surface_mouse_enter");
+ surface->connect_compat("mouse_exited", this, "_surface_mouse_exit");
+ surface->connect_compat("focus_entered", this, "_surface_focus_enter");
+ surface->connect_compat("focus_exited", this, "_surface_focus_exit");
_init_gizmo_instance(index);
}
@@ -2333,7 +2370,7 @@ void SpatialEditorViewport::_notification(int p_what) {
}
}
-static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture> icon) {
+static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> icon) {
// Adjust bar size from control height
Vector2 surface_size = surface.get_size();
@@ -2404,8 +2441,7 @@ void SpatialEditorViewport::_draw() {
_edit.mouse_pos,
center,
get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
- Math::round(2 * EDSCALE),
- true);
+ Math::round(2 * EDSCALE));
}
if (previewing) {
@@ -2725,53 +2761,86 @@ void SpatialEditorViewport::_menu_option(int p_option) {
view_menu->get_popup()->set_item_checked(idx, !current);
} break;
- case VIEW_DISPLAY_NORMAL: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_DISABLED);
-
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), true);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), false);
- } break;
- case VIEW_DISPLAY_WIREFRAME: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_WIREFRAME);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), true);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), false);
-
- } break;
- case VIEW_DISPLAY_OVERDRAW: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_OVERDRAW);
- VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_OVERDRAW);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), true);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), false);
-
- } break;
- case VIEW_DISPLAY_SHADELESS: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_UNSHADED);
- VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_SHADELESS);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), true);
+ case VIEW_DISPLAY_NORMAL:
+ case VIEW_DISPLAY_WIREFRAME:
+ case VIEW_DISPLAY_OVERDRAW:
+ case VIEW_DISPLAY_SHADELESS:
+ case VIEW_DISPLAY_LIGHTING:
+ case VIEW_DISPLAY_NORMAL_BUFFER:
+ case VIEW_DISPLAY_DEBUG_SHADOW_ATLAS:
+ case VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS:
+ case VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO:
+ case VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING:
+ case VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION:
+ case VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE:
+ case VIEW_DISPLAY_DEBUG_SSAO:
+ case VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER: {
+
+ static const int display_options[] = {
+ VIEW_DISPLAY_NORMAL,
+ VIEW_DISPLAY_WIREFRAME,
+ VIEW_DISPLAY_OVERDRAW,
+ VIEW_DISPLAY_SHADELESS,
+ VIEW_DISPLAY_LIGHTING,
+ VIEW_DISPLAY_NORMAL_BUFFER,
+ VIEW_DISPLAY_WIREFRAME,
+ VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO,
+ VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING,
+ VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION,
+ VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE,
+ VIEW_DISPLAY_DEBUG_SSAO,
+ VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER,
+ VIEW_MAX
+ };
+ static const Viewport::DebugDraw debug_draw_modes[] = {
+ Viewport::DEBUG_DRAW_DISABLED,
+ Viewport::DEBUG_DRAW_WIREFRAME,
+ Viewport::DEBUG_DRAW_OVERDRAW,
+ Viewport::DEBUG_DRAW_UNSHADED,
+ Viewport::DEBUG_DRAW_LIGHTING,
+ Viewport::DEBUG_DRAW_NORMAL_BUFFER,
+ Viewport::DEBUG_DRAW_WIREFRAME,
+ Viewport::DEBUG_DRAW_SHADOW_ATLAS,
+ Viewport::DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
+ Viewport::DEBUG_DRAW_GI_PROBE_ALBEDO,
+ Viewport::DEBUG_DRAW_GI_PROBE_LIGHTING,
+ Viewport::DEBUG_DRAW_GI_PROBE_EMISSION,
+ Viewport::DEBUG_DRAW_SCENE_LUMINANCE,
+ Viewport::DEBUG_DRAW_SSAO,
+ Viewport::DEBUG_DRAW_ROUGHNESS_LIMITER,
+ };
+
+ int idx = 0;
+
+ while (display_options[idx] != VIEW_MAX) {
+
+ int id = display_options[idx];
+ int item_idx = view_menu->get_popup()->get_item_index(id);
+ if (item_idx != -1) {
+ view_menu->get_popup()->set_item_checked(item_idx, id == p_option);
+ }
+ item_idx = display_submenu->get_item_index(id);
+ if (item_idx != -1) {
+ display_submenu->set_item_checked(item_idx, id == p_option);
+ }
+ if (id == p_option) {
+ viewport->set_debug_draw(debug_draw_modes[idx]);
+ }
+ idx++;
+ }
} break;
}
}
void SpatialEditorViewport::_preview_exited_scene() {
- preview_camera->disconnect("toggled", this, "_toggle_camera_preview");
+ preview_camera->disconnect_compat("toggled", this, "_toggle_camera_preview");
preview_camera->set_pressed(false);
_toggle_camera_preview(false);
- preview_camera->connect("toggled", this, "_toggle_camera_preview");
+ preview_camera->connect_compat("toggled", this, "_toggle_camera_preview");
view_menu->show();
}
@@ -2834,7 +2903,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
if (!p_activate) {
- previewing->disconnect("tree_exiting", this, "_preview_exited_scene");
+ previewing->disconnect_compat("tree_exiting", this, "_preview_exited_scene");
previewing = NULL;
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
if (!preview)
@@ -2845,7 +2914,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
} else {
previewing = preview;
- previewing->connect("tree_exiting", this, "_preview_exited_scene");
+ previewing->connect_compat("tree_exiting", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
view_menu->set_disabled(true);
surface->update();
@@ -2856,7 +2925,7 @@ void SpatialEditorViewport::_toggle_cinema_preview(bool p_activate) {
previewing_cinema = p_activate;
if (!previewing_cinema) {
if (previewing != NULL)
- previewing->disconnect("tree_exited", this, "_preview_exited_scene");
+ previewing->disconnect_compat("tree_exited", this, "_preview_exited_scene");
previewing = NULL;
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
@@ -2878,9 +2947,9 @@ void SpatialEditorViewport::_selection_result_pressed(int p_result) {
clicked = selection_results[p_result].item->get_instance_id();
- if (clicked) {
- _select_clicked(clicked_wants_append, true);
- clicked = 0;
+ if (clicked.is_valid()) {
+ _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
+ clicked = ObjectID();
}
}
@@ -3041,14 +3110,14 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
view_menu->get_popup()->set_item_checked(idx, previewing_cinema);
}
- if (preview_camera->is_connected("toggled", this, "_toggle_camera_preview")) {
- preview_camera->disconnect("toggled", this, "_toggle_camera_preview");
+ if (preview_camera->is_connected_compat("toggled", this, "_toggle_camera_preview")) {
+ preview_camera->disconnect_compat("toggled", this, "_toggle_camera_preview");
}
if (p_state.has("previewing")) {
Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]);
if (Object::cast_to<Camera>(pv)) {
previewing = Object::cast_to<Camera>(pv);
- previewing->connect("tree_exiting", this, "_preview_exited_scene");
+ previewing->connect_compat("tree_exiting", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
view_menu->set_disabled(true);
surface->update();
@@ -3056,7 +3125,7 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
preview_camera->show();
}
}
- preview_camera->connect("toggled", this, "_toggle_camera_preview");
+ preview_camera->connect_compat("toggled", this, "_toggle_camera_preview");
}
Dictionary SpatialEditorViewport::get_state() const {
@@ -3352,9 +3421,9 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P
editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
String new_name = parent->validate_child_name(instanced_scene);
- ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
- editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
+ EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
+ editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
+ editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
Transform global_transform;
Spatial *parent_spatial = Object::cast_to<Spatial>(parent);
@@ -3514,7 +3583,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
editor_data = editor->get_scene_tree_dock()->get_editor_data();
editor_selection = editor->get_editor_selection();
undo_redo = editor->get_undo_redo();
- clicked = 0;
+
clicked_includes_current = false;
orthogonal = false;
lock_rotation = false;
@@ -3543,6 +3612,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
camera->make_current();
surface->set_focus_mode(FOCUS_ALL);
+ crosshair = memnew(TextureRect);
+ crosshair->set_mouse_filter(MOUSE_FILTER_IGNORE);
+ surface->add_child(crosshair);
+
VBoxContainer *vbox = memnew(VBoxContainer);
surface->add_child(vbox);
vbox->set_position(Point2(10, 10) * EDSCALE);
@@ -3552,6 +3625,9 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
vbox->add_child(view_menu);
view_menu->set_h_size_flags(0);
+ display_submenu = memnew(PopupMenu);
+ view_menu->get_popup()->add_child(display_submenu);
+
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
@@ -3568,8 +3644,25 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_normal", TTR("Display Normal")), VIEW_DISPLAY_NORMAL);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_wireframe", TTR("Display Wireframe")), VIEW_DISPLAY_WIREFRAME);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_overdraw", TTR("Display Overdraw")), VIEW_DISPLAY_OVERDRAW);
+ view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_lighting", TTR("Display Lighting")), VIEW_DISPLAY_LIGHTING);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_unshaded", TTR("Display Unshaded")), VIEW_DISPLAY_SHADELESS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), true);
+ display_submenu->add_radio_check_item(TTR("Normal Buffer"), VIEW_DISPLAY_NORMAL_BUFFER);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Shadow Atlas"), VIEW_DISPLAY_DEBUG_SHADOW_ATLAS);
+ display_submenu->add_radio_check_item(TTR("Directional Shadow"), VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("GIProbe Lighting"), VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING);
+ display_submenu->add_radio_check_item(TTR("GIProbe Albedo"), VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO);
+ display_submenu->add_radio_check_item(TTR("GIProbe Emission"), VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Scene Luminance"), VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("SSAO"), VIEW_DISPLAY_DEBUG_SSAO);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Roughness Limiter"), VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER);
+ display_submenu->set_name("display_advanced");
+ view_menu->get_popup()->add_submenu_item(TTR("Display Advanced..."), "display_advanced");
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("View Environment")), VIEW_ENVIRONMENT);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("View Gizmos")), VIEW_GIZMOS);
@@ -3591,10 +3684,28 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_transform_with_view"), VIEW_ALIGN_TRANSFORM_WITH_VIEW);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_rotation_with_view"), VIEW_ALIGN_ROTATION_WITH_VIEW);
- view_menu->get_popup()->connect("id_pressed", this, "_menu_option");
-
+ view_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
+ display_submenu->connect_compat("id_pressed", this, "_menu_option");
view_menu->set_disable_shortcuts(true);
+ if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+ // Alternate display modes only work when using the Vulkan renderer; make this explicit.
+ const int normal_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL);
+ const int wireframe_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME);
+ const int overdraw_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW);
+ const int shadeless_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS);
+ const String unsupported_tooltip = TTR("Not available when using the GLES2 renderer.");
+
+ view_menu->get_popup()->set_item_disabled(normal_idx, true);
+ view_menu->get_popup()->set_item_tooltip(normal_idx, unsupported_tooltip);
+ view_menu->get_popup()->set_item_disabled(wireframe_idx, true);
+ view_menu->get_popup()->set_item_tooltip(wireframe_idx, unsupported_tooltip);
+ view_menu->get_popup()->set_item_disabled(overdraw_idx, true);
+ view_menu->get_popup()->set_item_tooltip(overdraw_idx, unsupported_tooltip);
+ view_menu->get_popup()->set_item_disabled(shadeless_idx, true);
+ view_menu->get_popup()->set_item_tooltip(shadeless_idx, unsupported_tooltip);
+ }
+
ED_SHORTCUT("spatial_editor/freelook_left", TTR("Freelook Left"), KEY_A);
ED_SHORTCUT("spatial_editor/freelook_right", TTR("Freelook Right"), KEY_D);
ED_SHORTCUT("spatial_editor/freelook_forward", TTR("Freelook Forward"), KEY_W);
@@ -3609,7 +3720,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
vbox->add_child(preview_camera);
preview_camera->set_h_size_flags(0);
preview_camera->hide();
- preview_camera->connect("toggled", this, "_toggle_camera_preview");
+ preview_camera->connect_compat("toggled", this, "_toggle_camera_preview");
previewing = NULL;
gizmo_scale = 1.0;
@@ -3662,8 +3773,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
selection_menu = memnew(PopupMenu);
add_child(selection_menu);
selection_menu->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
- selection_menu->connect("id_pressed", this, "_selection_result_pressed");
- selection_menu->connect("popup_hide", this, "_selection_menu_hide");
+ selection_menu->connect_compat("id_pressed", this, "_selection_result_pressed");
+ selection_menu->connect_compat("popup_hide", this, "_selection_menu_hide");
if (p_index == 0) {
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER), true);
@@ -3673,7 +3784,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
name = "";
_update_name();
- EditorSettings::get_singleton()->connect("settings_changed", this, "update_transform_gizmo_view");
+ EditorSettings::get_singleton()->connect_compat("settings_changed", this, "update_transform_gizmo_view");
}
//////////////////////////////////////////////////////////////
@@ -3781,12 +3892,12 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW && mouseover) {
- Ref<Texture> h_grabber = get_icon("grabber", "HSplitContainer");
- Ref<Texture> v_grabber = get_icon("grabber", "VSplitContainer");
+ Ref<Texture2D> h_grabber = get_icon("grabber", "HSplitContainer");
+ Ref<Texture2D> v_grabber = get_icon("grabber", "VSplitContainer");
- Ref<Texture> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons");
- Ref<Texture> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons");
- Ref<Texture> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons");
+ Ref<Texture2D> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons");
+ Ref<Texture2D> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons");
+ Ref<Texture2D> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons");
Vector2 size = get_size();
@@ -4138,12 +4249,12 @@ void SpatialEditor::_generate_selection_box() {
st->add_vertex(b);
}
- Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
- mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
+ mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
mat->set_albedo(Color(1, 1, 1));
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
st->set_material(mat);
selection_box = st->commit();
}
@@ -4386,7 +4497,7 @@ void SpatialEditor::_menu_item_toggled(bool pressed, int p_option) {
} break;
case MENU_TOOL_OVERRIDE_CAMERA: {
- ScriptEditorDebugger *const debugger = ScriptEditor::get_singleton()->get_debugger();
+ EditorDebuggerNode *const debugger = EditorDebuggerNode::get_singleton();
if (pressed) {
using Override = ScriptEditorDebugger::CameraOverride;
@@ -4443,7 +4554,7 @@ void SpatialEditor::_update_camera_override_viewport(Object *p_viewport) {
if (!current_viewport)
return;
- ScriptEditorDebugger *const debugger = ScriptEditor::get_singleton()->get_debugger();
+ EditorDebuggerNode *const debugger = EditorDebuggerNode::get_singleton();
camera_override_viewport_id = current_viewport->index;
if (debugger->get_camera_override() >= ScriptEditorDebugger::OVERRIDE_3D_1) {
@@ -4697,9 +4808,9 @@ void SpatialEditor::_init_indicators() {
grid_enabled = true;
indicator_mat.instance();
- indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
Vector<Color> origin_colors;
Vector<Vector3> origin_points;
@@ -4782,14 +4893,14 @@ void SpatialEditor::_init_indicators() {
scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
- Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
- mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
+ mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
mat->set_on_top_of_alpha();
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
mat->set_albedo(col);
gizmo_color[i] = mat;
- Ref<SpatialMaterial> mat_hl = mat->duplicate();
+ Ref<StandardMaterial3D> mat_hl = mat->duplicate();
mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
gizmo_color_hl[i] = mat_hl;
@@ -4877,17 +4988,17 @@ void SpatialEditor::_init_indicators() {
surftool->add_vertex(points[2]);
surftool->add_vertex(points[3]);
- Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial);
- plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> plane_mat = memnew(StandardMaterial3D);
+ plane_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
plane_mat->set_on_top_of_alpha();
- plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ plane_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ plane_mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
plane_mat->set_albedo(col);
plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides
surftool->set_material(plane_mat);
surftool->commit(move_plane_gizmo[i]);
- Ref<SpatialMaterial> plane_mat_hl = plane_mat->duplicate();
+ Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate();
plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides
}
@@ -5007,17 +5118,17 @@ void SpatialEditor::_init_indicators() {
surftool->add_vertex(points[2]);
surftool->add_vertex(points[3]);
- Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial);
- plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> plane_mat = memnew(StandardMaterial3D);
+ plane_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
plane_mat->set_on_top_of_alpha();
- plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ plane_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ plane_mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
plane_mat->set_albedo(col);
plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides
surftool->set_material(plane_mat);
surftool->commit(scale_plane_gizmo[i]);
- Ref<SpatialMaterial> plane_mat_hl = plane_mat->duplicate();
+ Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate();
plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides
}
@@ -5072,8 +5183,8 @@ void SpatialEditor::_update_gizmos_menu_theme() {
void SpatialEditor::_init_grid() {
- PoolVector<Color> grid_colors[3];
- PoolVector<Vector3> grid_points[3];
+ Vector<Color> grid_colors[3];
+ Vector<Vector3> grid_points[3];
Color primary_grid_color = EditorSettings::get_singleton()->get("editors/3d/primary_grid_color");
Color secondary_grid_color = EditorSettings::get_singleton()->get("editors/3d/secondary_grid_color");
@@ -5360,12 +5471,12 @@ void SpatialEditor::_notification(int p_what) {
_refresh_menu_icons();
- get_tree()->connect("node_removed", this, "_node_removed");
- EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", this, "_refresh_menu_icons");
- editor_selection->connect("selection_changed", this, "_refresh_menu_icons");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
+ EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect_compat("node_changed", this, "_refresh_menu_icons");
+ editor_selection->connect_compat("selection_changed", this, "_refresh_menu_icons");
- editor->connect("stop_pressed", this, "_update_camera_override_button", make_binds(false));
- editor->connect("play_pressed", this, "_update_camera_override_button", make_binds(true));
+ editor->connect_compat("stop_pressed", this, "_update_camera_override_button", make_binds(false));
+ editor->connect_compat("play_pressed", this, "_update_camera_override_button", make_binds(true));
} else if (p_what == NOTIFICATION_ENTER_TREE) {
_register_all_gizmos();
@@ -5402,7 +5513,7 @@ void SpatialEditor::_notification(int p_what) {
_init_grid();
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) {
- ScriptEditorDebugger *debugger = ScriptEditor::get_singleton()->get_debugger();
+ EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_NONE);
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_pressed(false);
@@ -5531,7 +5642,7 @@ void SpatialEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<CPUParticlesGizmoPlugin>(memnew(CPUParticlesGizmoPlugin)));
add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin)));
add_gizmo_plugin(Ref<GIProbeGizmoPlugin>(memnew(GIProbeGizmoPlugin)));
- add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin)));
+ // add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin)));
add_gizmo_plugin(Ref<CollisionShapeSpatialGizmoPlugin>(memnew(CollisionShapeSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<CollisionPolygonSpatialGizmoPlugin>(memnew(CollisionPolygonSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<NavigationMeshSpatialGizmoPlugin>(memnew(NavigationMeshSpatialGizmoPlugin)));
@@ -5621,7 +5732,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_SELECT]->set_flat(true);
tool_button[TOOL_MODE_SELECT]->set_pressed(true);
button_binds.write[0] = MENU_TOOL_SELECT;
- tool_button[TOOL_MODE_SELECT]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_MODE_SELECT]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_SELECT]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_select", TTR("Select Mode"), KEY_Q));
tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection"));
@@ -5632,7 +5743,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_MOVE]->set_toggle_mode(true);
tool_button[TOOL_MODE_MOVE]->set_flat(true);
button_binds.write[0] = MENU_TOOL_MOVE;
- tool_button[TOOL_MODE_MOVE]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_MODE_MOVE]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_MOVE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_move", TTR("Move Mode"), KEY_W));
tool_button[TOOL_MODE_ROTATE] = memnew(ToolButton);
@@ -5640,7 +5751,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_ROTATE]->set_toggle_mode(true);
tool_button[TOOL_MODE_ROTATE]->set_flat(true);
button_binds.write[0] = MENU_TOOL_ROTATE;
- tool_button[TOOL_MODE_ROTATE]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_MODE_ROTATE]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_ROTATE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_rotate", TTR("Rotate Mode"), KEY_E));
tool_button[TOOL_MODE_SCALE] = memnew(ToolButton);
@@ -5648,7 +5759,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_SCALE]->set_toggle_mode(true);
tool_button[TOOL_MODE_SCALE]->set_flat(true);
button_binds.write[0] = MENU_TOOL_SCALE;
- tool_button[TOOL_MODE_SCALE]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_MODE_SCALE]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_SCALE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_scale", TTR("Scale Mode"), KEY_R));
hbc_menu->add_child(memnew(VSeparator));
@@ -5658,31 +5769,31 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_LIST_SELECT]->set_toggle_mode(true);
tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true);
button_binds.write[0] = MENU_TOOL_LIST_SELECT;
- tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_MODE_LIST_SELECT]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode)."));
tool_button[TOOL_LOCK_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_LOCK_SELECTED]);
button_binds.write[0] = MENU_LOCK_SELECTED;
- tool_button[TOOL_LOCK_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_LOCK_SELECTED]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_LOCK_SELECTED]->set_tooltip(TTR("Lock the selected object in place (can't be moved)."));
tool_button[TOOL_UNLOCK_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_UNLOCK_SELECTED]);
button_binds.write[0] = MENU_UNLOCK_SELECTED;
- tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_UNLOCK_SELECTED]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_UNLOCK_SELECTED]->set_tooltip(TTR("Unlock the selected object (can be moved)."));
tool_button[TOOL_GROUP_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_GROUP_SELECTED]);
button_binds.write[0] = MENU_GROUP_SELECTED;
- tool_button[TOOL_GROUP_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_GROUP_SELECTED]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_GROUP_SELECTED]->set_tooltip(TTR("Makes sure the object's children are not selectable."));
tool_button[TOOL_UNGROUP_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_UNGROUP_SELECTED]);
button_binds.write[0] = MENU_UNGROUP_SELECTED;
- tool_button[TOOL_UNGROUP_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_UNGROUP_SELECTED]->connect_compat("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_UNGROUP_SELECTED]->set_tooltip(TTR("Restores the object's children's ability to be selected."));
hbc_menu->add_child(memnew(VSeparator));
@@ -5692,7 +5803,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_toggle_mode(true);
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_flat(true);
button_binds.write[0] = MENU_TOOL_LOCAL_COORDS;
- tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", this, "_menu_item_toggled", button_binds);
+ tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect_compat("toggled", this, "_menu_item_toggled", button_binds);
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Use Local Space"), KEY_T));
tool_option_button[TOOL_OPT_USE_SNAP] = memnew(ToolButton);
@@ -5700,7 +5811,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_option_button[TOOL_OPT_USE_SNAP]->set_toggle_mode(true);
tool_option_button[TOOL_OPT_USE_SNAP]->set_flat(true);
button_binds.write[0] = MENU_TOOL_USE_SNAP;
- tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", this, "_menu_item_toggled", button_binds);
+ tool_option_button[TOOL_OPT_USE_SNAP]->connect_compat("toggled", this, "_menu_item_toggled", button_binds);
tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut(ED_SHORTCUT("spatial_editor/snap", TTR("Use Snap"), KEY_Y));
hbc_menu->add_child(memnew(VSeparator));
@@ -5711,7 +5822,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_flat(true);
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_disabled(true);
button_binds.write[0] = MENU_TOOL_OVERRIDE_CAMERA;
- tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect("toggled", this, "_menu_item_toggled", button_binds);
+ tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect_compat("toggled", this, "_menu_item_toggled", button_binds);
_update_camera_override_button(false);
hbc_menu->add_child(memnew(VSeparator));
@@ -5748,7 +5859,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap...")), MENU_TRANSFORM_CONFIGURE_SNAP);
- p->connect("id_pressed", this, "_menu_item_pressed");
+ p->connect_compat("id_pressed", this, "_menu_item_pressed");
view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
@@ -5780,13 +5891,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p->set_item_checked(p->get_item_index(MENU_VIEW_ORIGIN), true);
p->set_item_checked(p->get_item_index(MENU_VIEW_GRID), true);
- p->connect("id_pressed", this, "_menu_item_pressed");
+ p->connect_compat("id_pressed", this, "_menu_item_pressed");
gizmos_menu = memnew(PopupMenu);
p->add_child(gizmos_menu);
gizmos_menu->set_name("GizmosMenu");
gizmos_menu->set_hide_on_checkable_item_selection(false);
- gizmos_menu->connect("id_pressed", this, "_menu_gizmo_toggled");
+ gizmos_menu->connect_compat("id_pressed", this, "_menu_gizmo_toggled");
/* REST OF MENU */
@@ -5803,8 +5914,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i] = memnew(SpatialEditorViewport(this, editor, i));
- viewports[i]->connect("toggle_maximize_view", this, "_toggle_maximize_view");
- viewports[i]->connect("clicked", this, "_update_camera_override_viewport");
+ viewports[i]->connect_compat("toggle_maximize_view", this, "_toggle_maximize_view");
+ viewports[i]->connect_compat("clicked", this, "_update_camera_override_viewport");
viewports[i]->assign_pending_data_pointers(preview_node, &preview_bounds, accept);
viewport_base->add_child(viewports[i]);
}
@@ -5919,7 +6030,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
xform_type->add_item(TTR("Post"));
xform_vbc->add_child(xform_type);
- xform_dialog->connect("confirmed", this, "_xform_dialog_action");
+ xform_dialog->connect_compat("confirmed", this, "_xform_dialog_action");
scenario_debug = VisualServer::SCENARIO_DEBUG_DISABLED;
@@ -5931,7 +6042,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
EDITOR_DEF("editors/3d/manipulator_gizmo_size", 80);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/3d/manipulator_gizmo_size", PROPERTY_HINT_RANGE, "16,1024,1"));
EDITOR_DEF("editors/3d/manipulator_gizmo_opacity", 0.4);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::REAL, "editors/3d/manipulator_gizmo_opacity", PROPERTY_HINT_RANGE, "0,1,0.01"));
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "editors/3d/manipulator_gizmo_opacity", PROPERTY_HINT_RANGE, "0,1,0.01"));
over_gizmo_handle = -1;
}
@@ -6073,7 +6184,7 @@ SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) {
editor->get_viewport()->add_child(spatial_editor);
spatial_editor->hide();
- spatial_editor->connect("transform_key_request", editor->get_inspector_dock(), "_transform_keyed");
+ spatial_editor->connect_compat("transform_key_request", editor->get_inspector_dock(), "_transform_keyed");
}
SpatialEditorPlugin::~SpatialEditorPlugin() {
@@ -6083,13 +6194,13 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
- Vector<Ref<SpatialMaterial> > mats;
+ Vector<Ref<StandardMaterial3D> > mats;
for (int i = 0; i < 4; i++) {
bool selected = i % 2 == 1;
bool instanced = i < 2;
- Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
Color color = instanced ? instanced_color : p_color;
@@ -6098,17 +6209,17 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color
}
material->set_albedo(color);
- material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 1);
+ material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 1);
if (p_use_vertex_color) {
- material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
}
if (p_billboard) {
- material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED);
}
if (p_on_top && selected) {
@@ -6121,17 +6232,17 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color
materials[p_name] = mats;
}
-void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top, const Color &p_albedo) {
+void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) {
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
- Vector<Ref<SpatialMaterial> > icons;
+ Vector<Ref<StandardMaterial3D> > icons;
for (int i = 0; i < 4; i++) {
bool selected = i % 2 == 1;
bool instanced = i < 2;
- Ref<SpatialMaterial> icon = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
Color color = instanced ? instanced_color : p_albedo;
@@ -6141,14 +6252,16 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const
icon->set_albedo(color);
- icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- icon->set_cull_mode(SpatialMaterial::CULL_DISABLED);
- icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED);
- icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, p_texture);
- icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true);
- icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
- icon->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN);
+ icon->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ icon->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ icon->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ icon->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
+ icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED);
+ icon->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ icon->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, p_texture);
+ icon->set_flag(StandardMaterial3D::FLAG_FIXED_SIZE, true);
+ icon->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED);
+ icon->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN);
if (p_on_top && selected) {
icon->set_on_top_of_alpha();
@@ -6161,46 +6274,46 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const
}
void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) {
- Ref<SpatialMaterial> handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
- handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
- Ref<Texture> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons");
+ handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
+ Ref<Texture2D> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons");
handle_material->set_point_size(handle_t->get_width());
- handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle_t);
+ handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t);
handle_material->set_albedo(Color(1, 1, 1));
- handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
handle_material->set_on_top_of_alpha();
if (p_billboard) {
- handle_material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ handle_material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED);
handle_material->set_on_top_of_alpha();
}
- materials[p_name] = Vector<Ref<SpatialMaterial> >();
+ materials[p_name] = Vector<Ref<StandardMaterial3D> >();
materials[p_name].push_back(handle_material);
}
-void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<SpatialMaterial> p_material) {
- materials[p_name] = Vector<Ref<SpatialMaterial> >();
+void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) {
+ materials[p_name] = Vector<Ref<StandardMaterial3D> >();
materials[p_name].push_back(p_material);
}
-Ref<SpatialMaterial> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) {
- ERR_FAIL_COND_V(!materials.has(p_name), Ref<SpatialMaterial>());
- ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<SpatialMaterial>());
+Ref<StandardMaterial3D> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) {
+ ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>());
+ ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>());
if (p_gizmo.is_null() || materials[p_name].size() == 1) return materials[p_name][0];
int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0);
- Ref<SpatialMaterial> mat = materials[p_name][index];
+ Ref<StandardMaterial3D> mat = materials[p_name][index];
if (current_state == ON_TOP && p_gizmo->is_selected()) {
- mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
+ mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
} else {
- mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, false);
+ mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false);
}
return mat;
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 65e3c32ca8..a4d6b13389 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,6 +41,7 @@
class Camera;
class SpatialEditor;
class EditorSpatialGizmoPlugin;
+class ViewportContainer;
class EditorSpatialGizmo : public SpatialGizmo {
@@ -101,11 +102,11 @@ protected:
static void _bind_methods();
public:
- void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false);
+ void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1));
void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>(), const Ref<Material> &p_material = Ref<Material>());
void add_collision_segments(const Vector<Vector3> &p_lines);
void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh);
- void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1);
+ void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1, const Color &p_modulate = Color(1, 1, 1));
void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard = false, bool p_secondary = false);
void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3());
@@ -166,8 +167,19 @@ class SpatialEditorViewport : public Control {
VIEW_DISPLAY_WIREFRAME,
VIEW_DISPLAY_OVERDRAW,
VIEW_DISPLAY_SHADELESS,
+ VIEW_DISPLAY_LIGHTING,
+ VIEW_DISPLAY_NORMAL_BUFFER,
+ VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO,
+ VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING,
+ VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION,
+ VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE,
+ VIEW_DISPLAY_DEBUG_SSAO,
+ VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER,
VIEW_LOCK_ROTATION,
- VIEW_CINEMATIC_PREVIEW
+ VIEW_CINEMATIC_PREVIEW,
+ VIEW_MAX
};
public:
@@ -204,6 +216,7 @@ private:
ViewportContainer *viewport_container;
MenuButton *view_menu;
+ PopupMenu *display_submenu;
Control *surface;
Viewport *viewport;
@@ -216,6 +229,7 @@ private:
bool freelook_active;
real_t freelook_speed;
+ TextureRect *crosshair;
Label *info_label;
Label *fps_label;
Label *cinema_label;
@@ -232,7 +246,7 @@ private:
void _update_name();
void _compute_edit(const Point2 &p_point);
void _clear_selected();
- void _select_clicked(bool p_append, bool p_single);
+ void _select_clicked(bool p_append, bool p_single, bool p_allow_locked = false);
void _select(Node *p_node, bool p_append, bool p_single);
ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false);
void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false);
@@ -525,10 +539,10 @@ private:
bool grid_enabled;
Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3], scale_plane_gizmo[3];
- Ref<SpatialMaterial> gizmo_color[3];
- Ref<SpatialMaterial> plane_gizmo_color[3];
- Ref<SpatialMaterial> gizmo_color_hl[3];
- Ref<SpatialMaterial> plane_gizmo_color_hl[3];
+ Ref<StandardMaterial3D> gizmo_color[3];
+ Ref<StandardMaterial3D> plane_gizmo_color[3];
+ Ref<StandardMaterial3D> gizmo_color_hl[3];
+ Ref<StandardMaterial3D> plane_gizmo_color_hl[3];
int over_gizmo_handle;
@@ -537,8 +551,8 @@ private:
RID indicators_instance;
RID cursor_mesh;
RID cursor_instance;
- Ref<SpatialMaterial> indicator_mat;
- Ref<SpatialMaterial> cursor_material;
+ Ref<StandardMaterial3D> indicator_mat;
+ Ref<StandardMaterial3D> cursor_material;
// Scene drag and drop support
Spatial *preview_node;
@@ -774,7 +788,7 @@ public:
private:
int current_state;
List<EditorSpatialGizmo *> current_gizmos;
- HashMap<String, Vector<Ref<SpatialMaterial> > > materials;
+ HashMap<String, Vector<Ref<StandardMaterial3D> > > materials;
protected:
static void _bind_methods();
@@ -783,11 +797,11 @@ protected:
public:
void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false);
- void create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1));
+ void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1));
void create_handle_material(const String &p_name, bool p_billboard = false);
- void add_material(const String &p_name, Ref<SpatialMaterial> p_material);
+ void add_material(const String &p_name, Ref<StandardMaterial3D> p_material);
- Ref<SpatialMaterial> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>());
+ Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>());
virtual String get_name() const;
virtual int get_priority() const;
diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp
index 40734cffc4..c35afa0644 100644
--- a/editor/plugins/sprite_editor_plugin.cpp
+++ b/editor/plugins/sprite_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,7 @@
#include "sprite_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "editor/editor_scale.h"
#include "scene/2d/collision_polygon_2d.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/mesh_instance_2d.h"
@@ -125,7 +126,7 @@ void SpriteEditor::_menu_option(int p_option) {
case MENU_OPTION_CONVERT_TO_MESH_2D: {
debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D"));
- debug_uv_dialog->set_title("Mesh2D Preview");
+ debug_uv_dialog->set_title(TTR("Mesh2D Preview"));
_update_mesh_data();
debug_uv_dialog->popup_centered();
@@ -135,7 +136,7 @@ void SpriteEditor::_menu_option(int p_option) {
case MENU_OPTION_CONVERT_TO_POLYGON_2D: {
debug_uv_dialog->get_ok()->set_text(TTR("Create Polygon2D"));
- debug_uv_dialog->set_title("Polygon2D Preview");
+ debug_uv_dialog->set_title(TTR("Polygon2D Preview"));
_update_mesh_data();
debug_uv_dialog->popup_centered();
@@ -144,7 +145,7 @@ void SpriteEditor::_menu_option(int p_option) {
case MENU_OPTION_CREATE_COLLISION_POLY_2D: {
debug_uv_dialog->get_ok()->set_text(TTR("Create CollisionPolygon2D"));
- debug_uv_dialog->set_title("CollisionPolygon2D Preview");
+ debug_uv_dialog->set_title(TTR("CollisionPolygon2D Preview"));
_update_mesh_data();
debug_uv_dialog->popup_centered();
@@ -154,7 +155,7 @@ void SpriteEditor::_menu_option(int p_option) {
case MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D: {
debug_uv_dialog->get_ok()->set_text(TTR("Create LightOccluder2D"));
- debug_uv_dialog->set_title("LightOccluder2D Preview");
+ debug_uv_dialog->set_title(TTR("LightOccluder2D Preview"));
_update_mesh_data();
debug_uv_dialog->popup_centered();
@@ -166,7 +167,7 @@ void SpriteEditor::_menu_option(int p_option) {
void SpriteEditor::_update_mesh_data() {
- Ref<Texture> texture = node->get_texture();
+ Ref<Texture2D> texture = node->get_texture();
if (texture.is_null()) {
err_dialog->set_text(TTR("Sprite is empty!"));
err_dialog->popup_centered_minsize();
@@ -329,7 +330,7 @@ void SpriteEditor::_convert_to_mesh_2d_node() {
a[Mesh::ARRAY_TEX_UV] = computed_uv;
a[Mesh::ARRAY_INDEX] = computed_indices;
- mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a, Array(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a, Array(), Dictionary(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
MeshInstance2D *mesh_instance = memnew(MeshInstance2D);
mesh_instance->set_mesh(mesh);
@@ -357,13 +358,13 @@ void SpriteEditor::_convert_to_polygon_2d_node() {
for (int i = 0; i < computed_outline_lines.size(); i++)
total_point_count += computed_outline_lines[i].size();
- PoolVector2Array polygon;
+ PackedVector2Array polygon;
polygon.resize(total_point_count);
- PoolVector2Array::Write polygon_write = polygon.write();
+ Vector2 *polygon_write = polygon.ptrw();
- PoolVector2Array uvs;
+ PackedVector2Array uvs;
uvs.resize(total_point_count);
- PoolVector2Array::Write uvs_write = uvs.write();
+ Vector2 *uvs_write = uvs.ptrw();
int current_point_index = 0;
@@ -375,9 +376,9 @@ void SpriteEditor::_convert_to_polygon_2d_node() {
Vector<Vector2> outline = computed_outline_lines[i];
Vector<Vector2> uv_outline = outline_lines[i];
- PoolIntArray pia;
+ PackedInt32Array pia;
pia.resize(outline.size());
- PoolIntArray::Write pia_write = pia.write();
+ int *pia_write = pia.ptrw();
for (int pi = 0; pi < outline.size(); pi++) {
polygon_write[current_point_index] = outline[pi];
@@ -441,9 +442,9 @@ void SpriteEditor::_create_light_occluder_2d_node() {
Ref<OccluderPolygon2D> polygon;
polygon.instance();
- PoolVector2Array a;
+ PackedVector2Array a;
a.resize(outline.size());
- PoolVector2Array::Write aw = a.write();
+ Vector2 *aw = a.ptrw();
for (int io = 0; io < outline.size(); io++) {
aw[io] = outline[io];
}
@@ -473,72 +474,9 @@ void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node)
p_new_node->set_owner(this->get_tree()->get_edited_scene_root());
}
-#if 0
-void SpriteEditor::_create_uv_lines() {
-
- Ref<Mesh> sprite = node->get_sprite();
- ERR_FAIL_COND(!sprite.is_valid());
-
- Set<SpriteEditorEdgeSort> edges;
- uv_lines.clear();
- for (int i = 0; i < sprite->get_surface_count(); i++) {
- if (sprite->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
- continue;
- Array a = sprite->surface_get_arrays(i);
-
- PoolVector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2];
- if (uv.size() == 0) {
- err_dialog->set_text(TTR("Model has no UV in this layer"));
- err_dialog->popup_centered_minsize();
- return;
- }
-
- PoolVector<Vector2>::Read r = uv.read();
-
- PoolVector<int> indices = a[Mesh::ARRAY_INDEX];
- PoolVector<int>::Read ri;
-
- int ic;
- bool use_indices;
-
- if (indices.size()) {
- ic = indices.size();
- ri = indices.read();
- use_indices = true;
- } else {
- ic = uv.size();
- use_indices = false;
- }
-
- for (int j = 0; j < ic; j += 3) {
-
- for (int k = 0; k < 3; k++) {
-
- SpriteEditorEdgeSort edge;
- if (use_indices) {
- edge.a = r[ri[j + k]];
- edge.b = r[ri[j + ((k + 1) % 3)]];
- } else {
- edge.a = r[j + k];
- edge.b = r[j + ((k + 1) % 3)];
- }
-
- if (edges.has(edge))
- continue;
-
- uv_lines.push_back(edge.a);
- uv_lines.push_back(edge.b);
- edges.insert(edge);
- }
- }
- }
-
- debug_uv_dialog->popup_centered_minsize();
-}
-#endif
void SpriteEditor::_debug_uv_draw() {
- Ref<Texture> tex = node->get_texture();
+ Ref<Texture2D> tex = node->get_texture();
ERR_FAIL_COND(!tex.is_valid());
Point2 draw_pos_offset = Point2(1.0, 1.0);
@@ -588,7 +526,7 @@ SpriteEditor::SpriteEditor() {
options->get_popup()->add_item(TTR("Create LightOccluder2D Sibling"), MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D);
options->set_switch_on_hover(true);
- options->get_popup()->connect("id_pressed", this, "_menu_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_menu_option");
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
@@ -604,9 +542,9 @@ SpriteEditor::SpriteEditor() {
scroll->set_enable_v_scroll(true);
vb->add_margin_child(TTR("Preview:"), scroll, true);
debug_uv = memnew(Control);
- debug_uv->connect("draw", this, "_debug_uv_draw");
+ debug_uv->connect_compat("draw", this, "_debug_uv_draw");
scroll->add_child(debug_uv);
- debug_uv_dialog->connect("confirmed", this, "_create_node");
+ debug_uv_dialog->connect_compat("confirmed", this, "_create_node");
HBoxContainer *hb = memnew(HBoxContainer);
hb->add_child(memnew(Label(TTR("Simplification: "))));
@@ -635,7 +573,7 @@ SpriteEditor::SpriteEditor() {
hb->add_spacer();
update_preview = memnew(Button);
update_preview->set_text(TTR("Update Preview"));
- update_preview->connect("pressed", this, "_update_mesh_data");
+ update_preview->connect_compat("pressed", this, "_update_mesh_data");
hb->add_child(update_preview);
vb->add_margin_child(TTR("Settings:"), hb);
diff --git a/editor/plugins/sprite_editor_plugin.h b/editor/plugins/sprite_editor_plugin.h
index 4ca7bca1a8..13177c9142 100644
--- a/editor/plugins/sprite_editor_plugin.h
+++ b/editor/plugins/sprite_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 394122d91d..c80ba873fb 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,8 +32,10 @@
#include "core/io/resource_loader.h"
#include "core/project_settings.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "scene/3d/sprite_3d.h"
+#include "scene/gui/center_container.h"
void SpriteFramesEditor::_gui_input(Ref<InputEvent> p_event) {
}
@@ -42,7 +44,7 @@ void SpriteFramesEditor::_open_sprite_sheet() {
file_split_sheet->clear_filters();
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
+ ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
for (int i = 0; i < extensions.size(); i++) {
file_split_sheet->add_filter("*." + extensions[i]);
}
@@ -202,7 +204,7 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
Ref<Resource> texture = ResourceLoader::load(p_file);
if (!texture.is_valid()) {
- EditorNode::get_singleton()->show_warning("Unable to load images");
+ EditorNode::get_singleton()->show_warning(TTR("Unable to load images"));
ERR_FAIL_COND(!texture.is_valid());
}
if (texture != split_sheet_preview->get_texture()) {
@@ -232,7 +234,7 @@ void SpriteFramesEditor::_notification(int p_what) {
_delete->set_icon(get_icon("Remove", "EditorIcons"));
new_anim->set_icon(get_icon("New", "EditorIcons"));
remove_anim->set_icon(get_icon("Remove", "EditorIcons"));
- FALLTHROUGH;
+ [[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
splite_sheet_scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
@@ -243,15 +245,15 @@ void SpriteFramesEditor::_notification(int p_what) {
}
}
-void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, int p_at_pos) {
+void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_at_pos) {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- List<Ref<Texture> > resources;
+ List<Ref<Texture2D> > resources;
for (int i = 0; i < p_path.size(); i++) {
- Ref<Texture> resource;
+ Ref<Texture2D> resource;
resource = ResourceLoader::load(p_path[i]);
if (resource.is_null()) {
@@ -276,7 +278,7 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, in
int count = 0;
- for (List<Ref<Texture> >::Element *E = resources.front(); E; E = E->next()) {
+ for (List<Ref<Texture2D> >::Element *E = resources.front(); E; E = E->next()) {
undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count);
undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos);
@@ -295,7 +297,7 @@ void SpriteFramesEditor::_load_pressed() {
file->clear_filters();
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
+ ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
for (int i = 0; i < extensions.size(); i++)
file->add_filter("*." + extensions[i]);
@@ -308,7 +310,7 @@ void SpriteFramesEditor::_paste_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- Ref<Texture> r = EditorSettings::get_singleton()->get_resource_clipboard();
+ Ref<Texture2D> r = EditorSettings::get_singleton()->get_resource_clipboard();
if (!r.is_valid()) {
dialog->set_text(TTR("Resource clipboard is empty or not a texture!"));
dialog->set_title(TTR("Error!"));
@@ -331,7 +333,7 @@ void SpriteFramesEditor::_copy_pressed() {
if (tree->get_current() < 0)
return;
- Ref<Texture> r = frames->get_frame(edited_anim, tree->get_current());
+ Ref<Texture2D> r = frames->get_frame(edited_anim, tree->get_current());
if (!r.is_valid()) {
return;
}
@@ -354,7 +356,7 @@ void SpriteFramesEditor::_empty_pressed() {
from = frames->get_frame_count(edited_anim);
}
- Ref<Texture> r;
+ Ref<Texture2D> r;
undo_redo->create_action(TTR("Add Empty"));
undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from);
@@ -379,7 +381,7 @@ void SpriteFramesEditor::_empty2_pressed() {
from = frames->get_frame_count(edited_anim);
}
- Ref<Texture> r;
+ Ref<Texture2D> r;
undo_redo->create_action(TTR("Add Empty"));
undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from + 1);
@@ -403,7 +405,6 @@ void SpriteFramesEditor::_up_pressed() {
sel = to_move;
sel -= 1;
- Ref<Texture> r = frames->get_frame(edited_anim, to_move);
undo_redo->create_action(TTR("Delete Resource"));
undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move - 1));
undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move - 1, frames->get_frame(edited_anim, to_move));
@@ -428,7 +429,6 @@ void SpriteFramesEditor::_down_pressed() {
sel = to_move;
sel += 1;
- Ref<Texture> r = frames->get_frame(edited_anim, to_move);
undo_redo->create_action(TTR("Delete Resource"));
undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move + 1));
undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move + 1, frames->get_frame(edited_anim, to_move));
@@ -603,7 +603,7 @@ void SpriteFramesEditor::_animation_remove_confirmed() {
undo_redo->add_undo_method(frames, "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim));
int fc = frames->get_frame_count(edited_anim);
for (int i = 0; i < fc; i++) {
- Ref<Texture> frame = frames->get_frame(edited_anim, i);
+ Ref<Texture2D> frame = frames->get_frame(edited_anim, i);
undo_redo->add_undo_method(frames, "add_frame", edited_anim, frame);
}
undo_redo->add_do_method(this, "_update_library");
@@ -688,7 +688,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
for (int i = 0; i < frames->get_frame_count(edited_anim); i++) {
String name;
- Ref<Texture> icon;
+ Ref<Texture2D> icon;
if (frames->get_frame(edited_anim, i).is_null()) {
@@ -757,7 +757,7 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
return Variant();
Dictionary drag_data = EditorNode::get_singleton()->drag_resource(frame, p_from);
- drag_data["frame"] = idx; // store the frame, incase we want to reorder frames inside 'drop_data_fw'
+ drag_data["frame"] = idx; // store the frame, in case we want to reorder frames inside 'drop_data_fw'
return drag_data;
}
@@ -775,7 +775,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
- Ref<Texture> texture = r;
+ Ref<Texture2D> texture = r;
if (texture.is_valid()) {
@@ -794,7 +794,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
String file = files[i];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
- if (!ClassDB::is_parent_class(ftype, "Texture")) {
+ if (!ClassDB::is_parent_class(ftype, "Texture2D")) {
return false;
}
}
@@ -819,7 +819,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
- Ref<Texture> texture = r;
+ Ref<Texture2D> texture = r;
if (texture.is_valid()) {
bool reorder = false;
@@ -852,7 +852,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (String(d["type"]) == "files") {
- PoolVector<String> files = d["files"];
+ Vector<String> files = d["files"];
_file_load_request(files, at_pos);
}
@@ -905,19 +905,19 @@ SpriteFramesEditor::SpriteFramesEditor() {
new_anim = memnew(ToolButton);
new_anim->set_tooltip(TTR("New Animation"));
hbc_animlist->add_child(new_anim);
- new_anim->connect("pressed", this, "_animation_add");
+ new_anim->connect_compat("pressed", this, "_animation_add");
remove_anim = memnew(ToolButton);
remove_anim->set_tooltip(TTR("Remove Animation"));
hbc_animlist->add_child(remove_anim);
- remove_anim->connect("pressed", this, "_animation_remove");
+ remove_anim->connect_compat("pressed", this, "_animation_remove");
animations = memnew(Tree);
sub_vb->add_child(animations);
animations->set_v_size_flags(SIZE_EXPAND_FILL);
animations->set_hide_root(true);
- animations->connect("cell_selected", this, "_animation_select");
- animations->connect("item_edited", this, "_animation_name_edited");
+ animations->connect_compat("cell_selected", this, "_animation_select");
+ animations->connect_compat("item_edited", this, "_animation_name_edited");
animations->set_allow_reselect(true);
anim_speed = memnew(SpinBox);
@@ -925,12 +925,12 @@ SpriteFramesEditor::SpriteFramesEditor() {
anim_speed->set_min(0);
anim_speed->set_max(100);
anim_speed->set_step(0.01);
- anim_speed->connect("value_changed", this, "_animation_fps_changed");
+ anim_speed->connect_compat("value_changed", this, "_animation_fps_changed");
anim_loop = memnew(CheckButton);
anim_loop->set_text(TTR("Loop"));
vbc_animlist->add_child(anim_loop);
- anim_loop->connect("pressed", this, "_animation_loop_changed");
+ anim_loop->connect_compat("pressed", this, "_animation_loop_changed");
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
@@ -1004,16 +1004,16 @@ SpriteFramesEditor::SpriteFramesEditor() {
dialog = memnew(AcceptDialog);
add_child(dialog);
- load->connect("pressed", this, "_load_pressed");
- load_sheet->connect("pressed", this, "_open_sprite_sheet");
- _delete->connect("pressed", this, "_delete_pressed");
- copy->connect("pressed", this, "_copy_pressed");
- paste->connect("pressed", this, "_paste_pressed");
- empty->connect("pressed", this, "_empty_pressed");
- empty2->connect("pressed", this, "_empty2_pressed");
- move_up->connect("pressed", this, "_up_pressed");
- move_down->connect("pressed", this, "_down_pressed");
- file->connect("files_selected", this, "_file_load_request");
+ load->connect_compat("pressed", this, "_load_pressed");
+ load_sheet->connect_compat("pressed", this, "_open_sprite_sheet");
+ _delete->connect_compat("pressed", this, "_delete_pressed");
+ copy->connect_compat("pressed", this, "_copy_pressed");
+ paste->connect_compat("pressed", this, "_paste_pressed");
+ empty->connect_compat("pressed", this, "_empty_pressed");
+ empty2->connect_compat("pressed", this, "_empty2_pressed");
+ move_up->connect_compat("pressed", this, "_up_pressed");
+ move_down->connect_compat("pressed", this, "_down_pressed");
+ file->connect_compat("files_selected", this, "_file_load_request");
loading_scene = false;
sel = -1;
@@ -1023,14 +1023,14 @@ SpriteFramesEditor::SpriteFramesEditor() {
delete_dialog = memnew(ConfirmationDialog);
add_child(delete_dialog);
- delete_dialog->connect("confirmed", this, "_animation_remove_confirmed");
+ delete_dialog->connect_compat("confirmed", this, "_animation_remove_confirmed");
split_sheet_dialog = memnew(ConfirmationDialog);
add_child(split_sheet_dialog);
VBoxContainer *split_sheet_vb = memnew(VBoxContainer);
split_sheet_dialog->add_child(split_sheet_vb);
split_sheet_dialog->set_title(TTR("Select Frames"));
- split_sheet_dialog->connect("confirmed", this, "_sheet_add_frames");
+ split_sheet_dialog->connect_compat("confirmed", this, "_sheet_add_frames");
HBoxContainer *split_sheet_hb = memnew(HBoxContainer);
@@ -1041,7 +1041,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_h->set_max(128);
split_sheet_h->set_step(1);
split_sheet_hb->add_child(split_sheet_h);
- split_sheet_h->connect("value_changed", this, "_sheet_spin_changed");
+ split_sheet_h->connect_compat("value_changed", this, "_sheet_spin_changed");
ss_label = memnew(Label(TTR("Vertical:")));
split_sheet_hb->add_child(ss_label);
@@ -1050,13 +1050,13 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_v->set_max(128);
split_sheet_v->set_step(1);
split_sheet_hb->add_child(split_sheet_v);
- split_sheet_v->connect("value_changed", this, "_sheet_spin_changed");
+ split_sheet_v->connect_compat("value_changed", this, "_sheet_spin_changed");
split_sheet_hb->add_spacer();
Button *select_clear_all = memnew(Button);
select_clear_all->set_text(TTR("Select/Clear All Frames"));
- select_clear_all->connect("pressed", this, "_sheet_select_clear_all_frames");
+ select_clear_all->connect_compat("pressed", this, "_sheet_select_clear_all_frames");
split_sheet_hb->add_child(select_clear_all);
split_sheet_vb->add_child(split_sheet_hb);
@@ -1064,8 +1064,8 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_preview = memnew(TextureRect);
split_sheet_preview->set_expand(false);
split_sheet_preview->set_mouse_filter(MOUSE_FILTER_PASS);
- split_sheet_preview->connect("draw", this, "_sheet_preview_draw");
- split_sheet_preview->connect("gui_input", this, "_sheet_preview_input");
+ split_sheet_preview->connect_compat("draw", this, "_sheet_preview_draw");
+ split_sheet_preview->connect_compat("gui_input", this, "_sheet_preview_input");
splite_sheet_scroll = memnew(ScrollContainer);
splite_sheet_scroll->set_enable_h_scroll(true);
@@ -1083,7 +1083,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
file_split_sheet->set_title(TTR("Create Frames from Sprite Sheet"));
file_split_sheet->set_mode(EditorFileDialog::MODE_OPEN_FILE);
add_child(file_split_sheet);
- file_split_sheet->connect("file_selected", this, "_prepare_sprite_sheet");
+ file_split_sheet->connect_compat("file_selected", this, "_prepare_sprite_sheet");
}
void SpriteFramesEditorPlugin::edit(Object *p_object) {
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index f20b54f910..1fa93b5c47 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -86,7 +86,7 @@ class SpriteFramesEditor : public HSplitContainer {
void _load_pressed();
void _load_scene_pressed();
- void _file_load_request(const PoolVector<String> &p_path, int p_at_pos = -1);
+ void _file_load_request(const Vector<String> &p_path, int p_at_pos = -1);
void _copy_pressed();
void _paste_pressed();
void _empty_pressed();
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index c4a9803ff4..a9936658c3 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,6 +30,8 @@
#include "style_box_editor_plugin.h"
+#include "editor/editor_scale.h"
+
bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) {
return Object::cast_to<StyleBox>(p_object) != NULL;
@@ -52,11 +54,11 @@ void EditorInspectorPluginStyleBox::parse_end() {
void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
if (stylebox.is_valid())
- stylebox->disconnect("changed", this, "_sb_changed");
+ stylebox->disconnect_compat("changed", this, "_sb_changed");
stylebox = p_stylebox;
if (p_stylebox.is_valid()) {
preview->add_style_override("panel", stylebox);
- stylebox->connect("changed", this, "_sb_changed");
+ stylebox->connect_compat("changed", this, "_sb_changed");
}
_sb_changed();
}
@@ -68,7 +70,14 @@ void StyleBoxPreview::_sb_changed() {
void StyleBoxPreview::_redraw() {
if (stylebox.is_valid()) {
- preview->draw_style_box(stylebox, preview->get_rect());
+ Rect2 preview_rect = preview->get_rect();
+
+ // Re-adjust preview panel to fit all drawn content
+ Rect2 draw_rect = stylebox->get_draw_rect(preview_rect);
+ preview_rect.size -= draw_rect.size - preview_rect.size;
+ preview_rect.position -= draw_rect.position - preview_rect.position;
+
+ preview->draw_style_box(stylebox, preview_rect);
}
}
@@ -81,7 +90,8 @@ void StyleBoxPreview::_bind_methods() {
StyleBoxPreview::StyleBoxPreview() {
preview = memnew(Control);
preview->set_custom_minimum_size(Size2(0, 150 * EDSCALE));
- preview->connect("draw", this, "_redraw");
+ preview->set_clip_contents(true);
+ preview->connect_compat("draw", this, "_redraw");
add_margin_child(TTR("Preview:"), preview);
}
diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h
index fead8e0de8..f4a72d9d1c 100644
--- a/editor/plugins/style_box_editor_plugin.h
+++ b/editor/plugins/style_box_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 0cef5a8b6f..a8b6d74c1f 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -163,7 +163,7 @@ String TextEditor::get_name() {
return name;
}
-Ref<Texture> TextEditor::get_icon() {
+Ref<Texture2D> TextEditor::get_icon() {
return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), "");
}
@@ -185,7 +185,7 @@ void TextEditor::set_edited_resource(const RES &p_res) {
code_editor->update_line_and_column();
}
-void TextEditor::add_callback(const String &p_function, PoolStringArray p_args) {
+void TextEditor::add_callback(const String &p_function, PackedStringArray p_args) {
}
void TextEditor::set_debugger_active(bool p_active) {
@@ -491,6 +491,12 @@ void TextEditor::_edit_option(int p_op) {
// So this will be delegated to the ScriptEditor.
emit_signal("search_in_files_requested", selected_text);
} break;
+ case REPLACE_IN_FILES: {
+
+ String selected_text = code_editor->get_text_edit()->get_selection_text();
+
+ emit_signal("replace_in_files_requested", selected_text);
+ } break;
case SEARCH_GOTO_LINE: {
goto_line_dialog->popup_find_line(tx);
@@ -627,19 +633,19 @@ TextEditor::TextEditor() {
code_editor = memnew(CodeTextEditor);
add_child(code_editor);
code_editor->add_constant_override("separation", 0);
- code_editor->connect("load_theme_settings", this, "_load_theme_settings");
- code_editor->connect("validate_script", this, "_validate_script");
+ code_editor->connect_compat("load_theme_settings", this, "_load_theme_settings");
+ code_editor->connect_compat("validate_script", this, "_validate_script");
code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
update_settings();
code_editor->get_text_edit()->set_context_menu_enabled(false);
- code_editor->get_text_edit()->connect("gui_input", this, "_text_edit_gui_input");
+ code_editor->get_text_edit()->connect_compat("gui_input", this, "_text_edit_gui_input");
context_menu = memnew(PopupMenu);
add_child(context_menu);
- context_menu->connect("id_pressed", this, "_edit_option");
+ context_menu->connect_compat("id_pressed", this, "_edit_option");
edit_hb = memnew(HBoxContainer);
@@ -647,7 +653,7 @@ TextEditor::TextEditor() {
edit_hb->add_child(search_menu);
search_menu->set_text(TTR("Search"));
search_menu->set_switch_on_hover(true);
- search_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+ search_menu->get_popup()->connect_compat("id_pressed", this, "_edit_option");
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT);
@@ -655,12 +661,13 @@ TextEditor::TextEditor() {
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE);
search_menu->get_popup()->add_separator();
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_in_files"), SEARCH_IN_FILES);
+ search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace_in_files"), REPLACE_IN_FILES);
edit_menu = memnew(MenuButton);
edit_hb->add_child(edit_menu);
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
- edit_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+ edit_menu->get_popup()->connect_compat("id_pressed", this, "_edit_option");
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
@@ -693,7 +700,7 @@ TextEditor::TextEditor() {
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase")), EDIT_TO_UPPERCASE);
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase")), EDIT_TO_LOWERCASE);
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE);
- convert_case->connect("id_pressed", this, "_edit_option");
+ convert_case->connect_compat("id_pressed", this, "_edit_option");
highlighters["Standard"] = NULL;
highlighter_menu = memnew(PopupMenu);
@@ -701,24 +708,24 @@ TextEditor::TextEditor() {
edit_menu->get_popup()->add_child(highlighter_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu");
highlighter_menu->add_radio_check_item(TTR("Standard"));
- highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter");
+ highlighter_menu->connect_compat("id_pressed", this, "_change_syntax_highlighter");
MenuButton *goto_menu = memnew(MenuButton);
edit_hb->add_child(goto_menu);
goto_menu->set_text(TTR("Go To"));
goto_menu->set_switch_on_hover(true);
- goto_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+ goto_menu->get_popup()->connect_compat("id_pressed", this, "_edit_option");
goto_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE);
goto_menu->get_popup()->add_separator();
bookmarks_menu = memnew(PopupMenu);
- bookmarks_menu->set_name(TTR("Bookmarks"));
+ bookmarks_menu->set_name("Bookmarks");
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
_update_bookmark_list();
- bookmarks_menu->connect("about_to_show", this, "_update_bookmark_list");
- bookmarks_menu->connect("index_pressed", this, "_bookmark_item_pressed");
+ bookmarks_menu->connect_compat("about_to_show", this, "_update_bookmark_list");
+ bookmarks_menu->connect_compat("index_pressed", this, "_bookmark_item_pressed");
goto_line_dialog = memnew(GotoLineDialog);
add_child(goto_line_dialog);
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index 7d441a187d..c80052e7ba 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -88,6 +88,7 @@ private:
SEARCH_FIND_PREV,
SEARCH_REPLACE,
SEARCH_IN_FILES,
+ REPLACE_IN_FILES,
SEARCH_GOTO_LINE,
BOOKMARK_TOGGLE,
BOOKMARK_GOTO_NEXT,
@@ -120,7 +121,7 @@ public:
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
virtual String get_name();
- virtual Ref<Texture> get_icon();
+ virtual Ref<Texture2D> get_icon();
virtual RES get_edited_resource() const;
virtual void set_edited_resource(const RES &p_res);
void set_edited_file(const Ref<TextFile> &p_file);
@@ -146,7 +147,7 @@ public:
virtual bool can_lose_focus_on_node_selection() { return true; }
virtual void set_debugger_active(bool p_active);
virtual void set_tooltip_request_func(String p_method, Object *p_obj);
- virtual void add_callback(const String &p_function, PoolStringArray p_args);
+ virtual void add_callback(const String &p_function, PackedStringArray p_args);
virtual Control *get_edit_menu();
virtual void clear_edit_menu();
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 6d71c56ead..60f9bb5dc1 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -46,7 +46,7 @@ void TextureEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
+ Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
@@ -110,7 +110,7 @@ void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) {
update();
}
-void TextureEditor::edit(Ref<Texture> p_texture) {
+void TextureEditor::edit(Ref<Texture2D> p_texture) {
if (!texture.is_null())
texture->remove_change_receptor(this);
@@ -132,6 +132,7 @@ void TextureEditor::_bind_methods() {
TextureEditor::TextureEditor() {
+ set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
set_custom_minimum_size(Size2(1, 150));
}
@@ -148,11 +149,11 @@ bool EditorInspectorPluginTexture::can_handle(Object *p_object) {
void EditorInspectorPluginTexture::parse_begin(Object *p_object) {
- Texture *texture = Object::cast_to<Texture>(p_object);
+ Texture2D *texture = Object::cast_to<Texture2D>(p_object);
if (!texture) {
return;
}
- Ref<Texture> m(texture);
+ Ref<Texture2D> m(texture);
TextureEditor *editor = memnew(TextureEditor);
editor->edit(m);
diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h
index ed25783303..29ad0183dc 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@ class TextureEditor : public Control {
GDCLASS(TextureEditor, Control);
- Ref<Texture> texture;
+ Ref<Texture2D> texture;
protected:
void _notification(int p_what);
@@ -48,7 +48,7 @@ protected:
static void _bind_methods();
public:
- void edit(Ref<Texture> p_texture);
+ void edit(Ref<Texture2D> p_texture);
TextureEditor();
~TextureEditor();
};
@@ -66,7 +66,7 @@ class TextureEditorPlugin : public EditorPlugin {
GDCLASS(TextureEditorPlugin, EditorPlugin);
public:
- virtual String get_name() const { return "Texture"; }
+ virtual String get_name() const { return "Texture2D"; }
TextureEditorPlugin(EditorNode *p_node);
};
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index bda3d142fa..065833fd2b 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,7 @@
#include "core/core_string_names.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
#include "scene/gui/check_box.h"
/**
@@ -48,7 +49,7 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) {
}
void TextureRegionEditor::_region_draw() {
- Ref<Texture> base_tex = NULL;
+ Ref<Texture2D> base_tex = NULL;
if (node_sprite)
base_tex = node_sprite->get_texture();
else if (node_sprite_3d)
@@ -133,15 +134,21 @@ void TextureRegionEditor::_region_draw() {
}
}
- Ref<Texture> select_handle = get_icon("EditorHandle", "EditorIcons");
+ Ref<Texture2D> select_handle = get_icon("EditorHandle", "EditorIcons");
- Rect2 scroll_rect;
+ Rect2 scroll_rect(Point2(), base_tex->get_size());
- Vector2 endpoints[4] = {
- mtx.basis_xform(rect.position),
- mtx.basis_xform(rect.position + Vector2(rect.size.x, 0)),
- mtx.basis_xform(rect.position + rect.size),
- mtx.basis_xform(rect.position + Vector2(0, rect.size.y))
+ const Vector2 raw_endpoints[4] = {
+ rect.position,
+ rect.position + Vector2(rect.size.x, 0),
+ rect.position + rect.size,
+ rect.position + Vector2(0, rect.size.y)
+ };
+ const Vector2 endpoints[4] = {
+ mtx.basis_xform(raw_endpoints[0]),
+ mtx.basis_xform(raw_endpoints[1]),
+ mtx.basis_xform(raw_endpoints[2]),
+ mtx.basis_xform(raw_endpoints[3])
};
Color color = get_color("mono_color", "Editor");
for (int i = 0; i < 4; i++) {
@@ -150,7 +157,7 @@ void TextureRegionEditor::_region_draw() {
int next = (i + 1) % 4;
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
- ofs *= 1.4144 * (select_handle->get_size().width / 2);
+ ofs *= Math_SQRT2 * (select_handle->get_size().width / 2);
edit_draw->draw_line(endpoints[i] - draw_ofs * draw_zoom, endpoints[next] - draw_ofs * draw_zoom, color, 2);
@@ -163,33 +170,43 @@ void TextureRegionEditor::_region_draw() {
if (snap_mode != SNAP_AUTOSLICE)
edit_draw->draw_texture(select_handle, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor() - draw_ofs * draw_zoom);
- scroll_rect.expand_to(endpoints[i]);
+ scroll_rect.expand_to(raw_endpoints[i]);
}
- scroll_rect.position -= edit_draw->get_size();
- scroll_rect.size += edit_draw->get_size() * 2.0;
+ const Size2 scroll_margin = edit_draw->get_size() / draw_zoom;
+ scroll_rect.position -= scroll_margin;
+ scroll_rect.size += scroll_margin * 2;
updating_scroll = true;
+
hscroll->set_min(scroll_rect.position.x);
hscroll->set_max(scroll_rect.position.x + scroll_rect.size.x);
- if (ABS(scroll_rect.position.x - (scroll_rect.position.x + scroll_rect.size.x)) <= edit_draw->get_size().x) {
+ if (ABS(scroll_rect.position.x - (scroll_rect.position.x + scroll_rect.size.x)) <= scroll_margin.x) {
hscroll->hide();
} else {
hscroll->show();
- hscroll->set_page(edit_draw->get_size().x);
+ hscroll->set_page(scroll_margin.x);
hscroll->set_value(draw_ofs.x);
}
vscroll->set_min(scroll_rect.position.y);
vscroll->set_max(scroll_rect.position.y + scroll_rect.size.y);
- if (ABS(scroll_rect.position.y - (scroll_rect.position.y + scroll_rect.size.y)) <= edit_draw->get_size().y) {
+ if (ABS(scroll_rect.position.y - (scroll_rect.position.y + scroll_rect.size.y)) <= scroll_margin.y) {
vscroll->hide();
draw_ofs.y = scroll_rect.position.y;
} else {
vscroll->show();
- vscroll->set_page(edit_draw->get_size().y);
+ vscroll->set_page(scroll_margin.y);
vscroll->set_value(draw_ofs.y);
}
+
+ Size2 hmin = hscroll->get_combined_minimum_size();
+ Size2 vmin = vscroll->get_combined_minimum_size();
+
+ // Avoid scrollbar overlapping.
+ hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, vscroll->is_visible() ? -vmin.width : 0);
+ vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, hscroll->is_visible() ? -hmin.height : 0);
+
updating_scroll = false;
if (node_ninepatch || obj_styleBox.is_valid()) {
@@ -225,15 +242,19 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
mtx.elements[2] = -draw_ofs * draw_zoom;
mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
- Vector2 endpoints[8] = {
- mtx.xform(rect.position) + Vector2(-4, -4),
- mtx.xform(rect.position + Vector2(rect.size.x / 2, 0)) + Vector2(0, -4),
- mtx.xform(rect.position + Vector2(rect.size.x, 0)) + Vector2(4, -4),
- mtx.xform(rect.position + Vector2(rect.size.x, rect.size.y / 2)) + Vector2(4, 0),
- mtx.xform(rect.position + rect.size) + Vector2(4, 4),
- mtx.xform(rect.position + Vector2(rect.size.x / 2, rect.size.y)) + Vector2(0, 4),
- mtx.xform(rect.position + Vector2(0, rect.size.y)) + Vector2(-4, 4),
- mtx.xform(rect.position + Vector2(0, rect.size.y / 2)) + Vector2(-4, 0)
+ const real_t handle_radius = 8 * EDSCALE;
+ const real_t handle_offset = 4 * EDSCALE;
+
+ // Position of selection handles.
+ const Vector2 endpoints[8] = {
+ mtx.xform(rect.position) + Vector2(-handle_offset, -handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x / 2, 0)) + Vector2(0, -handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x, 0)) + Vector2(handle_offset, -handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x, rect.size.y / 2)) + Vector2(handle_offset, 0),
+ mtx.xform(rect.position + rect.size) + Vector2(handle_offset, handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x / 2, rect.size.y)) + Vector2(0, handle_offset),
+ mtx.xform(rect.position + Vector2(0, rect.size.y)) + Vector2(-handle_offset, handle_offset),
+ mtx.xform(rect.position + Vector2(0, rect.size.y / 2)) + Vector2(-handle_offset, 0)
};
Ref<InputEventMouseButton> mb = p_input;
@@ -346,7 +367,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
for (int i = 0; i < 8; i++) {
Vector2 tuv = endpoints[i];
- if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < 8) {
+ if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < handle_radius) {
drag_index = i;
}
}
@@ -430,9 +451,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
- Vector2 draged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom);
- hscroll->set_value(hscroll->get_value() - draged.x);
- vscroll->set_value(vscroll->get_value() - draged.y);
+ Vector2 dragged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom);
+ hscroll->set_value(hscroll->get_value() - dragged.x);
+ vscroll->set_value(vscroll->get_value() - dragged.y);
} else if (drag) {
@@ -525,6 +546,17 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
edit_draw->update();
}
}
+
+ Ref<InputEventMagnifyGesture> magnify_gesture = p_input;
+ if (magnify_gesture.is_valid()) {
+ _zoom_on_position(draw_zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
+ }
+
+ Ref<InputEventPanGesture> pan_gesture = p_input;
+ if (pan_gesture.is_valid()) {
+ hscroll->set_value(hscroll->get_value() + hscroll->get_page() * pan_gesture->get_delta().x / 8);
+ vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y / 8);
+ }
}
void TextureRegionEditor::_scroll_changed(float) {
@@ -640,7 +672,7 @@ void TextureRegionEditor::_update_autoslice() {
autoslice_is_dirty = false;
autoslice_cache.clear();
- Ref<Texture> texture = NULL;
+ Ref<Texture2D> texture = NULL;
if (node_sprite)
texture = node_sprite->get_texture();
else if (node_sprite_3d)
@@ -715,6 +747,9 @@ void TextureRegionEditor::_notification(int p_what) {
zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons"));
zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons"));
zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons"));
+
+ vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
+ hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) {
@@ -828,7 +863,7 @@ void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_pro
}
void TextureRegionEditor::_edit_region() {
- Ref<Texture> texture = NULL;
+ Ref<Texture2D> texture = NULL;
if (node_sprite)
texture = node_sprite->get_texture();
else if (node_sprite_3d)
@@ -900,7 +935,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
snap_mode_button->add_item(TTR("Grid Snap"), 2);
snap_mode_button->add_item(TTR("Auto Slice"), 3);
snap_mode_button->select(0);
- snap_mode_button->connect("item_selected", this, "_set_snap_mode");
+ snap_mode_button->connect_compat("item_selected", this, "_set_snap_mode");
hb_grid = memnew(HBoxContainer);
hb_tools->add_child(hb_grid);
@@ -914,7 +949,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
sb_off_x->set_step(1);
sb_off_x->set_value(snap_offset.x);
sb_off_x->set_suffix("px");
- sb_off_x->connect("value_changed", this, "_set_snap_off_x");
+ sb_off_x->connect_compat("value_changed", this, "_set_snap_off_x");
hb_grid->add_child(sb_off_x);
sb_off_y = memnew(SpinBox);
@@ -923,7 +958,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
sb_off_y->set_step(1);
sb_off_y->set_value(snap_offset.y);
sb_off_y->set_suffix("px");
- sb_off_y->connect("value_changed", this, "_set_snap_off_y");
+ sb_off_y->connect_compat("value_changed", this, "_set_snap_off_y");
hb_grid->add_child(sb_off_y);
hb_grid->add_child(memnew(VSeparator));
@@ -935,7 +970,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
sb_step_x->set_step(1);
sb_step_x->set_value(snap_step.x);
sb_step_x->set_suffix("px");
- sb_step_x->connect("value_changed", this, "_set_snap_step_x");
+ sb_step_x->connect_compat("value_changed", this, "_set_snap_step_x");
hb_grid->add_child(sb_step_x);
sb_step_y = memnew(SpinBox);
@@ -944,7 +979,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
sb_step_y->set_step(1);
sb_step_y->set_value(snap_step.y);
sb_step_y->set_suffix("px");
- sb_step_y->connect("value_changed", this, "_set_snap_step_y");
+ sb_step_y->connect_compat("value_changed", this, "_set_snap_step_y");
hb_grid->add_child(sb_step_y);
hb_grid->add_child(memnew(VSeparator));
@@ -956,7 +991,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
sb_sep_x->set_step(1);
sb_sep_x->set_value(snap_separation.x);
sb_sep_x->set_suffix("px");
- sb_sep_x->connect("value_changed", this, "_set_snap_sep_x");
+ sb_sep_x->connect_compat("value_changed", this, "_set_snap_sep_x");
hb_grid->add_child(sb_sep_x);
sb_sep_y = memnew(SpinBox);
@@ -965,7 +1000,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
sb_sep_y->set_step(1);
sb_sep_y->set_value(snap_separation.y);
sb_sep_y->set_suffix("px");
- sb_sep_y->connect("value_changed", this, "_set_snap_sep_y");
+ sb_sep_y->connect_compat("value_changed", this, "_set_snap_sep_y");
hb_grid->add_child(sb_sep_y);
hb_grid->hide();
@@ -973,8 +1008,8 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
edit_draw = memnew(Panel);
add_child(edit_draw);
edit_draw->set_v_size_flags(SIZE_EXPAND_FILL);
- edit_draw->connect("draw", this, "_region_draw");
- edit_draw->connect("gui_input", this, "_region_input");
+ edit_draw->connect_compat("draw", this, "_region_draw");
+ edit_draw->connect_compat("gui_input", this, "_region_input");
draw_zoom = 1.0;
edit_draw->set_clip_contents(true);
@@ -985,30 +1020,27 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
zoom_out = memnew(ToolButton);
zoom_out->set_tooltip(TTR("Zoom Out"));
- zoom_out->connect("pressed", this, "_zoom_out");
+ zoom_out->connect_compat("pressed", this, "_zoom_out");
zoom_hb->add_child(zoom_out);
zoom_reset = memnew(ToolButton);
- zoom_out->set_tooltip(TTR("Zoom Reset"));
- zoom_reset->connect("pressed", this, "_zoom_reset");
+ zoom_reset->set_tooltip(TTR("Zoom Reset"));
+ zoom_reset->connect_compat("pressed", this, "_zoom_reset");
zoom_hb->add_child(zoom_reset);
zoom_in = memnew(ToolButton);
- zoom_out->set_tooltip(TTR("Zoom In"));
- zoom_in->connect("pressed", this, "_zoom_in");
+ zoom_in->set_tooltip(TTR("Zoom In"));
+ zoom_in->connect_compat("pressed", this, "_zoom_in");
zoom_hb->add_child(zoom_in);
vscroll = memnew(VScrollBar);
vscroll->set_step(0.001);
edit_draw->add_child(vscroll);
- vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
- vscroll->connect("value_changed", this, "_scroll_changed");
+ vscroll->connect_compat("value_changed", this, "_scroll_changed");
hscroll = memnew(HScrollBar);
hscroll->set_step(0.001);
edit_draw->add_child(hscroll);
- hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
- hscroll->set_margin(MARGIN_RIGHT, -vscroll->get_size().x * EDSCALE);
- hscroll->connect("value_changed", this, "_scroll_changed");
+ hscroll->connect_compat("value_changed", this, "_scroll_changed");
updating_scroll = false;
}
@@ -1093,7 +1125,7 @@ TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node) {
region_editor = memnew(TextureRegionEditor(p_node));
region_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
region_editor->hide();
- region_editor->connect("visibility_changed", this, "_editor_visiblity_changed");
+ region_editor->connect_compat("visibility_changed", this, "_editor_visiblity_changed");
texture_region_button = p_node->add_bottom_panel_item(TTR("TextureRegion"), region_editor);
texture_region_button->hide();
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index 4eb84ae176..d877cf9436 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index d501a04016..717c9adad3 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,8 @@
#include "core/os/file_access.h"
#include "core/version.h"
+#include "editor/editor_scale.h"
+#include "scene/gui/progress_bar.h"
void ThemeEditor::edit(const Ref<Theme> &p_theme) {
@@ -120,7 +122,7 @@ struct _TECategory {
Set<RefItem<StyleBox> > stylebox_items;
Set<RefItem<Font> > font_items;
- Set<RefItem<Texture> > icon_items;
+ Set<RefItem<Texture2D> > icon_items;
Set<Item<Color> > color_items;
Set<Item<int> > constant_items;
@@ -165,7 +167,7 @@ void ThemeEditor::_save_template_cbk(String fname) {
List<StringName> icon_list;
Theme::get_default()->get_icon_list(E->key(), &icon_list);
for (List<StringName>::Element *F = icon_list.front(); F; F = F->next()) {
- _TECategory::RefItem<Texture> it;
+ _TECategory::RefItem<Texture2D> it;
it.name = F->get();
it.item = Theme::get_default()->get_icon(F->get(), E->key());
tc.icon_items.insert(it);
@@ -289,7 +291,7 @@ void ThemeEditor::_save_template_cbk(String fname) {
if (tc.icon_items.size())
file->store_line("\n; Icon Items:\n");
- for (Set<_TECategory::RefItem<Texture> >::Element *F = tc.icon_items.front(); F; F = F->next()) {
+ for (Set<_TECategory::RefItem<Texture2D> >::Element *F = tc.icon_items.front(); F; F = F->next()) {
file->store_line(E->key() + "." + F->get().name + " = default");
}
@@ -322,7 +324,7 @@ void ThemeEditor::_dialog_cbk() {
switch (type_select->get_selected()) {
- case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture>()); break;
+ case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture2D>()); break;
case 1: theme->set_stylebox(name_edit->get_text(), type_edit->get_text(), Ref<StyleBox>()); break;
case 2: theme->set_font(name_edit->get_text(), type_edit->get_text(), Ref<Font>()); break;
case 3: theme->set_color(name_edit->get_text(), type_edit->get_text(), Color()); break;
@@ -339,7 +341,7 @@ void ThemeEditor::_dialog_cbk() {
names.clear();
Theme::get_default()->get_icon_list(fromtype, &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- theme->set_icon(E->get(), fromtype, Ref<Texture>());
+ theme->set_icon(E->get(), fromtype, Ref<Texture2D>());
}
}
{
@@ -452,7 +454,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
base_theme->get_icon_list(type, &icons);
for (List<StringName>::Element *E = icons.front(); E; E = E->next()) {
- theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture>());
+ theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture2D>());
}
List<StringName> shaders;
@@ -627,7 +629,7 @@ ThemeEditor::ThemeEditor() {
theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY);
theme_menu->get_popup()->add_item(TTR("Create From Current Editor Theme"), POPUP_IMPORT_EDITOR_THEME);
top_menu->add_child(theme_menu);
- theme_menu->get_popup()->connect("id_pressed", this, "_theme_menu_cbk");
+ theme_menu->get_popup()->connect_compat("id_pressed", this, "_theme_menu_cbk");
ScrollContainer *scroll = memnew(ScrollContainer);
add_child(scroll);
@@ -833,7 +835,7 @@ ThemeEditor::ThemeEditor() {
type_menu->set_text("..");
type_hbc->add_child(type_menu);
- type_menu->get_popup()->connect("id_pressed", this, "_type_menu_cbk");
+ type_menu->get_popup()->connect_compat("id_pressed", this, "_type_menu_cbk");
l = memnew(Label);
l->set_text(TTR("Name:"));
@@ -851,8 +853,8 @@ ThemeEditor::ThemeEditor() {
name_menu->set_text("..");
name_hbc->add_child(name_menu);
- name_menu->get_popup()->connect("about_to_show", this, "_name_menu_about_to_show");
- name_menu->get_popup()->connect("id_pressed", this, "_name_menu_cbk");
+ name_menu->get_popup()->connect_compat("about_to_show", this, "_name_menu_about_to_show");
+ name_menu->get_popup()->connect_compat("id_pressed", this, "_name_menu_cbk");
type_select_label = memnew(Label);
type_select_label->set_text(TTR("Data Type:"));
@@ -867,12 +869,12 @@ ThemeEditor::ThemeEditor() {
dialog_vbc->add_child(type_select);
- add_del_dialog->get_ok()->connect("pressed", this, "_dialog_cbk");
+ add_del_dialog->get_ok()->connect_compat("pressed", this, "_dialog_cbk");
file_dialog = memnew(EditorFileDialog);
- file_dialog->add_filter("*.theme ; Theme File");
+ file_dialog->add_filter("*.theme ; " + TTR("Theme File"));
add_child(file_dialog);
- file_dialog->connect("file_selected", this, "_save_template_cbk");
+ file_dialog->connect_compat("file_selected", this, "_save_template_cbk");
}
void ThemeEditorPlugin::edit(Object *p_node) {
@@ -908,7 +910,7 @@ ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) {
editor = p_node;
theme_editor = memnew(ThemeEditor);
- theme_editor->set_custom_minimum_size(Size2(0, 200));
+ theme_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("Theme"), theme_editor);
button->hide();
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index 6ffee46569..c51583593d 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 385ba4cfda..10d00b2a1d 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -52,16 +52,10 @@ void TileMapEditor::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- bool new_show_tile_info = EditorSettings::get_singleton()->get("editors/tile_map/show_tile_info_on_hover");
- if (new_show_tile_info != show_tile_info) {
- show_tile_info = new_show_tile_info;
- tile_info->set_visible(show_tile_info);
- }
-
if (is_visible_in_tree()) {
_update_palette();
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case NOTIFICATION_ENTER_TREE: {
@@ -474,7 +468,7 @@ void TileMapEditor::_update_palette() {
palette->add_item(String());
}
- Ref<Texture> tex = tileset->tile_get_texture(entries[i].id);
+ Ref<Texture2D> tex = tileset->tile_get_texture(entries[i].id);
if (tex.is_valid()) {
Rect2 region = tileset->tile_get_region(entries[i].id);
@@ -534,7 +528,7 @@ void TileMapEditor::_update_palette() {
};
entries2.sort_custom<SwapComparator>();
- Ref<Texture> tex = tileset->tile_get_texture(sel_tile);
+ Ref<Texture2D> tex = tileset->tile_get_texture(sel_tile);
for (int i = 0; i < entries2.size(); i++) {
@@ -604,7 +598,7 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) {
CanvasItemEditor::get_singleton()->update_viewport();
}
-PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) {
+Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) {
int prev_id = node->get_cell(p_start.x, p_start.y);
Vector<int> ids;
@@ -613,14 +607,14 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
ids = get_selected_tiles();
if (ids.size() == 0 || ids[0] == TileMap::INVALID_CELL)
- return PoolVector<Vector2>();
+ return Vector<Vector2>();
} else if (prev_id == TileMap::INVALID_CELL) {
- return PoolVector<Vector2>();
+ return Vector<Vector2>();
}
if (ids.size() == 1 && ids[0] == prev_id) {
// Same ID, nothing to change
- return PoolVector<Vector2>();
+ return Vector<Vector2>();
}
Rect2i r = node->get_used_rect();
@@ -633,26 +627,27 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
if (r != bucket_cache_rect)
_clear_bucket_cache();
// Cache grid is not initialized
- if (bucket_cache_visited == 0) {
+ if (bucket_cache_visited == NULL) {
bucket_cache_visited = new bool[area];
invalidate_cache = true;
}
// Tile ID changed or position wasn't visited by the previous fill
- int loc = (p_start.x - r.position.x) + (p_start.y - r.position.y) * r.get_size().x;
- if (prev_id != bucket_cache_tile || !bucket_cache_visited[loc]) {
+ const int loc = (p_start.x - r.position.x) + (p_start.y - r.position.y) * r.get_size().x;
+ const bool in_range = 0 <= loc && loc < area;
+ if (prev_id != bucket_cache_tile || (in_range && !bucket_cache_visited[loc])) {
invalidate_cache = true;
}
if (invalidate_cache) {
for (int i = 0; i < area; ++i)
bucket_cache_visited[i] = false;
- bucket_cache = PoolVector<Vector2>();
+ bucket_cache = Vector<Vector2>();
bucket_cache_tile = prev_id;
bucket_cache_rect = r;
bucket_queue.clear();
}
}
- PoolVector<Vector2> points;
+ Vector<Vector2> points;
Vector<Vector2> non_preview_cache;
int count = 0;
int limit = 0;
@@ -703,10 +698,10 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
return preview ? bucket_cache : points;
}
-void TileMapEditor::_fill_points(const PoolVector<Vector2> &p_points, const Dictionary &p_op) {
+void TileMapEditor::_fill_points(const Vector<Vector2> &p_points, const Dictionary &p_op) {
int len = p_points.size();
- PoolVector<Vector2>::Read pr = p_points.read();
+ const Vector2 *pr = p_points.ptr();
Vector<int> ids = p_op["id"];
bool xf = p_op["flip_h"];
@@ -721,10 +716,10 @@ void TileMapEditor::_fill_points(const PoolVector<Vector2> &p_points, const Dict
node->update_dirty_bitmask();
}
-void TileMapEditor::_erase_points(const PoolVector<Vector2> &p_points) {
+void TileMapEditor::_erase_points(const Vector<Vector2> &p_points) {
int len = p_points.size();
- PoolVector<Vector2>::Read pr = p_points.read();
+ const Vector2 *pr = p_points.ptr();
for (int i = 0; i < len; i++) {
@@ -766,7 +761,7 @@ void TileMapEditor::_erase_selection() {
void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) {
- Ref<Texture> t = node->get_tileset()->tile_get_texture(p_cell);
+ Ref<Texture2D> t = node->get_tileset()->tile_get_texture(p_cell);
if (t.is_null())
return;
@@ -887,8 +882,8 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) {
- PoolVector<Vector2> points = _bucket_fill(p_point, false, true);
- PoolVector<Vector2>::Read pr = points.read();
+ Vector<Vector2> points = _bucket_fill(p_point, false, true);
+ const Vector2 *pr = points.ptr();
int len = points.size();
for (int i = 0; i < len; ++i) {
@@ -899,7 +894,7 @@ void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Po
void TileMapEditor::_clear_bucket_cache() {
if (bucket_cache_visited) {
delete[] bucket_cache_visited;
- bucket_cache_visited = 0;
+ bucket_cache_visited = NULL;
}
}
@@ -1114,7 +1109,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else if (tool == TOOL_BUCKET) {
- PoolVector<Vector2> points = _bucket_fill(over_tile);
+ Vector<Vector2> points = _bucket_fill(over_tile);
if (points.size() == 0)
return false;
@@ -1221,7 +1216,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
pop["flip_v"] = node->is_cell_y_flipped(over_tile.x, over_tile.y);
pop["transpose"] = node->is_cell_transposed(over_tile.x, over_tile.y);
- PoolVector<Vector2> points = _bucket_fill(over_tile, true);
+ Vector<Vector2> points = _bucket_fill(over_tile, true);
if (points.size() == 0)
return false;
@@ -1250,14 +1245,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
}
- if (show_tile_info) {
- int tile_under = node->get_cell(over_tile.x, over_tile.y);
- String tile_name = "none";
+ int tile_under = node->get_cell(over_tile.x, over_tile.y);
+ String tile_name = "none";
- if (node->get_tileset()->has_tile(tile_under))
- tile_name = node->get_tileset()->tile_get_name(tile_under);
- tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]");
- }
+ if (node->get_tileset()->has_tile(tile_under))
+ tile_name = node->get_tileset()->tile_get_name(tile_under);
+ tile_info->show();
+ tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]");
if (tool == TOOL_PAINTING) {
@@ -1767,30 +1761,30 @@ void TileMapEditor::edit(Node *p_tile_map) {
}
if (node)
- node->disconnect("settings_changed", this, "_tileset_settings_changed");
+ node->disconnect_compat("settings_changed", this, "_tileset_settings_changed");
if (p_tile_map) {
node = Object::cast_to<TileMap>(p_tile_map);
- if (!canvas_item_editor_viewport->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
- canvas_item_editor_viewport->connect("mouse_entered", this, "_canvas_mouse_enter");
- if (!canvas_item_editor_viewport->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
- canvas_item_editor_viewport->connect("mouse_exited", this, "_canvas_mouse_exit");
+ if (!canvas_item_editor_viewport->is_connected_compat("mouse_entered", this, "_canvas_mouse_enter"))
+ canvas_item_editor_viewport->connect_compat("mouse_entered", this, "_canvas_mouse_enter");
+ if (!canvas_item_editor_viewport->is_connected_compat("mouse_exited", this, "_canvas_mouse_exit"))
+ canvas_item_editor_viewport->connect_compat("mouse_exited", this, "_canvas_mouse_exit");
_update_palette();
} else {
node = NULL;
- if (canvas_item_editor_viewport->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
- canvas_item_editor_viewport->disconnect("mouse_entered", this, "_canvas_mouse_enter");
- if (canvas_item_editor_viewport->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
- canvas_item_editor_viewport->disconnect("mouse_exited", this, "_canvas_mouse_exit");
+ if (canvas_item_editor_viewport->is_connected_compat("mouse_entered", this, "_canvas_mouse_enter"))
+ canvas_item_editor_viewport->disconnect_compat("mouse_entered", this, "_canvas_mouse_enter");
+ if (canvas_item_editor_viewport->is_connected_compat("mouse_exited", this, "_canvas_mouse_exit"))
+ canvas_item_editor_viewport->disconnect_compat("mouse_exited", this, "_canvas_mouse_exit");
_update_palette();
}
if (node)
- node->connect("settings_changed", this, "_tileset_settings_changed");
+ node->connect_compat("settings_changed", this, "_tileset_settings_changed");
_clear_bucket_cache();
}
@@ -1925,14 +1919,13 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
tool = TOOL_NONE;
selection_active = false;
mouse_over = false;
- show_tile_info = true;
flip_h = false;
flip_v = false;
transpose = false;
bucket_cache_tile = -1;
- bucket_cache_visited = 0;
+ bucket_cache_visited = NULL;
invalid_cell.resize(1);
invalid_cell.write[0] = TileMap::INVALID_CELL;
@@ -1946,20 +1939,20 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
manual_button = memnew(CheckBox);
manual_button->set_text(TTR("Disable Autotile"));
- manual_button->connect("toggled", this, "_manual_toggled");
+ manual_button->connect_compat("toggled", this, "_manual_toggled");
add_child(manual_button);
priority_button = memnew(CheckBox);
priority_button->set_text(TTR("Enable Priority"));
- priority_button->connect("toggled", this, "_priority_toggled");
+ priority_button->connect_compat("toggled", this, "_priority_toggled");
add_child(priority_button);
search_box = memnew(LineEdit);
search_box->set_placeholder(TTR("Filter tiles"));
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
- search_box->connect("text_entered", this, "_text_entered");
- search_box->connect("text_changed", this, "_text_changed");
- search_box->connect("gui_input", this, "_sbox_input");
+ search_box->connect_compat("text_entered", this, "_text_entered");
+ search_box->connect_compat("text_changed", this, "_text_changed");
+ search_box->connect_compat("gui_input", this, "_sbox_input");
add_child(search_box);
size_slider = memnew(HSlider);
@@ -1968,7 +1961,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
size_slider->set_max(4.0f);
size_slider->set_step(0.1f);
size_slider->set_value(1.0f);
- size_slider->connect("value_changed", this, "_icon_size_changed");
+ size_slider->connect_compat("value_changed", this, "_icon_size_changed");
add_child(size_slider);
int mw = EDITOR_DEF("editors/tile_map/palette_min_width", 80);
@@ -1987,8 +1980,8 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
palette->set_max_text_lines(2);
palette->set_select_mode(ItemList::SELECT_MULTI);
palette->add_constant_override("vseparation", 8 * EDSCALE);
- palette->connect("item_selected", this, "_palette_selected");
- palette->connect("multi_selected", this, "_palette_multi_selected");
+ palette->connect_compat("item_selected", this, "_palette_selected");
+ palette->connect_compat("multi_selected", this, "_palette_multi_selected");
palette_container->add_child(palette);
// Add message for when no texture is selected.
@@ -2022,25 +2015,25 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
paint_button = memnew(ToolButton);
paint_button->set_shortcut(ED_SHORTCUT("tile_map_editor/paint_tile", TTR("Paint Tile"), KEY_P));
paint_button->set_tooltip(TTR("Shift+LMB: Line Draw\nShift+Ctrl+LMB: Rectangle Paint"));
- paint_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_NONE));
+ paint_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_NONE));
paint_button->set_toggle_mode(true);
toolbar->add_child(paint_button);
bucket_fill_button = memnew(ToolButton);
bucket_fill_button->set_shortcut(ED_SHORTCUT("tile_map_editor/bucket_fill", TTR("Bucket Fill"), KEY_G));
- bucket_fill_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_BUCKET));
+ bucket_fill_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_BUCKET));
bucket_fill_button->set_toggle_mode(true);
toolbar->add_child(bucket_fill_button);
picker_button = memnew(ToolButton);
- picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_CONTROL));
- picker_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_PICKING));
+ picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_I));
+ picker_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_PICKING));
picker_button->set_toggle_mode(true);
toolbar->add_child(picker_button);
select_button = memnew(ToolButton);
- select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD + KEY_B));
- select_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_SELECTING));
+ select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_M));
+ select_button->connect_compat("pressed", this, "_button_tool_select", make_binds(TOOL_SELECTING));
select_button->set_toggle_mode(true);
toolbar->add_child(select_button);
@@ -2055,7 +2048,12 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
// Tile position.
tile_info = memnew(Label);
- toolbar_right->add_child(tile_info);
+ tile_info->set_modulate(Color(1, 1, 1, 0.8));
+ tile_info->set_mouse_filter(MOUSE_FILTER_IGNORE);
+ tile_info->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("main", "EditorFonts"));
+ // The tile info is only displayed after a tile has been hovered.
+ tile_info->hide();
+ CanvasItemEditor::get_singleton()->add_control_to_info_overlay(tile_info);
// Menu.
options = memnew(MenuButton);
@@ -2070,40 +2068,40 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
p->add_shortcut(ED_GET_SHORTCUT("tile_map_editor/erase_selection"), OPTION_ERASE_SELECTION);
p->add_separator();
p->add_item(TTR("Fix Invalid Tiles"), OPTION_FIX_INVALID);
- p->connect("id_pressed", this, "_menu_option");
+ p->connect_compat("id_pressed", this, "_menu_option");
rotate_left_button = memnew(ToolButton);
rotate_left_button->set_tooltip(TTR("Rotate Left"));
rotate_left_button->set_focus_mode(FOCUS_NONE);
- rotate_left_button->connect("pressed", this, "_rotate", varray(-1));
+ rotate_left_button->connect_compat("pressed", this, "_rotate", varray(-1));
rotate_left_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rotate_left", TTR("Rotate Left"), KEY_A));
tool_hb->add_child(rotate_left_button);
rotate_right_button = memnew(ToolButton);
rotate_right_button->set_tooltip(TTR("Rotate Right"));
rotate_right_button->set_focus_mode(FOCUS_NONE);
- rotate_right_button->connect("pressed", this, "_rotate", varray(1));
+ rotate_right_button->connect_compat("pressed", this, "_rotate", varray(1));
rotate_right_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rotate_right", TTR("Rotate Right"), KEY_S));
tool_hb->add_child(rotate_right_button);
flip_horizontal_button = memnew(ToolButton);
flip_horizontal_button->set_tooltip(TTR("Flip Horizontally"));
flip_horizontal_button->set_focus_mode(FOCUS_NONE);
- flip_horizontal_button->connect("pressed", this, "_flip_horizontal");
+ flip_horizontal_button->connect_compat("pressed", this, "_flip_horizontal");
flip_horizontal_button->set_shortcut(ED_SHORTCUT("tile_map_editor/flip_horizontal", TTR("Flip Horizontally"), KEY_X));
tool_hb->add_child(flip_horizontal_button);
flip_vertical_button = memnew(ToolButton);
flip_vertical_button->set_tooltip(TTR("Flip Vertically"));
flip_vertical_button->set_focus_mode(FOCUS_NONE);
- flip_vertical_button->connect("pressed", this, "_flip_vertical");
+ flip_vertical_button->connect_compat("pressed", this, "_flip_vertical");
flip_vertical_button->set_shortcut(ED_SHORTCUT("tile_map_editor/flip_vertical", TTR("Flip Vertically"), KEY_Z));
tool_hb->add_child(flip_vertical_button);
clear_transform_button = memnew(ToolButton);
clear_transform_button->set_tooltip(TTR("Clear Transform"));
clear_transform_button->set_focus_mode(FOCUS_NONE);
- clear_transform_button->connect("pressed", this, "_clear_transform");
+ clear_transform_button->connect_compat("pressed", this, "_clear_transform");
clear_transform_button->set_shortcut(ED_SHORTCUT("tile_map_editor/clear_transform", TTR("Clear Transform"), KEY_W));
tool_hb->add_child(clear_transform_button);
@@ -2151,6 +2149,10 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
tile_map_editor->show();
tile_map_editor->get_toolbar()->show();
tile_map_editor->get_toolbar_right()->show();
+ // `tile_info` isn't shown here, as it's displayed after a tile has been hovered.
+ // Otherwise, a translucent black rectangle would be visible as there would be an
+ // empty Label in the CanvasItemEditor's info overlay.
+
// Change to TOOL_SELECT when TileMap node is selected, to prevent accidental movement.
CanvasItemEditor::get_singleton()->set_current_tool(CanvasItemEditor::TOOL_SELECT);
} else {
@@ -2158,6 +2160,7 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
tile_map_editor->hide();
tile_map_editor->get_toolbar()->hide();
tile_map_editor->get_toolbar_right()->hide();
+ tile_map_editor->get_tile_info()->hide();
tile_map_editor->edit(NULL);
}
}
@@ -2170,7 +2173,6 @@ TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("editors/tile_map/show_tile_ids", false);
EDITOR_DEF("editors/tile_map/sort_tiles_by_name", true);
EDITOR_DEF("editors/tile_map/bucket_fill_preview", true);
- EDITOR_DEF("editors/tile_map/show_tile_info_on_hover", true);
EDITOR_DEF("editors/tile_map/editor_side", 1);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/tile_map/editor_side", PROPERTY_HINT_ENUM, "Left,Right"));
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index e3d678c2fd..74969d3e64 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -109,7 +109,6 @@ class TileMapEditor : public VBoxContainer {
bool selection_active;
bool mouse_over;
- bool show_tile_info;
bool flip_h;
bool flip_v;
@@ -124,7 +123,7 @@ class TileMapEditor : public VBoxContainer {
bool *bucket_cache_visited;
Rect2i bucket_cache_rect;
int bucket_cache_tile;
- PoolVector<Vector2> bucket_cache;
+ Vector<Vector2> bucket_cache;
List<Point2i> bucket_queue;
struct CellOp {
@@ -165,10 +164,10 @@ class TileMapEditor : public VBoxContainer {
void _pick_tile(const Point2 &p_pos);
- PoolVector<Vector2> _bucket_fill(const Point2i &p_start, bool erase = false, bool preview = false);
+ Vector<Vector2> _bucket_fill(const Point2i &p_start, bool erase = false, bool preview = false);
- void _fill_points(const PoolVector<Vector2> &p_points, const Dictionary &p_op);
- void _erase_points(const PoolVector<Vector2> &p_points);
+ void _fill_points(const Vector<Vector2> &p_points, const Dictionary &p_op);
+ void _erase_points(const Vector<Vector2> &p_points);
void _select(const Point2i &p_from, const Point2i &p_to);
void _erase_selection();
@@ -218,6 +217,7 @@ protected:
public:
HBoxContainer *get_toolbar() const { return toolbar; }
HBoxContainer *get_toolbar_right() const { return toolbar_right; }
+ Label *get_tile_info() const { return tile_info; }
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index a8cf5b46e1..a61b291029 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
+#include "editor/editor_scale.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/2d/sprite.h"
@@ -61,8 +62,8 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
}
Sprite *mi = Object::cast_to<Sprite>(child);
- Ref<Texture> texture = mi->get_texture();
- Ref<Texture> normal_map = mi->get_normal_map();
+ Ref<Texture2D> texture = mi->get_texture();
+ Ref<Texture2D> normal_map = mi->get_normal_map();
Ref<ShaderMaterial> material = mi->get_material();
if (texture.is_null())
@@ -194,7 +195,7 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
- Ref<Texture> texture = r;
+ Ref<Texture2D> texture = r;
if (texture.is_valid()) {
@@ -236,7 +237,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
- Ref<Texture> texture = r;
+ Ref<Texture2D> texture = r;
if (texture.is_valid())
add_texture(texture);
@@ -250,7 +251,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C
if (String(d["type"]) == "files") {
- PoolVector<String> files = d["files"];
+ Vector<String> files = d["files"];
_on_textures_added(files);
}
@@ -357,19 +358,19 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
left_container->add_child(texture_list);
texture_list->set_v_size_flags(SIZE_EXPAND_FILL);
texture_list->set_custom_minimum_size(Size2(200, 0));
- texture_list->connect("item_selected", this, "_on_texture_list_selected");
+ texture_list->connect_compat("item_selected", this, "_on_texture_list_selected");
texture_list->set_drag_forwarding(this);
HBoxContainer *tileset_toolbar_container = memnew(HBoxContainer);
left_container->add_child(tileset_toolbar_container);
tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE] = memnew(ToolButton);
- tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->connect("pressed", this, "_on_tileset_toolbar_button_pressed", varray(TOOL_TILESET_ADD_TEXTURE));
+ tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->connect_compat("pressed", this, "_on_tileset_toolbar_button_pressed", varray(TOOL_TILESET_ADD_TEXTURE));
tileset_toolbar_container->add_child(tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]);
tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->set_tooltip(TTR("Add Texture(s) to TileSet."));
tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE] = memnew(ToolButton);
- tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->connect("pressed", this, "_on_tileset_toolbar_button_pressed", varray(TOOL_TILESET_REMOVE_TEXTURE));
+ tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->connect_compat("pressed", this, "_on_tileset_toolbar_button_pressed", varray(TOOL_TILESET_REMOVE_TEXTURE));
tileset_toolbar_container->add_child(tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]);
tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->set_tooltip(TTR("Remove selected Texture from TileSet."));
@@ -382,7 +383,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tileset_toolbar_tools->get_popup()->add_item(TTR("Create from Scene"), TOOL_TILESET_CREATE_SCENE);
tileset_toolbar_tools->get_popup()->add_item(TTR("Merge from Scene"), TOOL_TILESET_MERGE_SCENE);
- tileset_toolbar_tools->get_popup()->connect("id_pressed", this, "_on_tileset_toolbar_button_pressed");
+ tileset_toolbar_tools->get_popup()->connect_compat("id_pressed", this, "_on_tileset_toolbar_button_pressed");
tileset_toolbar_container->add_child(tileset_toolbar_tools);
//---------------
@@ -404,13 +405,18 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
HBoxContainer *tool_hb = memnew(HBoxContainer);
Ref<ButtonGroup> g(memnew(ButtonGroup));
- String workspace_label[WORKSPACE_MODE_MAX] = { "Edit", "New Single Tile", "New Autotile", "New Atlas" };
+ String workspace_label[WORKSPACE_MODE_MAX] = {
+ TTR("Edit"),
+ TTR("New Single Tile"),
+ TTR("New Autotile"),
+ TTR("New Atlas")
+ };
for (int i = 0; i < (int)WORKSPACE_MODE_MAX; i++) {
tool_workspacemode[i] = memnew(Button);
- tool_workspacemode[i]->set_text(TTR(workspace_label[i]));
+ tool_workspacemode[i]->set_text(workspace_label[i]);
tool_workspacemode[i]->set_toggle_mode(true);
tool_workspacemode[i]->set_button_group(g);
- tool_workspacemode[i]->connect("pressed", this, "_on_workspace_mode_changed", varray(i));
+ tool_workspacemode[i]->connect_compat("pressed", this, "_on_workspace_mode_changed", varray(i));
tool_hb->add_child(tool_workspacemode[i]);
}
@@ -423,14 +429,14 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_hb->add_child(tools[SELECT_NEXT]);
tool_hb->move_child(tools[SELECT_NEXT], WORKSPACE_CREATE_SINGLE);
tools[SELECT_NEXT]->set_shortcut(ED_SHORTCUT("tileset_editor/next_shape", TTR("Next Coordinate"), KEY_PAGEDOWN));
- tools[SELECT_NEXT]->connect("pressed", this, "_on_tool_clicked", varray(SELECT_NEXT));
+ tools[SELECT_NEXT]->connect_compat("pressed", this, "_on_tool_clicked", varray(SELECT_NEXT));
tools[SELECT_NEXT]->set_tooltip(TTR("Select the next shape, subtile, or Tile."));
tools[SELECT_PREVIOUS] = memnew(ToolButton);
tool_hb->add_child(tools[SELECT_PREVIOUS]);
tool_hb->move_child(tools[SELECT_PREVIOUS], WORKSPACE_CREATE_SINGLE);
tools[SELECT_PREVIOUS]->set_shortcut(ED_SHORTCUT("tileset_editor/previous_shape", TTR("Previous Coordinate"), KEY_PAGEUP));
tools[SELECT_PREVIOUS]->set_tooltip(TTR("Select the previous shape, subtile, or Tile."));
- tools[SELECT_PREVIOUS]->connect("pressed", this, "_on_tool_clicked", varray(SELECT_PREVIOUS));
+ tools[SELECT_PREVIOUS]->connect_compat("pressed", this, "_on_tool_clicked", varray(SELECT_PREVIOUS));
VSeparator *separator_shape_selection = memnew(VSeparator);
tool_hb->add_child(separator_shape_selection);
@@ -445,13 +451,22 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_hb = memnew(HBoxContainer);
g = Ref<ButtonGroup>(memnew(ButtonGroup));
- String label[EDITMODE_MAX] = { "Region", "Collision", "Occlusion", "Navigation", "Bitmask", "Priority", "Icon", "Z Index" };
+ String label[EDITMODE_MAX] = {
+ TTR("Region"),
+ TTR("Collision"),
+ TTR("Occlusion"),
+ TTR("Navigation"),
+ TTR("Bitmask"),
+ TTR("Priority"),
+ TTR("Icon"),
+ TTR("Z Index")
+ };
for (int i = 0; i < (int)EDITMODE_MAX; i++) {
tool_editmode[i] = memnew(Button);
tool_editmode[i]->set_text(label[i]);
tool_editmode[i]->set_toggle_mode(true);
tool_editmode[i]->set_button_group(g);
- tool_editmode[i]->connect("pressed", this, "_on_edit_mode_changed", varray(i));
+ tool_editmode[i]->connect_compat("pressed", this, "_on_edit_mode_changed", varray(i));
tool_hb->add_child(tool_editmode[i]);
}
tool_editmode[EDITMODE_COLLISION]->set_pressed(true);
@@ -478,21 +493,21 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tools[TOOL_SELECT]->set_toggle_mode(true);
tools[TOOL_SELECT]->set_button_group(tg);
tools[TOOL_SELECT]->set_pressed(true);
- tools[TOOL_SELECT]->connect("pressed", this, "_on_tool_clicked", varray(TOOL_SELECT));
+ tools[TOOL_SELECT]->connect_compat("pressed", this, "_on_tool_clicked", varray(TOOL_SELECT));
separator_bitmask = memnew(VSeparator);
toolbar->add_child(separator_bitmask);
tools[BITMASK_COPY] = memnew(ToolButton);
tools[BITMASK_COPY]->set_tooltip(TTR("Copy bitmask."));
- tools[BITMASK_COPY]->connect("pressed", this, "_on_tool_clicked", varray(BITMASK_COPY));
+ tools[BITMASK_COPY]->connect_compat("pressed", this, "_on_tool_clicked", varray(BITMASK_COPY));
toolbar->add_child(tools[BITMASK_COPY]);
tools[BITMASK_PASTE] = memnew(ToolButton);
tools[BITMASK_PASTE]->set_tooltip(TTR("Paste bitmask."));
- tools[BITMASK_PASTE]->connect("pressed", this, "_on_tool_clicked", varray(BITMASK_PASTE));
+ tools[BITMASK_PASTE]->connect_compat("pressed", this, "_on_tool_clicked", varray(BITMASK_PASTE));
toolbar->add_child(tools[BITMASK_PASTE]);
tools[BITMASK_CLEAR] = memnew(ToolButton);
tools[BITMASK_CLEAR]->set_tooltip(TTR("Erase bitmask."));
- tools[BITMASK_CLEAR]->connect("pressed", this, "_on_tool_clicked", varray(BITMASK_CLEAR));
+ tools[BITMASK_CLEAR]->connect_compat("pressed", this, "_on_tool_clicked", varray(BITMASK_CLEAR));
toolbar->add_child(tools[BITMASK_CLEAR]);
tools[SHAPE_NEW_RECTANGLE] = memnew(ToolButton);
@@ -510,13 +525,13 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
separator_shape_toggle = memnew(VSeparator);
toolbar->add_child(separator_shape_toggle);
tools[SHAPE_TOGGLE_TYPE] = memnew(ToolButton);
- tools[SHAPE_TOGGLE_TYPE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_TOGGLE_TYPE));
+ tools[SHAPE_TOGGLE_TYPE]->connect_compat("pressed", this, "_on_tool_clicked", varray(SHAPE_TOGGLE_TYPE));
toolbar->add_child(tools[SHAPE_TOGGLE_TYPE]);
separator_delete = memnew(VSeparator);
toolbar->add_child(separator_delete);
tools[SHAPE_DELETE] = memnew(ToolButton);
- tools[SHAPE_DELETE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_DELETE));
+ tools[SHAPE_DELETE]->connect_compat("pressed", this, "_on_tool_clicked", varray(SHAPE_DELETE));
toolbar->add_child(tools[SHAPE_DELETE]);
spin_priority = memnew(SpinBox);
@@ -524,7 +539,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
spin_priority->set_max(255);
spin_priority->set_step(1);
spin_priority->set_custom_minimum_size(Size2(100, 0));
- spin_priority->connect("value_changed", this, "_on_priority_changed");
+ spin_priority->connect_compat("value_changed", this, "_on_priority_changed");
spin_priority->hide();
toolbar->add_child(spin_priority);
@@ -533,7 +548,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
spin_z_index->set_max(VS::CANVAS_ITEM_Z_MAX);
spin_z_index->set_step(1);
spin_z_index->set_custom_minimum_size(Size2(100, 0));
- spin_z_index->connect("value_changed", this, "_on_z_index_changed");
+ spin_z_index->connect_compat("value_changed", this, "_on_z_index_changed");
spin_z_index->hide();
toolbar->add_child(spin_z_index);
@@ -547,7 +562,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tools[TOOL_GRID_SNAP] = memnew(ToolButton);
tools[TOOL_GRID_SNAP]->set_toggle_mode(true);
tools[TOOL_GRID_SNAP]->set_tooltip(TTR("Enable snap and show grid (configurable via the Inspector)."));
- tools[TOOL_GRID_SNAP]->connect("toggled", this, "_on_grid_snap_toggled");
+ tools[TOOL_GRID_SNAP]->connect_compat("toggled", this, "_on_grid_snap_toggled");
toolbar->add_child(tools[TOOL_GRID_SNAP]);
Control *separator = memnew(Control);
@@ -555,15 +570,15 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
toolbar->add_child(separator);
tools[ZOOM_OUT] = memnew(ToolButton);
- tools[ZOOM_OUT]->connect("pressed", this, "_zoom_out");
+ tools[ZOOM_OUT]->connect_compat("pressed", this, "_zoom_out");
toolbar->add_child(tools[ZOOM_OUT]);
tools[ZOOM_OUT]->set_tooltip(TTR("Zoom Out"));
tools[ZOOM_1] = memnew(ToolButton);
- tools[ZOOM_1]->connect("pressed", this, "_zoom_reset");
+ tools[ZOOM_1]->connect_compat("pressed", this, "_zoom_reset");
toolbar->add_child(tools[ZOOM_1]);
tools[ZOOM_1]->set_tooltip(TTR("Zoom Reset"));
tools[ZOOM_IN] = memnew(ToolButton);
- tools[ZOOM_IN]->connect("pressed", this, "_zoom_in");
+ tools[ZOOM_IN]->connect_compat("pressed", this, "_zoom_in");
toolbar->add_child(tools[ZOOM_IN]);
tools[ZOOM_IN]->set_tooltip(TTR("Zoom In"));
@@ -592,13 +607,13 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
scroll->add_child(workspace_container);
workspace_overlay = memnew(Control);
- workspace_overlay->connect("draw", this, "_on_workspace_overlay_draw");
+ workspace_overlay->connect_compat("draw", this, "_on_workspace_overlay_draw");
workspace_container->add_child(workspace_overlay);
workspace = memnew(Control);
workspace->set_focus_mode(FOCUS_ALL);
- workspace->connect("draw", this, "_on_workspace_draw");
- workspace->connect("gui_input", this, "_on_workspace_input");
+ workspace->connect_compat("draw", this, "_on_workspace_draw");
+ workspace->connect_compat("gui_input", this, "_on_workspace_input");
workspace->set_draw_behind_parent(true);
workspace_overlay->add_child(workspace);
@@ -611,7 +626,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
//---------------
cd = memnew(ConfirmationDialog);
add_child(cd);
- cd->connect("confirmed", this, "_on_tileset_toolbar_confirm");
+ cd->connect_compat("confirmed", this, "_on_tileset_toolbar_confirm");
//---------------
err_dialog = memnew(AcceptDialog);
@@ -624,21 +639,21 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
texture_dialog->clear_filters();
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
+ ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
texture_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
add_child(texture_dialog);
- texture_dialog->connect("files_selected", this, "_on_textures_added");
+ texture_dialog->connect_compat("files_selected", this, "_on_textures_added");
//---------------
helper = memnew(TilesetEditorContext(this));
tile_names_visible = false;
// Config scale.
- max_scale = 10.0f;
- min_scale = 0.1f;
+ max_scale = 16.0f;
+ min_scale = 0.01f;
scale_ratio = 1.2f;
}
@@ -735,10 +750,10 @@ void TileSetEditor::_on_texture_list_selected(int p_index) {
workspace->update();
}
-void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) {
+void TileSetEditor::_on_textures_added(const PackedStringArray &p_paths) {
int invalid_count = 0;
for (int i = 0; i < p_paths.size(); i++) {
- Ref<Texture> t = Ref<Texture>(ResourceLoader::load(p_paths[i]));
+ Ref<Texture2D> t = Ref<Texture2D>(ResourceLoader::load(p_paths[i]));
ERR_CONTINUE_MSG(!t.is_valid(), "'" + p_paths[i] + "' is not a valid texture.");
@@ -1168,7 +1183,7 @@ void TileSetEditor::_on_workspace_overlay_draw() {
if (t_id < 0)
return;
- Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
+ Ref<Texture2D> handle = get_icon("EditorHandle", "EditorIcons");
if (draw_handles) {
for (int i = 0; i < current_shape.size(); i++) {
workspace_overlay->draw_texture(handle, current_shape[i] * workspace->get_scale().x - handle->get_size() * 0.5);
@@ -1176,6 +1191,31 @@ void TileSetEditor::_on_workspace_overlay_draw() {
}
}
+int TileSetEditor::get_grabbed_point(const Vector2 &p_mouse_pos, real_t p_grab_threshold) {
+ Transform2D xform = workspace->get_transform();
+
+ int grabbed_point = -1;
+ real_t min_distance = 1e10;
+
+ for (int i = 0; i < current_shape.size(); i++) {
+ const real_t distance = xform.xform(current_shape[i]).distance_to(xform.xform(p_mouse_pos));
+ if (distance < p_grab_threshold && distance < min_distance) {
+ min_distance = distance;
+ grabbed_point = i;
+ }
+ }
+
+ return grabbed_point;
+}
+
+bool TileSetEditor::is_within_grabbing_distance_of_first_point(const Vector2 &p_pos, real_t p_grab_threshold) {
+ Transform2D xform = workspace->get_transform();
+
+ const real_t distance = xform.xform(current_shape[0]).distance_to(xform.xform(p_pos));
+
+ return distance < p_grab_threshold;
+}
+
void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if (tileset.is_null() || !get_current_texture().is_valid())
@@ -1263,12 +1303,14 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
Size2 tile_workspace_size = edited_region.position + edited_region.size + WORKSPACE_MARGIN * 2;
Size2 workspace_minsize = workspace->get_custom_minimum_size();
- if (tile_workspace_size.x > workspace_minsize.x && tile_workspace_size.y > workspace_minsize.y) {
- undo_redo->add_do_method(workspace, "set_custom_minimum_size", tile_workspace_size);
+ // If the new region is bigger, just directly change the workspace size to avoid checking all other tiles.
+ if (tile_workspace_size.x > workspace_minsize.x || tile_workspace_size.y > workspace_minsize.y) {
+ Size2 max_workspace_size = Size2(MAX(tile_workspace_size.x, workspace_minsize.x), MAX(tile_workspace_size.y, workspace_minsize.y));
+ undo_redo->add_do_method(workspace, "set_custom_minimum_size", max_workspace_size);
undo_redo->add_undo_method(workspace, "set_custom_minimum_size", workspace_minsize);
- undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", tile_workspace_size);
+ undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", max_workspace_size);
undo_redo->add_undo_method(workspace_container, "set_custom_minimum_size", workspace_minsize);
- undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", tile_workspace_size);
+ undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", max_workspace_size);
undo_redo->add_undo_method(workspace_overlay, "set_custom_minimum_size", workspace_minsize);
} else if (workspace_minsize.x > get_current_texture()->get_size().x + WORKSPACE_MARGIN.x * 2 || workspace_minsize.y > get_current_texture()->get_size().y + WORKSPACE_MARGIN.y * 2) {
undo_redo->add_do_method(this, "update_workspace_minsize");
@@ -1528,18 +1570,19 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
shape_anchor.x *= (size.x + spacing);
shape_anchor.y *= (size.y + spacing);
}
+
const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
shape_anchor += current_tile_region.position;
if (tools[TOOL_SELECT]->is_pressed()) {
if (mb.is_valid()) {
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
if (edit_mode != EDITMODE_PRIORITY && current_shape.size() > 0) {
- for (int i = 0; i < current_shape.size(); i++) {
- if ((current_shape[i] - mb->get_position()).length_squared() <= grab_threshold) {
- dragging_point = i;
- workspace->update();
- return;
- }
+ int grabbed_point = get_grabbed_point(mb->get_position(), grab_threshold);
+
+ if (grabbed_point >= 0) {
+ dragging_point = grabbed_point;
+ workspace->update();
+ return;
}
}
if ((tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) && current_tile_region.has_point(mb->get_position())) {
@@ -1575,16 +1618,14 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if (dragging_point >= 0) {
dragging_point = -1;
- PoolVector<Vector2> polygon;
+ Vector<Vector2> polygon;
polygon.resize(current_shape.size());
- PoolVector<Vector2>::Write w = polygon.write();
+ Vector2 *w = polygon.ptrw();
for (int i = 0; i < current_shape.size(); i++) {
w[i] = current_shape[i] - shape_anchor;
}
- w.release();
-
undo_redo->create_action(TTR("Edit Occlusion Polygon"));
undo_redo->add_do_method(edited_occlusion_shape.ptr(), "set_polygon", polygon);
undo_redo->add_undo_method(edited_occlusion_shape.ptr(), "set_polygon", edited_occlusion_shape->get_polygon());
@@ -1596,18 +1637,16 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if (dragging_point >= 0) {
dragging_point = -1;
- PoolVector<Vector2> polygon;
+ Vector<Vector2> polygon;
Vector<int> indices;
polygon.resize(current_shape.size());
- PoolVector<Vector2>::Write w = polygon.write();
+ Vector2 *w = polygon.ptrw();
for (int i = 0; i < current_shape.size(); i++) {
w[i] = current_shape[i] - shape_anchor;
indices.push_back(i);
}
- w.release();
-
undo_redo->create_action(TTR("Edit Navigation Polygon"));
undo_redo->add_do_method(edited_navigation_shape.ptr(), "set_vertices", polygon);
undo_redo->add_undo_method(edited_navigation_shape.ptr(), "set_vertices", edited_navigation_shape->get_vertices());
@@ -1633,13 +1672,12 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
Vector2 pos = mb->get_position();
pos = snap_point(pos);
if (creating_shape) {
- if (current_shape.size() > 0) {
- if ((pos - current_shape[0]).length_squared() <= grab_threshold) {
- if (current_shape.size() > 2) {
- close_shape(shape_anchor);
- workspace->update();
- return;
- }
+ if (current_shape.size() > 2) {
+
+ if (is_within_grabbing_distance_of_first_point(mb->get_position(), grab_threshold)) {
+ close_shape(shape_anchor);
+ workspace->update();
+ return;
}
}
current_shape.push_back(pos);
@@ -1685,12 +1723,15 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
} else if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
if (creating_shape) {
- if ((current_shape[0] - current_shape[1]).length_squared() <= grab_threshold) {
+
+ // if the first two corners are within grabbing distance of one another, expand the rect to fill the tile
+ if (is_within_grabbing_distance_of_first_point(current_shape[1], grab_threshold)) {
current_shape.set(0, snap_point(shape_anchor));
current_shape.set(1, snap_point(shape_anchor + Vector2(current_tile_region.size.x, 0)));
current_shape.set(2, snap_point(shape_anchor + current_tile_region.size));
current_shape.set(3, snap_point(shape_anchor + Vector2(0, current_tile_region.size.y)));
}
+
close_shape(shape_anchor);
workspace->update();
return;
@@ -1749,32 +1790,36 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
Array sd = tileset->call("tile_get_shapes", get_current_tile());
if (convex.is_valid()) {
- // Make concave
+ // Make concave.
undo_redo->create_action(TTR("Make Polygon Concave"));
Ref<ConcavePolygonShape2D> _concave = memnew(ConcavePolygonShape2D);
edited_collision_shape = _concave;
_set_edited_shape_points(_get_collision_shape_points(convex));
} else if (concave.is_valid()) {
- // Make convex
+ // Make convex.
undo_redo->create_action(TTR("Make Polygon Convex"));
Ref<ConvexPolygonShape2D> _convex = memnew(ConvexPolygonShape2D);
edited_collision_shape = _convex;
_set_edited_shape_points(_get_collision_shape_points(concave));
- } else {
- // Shouldn't happen
}
for (int i = 0; i < sd.size(); i++) {
if (sd[i].get("shape") == previous_shape) {
undo_redo->add_undo_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd.duplicate());
sd.remove(i);
- sd.insert(i, edited_collision_shape);
- undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd);
- undo_redo->add_do_method(this, "_select_edited_shape_coord");
- undo_redo->add_undo_method(this, "_select_edited_shape_coord");
- undo_redo->commit_action();
break;
}
}
+
+ undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd);
+ if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) {
+ undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), edited_collision_shape, Transform2D(), false, edited_shape_coord);
+ } else {
+ undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), edited_collision_shape, Transform2D());
+ }
+ undo_redo->add_do_method(this, "_select_edited_shape_coord");
+ undo_redo->add_undo_method(this, "_select_edited_shape_coord");
+ undo_redo->commit_action();
+
_update_toggle_shape_button();
workspace->update();
workspace_container->update();
@@ -1934,18 +1979,15 @@ void TileSetEditor::_set_edited_shape_points(const Vector<Vector2> &points) {
undo_redo->add_do_method(convex.ptr(), "set_points", points);
undo_redo->add_undo_method(convex.ptr(), "set_points", _get_edited_shape_points());
} else if (concave.is_valid()) {
- PoolVector2Array segments;
+ PackedVector2Array segments;
for (int i = 0; i < points.size() - 1; i++) {
segments.push_back(points[i]);
segments.push_back(points[i + 1]);
}
segments.push_back(points[points.size() - 1]);
segments.push_back(points[0]);
- concave->set_segments(segments);
undo_redo->add_do_method(concave.ptr(), "set_segments", segments);
undo_redo->add_undo_method(concave.ptr(), "set_segments", concave->get_segments());
- } else {
- // Invalid shape
}
}
@@ -1994,10 +2036,10 @@ void TileSetEditor::_update_toggle_shape_button() {
tools[SHAPE_TOGGLE_TYPE]->hide();
} else if (concave.is_valid()) {
tools[SHAPE_TOGGLE_TYPE]->set_icon(get_icon("ConvexPolygonShape2D", "EditorIcons"));
- tools[SHAPE_TOGGLE_TYPE]->set_text("Make Convex");
+ tools[SHAPE_TOGGLE_TYPE]->set_text(TTR("Make Convex"));
} else if (convex.is_valid()) {
tools[SHAPE_TOGGLE_TYPE]->set_icon(get_icon("ConcavePolygonShape2D", "EditorIcons"));
- tools[SHAPE_TOGGLE_TYPE]->set_text("Make Concave");
+ tools[SHAPE_TOGGLE_TYPE]->set_text(TTR("Make Concave"));
} else {
// Shouldn't happen
separator_shape_toggle->hide();
@@ -2535,7 +2577,7 @@ void TileSetEditor::draw_grid_snap() {
if (i == 0 && snap_offset.y != 0) {
last_p = snap_offset.y;
}
- if (snap_separation.x != 0) {
+ if (snap_separation.y != 0) {
if (i != 0) {
workspace->draw_rect(Rect2(0, last_p, s.width, snap_separation.y), grid_color);
last_p += snap_separation.y;
@@ -2619,9 +2661,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (coord == edited_shape_coord || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_collision_shape) {
draw_handles = true;
@@ -2657,9 +2699,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (!creating_shape) {
if (polygon.size() > 1) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
}
if (shape == edited_occlusion_shape) {
@@ -2706,9 +2748,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (coord == edited_shape_coord) {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_occlusion_shape) {
draw_handles = true;
@@ -2736,7 +2778,7 @@ void TileSetEditor::draw_polygon_shapes() {
colors.push_back(c_bg);
}
} else {
- PoolVector<Vector2> vertices = shape->get_vertices();
+ Vector<Vector2> vertices = shape->get_vertices();
for (int j = 0; j < shape->get_polygon(0).size(); j++) {
polygon.push_back(vertices[shape->get_polygon(0)[j]] + anchor);
colors.push_back(c_bg);
@@ -2746,9 +2788,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_navigation_shape) {
draw_handles = true;
@@ -2784,7 +2826,7 @@ void TileSetEditor::draw_polygon_shapes() {
colors.push_back(c_bg);
}
} else {
- PoolVector<Vector2> vertices = shape->get_vertices();
+ Vector<Vector2> vertices = shape->get_vertices();
for (int j = 0; j < shape->get_polygon(0).size(); j++) {
polygon.push_back(vertices[shape->get_polygon(0)[j]] + anchor);
colors.push_back(c_bg);
@@ -2795,9 +2837,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (coord == edited_shape_coord) {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_navigation_shape) {
draw_handles = true;
@@ -2813,9 +2855,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (creating_shape) {
for (int j = 0; j < current_shape.size() - 1; j++) {
- workspace->draw_line(current_shape[j], current_shape[j + 1], Color(0, 1, 1), 1, true);
+ workspace->draw_line(current_shape[j], current_shape[j + 1], Color(0, 1, 1), 1);
}
- workspace->draw_line(current_shape[current_shape.size() - 1], snap_point(workspace->get_local_mouse_position()), Color(0, 1, 1), 1, true);
+ workspace->draw_line(current_shape[current_shape.size() - 1], snap_point(workspace->get_local_mouse_position()), Color(0, 1, 1), 1);
draw_handles = true;
}
}
@@ -2871,15 +2913,14 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
} else if (edit_mode == EDITMODE_OCCLUSION) {
Ref<OccluderPolygon2D> shape = memnew(OccluderPolygon2D);
- PoolVector<Vector2> polygon;
+ Vector<Vector2> polygon;
polygon.resize(current_shape.size());
- PoolVector<Vector2>::Write w = polygon.write();
+ Vector2 *w = polygon.ptrw();
for (int i = 0; i < current_shape.size(); i++) {
w[i] = current_shape[i] - shape_anchor;
}
- w.release();
shape->set_polygon(polygon);
undo_redo->create_action(TTR("Create Occlusion Polygon"));
@@ -2897,17 +2938,16 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
} else if (edit_mode == EDITMODE_NAVIGATION) {
Ref<NavigationPolygon> shape = memnew(NavigationPolygon);
- PoolVector<Vector2> polygon;
+ Vector<Vector2> polygon;
Vector<int> indices;
polygon.resize(current_shape.size());
- PoolVector<Vector2>::Write w = polygon.write();
+ Vector2 *w = polygon.ptrw();
for (int i = 0; i < current_shape.size(); i++) {
w[i] = current_shape[i] - shape_anchor;
indices.push_back(i);
}
- w.release();
shape->set_vertices(polygon);
shape->add_polygon(indices);
@@ -2929,7 +2969,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
void TileSetEditor::select_coord(const Vector2 &coord) {
_update_tile_data();
- current_shape = PoolVector2Array();
+ current_shape = PackedVector2Array();
if (get_current_tile() == -1)
return;
Rect2 current_tile_region = tileset->tile_get_region(get_current_tile());
@@ -2960,7 +3000,7 @@ void TileSetEditor::select_coord(const Vector2 &coord) {
current_shape.resize(0);
if (edited_navigation_shape.is_valid()) {
if (edited_navigation_shape->get_polygon_count() > 0) {
- PoolVector<Vector2> vertices = edited_navigation_shape->get_vertices();
+ Vector<Vector2> vertices = edited_navigation_shape->get_vertices();
for (int i = 0; i < edited_navigation_shape->get_polygon(0).size(); i++) {
current_shape.push_back(vertices[edited_navigation_shape->get_polygon(0)[i]] + current_tile_region.position);
}
@@ -3009,7 +3049,7 @@ void TileSetEditor::select_coord(const Vector2 &coord) {
current_shape.resize(0);
if (edited_navigation_shape.is_valid()) {
if (edited_navigation_shape->get_polygon_count() > 0) {
- PoolVector<Vector2> vertices = edited_navigation_shape->get_vertices();
+ Vector<Vector2> vertices = edited_navigation_shape->get_vertices();
for (int i = 0; i < edited_navigation_shape->get_polygon(0).size(); i++) {
current_shape.push_back(vertices[edited_navigation_shape->get_polygon(0)[i]] + shape_anchor);
}
@@ -3055,13 +3095,13 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
return p;
}
-void TileSetEditor::add_texture(Ref<Texture> p_texture) {
+void TileSetEditor::add_texture(Ref<Texture2D> p_texture) {
texture_list->add_item(p_texture->get_path().get_file());
texture_map.insert(p_texture->get_rid(), p_texture);
texture_list->set_item_metadata(texture_list->get_item_count() - 1, p_texture->get_rid());
}
-void TileSetEditor::remove_texture(Ref<Texture> p_texture) {
+void TileSetEditor::remove_texture(Ref<Texture2D> p_texture) {
texture_list->remove_item(texture_list->find_metadata(p_texture->get_rid()));
texture_map.erase(p_texture->get_rid());
@@ -3074,7 +3114,7 @@ void TileSetEditor::remove_texture(Ref<Texture> p_texture) {
}
void TileSetEditor::update_texture_list() {
- Ref<Texture> selected_texture = get_current_texture();
+ Ref<Texture2D> selected_texture = get_current_texture();
helper->set_tileset(tileset);
@@ -3224,12 +3264,16 @@ void TileSetEditor::update_workspace_minsize() {
List<int> *tiles = new List<int>();
tileset->get_tile_list(tiles);
for (List<int>::Element *E = tiles->front(); E; E = E->next()) {
- if (tileset->tile_get_texture(E->get())->get_rid() == current_texture_rid) {
- Rect2i region = tileset->tile_get_region(E->get());
- if (region.position.x + region.size.x > workspace_min_size.x)
- workspace_min_size.x = region.position.x + region.size.x;
- if (region.position.y + region.size.y > workspace_min_size.y)
- workspace_min_size.y = region.position.y + region.size.y;
+ if (tileset->tile_get_texture(E->get())->get_rid() != current_texture_rid) {
+ continue;
+ }
+
+ Rect2i region = tileset->tile_get_region(E->get());
+ if (region.position.x + region.size.x > workspace_min_size.x) {
+ workspace_min_size.x = region.position.x + region.size.x;
+ }
+ if (region.position.y + region.size.y > workspace_min_size.y) {
+ workspace_min_size.y = region.position.y + region.size.y;
}
}
delete tiles;
@@ -3279,9 +3323,9 @@ void TileSetEditor::set_current_tile(int p_id) {
}
}
-Ref<Texture> TileSetEditor::get_current_texture() {
+Ref<Texture2D> TileSetEditor::get_current_texture() {
if (texture_list->get_selected_items().size() == 0)
- return Ref<Texture>();
+ return Ref<Texture2D>();
else
return texture_map[texture_list->get_item_metadata(texture_list->get_selected_items()[0])];
}
@@ -3440,7 +3484,7 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const
int id = tileset_editor->get_current_tile();
p_list->push_back(PropertyInfo(Variant::NIL, "Selected Tile", PROPERTY_HINT_NONE, "tile_", PROPERTY_USAGE_GROUP));
p_list->push_back(PropertyInfo(Variant::STRING, "tile_name"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_tex_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial"));
p_list->push_back(PropertyInfo(Variant::COLOR, "tile_modulate"));
@@ -3463,7 +3507,7 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const
p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_collision", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_collision_shape->get_class()));
if (tileset_editor->edited_collision_shape.is_valid()) {
p_list->push_back(PropertyInfo(Variant::BOOL, "selected_collision_one_way", PROPERTY_HINT_NONE));
- p_list->push_back(PropertyInfo(Variant::REAL, "selected_collision_one_way_margin", PROPERTY_HINT_NONE));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "selected_collision_one_way_margin", PROPERTY_HINT_NONE));
}
}
if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_NAVIGATION && tileset_editor->edited_navigation_shape.is_valid()) {
@@ -3504,11 +3548,11 @@ void TileSetEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
tileset_editor_button->show();
editor->make_bottom_panel_item_visible(tileset_editor);
- get_tree()->connect("idle_frame", tileset_editor, "_on_workspace_process");
+ get_tree()->connect_compat("idle_frame", tileset_editor, "_on_workspace_process");
} else {
editor->hide_bottom_panel();
tileset_editor_button->hide();
- get_tree()->disconnect("idle_frame", tileset_editor, "_on_workspace_process");
+ get_tree()->disconnect_compat("idle_frame", tileset_editor, "_on_workspace_process");
}
}
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index 944dc04e4e..7b49e2ece2 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -114,7 +114,7 @@ class TileSetEditor : public HSplitContainer {
int option;
ToolButton *tileset_toolbar_buttons[TOOL_TILESET_MAX];
MenuButton *tileset_toolbar_tools;
- Map<RID, Ref<Texture> > texture_map;
+ Map<RID, Ref<Texture2D> > texture_map;
bool creating_shape;
int dragging_point;
@@ -123,7 +123,7 @@ class TileSetEditor : public HSplitContainer {
Rect2 edited_region;
bool draw_edited_region;
Vector2 edited_shape_coord;
- PoolVector2Array current_shape;
+ PackedVector2Array current_shape;
Map<Vector2i, SubtileData> current_tile_data;
Map<Vector2, uint32_t> bitmask_map_copy;
@@ -165,10 +165,10 @@ class TileSetEditor : public HSplitContainer {
void update_texture_list();
void update_texture_list_icon();
- void add_texture(Ref<Texture> p_texture);
- void remove_texture(Ref<Texture> p_texture);
+ void add_texture(Ref<Texture2D> p_texture);
+ void remove_texture(Ref<Texture2D> p_texture);
- Ref<Texture> get_current_texture();
+ Ref<Texture2D> get_current_texture();
static void _import_node(Node *p_node, Ref<TileSet> p_library);
static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge);
@@ -178,7 +178,7 @@ class TileSetEditor : public HSplitContainer {
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
- void _file_load_request(const PoolVector<String> &p_path, int p_at_pos = -1);
+ void _file_load_request(const Vector<String> &p_path, int p_at_pos = -1);
protected:
static void _bind_methods();
@@ -195,7 +195,7 @@ private:
void _on_tileset_toolbar_button_pressed(int p_index);
void _on_tileset_toolbar_confirm();
void _on_texture_list_selected(int p_index);
- void _on_textures_added(const PoolStringArray &p_paths);
+ void _on_textures_added(const PackedStringArray &p_paths);
void _on_edit_mode_changed(int p_edit_mode);
void _on_workspace_mode_changed(int p_workspace_mode);
void _on_workspace_overlay_draw();
@@ -244,6 +244,8 @@ private:
void update_workspace_tile_mode();
void update_workspace_minsize();
void update_edited_region(const Vector2 &end_point);
+ int get_grabbed_point(const Vector2 &p_mouse_pos, real_t grab_threshold);
+ bool is_within_grabbing_distance_of_first_point(const Vector2 &p_pos, real_t p_grab_threshold);
int get_current_tile() const;
void set_current_tile(int p_id);
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index 783797ada4..cfa10488ab 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,9 +29,11 @@
/*************************************************************************/
#include "version_control_editor_plugin.h"
+
#include "core/script_language.h"
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = NULL;
@@ -122,10 +124,10 @@ void VersionControlEditorPlugin::_initialize_vcs() {
ERR_FAIL_COND_MSG(!addon_script_instance, "Failed to create addon script instance.");
// The addon is attached as a script to the VCS interface as a proxy end-point
- vcs_interface->set_script_and_instance(script.get_ref_ptr(), addon_script_instance);
+ vcs_interface->set_script_and_instance(script, addon_script_instance);
EditorVCSInterface::set_singleton(vcs_interface);
- EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_refresh_stage_area");
+ EditorFileSystem::get_singleton()->connect_compat("filesystem_changed", this, "_refresh_stage_area");
String res_dir = OS::get_singleton()->get_resource_dir();
@@ -201,7 +203,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() {
}
} else {
- WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu.")
+ WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu.");
}
}
@@ -386,8 +388,8 @@ void VersionControlEditorPlugin::clear_stage_area() {
void VersionControlEditorPlugin::shut_down() {
if (EditorVCSInterface::get_singleton()) {
- if (EditorFileSystem::get_singleton()->is_connected("filesystem_changed", this, "_refresh_stage_area")) {
- EditorFileSystem::get_singleton()->disconnect("filesystem_changed", this, "_refresh_stage_area");
+ if (EditorFileSystem::get_singleton()->is_connected_compat("filesystem_changed", this, "_refresh_stage_area")) {
+ EditorFileSystem::get_singleton()->disconnect_compat("filesystem_changed", this, "_refresh_stage_area");
}
EditorVCSInterface::get_singleton()->shut_down();
memdelete(EditorVCSInterface::get_singleton());
@@ -398,9 +400,9 @@ void VersionControlEditorPlugin::shut_down() {
}
}
-bool VersionControlEditorPlugin::get_is_vcs_intialized() const {
+bool VersionControlEditorPlugin::is_vcs_initialized() const {
- return EditorVCSInterface::get_singleton() ? EditorVCSInterface::get_singleton()->get_is_vcs_intialized() : false;
+ return EditorVCSInterface::get_singleton() ? EditorVCSInterface::get_singleton()->is_vcs_initialized() : false;
}
const String VersionControlEditorPlugin::get_vcs_name() const {
@@ -442,14 +444,14 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_choice = memnew(OptionButton);
set_up_choice->set_h_size_flags(HBoxContainer::SIZE_EXPAND_FILL);
- set_up_choice->connect("item_selected", this, "_selected_a_vcs");
+ set_up_choice->connect_compat("item_selected", this, "_selected_a_vcs");
set_up_hbc->add_child(set_up_choice);
set_up_init_settings = NULL;
set_up_init_button = memnew(Button);
set_up_init_button->set_text(TTR("Initialize"));
- set_up_init_button->connect("pressed", this, "_initialize_vcs");
+ set_up_init_button->connect_compat("pressed", this, "_initialize_vcs");
set_up_vbc->add_child(set_up_init_button);
version_control_actions->set_v_size_flags(PopupMenu::SIZE_EXPAND_FILL);
@@ -477,7 +479,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
refresh_button->set_tooltip(TTR("Detect new changes"));
refresh_button->set_text(TTR("Refresh"));
refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Reload", "EditorIcons"));
- refresh_button->connect("pressed", this, "_refresh_stage_area");
+ refresh_button->connect_compat("pressed", this, "_refresh_stage_area");
stage_tools->add_child(refresh_button);
stage_files = memnew(Tree);
@@ -490,7 +492,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
stage_files->set_allow_rmb_select(true);
stage_files->set_select_mode(Tree::SelectMode::SELECT_MULTI);
stage_files->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
- stage_files->connect("cell_selected", this, "_view_file_diff");
+ stage_files->connect_compat("cell_selected", this, "_view_file_diff");
stage_files->create_item();
stage_files->set_hide_root(true);
commit_box_vbc->add_child(stage_files);
@@ -514,12 +516,12 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
stage_selected_button = memnew(Button);
stage_selected_button->set_h_size_flags(Button::SIZE_EXPAND_FILL);
stage_selected_button->set_text(TTR("Stage Selected"));
- stage_selected_button->connect("pressed", this, "_stage_selected");
+ stage_selected_button->connect_compat("pressed", this, "_stage_selected");
stage_buttons->add_child(stage_selected_button);
stage_all_button = memnew(Button);
stage_all_button->set_text(TTR("Stage All"));
- stage_all_button->connect("pressed", this, "_stage_all");
+ stage_all_button->connect_compat("pressed", this, "_stage_all");
stage_buttons->add_child(stage_all_button);
commit_box_vbc->add_child(memnew(HSeparator));
@@ -535,7 +537,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
commit_button = memnew(Button);
commit_button->set_text(TTR("Commit Changes"));
- commit_button->connect("pressed", this, "_send_commit_msg");
+ commit_button->connect_compat("pressed", this, "_send_commit_msg");
commit_box_vbc->add_child(commit_button);
commit_status = memnew(Label);
@@ -569,7 +571,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
diff_refresh_button = memnew(Button);
diff_refresh_button->set_tooltip(TTR("Detect changes in file diff"));
diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Reload", "EditorIcons"));
- diff_refresh_button->connect("pressed", this, "_refresh_file_diff");
+ diff_refresh_button->connect_compat("pressed", this, "_refresh_file_diff");
diff_hbc->add_child(diff_refresh_button);
diff = memnew(RichTextLabel);
diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h
index 450ebccce1..4a98c8580e 100644
--- a/editor/plugins/version_control_editor_plugin.h
+++ b/editor/plugins/version_control_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -129,7 +129,7 @@ public:
PanelContainer *get_version_control_dock() const { return version_control_dock; }
List<StringName> get_available_vcs_names() const { return available_addons; }
- bool get_is_vcs_intialized() const;
+ bool is_vcs_initialized() const;
const String get_vcs_name() const;
void register_editor();
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 1a74779fb5..8766d96939 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,10 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
+#include "core/version.h"
+#include "editor/editor_log.h"
#include "editor/editor_properties.h"
+#include "editor/editor_scale.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
@@ -70,14 +73,20 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
}
}
visual_shader = Ref<VisualShader>(p_visual_shader);
- if (!visual_shader->is_connected("changed", this, "_update_preview")) {
- visual_shader->connect("changed", this, "_update_preview");
+ if (!visual_shader->is_connected_compat("changed", this, "_update_preview")) {
+ visual_shader->connect_compat("changed", this, "_update_preview");
}
+#ifndef DISABLE_DEPRECATED
+ String version = VERSION_BRANCH;
+ if (visual_shader->get_version() != version) {
+ visual_shader->update_version(version);
+ }
+#endif
visual_shader->set_graph_offset(graph->get_scroll_ofs() / EDSCALE);
} else {
if (visual_shader.is_valid()) {
- if (visual_shader->is_connected("changed", this, "")) {
- visual_shader->disconnect("changed", this, "_update_preview");
+ if (visual_shader->is_connected_compat("changed", this, "")) {
+ visual_shader->disconnect_compat("changed", this, "_update_preview");
}
}
visual_shader.unref();
@@ -114,7 +123,7 @@ void VisualShaderEditor::clear_custom_types() {
}
}
-void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, const String &p_subcategory) {
+void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend) {
ERR_FAIL_COND(!p_name.is_valid_identifier());
ERR_FAIL_COND(!p_script.is_valid());
@@ -132,14 +141,15 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script>
ao.return_type = p_return_icon_type;
ao.description = p_description;
ao.category = p_category;
- ao.sub_category = p_subcategory;
+ ao.highend = p_highend;
ao.is_custom = true;
bool begin = false;
+ String root = p_category.split("/")[0];
for (int i = 0; i < add_options.size(); i++) {
if (add_options[i].is_custom) {
- if (add_options[i].category == p_category) {
+ if (add_options[i].category == root) {
if (!begin) {
begin = true;
}
@@ -213,7 +223,7 @@ void VisualShaderEditor::update_custom_nodes() {
Ref<VisualShaderNodeCustom> ref;
ref.instance();
- ref->set_script(script.get_ref_ptr());
+ ref->set_script(script);
String name;
if (ref->has_method("_get_name")) {
@@ -236,31 +246,35 @@ void VisualShaderEditor::update_custom_nodes() {
if (ref->has_method("_get_category")) {
category = (String)ref->call("_get_category");
}
- if (category == "") {
- category = "Custom";
- }
String subcategory = "";
if (ref->has_method("_get_subcategory")) {
subcategory = (String)ref->call("_get_subcategory");
}
+ bool highend = false;
+ if (ref->has_method("_is_highend")) {
+ highend = (bool)ref->call("_is_highend");
+ }
+
Dictionary dict;
dict["name"] = name;
dict["script"] = script;
dict["description"] = description;
dict["return_icon_type"] = return_icon_type;
- dict["category"] = category;
- dict["subcategory"] = subcategory;
- String key;
- key = category;
- key += "/";
+ category = category.rstrip("/");
+ category = category.lstrip("/");
+ category = "Addons/" + category;
if (subcategory != "") {
- key += subcategory;
- key += "/";
+ category += "/" + subcategory;
}
- key += name;
+
+ dict["category"] = category;
+ dict["highend"] = highend;
+
+ String key;
+ key = category + "/" + name;
added[key] = dict;
}
@@ -275,18 +289,14 @@ void VisualShaderEditor::update_custom_nodes() {
const Dictionary &value = (Dictionary)added[key];
- add_custom_type(value["name"], value["script"], value["description"], value["return_icon_type"], value["category"], value["subcategory"]);
+ add_custom_type(value["name"], value["script"], value["description"], value["return_icon_type"], value["category"], value["highend"]);
}
_update_options_menu();
}
String VisualShaderEditor::_get_description(int p_idx) {
- if (add_options[p_idx].highend) {
- return TTR("(GLES3 only)") + " " + add_options[p_idx].description; // TODO: change it to (Vulkan Only) when its ready
- } else {
- return add_options[p_idx].description;
- }
+ return add_options[p_idx].description;
}
void VisualShaderEditor::_update_options_menu() {
@@ -294,22 +304,12 @@ void VisualShaderEditor::_update_options_menu() {
node_desc->set_text("");
members_dialog->get_ok()->set_disabled(true);
- String prev_category;
- String prev_sub_category;
-
members->clear();
TreeItem *root = members->create_item();
- TreeItem *category = NULL;
- TreeItem *sub_category = NULL;
String filter = node_filter->get_text().strip_edges();
bool use_filter = !filter.empty();
- Vector<String> categories;
- Vector<String> sub_categories;
-
- int item_count = 0;
- int item_count2 = 0;
bool is_first_item = true;
Color unsupported_color = get_color("error_color", "Editor");
@@ -317,111 +317,95 @@ void VisualShaderEditor::_update_options_menu() {
static bool low_driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name") == "GLES2";
+ Map<String, TreeItem *> folders;
+
int current_func = -1;
if (!visual_shader.is_null()) {
current_func = visual_shader->get_mode();
}
- for (int i = 0; i < add_options.size() + 1; i++) {
+ Vector<AddOption> custom_options;
+ Vector<AddOption> embedded_options;
- if (i == add_options.size()) {
- if (sub_category != NULL && item_count2 == 0) {
- memdelete(sub_category);
- --item_count;
+ for (int i = 0; i < add_options.size(); i++) {
+ if (!use_filter || add_options[i].name.findn(filter) != -1) {
+ if ((add_options[i].func != current_func && add_options[i].func != -1) || !_is_available(add_options[i].mode)) {
+ continue;
}
- if (category != NULL && item_count == 0) {
- memdelete(category);
+ const_cast<AddOption &>(add_options[i]).temp_idx = i; // save valid id
+ if (add_options[i].is_custom) {
+ custom_options.push_back(add_options[i]);
+ } else {
+ embedded_options.push_back(add_options[i]);
}
- break;
}
+ }
+ Vector<AddOption> options;
+ SortArray<AddOption, _OptionComparator> sorter;
+ sorter.sort(custom_options.ptrw(), custom_options.size());
- if (!use_filter || add_options[i].name.findn(filter) != -1) {
+ options.append_array(custom_options);
+ options.append_array(embedded_options);
- if ((add_options[i].func != current_func && add_options[i].func != -1) || !_is_available(add_options[i].mode))
- continue;
+ for (int i = 0; i < options.size(); i++) {
+ String path = options[i].category;
+ Vector<String> subfolders = path.split("/");
+ TreeItem *category = NULL;
- if (prev_category != add_options[i].category) {
- if (category != NULL && item_count == 0) {
- memdelete(category);
- }
-
- item_count = 0;
- prev_sub_category = "";
- category = members->create_item(root);
- category->set_text(0, add_options[i].category);
- category->set_selectable(0, false);
- if (!use_filter)
- category->set_collapsed(true);
- }
-
- if (add_options[i].sub_category != "") {
- if (prev_sub_category != add_options[i].sub_category) {
- if (category != NULL) {
- if (sub_category != NULL && item_count2 == 0) {
- memdelete(sub_category);
- --item_count;
- }
- ++item_count;
- item_count2 = 0;
- sub_category = members->create_item(category);
- sub_category->set_text(0, add_options[i].sub_category);
- sub_category->set_selectable(0, false);
- if (!use_filter)
- sub_category->set_collapsed(true);
- }
- }
- } else {
- sub_category = NULL;
- }
-
- TreeItem *p_category = NULL;
-
- if (sub_category != NULL) {
- p_category = sub_category;
- ++item_count2;
- } else if (category != NULL) {
- p_category = category;
- ++item_count;
- }
-
- if (p_category != NULL) {
- TreeItem *item = members->create_item(p_category);
- if (add_options[i].highend && low_driver)
- item->set_custom_color(0, unsupported_color);
- else if (add_options[i].highend)
- item->set_custom_color(0, supported_color);
- item->set_text(0, add_options[i].name);
- if (is_first_item && use_filter) {
- item->select(0);
- node_desc->set_text(_get_description(i));
- is_first_item = false;
- }
- switch (add_options[i].return_type) {
- case VisualShaderNode::PORT_TYPE_SCALAR:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"));
- break;
- case VisualShaderNode::PORT_TYPE_VECTOR:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"));
- break;
- case VisualShaderNode::PORT_TYPE_BOOLEAN:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"));
- break;
- case VisualShaderNode::PORT_TYPE_TRANSFORM:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"));
- break;
- case VisualShaderNode::PORT_TYPE_SAMPLER:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons"));
- break;
- default:
- break;
+ if (!folders.has(path)) {
+ category = root;
+ String path_temp = "";
+ for (int j = 0; j < subfolders.size(); j++) {
+ path_temp += subfolders[j];
+ if (!folders.has(path_temp)) {
+ category = members->create_item(category);
+ category->set_selectable(0, false);
+ category->set_collapsed(!use_filter);
+ category->set_text(0, subfolders[j]);
+ folders.insert(path_temp, category);
+ } else {
+ category = folders[path_temp];
}
- item->set_meta("id", i);
}
-
- prev_sub_category = add_options[i].sub_category;
- prev_category = add_options[i].category;
+ } else {
+ category = folders[path];
+ }
+
+ TreeItem *item = members->create_item(category);
+ if (options[i].highend && low_driver)
+ item->set_custom_color(0, unsupported_color);
+ else if (options[i].highend)
+ item->set_custom_color(0, supported_color);
+ item->set_text(0, options[i].name);
+ if (is_first_item && use_filter) {
+ item->select(0);
+ node_desc->set_text(options[i].description);
+ is_first_item = false;
+ }
+ switch (options[i].return_type) {
+ case VisualShaderNode::PORT_TYPE_SCALAR:
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"));
+ break;
+ case VisualShaderNode::PORT_TYPE_SCALAR_INT:
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("int", "EditorIcons"));
+ break;
+ case VisualShaderNode::PORT_TYPE_VECTOR:
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"));
+ break;
+ case VisualShaderNode::PORT_TYPE_BOOLEAN:
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"));
+ break;
+ case VisualShaderNode::PORT_TYPE_TRANSFORM:
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"));
+ break;
+ case VisualShaderNode::PORT_TYPE_SAMPLER:
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons"));
+ break;
+ default:
+ break;
}
+ item->set_meta("id", options[i].temp_idx);
}
}
@@ -454,14 +438,22 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
Ref<StyleBoxFlat> sb = node->get_stylebox("frame", "GraphNode");
Color c = sb->get_border_color();
- Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0);
+ Color ic;
+ Color mono_color;
+ if (((c.r + c.g + c.b) / 3) < 0.7) {
+ mono_color = Color(1.0, 1.0, 1.0);
+ ic = Color(0.0, 0.0, 0.0, 0.7);
+ } else {
+ mono_color = Color(0.0, 0.0, 0.0);
+ ic = Color(1.0, 1.0, 1.0, 0.7);
+ }
mono_color.a = 0.85;
c = mono_color;
node->add_color_override("title_color", c);
c.a = 0.7;
node->add_color_override("close_color", c);
- node->add_color_override("resizer_color", c);
+ node->add_color_override("resizer_color", ic);
}
}
@@ -488,12 +480,13 @@ void VisualShaderEditor::_update_graph() {
}
}
- static const Color type_color[5] = {
- Color(0.38, 0.85, 0.96), // scalar
+ static const Color type_color[6] = {
+ Color(0.38, 0.85, 0.96), // scalar (float)
+ Color(0.49, 0.78, 0.94), // scalar (int)
Color(0.84, 0.49, 0.93), // vector
Color(0.55, 0.65, 0.94), // boolean
Color(0.96, 0.66, 0.43), // transform
- Color(1.0, 1.0, 0.0) // sampler
+ Color(1.0, 1.0, 0.0), // sampler
};
List<VisualShader::Connection> connections;
@@ -524,7 +517,7 @@ void VisualShaderEditor::_update_graph() {
size = group_node->get_size();
node->set_resizable(true);
- node->connect("resize_request", this, "_node_resized", varray((int)type, nodes[n_i]));
+ node->connect_compat("resize_request", this, "_node_resized", varray((int)type, nodes[n_i]));
}
if (is_expression) {
expression = expression_node->get_expression();
@@ -541,10 +534,10 @@ void VisualShaderEditor::_update_graph() {
if (nodes[n_i] >= 2) {
node->set_show_close_button(true);
- node->connect("close_request", this, "_delete_request", varray(nodes[n_i]), CONNECT_DEFERRED);
+ node->connect_compat("close_request", this, "_delete_request", varray(nodes[n_i]), CONNECT_DEFERRED);
}
- node->connect("dragged", this, "_node_dragged", varray(nodes[n_i]));
+ node->connect_compat("dragged", this, "_node_dragged", varray(nodes[n_i]));
Control *custom_editor = NULL;
int port_offset = 0;
@@ -554,6 +547,8 @@ void VisualShaderEditor::_update_graph() {
}
Ref<VisualShaderNodeUniform> uniform = vsnode;
+ Ref<VisualShaderNodeFloatUniform> float_uniform = vsnode;
+ Ref<VisualShaderNodeIntUniform> int_uniform = vsnode;
if (uniform.is_valid()) {
graph->add_child(node);
_update_created_node(node);
@@ -561,14 +556,16 @@ void VisualShaderEditor::_update_graph() {
LineEdit *uniform_name = memnew(LineEdit);
uniform_name->set_text(uniform->get_uniform_name());
node->add_child(uniform_name);
- uniform_name->connect("text_entered", this, "_line_edit_changed", varray(uniform_name, nodes[n_i]));
- uniform_name->connect("focus_exited", this, "_line_edit_focus_out", varray(uniform_name, nodes[n_i]));
+ uniform_name->connect_compat("text_entered", this, "_line_edit_changed", varray(uniform_name, nodes[n_i]));
+ uniform_name->connect_compat("focus_exited", this, "_line_edit_focus_out", varray(uniform_name, nodes[n_i]));
if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
//shortcut
VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0);
node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]);
- continue;
+ if (!float_uniform.is_valid() && !int_uniform.is_valid()) {
+ continue;
+ }
}
port_offset++;
}
@@ -580,11 +577,16 @@ void VisualShaderEditor::_update_graph() {
}
}
- if (custom_editor && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
+ if (custom_editor && !float_uniform.is_valid() && !int_uniform.is_valid() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
//will be embedded in first port
} else if (custom_editor) {
+
port_offset++;
node->add_child(custom_editor);
+ if (float_uniform.is_valid() || int_uniform.is_valid()) {
+ custom_editor->call_deferred("_show_prop_names", true);
+ continue;
+ }
custom_editor = NULL;
}
@@ -599,14 +601,14 @@ void VisualShaderEditor::_update_graph() {
Button *add_input_btn = memnew(Button);
add_input_btn->set_text(TTR("Add Input"));
- add_input_btn->connect("pressed", this, "_add_input_port", varray(nodes[n_i], group_node->get_free_input_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "input" + itos(group_node->get_free_input_port_id())), CONNECT_DEFERRED);
+ add_input_btn->connect_compat("pressed", this, "_add_input_port", varray(nodes[n_i], group_node->get_free_input_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "input" + itos(group_node->get_free_input_port_id())), CONNECT_DEFERRED);
hb2->add_child(add_input_btn);
hb2->add_spacer();
Button *add_output_btn = memnew(Button);
add_output_btn->set_text(TTR("Add Output"));
- add_output_btn->connect("pressed", this, "_add_output_port", varray(nodes[n_i], group_node->get_free_output_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "output" + itos(group_node->get_free_output_port_id())), CONNECT_DEFERRED);
+ add_output_btn->connect_compat("pressed", this, "_add_output_port", varray(nodes[n_i], group_node->get_free_output_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "output" + itos(group_node->get_free_output_port_id())), CONNECT_DEFERRED);
hb2->add_child(add_output_btn);
node->add_child(hb2);
@@ -654,19 +656,19 @@ void VisualShaderEditor::_update_graph() {
if (default_value.get_type() != Variant::NIL) { // only a label
Button *button = memnew(Button);
hb->add_child(button);
- button->connect("pressed", this, "_edit_port_default_input", varray(button, nodes[n_i], i));
+ button->connect_compat("pressed", this, "_edit_port_default_input", varray(button, nodes[n_i], i));
switch (default_value.get_type()) {
case Variant::COLOR: {
button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- button->connect("draw", this, "_draw_color_over_button", varray(button, default_value));
+ button->connect_compat("draw", this, "_draw_color_over_button", varray(button, default_value));
} break;
case Variant::BOOL: {
button->set_text(((bool)default_value) ? "true" : "false");
} break;
case Variant::INT:
- case Variant::REAL: {
+ case Variant::FLOAT: {
button->set_text(String::num(default_value, 4));
} break;
case Variant::VECTOR3: {
@@ -688,27 +690,28 @@ void VisualShaderEditor::_update_graph() {
if (is_group) {
OptionButton *type_box = memnew(OptionButton);
hb->add_child(type_box);
- type_box->add_item(TTR("Scalar"));
+ type_box->add_item(TTR("Float"));
+ type_box->add_item(TTR("Int"));
type_box->add_item(TTR("Vector"));
type_box->add_item(TTR("Boolean"));
type_box->add_item(TTR("Transform"));
type_box->add_item(TTR("Sampler"));
type_box->select(group_node->get_input_port_type(i));
type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
- type_box->connect("item_selected", this, "_change_input_port_type", varray(nodes[n_i], i), CONNECT_DEFERRED);
+ type_box->connect_compat("item_selected", this, "_change_input_port_type", varray(nodes[n_i], i), CONNECT_DEFERRED);
LineEdit *name_box = memnew(LineEdit);
hb->add_child(name_box);
name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
name_box->set_h_size_flags(SIZE_EXPAND_FILL);
name_box->set_text(name_left);
- name_box->connect("text_entered", this, "_change_input_port_name", varray(name_box, nodes[n_i], i));
- name_box->connect("focus_exited", this, "_port_name_focus_out", varray(name_box, nodes[n_i], i, false));
+ name_box->connect_compat("text_entered", this, "_change_input_port_name", varray(name_box, nodes[n_i], i));
+ name_box->connect_compat("focus_exited", this, "_port_name_focus_out", varray(name_box, nodes[n_i], i, false));
Button *remove_btn = memnew(Button);
remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
- remove_btn->connect("pressed", this, "_remove_input_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
+ remove_btn->connect_compat("pressed", this, "_remove_input_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
} else {
@@ -737,7 +740,7 @@ void VisualShaderEditor::_update_graph() {
Button *remove_btn = memnew(Button);
remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
- remove_btn->connect("pressed", this, "_remove_output_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
+ remove_btn->connect_compat("pressed", this, "_remove_output_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
LineEdit *name_box = memnew(LineEdit);
@@ -745,18 +748,19 @@ void VisualShaderEditor::_update_graph() {
name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
name_box->set_h_size_flags(SIZE_EXPAND_FILL);
name_box->set_text(name_right);
- name_box->connect("text_entered", this, "_change_output_port_name", varray(name_box, nodes[n_i], i));
- name_box->connect("focus_exited", this, "_port_name_focus_out", varray(name_box, nodes[n_i], i, true));
+ name_box->connect_compat("text_entered", this, "_change_output_port_name", varray(name_box, nodes[n_i], i));
+ name_box->connect_compat("focus_exited", this, "_port_name_focus_out", varray(name_box, nodes[n_i], i, true));
OptionButton *type_box = memnew(OptionButton);
hb->add_child(type_box);
- type_box->add_item(TTR("Scalar"));
+ type_box->add_item(TTR("Float"));
+ type_box->add_item(TTR("Int"));
type_box->add_item(TTR("Vector"));
type_box->add_item(TTR("Boolean"));
type_box->add_item(TTR("Transform"));
type_box->select(group_node->get_output_port_type(i));
type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
- type_box->connect("item_selected", this, "_change_output_port_type", varray(nodes[n_i], i), CONNECT_DEFERRED);
+ type_box->connect_compat("item_selected", this, "_change_output_port_type", varray(nodes[n_i], i), CONNECT_DEFERRED);
} else {
Label *label = memnew(Label);
label->set_text(name_right);
@@ -777,7 +781,7 @@ void VisualShaderEditor::_update_graph() {
preview->set_pressed(true);
}
- preview->connect("pressed", this, "_preview_select_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
+ preview->connect_compat("pressed", this, "_preview_select_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(preview);
}
@@ -850,7 +854,7 @@ void VisualShaderEditor::_update_graph() {
expression_box->set_context_menu_enabled(false);
expression_box->set_show_line_numbers(true);
- expression_box->connect("focus_exited", this, "_expression_focus_out", varray(expression_box, nodes[n_i]));
+ expression_box->connect_compat("focus_exited", this, "_expression_focus_out", varray(expression_box, nodes[n_i]));
}
if (!uniform.is_valid()) {
@@ -1313,7 +1317,7 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type));
ERR_FAIL_COND_V(!vsn, NULL);
- VisualShaderNodeScalarConstant *constant = Object::cast_to<VisualShaderNodeScalarConstant>(vsn);
+ VisualShaderNodeFloatConstant *constant = Object::cast_to<VisualShaderNodeFloatConstant>(vsn);
if (constant) {
if ((int)add_options[p_idx].value != -1)
@@ -1352,16 +1356,28 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
colorFunc->set_function((VisualShaderNodeColorFunc::Function)p_op_idx);
}
- VisualShaderNodeScalarOp *scalarOp = Object::cast_to<VisualShaderNodeScalarOp>(vsn);
+ VisualShaderNodeFloatOp *floatOp = Object::cast_to<VisualShaderNodeFloatOp>(vsn);
- if (scalarOp) {
- scalarOp->set_operator((VisualShaderNodeScalarOp::Operator)p_op_idx);
+ if (floatOp) {
+ floatOp->set_operator((VisualShaderNodeFloatOp::Operator)p_op_idx);
}
- VisualShaderNodeScalarFunc *scalarFunc = Object::cast_to<VisualShaderNodeScalarFunc>(vsn);
+ VisualShaderNodeIntOp *intOp = Object::cast_to<VisualShaderNodeIntOp>(vsn);
- if (scalarFunc) {
- scalarFunc->set_function((VisualShaderNodeScalarFunc::Function)p_op_idx);
+ if (intOp) {
+ intOp->set_operator((VisualShaderNodeIntOp::Operator)p_op_idx);
+ }
+
+ VisualShaderNodeFloatFunc *floatFunc = Object::cast_to<VisualShaderNodeFloatFunc>(vsn);
+
+ if (floatFunc) {
+ floatFunc->set_function((VisualShaderNodeFloatFunc::Function)p_op_idx);
+ }
+
+ VisualShaderNodeIntFunc *intFunc = Object::cast_to<VisualShaderNodeIntFunc>(vsn);
+
+ if (intFunc) {
+ intFunc->set_function((VisualShaderNodeIntFunc::Function)p_op_idx);
}
VisualShaderNodeVectorOp *vecOp = Object::cast_to<VisualShaderNodeVectorOp>(vsn);
@@ -1402,7 +1418,7 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(base_type));
ERR_FAIL_COND_V(!vsn, NULL);
vsnode = Ref<VisualShaderNode>(vsn);
- vsnode->set_script(add_options[p_idx].script.get_ref_ptr());
+ vsnode->set_script(add_options[p_idx].script);
}
Point2 position = graph->get_scroll_ofs();
@@ -1670,6 +1686,8 @@ void VisualShaderEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
+ highend_label->set_modulate(get_color("vulkan_color", "Editor"));
+
error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
error_label->add_color_override("font_color", get_color("error_color", "Editor"));
@@ -2027,8 +2045,10 @@ void VisualShaderEditor::_member_selected() {
if (item != NULL && item->has_meta("id")) {
members_dialog->get_ok()->set_disabled(false);
+ highend_label->set_visible(add_options[item->get_meta("id")].highend);
node_desc->set_text(_get_description(item->get_meta("id")));
} else {
+ highend_label->set_visible(false);
members_dialog->get_ok()->set_disabled(true);
node_desc->set_text("");
}
@@ -2147,10 +2167,10 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
saved_node_pos_dirty = true;
_add_node(idx, add_options[idx].sub_func);
} else if (d.has("files")) {
- if (d["files"].get_type() == Variant::POOL_STRING_ARRAY) {
+ if (d["files"].get_type() == Variant::PACKED_STRING_ARRAY) {
int j = 0;
- PoolStringArray arr = d["files"];
+ PackedStringArray arr = d["files"];
for (int i = 0; i < arr.size(); i++) {
String type = ResourceLoader::get_resource_type(arr[i]);
@@ -2162,7 +2182,7 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
_add_custom_node(arr[i]);
j++;
}
- } else if (ClassDB::get_parent_class(type) == "Texture") {
+ } else if (ClassDB::get_parent_class(type) == "Texture2D") {
saved_node_pos = p_point + Vector2(0, j * 210 * EDSCALE);
saved_node_pos_dirty = true;
_add_texture_node(arr[i]);
@@ -2304,30 +2324,38 @@ VisualShaderEditor::VisualShaderEditor() {
main_box->add_child(graph);
graph->set_drag_forwarding(this);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR);
+ graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR_INT);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_BOOLEAN);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_TRANSFORM);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SAMPLER);
//graph->add_valid_left_disconnect_type(0);
graph->set_v_size_flags(SIZE_EXPAND_FILL);
- graph->connect("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED);
- graph->connect("disconnection_request", this, "_disconnection_request", varray(), CONNECT_DEFERRED);
- graph->connect("node_selected", this, "_node_selected");
- graph->connect("scroll_offset_changed", this, "_scroll_changed");
- graph->connect("duplicate_nodes_request", this, "_duplicate_nodes");
- graph->connect("copy_nodes_request", this, "_copy_nodes");
- graph->connect("paste_nodes_request", this, "_paste_nodes");
- graph->connect("delete_nodes_request", this, "_on_nodes_delete");
- graph->connect("gui_input", this, "_graph_gui_input");
- graph->connect("connection_to_empty", this, "_connection_to_empty");
- graph->connect("connection_from_empty", this, "_connection_from_empty");
+ graph->connect_compat("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED);
+ graph->connect_compat("disconnection_request", this, "_disconnection_request", varray(), CONNECT_DEFERRED);
+ graph->connect_compat("node_selected", this, "_node_selected");
+ graph->connect_compat("scroll_offset_changed", this, "_scroll_changed");
+ graph->connect_compat("duplicate_nodes_request", this, "_duplicate_nodes");
+ graph->connect_compat("copy_nodes_request", this, "_copy_nodes");
+ graph->connect_compat("paste_nodes_request", this, "_paste_nodes");
+ graph->connect_compat("delete_nodes_request", this, "_on_nodes_delete");
+ graph->connect_compat("gui_input", this, "_graph_gui_input");
+ graph->connect_compat("connection_to_empty", this, "_connection_to_empty");
+ graph->connect_compat("connection_from_empty", this, "_connection_from_empty");
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR_INT);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_BOOLEAN);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR_INT, VisualShaderNode::PORT_TYPE_SCALAR_INT);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR_INT, VisualShaderNode::PORT_TYPE_SCALAR);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR_INT, VisualShaderNode::PORT_TYPE_VECTOR);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR_INT, VisualShaderNode::PORT_TYPE_BOOLEAN);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_SCALAR);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_SCALAR_INT);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_BOOLEAN);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_SCALAR);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_SCALAR_INT);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_BOOLEAN);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShaderNode::PORT_TYPE_TRANSFORM);
@@ -2342,7 +2370,7 @@ VisualShaderEditor::VisualShaderEditor() {
edit_type->add_item(TTR("Fragment"));
edit_type->add_item(TTR("Light"));
edit_type->select(1);
- edit_type->connect("item_selected", this, "_mode_selected");
+ edit_type->connect_compat("item_selected", this, "_mode_selected");
graph->get_zoom_hbox()->add_child(edit_type);
graph->get_zoom_hbox()->move_child(edit_type, 0);
@@ -2350,13 +2378,13 @@ VisualShaderEditor::VisualShaderEditor() {
graph->get_zoom_hbox()->add_child(add_node);
add_node->set_text(TTR("Add Node..."));
graph->get_zoom_hbox()->move_child(add_node, 0);
- add_node->connect("pressed", this, "_show_members_dialog", varray(false));
+ add_node->connect_compat("pressed", this, "_show_members_dialog", varray(false));
preview_shader = memnew(ToolButton);
preview_shader->set_toggle_mode(true);
preview_shader->set_tooltip(TTR("Show resulted shader code."));
graph->get_zoom_hbox()->add_child(preview_shader);
- preview_shader->connect("pressed", this, "_show_preview_text");
+ preview_shader->connect_compat("pressed", this, "_show_preview_text");
///////////////////////////////////////
// PREVIEW PANEL
@@ -2390,15 +2418,15 @@ VisualShaderEditor::VisualShaderEditor() {
node_filter = memnew(LineEdit);
filter_hb->add_child(node_filter);
- node_filter->connect("text_changed", this, "_member_filter_changed");
- node_filter->connect("gui_input", this, "_sbox_input");
+ node_filter->connect_compat("text_changed", this, "_member_filter_changed");
+ node_filter->connect_compat("gui_input", this, "_sbox_input");
node_filter->set_h_size_flags(SIZE_EXPAND_FILL);
node_filter->set_placeholder(TTR("Search"));
tools = memnew(MenuButton);
filter_hb->add_child(tools);
tools->set_tooltip(TTR("Options"));
- tools->get_popup()->connect("id_pressed", this, "_tools_menu_option");
+ tools->get_popup()->connect_compat("id_pressed", this, "_tools_menu_option");
tools->get_popup()->add_item(TTR("Expand All"), EXPAND_ALL);
tools->get_popup()->add_item(TTR("Collapse All"), COLLAPSE_ALL);
@@ -2411,14 +2439,26 @@ VisualShaderEditor::VisualShaderEditor() {
members->set_allow_reselect(true);
members->set_hide_folding(false);
members->set_custom_minimum_size(Size2(180 * EDSCALE, 200 * EDSCALE));
- members->connect("item_activated", this, "_member_create");
- members->connect("item_selected", this, "_member_selected");
- members->connect("nothing_selected", this, "_member_unselected");
+ members->connect_compat("item_activated", this, "_member_create");
+ members->connect_compat("item_selected", this, "_member_selected");
+ members->connect_compat("nothing_selected", this, "_member_unselected");
+
+ HBoxContainer *desc_hbox = memnew(HBoxContainer);
+ members_vb->add_child(desc_hbox);
Label *desc_label = memnew(Label);
- members_vb->add_child(desc_label);
+ desc_hbox->add_child(desc_label);
desc_label->set_text(TTR("Description:"));
+ desc_hbox->add_spacer();
+
+ highend_label = memnew(Label);
+ desc_hbox->add_child(highend_label);
+ highend_label->set_visible(false);
+ highend_label->set_text("Vulkan");
+ highend_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
+ highend_label->set_tooltip(TTR("High-end node"));
+
node_desc = memnew(RichTextLabel);
members_vb->add_child(node_desc);
node_desc->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -2429,11 +2469,11 @@ VisualShaderEditor::VisualShaderEditor() {
members_dialog->set_title(TTR("Create Shader Node"));
members_dialog->add_child(members_vb);
members_dialog->get_ok()->set_text(TTR("Create"));
- members_dialog->get_ok()->connect("pressed", this, "_member_create");
+ members_dialog->get_ok()->connect_compat("pressed", this, "_member_create");
members_dialog->get_ok()->set_disabled(true);
members_dialog->set_resizable(true);
members_dialog->set_as_minsize();
- members_dialog->connect("hide", this, "_member_cancel");
+ members_dialog->connect_compat("hide", this, "_member_cancel");
add_child(members_dialog);
alert = memnew(AcceptDialog);
@@ -2604,7 +2644,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("CustomAlpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "custom_alpha"), "custom_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("Delta", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "delta"), "delta", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("EmissionTransform", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "emission_transform"), "emission_transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Index", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Index", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR_INT, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("LifeTime", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "lifetime"), "lifetime", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("Restart", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "restart"), "restart", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("Time", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
@@ -2613,79 +2653,91 @@ VisualShaderEditor::VisualShaderEditor() {
// SCALAR
- add_options.push_back(AddOption("ScalarFunc", "Scalar", "Common", "VisualShaderNodeScalarFunc", TTR("Scalar function."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ScalarOp", "Scalar", "Common", "VisualShaderNodeScalarOp", TTR("Scalar operator."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("FloatFunc", "Scalar", "Common", "VisualShaderNodeFloatFunc", TTR("Float function."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("IntFunc", "Scalar", "Common", "VisualShaderNodeIntFunc", TTR("Integer function."), -1, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("FloatOp", "Scalar", "Common", "VisualShaderNodeFloatOp", TTR("Float operator."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("IntOp", "Scalar", "Common", "VisualShaderNodeIntOp", TTR("Integer operator."), -1, VisualShaderNode::PORT_TYPE_SCALAR_INT));
//CONSTANTS
- add_options.push_back(AddOption("E", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("E constant (2.718282). Represents the base of the natural logarithm."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_E));
- add_options.push_back(AddOption("Epsilon", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("Epsilon constant (0.00001). Smallest possible scalar number."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, CMP_EPSILON));
- add_options.push_back(AddOption("Phi", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("Phi constant (1.618034). Golden ratio."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, 1.618034f));
- add_options.push_back(AddOption("Pi/4", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("Pi/4 constant (0.785398) or 45 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_PI / 4));
- add_options.push_back(AddOption("Pi/2", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("Pi/2 constant (1.570796) or 90 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_PI / 2));
- add_options.push_back(AddOption("Pi", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("Pi constant (3.141593) or 180 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_PI));
- add_options.push_back(AddOption("Tau", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("Tau constant (6.283185) or 360 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_TAU));
- add_options.push_back(AddOption("Sqrt2", "Scalar", "Constants", "VisualShaderNodeScalarConstant", TTR("Sqrt2 constant (1.414214). Square root of 2."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_SQRT2));
+ add_options.push_back(AddOption("E", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("E constant (2.718282). Represents the base of the natural logarithm."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_E));
+ add_options.push_back(AddOption("Epsilon", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("Epsilon constant (0.00001). Smallest possible scalar number."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, CMP_EPSILON));
+ add_options.push_back(AddOption("Phi", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("Phi constant (1.618034). Golden ratio."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, 1.618034f));
+ add_options.push_back(AddOption("Pi/4", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("Pi/4 constant (0.785398) or 45 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_PI / 4));
+ add_options.push_back(AddOption("Pi/2", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("Pi/2 constant (1.570796) or 90 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_PI / 2));
+ add_options.push_back(AddOption("Pi", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("Pi constant (3.141593) or 180 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_PI));
+ add_options.push_back(AddOption("Tau", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("Tau constant (6.283185) or 360 degrees."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_TAU));
+ add_options.push_back(AddOption("Sqrt2", "Scalar", "Constants", "VisualShaderNodeFloatConstant", TTR("Sqrt2 constant (1.414214). Square root of 2."), -1, VisualShaderNode::PORT_TYPE_SCALAR, -1, -1, Math_SQRT2));
// FUNCTIONS
- add_options.push_back(AddOption("Abs", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the absolute value of the parameter."), VisualShaderNodeScalarFunc::FUNC_ABS, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ACos", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the arc-cosine of the parameter."), VisualShaderNodeScalarFunc::FUNC_ACOS, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ACosH", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the inverse hyperbolic cosine of the parameter."), VisualShaderNodeScalarFunc::FUNC_ACOSH, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ASin", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the arc-sine of the parameter."), VisualShaderNodeScalarFunc::FUNC_ASIN, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ASinH", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the inverse hyperbolic sine of the parameter."), VisualShaderNodeScalarFunc::FUNC_ASINH, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ATan", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the arc-tangent of the parameter."), VisualShaderNodeScalarFunc::FUNC_ATAN, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ATan2", "Scalar", "Functions", "VisualShaderNodeScalarOp", TTR("Returns the arc-tangent of the parameters."), VisualShaderNodeScalarOp::OP_ATAN2, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ATanH", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the inverse hyperbolic tangent of the parameter."), VisualShaderNodeScalarFunc::FUNC_ATANH, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Ceil", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Finds the nearest integer that is greater than or equal to the parameter."), VisualShaderNodeScalarFunc::FUNC_CEIL, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Abs", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the absolute value of the parameter."), VisualShaderNodeFloatFunc::FUNC_ABS, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Abs", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Returns the absolute value of the parameter."), VisualShaderNodeIntFunc::FUNC_ABS, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("ACos", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the arc-cosine of the parameter."), VisualShaderNodeFloatFunc::FUNC_ACOS, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("ACosH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the inverse hyperbolic cosine of the parameter."), VisualShaderNodeFloatFunc::FUNC_ACOSH, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("ASin", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the arc-sine of the parameter."), VisualShaderNodeFloatFunc::FUNC_ASIN, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("ASinH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the inverse hyperbolic sine of the parameter."), VisualShaderNodeFloatFunc::FUNC_ASINH, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("ATan", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the arc-tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_ATAN, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("ATan2", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the arc-tangent of the parameters."), VisualShaderNodeFloatOp::OP_ATAN2, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("ATanH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the inverse hyperbolic tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_ATANH, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Ceil", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the nearest integer that is greater than or equal to the parameter."), VisualShaderNodeFloatFunc::FUNC_CEIL, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeScalarClamp", TTR("Constrains a value to lie between two further values."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Cos", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the cosine of the parameter."), VisualShaderNodeScalarFunc::FUNC_COS, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("CosH", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the hyperbolic cosine of the parameter."), VisualShaderNodeScalarFunc::FUNC_COSH, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Degrees", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Converts a quantity in radians to degrees."), VisualShaderNodeScalarFunc::FUNC_DEGREES, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Exp", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Base-e Exponential."), VisualShaderNodeScalarFunc::FUNC_EXP, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Exp2", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Base-2 Exponential."), VisualShaderNodeScalarFunc::FUNC_EXP2, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Floor", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Finds the nearest integer less than or equal to the parameter."), VisualShaderNodeScalarFunc::FUNC_FLOOR, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Fract", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Computes the fractional part of the argument."), VisualShaderNodeScalarFunc::FUNC_FRAC, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("InverseSqrt", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the inverse of the square root of the parameter."), VisualShaderNodeScalarFunc::FUNC_INVERSE_SQRT, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Log", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Natural logarithm."), VisualShaderNodeScalarFunc::FUNC_LOG, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Log2", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Base-2 logarithm."), VisualShaderNodeScalarFunc::FUNC_LOG2, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Max", "Scalar", "Functions", "VisualShaderNodeScalarOp", TTR("Returns the greater of two values."), VisualShaderNodeScalarOp::OP_MAX, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Min", "Scalar", "Functions", "VisualShaderNodeScalarOp", TTR("Returns the lesser of two values."), VisualShaderNodeScalarOp::OP_MIN, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Constrains a value to lie between two further values."), VisualShaderNodeIntFunc::FUNC_CLAMP, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("Cos", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the cosine of the parameter."), VisualShaderNodeFloatFunc::FUNC_COS, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("CosH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the hyperbolic cosine of the parameter."), VisualShaderNodeFloatFunc::FUNC_COSH, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Degrees", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Converts a quantity in radians to degrees."), VisualShaderNodeFloatFunc::FUNC_DEGREES, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Exp", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Base-e Exponential."), VisualShaderNodeFloatFunc::FUNC_EXP, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Exp2", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Base-2 Exponential."), VisualShaderNodeFloatFunc::FUNC_EXP2, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Floor", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the nearest integer less than or equal to the parameter."), VisualShaderNodeFloatFunc::FUNC_FLOOR, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Fract", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Computes the fractional part of the argument."), VisualShaderNodeFloatFunc::FUNC_FRAC, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("InverseSqrt", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the inverse of the square root of the parameter."), VisualShaderNodeFloatFunc::FUNC_INVERSE_SQRT, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Log", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Natural logarithm."), VisualShaderNodeFloatFunc::FUNC_LOG, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Log2", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Base-2 logarithm."), VisualShaderNodeFloatFunc::FUNC_LOG2, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Max", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the greater of two values."), VisualShaderNodeFloatOp::OP_MAX, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Min", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the lesser of two values."), VisualShaderNodeFloatOp::OP_MIN, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Mix", "Scalar", "Functions", "VisualShaderNodeScalarInterp", TTR("Linear interpolation between two scalars."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeScalarFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("OneMinus", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("1.0 - scalar"), VisualShaderNodeScalarFunc::FUNC_ONEMINUS, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Pow", "Scalar", "Functions", "VisualShaderNodeScalarOp", TTR("Returns the value of the first parameter raised to the power of the second."), VisualShaderNodeScalarOp::OP_POW, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Radians", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Converts a quantity in degrees to radians."), VisualShaderNodeScalarFunc::FUNC_RADIANS, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Reciprocal", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("1.0 / scalar"), VisualShaderNodeScalarFunc::FUNC_RECIPROCAL, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Round", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Finds the nearest integer to the parameter."), VisualShaderNodeScalarFunc::FUNC_ROUND, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("RoundEven", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Finds the nearest even integer to the parameter."), VisualShaderNodeScalarFunc::FUNC_ROUNDEVEN, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Saturate", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Clamps the value between 0.0 and 1.0."), VisualShaderNodeScalarFunc::FUNC_SATURATE, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Sign", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Extracts the sign of the parameter."), VisualShaderNodeScalarFunc::FUNC_SIGN, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Sin", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the sine of the parameter."), VisualShaderNodeScalarFunc::FUNC_SIN, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("SinH", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the hyperbolic sine of the parameter."), VisualShaderNodeScalarFunc::FUNC_SINH, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Sqrt", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the square root of the parameter."), VisualShaderNodeScalarFunc::FUNC_SQRT, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeFloatFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeIntFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("OneMinus", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("1.0 - scalar"), VisualShaderNodeFloatFunc::FUNC_ONEMINUS, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Pow", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the value of the first parameter raised to the power of the second."), VisualShaderNodeFloatOp::OP_POW, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Radians", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Converts a quantity in degrees to radians."), VisualShaderNodeFloatFunc::FUNC_RADIANS, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Reciprocal", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("1.0 / scalar"), VisualShaderNodeFloatFunc::FUNC_RECIPROCAL, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Round", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the nearest integer to the parameter."), VisualShaderNodeFloatFunc::FUNC_ROUND, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("RoundEven", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the nearest even integer to the parameter."), VisualShaderNodeFloatFunc::FUNC_ROUNDEVEN, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Saturate", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Clamps the value between 0.0 and 1.0."), VisualShaderNodeFloatFunc::FUNC_SATURATE, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Sign", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Extracts the sign of the parameter."), VisualShaderNodeFloatFunc::FUNC_SIGN, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Sign", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Extracts the sign of the parameter."), VisualShaderNodeIntFunc::FUNC_SIGN, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("Sin", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the sine of the parameter."), VisualShaderNodeFloatFunc::FUNC_SIN, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("SinH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the hyperbolic sine of the parameter."), VisualShaderNodeFloatFunc::FUNC_SINH, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Sqrt", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the square root of the parameter."), VisualShaderNodeFloatFunc::FUNC_SQRT, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("SmoothStep", "Scalar", "Functions", "VisualShaderNodeScalarSmoothStep", TTR("SmoothStep function( scalar(edge0), scalar(edge1), scalar(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge0' and 1.0 if x is larger than 'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Step", "Scalar", "Functions", "VisualShaderNodeScalarOp", TTR("Step function( scalar(edge), scalar(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), VisualShaderNodeScalarOp::OP_STEP, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Tan", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the tangent of the parameter."), VisualShaderNodeScalarFunc::FUNC_TAN, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("TanH", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Returns the hyperbolic tangent of the parameter."), VisualShaderNodeScalarFunc::FUNC_TANH, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Trunc", "Scalar", "Functions", "VisualShaderNodeScalarFunc", TTR("Finds the truncated value of the parameter."), VisualShaderNodeScalarFunc::FUNC_TRUNC, VisualShaderNode::PORT_TYPE_SCALAR));
-
- add_options.push_back(AddOption("Add", "Scalar", "Operators", "VisualShaderNodeScalarOp", TTR("Adds scalar to scalar."), VisualShaderNodeScalarOp::OP_ADD, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Divide", "Scalar", "Operators", "VisualShaderNodeScalarOp", TTR("Divides scalar by scalar."), VisualShaderNodeScalarOp::OP_DIV, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Multiply", "Scalar", "Operators", "VisualShaderNodeScalarOp", TTR("Multiplies scalar by scalar."), VisualShaderNodeScalarOp::OP_MUL, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Remainder", "Scalar", "Operators", "VisualShaderNodeScalarOp", TTR("Returns the remainder of the two scalars."), VisualShaderNodeScalarOp::OP_MOD, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Subtract", "Scalar", "Operators", "VisualShaderNodeScalarOp", TTR("Subtracts scalar from scalar."), VisualShaderNodeScalarOp::OP_SUB, VisualShaderNode::PORT_TYPE_SCALAR));
-
- add_options.push_back(AddOption("ScalarConstant", "Scalar", "Variables", "VisualShaderNodeScalarConstant", TTR("Scalar constant."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("ScalarUniform", "Scalar", "Variables", "VisualShaderNodeScalarUniform", TTR("Scalar uniform."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Step", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Step function( scalar(edge), scalar(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), VisualShaderNodeFloatOp::OP_STEP, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Tan", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_TAN, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("TanH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the hyperbolic tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_TANH, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Trunc", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the truncated value of the parameter."), VisualShaderNodeFloatFunc::FUNC_TRUNC, VisualShaderNode::PORT_TYPE_SCALAR));
+
+ add_options.push_back(AddOption("Add", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Sums two floating-point scalars."), VisualShaderNodeFloatOp::OP_ADD, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Add", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Sums two integer scalars."), VisualShaderNodeIntOp::OP_ADD, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("Divide", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Divides two floating-point scalars."), VisualShaderNodeFloatOp::OP_DIV, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Divide", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Divides two integer scalars."), VisualShaderNodeIntOp::OP_DIV, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("Multiply", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Multiplies two floating-point scalars."), VisualShaderNodeFloatOp::OP_MUL, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Multiply", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Multiplies two integer scalars."), VisualShaderNodeIntOp::OP_MUL, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("Remainder", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Returns the remainder of the two floating-point scalars."), VisualShaderNodeFloatOp::OP_MOD, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Remainder", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Returns the remainder of the two integer scalars."), VisualShaderNodeIntOp::OP_MOD, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("Subtract", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Subtracts two floating-point scalars."), VisualShaderNodeFloatOp::OP_SUB, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Subtract", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Subtracts two integer scalars."), VisualShaderNodeIntOp::OP_SUB, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+
+ add_options.push_back(AddOption("FloatConstant", "Scalar", "Variables", "VisualShaderNodeFloatConstant", TTR("Scalar floating-point constant."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("IntConstant", "Scalar", "Variables", "VisualShaderNodeIntConstant", TTR("Scalar integer constant."), -1, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("FloatUniform", "Scalar", "Variables", "VisualShaderNodeFloatUniform", TTR("Scalar floating-point uniform."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("IntUniform", "Scalar", "Variables", "VisualShaderNodeIntUniform", TTR("Scalar integer uniform."), -1, VisualShaderNode::PORT_TYPE_SCALAR_INT));
// TEXTURES
- add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, -1));
+ add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubemap", TTR("Perform the cubic texture lookup."), -1, -1));
texture_node_option_idx = add_options.size();
- add_options.push_back(AddOption("Texture", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1));
-
- add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, -1));
+ add_options.push_back(AddOption("Texture2D", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1));
+ add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubemapUniform", TTR("Cubic texture uniform lookup."), -1, -1));
add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, -1));
add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, -1, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
@@ -2813,7 +2865,7 @@ VisualShaderEditor::VisualShaderEditor() {
property_editor = memnew(CustomPropertyEditor);
add_child(property_editor);
- property_editor->connect("variant_changed", this, "_port_edited");
+ property_editor->connect_compat("variant_changed", this, "_port_edited");
}
void VisualShaderEditorPlugin::edit(Object *p_object) {
@@ -2850,7 +2902,7 @@ VisualShaderEditorPlugin::VisualShaderEditorPlugin(EditorNode *p_node) {
editor = p_node;
visual_shader_editor = memnew(VisualShaderEditor);
- visual_shader_editor->set_custom_minimum_size(Size2(0, 300));
+ visual_shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("VisualShader"), visual_shader_editor);
button->hide();
@@ -2874,7 +2926,7 @@ protected:
public:
void _notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- connect("item_selected", this, "_item_selected");
+ connect_compat("item_selected", this, "_item_selected");
}
}
@@ -2884,8 +2936,9 @@ public:
void setup(const Ref<VisualShaderNodeInput> &p_input) {
input = p_input;
- Ref<Texture> type_icon[5] = {
+ Ref<Texture2D> type_icon[6] = {
EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"),
+ EditorNode::get_singleton()->get_gui_base()->get_icon("int", "EditorIcons"),
EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"),
EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"),
EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"),
@@ -2970,6 +3023,13 @@ public:
bool updating;
Ref<VisualShaderNode> node;
Vector<EditorProperty *> properties;
+ Vector<Label *> prop_names;
+
+ void _show_prop_names(bool p_show) {
+ for (int i = 0; i < prop_names.size(); i++) {
+ prop_names[i]->set_visible(p_show);
+ }
+ }
void setup(Ref<Resource> p_parent_resource, Vector<EditorProperty *> p_properties, const Vector<StringName> &p_names, Ref<VisualShaderNode> p_node) {
parent_resource = p_parent_resource;
@@ -2979,20 +3039,33 @@ public:
for (int i = 0; i < p_properties.size(); i++) {
- add_child(p_properties[i]);
+ HBoxContainer *hbox = memnew(HBoxContainer);
+ hbox->set_h_size_flags(SIZE_EXPAND_FILL);
+ add_child(hbox);
+
+ Label *prop_name = memnew(Label);
+ String prop_name_str = p_names[i];
+ prop_name_str = prop_name_str.capitalize() + ":";
+ prop_name->set_text(prop_name_str);
+ prop_name->set_visible(false);
+ hbox->add_child(prop_name);
+ prop_names.push_back(prop_name);
+
+ p_properties[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbox->add_child(p_properties[i]);
bool res_prop = Object::cast_to<EditorPropertyResource>(p_properties[i]);
if (res_prop) {
- p_properties[i]->connect("resource_selected", this, "_resource_selected");
+ p_properties[i]->connect_compat("resource_selected", this, "_resource_selected");
}
- properties[i]->connect("property_changed", this, "_property_changed");
+ properties[i]->connect_compat("property_changed", this, "_property_changed");
properties[i]->set_object_and_property(node.ptr(), p_names[i]);
properties[i]->update_property();
properties[i]->set_name_split_ratio(0);
}
- node->connect("changed", this, "_node_changed");
- node->connect("editor_refresh_request", this, "_refresh_request", varray(), CONNECT_DEFERRED);
+ node->connect_compat("changed", this, "_node_changed");
+ node->connect_compat("editor_refresh_request", this, "_refresh_request", varray(), CONNECT_DEFERRED);
}
static void _bind_methods() {
@@ -3001,6 +3074,7 @@ public:
ClassDB::bind_method("_refresh_request", &VisualShaderNodePluginDefaultEditor::_refresh_request);
ClassDB::bind_method("_resource_selected", &VisualShaderNodePluginDefaultEditor::_resource_selected);
ClassDB::bind_method("_open_inspector", &VisualShaderNodePluginDefaultEditor::_open_inspector);
+ ClassDB::bind_method("_show_prop_names", &VisualShaderNodePluginDefaultEditor::_show_prop_names);
}
};
@@ -3157,7 +3231,7 @@ EditorPropertyShaderMode::EditorPropertyShaderMode() {
options->set_clip_text(true);
add_child(options);
add_focusable(options);
- options->connect("item_selected", this, "_option_selected");
+ options->connect_compat("item_selected", this, "_option_selected");
}
bool EditorInspectorShaderModePlugin::can_handle(Object *p_object) {
@@ -3230,7 +3304,7 @@ void VisualShaderNodePortPreview::_shader_changed() {
void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) {
shader = p_shader;
- shader->connect("changed", this, "_shader_changed");
+ shader->connect_compat("changed", this, "_shader_changed");
type = p_type;
port = p_port;
node = p_node;
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 5197f8c77f..8919690ada 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -94,6 +94,7 @@ class VisualShaderEditor : public VBoxContainer {
AcceptDialog *alert;
LineEdit *node_filter;
RichTextLabel *node_desc;
+ Label *highend_label;
void _tools_menu_option(int p_idx);
void _show_members_dialog(bool at_mouse_pos);
@@ -103,7 +104,6 @@ class VisualShaderEditor : public VBoxContainer {
struct AddOption {
String name;
String category;
- String sub_category;
String type;
String description;
int sub_func;
@@ -115,12 +115,12 @@ class VisualShaderEditor : public VBoxContainer {
float value;
bool highend;
bool is_custom;
+ int temp_idx;
AddOption(const String &p_name = String(), const String &p_category = String(), const String &p_sub_category = String(), const String &p_type = String(), const String &p_description = String(), int p_sub_func = -1, int p_return_type = -1, int p_mode = -1, int p_func = -1, float p_value = -1, bool p_highend = false) {
name = p_name;
type = p_type;
- category = p_category;
- sub_category = p_sub_category;
+ category = p_category + "/" + p_sub_category;
description = p_description;
sub_func = p_sub_func;
return_type = p_return_type;
@@ -134,8 +134,7 @@ class VisualShaderEditor : public VBoxContainer {
AddOption(const String &p_name, const String &p_category, const String &p_sub_category, const String &p_type, const String &p_description, const String &p_sub_func, int p_return_type = -1, int p_mode = -1, int p_func = -1, float p_value = -1, bool p_highend = false) {
name = p_name;
type = p_type;
- category = p_category;
- sub_category = p_sub_category;
+ category = p_category + "/" + p_sub_category;
description = p_description;
sub_func = 0;
sub_func_str = p_sub_func;
@@ -147,6 +146,12 @@ class VisualShaderEditor : public VBoxContainer {
is_custom = false;
}
};
+ struct _OptionComparator {
+
+ _FORCE_INLINE_ bool operator()(const AddOption &a, const AddOption &b) const {
+ return a.category.count("/") > b.category.count("/") || (a.category + "/" + a.name).naturalnocasecmp_to(b.category + "/" + b.name) < 0;
+ }
+ };
Vector<AddOption> add_options;
int texture_node_option_idx;
@@ -264,7 +269,7 @@ public:
static VisualShaderEditor *get_singleton() { return singleton; }
void clear_custom_types();
- void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, const String &p_subcategory);
+ void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend);
virtual Size2 get_minimum_size() const;
void edit(VisualShader *p_visual_shader);