summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp40
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp53
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp82
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp65
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp96
-rw-r--r--editor/plugins/animation_player_editor_plugin.h4
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp76
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp12
-rw-r--r--editor/plugins/animation_tree_player_editor_plugin.cpp1451
-rw-r--r--editor/plugins/animation_tree_player_editor_plugin.h184
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp167
-rw-r--r--editor/plugins/asset_library_editor_plugin.h23
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp22
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.cpp2
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.h2
-rw-r--r--editor/plugins/camera_editor_plugin.cpp4
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp375
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h14
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp45
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.h4
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp10
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp26
-rw-r--r--editor/plugins/cpu_particles_editor_plugin.cpp15
-rw-r--r--editor/plugins/cpu_particles_editor_plugin.h1
-rw-r--r--editor/plugins/curve_editor_plugin.cpp33
-rw-r--r--editor/plugins/curve_editor_plugin.h2
-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.cpp121
-rw-r--r--editor/plugins/editor_preview_plugins.h22
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp87
-rw-r--r--editor/plugins/gi_probe_editor_plugin.h6
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp7
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp15
-rw-r--r--editor/plugins/item_list_editor_plugin.h16
-rw-r--r--editor/plugins/material_editor_plugin.cpp30
-rw-r--r--editor/plugins/material_editor_plugin.h4
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp5
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.cpp94
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.h4
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp18
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp27
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp4
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h2
-rw-r--r--editor/plugins/particles_2d_editor_plugin.cpp39
-rw-r--r--editor/plugins/particles_editor_plugin.cpp77
-rw-r--r--editor/plugins/particles_editor_plugin.h6
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp39
-rw-r--r--editor/plugins/path_editor_plugin.cpp30
-rw-r--r--editor/plugins/physical_bone_plugin.cpp3
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp122
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h10
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp15
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp18
-rw-r--r--editor/plugins/script_editor_plugin.cpp334
-rw-r--r--editor/plugins/script_editor_plugin.h24
-rw-r--r--editor/plugins/script_text_editor.cpp156
-rw-r--r--editor/plugins/script_text_editor.h5
-rw-r--r--editor/plugins/shader_editor_plugin.cpp41
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/skeleton_editor_plugin.cpp15
-rw-r--r--editor/plugins/skeleton_ik_editor_plugin.cpp15
-rw-r--r--editor/plugins/skeleton_ik_editor_plugin.h1
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp495
-rw-r--r--editor/plugins/spatial_editor_plugin.h36
-rw-r--r--editor/plugins/sprite_editor_plugin.cpp34
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp105
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h2
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp9
-rw-r--r--editor/plugins/text_editor.cpp43
-rw-r--r--editor/plugins/text_editor.h5
-rw-r--r--editor/plugins/texture_editor_plugin.cpp9
-rw-r--r--editor/plugins/texture_editor_plugin.h6
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp63
-rw-r--r--editor/plugins/theme_editor_plugin.cpp31
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp133
-rw-r--r--editor/plugins/tile_map_editor_plugin.h8
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp189
-rw-r--r--editor/plugins/tile_set_editor_plugin.h14
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp34
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp737
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h34
82 files changed, 2318 insertions, 3994 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index c8a36a3a99..8d5444db73 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -150,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) {
@@ -209,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("node_removed", callable_mp(this, &AbstractPolygon2DEditor::_node_removed));
+ create_resource->connect("confirmed", callable_mp(this, &AbstractPolygon2DEditor::_create_resource));
} break;
}
}
@@ -256,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();
@@ -533,7 +533,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
if (k.is_valid() && k->is_pressed()) {
- if (k->get_scancode() == KEY_DELETE || k->get_scancode() == KEY_BACKSPACE) {
+ if (k->get_keycode() == KEY_DELETE || k->get_keycode() == KEY_BACKSPACE) {
if (wip_active && selected_point.polygon == -1) {
@@ -555,10 +555,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
}
}
- } else if (wip_active && k->get_scancode() == KEY_ENTER) {
+ } else if (wip_active && k->get_keycode() == KEY_ENTER) {
_wip_close();
- } else if (wip_active && k->get_scancode() == KEY_ESCAPE) {
+ } else if (wip_active && k->get_keycode() == KEY_ESCAPE) {
_wip_cancel();
}
}
@@ -573,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();
@@ -584,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) {
@@ -612,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));
}
}
@@ -636,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));
}
}
@@ -661,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);
}
}
@@ -695,15 +695,11 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) {
}
void AbstractPolygon2DEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_node_removed"), &AbstractPolygon2DEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_menu_option"), &AbstractPolygon2DEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_create_resource"), &AbstractPolygon2DEditor::_create_resource);
}
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)) {
@@ -744,7 +740,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();
@@ -777,7 +773,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);
@@ -820,17 +816,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("pressed", callable_mp(this, &AbstractPolygon2DEditor::_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("pressed", callable_mp(this, &AbstractPolygon2DEditor::_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("pressed", callable_mp(this, &AbstractPolygon2DEditor::_menu_option), varray(MODE_DELETE));
button_delete->set_toggle_mode(true);
create_resource = memnew(ConfirmationDialog);
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index d743d1ac2f..7916ac71ea 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -42,7 +42,7 @@ StringName AnimationNodeBlendSpace1DEditor::get_blend_position_path() const {
void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
- if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && !k->is_echo()) {
+ if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) {
if (selected_point != -1) {
_erase_selected();
accept_event();
@@ -202,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();
@@ -568,25 +568,10 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
}
void AnimationNodeBlendSpace1DEditor::_bind_methods() {
- ClassDB::bind_method("_blend_space_gui_input", &AnimationNodeBlendSpace1DEditor::_blend_space_gui_input);
- ClassDB::bind_method("_blend_space_draw", &AnimationNodeBlendSpace1DEditor::_blend_space_draw);
- ClassDB::bind_method("_config_changed", &AnimationNodeBlendSpace1DEditor::_config_changed);
- ClassDB::bind_method("_labels_changed", &AnimationNodeBlendSpace1DEditor::_labels_changed);
ClassDB::bind_method("_update_space", &AnimationNodeBlendSpace1DEditor::_update_space);
- ClassDB::bind_method("_snap_toggled", &AnimationNodeBlendSpace1DEditor::_snap_toggled);
- ClassDB::bind_method("_tool_switch", &AnimationNodeBlendSpace1DEditor::_tool_switch);
- ClassDB::bind_method("_erase_selected", &AnimationNodeBlendSpace1DEditor::_erase_selected);
ClassDB::bind_method("_update_tool_erase", &AnimationNodeBlendSpace1DEditor::_update_tool_erase);
- ClassDB::bind_method("_edit_point_pos", &AnimationNodeBlendSpace1DEditor::_edit_point_pos);
-
- ClassDB::bind_method("_add_menu_type", &AnimationNodeBlendSpace1DEditor::_add_menu_type);
- ClassDB::bind_method("_add_animation_type", &AnimationNodeBlendSpace1DEditor::_add_animation_type);
ClassDB::bind_method("_update_edited_point_pos", &AnimationNodeBlendSpace1DEditor::_update_edited_point_pos);
-
- ClassDB::bind_method("_open_editor", &AnimationNodeBlendSpace1DEditor::_open_editor);
-
- ClassDB::bind_method("_file_opened", &AnimationNodeBlendSpace1DEditor::_file_opened);
}
bool AnimationNodeBlendSpace1DEditor::can_edit(const Ref<AnimationNode> &p_node) {
@@ -622,28 +607,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("pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_erase_selected));
top_hb->add_child(memnew(VSeparator));
@@ -652,7 +637,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("pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_snap_toggled));
snap_value = memnew(SpinBox);
top_hb->add_child(snap_value);
@@ -670,12 +655,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("value_changed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_open_editor), varray(), CONNECT_DEFERRED);
edit_hb->hide();
open_editor->hide();
@@ -691,8 +676,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("gui_input", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_blend_space_gui_input));
+ blend_space_draw->connect("draw", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_blend_space_draw));
blend_space_draw->set_focus_mode(FOCUS_ALL);
panel->add_child(blend_space_draw);
@@ -724,10 +709,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("value_changed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_config_changed));
+ min_value->connect("value_changed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_config_changed));
+ max_value->connect("value_changed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_config_changed));
+ label_value->connect("text_changed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_labels_changed));
error_panel = memnew(PanelContainer);
add_child(error_panel);
@@ -740,18 +725,18 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed", this, "_add_menu_type");
+ menu->connect("id_pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_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("index_pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_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("file_selected", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
selected_point = -1;
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index dc7754ba9a..663f2dde05 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -55,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("triangles_updated", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_blend_space_changed));
}
blend_space = p_node;
if (!blend_space.is_null()) {
- blend_space->connect("triangles_updated", this, "_blend_space_changed");
+ blend_space->connect("triangles_updated", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_blend_space_changed));
_update_space();
}
}
@@ -73,7 +73,7 @@ StringName AnimationNodeBlendSpace2DEditor::get_blend_position_path() const {
void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
- if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && !k->is_echo()) {
+ if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) {
if (selected_point != -1 || selected_triangle != -1) {
_erase_selected();
accept_event();
@@ -410,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();
@@ -497,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;
@@ -553,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
@@ -825,30 +825,12 @@ void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() {
void AnimationNodeBlendSpace2DEditor::_bind_methods() {
- ClassDB::bind_method("_blend_space_gui_input", &AnimationNodeBlendSpace2DEditor::_blend_space_gui_input);
- ClassDB::bind_method("_blend_space_draw", &AnimationNodeBlendSpace2DEditor::_blend_space_draw);
- ClassDB::bind_method("_config_changed", &AnimationNodeBlendSpace2DEditor::_config_changed);
- ClassDB::bind_method("_labels_changed", &AnimationNodeBlendSpace2DEditor::_labels_changed);
ClassDB::bind_method("_update_space", &AnimationNodeBlendSpace2DEditor::_update_space);
- ClassDB::bind_method("_snap_toggled", &AnimationNodeBlendSpace2DEditor::_snap_toggled);
- ClassDB::bind_method("_tool_switch", &AnimationNodeBlendSpace2DEditor::_tool_switch);
- ClassDB::bind_method("_erase_selected", &AnimationNodeBlendSpace2DEditor::_erase_selected);
ClassDB::bind_method("_update_tool_erase", &AnimationNodeBlendSpace2DEditor::_update_tool_erase);
- ClassDB::bind_method("_edit_point_pos", &AnimationNodeBlendSpace2DEditor::_edit_point_pos);
-
- ClassDB::bind_method("_add_menu_type", &AnimationNodeBlendSpace2DEditor::_add_menu_type);
- ClassDB::bind_method("_add_animation_type", &AnimationNodeBlendSpace2DEditor::_add_animation_type);
ClassDB::bind_method("_update_edited_point_pos", &AnimationNodeBlendSpace2DEditor::_update_edited_point_pos);
- ClassDB::bind_method("_open_editor", &AnimationNodeBlendSpace2DEditor::_open_editor);
-
ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendSpace2DEditor::_removed_from_graph);
-
- ClassDB::bind_method("_auto_triangles_toggled", &AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled);
- ClassDB::bind_method("_blend_space_changed", &AnimationNodeBlendSpace2DEditor::_blend_space_changed);
-
- ClassDB::bind_method("_file_opened", &AnimationNodeBlendSpace2DEditor::_file_opened);
}
AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = NULL;
@@ -870,42 +852,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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled));
auto_triangles->set_toggle_mode(true);
auto_triangles->set_tooltip(TTR("Generate blend triangles automatically (instead of manually)"));
@@ -916,7 +898,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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_snap_toggled));
snap_x = memnew(SpinBox);
top_hb->add_child(snap_x);
@@ -937,7 +919,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("item_selected", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed));
edit_hb = memnew(HBoxContainer);
top_hb->add_child(edit_hb);
@@ -948,17 +930,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("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_open_editor), varray(), CONNECT_DEFERRED);
edit_hb->hide();
open_editor->hide();
@@ -999,8 +981,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("gui_input", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_blend_space_gui_input));
+ blend_space_draw->connect("draw", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_blend_space_draw));
blend_space_draw->set_focus_mode(FOCUS_ALL);
panel->add_child(blend_space_draw);
@@ -1029,14 +1011,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("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed));
+ snap_y->connect("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed));
+ max_x_value->connect("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed));
+ min_x_value->connect("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed));
+ max_y_value->connect("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed));
+ min_y_value->connect("value_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed));
+ label_x->connect("text_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_labels_changed));
+ label_y->connect("text_changed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_labels_changed));
error_panel = memnew(PanelContainer);
add_child(error_panel);
@@ -1050,18 +1032,18 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed", this, "_add_menu_type");
+ menu->connect("id_pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("index_pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_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("file_selected", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
selected_point = -1;
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 2de224c043..5e53adf471 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -146,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), CONNECT_DEFERRED);
+ name->connect("text_entered", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode));
+ name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_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("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request), varray(E->get()), CONNECT_DEFERRED);
}
for (int i = 0; i < agnode->get_input_count(); i++) {
@@ -173,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("property_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_property_changed));
node->add_child(prop);
visible_properties.push_back(prop);
}
}
- node->connect("dragged", this, "_node_dragged", varray(E->get()));
+ node->connect("dragged", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_dragged), varray(E->get()));
if (AnimationTreeEditor::get_singleton()->can_edit(agnode)) {
node->add_child(memnew(HSeparator));
@@ -187,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("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E->get()), CONNECT_DEFERRED);
open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER);
}
@@ -198,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("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E->get()), CONNECT_DEFERRED);
edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER);
}
@@ -238,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("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E->get()), CONNECT_DEFERRED);
}
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
@@ -312,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;
}
@@ -799,28 +799,7 @@ void AnimationNodeBlendTreeEditor::_scroll_changed(const Vector2 &p_scroll) {
void AnimationNodeBlendTreeEditor::_bind_methods() {
ClassDB::bind_method("_update_graph", &AnimationNodeBlendTreeEditor::_update_graph);
- ClassDB::bind_method("_add_node", &AnimationNodeBlendTreeEditor::_add_node);
- ClassDB::bind_method("_node_dragged", &AnimationNodeBlendTreeEditor::_node_dragged);
- ClassDB::bind_method("_node_renamed", &AnimationNodeBlendTreeEditor::_node_renamed);
- ClassDB::bind_method("_node_renamed_focus_out", &AnimationNodeBlendTreeEditor::_node_renamed_focus_out);
- ClassDB::bind_method("_connection_request", &AnimationNodeBlendTreeEditor::_connection_request);
- ClassDB::bind_method("_disconnection_request", &AnimationNodeBlendTreeEditor::_disconnection_request);
- ClassDB::bind_method("_node_selected", &AnimationNodeBlendTreeEditor::_node_selected);
- ClassDB::bind_method("_open_in_editor", &AnimationNodeBlendTreeEditor::_open_in_editor);
- ClassDB::bind_method("_scroll_changed", &AnimationNodeBlendTreeEditor::_scroll_changed);
- ClassDB::bind_method("_delete_request", &AnimationNodeBlendTreeEditor::_delete_request);
- ClassDB::bind_method("_delete_nodes_request", &AnimationNodeBlendTreeEditor::_delete_nodes_request);
- ClassDB::bind_method("_popup_request", &AnimationNodeBlendTreeEditor::_popup_request);
- ClassDB::bind_method("_edit_filters", &AnimationNodeBlendTreeEditor::_edit_filters);
ClassDB::bind_method("_update_filters", &AnimationNodeBlendTreeEditor::_update_filters);
- ClassDB::bind_method("_filter_edited", &AnimationNodeBlendTreeEditor::_filter_edited);
- ClassDB::bind_method("_filter_toggled", &AnimationNodeBlendTreeEditor::_filter_toggled);
- ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendTreeEditor::_removed_from_graph);
- ClassDB::bind_method("_property_changed", &AnimationNodeBlendTreeEditor::_property_changed);
- ClassDB::bind_method("_file_opened", &AnimationNodeBlendTreeEditor::_file_opened);
- ClassDB::bind_method("_update_options_menu", &AnimationNodeBlendTreeEditor::_update_options_menu);
-
- ClassDB::bind_method("_anim_selected", &AnimationNodeBlendTreeEditor::_anim_selected);
}
AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = NULL;
@@ -911,7 +890,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("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph));
}
blend_tree = p_node;
@@ -919,7 +898,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("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph));
_update_graph();
}
@@ -936,12 +915,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("connection_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_connection_request), varray(), CONNECT_DEFERRED);
+ graph->connect("disconnection_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_disconnection_request), varray(), CONNECT_DEFERRED);
+ graph->connect("node_selected", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_selected));
+ graph->connect("scroll_offset_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_scroll_changed));
+ graph->connect("delete_nodes_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_nodes_request));
+ graph->connect("popup_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_popup_request));
VSeparator *vs = memnew(VSeparator);
graph->get_zoom_hbox()->add_child(vs);
@@ -951,8 +930,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("id_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_add_node));
+ add_node->connect("about_to_show", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu));
add_options.push_back(AddOption("Animation", "AnimationNodeAnimation"));
add_options.push_back(AddOption("OneShot", "AnimationNodeOneShot"));
@@ -984,19 +963,19 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
filter_enabled = memnew(CheckBox);
filter_enabled->set_text(TTR("Enable Filtering"));
- filter_enabled->connect("pressed", this, "_filter_toggled");
+ filter_enabled->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_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("item_edited", callable_mp(this, &AnimationNodeBlendTreeEditor::_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("file_selected", callable_mp(this, &AnimationNodeBlendTreeEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
}
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 5e69ce4e69..af12335a27 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -38,10 +38,8 @@
#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"
@@ -99,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("id_pressed", callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu));
- onion_skinning->get_popup()->connect("id_pressed", this, "_onion_skinning_menu");
+ onion_skinning->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu));
- blend_editor.next->connect("item_selected", this, "_blend_editor_next_changed");
+ blend_editor.next->connect("item_selected", callable_mp(this, &AnimationPlayerEditor::_blend_editor_next_changed));
- get_tree()->connect("node_removed", this, "_node_removed");
+ get_tree()->connect("node_removed", callable_mp(this, &AnimationPlayerEditor::_node_removed));
add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel"));
} break;
@@ -375,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;
}
@@ -1271,7 +1268,7 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventKey> k = p_ev;
if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) {
- switch (k->get_scancode()) {
+ switch (k->get_keycode()) {
case KEY_A: {
if (!k->get_shift())
@@ -1322,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);
}
@@ -1373,6 +1369,10 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() {
call_deferred("_prepare_onion_layers_2");
}
+void AnimationPlayerEditor::_prepare_onion_layers_1_deferred() {
+ call_deferred("_prepare_onion_layers_1");
+}
+
void AnimationPlayerEditor::_prepare_onion_layers_2() {
Ref<Animation> anim = player->get_animation(player->get_assigned_animation());
@@ -1505,16 +1505,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("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) {
+ get_tree()->connect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred));
}
}
void AnimationPlayerEditor::_stop_onion_skinning() {
- if (get_tree()->is_connected("idle_frame", this, "call_deferred")) {
+ if (get_tree()->is_connected("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) {
- get_tree()->disconnect("idle_frame", this, "call_deferred");
+ get_tree()->disconnect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred));
_free_onion_layers();
@@ -1531,44 +1531,22 @@ void AnimationPlayerEditor::_pin_pressed() {
void AnimationPlayerEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_node_removed"), &AnimationPlayerEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_play_pressed"), &AnimationPlayerEditor::_play_pressed);
- ClassDB::bind_method(D_METHOD("_play_from_pressed"), &AnimationPlayerEditor::_play_from_pressed);
- ClassDB::bind_method(D_METHOD("_play_bw_pressed"), &AnimationPlayerEditor::_play_bw_pressed);
- ClassDB::bind_method(D_METHOD("_play_bw_from_pressed"), &AnimationPlayerEditor::_play_bw_from_pressed);
- ClassDB::bind_method(D_METHOD("_stop_pressed"), &AnimationPlayerEditor::_stop_pressed);
- ClassDB::bind_method(D_METHOD("_autoplay_pressed"), &AnimationPlayerEditor::_autoplay_pressed);
- ClassDB::bind_method(D_METHOD("_animation_selected"), &AnimationPlayerEditor::_animation_selected);
- ClassDB::bind_method(D_METHOD("_animation_name_edited"), &AnimationPlayerEditor::_animation_name_edited);
ClassDB::bind_method(D_METHOD("_animation_new"), &AnimationPlayerEditor::_animation_new);
ClassDB::bind_method(D_METHOD("_animation_rename"), &AnimationPlayerEditor::_animation_rename);
ClassDB::bind_method(D_METHOD("_animation_load"), &AnimationPlayerEditor::_animation_load);
ClassDB::bind_method(D_METHOD("_animation_remove"), &AnimationPlayerEditor::_animation_remove);
- ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"), &AnimationPlayerEditor::_animation_remove_confirmed);
ClassDB::bind_method(D_METHOD("_animation_blend"), &AnimationPlayerEditor::_animation_blend);
ClassDB::bind_method(D_METHOD("_animation_edit"), &AnimationPlayerEditor::_animation_edit);
ClassDB::bind_method(D_METHOD("_animation_resource_edit"), &AnimationPlayerEditor::_animation_resource_edit);
- ClassDB::bind_method(D_METHOD("_dialog_action"), &AnimationPlayerEditor::_dialog_action);
- ClassDB::bind_method(D_METHOD("_seek_value_changed"), &AnimationPlayerEditor::_seek_value_changed, DEFVAL(true));
ClassDB::bind_method(D_METHOD("_animation_player_changed"), &AnimationPlayerEditor::_animation_player_changed);
- ClassDB::bind_method(D_METHOD("_blend_edited"), &AnimationPlayerEditor::_blend_edited);
- ClassDB::bind_method(D_METHOD("_scale_changed"), &AnimationPlayerEditor::_scale_changed);
ClassDB::bind_method(D_METHOD("_list_changed"), &AnimationPlayerEditor::_list_changed);
- ClassDB::bind_method(D_METHOD("_animation_key_editor_seek"), &AnimationPlayerEditor::_animation_key_editor_seek);
- ClassDB::bind_method(D_METHOD("_animation_key_editor_anim_len_changed"), &AnimationPlayerEditor::_animation_key_editor_anim_len_changed);
ClassDB::bind_method(D_METHOD("_animation_duplicate"), &AnimationPlayerEditor::_animation_duplicate);
- ClassDB::bind_method(D_METHOD("_blend_editor_next_changed"), &AnimationPlayerEditor::_blend_editor_next_changed);
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &AnimationPlayerEditor::_unhandled_key_input);
- ClassDB::bind_method(D_METHOD("_animation_tool_menu"), &AnimationPlayerEditor::_animation_tool_menu);
- ClassDB::bind_method(D_METHOD("_onion_skinning_menu"), &AnimationPlayerEditor::_onion_skinning_menu);
- ClassDB::bind_method(D_METHOD("_editor_visibility_changed"), &AnimationPlayerEditor::_editor_visibility_changed);
ClassDB::bind_method(D_METHOD("_prepare_onion_layers_1"), &AnimationPlayerEditor::_prepare_onion_layers_1);
ClassDB::bind_method(D_METHOD("_prepare_onion_layers_2"), &AnimationPlayerEditor::_prepare_onion_layers_2);
ClassDB::bind_method(D_METHOD("_start_onion_skinning"), &AnimationPlayerEditor::_start_onion_skinning);
ClassDB::bind_method(D_METHOD("_stop_onion_skinning"), &AnimationPlayerEditor::_stop_onion_skinning);
-
- ClassDB::bind_method(D_METHOD("_pin_pressed"), &AnimationPlayerEditor::_pin_pressed);
}
AnimationPlayerEditor *AnimationPlayerEditor::singleton = NULL;
@@ -1629,13 +1607,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("confirmed", callable_mp(this, &AnimationPlayerEditor::_animation_remove_confirmed));
tool_anim = memnew(MenuButton);
tool_anim->set_flat(false);
@@ -1680,7 +1654,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("pressed", callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu), varray(ONION_SKINNING_ENABLE));
hb->add_child(onion_toggle);
onion_skinning = memnew(MenuButton);
@@ -1706,7 +1680,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("pressed", callable_mp(this, &AnimationPlayerEditor::_pin_pressed));
file = memnew(EditorFileDialog);
add_child(file);
@@ -1730,7 +1704,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("confirmed", callable_mp(this, &AnimationPlayerEditor::_animation_name_edited));
blend_editor.dialog = memnew(AcceptDialog);
add_child(blend_editor.dialog);
@@ -1746,21 +1720,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("item_edited", callable_mp(this, &AnimationPlayerEditor::_blend_edited));
- autoplay->connect("pressed", this, "_autoplay_pressed");
+ autoplay->connect("pressed", callable_mp(this, &AnimationPlayerEditor::_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("pressed", callable_mp(this, &AnimationPlayerEditor::_play_pressed));
+ play_from->connect("pressed", callable_mp(this, &AnimationPlayerEditor::_play_from_pressed));
+ play_bw->connect("pressed", callable_mp(this, &AnimationPlayerEditor::_play_bw_pressed));
+ play_bw_from->connect("pressed", callable_mp(this, &AnimationPlayerEditor::_play_bw_from_pressed));
+ stop->connect("pressed", callable_mp(this, &AnimationPlayerEditor::_stop_pressed));
- animation->connect("item_selected", this, "_animation_selected", Vector<Variant>(), true);
+ animation->connect("item_selected", callable_mp(this, &AnimationPlayerEditor::_animation_selected));
- 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("file_selected", callable_mp(this, &AnimationPlayerEditor::_dialog_action));
+ frame->connect("value_changed", callable_mp(this, &AnimationPlayerEditor::_seek_value_changed), make_binds(true));
+ scale->connect("text_entered", callable_mp(this, &AnimationPlayerEditor::_scale_changed));
renaming = false;
last_active = false;
@@ -1770,14 +1744,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("timeline_changed", callable_mp(this, &AnimationPlayerEditor::_animation_key_editor_seek));
+ track_editor->connect("animation_len_changed", callable_mp(this, &AnimationPlayerEditor::_animation_key_editor_anim_len_changed));
_update_player();
// Onion skinning.
- track_editor->connect("visibility_changed", this, "_editor_visibility_changed");
+ track_editor->connect("visibility_changed", callable_mp(this, &AnimationPlayerEditor::_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 55c2f365ce..1abefad635 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -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;
@@ -210,6 +209,7 @@ class AnimationPlayerEditor : public VBoxContainer {
void _allocate_onion_layers();
void _free_onion_layers();
void _prepare_onion_layers_1();
+ void _prepare_onion_layers_1_deferred();
void _prepare_onion_layers_2();
void _start_onion_skinning();
void _stop_onion_skinning();
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 2a582a1249..cae959e1f4 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -69,7 +69,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
return;
Ref<InputEventKey> k = p_event;
- if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && !k->is_echo()) {
+ if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) {
if (selected_node != StringName() || selected_transition_to != StringName() || selected_transition_from != StringName()) {
_erase_selected();
accept_event();
@@ -514,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"),
@@ -524,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();
@@ -578,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;
@@ -686,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
@@ -796,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);
@@ -918,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"));
@@ -1242,27 +1234,11 @@ void AnimationNodeStateMachineEditor::_update_mode() {
void AnimationNodeStateMachineEditor::_bind_methods() {
- ClassDB::bind_method("_state_machine_gui_input", &AnimationNodeStateMachineEditor::_state_machine_gui_input);
- ClassDB::bind_method("_state_machine_draw", &AnimationNodeStateMachineEditor::_state_machine_draw);
- ClassDB::bind_method("_state_machine_pos_draw", &AnimationNodeStateMachineEditor::_state_machine_pos_draw);
ClassDB::bind_method("_update_graph", &AnimationNodeStateMachineEditor::_update_graph);
- ClassDB::bind_method("_add_menu_type", &AnimationNodeStateMachineEditor::_add_menu_type);
- ClassDB::bind_method("_add_animation_type", &AnimationNodeStateMachineEditor::_add_animation_type);
-
- ClassDB::bind_method("_name_edited", &AnimationNodeStateMachineEditor::_name_edited);
- ClassDB::bind_method("_name_edited_focus_out", &AnimationNodeStateMachineEditor::_name_edited_focus_out);
-
ClassDB::bind_method("_removed_from_graph", &AnimationNodeStateMachineEditor::_removed_from_graph);
ClassDB::bind_method("_open_editor", &AnimationNodeStateMachineEditor::_open_editor);
- ClassDB::bind_method("_scroll_changed", &AnimationNodeStateMachineEditor::_scroll_changed);
-
- ClassDB::bind_method("_erase_selected", &AnimationNodeStateMachineEditor::_erase_selected);
- ClassDB::bind_method("_autoplay_selected", &AnimationNodeStateMachineEditor::_autoplay_selected);
- ClassDB::bind_method("_end_selected", &AnimationNodeStateMachineEditor::_end_selected);
- ClassDB::bind_method("_update_mode", &AnimationNodeStateMachineEditor::_update_mode);
- ClassDB::bind_method("_file_opened", &AnimationNodeStateMachineEditor::_file_opened);
}
AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = NULL;
@@ -1284,21 +1260,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("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_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("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_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("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_update_mode), varray(), CONNECT_DEFERRED);
tool_erase_hb = memnew(HBoxContainer);
top_hb->add_child(tool_erase_hb);
@@ -1306,7 +1282,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("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_erase_selected));
tool_erase->set_disabled(true);
tool_erase_hb->add_child(memnew(VSeparator));
@@ -1314,13 +1290,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("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_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("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_end_selected));
tool_end->set_disabled(true);
top_hb->add_child(memnew(VSeparator));
@@ -1341,26 +1317,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("gui_input", callable_mp(this, &AnimationNodeStateMachineEditor::_state_machine_gui_input));
+ state_machine_draw->connect("draw", callable_mp(this, &AnimationNodeStateMachineEditor::_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("draw", callable_mp(this, &AnimationNodeStateMachineEditor::_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("value_changed", callable_mp(this, &AnimationNodeStateMachineEditor::_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("value_changed", callable_mp(this, &AnimationNodeStateMachineEditor::_scroll_changed));
error_panel = memnew(PanelContainer);
add_child(error_panel);
@@ -1374,25 +1350,25 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed", this, "_add_menu_type");
+ menu->connect("id_pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_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("index_pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_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("text_entered", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited));
+ name_edit->connect("focus_exited", callable_mp(this, &AnimationNodeStateMachineEditor::_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("file_selected", callable_mp(this, &AnimationNodeStateMachineEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
over_text = false;
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 8dc7e4638d..c9706a7f68 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -59,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();
}
}
@@ -85,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("pressed", callable_mp(this, &AnimationTreeEditor::_path_button_pressed), varray(-1));
path_hb->add_child(b);
for (int i = 0; i < button_path.size(); i++) {
b = memnew(Button);
@@ -95,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("pressed", callable_mp(this, &AnimationTreeEditor::_path_button_pressed), varray(i));
}
}
@@ -128,7 +128,7 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
}
}
} else {
- current_root = 0;
+ current_root = ObjectID();
edited_path = button_path;
}
@@ -151,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();
}
@@ -167,7 +167,6 @@ void AnimationTreeEditor::_notification(int p_what) {
}
void AnimationTreeEditor::_bind_methods() {
- ClassDB::bind_method("_path_button_pressed", &AnimationTreeEditor::_path_button_pressed);
}
AnimationTreeEditor *AnimationTreeEditor::singleton = NULL;
@@ -242,7 +241,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);
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 2b365feec5..0000000000
--- a/editor/plugins/animation_tree_player_editor_plugin.cpp
+++ /dev/null
@@ -1,1451 +0,0 @@
-/*************************************************************************/
-/* animation_tree_player_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 "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 "editor/editor_scale.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);
- }
-
- const Ref<Font> f = get_font("font", "Label");
- const Point2 status_offset = Point2(5, 25) * EDSCALE + Point2(0, f->get_ascent());
-
- switch (anim_tree->get_last_error()) {
-
- case AnimationTreePlayer::CONNECT_OK: {
-
- f->draw(get_canvas_item(), status_offset, TTR("Animation tree is valid."), Color(0, 1, 0.6, 0.8));
- } break;
- default: {
-
- f->draw(get_canvas_item(), status_offset, 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) * EDSCALE);
- 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) * EDSCALE);
-
- 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 d3fd6ae362..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-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 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 4f73a5eaea..80b7e6ffc8 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -31,6 +31,8 @@
#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"
@@ -48,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);
@@ -84,9 +86,6 @@ void EditorAssetLibraryItem::_author_clicked() {
void EditorAssetLibraryItem::_bind_methods() {
ClassDB::bind_method("set_image", &EditorAssetLibraryItem::set_image);
- ClassDB::bind_method("_asset_clicked", &EditorAssetLibraryItem::_asset_clicked);
- ClassDB::bind_method("_category_clicked", &EditorAssetLibraryItem::_category_clicked);
- ClassDB::bind_method("_author_clicked", &EditorAssetLibraryItem::_author_clicked);
ADD_SIGNAL(MethodInfo("asset_selected"));
ADD_SIGNAL(MethodInfo("category_selected"));
ADD_SIGNAL(MethodInfo("author_selected"));
@@ -110,7 +109,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("pressed", callable_mp(this, &EditorAssetLibraryItem::_asset_clicked));
hb->add_child(icon);
@@ -121,17 +120,17 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
title = memnew(LinkButton);
title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- title->connect("pressed", this, "_asset_clicked");
+ title->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_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("pressed", callable_mp(this, &EditorAssetLibraryItem::_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("pressed", callable_mp(this, &EditorAssetLibraryItem::_author_clicked));
vb->add_child(author);
price = memnew(Label);
@@ -139,13 +138,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) {
@@ -166,9 +163,8 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
// 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();
@@ -209,8 +205,6 @@ void EditorAssetLibraryItemDescription::_notification(int p_what) {
void EditorAssetLibraryItemDescription::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_image"), &EditorAssetLibraryItemDescription::set_image);
- ClassDB::bind_method(D_METHOD("_link_click"), &EditorAssetLibraryItemDescription::_link_click);
- ClassDB::bind_method(D_METHOD("_preview_click"), &EditorAssetLibraryItemDescription::_preview_click);
}
void EditorAssetLibraryItemDescription::_link_click(const String &p_url) {
@@ -264,7 +258,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("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click), varray(p_id));
preview_hb->add_child(preview.button);
if (!p_video) {
preview.image = get_icon("ThumbnailWait", "EditorIcons");
@@ -291,7 +285,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("meta_clicked", callable_mp(this, &EditorAssetLibraryItemDescription::_link_click));
description->add_constant_override("line_separation", Math::round(5 * EDSCALE));
VBoxContainer *previews_vbox = memnew(VBoxContainer);
@@ -322,7 +316,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;
@@ -393,7 +387,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);
@@ -501,11 +495,6 @@ void EditorAssetLibraryItemDownload::_make_request() {
void EditorAssetLibraryItemDownload::_bind_methods() {
- ClassDB::bind_method("_http_download_completed", &EditorAssetLibraryItemDownload::_http_download_completed);
- ClassDB::bind_method("_install", &EditorAssetLibraryItemDownload::_install);
- ClassDB::bind_method("_close", &EditorAssetLibraryItemDownload::_close);
- ClassDB::bind_method("_make_request", &EditorAssetLibraryItemDownload::_make_request);
-
ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
@@ -527,7 +516,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
title->set_h_size_flags(SIZE_EXPAND_FILL);
dismiss = memnew(TextureButton);
- dismiss->connect("pressed", this, "_close");
+ dismiss->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDownload::_close));
title_hb->add_child(dismiss);
title->set_clip_text(true);
@@ -547,11 +536,11 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
install = memnew(Button);
install->set_text(TTR("Install..."));
install->set_disabled(true);
- install->connect("pressed", this, "_install");
+ install->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDownload::_install));
retry = memnew(Button);
retry->set_text(TTR("Retry"));
- retry->connect("pressed", this, "_make_request");
+ retry->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDownload::_make_request));
hb2->add_child(retry);
hb2->add_child(install);
@@ -559,7 +548,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
download = memnew(HTTPRequest);
add_child(download);
- download->connect("request_completed", this, "_http_download_completed");
+ download->connect("request_completed", callable_mp(this, &EditorAssetLibraryItemDownload::_http_download_completed));
download->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
download_error = memnew(AcceptDialog);
@@ -568,7 +557,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
asset_installer = memnew(EditorAssetInstaller);
add_child(asset_installer);
- asset_installer->connect("confirmed", this, "_close");
+ asset_installer->connect("confirmed", callable_mp(this, &EditorAssetLibraryItemDownload::_close));
prev_status = -1;
@@ -622,6 +611,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_keycode_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);
@@ -643,7 +647,7 @@ void EditorAssetLibrary::_install_asset() {
if (templates_only) {
download->set_external_install(true);
- download->connect("install_asset", this, "_install_external_asset");
+ download->connect("install_asset", callable_mp(this, &EditorAssetLibrary::_install_external_asset));
}
}
@@ -695,12 +699,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());
@@ -708,12 +712,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();
@@ -722,17 +726,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 (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.ptr(), len));
+ 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.ptr(), len));
+ image->copy_internals_from(Image::_jpg_mem_loader_func(r, len));
}
}
@@ -775,7 +779,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));
@@ -796,11 +800,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);
}
@@ -812,7 +816,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"));
@@ -878,13 +882,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("request_completed", callable_mp(this, &EditorAssetLibrary::_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();
}
@@ -977,7 +981,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("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(0));
} else {
first->set_disabled(true);
first->set_focus_mode(Control::FOCUS_NONE);
@@ -987,7 +991,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("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(p_page - 1));
} else {
prev->set_disabled(true);
prev->set_focus_mode(Control::FOCUS_NONE);
@@ -1009,7 +1013,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("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(i));
hbc->add_child(current);
}
@@ -1018,7 +1022,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("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(p_page + 1));
} else {
next->set_disabled(true);
next->set_focus_mode(Control::FOCUS_NONE);
@@ -1029,7 +1033,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("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(p_page_count - 1));
} else {
last->set_disabled(true);
last->set_focus_mode(Control::FOCUS_NONE);
@@ -1053,14 +1057,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;
@@ -1196,7 +1200,16 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
library_vb->add_child(asset_bottom_page);
if (result.empty()) {
- library_error->set_text(vformat(TTR("No results for \"%s\"."), filter->get_text()));
+ if (filter->get_text() != String()) {
+ library_error->set_text(
+ vformat(TTR("No results for \"%s\"."), filter->get_text()));
+ } else {
+ // No results, even though the user didn't search for anything specific.
+ // This is typically because the version number changed recently
+ // and no assets compatible with the new version have been published yet.
+ library_error->set_text(
+ vformat(TTR("No results compatible with %s %s."), String(VERSION_SHORT_NAME).capitalize(), String(VERSION_BRANCH)));
+ }
library_error->show();
}
@@ -1215,9 +1228,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("asset_selected", callable_mp(this, &EditorAssetLibrary::_select_asset));
+ item->connect("author_selected", callable_mp(this, &EditorAssetLibrary::_select_author));
+ item->connect("category_selected", callable_mp(this, &EditorAssetLibrary::_select_category));
if (r.has("icon_url") && r["icon_url"] != "") {
_request_image(item->get_instance_id(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
@@ -1248,7 +1261,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("confirmed", callable_mp(this, &EditorAssetLibrary::_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"]);
@@ -1322,21 +1335,7 @@ void EditorAssetLibrary::disable_community_support() {
void EditorAssetLibrary::_bind_methods() {
- 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);
- ClassDB::bind_method("_select_category", &EditorAssetLibrary::_select_category);
- ClassDB::bind_method("_image_request_completed", &EditorAssetLibrary::_image_request_completed);
- ClassDB::bind_method("_search", &EditorAssetLibrary::_search, DEFVAL(0));
- ClassDB::bind_method("_search_text_entered", &EditorAssetLibrary::_search_text_entered);
- ClassDB::bind_method("_install_asset", &EditorAssetLibrary::_install_asset);
- ClassDB::bind_method("_manage_plugins", &EditorAssetLibrary::_manage_plugins);
- ClassDB::bind_method("_asset_open", &EditorAssetLibrary::_asset_open);
- ClassDB::bind_method("_asset_file_selected", &EditorAssetLibrary::_asset_file_selected);
- ClassDB::bind_method("_repository_changed", &EditorAssetLibrary::_repository_changed);
- ClassDB::bind_method("_support_toggled", &EditorAssetLibrary::_support_toggled);
- ClassDB::bind_method("_rerun_search", &EditorAssetLibrary::_rerun_search);
- ClassDB::bind_method("_install_external_asset", &EditorAssetLibrary::_install_external_asset);
+ ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input);
ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
@@ -1359,9 +1358,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("text_entered", callable_mp(this, &EditorAssetLibrary::_search_text_entered));
search = memnew(Button(TTR("Search")));
- search->connect("pressed", this, "_search");
+ search->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), make_binds(0));
search_hb->add_child(search);
if (!p_templates_only)
@@ -1370,12 +1369,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("pressed", callable_mp(this, &EditorAssetLibrary::_asset_open));
Button *plugins = memnew(Button);
plugins->set_text(TTR("Plugins..."));
search_hb->add_child(plugins);
- plugins->connect("pressed", this, "_manage_plugins");
+ plugins->connect("pressed", callable_mp(this, &EditorAssetLibrary::_manage_plugins));
if (p_templates_only) {
open_asset->hide();
@@ -1394,7 +1393,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(sort);
sort->set_h_size_flags(SIZE_EXPAND_FILL);
- sort->connect("item_selected", this, "_rerun_search");
+ sort->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search));
search_hb2->add_child(memnew(VSeparator));
@@ -1403,7 +1402,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("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search));
search_hb2->add_child(memnew(VSeparator));
@@ -1415,7 +1414,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("item_selected", callable_mp(this, &EditorAssetLibrary::_repository_changed));
search_hb2->add_child(repository);
repository->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1430,7 +1429,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("id_pressed", callable_mp(this, &EditorAssetLibrary::_support_toggled));
/////////
@@ -1455,7 +1454,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);
@@ -1487,7 +1485,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("request_completed", callable_mp(this, &EditorAssetLibrary::_http_request_completed));
last_queue_id = 0;
@@ -1505,6 +1503,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
description = NULL;
set_process(true);
+ set_process_unhandled_input(true);
downloads_scroll = memnew(ScrollContainer);
downloads_scroll->set_enable_h_scroll(true);
@@ -1519,7 +1518,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("file_selected", callable_mp(this, &EditorAssetLibrary::_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 aa3c735810..536a855d03 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -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 60cb2ff54d..7a1722c73b 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -39,7 +39,7 @@
void AudioStreamEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", this, "_preview_changed");
+ AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed));
}
if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
@@ -197,14 +197,6 @@ void AudioStreamEditor::edit(Ref<AudioStream> p_stream) {
}
void AudioStreamEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_preview_changed"), &AudioStreamEditor::_preview_changed);
- ClassDB::bind_method(D_METHOD("_play"), &AudioStreamEditor::_play);
- ClassDB::bind_method(D_METHOD("_stop"), &AudioStreamEditor::_stop);
- ClassDB::bind_method(D_METHOD("_on_finished"), &AudioStreamEditor::_on_finished);
- ClassDB::bind_method(D_METHOD("_draw_preview"), &AudioStreamEditor::_draw_preview);
- ClassDB::bind_method(D_METHOD("_draw_indicator"), &AudioStreamEditor::_draw_indicator);
- ClassDB::bind_method(D_METHOD("_on_input_indicator"), &AudioStreamEditor::_on_input_indicator);
}
AudioStreamEditor::AudioStreamEditor() {
@@ -214,7 +206,7 @@ AudioStreamEditor::AudioStreamEditor() {
_dragging = false;
_player = memnew(AudioStreamPlayer);
- _player->connect("finished", this, "_on_finished");
+ _player->connect("finished", callable_mp(this, &AudioStreamEditor::_on_finished));
add_child(_player);
VBoxContainer *vbox = memnew(VBoxContainer);
@@ -223,13 +215,13 @@ AudioStreamEditor::AudioStreamEditor() {
_preview = memnew(ColorRect);
_preview->set_v_size_flags(SIZE_EXPAND_FILL);
- _preview->connect("draw", this, "_draw_preview");
+ _preview->connect("draw", callable_mp(this, &AudioStreamEditor::_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("draw", callable_mp(this, &AudioStreamEditor::_draw_indicator));
+ _indicator->connect("gui_input", callable_mp(this, &AudioStreamEditor::_on_input_indicator));
_preview->add_child(_indicator);
HBoxContainer *hbox = memnew(HBoxContainer);
@@ -239,12 +231,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("pressed", callable_mp(this, &AudioStreamEditor::_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("pressed", callable_mp(this, &AudioStreamEditor::_stop));
_current_label = memnew(Label);
_current_label->set_align(Label::ALIGN_RIGHT);
diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp
index 7db936ccb8..6bc9562c5a 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.cpp
+++ b/editor/plugins/baked_lightmap_editor_plugin.cpp
@@ -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 8b94257a62..818cdfe8fa 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.h
+++ b/editor/plugins/baked_lightmap_editor_plugin.h
@@ -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 6f5bc69bd1..8726c8c552 100644
--- a/editor/plugins/camera_editor_plugin.cpp
+++ b/editor/plugins/camera_editor_plugin.cpp
@@ -48,8 +48,6 @@ void CameraEditor::_pressed() {
}
void CameraEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_pressed"), &CameraEditor::_pressed);
}
void CameraEditor::edit(Node *p_camera) {
@@ -81,7 +79,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("pressed", callable_mp(this, &CameraEditor::_pressed));
}
void CameraEditorPlugin::edit(Object *p_object) {
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 1d8f3a2bbd..af7f8cf5d6 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -34,12 +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"
@@ -58,6 +58,7 @@
#define RULER_WIDTH (15 * EDSCALE)
#define SCALE_HANDLE_DISTANCE 25
+#define MOVE_HANDLE_DISTANCE 25
class SnapDialog : public ConfirmationDialog {
@@ -471,7 +472,7 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
return;
- if (k->get_scancode() == KEY_CONTROL || k->get_scancode() == KEY_ALT || k->get_scancode() == KEY_SHIFT) {
+ if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
viewport->update();
}
@@ -605,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();
@@ -620,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)
@@ -640,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 {
@@ -1312,7 +1315,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
// Drag the pivot (in pivot mode / with V key)
if (drag_type == DRAG_NONE) {
if ((b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
- (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_scancode() == KEY_V)) {
+ (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_V)) {
List<CanvasItem *> selection = _get_edited_canvas_items();
// Filters the selection with nodes that allow setting the pivot
@@ -1364,7 +1367,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
// Confirm the pivot move
if ((b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) ||
- (k.is_valid() && !k->is_pressed() && k->get_scancode() == KEY_V)) {
+ (k.is_valid() && !k->is_pressed() && k->get_keycode() == KEY_V)) {
_commit_canvas_item_state(drag_selection, TTR("Move pivot"));
drag_type = DRAG_NONE;
return true;
@@ -1866,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());
@@ -1924,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;
}
@@ -1983,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);
@@ -1992,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()) {
@@ -2014,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)) {
@@ -2077,8 +2108,8 @@ 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 &&
- (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)) {
+ if (k.is_valid() && k->is_pressed() && (tool == TOOL_SELECT || tool == TOOL_MOVE) &&
+ (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)) {
if (!k->is_echo()) {
// Start moving the canvas items with the keyboard
drag_selection = _get_edited_canvas_items();
@@ -2104,13 +2135,13 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
bool move_local_base_rotated = k->get_control() || k->get_metakey();
Vector2 dir;
- if (k->get_scancode() == KEY_UP)
+ if (k->get_keycode() == KEY_UP)
dir += Vector2(0, -1);
- else if (k->get_scancode() == KEY_DOWN)
+ else if (k->get_keycode() == KEY_DOWN)
dir += Vector2(0, 1);
- else if (k->get_scancode() == KEY_LEFT)
+ else if (k->get_keycode() == KEY_LEFT)
dir += Vector2(-1, 0);
- else if (k->get_scancode() == KEY_RIGHT)
+ else if (k->get_keycode() == KEY_RIGHT)
dir += Vector2(1, 0);
if (k->get_shift())
dir *= grid_step * Math::pow(2.0, grid_step_multiplier);
@@ -2166,7 +2197,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
if (k.is_valid() && !k->is_pressed() && drag_type == DRAG_KEY_MOVE && tool == TOOL_SELECT &&
- (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)) {
+ (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)) {
// Confirm canvas items move by arrow keys
if ((!Input::get_singleton()->is_key_pressed(KEY_UP)) &&
(!Input::get_singleton()->is_key_pressed(KEY_DOWN)) &&
@@ -2179,7 +2210,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
return true;
}
- return (k.is_valid() && (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)); // Accept the key event in any case
+ return (k.is_valid() && (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)); // Accept the key event in any case
}
bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
@@ -2194,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;
@@ -2213,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);
@@ -2334,7 +2387,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
}
- if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_ESCAPE && drag_type == DRAG_NONE && tool == TOOL_SELECT) {
+ if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_ESCAPE && drag_type == DRAG_NONE && tool == TOOL_SELECT) {
// Unselect everything
editor_selection->clear();
viewport->update();
@@ -2806,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));
@@ -2913,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);
}
}
@@ -3047,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);
@@ -3062,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);
@@ -3077,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));
@@ -3092,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));
@@ -3126,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();
@@ -3157,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());
@@ -3179,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 {
@@ -3235,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;
@@ -3253,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());
}
@@ -3296,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));
}
}
@@ -3458,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);
@@ -3472,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");
@@ -3526,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;
@@ -3578,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;
@@ -3810,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("visibility_changed", callable_mp(this, &CanvasItemEditor::_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("node_added", callable_mp(this, &CanvasItemEditor::_tree_changed), varray());
+ get_tree()->connect("node_removed", callable_mp(this, &CanvasItemEditor::_tree_changed), varray());
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
@@ -3821,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("node_added", callable_mp(this, &CanvasItemEditor::_tree_changed));
+ get_tree()->disconnect("node_removed", callable_mp(this, &CanvasItemEditor::_tree_changed));
}
if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
@@ -3909,7 +3990,7 @@ void CanvasItemEditor::_notification(int p_what) {
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);
@@ -4100,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("timeout", callable_mp(this, &CanvasItemEditor::_popup_warning_depop), varray(p_control));
timer->set_one_shot(true);
add_child(timer);
@@ -4264,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);
@@ -4381,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);
@@ -4409,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);
@@ -4967,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);
}
}
@@ -4974,31 +5060,11 @@ void CanvasItemEditor::_focus_selection(int p_op) {
void CanvasItemEditor::_bind_methods() {
- ClassDB::bind_method("_button_zoom_minus", &CanvasItemEditor::_button_zoom_minus);
- ClassDB::bind_method("_button_zoom_reset", &CanvasItemEditor::_button_zoom_reset);
- ClassDB::bind_method("_button_zoom_plus", &CanvasItemEditor::_button_zoom_plus);
- ClassDB::bind_method("_button_toggle_smart_snap", &CanvasItemEditor::_button_toggle_smart_snap);
- ClassDB::bind_method("_button_toggle_grid_snap", &CanvasItemEditor::_button_toggle_grid_snap);
- ClassDB::bind_method(D_METHOD("_button_override_camera", "pressed"), &CanvasItemEditor::_button_override_camera);
ClassDB::bind_method(D_METHOD("_update_override_camera_button", "game_running"), &CanvasItemEditor::_update_override_camera_button);
- ClassDB::bind_method("_button_toggle_anchor_mode", &CanvasItemEditor::_button_toggle_anchor_mode);
- ClassDB::bind_method("_update_scroll", &CanvasItemEditor::_update_scroll);
- ClassDB::bind_method("_update_scrollbars", &CanvasItemEditor::_update_scrollbars);
- ClassDB::bind_method("_popup_callback", &CanvasItemEditor::_popup_callback);
ClassDB::bind_method("_get_editor_data", &CanvasItemEditor::_get_editor_data);
- ClassDB::bind_method("_button_tool_select", &CanvasItemEditor::_button_tool_select);
- ClassDB::bind_method("_keying_changed", &CanvasItemEditor::_keying_changed);
ClassDB::bind_method("_unhandled_key_input", &CanvasItemEditor::_unhandled_key_input);
- ClassDB::bind_method("_draw_viewport", &CanvasItemEditor::_draw_viewport);
- ClassDB::bind_method("_gui_input_viewport", &CanvasItemEditor::_gui_input_viewport);
- ClassDB::bind_method("_snap_changed", &CanvasItemEditor::_snap_changed);
ClassDB::bind_method("_queue_update_bone_list", &CanvasItemEditor::_update_bone_list);
ClassDB::bind_method("_update_bone_list", &CanvasItemEditor::_update_bone_list);
- ClassDB::bind_method("_tree_changed", &CanvasItemEditor::_tree_changed);
- ClassDB::bind_method("_selection_changed", &CanvasItemEditor::_selection_changed);
- ClassDB::bind_method("_popup_warning_depop", &CanvasItemEditor::_popup_warning_depop);
- ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &CanvasItemEditor::_selection_result_pressed);
- ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &CanvasItemEditor::_selection_menu_hide);
ClassDB::bind_method(D_METHOD("set_state"), &CanvasItemEditor::set_state);
ClassDB::bind_method(D_METHOD("update_viewport"), &CanvasItemEditor::update_viewport);
@@ -5034,6 +5100,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;
@@ -5172,6 +5239,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"]);
@@ -5264,6 +5337,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
show_helpers = false;
show_rulers = true;
show_guides = true;
+ show_transformation_gizmos = true;
show_edit_locks = true;
zoom = 1.0 / MAX(1, EDSCALE);
view_offset = Point2(-150 - RULER_WIDTH, -95 - RULER_WIDTH);
@@ -5316,11 +5390,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("selection_changed", callable_mp((CanvasItem *)this, &CanvasItem::update));
+ editor_selection->connect("selection_changed", callable_mp(this, &CanvasItemEditor::_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", "play_pressed", Callable(this, "_update_override_camera_button"), make_binds(true));
+ editor->call_deferred("connect", "stop_pressed", Callable(this, "_update_override_camera_button"), make_binds(false));
hb = memnew(HBoxContainer);
add_child(hb);
@@ -5340,7 +5414,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("draw", callable_mp(this, &CanvasItemEditor::_update_scrollbars));
ViewportContainer *scene_tree = memnew(ViewportContainer);
viewport_scrollable->add_child(scene_tree);
@@ -5362,8 +5436,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
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("draw", callable_mp(this, &CanvasItemEditor::_draw_viewport));
+ viewport->connect("gui_input", callable_mp(this, &CanvasItemEditor::_gui_input_viewport));
info_overlay = memnew(VBoxContainer);
info_overlay->set_anchors_and_margins_preset(Control::PRESET_BOTTOM_LEFT);
@@ -5391,25 +5465,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("value_changed", callable_mp(this, &CanvasItemEditor::_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("value_changed", callable_mp(this, &CanvasItemEditor::_update_scroll));
v_scroll->hide();
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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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);
@@ -5418,7 +5492,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("pressed", callable_mp(this, &CanvasItemEditor::_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);
@@ -5427,7 +5501,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("pressed", callable_mp(this, &CanvasItemEditor::_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"));
@@ -5437,21 +5511,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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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"));
@@ -5460,25 +5534,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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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"));
@@ -5487,14 +5561,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("toggled", callable_mp(this, &CanvasItemEditor::_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("toggled", callable_mp(this, &CanvasItemEditor::_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));
@@ -5505,7 +5579,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("id_pressed", callable_mp(this, &CanvasItemEditor::_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);
@@ -5519,7 +5593,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("id_pressed", callable_mp(this, &CanvasItemEditor::_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);
@@ -5533,22 +5607,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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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));
@@ -5567,13 +5641,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("id_pressed", callable_mp(this, &CanvasItemEditor::_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("toggled", callable_mp(this, &CanvasItemEditor::_button_override_camera));
override_camera_button->set_toggle_mode(true);
override_camera_button->set_disabled(true);
_update_override_camera_button(false);
@@ -5583,7 +5657,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("id_pressed", callable_mp(this, &CanvasItemEditor::_popup_callback));
view_menu->set_switch_on_hover(true);
p = view_menu->get_popup();
@@ -5595,6 +5669,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);
@@ -5610,18 +5685,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("id_pressed", callable_mp(this, &CanvasItemEditor::_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("id_pressed", callable_mp(this, &CanvasItemEditor::_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("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_anchor_mode));
animation_hb = memnew(HBoxContainer);
hb->add_child(animation_hb);
@@ -5633,7 +5708,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("pressed", callable_mp(this, &CanvasItemEditor::_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);
@@ -5641,20 +5716,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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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("pressed", callable_mp(this, &CanvasItemEditor::_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);
@@ -5670,7 +5745,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
animation_menu = memnew(MenuButton);
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("id_pressed", callable_mp(this, &CanvasItemEditor::_popup_callback));
animation_menu->set_switch_on_hover(true);
p = animation_menu->get_popup();
@@ -5683,7 +5758,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("confirmed", callable_mp(this, &CanvasItemEditor::_snap_changed));
add_child(snap_dialog);
select_sb = Ref<StyleBoxTexture>(memnew(StyleBoxTexture));
@@ -5691,8 +5766,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("id_pressed", callable_mp(this, &CanvasItemEditor::_selection_result_pressed));
+ selection_menu->connect("popup_hide", callable_mp(this, &CanvasItemEditor::_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);
@@ -5791,7 +5866,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
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) {
@@ -5848,7 +5923,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) {
@@ -5865,9 +5940,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
@@ -5892,7 +5967,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));
@@ -5935,9 +6010,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) {
@@ -5985,7 +6060,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")
@@ -6040,7 +6115,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" ||
@@ -6048,7 +6123,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;
}
@@ -6139,11 +6214,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("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_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("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit));
} break;
default: break;
@@ -6151,10 +6226,6 @@ void CanvasItemEditorViewport::_notification(int p_what) {
}
void CanvasItemEditorViewport::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_on_select_type"), &CanvasItemEditorViewport::_on_select_type);
- ClassDB::bind_method(D_METHOD("_on_change_type_confirmed"), &CanvasItemEditorViewport::_on_change_type_confirmed);
- ClassDB::bind_method(D_METHOD("_on_change_type_closed"), &CanvasItemEditorViewport::_on_change_type_closed);
- ClassDB::bind_method(D_METHOD("_on_mouse_exit"), &CanvasItemEditorViewport::_on_mouse_exit);
}
CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas_item_editor) {
@@ -6181,8 +6252,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("confirmed", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_confirmed));
+ selector->connect("popup_hide", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_closed));
VBoxContainer *vbc = memnew(VBoxContainer);
selector->add_child(vbc);
@@ -6199,7 +6270,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("button_down", callable_mp(this, &CanvasItemEditorViewport::_on_select_type), varray(check));
check->set_button_group(button_group);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 3291d6b9bf..3c4cacf5c8 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -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,6 +250,8 @@ 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;
@@ -302,7 +306,7 @@ private:
struct _HoverResult {
Point2 position;
- Ref<Texture> icon;
+ Ref<Texture2D> icon;
String name;
};
Vector<_HoverResult> hovering_results;
@@ -402,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;
@@ -414,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());
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index 8620437ac6..1562286073 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -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("node_removed", callable_mp(this, &Polygon3DEditor::_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;
@@ -520,9 +518,7 @@ void Polygon3DEditor::edit(Node *p_collision_polygon) {
void Polygon3DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"), &Polygon3DEditor::_menu_option);
ClassDB::bind_method(D_METHOD("_polygon_draw"), &Polygon3DEditor::_polygon_draw);
- ClassDB::bind_method(D_METHOD("_node_removed"), &Polygon3DEditor::_node_removed);
}
Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
@@ -534,12 +530,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("pressed", callable_mp(this, &Polygon3DEditor::_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("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
mode = MODE_EDIT;
@@ -547,23 +543,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 1871c6ee7e..3b6c25ac17 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_editor_plugin.h
@@ -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 be9e5b0e3a..01b4a61a85 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -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/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index 655048c271..119528dfc8 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -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,17 +240,13 @@ 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("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback));
menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
- file->connect("file_selected", this, "_file_selected");
+ file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected));
}
}
void CPUParticles2DEditorPlugin::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_menu_callback"), &CPUParticles2DEditorPlugin::_menu_callback);
- ClassDB::bind_method(D_METHOD("_file_selected"), &CPUParticles2DEditorPlugin::_file_selected);
- ClassDB::bind_method(D_METHOD("_generate_emission_mask"), &CPUParticles2DEditorPlugin::_generate_emission_mask);
}
CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
@@ -305,7 +301,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
toolbar->add_child(emission_mask);
- emission_mask->connect("confirmed", this, "_generate_emission_mask");
+ emission_mask->connect("confirmed", callable_mp(this, &CPUParticles2DEditorPlugin::_generate_emission_mask));
}
CPUParticles2DEditorPlugin::~CPUParticles2DEditorPlugin() {
diff --git a/editor/plugins/cpu_particles_editor_plugin.cpp b/editor/plugins/cpu_particles_editor_plugin.cpp
index 2074ba6b99..2161041ee6 100644
--- a/editor/plugins/cpu_particles_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_editor_plugin.cpp
@@ -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;
@@ -98,8 +92,6 @@ void CPUParticlesEditor::_generate_emission_points() {
}
void CPUParticlesEditor::_bind_methods() {
-
- ClassDB::bind_method("_menu_option", &CPUParticlesEditor::_menu_option);
}
CPUParticlesEditor::CPUParticlesEditor() {
@@ -112,11 +104,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("id_pressed", callable_mp(this, &CPUParticlesEditor::_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 deaced9ad9..4cf143fc0c 100644
--- a/editor/plugins/cpu_particles_editor_plugin.h
+++ b/editor/plugins/cpu_particles_editor_plugin.h
@@ -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 a4fc9b37ad..878787231d 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -49,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("id_pressed", callable_mp(this, &CurveEditor::on_context_menu_item_selected));
add_child(_context_menu);
_presets_menu = memnew(PopupMenu);
@@ -60,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("id_pressed", callable_mp(this, &CurveEditor::on_preset_item_selected));
_context_menu->add_child(_presets_menu);
}
@@ -70,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(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveEditor::_curve_changed));
+ _curve_ref->disconnect(Curve::SIGNAL_RANGE_CHANGED, callable_mp(this, &CurveEditor::_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(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveEditor::_curve_changed));
+ _curve_ref->connect(Curve::SIGNAL_RANGE_CHANGED, callable_mp(this, &CurveEditor::_curve_changed));
}
_selected_point = -1;
@@ -238,7 +238,7 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
const InputEventKey &key = **key_ref;
if (key.is_pressed() && _selected_point != -1) {
- if (key.get_scancode() == KEY_DELETE)
+ if (key.get_keycode() == KEY_DELETE)
remove_point(_selected_point);
}
}
@@ -612,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);
}
};
@@ -693,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);
}
}
@@ -749,9 +749,6 @@ void CurveEditor::_draw() {
void CurveEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &CurveEditor::on_gui_input);
- ClassDB::bind_method(D_METHOD("_on_preset_item_selected"), &CurveEditor::on_preset_item_selected);
- ClassDB::bind_method(D_METHOD("_curve_changed"), &CurveEditor::_curve_changed);
- ClassDB::bind_method(D_METHOD("_on_context_menu_item_selected"), &CurveEditor::on_context_menu_item_selected);
}
//---------------
@@ -787,10 +784,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
@@ -802,8 +799,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++) {
@@ -844,10 +839,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 06e2692373..c00aa3eca5 100644
--- a/editor/plugins/curve_editor_plugin.h
+++ b/editor/plugins/curve_editor_plugin.h
@@ -141,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 9b0d5d3daf..3c173ab783 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -47,8 +47,6 @@ 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();
@@ -70,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()) {
@@ -113,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);
}
@@ -137,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;
}
@@ -151,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;
@@ -182,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;
}
@@ -199,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;
}
}
}
@@ -231,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);
}
@@ -249,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;
}
@@ -266,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();
@@ -282,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();
@@ -292,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>();
}
}
@@ -324,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) {
@@ -342,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>());
@@ -352,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() {
@@ -369,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();
@@ -396,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++) {
@@ -490,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);
@@ -522,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
@@ -593,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;
}
@@ -612,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) {
@@ -680,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;
}
@@ -710,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());
@@ -726,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));
@@ -743,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());
@@ -762,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;
}
@@ -772,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);
@@ -831,7 +821,7 @@ bool EditorFontPreviewPlugin::handles(const String &p_type) const {
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<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
RES res = ResourceLoader::load(p_path);
Ref<DynamicFont> sampled_font;
@@ -868,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);
@@ -885,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);
}
@@ -903,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 e6e4aff8de..840fa2410a 100644
--- a/editor/plugins/editor_preview_plugins.h
+++ b/editor/plugins/editor_preview_plugins.h
@@ -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 8914e0ed01..c077c23e8a 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -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,53 @@ 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;
+ }
+
+ const Vector3i size = gi_probe->get_estimated_cell_size();
+ String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z);
+ int data_size = 4;
+ if (GLOBAL_GET("rendering/quality/gi_probes/anisotropic")) {
+ data_size += 4;
+ }
+ const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
+ text += " - " + vformat(TTR("VRAM Size: %s MB"), String::num(size_mb, 2));
+
+ if (bake_info->get_text() == text) {
+ return;
+ }
+
+ // Color the label depending on the estimated performance level.
+ Color color;
+ if (size_mb <= 16.0 + CMP_EPSILON) {
+ // Fast.
+ color = bake_info->get_color("success_color", "Editor");
+ } else if (size_mb <= 64.0 + CMP_EPSILON) {
+ // Medium.
+ color = bake_info->get_color("warning_color", "Editor");
+ } else {
+ // Slow.
+ color = bake_info->get_color("error_color", "Editor");
+ }
+
+ bake_info->add_color_override("font_color", color);
+ 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 +134,42 @@ void GIProbeEditorPlugin::bake_func_end() {
tmp_progress = NULL;
}
-void GIProbeEditorPlugin::_bind_methods() {
+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);
+ }
+}
- ClassDB::bind_method("_bake", &GIProbeEditorPlugin::_bake);
+void GIProbeEditorPlugin::_bind_methods() {
}
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("pressed", callable_mp(this, &GIProbeEditorPlugin::_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("file_selected", callable_mp(this, &GIProbeEditorPlugin::_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 5db682835d..2068ebaaa8 100644
--- a/editor/plugins/gi_probe_editor_plugin.h
+++ b/editor/plugins/gi_probe_editor_plugin.h
@@ -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 0a3a994eb7..ff03fcf159 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -62,15 +62,12 @@ void GradientEditor::_ramp_changed() {
}
void GradientEditor::_bind_methods() {
-
- ClassDB::bind_method("_gradient_changed", &GradientEditor::_gradient_changed);
- ClassDB::bind_method("_ramp_changed", &GradientEditor::_ramp_changed);
}
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("ramp_changed", callable_mp(this, &GradientEditor::_ramp_changed));
+ gradient->connect("changed", callable_mp(this, &GradientEditor::_gradient_changed));
set_points(gradient->get_points());
}
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index 9f836ed0d3..ba640883c7 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -105,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();
@@ -268,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("node_removed", callable_mp(this, &ItemListEditor::_node_removed));
}
}
@@ -344,11 +344,6 @@ bool ItemListEditor::handles(Object *p_object) const {
}
void ItemListEditor::_bind_methods() {
-
- ClassDB::bind_method("_node_removed", &ItemListEditor::_node_removed);
- ClassDB::bind_method("_edit_items", &ItemListEditor::_edit_items);
- ClassDB::bind_method("_add_button", &ItemListEditor::_add_pressed);
- ClassDB::bind_method("_delete_button", &ItemListEditor::_delete_pressed);
}
ItemListEditor::ItemListEditor() {
@@ -359,7 +354,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("pressed", callable_mp(this, &ItemListEditor::_edit_items));
dialog = memnew(AcceptDialog);
dialog->set_title(TTR("Item List Editor"));
@@ -376,14 +371,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("pressed", callable_mp(this, &ItemListEditor::_add_pressed));
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("pressed", callable_mp(this, &ItemListEditor::_delete_pressed));
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 8a73367bf7..8dcf938139 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -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/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 750f814319..b39465f618 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -59,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);
@@ -105,8 +105,6 @@ void MaterialEditor::_button_pressed(Node *p_button) {
}
void MaterialEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_button_pressed"), &MaterialEditor::_button_pressed);
}
MaterialEditor::MaterialEditor() {
@@ -171,13 +169,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("pressed", callable_mp(this, &MaterialEditor::_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("pressed", callable_mp(this, &MaterialEditor::_button_pressed), varray(box_switch));
hb->add_spacer();
@@ -187,12 +185,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("pressed", callable_mp(this, &MaterialEditor::_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("pressed", callable_mp(this, &MaterialEditor::_button_pressed), varray(light_2_switch));
first_enter = true;
}
@@ -225,7 +223,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) {
@@ -235,18 +235,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;
@@ -266,9 +266,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 7f0a373dc7..95a6c4bf8f 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -100,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 d06e5b6349..5a17f0d4f1 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -111,7 +111,6 @@ void MeshEditor::_button_pressed(Node *p_button) {
void MeshEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &MeshEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_button_pressed"), &MeshEditor::_button_pressed);
}
MeshEditor::MeshEditor() {
@@ -157,12 +156,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("pressed", callable_mp(this, &MeshEditor::_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("pressed", callable_mp(this, &MeshEditor::_button_pressed), varray(light_2_switch));
first_enter = true;
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index 25329906a9..e5b948aad7 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -32,7 +32,7 @@
#include "editor/editor_scale.h"
#include "scene/3d/collision_shape.h"
-#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/navigation_region.h"
#include "scene/3d/physics_body.h"
#include "scene/gui/box_container.h"
#include "spatial_editor_plugin.h"
@@ -60,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();
@@ -71,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);
@@ -82,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);
@@ -108,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;
@@ -158,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;
}
@@ -169,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++) {
@@ -203,7 +233,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
return;
nmesh->create_from_mesh(mesh);
- NavigationMeshInstance *nmi = memnew(NavigationMeshInstance);
+ NavigationRegion *nmi = memnew(NavigationRegion);
nmi->set_navigation_mesh(nmesh);
Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
@@ -297,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();
@@ -405,10 +435,6 @@ void MeshInstanceEditor::_create_outline_mesh() {
}
void MeshInstanceEditor::_bind_methods() {
-
- ClassDB::bind_method("_menu_option", &MeshInstanceEditor::_menu_option);
- ClassDB::bind_method("_create_outline_mesh", &MeshInstanceEditor::_create_outline_mesh);
- ClassDB::bind_method("_debug_uv_draw", &MeshInstanceEditor::_debug_uv_draw);
}
MeshInstanceEditor::MeshInstanceEditor() {
@@ -421,19 +447,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 Sibling"), 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("id_pressed", callable_mp(this, &MeshInstanceEditor::_menu_option));
outline_dialog = memnew(ConfirmationDialog);
outline_dialog->set_title(TTR("Create Outline Mesh"));
@@ -451,7 +483,7 @@ 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("confirmed", callable_mp(this, &MeshInstanceEditor::_create_outline_mesh));
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
@@ -461,7 +493,7 @@ MeshInstanceEditor::MeshInstanceEditor() {
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("draw", callable_mp(this, &MeshInstanceEditor::_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 5c95676fc4..5ca9aa3fec 100644
--- a/editor/plugins/mesh_instance_editor_plugin.h
+++ b/editor/plugins/mesh_instance_editor_plugin.h
@@ -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 92898ff9c3..71976d509b 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -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_region.h"
#include "scene/3d/physics_body.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
@@ -152,9 +152,9 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Transform navmesh_transform;
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
- if (!Object::cast_to<NavigationMeshInstance>(child2))
+ if (!Object::cast_to<NavigationRegion>(child2))
continue;
- NavigationMeshInstance *sb = Object::cast_to<NavigationMeshInstance>(child2);
+ NavigationRegion *sb = Object::cast_to<NavigationRegion>(child2);
navmesh = sb->get_navigation_mesh();
navmesh_transform = sb->get_transform();
if (!navmesh.is_null())
@@ -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++) {
@@ -248,10 +248,6 @@ void MeshLibraryEditor::_menu_cbk(int p_option) {
}
void MeshLibraryEditor::_bind_methods() {
-
- ClassDB::bind_method("_menu_cbk", &MeshLibraryEditor::_menu_cbk);
- ClassDB::bind_method("_menu_confirm", &MeshLibraryEditor::_menu_confirm);
- ClassDB::bind_method("_import_scene_cbk", &MeshLibraryEditor::_import_scene_cbk);
}
MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
@@ -268,7 +264,7 @@ 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("file_selected", callable_mp(this, &MeshLibraryEditor::_import_scene_cbk));
menu = memnew(MenuButton);
SpatialEditor::get_singleton()->add_control_to_menu_panel(menu);
@@ -281,13 +277,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("id_pressed", callable_mp(this, &MeshLibraryEditor::_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("pressed", callable_mp(this, &MeshLibraryEditor::_menu_confirm));
}
void MeshLibraryEditorPlugin::edit(Object *p_node) {
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index 5dc222f84c..27d400c035 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -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();
@@ -280,11 +278,6 @@ void MultiMeshEditor::_browse(bool p_source) {
}
void MultiMeshEditor::_bind_methods() {
-
- ClassDB::bind_method("_menu_option", &MultiMeshEditor::_menu_option);
- ClassDB::bind_method("_populate", &MultiMeshEditor::_populate);
- ClassDB::bind_method("_browsed", &MultiMeshEditor::_browsed);
- ClassDB::bind_method("_browse", &MultiMeshEditor::_browse);
}
MultiMeshEditor::MultiMeshEditor() {
@@ -297,7 +290,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("id_pressed", callable_mp(this, &MultiMeshEditor::_menu_option));
populate_dialog = memnew(ConfirmationDialog);
populate_dialog->set_title(TTR("Populate MultiMesh"));
@@ -315,7 +308,7 @@ MultiMeshEditor::MultiMeshEditor() {
Button *b = memnew(Button);
hbc->add_child(b);
b->set_text("..");
- b->connect("pressed", this, "_browse", make_binds(false));
+ b->connect("pressed", callable_mp(this, &MultiMeshEditor::_browse), make_binds(false));
vbc->add_margin_child(TTR("Target Surface:"), hbc);
@@ -327,7 +320,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("pressed", callable_mp(this, &MultiMeshEditor::_browse), make_binds(true));
populate_axis = memnew(OptionButton);
populate_axis->add_item(TTR("X-Axis"));
@@ -373,10 +366,10 @@ MultiMeshEditor::MultiMeshEditor() {
populate_dialog->get_ok()->set_text(TTR("Populate"));
- populate_dialog->get_ok()->connect("pressed", this, "_populate");
+ populate_dialog->get_ok()->connect("pressed", callable_mp(this, &MultiMeshEditor::_populate));
std = memnew(SceneTreeDialog);
populate_dialog->add_child(std);
- std->connect("selected", this, "_browsed");
+ std->connect("selected", callable_mp(this, &MultiMeshEditor::_browsed));
_last_pp_node = NULL;
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index c4e61f2488..6671d0b6b4 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -48,7 +48,7 @@ Node2D *NavigationPolygonEditor::_get_node() const {
void NavigationPolygonEditor::_set_node(Node *p_polygon) {
- node = Object::cast_to<NavigationPolygonInstance>(p_polygon);
+ node = Object::cast_to<NavigationRegion2D>(p_polygon);
}
int NavigationPolygonEditor::_get_polygon_count() const {
@@ -127,5 +127,5 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) :
}
NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) :
- AbstractPolygon2DEditorPlugin(p_node, memnew(NavigationPolygonEditor(p_node)), "NavigationPolygonInstance") {
+ AbstractPolygon2DEditorPlugin(p_node, memnew(NavigationPolygonEditor(p_node)), "NavigationRegion2D") {
}
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 1cab336381..10f8cbc0a5 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -38,7 +38,7 @@ class NavigationPolygonEditor : public AbstractPolygon2DEditor {
GDCLASS(NavigationPolygonEditor, AbstractPolygon2DEditor);
- NavigationPolygonInstance *node;
+ NavigationRegion2D *node;
Ref<NavigationPolygon> _ensure_navpoly() const;
diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp
index b036368bc8..812144742f 100644
--- a/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/editor/plugins/particles_2d_editor_plugin.cpp
@@ -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,18 +349,13 @@ 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("id_pressed", callable_mp(this, &Particles2DEditorPlugin::_menu_callback));
menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
- file->connect("file_selected", this, "_file_selected");
+ file->connect("file_selected", callable_mp(this, &Particles2DEditorPlugin::_file_selected));
}
}
void Particles2DEditorPlugin::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_menu_callback"), &Particles2DEditorPlugin::_menu_callback);
- ClassDB::bind_method(D_METHOD("_file_selected"), &Particles2DEditorPlugin::_file_selected);
- ClassDB::bind_method(D_METHOD("_generate_visibility_rect"), &Particles2DEditorPlugin::_generate_visibility_rect);
- ClassDB::bind_method(D_METHOD("_generate_emission_mask"), &Particles2DEditorPlugin::_generate_emission_mask);
}
Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
@@ -416,7 +411,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("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_visibility_rect));
emission_mask = memnew(ConfirmationDialog);
emission_mask->set_title(TTR("Load Emission Mask"));
@@ -433,7 +428,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
toolbar->add_child(emission_mask);
- emission_mask->connect("confirmed", this, "_generate_emission_mask");
+ emission_mask->connect("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_emission_mask));
}
Particles2DEditorPlugin::~Particles2DEditorPlugin() {
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index f869dabf9a..a4d704c6e1 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -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,15 +199,10 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
}
}
- w.release();
-
emission_dialog->popup_centered(Size2(300, 130));
}
void ParticlesEditorBase::_bind_methods() {
-
- ClassDB::bind_method("_node_selected", &ParticlesEditorBase::_node_selected);
- ClassDB::bind_method("_generate_emission_points", &ParticlesEditorBase::_generate_emission_points);
}
ParticlesEditorBase::ParticlesEditorBase() {
@@ -231,25 +226,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("confirmed", callable_mp(this, &ParticlesEditorBase::_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("selected", callable_mp(this, &ParticlesEditorBase::_node_selected));
}
void ParticlesEditor::_node_removed(Node *p_node) {
@@ -264,7 +245,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("node_removed", callable_mp(this, &ParticlesEditor::_node_removed));
}
}
@@ -281,17 +262,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 +349,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 +361,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 +380,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 +390,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 +409,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 {
@@ -452,10 +420,6 @@ void ParticlesEditor::_generate_emission_points() {
}
void ParticlesEditor::_bind_methods() {
-
- ClassDB::bind_method("_menu_option", &ParticlesEditor::_menu_option);
- ClassDB::bind_method("_generate_aabb", &ParticlesEditor::_generate_aabb);
- ClassDB::bind_method("_node_removed", &ParticlesEditor::_node_removed);
}
ParticlesEditor::ParticlesEditor() {
@@ -471,14 +435,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("id_pressed", callable_mp(this, &ParticlesEditor::_menu_option));
generate_aabb = memnew(ConfirmationDialog);
generate_aabb->set_title(TTR("Generate Visibility AABB"));
@@ -492,7 +455,7 @@ ParticlesEditor::ParticlesEditor() {
add_child(generate_aabb);
- generate_aabb->connect("confirmed", this, "_generate_aabb");
+ generate_aabb->connect("confirmed", callable_mp(this, &ParticlesEditor::_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 4b20d00670..fb5ce17560 100644
--- a/editor/plugins/particles_editor_plugin.h
+++ b/editor/plugins/particles_editor_plugin.h
@@ -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 3737dbdd57..165df6b500 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -373,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();
@@ -396,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));
}
}
@@ -407,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));
}
}
@@ -420,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);
}
}
@@ -441,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("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed)))
+ node->connect("visibility_changed", callable_mp(this, &Path2DEditor::_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("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed)))
+ node->disconnect("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed));
node = NULL;
}
}
@@ -456,9 +456,6 @@ void Path2DEditor::edit(Node *p_path2d) {
void Path2DEditor::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_menu_option"),&Path2DEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_node_visibility_changed"), &Path2DEditor::_node_visibility_changed);
- ClassDB::bind_method(D_METHOD("_mode_selected"), &Path2DEditor::_mode_selected);
- ClassDB::bind_method(D_METHOD("_handle_option_pressed"), &Path2DEditor::_handle_option_pressed);
}
void Path2DEditor::_mode_selected(int p_mode) {
@@ -555,34 +552,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("pressed", callable_mp(this, &Path2DEditor::_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("pressed", callable_mp(this, &Path2DEditor::_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("pressed", callable_mp(this, &Path2DEditor::_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("pressed", callable_mp(this, &Path2DEditor::_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("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(ACTION_CLOSE));
base_hb->add_child(curve_close);
PopupMenu *menu;
@@ -596,7 +593,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("id_pressed", callable_mp(this, &Path2DEditor::_handle_option_pressed));
base_hb->hide();
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index 67889bc074..42b1045666 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -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,18 +543,14 @@ 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("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(0));
+ curve_edit->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(1));
+ curve_del->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(2));
+ curve_close->connect("pressed", callable_mp(this, &PathEditorPlugin::_close_curve));
}
}
void PathEditorPlugin::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_mode_changed"), &PathEditorPlugin::_mode_changed);
- ClassDB::bind_method(D_METHOD("_close_curve"), &PathEditorPlugin::_close_curve);
- ClassDB::bind_method(D_METHOD("_handle_option_pressed"), &PathEditorPlugin::_handle_option_pressed);
}
PathEditorPlugin *PathEditorPlugin::singleton = NULL;
@@ -614,7 +610,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("id_pressed", callable_mp(this, &PathEditorPlugin::_handle_option_pressed));
curve_edit->set_pressed(true);
/*
diff --git a/editor/plugins/physical_bone_plugin.cpp b/editor/plugins/physical_bone_plugin.cpp
index 28099a927b..e0d48afeef 100644
--- a/editor/plugins/physical_bone_plugin.cpp
+++ b/editor/plugins/physical_bone_plugin.cpp
@@ -33,7 +33,6 @@
#include "scene/3d/physics_body.h"
void PhysicalBoneEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_on_toggle_button_transform_joint", "is_pressed"), &PhysicalBoneEditor::_on_toggle_button_transform_joint);
}
void PhysicalBoneEditor::_on_toggle_button_transform_joint(bool p_is_pressed) {
@@ -64,7 +63,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("toggled", callable_mp(this, &PhysicalBoneEditor::_on_toggle_button_transform_joint));
hide();
}
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 35c0142d4b..8c115586a4 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -125,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;
}
@@ -138,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;
}
@@ -192,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("pressed", callable_mp(this, &Polygon2DEditor::_bone_paint_selected), varray(i));
}
uv_edit_draw->update();
@@ -293,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);
@@ -312,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);
@@ -325,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;
@@ -339,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");
@@ -567,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));
@@ -622,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));
@@ -712,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++) {
@@ -832,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
@@ -843,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);
@@ -856,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];
@@ -879,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];
@@ -914,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();
@@ -925,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) {
@@ -980,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;
@@ -1024,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;
@@ -1045,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()) {
@@ -1078,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];
@@ -1086,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]));
@@ -1094,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();
@@ -1107,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);
@@ -1116,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));
@@ -1134,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));
}
}
@@ -1234,22 +1234,8 @@ void Polygon2DEditor::_uv_draw() {
void Polygon2DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_uv_mode"), &Polygon2DEditor::_uv_mode);
- ClassDB::bind_method(D_METHOD("_uv_draw"), &Polygon2DEditor::_uv_draw);
- ClassDB::bind_method(D_METHOD("_uv_input"), &Polygon2DEditor::_uv_input);
- ClassDB::bind_method(D_METHOD("_uv_scroll_changed"), &Polygon2DEditor::_uv_scroll_changed);
- ClassDB::bind_method(D_METHOD("_set_use_snap"), &Polygon2DEditor::_set_use_snap);
- ClassDB::bind_method(D_METHOD("_set_show_grid"), &Polygon2DEditor::_set_show_grid);
- ClassDB::bind_method(D_METHOD("_set_snap_off_x"), &Polygon2DEditor::_set_snap_off_x);
- ClassDB::bind_method(D_METHOD("_set_snap_off_y"), &Polygon2DEditor::_set_snap_off_y);
- ClassDB::bind_method(D_METHOD("_set_snap_step_x"), &Polygon2DEditor::_set_snap_step_x);
- ClassDB::bind_method(D_METHOD("_set_snap_step_y"), &Polygon2DEditor::_set_snap_step_y);
- ClassDB::bind_method(D_METHOD("_uv_edit_mode_select"), &Polygon2DEditor::_uv_edit_mode_select);
- ClassDB::bind_method(D_METHOD("_uv_edit_popup_hide"), &Polygon2DEditor::_uv_edit_popup_hide);
- ClassDB::bind_method(D_METHOD("_sync_bones"), &Polygon2DEditor::_sync_bones);
ClassDB::bind_method(D_METHOD("_update_bone_list"), &Polygon2DEditor::_update_bone_list);
ClassDB::bind_method(D_METHOD("_update_polygon_editing_state"), &Polygon2DEditor::_update_polygon_editing_state);
- ClassDB::bind_method(D_METHOD("_bone_paint_selected"), &Polygon2DEditor::_bone_paint_selected);
}
Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const {
@@ -1273,14 +1259,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("pressed", callable_mp(this, &Polygon2DEditor::_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("popup_hide", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
VBoxContainer *uv_main_vb = memnew(VBoxContainer);
uv_edit->add_child(uv_main_vb);
@@ -1312,10 +1298,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("pressed", callable_mp(this, &Polygon2DEditor::_uv_edit_mode_select), varray(0));
+ uv_edit_mode[1]->connect("pressed", callable_mp(this, &Polygon2DEditor::_uv_edit_mode_select), varray(1));
+ uv_edit_mode[2]->connect("pressed", callable_mp(this, &Polygon2DEditor::_uv_edit_mode_select), varray(2));
+ uv_edit_mode[3]->connect("pressed", callable_mp(this, &Polygon2DEditor::_uv_edit_mode_select), varray(3));
uv_mode_hb->add_child(memnew(VSeparator));
@@ -1325,7 +1311,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("pressed", callable_mp(this, &Polygon2DEditor::_uv_mode), varray(i));
uv_button[i]->set_focus_mode(FOCUS_NONE);
}
@@ -1388,7 +1374,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("id_pressed", callable_mp(this, &Polygon2DEditor::_menu_option));
uv_mode_hb->add_child(memnew(VSeparator));
@@ -1399,7 +1385,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("toggled", callable_mp(this, &Polygon2DEditor::_set_use_snap));
b_snap_grid = memnew(ToolButton);
uv_mode_hb->add_child(b_snap_grid);
@@ -1408,7 +1394,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("toggled", callable_mp(this, &Polygon2DEditor::_set_show_grid));
grid_settings = memnew(AcceptDialog);
grid_settings->set_title(TTR("Configure Grid:"));
@@ -1422,7 +1408,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("value_changed", callable_mp(this, &Polygon2DEditor::_set_snap_off_x));
grid_settings_vb->add_margin_child(TTR("Grid Offset X:"), sb_off_x);
SpinBox *sb_off_y = memnew(SpinBox);
@@ -1431,7 +1417,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("value_changed", callable_mp(this, &Polygon2DEditor::_set_snap_off_y));
grid_settings_vb->add_margin_child(TTR("Grid Offset Y:"), sb_off_y);
SpinBox *sb_step_x = memnew(SpinBox);
@@ -1440,7 +1426,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("value_changed", callable_mp(this, &Polygon2DEditor::_set_snap_step_x));
grid_settings_vb->add_margin_child(TTR("Grid Step X:"), sb_step_x);
SpinBox *sb_step_y = memnew(SpinBox);
@@ -1449,7 +1435,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("value_changed", callable_mp(this, &Polygon2DEditor::_set_snap_step_y));
grid_settings_vb->add_margin_child(TTR("Grid Step Y:"), sb_step_y);
uv_mode_hb->add_child(memnew(VSeparator));
@@ -1469,16 +1455,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("value_changed", callable_mp(this, &Polygon2DEditor::_uv_scroll_changed));
uv_vscroll = memnew(VScrollBar);
uv_vscroll->set_step(0.001);
uv_edit_draw->add_child(uv_vscroll);
- uv_vscroll->connect("value_changed", this, "_uv_scroll_changed");
+ uv_vscroll->connect("value_changed", callable_mp(this, &Polygon2DEditor::_uv_scroll_changed));
uv_hscroll = memnew(HScrollBar);
uv_hscroll->set_step(0.001);
uv_edit_draw->add_child(uv_hscroll);
- uv_hscroll->connect("value_changed", this, "_uv_scroll_changed");
+ uv_hscroll->connect("value_changed", callable_mp(this, &Polygon2DEditor::_uv_scroll_changed));
bone_scroll_main_vb = memnew(VBoxContainer);
bone_scroll_main_vb->hide();
@@ -1486,7 +1472,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("pressed", callable_mp(this, &Polygon2DEditor::_sync_bones));
uv_main_hsc->add_child(bone_scroll_main_vb);
bone_scroll = memnew(ScrollContainer);
bone_scroll->set_v_scroll(true);
@@ -1496,8 +1482,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("draw", callable_mp(this, &Polygon2DEditor::_uv_draw));
+ uv_edit_draw->connect("gui_input", callable_mp(this, &Polygon2DEditor::_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 1454a03325..2b00b50e5c 100644
--- a/editor/plugins/polygon_2d_editor_plugin.h
+++ b/editor/plugins/polygon_2d_editor_plugin.h
@@ -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 fb04f50827..feef505acc 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -347,12 +347,7 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant
void ResourcePreloaderEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &ResourcePreloaderEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_load_pressed"), &ResourcePreloaderEditor::_load_pressed);
- ClassDB::bind_method(D_METHOD("_item_edited"), &ResourcePreloaderEditor::_item_edited);
- ClassDB::bind_method(D_METHOD("_paste_pressed"), &ResourcePreloaderEditor::_paste_pressed);
- ClassDB::bind_method(D_METHOD("_files_load_request"), &ResourcePreloaderEditor::_files_load_request);
ClassDB::bind_method(D_METHOD("_update_library"), &ResourcePreloaderEditor::_update_library);
- ClassDB::bind_method(D_METHOD("_cell_button_pressed"), &ResourcePreloaderEditor::_cell_button_pressed);
ClassDB::bind_method(D_METHOD("_remove_resource", "to_remove"), &ResourcePreloaderEditor::_remove_resource);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &ResourcePreloaderEditor::get_drag_data_fw);
@@ -382,7 +377,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
add_child(file);
tree = memnew(Tree);
- tree->connect("button_pressed", this, "_cell_button_pressed");
+ tree->connect("button_pressed", callable_mp(this, &ResourcePreloaderEditor::_cell_button_pressed));
tree->set_columns(2);
tree->set_column_min_width(0, 2);
tree->set_column_min_width(1, 3);
@@ -396,10 +391,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("pressed", callable_mp(this, &ResourcePreloaderEditor::_load_pressed));
+ paste->connect("pressed", callable_mp(this, &ResourcePreloaderEditor::_paste_pressed));
+ file->connect("files_selected", callable_mp(this, &ResourcePreloaderEditor::_files_load_request));
+ tree->connect("item_edited", callable_mp(this, &ResourcePreloaderEditor::_item_edited));
loading_scene = false;
}
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index 3489537fa4..d932305c63 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -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,16 +242,12 @@ 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);
}
}
void EditorPropertyRootMotion::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_confirmed"), &EditorPropertyRootMotion::_confirmed);
- ClassDB::bind_method(D_METHOD("_node_assign"), &EditorPropertyRootMotion::_node_assign);
- ClassDB::bind_method(D_METHOD("_node_clear"), &EditorPropertyRootMotion::_node_clear);
}
EditorPropertyRootMotion::EditorPropertyRootMotion() {
@@ -262,24 +258,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("pressed", callable_mp(this, &EditorPropertyRootMotion::_node_assign));
hbc->add_child(assign);
clear = memnew(Button);
clear->set_flat(true);
- clear->connect("pressed", this, "_node_clear");
+ clear->connect("pressed", callable_mp(this, &EditorPropertyRootMotion::_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("confirmed", callable_mp(this, &EditorPropertyRootMotion::_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("item_activated", callable_mp(this, &EditorPropertyRootMotion::_confirmed));
//filters->connect("item_edited", this, "_filter_edited");
}
//////////////////////////
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index f13abd47a9..60bed10351 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -36,6 +36,8 @@
#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"
@@ -44,7 +46,6 @@
#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"
@@ -62,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) {
@@ -164,10 +166,10 @@ void ScriptEditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) {
Ref<InputEventKey> k = p_ie;
- if (k.is_valid() && (k->get_scancode() == KEY_UP ||
- k->get_scancode() == KEY_DOWN ||
- k->get_scancode() == KEY_PAGEUP ||
- k->get_scancode() == KEY_PAGEDOWN)) {
+ if (k.is_valid() && (k->get_keycode() == KEY_UP ||
+ k->get_keycode() == KEY_DOWN ||
+ k->get_keycode() == KEY_PAGEUP ||
+ k->get_keycode() == KEY_PAGEDOWN)) {
search_options->call("_gui_input", k);
search_box->accept_event();
@@ -209,26 +211,22 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- connect("confirmed", this, "_confirmed");
+ connect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_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("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
} break;
}
}
void ScriptEditorQuickOpen::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_text_changed"), &ScriptEditorQuickOpen::_text_changed);
- ClassDB::bind_method(D_METHOD("_confirmed"), &ScriptEditorQuickOpen::_confirmed);
- ClassDB::bind_method(D_METHOD("_sbox_input"), &ScriptEditorQuickOpen::_sbox_input);
-
ADD_SIGNAL(MethodInfo("goto_line", PropertyInfo(Variant::INT, "line")));
}
@@ -238,15 +236,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("text_changed", callable_mp(this, &ScriptEditorQuickOpen::_text_changed));
+ search_box->connect("gui_input", callable_mp(this, &ScriptEditorQuickOpen::_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("item_activated", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
search_options->add_constant_override("draw_guides", 1);
@@ -260,7 +258,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 {
@@ -275,11 +273,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));
@@ -291,11 +284,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->());
}
@@ -842,7 +830,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) {
@@ -908,7 +896,7 @@ void ScriptEditor::_file_dialog_action(String p_file) {
}
file->close();
memdelete(file);
- FALLTHROUGH;
+ [[fallthrough]];
}
case FILE_OPEN: {
@@ -1093,6 +1081,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();
@@ -1118,27 +1110,6 @@ 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: {
if (current) {
ScriptTextEditor *editor = Object::cast_to<ScriptTextEditor>(current);
@@ -1252,7 +1223,7 @@ void ScriptEditor::_menu_option(int p_option) {
}
Ref<EditorScript> es = memnew(EditorScript);
- es->set_script(scr.get_ref_ptr());
+ es->set_script(scr);
es->set_editor(EditorNode::get_singleton());
es->_run();
@@ -1289,29 +1260,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) {
@@ -1434,19 +1382,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("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
+ editor->connect("script_add_function_request", callable_mp(this, &ScriptEditor::_add_callback));
+ editor->connect("resource_saved", callable_mp(this, &ScriptEditor::_res_saved_callback));
+ script_list->connect("item_selected", callable_mp(this, &ScriptEditor::_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("item_selected", callable_mp(this, &ScriptEditor::_members_overview_selected));
+ help_overview->connect("item_selected", callable_mp(this, &ScriptEditor::_help_overview_selected));
+ script_split->connect("dragged", callable_mp(this, &ScriptEditor::_script_split_dragged));
- EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
- FALLTHROUGH;
+ EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ScriptEditor::_editor_settings_changed));
+ [[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
@@ -1469,16 +1415,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("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed));
+ editor->get_inspector_dock()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open));
+ editor->connect("request_help_search", callable_mp(this, &ScriptEditor::_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("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
} break;
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
@@ -1647,7 +1591,7 @@ struct _ScriptEditorItemData {
String name;
String sort_key;
- Ref<Texture> icon;
+ Ref<Texture2D> icon;
int index;
String tooltip;
bool used;
@@ -1832,7 +1776,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;
@@ -1893,7 +1837,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;
@@ -2057,7 +2001,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"))) {
@@ -2189,13 +2133,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("name_changed", callable_mp(this, &ScriptEditor::_update_script_names));
+ se->connect("edited_script_changed", callable_mp(this, &ScriptEditor::_script_changed));
+ se->connect("request_help", callable_mp(this, &ScriptEditor::_help_search));
+ se->connect("request_open_script_at_line", callable_mp(this, &ScriptEditor::_goto_script_line));
+ se->connect("go_to_help", callable_mp(this, &ScriptEditor::_help_class_goto));
+ se->connect("request_save_history", callable_mp(this, &ScriptEditor::_save_history));
+ se->connect("search_in_files_requested", callable_mp(this, &ScriptEditor::_on_find_in_files_requested));
+ se->connect("replace_in_files_requested", callable_mp(this, &ScriptEditor::_on_replace_in_files_requested));
//test for modification, maybe the script was not edited but was loaded
@@ -2271,26 +2216,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));
@@ -2303,7 +2229,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();
@@ -2416,7 +2342,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) {
@@ -2807,7 +2733,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("go_to_help", callable_mp(this, &ScriptEditor::_help_class_goto));
_add_recent_script(p_class);
_sort_list_on_update = true;
_update_script_names();
@@ -2837,7 +2763,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("go_to_help", callable_mp(this, &ScriptEditor::_help_class_goto));
_add_recent_script(eh->get_class());
_sort_list_on_update = true;
_update_script_names();
@@ -3025,10 +2951,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)) {
@@ -3078,12 +3013,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();
@@ -3099,63 +3035,19 @@ void ScriptEditor::_filter_methods_text_changed(const String &p_newtext) {
void ScriptEditor::_bind_methods() {
- ClassDB::bind_method("_file_dialog_action", &ScriptEditor::_file_dialog_action);
- ClassDB::bind_method("_tab_changed", &ScriptEditor::_tab_changed);
- ClassDB::bind_method("_menu_option", &ScriptEditor::_menu_option);
- ClassDB::bind_method("_close_current_tab", &ScriptEditor::_close_current_tab);
- ClassDB::bind_method("_close_discard_current_tab", &ScriptEditor::_close_discard_current_tab);
ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab);
ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs);
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);
- ClassDB::bind_method("_resave_scripts", &ScriptEditor::_resave_scripts);
- ClassDB::bind_method("_res_saved_callback", &ScriptEditor::_res_saved_callback);
- ClassDB::bind_method("_goto_script_line", &ScriptEditor::_goto_script_line);
ClassDB::bind_method("_goto_script_line2", &ScriptEditor::_goto_script_line2);
- ClassDB::bind_method("_set_execution", &ScriptEditor::_set_execution);
- ClassDB::bind_method("_clear_execution", &ScriptEditor::_clear_execution);
- ClassDB::bind_method("_help_search", &ScriptEditor::_help_search);
- ClassDB::bind_method("_save_history", &ScriptEditor::_save_history);
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);
- ClassDB::bind_method("_editor_settings_changed", &ScriptEditor::_editor_settings_changed);
- ClassDB::bind_method("_update_script_names", &ScriptEditor::_update_script_names);
ClassDB::bind_method("_update_script_connections", &ScriptEditor::_update_script_connections);
- ClassDB::bind_method("_tree_changed", &ScriptEditor::_tree_changed);
- ClassDB::bind_method("_members_overview_selected", &ScriptEditor::_members_overview_selected);
- ClassDB::bind_method("_help_overview_selected", &ScriptEditor::_help_overview_selected);
- ClassDB::bind_method("_script_selected", &ScriptEditor::_script_selected);
- ClassDB::bind_method("_script_created", &ScriptEditor::_script_created);
- ClassDB::bind_method("_script_split_dragged", &ScriptEditor::_script_split_dragged);
ClassDB::bind_method("_help_class_open", &ScriptEditor::_help_class_open);
- ClassDB::bind_method("_help_class_goto", &ScriptEditor::_help_class_goto);
- ClassDB::bind_method("_request_help", &ScriptEditor::_help_class_open);
- ClassDB::bind_method("_history_forward", &ScriptEditor::_history_forward);
- ClassDB::bind_method("_history_back", &ScriptEditor::_history_back);
ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
- ClassDB::bind_method("_script_list_gui_input", &ScriptEditor::_script_list_gui_input);
- ClassDB::bind_method("_toggle_members_overview_alpha_sort", &ScriptEditor::_toggle_members_overview_alpha_sort);
ClassDB::bind_method("_update_members_overview", &ScriptEditor::_update_members_overview);
- ClassDB::bind_method("_script_changed", &ScriptEditor::_script_changed);
- ClassDB::bind_method("_filter_scripts_text_changed", &ScriptEditor::_filter_scripts_text_changed);
- 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("_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);
ClassDB::bind_method(D_METHOD("get_drag_data_fw", "point", "from"), &ScriptEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw", "point", "data", "from"), &ScriptEditor::can_drop_data_fw);
@@ -3204,22 +3096,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("text_changed", callable_mp(this, &ScriptEditor::_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);
+ script_split->set_split_offset(70 * EDSCALE);
_sort_list_on_update = true;
- script_list->connect("gui_input", this, "_script_list_gui_input", varray(), CONNECT_DEFERRED);
+ script_list->connect("gui_input", callable_mp(this, &ScriptEditor::_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("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
context_menu->set_hide_on_window_lose_focus(true);
overview_vbox = memnew(VBoxContainer);
@@ -3240,28 +3132,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("toggled", callable_mp(this, &ScriptEditor::_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("text_changed", callable_mp(this, &ScriptEditor::_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);
@@ -3291,7 +3183,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("id_pressed", callable_mp(this, &ScriptEditor::_open_recent_script));
_update_recent_scripts();
file_menu->get_popup()->add_separator();
@@ -3313,7 +3205,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("id_pressed", callable_mp(this, &ScriptEditor::_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);
@@ -3332,35 +3224,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("id_pressed", callable_mp(this, &ScriptEditor::_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("id_pressed", callable_mp(this, &ScriptEditor::_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("goto_script_line", callable_mp(this, &ScriptEditor::_goto_script_line));
+ debugger->connect("set_execution", callable_mp(this, &ScriptEditor::_set_execution));
+ debugger->connect("clear_execution", callable_mp(this, &ScriptEditor::_clear_execution));
+ debugger->connect("breaked", callable_mp(this, &ScriptEditor::_breaked));
menu_hb->add_spacer();
@@ -3376,64 +3258,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("pressed", callable_mp(this, &ScriptEditor::_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("pressed", callable_mp(this, &ScriptEditor::_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("pressed", callable_mp(this, &ScriptEditor::_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("pressed", callable_mp(this, &ScriptEditor::_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("pressed", callable_mp(this, &ScriptEditor::_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("tab_changed", callable_mp(this, &ScriptEditor::_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("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab));
+ erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_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("script_created", callable_mp(this, &ScriptEditor::_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("file_selected", callable_mp(this, &ScriptEditor::_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);
@@ -3447,48 +3323,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("confirmed", callable_mp(this, &ScriptEditor::_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("custom_action", callable_mp(this, &ScriptEditor::_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(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &ScriptEditor::_update_autosave_timer));
+ autosave_timer->connect("timeout", callable_mp(this, &ScriptEditor::_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("go_to_help", callable_mp(this, &ScriptEditor::_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(FindInFilesDialog::SIGNAL_FIND_REQUESTED, callable_mp(this, &ScriptEditor::_start_find_in_files), varray(false));
+ find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, callable_mp(this, &ScriptEditor::_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(FindInFilesPanel::SIGNAL_RESULT_SELECTED, callable_mp(this, &ScriptEditor::_on_find_in_files_result_selected));
+ find_in_files->connect(FindInFilesPanel::SIGNAL_FILES_MODIFIED, callable_mp(this, &ScriptEditor::_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 a41480c80d..b4b4f33fc5 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -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);
@@ -455,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 1432c3fc63..02168a4c97 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -32,10 +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() {
}
@@ -53,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() {
@@ -292,27 +292,34 @@ void ScriptTextEditor::_set_theme_for_script() {
const Color basetype_color = colors_cache.basetype_color;
text_edit->add_keyword_color("String", basetype_color);
text_edit->add_keyword_color("Vector2", basetype_color);
+ text_edit->add_keyword_color("Vector2i", basetype_color);
text_edit->add_keyword_color("Rect2", basetype_color);
- text_edit->add_keyword_color("Transform2D", basetype_color);
+ text_edit->add_keyword_color("Rect2i", basetype_color);
text_edit->add_keyword_color("Vector3", basetype_color);
+ text_edit->add_keyword_color("Vector3i", basetype_color);
+ text_edit->add_keyword_color("Transform2D", basetype_color);
+ text_edit->add_keyword_color("Plane", basetype_color);
+ text_edit->add_keyword_color("Quat", basetype_color);
text_edit->add_keyword_color("AABB", basetype_color);
text_edit->add_keyword_color("Basis", basetype_color);
- text_edit->add_keyword_color("Plane", basetype_color);
text_edit->add_keyword_color("Transform", basetype_color);
- text_edit->add_keyword_color("Quat", basetype_color);
text_edit->add_keyword_color("Color", basetype_color);
- text_edit->add_keyword_color("Object", basetype_color);
+ text_edit->add_keyword_color("StringName", basetype_color);
text_edit->add_keyword_color("NodePath", basetype_color);
text_edit->add_keyword_color("RID", basetype_color);
+ text_edit->add_keyword_color("Object", basetype_color);
+ text_edit->add_keyword_color("Callable", 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("PackedInt64Array", basetype_color);
+ text_edit->add_keyword_color("PackedFloat32Array", 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;
@@ -424,7 +431,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);
@@ -548,13 +555,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() {
@@ -603,12 +610,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.
}
@@ -870,7 +877,7 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
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) {
@@ -1006,24 +1013,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;
}
}
@@ -1036,7 +1043,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;
}
@@ -1212,7 +1219,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];
@@ -1221,17 +1228,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: {
@@ -1258,6 +1265,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());
@@ -1288,7 +1301,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: {
@@ -1299,7 +1312,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: {
@@ -1423,24 +1436,7 @@ void ScriptTextEditor::_change_syntax_highlighter(int p_idx) {
void ScriptTextEditor::_bind_methods() {
- ClassDB::bind_method("_validate_script", &ScriptTextEditor::_validate_script);
- ClassDB::bind_method("_update_bookmark_list", &ScriptTextEditor::_update_bookmark_list);
- ClassDB::bind_method("_bookmark_item_pressed", &ScriptTextEditor::_bookmark_item_pressed);
- ClassDB::bind_method("_load_theme_settings", &ScriptTextEditor::_load_theme_settings);
- ClassDB::bind_method("_update_breakpoint_list", &ScriptTextEditor::_update_breakpoint_list);
- ClassDB::bind_method("_breakpoint_item_pressed", &ScriptTextEditor::_breakpoint_item_pressed);
- ClassDB::bind_method("_breakpoint_toggled", &ScriptTextEditor::_breakpoint_toggled);
- ClassDB::bind_method("_lookup_connections", &ScriptTextEditor::_lookup_connections);
ClassDB::bind_method("_update_connected_methods", &ScriptTextEditor::_update_connected_methods);
- ClassDB::bind_method("_change_syntax_highlighter", &ScriptTextEditor::_change_syntax_highlighter);
- ClassDB::bind_method("_edit_option", &ScriptTextEditor::_edit_option);
- ClassDB::bind_method("_goto_line", &ScriptTextEditor::_goto_line);
- ClassDB::bind_method("_lookup_symbol", &ScriptTextEditor::_lookup_symbol);
- ClassDB::bind_method("_text_edit_gui_input", &ScriptTextEditor::_text_edit_gui_input);
- ClassDB::bind_method("_show_warnings_panel", &ScriptTextEditor::_show_warnings_panel);
- ClassDB::bind_method("_error_pressed", &ScriptTextEditor::_error_pressed);
- ClassDB::bind_method("_warning_clicked", &ScriptTextEditor::_warning_clicked);
- ClassDB::bind_method("_color_changed", &ScriptTextEditor::_color_changed);
ClassDB::bind_method("get_drag_data_fw", &ScriptTextEditor::get_drag_data_fw);
ClassDB::bind_method("can_drop_data_fw", &ScriptTextEditor::can_drop_data_fw);
@@ -1604,7 +1600,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
local_pos = mb->get_global_position() - tx->get_global_position();
create_menu = true;
- } else if (k.is_valid() && k->get_scancode() == KEY_MENU) {
+ } else if (k.is_valid() && k->get_keycode() == KEY_MENU) {
local_pos = tx->_get_cursor_pixel_pos();
create_menu = true;
}
@@ -1768,12 +1764,12 @@ 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("validate_script", callable_mp(this, &ScriptTextEditor::_validate_script));
+ code_editor->connect("load_theme_settings", callable_mp(this, &ScriptTextEditor::_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("breakpoint_toggled", callable_mp(this, &ScriptTextEditor::_breakpoint_toggled));
+ code_editor->get_text_edit()->connect("symbol_lookup", callable_mp(this, &ScriptTextEditor::_lookup_symbol));
+ code_editor->get_text_edit()->connect("info_clicked", callable_mp(this, &ScriptTextEditor::_lookup_connections));
code_editor->set_v_size_flags(SIZE_EXPAND_FILL);
code_editor->show_toggle_scripts_button();
@@ -1786,9 +1782,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("error_pressed", callable_mp(this, &ScriptTextEditor::_error_pressed));
+ code_editor->connect("show_warnings_panel", callable_mp(this, &ScriptTextEditor::_show_warnings_panel));
+ warnings_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_warning_clicked));
update_settings();
@@ -1798,11 +1794,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("gui_input", callable_mp(this, &ScriptTextEditor::_text_edit_gui_input));
context_menu = memnew(PopupMenu);
add_child(context_menu);
- context_menu->connect("id_pressed", this, "_edit_option");
+ context_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
context_menu->set_hide_on_window_lose_focus(true);
color_panel = memnew(PopupPanel);
@@ -1810,7 +1806,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("color_changed", callable_mp(this, &ScriptTextEditor::_color_changed));
// get default color picker mode from editor settings
int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
@@ -1851,7 +1847,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("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
edit_menu->get_popup()->add_separator();
PopupMenu *convert_case = memnew(PopupMenu);
@@ -1861,7 +1857,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("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
highlighters[TTR("Standard")] = NULL;
highlighter_menu = memnew(PopupMenu);
@@ -1869,7 +1865,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("id_pressed", callable_mp(this, &ScriptTextEditor::_change_syntax_highlighter));
search_menu = memnew(MenuButton);
edit_hb->add_child(search_menu);
@@ -1882,9 +1878,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("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
edit_hb->add_child(edit_menu);
@@ -1892,7 +1889,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("id_pressed", callable_mp(this, &ScriptTextEditor::_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);
@@ -1903,20 +1900,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("about_to_show", callable_mp(this, &ScriptTextEditor::_update_bookmark_list));
+ bookmarks_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_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("about_to_show", callable_mp(this, &ScriptTextEditor::_update_breakpoint_list));
+ breakpoints_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_breakpoint_item_pressed));
quick_open = memnew(ScriptEditorQuickOpen);
add_child(quick_open);
- quick_open->connect("goto_line", this, "_goto_line");
+ quick_open->connect("goto_line", callable_mp(this, &ScriptTextEditor::_goto_line));
goto_line_dialog = memnew(GotoLineDialog);
add_child(goto_line_dialog);
@@ -1990,6 +1987,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 9018e9d3c2..e23160d029 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -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,
@@ -199,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);
@@ -219,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 c24a666c55..01b1e21153 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -369,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"));
@@ -381,21 +382,15 @@ void ShaderEditor::_editor_settings_changed() {
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_guidelines(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guidelines"));
+ shader_editor->get_text_edit()->set_line_length_guideline_soft_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_soft_column"));
+ shader_editor->get_text_edit()->set_line_length_guideline_hard_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_hard_column"));
+ shader_editor->get_text_edit()->set_breakpoint_gutter_enabled(false);
}
void ShaderEditor::_bind_methods() {
- ClassDB::bind_method("_reload_shader_from_disk", &ShaderEditor::_reload_shader_from_disk);
- ClassDB::bind_method("_editor_settings_changed", &ShaderEditor::_editor_settings_changed);
- ClassDB::bind_method("_text_edit_gui_input", &ShaderEditor::_text_edit_gui_input);
-
- ClassDB::bind_method("_update_bookmark_list", &ShaderEditor::_update_bookmark_list);
- ClassDB::bind_method("_bookmark_item_pressed", &ShaderEditor::_bookmark_item_pressed);
-
- ClassDB::bind_method("_menu_option", &ShaderEditor::_menu_option);
ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed);
- ClassDB::bind_method("apply_shaders", &ShaderEditor::apply_shaders);
- ClassDB::bind_method("save_external_data", &ShaderEditor::save_external_data);
}
void ShaderEditor::ensure_select_current() {
@@ -527,7 +522,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
Ref<InputEventKey> k = ev;
- if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_MENU) {
+ if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_MENU) {
TextEdit *tx = shader_editor->get_text_edit();
_make_context_menu(tx->is_selection_active(), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos()));
context_menu->grab_focus();
@@ -603,8 +598,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("script_changed", callable_mp(this, &ShaderEditor::apply_shaders));
+ EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ShaderEditor::_editor_settings_changed));
shader_editor->get_text_edit()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"),
@@ -612,13 +607,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("gui_input", callable_mp(this, &ShaderEditor::_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("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
context_menu->set_hide_on_window_lose_focus(true);
VBoxContainer *main_container = memnew(VBoxContainer);
@@ -646,7 +641,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("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
search_menu = memnew(MenuButton);
search_menu->set_text(TTR("Search"));
@@ -656,12 +651,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("id_pressed", callable_mp(this, &ShaderEditor::_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("id_pressed", callable_mp(this, &ShaderEditor::_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();
@@ -671,14 +666,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("about_to_show", callable_mp(this, &ShaderEditor::_update_bookmark_list));
+ bookmarks_menu->connect("index_pressed", callable_mp(this, &ShaderEditor::_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("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
add_child(main_container);
main_container->add_child(hbc);
@@ -701,11 +696,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("confirmed", callable_mp(this, &ShaderEditor::_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("custom_action", callable_mp(this, &ShaderEditor::save_external_data));
add_child(disk_changed);
diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp
index dbe64f202d..0b77b987bf 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_2d_editor_plugin.cpp
@@ -92,8 +92,6 @@ void Skeleton2DEditor::_menu_option(int p_option) {
}
void Skeleton2DEditor::_bind_methods() {
-
- ClassDB::bind_method("_menu_option", &Skeleton2DEditor::_menu_option);
}
Skeleton2DEditor::Skeleton2DEditor() {
@@ -110,7 +108,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("id_pressed", callable_mp(this, &Skeleton2DEditor::_menu_option));
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_editor_plugin.cpp
index 8b5fe7d2c5..07bd6a0e41 100644
--- a/editor/plugins/skeleton_editor_plugin.cpp
+++ b/editor/plugins/skeleton_editor_plugin.cpp
@@ -103,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);
@@ -114,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);
@@ -134,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("node_removed", callable_mp(this, &SkeletonEditor::_node_removed));
}
}
@@ -147,8 +150,6 @@ void SkeletonEditor::_node_removed(Node *p_node) {
}
void SkeletonEditor::_bind_methods() {
- ClassDB::bind_method("_on_click_option", &SkeletonEditor::_on_click_option);
- ClassDB::bind_method("_node_removed", &SkeletonEditor::_node_removed);
}
SkeletonEditor::SkeletonEditor() {
@@ -161,7 +162,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("id_pressed", callable_mp(this, &SkeletonEditor::_on_click_option));
options->hide();
}
diff --git a/editor/plugins/skeleton_ik_editor_plugin.cpp b/editor/plugins/skeleton_ik_editor_plugin.cpp
index 43dc13b270..b031bd71d3 100644
--- a/editor/plugins/skeleton_ik_editor_plugin.cpp
+++ b/editor/plugins/skeleton_ik_editor_plugin.cpp
@@ -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);
}
}
}
@@ -90,8 +81,6 @@ void SkeletonIKEditorPlugin::make_visible(bool p_visible) {
}
void SkeletonIKEditorPlugin::_bind_methods() {
-
- ClassDB::bind_method("_play", &SkeletonIKEditorPlugin::_play);
}
SkeletonIKEditorPlugin::SkeletonIKEditorPlugin(EditorNode *p_node) {
@@ -102,7 +91,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("pressed", callable_mp(this, &SkeletonIKEditorPlugin::_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 06c07031f6..814eb8ff5b 100644
--- a/editor/plugins/skeleton_ik_editor_plugin.h
+++ b/editor/plugins/skeleton_ik_editor_plugin.h
@@ -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 31e6b65640..0bbcbb0080 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -36,12 +36,12 @@
#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"
@@ -250,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));
@@ -260,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) {
@@ -306,7 +309,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
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;
@@ -353,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)) {
@@ -847,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()) {
@@ -861,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);
@@ -1070,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) {
@@ -1114,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();
@@ -1125,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) {
@@ -1150,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) {
@@ -1254,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) {
@@ -1263,7 +1288,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
_compute_edit(_edit.mouse_pos);
- clicked = 0;
+ clicked = ObjectID();
_edit.mode = TRANSFORM_TRANSLATE;
}
@@ -1848,11 +1873,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (!orthogonal && ED_IS_SHORTCUT("spatial_editor/freelook_toggle", p_event)) {
set_freelook_active(!is_freelook_active());
- } else if (k->get_scancode() == KEY_ESCAPE) {
+ } else if (k->get_keycode() == KEY_ESCAPE) {
set_freelook_active(false);
}
- if (k->get_scancode() == KEY_SPACE) {
+ if (k->get_keycode() == KEY_SPACE) {
if (!k->is_pressed()) emit_signal("toggle_maximize_view", this);
}
}
@@ -2049,8 +2074,8 @@ static bool is_shortcut_pressed(const String &p_path) {
return false;
}
const Input &input = *Input::get_singleton();
- int scancode = k->get_scancode();
- return input.is_key_pressed(scancode);
+ int keycode = k->get_keycode();
+ return input.is_key_pressed(keycode);
}
void SpatialEditorViewport::_update_freelook(real_t delta) {
@@ -2122,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);
@@ -2160,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("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
}
previewing = cam;
- previewing->connect("tree_exited", this, "_preview_exited_scene");
+ previewing->connect("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera());
surface->update();
}
@@ -2247,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);
@@ -2307,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("draw", callable_mp(this, &SpatialEditorViewport::_draw));
+ surface->connect("gui_input", callable_mp(this, &SpatialEditorViewport::_sinput));
+ surface->connect("mouse_entered", callable_mp(this, &SpatialEditorViewport::_surface_mouse_enter));
+ surface->connect("mouse_exited", callable_mp(this, &SpatialEditorViewport::_surface_mouse_exit));
+ surface->connect("focus_entered", callable_mp(this, &SpatialEditorViewport::_surface_focus_enter));
+ surface->connect("focus_exited", callable_mp(this, &SpatialEditorViewport::_surface_focus_exit));
_init_gizmo_instance(index);
}
@@ -2346,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();
@@ -2417,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) {
@@ -2738,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("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
preview_camera->set_pressed(false);
_toggle_camera_preview(false);
- preview_camera->connect("toggled", this, "_toggle_camera_preview");
+ preview_camera->connect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
view_menu->show();
}
@@ -2847,7 +2903,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
if (!p_activate) {
- previewing->disconnect("tree_exiting", this, "_preview_exited_scene");
+ previewing->disconnect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
previewing = NULL;
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
if (!preview)
@@ -2858,7 +2914,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
} else {
previewing = preview;
- previewing->connect("tree_exiting", this, "_preview_exited_scene");
+ previewing->connect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
view_menu->set_disabled(true);
surface->update();
@@ -2869,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("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
previewing = NULL;
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
@@ -2891,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();
}
}
@@ -3054,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("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview))) {
+ preview_camera->disconnect("toggled", callable_mp(this, &SpatialEditorViewport::_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("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
view_menu->set_disabled(true);
surface->update();
@@ -3069,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("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
}
Dictionary SpatialEditorViewport::get_state() const {
@@ -3106,19 +3162,7 @@ Dictionary SpatialEditorViewport::get_state() const {
void SpatialEditorViewport::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_draw"), &SpatialEditorViewport::_draw);
-
- ClassDB::bind_method(D_METHOD("_surface_mouse_enter"), &SpatialEditorViewport::_surface_mouse_enter);
- ClassDB::bind_method(D_METHOD("_surface_mouse_exit"), &SpatialEditorViewport::_surface_mouse_exit);
- ClassDB::bind_method(D_METHOD("_surface_focus_enter"), &SpatialEditorViewport::_surface_focus_enter);
- ClassDB::bind_method(D_METHOD("_surface_focus_exit"), &SpatialEditorViewport::_surface_focus_exit);
- ClassDB::bind_method(D_METHOD("_sinput"), &SpatialEditorViewport::_sinput);
- ClassDB::bind_method(D_METHOD("_menu_option"), &SpatialEditorViewport::_menu_option);
- ClassDB::bind_method(D_METHOD("_toggle_camera_preview"), &SpatialEditorViewport::_toggle_camera_preview);
- ClassDB::bind_method(D_METHOD("_preview_exited_scene"), &SpatialEditorViewport::_preview_exited_scene);
- ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &SpatialEditorViewport::update_transform_gizmo_view);
- ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &SpatialEditorViewport::_selection_result_pressed);
- ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &SpatialEditorViewport::_selection_menu_hide);
+ ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &SpatialEditorViewport::update_transform_gizmo_view); // Used by call_deferred.
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpatialEditorViewport::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpatialEditorViewport::drop_data_fw);
@@ -3365,9 +3409,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);
@@ -3527,7 +3571,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;
@@ -3569,6 +3613,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);
@@ -3585,8 +3632,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);
@@ -3608,12 +3672,12 @@ 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("id_pressed", callable_mp(this, &SpatialEditorViewport::_menu_option));
+ display_submenu->connect("id_pressed", callable_mp(this, &SpatialEditorViewport::_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 GLES3 renderer; make this explicit.
+ // 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);
@@ -3644,7 +3708,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("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
previewing = NULL;
gizmo_scale = 1.0;
@@ -3697,8 +3761,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("id_pressed", callable_mp(this, &SpatialEditorViewport::_selection_result_pressed));
+ selection_menu->connect("popup_hide", callable_mp(this, &SpatialEditorViewport::_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);
@@ -3708,7 +3772,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("settings_changed", callable_mp(this, &SpatialEditorViewport::update_transform_gizmo_view));
}
//////////////////////////////////////////////////////////////
@@ -3816,12 +3880,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();
@@ -4173,12 +4237,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();
}
@@ -4421,7 +4485,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;
@@ -4478,7 +4542,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) {
@@ -4732,9 +4796,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;
@@ -4817,14 +4881,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;
@@ -4912,17 +4976,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
}
@@ -5042,17 +5106,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
}
@@ -5107,8 +5171,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");
@@ -5395,12 +5459,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("node_removed", callable_mp(this, &SpatialEditor::_node_removed));
+ EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &SpatialEditor::_refresh_menu_icons));
+ editor_selection->connect("selection_changed", callable_mp(this, &SpatialEditor::_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("stop_pressed", callable_mp(this, &SpatialEditor::_update_camera_override_button), make_binds(false));
+ editor->connect("play_pressed", callable_mp(this, &SpatialEditor::_update_camera_override_button), make_binds(true));
} else if (p_what == NOTIFICATION_ENTER_TREE) {
_register_all_gizmos();
@@ -5437,7 +5501,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);
@@ -5566,7 +5630,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)));
@@ -5577,17 +5641,8 @@ void SpatialEditor::_register_all_gizmos() {
void SpatialEditor::_bind_methods() {
ClassDB::bind_method("_unhandled_key_input", &SpatialEditor::_unhandled_key_input);
- ClassDB::bind_method("_node_removed", &SpatialEditor::_node_removed);
- ClassDB::bind_method("_menu_item_pressed", &SpatialEditor::_menu_item_pressed);
- ClassDB::bind_method("_menu_gizmo_toggled", &SpatialEditor::_menu_gizmo_toggled);
- ClassDB::bind_method("_menu_item_toggled", &SpatialEditor::_menu_item_toggled);
- ClassDB::bind_method("_xform_dialog_action", &SpatialEditor::_xform_dialog_action);
ClassDB::bind_method("_get_editor_data", &SpatialEditor::_get_editor_data);
ClassDB::bind_method("_request_gizmo", &SpatialEditor::_request_gizmo);
- ClassDB::bind_method("_toggle_maximize_view", &SpatialEditor::_toggle_maximize_view);
- ClassDB::bind_method("_refresh_menu_icons", &SpatialEditor::_refresh_menu_icons);
- ClassDB::bind_method("_update_camera_override_button", &SpatialEditor::_update_camera_override_button);
- ClassDB::bind_method("_update_camera_override_viewport", &SpatialEditor::_update_camera_override_viewport);
ADD_SIGNAL(MethodInfo("transform_key_request"));
ADD_SIGNAL(MethodInfo("item_lock_status_changed"));
@@ -5656,7 +5711,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("pressed", callable_mp(this, &SpatialEditor::_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"));
@@ -5667,7 +5722,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("pressed", callable_mp(this, &SpatialEditor::_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);
@@ -5675,7 +5730,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("pressed", callable_mp(this, &SpatialEditor::_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);
@@ -5683,7 +5738,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("pressed", callable_mp(this, &SpatialEditor::_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));
@@ -5693,31 +5748,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("pressed", callable_mp(this, &SpatialEditor::_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("pressed", callable_mp(this, &SpatialEditor::_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("pressed", callable_mp(this, &SpatialEditor::_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("pressed", callable_mp(this, &SpatialEditor::_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("pressed", callable_mp(this, &SpatialEditor::_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));
@@ -5727,7 +5782,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("toggled", callable_mp(this, &SpatialEditor::_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);
@@ -5735,7 +5790,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("toggled", callable_mp(this, &SpatialEditor::_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));
@@ -5746,7 +5801,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("toggled", callable_mp(this, &SpatialEditor::_menu_item_toggled), button_binds);
_update_camera_override_button(false);
hbc_menu->add_child(memnew(VSeparator));
@@ -5783,7 +5838,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("id_pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed));
view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
@@ -5815,13 +5870,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("id_pressed", callable_mp(this, &SpatialEditor::_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("id_pressed", callable_mp(this, &SpatialEditor::_menu_gizmo_toggled));
/* REST OF MENU */
@@ -5838,8 +5893,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("toggle_maximize_view", callable_mp(this, &SpatialEditor::_toggle_maximize_view));
+ viewports[i]->connect("clicked", callable_mp(this, &SpatialEditor::_update_camera_override_viewport));
viewports[i]->assign_pending_data_pointers(preview_node, &preview_bounds, accept);
viewport_base->add_child(viewports[i]);
}
@@ -5954,7 +6009,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("confirmed", callable_mp(this, &SpatialEditor::_xform_dialog_action));
scenario_debug = VisualServer::SCENARIO_DEBUG_DISABLED;
@@ -5966,7 +6021,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;
}
@@ -6108,7 +6163,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() {
@@ -6118,13 +6173,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;
@@ -6133,17 +6188,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) {
@@ -6156,17 +6211,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;
@@ -6176,16 +6231,16 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const
icon->set_albedo(color);
- icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- icon->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- icon->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, 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();
@@ -6198,46 +6253,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 5cc2b24cbb..a4d6b13389 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -167,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:
@@ -205,6 +216,7 @@ private:
ViewportContainer *viewport_container;
MenuButton *view_menu;
+ PopupMenu *display_submenu;
Control *surface;
Viewport *viewport;
@@ -234,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);
@@ -527,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;
@@ -539,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;
@@ -776,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();
@@ -785,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 6757b180a3..135807e88c 100644
--- a/editor/plugins/sprite_editor_plugin.cpp
+++ b/editor/plugins/sprite_editor_plugin.cpp
@@ -167,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();
@@ -330,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);
@@ -358,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;
@@ -376,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];
@@ -442,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];
}
@@ -476,7 +476,7 @@ void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node)
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);
@@ -504,10 +504,6 @@ void SpriteEditor::_debug_uv_draw() {
void SpriteEditor::_bind_methods() {
- ClassDB::bind_method("_menu_option", &SpriteEditor::_menu_option);
- ClassDB::bind_method("_debug_uv_draw", &SpriteEditor::_debug_uv_draw);
- ClassDB::bind_method("_update_mesh_data", &SpriteEditor::_update_mesh_data);
- ClassDB::bind_method("_create_node", &SpriteEditor::_create_node);
ClassDB::bind_method("_add_as_sibling_or_child", &SpriteEditor::_add_as_sibling_or_child);
}
@@ -526,7 +522,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("id_pressed", callable_mp(this, &SpriteEditor::_menu_option));
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
@@ -542,9 +538,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("draw", callable_mp(this, &SpriteEditor::_debug_uv_draw));
scroll->add_child(debug_uv);
- debug_uv_dialog->connect("confirmed", this, "_create_node");
+ debug_uv_dialog->connect("confirmed", callable_mp(this, &SpriteEditor::_create_node));
HBoxContainer *hb = memnew(HBoxContainer);
hb->add_child(memnew(Label(TTR("Simplification: "))));
@@ -573,7 +569,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("pressed", callable_mp(this, &SpriteEditor::_update_mesh_data));
hb->add_child(update_preview);
vb->add_margin_child(TTR("Settings:"), hb);
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 4101980e29..5d615c7553 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -44,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]);
}
@@ -234,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"));
@@ -245,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()) {
@@ -278,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);
@@ -297,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]);
@@ -310,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!"));
@@ -333,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;
}
@@ -356,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);
@@ -381,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);
@@ -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()) {
@@ -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);
}
@@ -860,33 +860,10 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
void SpriteFramesEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_load_pressed"), &SpriteFramesEditor::_load_pressed);
- ClassDB::bind_method(D_METHOD("_empty_pressed"), &SpriteFramesEditor::_empty_pressed);
- ClassDB::bind_method(D_METHOD("_empty2_pressed"), &SpriteFramesEditor::_empty2_pressed);
- ClassDB::bind_method(D_METHOD("_delete_pressed"), &SpriteFramesEditor::_delete_pressed);
- ClassDB::bind_method(D_METHOD("_copy_pressed"), &SpriteFramesEditor::_copy_pressed);
- ClassDB::bind_method(D_METHOD("_paste_pressed"), &SpriteFramesEditor::_paste_pressed);
- ClassDB::bind_method(D_METHOD("_file_load_request", "files", "at_position"), &SpriteFramesEditor::_file_load_request, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("_update_library", "skipsel"), &SpriteFramesEditor::_update_library, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("_up_pressed"), &SpriteFramesEditor::_up_pressed);
- ClassDB::bind_method(D_METHOD("_down_pressed"), &SpriteFramesEditor::_down_pressed);
- ClassDB::bind_method(D_METHOD("_animation_select"), &SpriteFramesEditor::_animation_select);
- ClassDB::bind_method(D_METHOD("_animation_name_edited"), &SpriteFramesEditor::_animation_name_edited);
- ClassDB::bind_method(D_METHOD("_animation_add"), &SpriteFramesEditor::_animation_add);
- ClassDB::bind_method(D_METHOD("_animation_remove"), &SpriteFramesEditor::_animation_remove);
- ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"), &SpriteFramesEditor::_animation_remove_confirmed);
- ClassDB::bind_method(D_METHOD("_animation_loop_changed"), &SpriteFramesEditor::_animation_loop_changed);
- ClassDB::bind_method(D_METHOD("_animation_fps_changed"), &SpriteFramesEditor::_animation_fps_changed);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpriteFramesEditor::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpriteFramesEditor::drop_data_fw);
- ClassDB::bind_method(D_METHOD("_prepare_sprite_sheet"), &SpriteFramesEditor::_prepare_sprite_sheet);
- ClassDB::bind_method(D_METHOD("_open_sprite_sheet"), &SpriteFramesEditor::_open_sprite_sheet);
- ClassDB::bind_method(D_METHOD("_sheet_preview_draw"), &SpriteFramesEditor::_sheet_preview_draw);
- ClassDB::bind_method(D_METHOD("_sheet_preview_input"), &SpriteFramesEditor::_sheet_preview_input);
- ClassDB::bind_method(D_METHOD("_sheet_spin_changed"), &SpriteFramesEditor::_sheet_spin_changed);
- ClassDB::bind_method(D_METHOD("_sheet_add_frames"), &SpriteFramesEditor::_sheet_add_frames);
- ClassDB::bind_method(D_METHOD("_sheet_select_clear_all_frames"), &SpriteFramesEditor::_sheet_select_clear_all_frames);
}
SpriteFramesEditor::SpriteFramesEditor() {
@@ -905,19 +882,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("pressed", callable_mp(this, &SpriteFramesEditor::_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("pressed", callable_mp(this, &SpriteFramesEditor::_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("cell_selected", callable_mp(this, &SpriteFramesEditor::_animation_select));
+ animations->connect("item_edited", callable_mp(this, &SpriteFramesEditor::_animation_name_edited));
animations->set_allow_reselect(true);
anim_speed = memnew(SpinBox);
@@ -925,12 +902,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("value_changed", callable_mp(this, &SpriteFramesEditor::_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("pressed", callable_mp(this, &SpriteFramesEditor::_animation_loop_changed));
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
@@ -1004,16 +981,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("pressed", callable_mp(this, &SpriteFramesEditor::_load_pressed));
+ load_sheet->connect("pressed", callable_mp(this, &SpriteFramesEditor::_open_sprite_sheet));
+ _delete->connect("pressed", callable_mp(this, &SpriteFramesEditor::_delete_pressed));
+ copy->connect("pressed", callable_mp(this, &SpriteFramesEditor::_copy_pressed));
+ paste->connect("pressed", callable_mp(this, &SpriteFramesEditor::_paste_pressed));
+ empty->connect("pressed", callable_mp(this, &SpriteFramesEditor::_empty_pressed));
+ empty2->connect("pressed", callable_mp(this, &SpriteFramesEditor::_empty2_pressed));
+ move_up->connect("pressed", callable_mp(this, &SpriteFramesEditor::_up_pressed));
+ move_down->connect("pressed", callable_mp(this, &SpriteFramesEditor::_down_pressed));
+ file->connect("files_selected", callable_mp(this, &SpriteFramesEditor::_file_load_request), make_binds(-1));
loading_scene = false;
sel = -1;
@@ -1023,14 +1000,14 @@ SpriteFramesEditor::SpriteFramesEditor() {
delete_dialog = memnew(ConfirmationDialog);
add_child(delete_dialog);
- delete_dialog->connect("confirmed", this, "_animation_remove_confirmed");
+ delete_dialog->connect("confirmed", callable_mp(this, &SpriteFramesEditor::_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("confirmed", callable_mp(this, &SpriteFramesEditor::_sheet_add_frames));
HBoxContainer *split_sheet_hb = memnew(HBoxContainer);
@@ -1041,7 +1018,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("value_changed", callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed));
ss_label = memnew(Label(TTR("Vertical:")));
split_sheet_hb->add_child(ss_label);
@@ -1050,13 +1027,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("value_changed", callable_mp(this, &SpriteFramesEditor::_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("pressed", callable_mp(this, &SpriteFramesEditor::_sheet_select_clear_all_frames));
split_sheet_hb->add_child(select_clear_all);
split_sheet_vb->add_child(split_sheet_hb);
@@ -1064,8 +1041,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("draw", callable_mp(this, &SpriteFramesEditor::_sheet_preview_draw));
+ split_sheet_preview->connect("gui_input", callable_mp(this, &SpriteFramesEditor::_sheet_preview_input));
splite_sheet_scroll = memnew(ScrollContainer);
splite_sheet_scroll->set_enable_h_scroll(true);
@@ -1083,7 +1060,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("file_selected", callable_mp(this, &SpriteFramesEditor::_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 aa683605ed..1fa93b5c47 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -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 eebcd567a4..a92194da17 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -54,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("changed", callable_mp(this, &StyleBoxPreview::_sb_changed));
stylebox = p_stylebox;
if (p_stylebox.is_valid()) {
preview->add_style_override("panel", stylebox);
- stylebox->connect("changed", this, "_sb_changed");
+ stylebox->connect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed));
}
_sb_changed();
}
@@ -82,16 +82,13 @@ void StyleBoxPreview::_redraw() {
}
void StyleBoxPreview::_bind_methods() {
-
- ClassDB::bind_method("_sb_changed", &StyleBoxPreview::_sb_changed);
- ClassDB::bind_method("_redraw", &StyleBoxPreview::_redraw);
}
StyleBoxPreview::StyleBoxPreview() {
preview = memnew(Control);
preview->set_custom_minimum_size(Size2(0, 150 * EDSCALE));
preview->set_clip_contents(true);
- preview->connect("draw", this, "_redraw");
+ preview->connect("draw", callable_mp(this, &StyleBoxPreview::_redraw));
add_margin_child(TTR("Preview:"), preview);
}
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 57447abf47..35f23ccf1d 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -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);
@@ -520,14 +526,6 @@ void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
}
void TextEditor::_bind_methods() {
-
- ClassDB::bind_method("_validate_script", &TextEditor::_validate_script);
- ClassDB::bind_method("_update_bookmark_list", &TextEditor::_update_bookmark_list);
- ClassDB::bind_method("_bookmark_item_pressed", &TextEditor::_bookmark_item_pressed);
- ClassDB::bind_method("_load_theme_settings", &TextEditor::_load_theme_settings);
- ClassDB::bind_method("_edit_option", &TextEditor::_edit_option);
- ClassDB::bind_method("_change_syntax_highlighter", &TextEditor::_change_syntax_highlighter);
- ClassDB::bind_method("_text_edit_gui_input", &TextEditor::_text_edit_gui_input);
}
static ScriptEditorBase *create_editor(const RES &p_resource) {
@@ -584,7 +582,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
Ref<InputEventKey> k = ev;
- if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_MENU) {
+ if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_MENU) {
TextEdit *tx = code_editor->get_text_edit();
int line = tx->cursor_get_line();
_make_context_menu(tx->is_selection_active(), tx->can_fold(line), tx->is_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos()));
@@ -627,19 +625,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("load_theme_settings", callable_mp(this, &TextEditor::_load_theme_settings));
+ code_editor->connect("validate_script", callable_mp(this, &TextEditor::_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("gui_input", callable_mp(this, &TextEditor::_text_edit_gui_input));
context_menu = memnew(PopupMenu);
add_child(context_menu);
- context_menu->connect("id_pressed", this, "_edit_option");
+ context_menu->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option));
edit_hb = memnew(HBoxContainer);
@@ -647,7 +645,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("id_pressed", callable_mp(this, &TextEditor::_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 +653,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("id_pressed", callable_mp(this, &TextEditor::_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 +692,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("id_pressed", callable_mp(this, &TextEditor::_edit_option));
highlighters["Standard"] = NULL;
highlighter_menu = memnew(PopupMenu);
@@ -701,13 +700,13 @@ 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("id_pressed", callable_mp(this, &TextEditor::_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("id_pressed", callable_mp(this, &TextEditor::_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();
@@ -717,8 +716,8 @@ TextEditor::TextEditor() {
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("about_to_show", callable_mp(this, &TextEditor::_update_bookmark_list));
+ bookmarks_menu->connect("index_pressed", callable_mp(this, &TextEditor::_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 fe157a29e6..c80052e7ba 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -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 9489836984..60f9bb5dc1 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -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 f587579902..29ad0183dc 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -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 507ea0b83d..2262e12f5d 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -49,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)
@@ -134,7 +134,7 @@ void TextureRegionEditor::_region_draw() {
}
}
- Ref<Texture> select_handle = get_icon("EditorHandle", "EditorIcons");
+ Ref<Texture2D> select_handle = get_icon("EditorHandle", "EditorIcons");
Rect2 scroll_rect(Point2(), base_tex->get_size());
@@ -546,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) {
@@ -661,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)
@@ -767,21 +778,8 @@ void TextureRegionEditor::_node_removed(Object *p_obj) {
void TextureRegionEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_edit_region"), &TextureRegionEditor::_edit_region);
- ClassDB::bind_method(D_METHOD("_region_draw"), &TextureRegionEditor::_region_draw);
- ClassDB::bind_method(D_METHOD("_region_input"), &TextureRegionEditor::_region_input);
- ClassDB::bind_method(D_METHOD("_scroll_changed"), &TextureRegionEditor::_scroll_changed);
ClassDB::bind_method(D_METHOD("_node_removed"), &TextureRegionEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_set_snap_mode"), &TextureRegionEditor::_set_snap_mode);
- ClassDB::bind_method(D_METHOD("_set_snap_off_x"), &TextureRegionEditor::_set_snap_off_x);
- ClassDB::bind_method(D_METHOD("_set_snap_off_y"), &TextureRegionEditor::_set_snap_off_y);
- ClassDB::bind_method(D_METHOD("_set_snap_step_x"), &TextureRegionEditor::_set_snap_step_x);
- ClassDB::bind_method(D_METHOD("_set_snap_step_y"), &TextureRegionEditor::_set_snap_step_y);
- ClassDB::bind_method(D_METHOD("_set_snap_sep_x"), &TextureRegionEditor::_set_snap_sep_x);
- ClassDB::bind_method(D_METHOD("_set_snap_sep_y"), &TextureRegionEditor::_set_snap_sep_y);
ClassDB::bind_method(D_METHOD("_zoom_on_position"), &TextureRegionEditor::_zoom_on_position);
- ClassDB::bind_method(D_METHOD("_zoom_in"), &TextureRegionEditor::_zoom_in);
- ClassDB::bind_method(D_METHOD("_zoom_reset"), &TextureRegionEditor::_zoom_reset);
- ClassDB::bind_method(D_METHOD("_zoom_out"), &TextureRegionEditor::_zoom_out);
ClassDB::bind_method(D_METHOD("_update_rect"), &TextureRegionEditor::_update_rect);
}
@@ -852,7 +850,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)
@@ -924,7 +922,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("item_selected", callable_mp(this, &TextureRegionEditor::_set_snap_mode));
hb_grid = memnew(HBoxContainer);
hb_tools->add_child(hb_grid);
@@ -938,7 +936,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("value_changed", callable_mp(this, &TextureRegionEditor::_set_snap_off_x));
hb_grid->add_child(sb_off_x);
sb_off_y = memnew(SpinBox);
@@ -947,7 +945,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("value_changed", callable_mp(this, &TextureRegionEditor::_set_snap_off_y));
hb_grid->add_child(sb_off_y);
hb_grid->add_child(memnew(VSeparator));
@@ -959,7 +957,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("value_changed", callable_mp(this, &TextureRegionEditor::_set_snap_step_x));
hb_grid->add_child(sb_step_x);
sb_step_y = memnew(SpinBox);
@@ -968,7 +966,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("value_changed", callable_mp(this, &TextureRegionEditor::_set_snap_step_y));
hb_grid->add_child(sb_step_y);
hb_grid->add_child(memnew(VSeparator));
@@ -980,7 +978,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("value_changed", callable_mp(this, &TextureRegionEditor::_set_snap_sep_x));
hb_grid->add_child(sb_sep_x);
sb_sep_y = memnew(SpinBox);
@@ -989,7 +987,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("value_changed", callable_mp(this, &TextureRegionEditor::_set_snap_sep_y));
hb_grid->add_child(sb_sep_y);
hb_grid->hide();
@@ -997,8 +995,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("draw", callable_mp(this, &TextureRegionEditor::_region_draw));
+ edit_draw->connect("gui_input", callable_mp(this, &TextureRegionEditor::_region_input));
draw_zoom = 1.0;
edit_draw->set_clip_contents(true);
@@ -1009,27 +1007,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("pressed", callable_mp(this, &TextureRegionEditor::_zoom_out));
zoom_hb->add_child(zoom_out);
zoom_reset = memnew(ToolButton);
zoom_reset->set_tooltip(TTR("Zoom Reset"));
- zoom_reset->connect("pressed", this, "_zoom_reset");
+ zoom_reset->connect("pressed", callable_mp(this, &TextureRegionEditor::_zoom_reset));
zoom_hb->add_child(zoom_reset);
zoom_in = memnew(ToolButton);
zoom_in->set_tooltip(TTR("Zoom In"));
- zoom_in->connect("pressed", this, "_zoom_in");
+ zoom_in->connect("pressed", callable_mp(this, &TextureRegionEditor::_zoom_in));
zoom_hb->add_child(zoom_in);
vscroll = memnew(VScrollBar);
vscroll->set_step(0.001);
edit_draw->add_child(vscroll);
- vscroll->connect("value_changed", this, "_scroll_changed");
+ vscroll->connect("value_changed", callable_mp(this, &TextureRegionEditor::_scroll_changed));
hscroll = memnew(HScrollBar);
hscroll->set_step(0.001);
edit_draw->add_child(hscroll);
- hscroll->connect("value_changed", this, "_scroll_changed");
+ hscroll->connect("value_changed", callable_mp(this, &TextureRegionEditor::_scroll_changed));
updating_scroll = false;
}
@@ -1104,7 +1102,6 @@ void TextureRegionEditorPlugin::set_state(const Dictionary &p_state) {
}
void TextureRegionEditorPlugin::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_editor_visiblity_changed"), &TextureRegionEditorPlugin::_editor_visiblity_changed);
}
TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node) {
@@ -1114,7 +1111,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("visibility_changed", callable_mp(this, &TextureRegionEditorPlugin::_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/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 22105f7ed4..d5b52e9711 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -122,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;
@@ -167,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);
@@ -291,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");
}
@@ -324,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;
@@ -341,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>());
}
}
{
@@ -454,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;
@@ -598,13 +598,6 @@ void ThemeEditor::_notification(int p_what) {
}
void ThemeEditor::_bind_methods() {
-
- ClassDB::bind_method("_type_menu_cbk", &ThemeEditor::_type_menu_cbk);
- ClassDB::bind_method("_name_menu_about_to_show", &ThemeEditor::_name_menu_about_to_show);
- ClassDB::bind_method("_name_menu_cbk", &ThemeEditor::_name_menu_cbk);
- ClassDB::bind_method("_theme_menu_cbk", &ThemeEditor::_theme_menu_cbk);
- ClassDB::bind_method("_dialog_cbk", &ThemeEditor::_dialog_cbk);
- ClassDB::bind_method("_save_template_cbk", &ThemeEditor::_save_template_cbk);
}
ThemeEditor::ThemeEditor() {
@@ -629,7 +622,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("id_pressed", callable_mp(this, &ThemeEditor::_theme_menu_cbk));
ScrollContainer *scroll = memnew(ScrollContainer);
add_child(scroll);
@@ -835,7 +828,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("id_pressed", callable_mp(this, &ThemeEditor::_type_menu_cbk));
l = memnew(Label);
l->set_text(TTR("Name:"));
@@ -853,8 +846,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("about_to_show", callable_mp(this, &ThemeEditor::_name_menu_about_to_show));
+ name_menu->get_popup()->connect("id_pressed", callable_mp(this, &ThemeEditor::_name_menu_cbk));
type_select_label = memnew(Label);
type_select_label->set_text(TTR("Data Type:"));
@@ -869,12 +862,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("pressed", callable_mp(this, &ThemeEditor::_dialog_cbk));
file_dialog = memnew(EditorFileDialog);
file_dialog->add_filter("*.theme ; " + TTR("Theme File"));
add_child(file_dialog);
- file_dialog->connect("file_selected", this, "_save_template_cbk");
+ file_dialog->connect("file_selected", callable_mp(this, &ThemeEditor::_save_template_cbk));
}
void ThemeEditorPlugin::edit(Object *p_node) {
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index f889228f87..017f986469 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -55,7 +55,7 @@ void TileMapEditor::_notification(int p_what) {
if (is_visible_in_tree()) {
_update_palette();
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case NOTIFICATION_ENTER_TREE: {
@@ -359,10 +359,10 @@ void TileMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
Ref<InputEventKey> k = p_ie;
- if (k.is_valid() && (k->get_scancode() == KEY_UP ||
- k->get_scancode() == KEY_DOWN ||
- k->get_scancode() == KEY_PAGEUP ||
- k->get_scancode() == KEY_PAGEDOWN)) {
+ if (k.is_valid() && (k->get_keycode() == KEY_UP ||
+ k->get_keycode() == KEY_DOWN ||
+ k->get_keycode() == KEY_PAGEUP ||
+ k->get_keycode() == KEY_PAGEDOWN)) {
palette->call("_gui_input", k);
search_box->accept_event();
@@ -468,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);
@@ -528,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++) {
@@ -598,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;
@@ -607,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();
@@ -640,14 +640,14 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
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;
@@ -698,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"];
@@ -716,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++) {
@@ -761,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;
@@ -882,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) {
@@ -1109,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;
@@ -1216,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;
@@ -1377,7 +1377,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (k.is_valid() && k->is_pressed()) {
- if (last_tool == TOOL_NONE && tool == TOOL_PICKING && k->get_scancode() == KEY_SHIFT && k->get_command()) {
+ if (last_tool == TOOL_NONE && tool == TOOL_PICKING && k->get_keycode() == KEY_SHIFT && k->get_command()) {
// trying to draw a rectangle with the painting tool, so change to the correct tool
tool = last_tool;
@@ -1385,7 +1385,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_update_button_tool();
}
- if (k->get_scancode() == KEY_ESCAPE) {
+ if (k->get_keycode() == KEY_ESCAPE) {
if (tool == TOOL_PASTING)
copydata.clear();
@@ -1506,7 +1506,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_NONE) {
- if (k->get_scancode() == KEY_SHIFT && k->get_command()) {
+ if (k->get_keycode() == KEY_SHIFT && k->get_command()) {
tool = TOOL_PICKING;
_update_button_tool();
@@ -1514,9 +1514,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else if (tool == TOOL_PICKING) {
#ifdef APPLE_STYLE_KEYS
- if (k->get_scancode() == KEY_META) {
+ if (k->get_keycode() == KEY_META) {
#else
- if (k->get_scancode() == KEY_CONTROL) {
+ if (k->get_keycode() == KEY_CONTROL) {
#endif
// Go back to that last tool if KEY_CONTROL was released.
tool = last_tool;
@@ -1761,30 +1761,30 @@ void TileMapEditor::edit(Node *p_tile_map) {
}
if (node)
- node->disconnect("settings_changed", this, "_tileset_settings_changed");
+ node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_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("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter)))
+ canvas_item_editor_viewport->connect("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter));
+ if (!canvas_item_editor_viewport->is_connected("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit)))
+ canvas_item_editor_viewport->connect("mouse_exited", callable_mp(this, &TileMapEditor::_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("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter)))
+ canvas_item_editor_viewport->disconnect("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter));
+ if (canvas_item_editor_viewport->is_connected("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit)))
+ canvas_item_editor_viewport->disconnect("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit));
_update_palette();
}
if (node)
- node->connect("settings_changed", this, "_tileset_settings_changed");
+ node->connect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed));
_clear_bucket_cache();
}
@@ -1805,27 +1805,8 @@ void TileMapEditor::_icon_size_changed(float p_value) {
void TileMapEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_manual_toggled"), &TileMapEditor::_manual_toggled);
- ClassDB::bind_method(D_METHOD("_priority_toggled"), &TileMapEditor::_priority_toggled);
- ClassDB::bind_method(D_METHOD("_text_entered"), &TileMapEditor::_text_entered);
- ClassDB::bind_method(D_METHOD("_text_changed"), &TileMapEditor::_text_changed);
- ClassDB::bind_method(D_METHOD("_sbox_input"), &TileMapEditor::_sbox_input);
- ClassDB::bind_method(D_METHOD("_button_tool_select"), &TileMapEditor::_button_tool_select);
- ClassDB::bind_method(D_METHOD("_menu_option"), &TileMapEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_canvas_mouse_enter"), &TileMapEditor::_canvas_mouse_enter);
- ClassDB::bind_method(D_METHOD("_canvas_mouse_exit"), &TileMapEditor::_canvas_mouse_exit);
- ClassDB::bind_method(D_METHOD("_tileset_settings_changed"), &TileMapEditor::_tileset_settings_changed);
- ClassDB::bind_method(D_METHOD("_rotate"), &TileMapEditor::_rotate);
- ClassDB::bind_method(D_METHOD("_flip_horizontal"), &TileMapEditor::_flip_horizontal);
- ClassDB::bind_method(D_METHOD("_flip_vertical"), &TileMapEditor::_flip_vertical);
- ClassDB::bind_method(D_METHOD("_clear_transform"), &TileMapEditor::_clear_transform);
- ClassDB::bind_method(D_METHOD("_palette_selected"), &TileMapEditor::_palette_selected);
- ClassDB::bind_method(D_METHOD("_palette_multi_selected"), &TileMapEditor::_palette_multi_selected);
-
ClassDB::bind_method(D_METHOD("_fill_points"), &TileMapEditor::_fill_points);
ClassDB::bind_method(D_METHOD("_erase_points"), &TileMapEditor::_erase_points);
-
- ClassDB::bind_method(D_METHOD("_icon_size_changed"), &TileMapEditor::_icon_size_changed);
}
TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i &p_pos) {
@@ -1939,20 +1920,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("toggled", callable_mp(this, &TileMapEditor::_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("toggled", callable_mp(this, &TileMapEditor::_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("text_entered", callable_mp(this, &TileMapEditor::_text_entered));
+ search_box->connect("text_changed", callable_mp(this, &TileMapEditor::_text_changed));
+ search_box->connect("gui_input", callable_mp(this, &TileMapEditor::_sbox_input));
add_child(search_box);
size_slider = memnew(HSlider);
@@ -1961,7 +1942,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("value_changed", callable_mp(this, &TileMapEditor::_icon_size_changed));
add_child(size_slider);
int mw = EDITOR_DEF("editors/tile_map/palette_min_width", 80);
@@ -1980,8 +1961,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("item_selected", callable_mp(this, &TileMapEditor::_palette_selected));
+ palette->connect("multi_selected", callable_mp(this, &TileMapEditor::_palette_multi_selected));
palette_container->add_child(palette);
// Add message for when no texture is selected.
@@ -2015,25 +1996,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("pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_SELECTING));
select_button->set_toggle_mode(true);
toolbar->add_child(select_button);
@@ -2068,40 +2049,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("id_pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_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("pressed", callable_mp(this, &TileMapEditor::_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);
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index 927f0887bb..74969d3e64 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -123,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 {
@@ -164,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();
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index b24d5add9f..d23b037ed4 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -62,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())
@@ -109,8 +109,8 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
Node *child2 = mi->get_child(j);
- if (Object::cast_to<NavigationPolygonInstance>(child2))
- nav_poly = Object::cast_to<NavigationPolygonInstance>(child2)->get_navigation_polygon();
+ if (Object::cast_to<NavigationRegion2D>(child2))
+ nav_poly = Object::cast_to<NavigationRegion2D>(child2)->get_navigation_polygon();
if (Object::cast_to<LightOccluder2D>(child2))
occluder = Object::cast_to<LightOccluder2D>(child2)->get_occluder_polygon();
@@ -195,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()) {
@@ -237,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);
@@ -251,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);
}
@@ -260,27 +260,11 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C
void TileSetEditor::_bind_methods() {
ClassDB::bind_method("_undo_redo_import_scene", &TileSetEditor::_undo_redo_import_scene);
- ClassDB::bind_method("_on_tileset_toolbar_button_pressed", &TileSetEditor::_on_tileset_toolbar_button_pressed);
- ClassDB::bind_method("_on_textures_added", &TileSetEditor::_on_textures_added);
- ClassDB::bind_method("_on_tileset_toolbar_confirm", &TileSetEditor::_on_tileset_toolbar_confirm);
- ClassDB::bind_method("_on_texture_list_selected", &TileSetEditor::_on_texture_list_selected);
- ClassDB::bind_method("_on_edit_mode_changed", &TileSetEditor::_on_edit_mode_changed);
- ClassDB::bind_method("_on_workspace_mode_changed", &TileSetEditor::_on_workspace_mode_changed);
- ClassDB::bind_method("_on_workspace_overlay_draw", &TileSetEditor::_on_workspace_overlay_draw);
- ClassDB::bind_method("_on_workspace_process", &TileSetEditor::_on_workspace_process);
- ClassDB::bind_method("_on_workspace_draw", &TileSetEditor::_on_workspace_draw);
- ClassDB::bind_method("_on_workspace_input", &TileSetEditor::_on_workspace_input);
- ClassDB::bind_method("_on_tool_clicked", &TileSetEditor::_on_tool_clicked);
- ClassDB::bind_method("_on_priority_changed", &TileSetEditor::_on_priority_changed);
- ClassDB::bind_method("_on_z_index_changed", &TileSetEditor::_on_z_index_changed);
- ClassDB::bind_method("_on_grid_snap_toggled", &TileSetEditor::_on_grid_snap_toggled);
+ ClassDB::bind_method("_on_workspace_process", &TileSetEditor::_on_workspace_process); // Still used by some connect_compat.
ClassDB::bind_method("_set_snap_step", &TileSetEditor::_set_snap_step);
ClassDB::bind_method("_set_snap_off", &TileSetEditor::_set_snap_off);
ClassDB::bind_method("_set_snap_sep", &TileSetEditor::_set_snap_sep);
ClassDB::bind_method("_validate_current_tile_id", &TileSetEditor::_validate_current_tile_id);
- ClassDB::bind_method("_zoom_in", &TileSetEditor::_zoom_in);
- ClassDB::bind_method("_zoom_out", &TileSetEditor::_zoom_out);
- ClassDB::bind_method("_zoom_reset", &TileSetEditor::_zoom_reset);
ClassDB::bind_method("_select_edited_shape_coord", &TileSetEditor::_select_edited_shape_coord);
ClassDB::bind_method("_sort_tiles", &TileSetEditor::_sort_tiles);
@@ -358,19 +342,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("item_selected", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_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."));
@@ -383,7 +367,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("id_pressed", callable_mp(this, &TileSetEditor::_on_tileset_toolbar_button_pressed));
tileset_toolbar_container->add_child(tileset_toolbar_tools);
//---------------
@@ -416,7 +400,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
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("pressed", callable_mp(this, &TileSetEditor::_on_workspace_mode_changed), varray(i));
tool_hb->add_child(tool_workspacemode[i]);
}
@@ -429,14 +413,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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SELECT_PREVIOUS));
VSeparator *separator_shape_selection = memnew(VSeparator);
tool_hb->add_child(separator_shape_selection);
@@ -466,7 +450,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
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("pressed", callable_mp(this, &TileSetEditor::_on_edit_mode_changed), varray(i));
tool_hb->add_child(tool_editmode[i]);
}
tool_editmode[EDITMODE_COLLISION]->set_pressed(true);
@@ -493,21 +477,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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(BITMASK_CLEAR));
toolbar->add_child(tools[BITMASK_CLEAR]);
tools[SHAPE_NEW_RECTANGLE] = memnew(ToolButton);
@@ -525,13 +509,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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SHAPE_DELETE));
toolbar->add_child(tools[SHAPE_DELETE]);
spin_priority = memnew(SpinBox);
@@ -539,7 +523,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("value_changed", callable_mp(this, &TileSetEditor::_on_priority_changed));
spin_priority->hide();
toolbar->add_child(spin_priority);
@@ -548,7 +532,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("value_changed", callable_mp(this, &TileSetEditor::_on_z_index_changed));
spin_z_index->hide();
toolbar->add_child(spin_z_index);
@@ -562,7 +546,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("toggled", callable_mp(this, &TileSetEditor::_on_grid_snap_toggled));
toolbar->add_child(tools[TOOL_GRID_SNAP]);
Control *separator = memnew(Control);
@@ -570,15 +554,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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_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("pressed", callable_mp(this, &TileSetEditor::_zoom_in));
toolbar->add_child(tools[ZOOM_IN]);
tools[ZOOM_IN]->set_tooltip(TTR("Zoom In"));
@@ -607,13 +591,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("draw", callable_mp(this, &TileSetEditor::_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("draw", callable_mp(this, &TileSetEditor::_on_workspace_draw));
+ workspace->connect("gui_input", callable_mp(this, &TileSetEditor::_on_workspace_input));
workspace->set_draw_behind_parent(true);
workspace_overlay->add_child(workspace);
@@ -626,7 +610,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
//---------------
cd = memnew(ConfirmationDialog);
add_child(cd);
- cd->connect("confirmed", this, "_on_tileset_toolbar_confirm");
+ cd->connect("confirmed", callable_mp(this, &TileSetEditor::_on_tileset_toolbar_confirm));
//---------------
err_dialog = memnew(AcceptDialog);
@@ -639,13 +623,13 @@ 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("files_selected", callable_mp(this, &TileSetEditor::_on_textures_added));
//---------------
helper = memnew(TilesetEditorContext(this));
@@ -750,10 +734,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.");
@@ -1183,7 +1167,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);
@@ -1618,16 +1602,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());
@@ -1639,18 +1621,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());
@@ -1794,13 +1774,13 @@ 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;
@@ -1810,14 +1790,20 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
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();
@@ -1977,18 +1963,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
}
}
@@ -2662,9 +2645,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;
@@ -2700,9 +2683,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) {
@@ -2749,9 +2732,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;
@@ -2779,7 +2762,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);
@@ -2789,9 +2772,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;
@@ -2827,7 +2810,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);
@@ -2838,9 +2821,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;
@@ -2856,9 +2839,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;
}
}
@@ -2914,15 +2897,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"));
@@ -2940,17 +2922,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);
@@ -2972,7 +2953,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());
@@ -3003,7 +2984,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);
}
@@ -3052,7 +3033,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);
}
@@ -3098,13 +3079,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());
@@ -3117,7 +3098,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);
@@ -3326,9 +3307,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])];
}
@@ -3487,7 +3468,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"));
@@ -3510,7 +3491,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()) {
@@ -3551,11 +3532,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 0e0bd6448c..7b49e2ece2 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -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();
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index c53fc7e6c5..da80eee253 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -39,14 +39,6 @@ VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = NULL;
void VersionControlEditorPlugin::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_selected_a_vcs"), &VersionControlEditorPlugin::_selected_a_vcs);
- ClassDB::bind_method(D_METHOD("_initialize_vcs"), &VersionControlEditorPlugin::_initialize_vcs);
- ClassDB::bind_method(D_METHOD("_send_commit_msg"), &VersionControlEditorPlugin::_send_commit_msg);
- ClassDB::bind_method(D_METHOD("_refresh_stage_area"), &VersionControlEditorPlugin::_refresh_stage_area);
- ClassDB::bind_method(D_METHOD("_stage_all"), &VersionControlEditorPlugin::_stage_all);
- ClassDB::bind_method(D_METHOD("_stage_selected"), &VersionControlEditorPlugin::_stage_selected);
- ClassDB::bind_method(D_METHOD("_view_file_diff"), &VersionControlEditorPlugin::_view_file_diff);
- ClassDB::bind_method(D_METHOD("_refresh_file_diff"), &VersionControlEditorPlugin::_refresh_file_diff);
ClassDB::bind_method(D_METHOD("popup_vcs_set_up_dialog"), &VersionControlEditorPlugin::popup_vcs_set_up_dialog);
// Used to track the status of files in the staging area
@@ -124,10 +116,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("filesystem_changed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));
String res_dir = OS::get_singleton()->get_resource_dir();
@@ -203,7 +195,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.");
}
}
@@ -388,8 +380,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("filesystem_changed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area))) {
+ EditorFileSystem::get_singleton()->disconnect("filesystem_changed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));
}
EditorVCSInterface::get_singleton()->shut_down();
memdelete(EditorVCSInterface::get_singleton());
@@ -444,14 +436,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("item_selected", callable_mp(this, &VersionControlEditorPlugin::_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("pressed", callable_mp(this, &VersionControlEditorPlugin::_initialize_vcs));
set_up_vbc->add_child(set_up_init_button);
version_control_actions->set_v_size_flags(PopupMenu::SIZE_EXPAND_FILL);
@@ -479,7 +471,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("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));
stage_tools->add_child(refresh_button);
stage_files = memnew(Tree);
@@ -492,7 +484,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("cell_selected", callable_mp(this, &VersionControlEditorPlugin::_view_file_diff));
stage_files->create_item();
stage_files->set_hide_root(true);
commit_box_vbc->add_child(stage_files);
@@ -516,12 +508,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("pressed", callable_mp(this, &VersionControlEditorPlugin::_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("pressed", callable_mp(this, &VersionControlEditorPlugin::_stage_all));
stage_buttons->add_child(stage_all_button);
commit_box_vbc->add_child(memnew(HSeparator));
@@ -537,7 +529,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("pressed", callable_mp(this, &VersionControlEditorPlugin::_send_commit_msg));
commit_box_vbc->add_child(commit_button);
commit_status = memnew(Label);
@@ -571,7 +563,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("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_file_diff));
diff_hbc->add_child(diff_refresh_button);
diff = memnew(RichTextLabel);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index e334d4b093..9100e28352 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -35,6 +35,7 @@
#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"
@@ -72,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("changed", callable_mp(this, &VisualShaderEditor::_update_preview))) {
+ visual_shader->connect("changed", callable_mp(this, &VisualShaderEditor::_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("changed", callable_mp(this, &VisualShaderEditor::_update_preview))) {
+ visual_shader->disconnect("changed", callable_mp(this, &VisualShaderEditor::_update_preview));
}
}
visual_shader.unref();
@@ -116,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());
@@ -134,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;
}
@@ -215,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")) {
@@ -238,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;
}
@@ -277,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() {
@@ -296,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");
@@ -319,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) {
-
- if ((add_options[i].func != current_func && add_options[i].func != -1) || !_is_available(add_options[i].mode))
- continue;
+ options.append_array(custom_options);
+ options.append_array(embedded_options);
- if (prev_category != add_options[i].category) {
- if (category != NULL && item_count == 0) {
- memdelete(category);
- }
+ for (int i = 0; i < options.size(); i++) {
+ String path = options[i].category;
+ Vector<String> subfolders = path.split("/");
+ TreeItem *category = NULL;
- 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);
}
}
@@ -456,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);
}
}
@@ -490,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;
@@ -526,16 +517,12 @@ 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("resize_request", callable_mp(this, &VisualShaderEditor::_node_resized), varray((int)type, nodes[n_i]));
}
if (is_expression) {
expression = expression_node->get_expression();
}
- /*if (!vsnode->is_connected("changed", this, "_node_changed")) {
- vsnode->connect("changed", this, "_node_changed", varray(vsnode->get_instance_id()), CONNECT_DEFERRED);
- }*/
-
node->set_offset(position);
node->set_title(vsnode->get_caption());
@@ -543,10 +530,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("close_request", callable_mp(this, &VisualShaderEditor::_delete_request), varray(nodes[n_i]), CONNECT_DEFERRED);
}
- node->connect("dragged", this, "_node_dragged", varray(nodes[n_i]));
+ node->connect("dragged", callable_mp(this, &VisualShaderEditor::_node_dragged), varray(nodes[n_i]));
Control *custom_editor = NULL;
int port_offset = 0;
@@ -556,6 +543,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);
@@ -563,14 +552,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("text_entered", callable_mp(this, &VisualShaderEditor::_line_edit_changed), varray(uniform_name, nodes[n_i]));
+ uniform_name->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_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++;
}
@@ -582,11 +573,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;
}
@@ -601,14 +597,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("pressed", callable_mp(this, &VisualShaderEditor::_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("pressed", callable_mp(this, &VisualShaderEditor::_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);
@@ -656,19 +652,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("pressed", callable_mp(this, &VisualShaderEditor::_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("draw", callable_mp(this, &VisualShaderEditor::_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: {
@@ -690,27 +686,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("item_selected", callable_mp(this, &VisualShaderEditor::_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("text_entered", callable_mp(this, &VisualShaderEditor::_change_input_port_name), varray(name_box, nodes[n_i], i));
+ name_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_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("pressed", callable_mp(this, &VisualShaderEditor::_remove_input_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
} else {
@@ -739,7 +736,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("pressed", callable_mp(this, &VisualShaderEditor::_remove_output_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
LineEdit *name_box = memnew(LineEdit);
@@ -747,18 +744,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("text_entered", callable_mp(this, &VisualShaderEditor::_change_output_port_name), varray(name_box, nodes[n_i], i));
+ name_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_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("item_selected", callable_mp(this, &VisualShaderEditor::_change_output_port_type), varray(nodes[n_i], i), CONNECT_DEFERRED);
} else {
Label *label = memnew(Label);
label->set_text(name_right);
@@ -779,7 +777,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("pressed", callable_mp(this, &VisualShaderEditor::_preview_select_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(preview);
}
@@ -852,7 +850,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("focus_exited", callable_mp(this, &VisualShaderEditor::_expression_focus_out), varray(expression_box, nodes[n_i]));
}
if (!uniform.is_valid()) {
@@ -1315,7 +1313,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)
@@ -1354,16 +1352,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 (floatOp) {
+ floatOp->set_operator((VisualShaderNodeFloatOp::Operator)p_op_idx);
+ }
+
+ VisualShaderNodeIntOp *intOp = Object::cast_to<VisualShaderNodeIntOp>(vsn);
- if (scalarOp) {
- scalarOp->set_operator((VisualShaderNodeScalarOp::Operator)p_op_idx);
+ if (intOp) {
+ intOp->set_operator((VisualShaderNodeIntOp::Operator)p_op_idx);
}
- VisualShaderNodeScalarFunc *scalarFunc = Object::cast_to<VisualShaderNodeScalarFunc>(vsn);
+ VisualShaderNodeFloatFunc *floatFunc = Object::cast_to<VisualShaderNodeFloatFunc>(vsn);
- if (scalarFunc) {
- scalarFunc->set_function((VisualShaderNodeScalarFunc::Function)p_op_idx);
+ 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);
@@ -1404,7 +1414,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();
@@ -1595,8 +1605,29 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT)
- _show_members_dialog(true);
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ List<int> to_change;
+ for (int i = 0; i < graph->get_child_count(); i++) {
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
+ if (gn) {
+ if (gn->is_selected() && gn->is_close_button_visible()) {
+ to_change.push_back(gn->get_name().operator String().to_int());
+ }
+ }
+ }
+ if (to_change.empty() && copy_nodes_buffer.empty()) {
+ _show_members_dialog(true);
+ } else {
+ popup_menu->set_item_disabled(NodeMenuOptions::COPY, to_change.empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::PASTE, copy_nodes_buffer.empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.empty());
+ menu_point = graph->get_local_mouse_position();
+ Point2 gpos = Input::get_singleton()->get_mouse_position();
+ popup_menu->set_position(gpos);
+ popup_menu->popup();
+ }
+ }
}
void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
@@ -1632,10 +1663,10 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
Ref<InputEventKey> ie = p_ie;
- if (ie.is_valid() && (ie->get_scancode() == KEY_UP ||
- ie->get_scancode() == KEY_DOWN ||
- ie->get_scancode() == KEY_ENTER ||
- ie->get_scancode() == KEY_KP_ENTER)) {
+ if (ie.is_valid() && (ie->get_keycode() == KEY_UP ||
+ ie->get_keycode() == KEY_DOWN ||
+ ie->get_keycode() == KEY_ENTER ||
+ ie->get_keycode() == KEY_KP_ENTER)) {
members->call("_gui_input", ie);
node_filter->accept_event();
@@ -1672,6 +1703,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"));
@@ -1892,7 +1925,7 @@ void VisualShaderEditor::_copy_nodes() {
_dup_copy_nodes(copy_type, copy_nodes_buffer, copy_nodes_excluded_buffer);
}
-void VisualShaderEditor::_paste_nodes() {
+void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 &p_custom_position) {
if (copy_nodes_buffer.empty())
return;
@@ -1903,12 +1936,19 @@ void VisualShaderEditor::_paste_nodes() {
float scale = graph->get_zoom();
- _dup_paste_nodes(type, copy_type, copy_nodes_buffer, copy_nodes_excluded_buffer, (graph->get_scroll_ofs() / scale + graph->get_local_mouse_position() / scale - selection_center), false);
+ Vector2 mpos;
+ if (p_use_custom_position) {
+ mpos = p_custom_position;
+ } else {
+ mpos = graph->get_local_mouse_position();
+ }
+
+ _dup_paste_nodes(type, copy_type, copy_nodes_buffer, copy_nodes_excluded_buffer, (graph->get_scroll_ofs() / scale + mpos / scale - selection_center), false);
_dup_update_excluded(type, copy_nodes_excluded_buffer); // to prevent selection of previous copies at new paste
}
-void VisualShaderEditor::_on_nodes_delete() {
+void VisualShaderEditor::_delete_nodes() {
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
List<int> to_erase;
@@ -2029,8 +2069,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("");
}
@@ -2092,6 +2134,26 @@ void VisualShaderEditor::_tools_menu_option(int p_idx) {
}
}
+void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
+ switch (p_idx) {
+ case NodeMenuOptions::ADD:
+ _show_members_dialog(true);
+ break;
+ case NodeMenuOptions::COPY:
+ _copy_nodes();
+ break;
+ case NodeMenuOptions::PASTE:
+ _paste_nodes(true, menu_point);
+ break;
+ case NodeMenuOptions::DELETE:
+ _delete_nodes();
+ break;
+ case NodeMenuOptions::DUPLICATE:
+ _duplicate_nodes();
+ break;
+ }
+}
+
Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
if (p_from == members) {
@@ -2149,10 +2211,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]);
@@ -2164,7 +2226,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]);
@@ -2222,57 +2284,17 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_rebuild", &VisualShaderEditor::_rebuild);
ClassDB::bind_method("_update_graph", &VisualShaderEditor::_update_graph);
ClassDB::bind_method("_update_options_menu", &VisualShaderEditor::_update_options_menu);
- ClassDB::bind_method("_expression_focus_out", &VisualShaderEditor::_expression_focus_out);
ClassDB::bind_method("_add_node", &VisualShaderEditor::_add_node);
- ClassDB::bind_method("_node_dragged", &VisualShaderEditor::_node_dragged);
- ClassDB::bind_method("_connection_request", &VisualShaderEditor::_connection_request);
- ClassDB::bind_method("_disconnection_request", &VisualShaderEditor::_disconnection_request);
- ClassDB::bind_method("_node_selected", &VisualShaderEditor::_node_selected);
- ClassDB::bind_method("_scroll_changed", &VisualShaderEditor::_scroll_changed);
- ClassDB::bind_method("_delete_request", &VisualShaderEditor::_delete_request);
- ClassDB::bind_method("_on_nodes_delete", &VisualShaderEditor::_on_nodes_delete);
ClassDB::bind_method("_node_changed", &VisualShaderEditor::_node_changed);
- ClassDB::bind_method("_edit_port_default_input", &VisualShaderEditor::_edit_port_default_input);
- ClassDB::bind_method("_port_edited", &VisualShaderEditor::_port_edited);
- ClassDB::bind_method("_connection_to_empty", &VisualShaderEditor::_connection_to_empty);
- ClassDB::bind_method("_connection_from_empty", &VisualShaderEditor::_connection_from_empty);
- ClassDB::bind_method("_line_edit_focus_out", &VisualShaderEditor::_line_edit_focus_out);
- ClassDB::bind_method("_line_edit_changed", &VisualShaderEditor::_line_edit_changed);
- ClassDB::bind_method("_port_name_focus_out", &VisualShaderEditor::_port_name_focus_out);
- ClassDB::bind_method("_duplicate_nodes", &VisualShaderEditor::_duplicate_nodes);
- ClassDB::bind_method("_copy_nodes", &VisualShaderEditor::_copy_nodes);
- ClassDB::bind_method("_paste_nodes", &VisualShaderEditor::_paste_nodes);
- ClassDB::bind_method("_mode_selected", &VisualShaderEditor::_mode_selected);
ClassDB::bind_method("_input_select_item", &VisualShaderEditor::_input_select_item);
- ClassDB::bind_method("_preview_select_port", &VisualShaderEditor::_preview_select_port);
- ClassDB::bind_method("_graph_gui_input", &VisualShaderEditor::_graph_gui_input);
- ClassDB::bind_method("_add_input_port", &VisualShaderEditor::_add_input_port);
- ClassDB::bind_method("_change_input_port_type", &VisualShaderEditor::_change_input_port_type);
- ClassDB::bind_method("_change_input_port_name", &VisualShaderEditor::_change_input_port_name);
- ClassDB::bind_method("_remove_input_port", &VisualShaderEditor::_remove_input_port);
- ClassDB::bind_method("_add_output_port", &VisualShaderEditor::_add_output_port);
- ClassDB::bind_method("_change_output_port_type", &VisualShaderEditor::_change_output_port_type);
- ClassDB::bind_method("_change_output_port_name", &VisualShaderEditor::_change_output_port_name);
- ClassDB::bind_method("_remove_output_port", &VisualShaderEditor::_remove_output_port);
- ClassDB::bind_method("_node_resized", &VisualShaderEditor::_node_resized);
ClassDB::bind_method("_set_node_size", &VisualShaderEditor::_set_node_size);
ClassDB::bind_method("_clear_buffer", &VisualShaderEditor::_clear_buffer);
- ClassDB::bind_method("_show_preview_text", &VisualShaderEditor::_show_preview_text);
- ClassDB::bind_method("_update_preview", &VisualShaderEditor::_update_preview);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &VisualShaderEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &VisualShaderEditor::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &VisualShaderEditor::drop_data_fw);
ClassDB::bind_method("_is_available", &VisualShaderEditor::_is_available);
- ClassDB::bind_method("_tools_menu_option", &VisualShaderEditor::_tools_menu_option);
- ClassDB::bind_method("_show_members_dialog", &VisualShaderEditor::_show_members_dialog);
- ClassDB::bind_method("_sbox_input", &VisualShaderEditor::_sbox_input);
- ClassDB::bind_method("_member_filter_changed", &VisualShaderEditor::_member_filter_changed);
- ClassDB::bind_method("_member_selected", &VisualShaderEditor::_member_selected);
- ClassDB::bind_method("_member_unselected", &VisualShaderEditor::_member_unselected);
- ClassDB::bind_method("_member_create", &VisualShaderEditor::_member_create);
- ClassDB::bind_method("_member_cancel", &VisualShaderEditor::_member_cancel);
}
VisualShaderEditor *VisualShaderEditor::singleton = NULL;
@@ -2306,30 +2328,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("connection_request", callable_mp(this, &VisualShaderEditor::_connection_request), varray(), CONNECT_DEFERRED);
+ graph->connect("disconnection_request", callable_mp(this, &VisualShaderEditor::_disconnection_request), varray(), CONNECT_DEFERRED);
+ graph->connect("node_selected", callable_mp(this, &VisualShaderEditor::_node_selected));
+ graph->connect("scroll_offset_changed", callable_mp(this, &VisualShaderEditor::_scroll_changed));
+ graph->connect("duplicate_nodes_request", callable_mp(this, &VisualShaderEditor::_duplicate_nodes));
+ graph->connect("copy_nodes_request", callable_mp(this, &VisualShaderEditor::_copy_nodes));
+ graph->connect("paste_nodes_request", callable_mp(this, &VisualShaderEditor::_paste_nodes));
+ graph->connect("delete_nodes_request", callable_mp(this, &VisualShaderEditor::_delete_nodes));
+ graph->connect("gui_input", callable_mp(this, &VisualShaderEditor::_graph_gui_input));
+ graph->connect("connection_to_empty", callable_mp(this, &VisualShaderEditor::_connection_to_empty));
+ graph->connect("connection_from_empty", callable_mp(this, &VisualShaderEditor::_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);
@@ -2344,7 +2374,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("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected));
graph->get_zoom_hbox()->add_child(edit_type);
graph->get_zoom_hbox()->move_child(edit_type, 0);
@@ -2352,13 +2382,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("pressed", callable_mp(this, &VisualShaderEditor::_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("pressed", callable_mp(this, &VisualShaderEditor::_show_preview_text));
///////////////////////////////////////
// PREVIEW PANEL
@@ -2381,6 +2411,20 @@ VisualShaderEditor::VisualShaderEditor() {
error_text->set_visible(false);
///////////////////////////////////////
+ // POPUP MENU
+ ///////////////////////////////////////
+
+ popup_menu = memnew(PopupMenu);
+ add_child(popup_menu);
+ popup_menu->add_item("Add Node", NodeMenuOptions::ADD);
+ popup_menu->add_separator();
+ popup_menu->add_item("Copy", NodeMenuOptions::COPY);
+ popup_menu->add_item("Paste", NodeMenuOptions::PASTE);
+ popup_menu->add_item("Delete", NodeMenuOptions::DELETE);
+ popup_menu->add_item("Duplicate", NodeMenuOptions::DUPLICATE);
+ popup_menu->connect("id_pressed", callable_mp(this, &VisualShaderEditor::_node_menu_id_pressed));
+
+ ///////////////////////////////////////
// SHADER NODES TREE
///////////////////////////////////////
@@ -2392,15 +2436,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("text_changed", callable_mp(this, &VisualShaderEditor::_member_filter_changed));
+ node_filter->connect("gui_input", callable_mp(this, &VisualShaderEditor::_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("id_pressed", callable_mp(this, &VisualShaderEditor::_tools_menu_option));
tools->get_popup()->add_item(TTR("Expand All"), EXPAND_ALL);
tools->get_popup()->add_item(TTR("Collapse All"), COLLAPSE_ALL);
@@ -2413,14 +2457,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("item_activated", callable_mp(this, &VisualShaderEditor::_member_create));
+ members->connect("item_selected", callable_mp(this, &VisualShaderEditor::_member_selected));
+ members->connect("nothing_selected", callable_mp(this, &VisualShaderEditor::_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);
@@ -2431,11 +2487,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("pressed", callable_mp(this, &VisualShaderEditor::_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("hide", callable_mp(this, &VisualShaderEditor::_member_cancel));
add_child(members_dialog);
alert = memnew(AcceptDialog);
@@ -2606,7 +2662,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));
@@ -2615,79 +2671,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));
@@ -2815,7 +2883,7 @@ VisualShaderEditor::VisualShaderEditor() {
property_editor = memnew(CustomPropertyEditor);
add_child(property_editor);
- property_editor->connect("variant_changed", this, "_port_edited");
+ property_editor->connect("variant_changed", callable_mp(this, &VisualShaderEditor::_port_edited));
}
void VisualShaderEditorPlugin::edit(Object *p_object) {
@@ -2868,15 +2936,10 @@ class VisualShaderNodePluginInputEditor : public OptionButton {
Ref<VisualShaderNodeInput> input;
-protected:
- static void _bind_methods() {
- ClassDB::bind_method("_item_selected", &VisualShaderNodePluginInputEditor::_item_selected);
- }
-
public:
void _notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- connect("item_selected", this, "_item_selected");
+ connect("item_selected", callable_mp(this, &VisualShaderNodePluginInputEditor::_item_selected));
}
}
@@ -2886,8 +2949,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"),
@@ -2914,7 +2978,7 @@ class VisualShaderNodePluginDefaultEditor : public VBoxContainer {
Ref<Resource> parent_resource;
public:
- void _property_changed(const String &prop, const Variant &p_value, const String &p_field, bool p_changing = false) {
+ void _property_changed(const String &p_property, const Variant &p_value, const String &p_field = "", bool p_changing = false) {
if (p_changing)
return;
@@ -2922,13 +2986,13 @@ public:
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
updating = true;
- undo_redo->create_action(TTR("Edit Visual Property") + ": " + prop, UndoRedo::MERGE_ENDS);
- undo_redo->add_do_property(node.ptr(), prop, p_value);
- undo_redo->add_undo_property(node.ptr(), prop, node->get(prop));
+ undo_redo->create_action(TTR("Edit Visual Property") + ": " + p_property, UndoRedo::MERGE_ENDS);
+ undo_redo->add_do_property(node.ptr(), p_property, p_value);
+ undo_redo->add_undo_property(node.ptr(), p_property, node->get(p_property));
if (p_value.get_type() == Variant::OBJECT) {
- RES prev_res = node->get(prop);
+ RES prev_res = node->get(p_property);
RES curr_res = p_value;
if (curr_res.is_null()) {
@@ -2972,6 +3036,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;
@@ -2981,28 +3052,39 @@ 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("resource_selected", callable_mp(this, &VisualShaderNodePluginDefaultEditor::_resource_selected));
}
- properties[i]->connect("property_changed", this, "_property_changed");
+ properties[i]->connect("property_changed", callable_mp(this, &VisualShaderNodePluginDefaultEditor::_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("changed", callable_mp(this, &VisualShaderNodePluginDefaultEditor::_node_changed));
+ node->connect("editor_refresh_request", callable_mp(this, &VisualShaderNodePluginDefaultEditor::_refresh_request), varray(), CONNECT_DEFERRED);
}
static void _bind_methods() {
- ClassDB::bind_method("_property_changed", &VisualShaderNodePluginDefaultEditor::_property_changed, DEFVAL(String()), DEFVAL(false));
- ClassDB::bind_method("_node_changed", &VisualShaderNodePluginDefaultEditor::_node_changed);
- 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("_refresh_request", &VisualShaderNodePluginDefaultEditor::_refresh_request); // Used by UndoRedo.
+ ClassDB::bind_method("_open_inspector", &VisualShaderNodePluginDefaultEditor::_open_inspector); // Used by UndoRedo.
+ ClassDB::bind_method("_show_prop_names", &VisualShaderNodePluginDefaultEditor::_show_prop_names); // Used with call_deferred.
}
};
@@ -3150,8 +3232,6 @@ void EditorPropertyShaderMode::set_option_button_clip(bool p_enable) {
}
void EditorPropertyShaderMode::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_option_selected"), &EditorPropertyShaderMode::_option_selected);
}
EditorPropertyShaderMode::EditorPropertyShaderMode() {
@@ -3159,7 +3239,7 @@ EditorPropertyShaderMode::EditorPropertyShaderMode() {
options->set_clip_text(true);
add_child(options);
add_focusable(options);
- options->connect("item_selected", this, "_option_selected");
+ options->connect("item_selected", callable_mp(this, &EditorPropertyShaderMode::_option_selected));
}
bool EditorInspectorShaderModePlugin::can_handle(Object *p_object) {
@@ -3232,7 +3312,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("changed", callable_mp(this, &VisualShaderNodePortPreview::_shader_changed));
type = p_type;
port = p_port;
node = p_node;
@@ -3267,7 +3347,6 @@ void VisualShaderNodePortPreview::_notification(int p_what) {
}
void VisualShaderNodePortPreview::_bind_methods() {
- ClassDB::bind_method("_shader_changed", &VisualShaderNodePortPreview::_shader_changed);
}
VisualShaderNodePortPreview::VisualShaderNodePortPreview() {
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 8c5dd8e82f..8756fe9fe9 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -81,6 +81,7 @@ class VisualShaderEditor : public VBoxContainer {
bool saved_node_pos_dirty;
ConfirmationDialog *members_dialog;
+ PopupMenu *popup_menu;
MenuButton *tools;
bool preview_showed;
@@ -90,10 +91,20 @@ class VisualShaderEditor : public VBoxContainer {
COLLAPSE_ALL
};
+ enum NodeMenuOptions {
+ ADD,
+ SEPARATOR, // ignore
+ COPY,
+ PASTE,
+ DELETE,
+ DUPLICATE,
+ };
+
Tree *members;
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 +114,6 @@ class VisualShaderEditor : public VBoxContainer {
struct AddOption {
String name;
String category;
- String sub_category;
String type;
String description;
int sub_func;
@@ -115,12 +125,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 +144,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 +156,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;
@@ -176,7 +191,7 @@ class VisualShaderEditor : public VBoxContainer {
void _node_selected(Object *p_node);
void _delete_request(int);
- void _on_nodes_delete();
+ void _delete_nodes();
void _removed_from_graph();
@@ -211,7 +226,7 @@ class VisualShaderEditor : public VBoxContainer {
void _clear_buffer();
void _copy_nodes();
- void _paste_nodes();
+ void _paste_nodes(bool p_use_custom_position = false, const Vector2 &p_custom_position = Vector2());
Vector<Ref<VisualShaderNodePlugin> > plugins;
@@ -245,6 +260,9 @@ class VisualShaderEditor : public VBoxContainer {
void _member_create();
void _member_cancel();
+ Vector2 menu_point;
+ void _node_menu_id_pressed(int p_idx);
+
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);
@@ -264,7 +282,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);