summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp1
-rw-r--r--editor/editor_node.cpp10
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp1
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp90
-rw-r--r--editor/plugins/texture_region_editor_plugin.h4
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp45
-rw-r--r--editor/project_settings_editor.cpp211
-rw-r--r--editor/project_settings_editor.h13
-rw-r--r--editor/script_create_dialog.cpp35
-rw-r--r--editor/script_create_dialog.h1
-rw-r--r--editor/script_editor_debugger.cpp63
-rw-r--r--editor/script_editor_debugger.h2
14 files changed, 381 insertions, 100 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index ee1faf5a55..0100c221c4 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1089,6 +1089,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/line_numbers/line_length_guideline_column"));
text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
+ text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index b77525c0ba..3513126a9b 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2670,12 +2670,12 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled)
String addon_path = "res://addons/" + p_addon + "/plugin.cfg";
Error err = cf->load(addon_path);
if (err != OK) {
- show_warning(TTR("Unable to enable addon plugin at: '") + addon_path + TTR("' parsing of config failed."));
+ show_warning(vformat(TTR("Unable to enable addon plugin at: '%s' parsing of config failed."), addon_path));
return;
}
if (!cf->has_section_key("plugin", "script")) {
- show_warning(TTR("Unable to find script field for addon plugin at: 'res://addons/") + p_addon + "''.");
+ show_warning(vformat(TTR("Unable to find script field for addon plugin at: 'res://addons/%s'."), p_addon));
return;
}
@@ -2685,18 +2685,18 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled)
Ref<Script> script = ResourceLoader::load(path);
if (script.is_null()) {
- show_warning(TTR("Unable to load addon script from path: '") + path + "'.");
+ show_warning(vformat(TTR("Unable to load addon script from path: '%s'."), path));
return;
}
//could check inheritance..
if (String(script->get_instance_base_type()) != "EditorPlugin") {
- show_warning(TTR("Unable to load addon script from path: '") + path + "' Base type is not EditorPlugin.");
+ show_warning(vformat(TTR("Unable to load addon script from path: '%s' Base type is not EditorPlugin."), path));
return;
}
if (!script->is_tool()) {
- show_warning(TTR("Unable to load addon script from path: '") + path + "' Script is not in tool mode.");
+ show_warning(vformat(TTR("Unable to load addon script from path: '%s' Script is not in tool mode."), path));
return;
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 7c45e19f5f..799a8a2eb8 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -632,6 +632,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/highlighting/syntax_highlighting", true);
_initial_set("text_editor/highlighting/highlight_all_occurrences", true);
+ _initial_set("text_editor/highlighting/highlight_current_line", true);
_initial_set("text_editor/cursor/scroll_past_end_of_file", false);
_initial_set("text_editor/indent/type", 0);
@@ -705,7 +706,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/3d/navigation_feel/orbit_sensitivity", 0.4);
hints["editors/3d/navigation_feel/orbit_sensitivity"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/orbit_sensitivity", PROPERTY_HINT_RANGE, "0.0, 2, 0.01");
- _initial_set("editors/3d/navigation_feel/orbit_inertia", 0.15);
+ _initial_set("editors/3d/navigation_feel/orbit_inertia", 0.05);
hints["editors/3d/navigation_feel/orbit_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/orbit_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
_initial_set("editors/3d/navigation_feel/translation_inertia", 0.15);
hints["editors/3d/navigation_feel/translation_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/translation_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 70a6954fb5..5782edd321 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -45,7 +45,7 @@
#include "scene/2d/screen_button.h"
#include "scene/2d/sprite.h"
#include "scene/gui/grid_container.h"
-#include "scene/gui/patch_9_rect.h"
+#include "scene/gui/nine_patch_rect.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index b0ee1a32ca..f7dcc4b52d 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -348,6 +348,7 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/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"));
+ shader_editor->get_text_edit()->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
shader_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 740772e204..8870166dba 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -48,8 +48,8 @@ void TextureRegionEditor::_region_draw() {
Ref<Texture> base_tex = NULL;
if (node_sprite)
base_tex = node_sprite->get_texture();
- else if (node_patch9)
- base_tex = node_patch9->get_texture();
+ else if (node_ninepatch)
+ base_tex = node_ninepatch->get_texture();
else if (obj_styleBox.is_valid())
base_tex = obj_styleBox->get_texture();
else if (atlas_tex.is_valid())
@@ -177,12 +177,12 @@ void TextureRegionEditor::_region_draw() {
updating_scroll = false;
float margins[4];
- if (node_patch9 || obj_styleBox.is_valid()) {
- if (node_patch9) {
- margins[0] = node_patch9->get_patch_margin(MARGIN_TOP);
- margins[1] = node_patch9->get_patch_margin(MARGIN_BOTTOM);
- margins[2] = node_patch9->get_patch_margin(MARGIN_LEFT);
- margins[3] = node_patch9->get_patch_margin(MARGIN_RIGHT);
+ if (node_ninepatch || obj_styleBox.is_valid()) {
+ if (node_ninepatch) {
+ margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP);
+ margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM);
+ margins[2] = node_ninepatch->get_patch_margin(MARGIN_LEFT);
+ margins[3] = node_ninepatch->get_patch_margin(MARGIN_RIGHT);
} else if (obj_styleBox.is_valid()) {
margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP);
margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM);
@@ -225,14 +225,14 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
- if (node_patch9 || obj_styleBox.is_valid()) {
+ if (node_ninepatch || obj_styleBox.is_valid()) {
edited_margin = -1;
float margins[4];
- if (node_patch9) {
- margins[0] = node_patch9->get_patch_margin(MARGIN_TOP);
- margins[1] = node_patch9->get_patch_margin(MARGIN_BOTTOM);
- margins[2] = node_patch9->get_patch_margin(MARGIN_LEFT);
- margins[3] = node_patch9->get_patch_margin(MARGIN_RIGHT);
+ if (node_ninepatch) {
+ margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP);
+ margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM);
+ margins[2] = node_ninepatch->get_patch_margin(MARGIN_LEFT);
+ margins[3] = node_ninepatch->get_patch_margin(MARGIN_RIGHT);
} else if (obj_styleBox.is_valid()) {
margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP);
margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM);
@@ -272,8 +272,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
Rect2 r;
if (node_sprite)
r = node_sprite->get_region_rect();
- else if (node_patch9)
- r = node_patch9->get_region_rect();
+ else if (node_ninepatch)
+ r = node_ninepatch->get_region_rect();
else if (obj_styleBox.is_valid())
r = obj_styleBox->get_region_rect();
else if (atlas_tex.is_valid())
@@ -285,9 +285,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (node_sprite) {
undo_redo->add_do_method(node_sprite, "set_region_rect", rect);
undo_redo->add_undo_method(node_sprite, "set_region_rect", node_sprite->get_region_rect());
- } else if (node_patch9) {
- undo_redo->add_do_method(node_patch9, "set_region_rect", rect);
- undo_redo->add_undo_method(node_patch9, "set_region_rect", node_patch9->get_region_rect());
+ } else if (node_ninepatch) {
+ undo_redo->add_do_method(node_ninepatch, "set_region_rect", rect);
+ undo_redo->add_undo_method(node_ninepatch, "set_region_rect", node_ninepatch->get_region_rect());
} else if (obj_styleBox.is_valid()) {
undo_redo->add_do_method(obj_styleBox.ptr(), "set_region_rect", rect);
undo_redo->add_undo_method(obj_styleBox.ptr(), "set_region_rect", obj_styleBox->get_region_rect());
@@ -310,8 +310,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
drag = true;
if (node_sprite)
rect_prev = node_sprite->get_region_rect();
- else if (node_patch9)
- rect_prev = node_patch9->get_region_rect();
+ else if (node_ninepatch)
+ rect_prev = node_ninepatch->get_region_rect();
else if (obj_styleBox.is_valid())
rect_prev = obj_styleBox->get_region_rect();
else if (atlas_tex.is_valid())
@@ -334,9 +334,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (edited_margin >= 0) {
undo_redo->create_action("Set Margin");
static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
- if (node_patch9) {
- undo_redo->add_do_method(node_patch9, "set_patch_margin", m[edited_margin], node_patch9->get_patch_margin(m[edited_margin]));
- undo_redo->add_undo_method(node_patch9, "set_patch_margin", m[edited_margin], prev_margin);
+ if (node_ninepatch) {
+ undo_redo->add_do_method(node_ninepatch, "set_patch_margin", m[edited_margin], node_ninepatch->get_patch_margin(m[edited_margin]));
+ undo_redo->add_undo_method(node_ninepatch, "set_patch_margin", m[edited_margin], prev_margin);
} else if (obj_styleBox.is_valid()) {
undo_redo->add_do_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], obj_styleBox->get_margin_size(m[edited_margin]));
undo_redo->add_undo_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], prev_margin);
@@ -351,11 +351,11 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
} else if (atlas_tex.is_valid()) {
undo_redo->add_do_method(atlas_tex.ptr(), "set_region", atlas_tex->get_region());
undo_redo->add_undo_method(atlas_tex.ptr(), "set_region", rect_prev);
- } else if (node_patch9) {
+ } else if (node_ninepatch) {
// FIXME: Is this intentional?
- } else if (node_patch9) {
- undo_redo->add_do_method(node_patch9, "set_region_rect", node_patch9->get_region_rect());
- undo_redo->add_undo_method(node_patch9, "set_region_rect", rect_prev);
+ } else if (node_ninepatch) {
+ undo_redo->add_do_method(node_ninepatch, "set_region_rect", node_ninepatch->get_region_rect());
+ undo_redo->add_undo_method(node_ninepatch, "set_region_rect", rect_prev);
} else if (obj_styleBox.is_valid()) {
undo_redo->add_do_method(obj_styleBox.ptr(), "set_region_rect", obj_styleBox->get_region_rect());
undo_redo->add_undo_method(obj_styleBox.ptr(), "set_region_rect", rect_prev);
@@ -375,8 +375,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
drag = false;
if (edited_margin >= 0) {
static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
- if (node_patch9)
- node_patch9->set_patch_margin(m[edited_margin], prev_margin);
+ if (node_ninepatch)
+ node_ninepatch->set_patch_margin(m[edited_margin], prev_margin);
if (obj_styleBox.is_valid())
obj_styleBox->set_margin_size(m[edited_margin], prev_margin);
edited_margin = -1;
@@ -422,8 +422,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (new_margin < 0)
new_margin = 0;
static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
- if (node_patch9)
- node_patch9->set_patch_margin(m[edited_margin], new_margin);
+ if (node_ninepatch)
+ node_ninepatch->set_patch_margin(m[edited_margin], new_margin);
if (obj_styleBox.is_valid())
obj_styleBox->set_margin_size(m[edited_margin], new_margin);
} else {
@@ -573,8 +573,8 @@ void TextureRegionEditor::_zoom_out() {
void TextureRegionEditor::apply_rect(const Rect2 &rect) {
if (node_sprite)
node_sprite->set_region_rect(rect);
- else if (node_patch9)
- node_patch9->set_region_rect(rect);
+ else if (node_ninepatch)
+ node_ninepatch->set_region_rect(rect);
else if (obj_styleBox.is_valid())
obj_styleBox->set_region_rect(rect);
else if (atlas_tex.is_valid())
@@ -593,8 +593,8 @@ void TextureRegionEditor::_notification(int p_what) {
}
void TextureRegionEditor::_node_removed(Object *p_obj) {
- if (p_obj == node_sprite || p_obj == node_patch9 || p_obj == obj_styleBox.ptr() || p_obj == atlas_tex.ptr()) {
- node_patch9 = NULL;
+ if (p_obj == node_sprite || p_obj == node_ninepatch || p_obj == obj_styleBox.ptr() || p_obj == atlas_tex.ptr()) {
+ node_ninepatch = NULL;
node_sprite = NULL;
obj_styleBox = Ref<StyleBox>(NULL);
atlas_tex = Ref<AtlasTexture>(NULL);
@@ -623,15 +623,15 @@ void TextureRegionEditor::_bind_methods() {
void TextureRegionEditor::edit(Object *p_obj) {
if (node_sprite)
node_sprite->remove_change_receptor(this);
- if (node_patch9)
- node_patch9->remove_change_receptor(this);
+ if (node_ninepatch)
+ node_ninepatch->remove_change_receptor(this);
if (obj_styleBox.is_valid())
obj_styleBox->remove_change_receptor(this);
if (atlas_tex.is_valid())
atlas_tex->remove_change_receptor(this);
if (p_obj) {
node_sprite = Object::cast_to<Sprite>(p_obj);
- node_patch9 = Object::cast_to<NinePatchRect>(p_obj);
+ node_ninepatch = Object::cast_to<NinePatchRect>(p_obj);
if (Object::cast_to<StyleBoxTexture>(p_obj))
obj_styleBox = Ref<StyleBoxTexture>(Object::cast_to<StyleBoxTexture>(p_obj));
if (Object::cast_to<AtlasTexture>(p_obj))
@@ -640,7 +640,7 @@ void TextureRegionEditor::edit(Object *p_obj) {
_edit_region();
} else {
node_sprite = NULL;
- node_patch9 = NULL;
+ node_ninepatch = NULL;
obj_styleBox = Ref<StyleBoxTexture>(NULL);
atlas_tex = Ref<AtlasTexture>(NULL);
}
@@ -659,8 +659,8 @@ void TextureRegionEditor::_edit_region() {
Ref<Texture> texture = NULL;
if (node_sprite)
texture = node_sprite->get_texture();
- else if (node_patch9)
- texture = node_patch9->get_texture();
+ else if (node_ninepatch)
+ texture = node_ninepatch->get_texture();
else if (obj_styleBox.is_valid())
texture = obj_styleBox->get_texture();
else if (atlas_tex.is_valid())
@@ -726,8 +726,8 @@ void TextureRegionEditor::_edit_region() {
if (node_sprite)
rect = node_sprite->get_region_rect();
- else if (node_patch9)
- rect = node_patch9->get_region_rect();
+ else if (node_ninepatch)
+ rect = node_ninepatch->get_region_rect();
else if (obj_styleBox.is_valid())
rect = obj_styleBox->get_region_rect();
else if (atlas_tex.is_valid())
@@ -747,7 +747,7 @@ Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const {
TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
node_sprite = NULL;
- node_patch9 = NULL;
+ node_ninepatch = NULL;
obj_styleBox = Ref<StyleBoxTexture>(NULL);
atlas_tex = Ref<AtlasTexture>(NULL);
editor = p_editor;
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index 0789dde1c1..2058dad791 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -37,7 +37,7 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/sprite.h"
-#include "scene/gui/patch_9_rect.h"
+#include "scene/gui/nine_patch_rect.h"
#include "scene/resources/style_box.h"
#include "scene/resources/texture.h"
@@ -82,7 +82,7 @@ class TextureRegionEditor : public Control {
Vector2 snap_step;
Vector2 snap_separation;
- NinePatchRect *node_patch9;
+ NinePatchRect *node_ninepatch;
Sprite *node_sprite;
Ref<StyleBoxTexture> obj_styleBox;
Ref<AtlasTexture> atlas_tex;
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index d12b3f1e0e..9235dafaa6 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -945,6 +945,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (mm.is_valid()) {
Point2i new_over_tile = node->world_to_map(xform_inv.xform(mm->get_position()));
+ Point2i old_over_tile = over_tile;
if (new_over_tile != over_tile) {
@@ -963,17 +964,43 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_PAINTING) {
+ // Paint using bresenham line to prevent holes in painting if the user moves fast
+
+ Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
int id = get_selected_tile();
- if (id != TileMap::INVALID_CELL) {
+
+ for (int i = 0; i < points.size(); ++i) {
+
+ Point2i pos = points[i];
if (!paint_undo.has(over_tile)) {
- paint_undo[over_tile] = _get_op_from_cell(over_tile);
+ paint_undo[pos] = _get_op_from_cell(pos);
}
- _set_cell(over_tile, id, flip_h, flip_v, transpose);
+ _set_cell(pos, id, flip_h, flip_v, transpose);
+ }
- return true;
+ return true;
+ }
+
+ if (tool == TOOL_ERASING) {
+
+ // erase using bresenham line to prevent holes in painting if the user moves fast
+
+ Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
+
+ for (int i = 0; i < points.size(); ++i) {
+
+ Point2i pos = points[i];
+
+ if (!paint_undo.has(over_tile)) {
+ paint_undo[pos] = _get_op_from_cell(pos);
+ }
+
+ _set_cell(pos, TileMap::INVALID_CELL);
}
+
+ return true;
}
if (tool == TOOL_SELECTING) {
@@ -1044,16 +1071,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
}
- if (tool == TOOL_ERASING) {
-
- if (!paint_undo.has(over_tile)) {
- paint_undo[over_tile] = _get_op_from_cell(over_tile);
- }
-
- _set_cell(over_tile, TileMap::INVALID_CELL);
-
- return true;
- }
if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
_pick_tile(over_tile);
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 723d7b14ff..1284788425 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -1127,7 +1127,11 @@ void ProjectSettingsEditor::_translation_res_option_changed() {
ERR_FAIL_COND(!remaps.has(key));
PoolStringArray r = remaps[key];
ERR_FAIL_INDEX(idx, r.size());
- r.set(idx, path + ":" + langs[which]);
+ if (translation_locales_idxs_remap.size() > 0) {
+ r.set(idx, path + ":" + langs[translation_locales_idxs_remap[which]]);
+ } else {
+ r.set(idx, path + ":" + langs[which]);
+ }
remaps[key] = r;
updating_translations = true;
@@ -1203,6 +1207,88 @@ void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p
undo_redo->commit_action();
}
+void ProjectSettingsEditor::_translation_filter_option_changed() {
+
+ int sel_id = translation_locale_filter_mode->get_selected_id();
+ TreeItem *t = translation_filter->get_selected();
+ String locale = t->get_tooltip(0);
+ bool checked = t->is_checked(0);
+
+ Variant prev;
+ Array f_locales_all;
+
+ if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) {
+ f_locales_all = ProjectSettings::get_singleton()->get("locale/locale_filter");
+ prev = f_locales_all;
+
+ if (f_locales_all.size() != 2) {
+ f_locales_all.clear();
+ f_locales_all.append(sel_id);
+ f_locales_all.append(Array());
+ }
+ } else {
+ f_locales_all.append(sel_id);
+ f_locales_all.append(Array());
+ }
+
+ Array f_locales = f_locales_all[1];
+ int l_idx = f_locales.find(locale);
+
+ if (checked) {
+ if (l_idx == -1) {
+ f_locales.append(locale);
+ }
+ } else {
+ if (l_idx != -1) {
+ f_locales.remove(l_idx);
+ }
+ }
+
+ f_locales = f_locales.sort();
+
+ undo_redo->create_action(TTR("Changed Locale Filter"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/locale_filter", f_locales_all);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/locale_filter", prev);
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
+ undo_redo->commit_action();
+}
+
+void ProjectSettingsEditor::_translation_filter_mode_changed(int p_mode) {
+
+ int sel_id = translation_locale_filter_mode->get_selected_id();
+
+ Variant prev;
+ Array f_locales_all;
+
+ if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) {
+ f_locales_all = ProjectSettings::get_singleton()->get("locale/locale_filter");
+ prev = f_locales_all;
+
+ if (f_locales_all.size() != 2) {
+ f_locales_all.clear();
+ f_locales_all.append(sel_id);
+ f_locales_all.append(Array());
+ } else {
+ f_locales_all[0] = sel_id;
+ }
+ } else {
+ f_locales_all.append(sel_id);
+ f_locales_all.append(Array());
+ }
+
+ undo_redo->create_action(TTR("Changed Locale Filter Mode"));
+ undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/locale_filter", f_locales_all);
+ undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/locale_filter", prev);
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
+ undo_redo->commit_action();
+}
+
void ProjectSettingsEditor::_update_translations() {
//update translations
@@ -1229,6 +1315,61 @@ void ProjectSettingsEditor::_update_translations() {
}
}
+ Vector<String> langs = TranslationServer::get_all_locales();
+ Vector<String> names = TranslationServer::get_all_locale_names();
+
+ //update filter tab
+ Array l_filter_all;
+
+ bool is_arr_empty = true;
+ if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) {
+
+ l_filter_all = ProjectSettings::get_singleton()->get("locale/locale_filter");
+
+ if (l_filter_all.size() == 2) {
+
+ translation_locale_filter_mode->select(l_filter_all[0]);
+ is_arr_empty = false;
+ }
+ }
+ if (is_arr_empty) {
+
+ l_filter_all.append(0);
+ l_filter_all.append(Array());
+ translation_locale_filter_mode->select(0);
+ }
+
+ int filter_mode = l_filter_all[0];
+ Array l_filter = l_filter_all[1];
+
+ int s = names.size();
+ if (!translation_locales_list_created) {
+
+ translation_locales_list_created = true;
+ translation_filter->clear();
+ root = translation_filter->create_item(NULL);
+ translation_filter->set_hide_root(true);
+ translation_filter_treeitems.resize(s);
+
+ for (int i = 0; i < s; i++) {
+ String n = names[i];
+ String l = langs[i];
+ TreeItem *t = translation_filter->create_item(root);
+ t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ t->set_text(0, n);
+ t->set_editable(0, true);
+ t->set_tooltip(0, l);
+ t->set_checked(0, l_filter.has(l));
+ translation_filter_treeitems[i] = t;
+ }
+ } else {
+ for (int i = 0; i < s; i++) {
+
+ TreeItem *t = translation_filter_treeitems[i];
+ t->set_checked(0, l_filter.has(t->get_tooltip(0)));
+ }
+ }
+
//update translation remaps
String remap_selected;
@@ -1244,13 +1385,30 @@ void ProjectSettingsEditor::_update_translations() {
translation_remap_options->set_hide_root(true);
translation_res_option_add_button->set_disabled(true);
- Vector<String> langs = TranslationServer::get_all_locales();
- Vector<String> names = TranslationServer::get_all_locale_names();
- String langnames;
+ translation_locales_idxs_remap.clear();
+ translation_locales_idxs_remap.resize(l_filter.size());
+ int fl_idx_count = translation_locales_idxs_remap.size();
+
+ String langnames = "";
+ int l_idx = 0;
for (int i = 0; i < names.size(); i++) {
- if (i > 0)
- langnames += ",";
- langnames += names[i];
+
+ if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && fl_idx_count != 0) {
+ if (l_filter.size() > 0) {
+
+ if (l_filter.find(langs[i]) != -1) {
+ if (langnames.length() > 0)
+ langnames += ",";
+ langnames += names[i];
+ translation_locales_idxs_remap[l_idx] = i;
+ l_idx++;
+ }
+ }
+ } else {
+ if (i > 0)
+ langnames += ",";
+ langnames += names[i];
+ }
}
if (ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
@@ -1295,11 +1453,18 @@ void ProjectSettingsEditor::_update_translations() {
t2->set_editable(1, true);
t2->set_metadata(1, path);
int idx = langs.find(locale);
- print_line("find " + locale + " at " + itos(idx));
+ //print_line("find " + locale + " at " + itos(idx));
if (idx < 0)
idx = 0;
- t2->set_range(1, idx);
+ int f_idx = translation_locales_idxs_remap.find(idx);
+ if (f_idx != -1 && fl_idx_count > 0 && filter_mode == SHOW_ONLY_SELECTED_LOCALES) {
+
+ t2->set_range(1, f_idx);
+ } else {
+
+ t2->set_range(1, idx);
+ }
}
}
}
@@ -1381,6 +1546,9 @@ void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettingsEditor::_translation_res_delete);
ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettingsEditor::_translation_res_option_delete);
+ ClassDB::bind_method(D_METHOD("_translation_filter_option_changed"), &ProjectSettingsEditor::_translation_filter_option_changed);
+ ClassDB::bind_method(D_METHOD("_translation_filter_mode_changed"), &ProjectSettingsEditor::_translation_filter_mode_changed);
+
ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettingsEditor::_clear_search_box);
ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar);
@@ -1601,6 +1769,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translations->set_tab_align(TabContainer::ALIGN_LEFT);
translations->set_name(TTR("Localization"));
tab_container->add_child(translations);
+ //remap for properly select language in popup
+ translation_locales_idxs_remap = Vector<int>();
{
@@ -1684,6 +1854,29 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
}
{
+ VBoxContainer *tvb = memnew(VBoxContainer);
+ translations->add_child(tvb);
+ tvb->set_name(TTR("Locales Filter"));
+ VBoxContainer *tmc = memnew(VBoxContainer);
+ tmc->set_v_size_flags(SIZE_EXPAND_FILL);
+ tvb->add_child(tmc);
+
+ translation_locale_filter_mode = memnew(OptionButton);
+ translation_locale_filter_mode->add_item(TTR("Show all locales"), SHOW_ALL_LOCALES);
+ translation_locale_filter_mode->add_item(TTR("Show only selected locales"), SHOW_ONLY_SELECTED_LOCALES);
+ translation_locale_filter_mode->select(0);
+ tmc->add_margin_child(TTR("Filter mode:"), translation_locale_filter_mode);
+ translation_locale_filter_mode->connect("item_selected", this, "_translation_filter_mode_changed");
+
+ translation_filter = memnew(Tree);
+ translation_filter->set_v_size_flags(SIZE_EXPAND_FILL);
+ translation_filter->set_columns(1);
+ tmc->add_child(memnew(Label(TTR("Locales:"))));
+ tmc->add_child(translation_filter);
+ translation_filter->connect("item_edited", this, "_translation_filter_option_changed");
+ }
+
+ {
autoload_settings = memnew(EditorAutoloadSettings);
autoload_settings->set_name(TTR("AutoLoad"));
tab_container->add_child(autoload_settings);
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 7f9b18a968..a86cfee813 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -49,6 +49,11 @@ class ProjectSettingsEditor : public AcceptDialog {
INPUT_MOUSE_BUTTON
};
+ enum LocaleFilter {
+ SHOW_ALL_LOCALES,
+ SHOW_ONLY_SELECTED_LOCALES,
+ };
+
TabContainer *tab_container;
Timer *timer;
@@ -95,6 +100,11 @@ class ProjectSettingsEditor : public AcceptDialog {
EditorFileDialog *translation_res_option_file_open;
Tree *translation_remap;
Tree *translation_remap_options;
+ Tree *translation_filter;
+ bool translation_locales_list_created;
+ OptionButton *translation_locale_filter_mode;
+ Vector<TreeItem *> translation_filter_treeitems;
+ Vector<int> translation_locales_idxs_remap;
EditorAutoloadSettings *autoload_settings;
@@ -142,6 +152,9 @@ class ProjectSettingsEditor : public AcceptDialog {
void _translation_res_option_changed();
void _translation_res_option_delete(Object *p_item, int p_column, int p_button);
+ void _translation_filter_option_changed();
+ void _translation_filter_mode_changed(int p_mode);
+
void _toggle_search_bar(bool p_pressed);
void _clear_search_box();
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 00f44ad9b0..c19b80e649 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -145,9 +145,13 @@ void ScriptCreateDialog::ok_pressed() {
void ScriptCreateDialog::_create_new() {
- String cname;
- if (has_named_classes)
- cname = class_name->get_text();
+ String cname_param;
+
+ if (has_named_classes) {
+ cname_param = class_name->get_text();
+ } else {
+ cname_param = ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename();
+ }
Ref<Script> scr;
if (script_template != "") {
@@ -159,13 +163,16 @@ void ScriptCreateDialog::_create_new() {
return;
}
scr = scr->duplicate();
- ScriptServer::get_language(language_menu->get_selected())->make_template(cname, parent_name->get_text(), scr);
+ ScriptServer::get_language(language_menu->get_selected())->make_template(cname_param, parent_name->get_text(), scr);
} else {
- scr = ScriptServer::get_language(language_menu->get_selected())->get_template(cname, parent_name->get_text());
+ scr = ScriptServer::get_language(language_menu->get_selected())->get_template(cname_param, parent_name->get_text());
}
- if (cname != "")
- scr->set_name(cname);
+ if (has_named_classes) {
+ String cname = class_name->get_text();
+ if (cname.length())
+ scr->set_name(cname);
+ }
if (!is_built_in) {
String lpath = ProjectSettings::get_singleton()->localize_path(file_path->get_text());
@@ -201,12 +208,20 @@ void ScriptCreateDialog::_lang_changed(int l) {
l = language_menu->get_selected();
ScriptLanguage *language = ScriptServer::get_language(l);
+
if (language->has_named_classes()) {
has_named_classes = true;
} else {
has_named_classes = false;
}
+ if (language->supports_builtin_mode()) {
+ supports_built_in = true;
+ } else {
+ supports_built_in = false;
+ is_built_in = false;
+ }
+
if (ScriptServer::get_language(l)->can_inherit_from_file()) {
can_inherit_from_file = true;
} else {
@@ -496,6 +511,9 @@ void ScriptCreateDialog::_update_dialog() {
}
}
+ if (!supports_built_in)
+ internal->set_pressed(false);
+
/* Is Script created or loaded from existing file */
if (is_new_script_created) {
@@ -503,7 +521,7 @@ void ScriptCreateDialog::_update_dialog() {
get_ok()->set_text(TTR("Create"));
parent_name->set_editable(true);
parent_browse_button->set_disabled(false);
- internal->set_disabled(false);
+ internal->set_disabled(!supports_built_in);
if (is_built_in) {
_msg_path_valid(true, TTR("Built-in script (into scene file)"));
} else {
@@ -734,6 +752,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
is_path_valid = false;
has_named_classes = false;
+ supports_built_in = false;
can_inherit_from_file = false;
is_built_in = false;
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index d16c523f0a..c7bbc82d47 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -62,6 +62,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
bool is_new_script_created;
bool is_path_valid;
bool has_named_classes;
+ bool supports_built_in;
bool can_inherit_from_file;
bool is_parent_name_valid;
bool is_class_name_valid;
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index ef61aad341..bc2423fffd 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -574,7 +574,38 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
for (int i = 0; i < arr.size(); i++) {
p[i] = arr[i];
if (i < perf_items.size()) {
- perf_items[i]->set_text(1, rtos(p[i]));
+
+ float v = p[i];
+ String vs = rtos(v);
+ String tt = vs;
+ switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) {
+ case Performance::MONITOR_TYPE_MEMORY: {
+ // for the time being, going above GBs is a bad sign.
+ String unit = "B";
+ if ((int)v > 1073741824) {
+ unit = "GB";
+ v /= 1073741824.0;
+ } else if ((int)v > 1048576) {
+ unit = "MB";
+ v /= 1048576.0;
+ } else if ((int)v > 1024) {
+ unit = "KB";
+ v /= 1024.0;
+ }
+ tt += " bytes";
+ vs = rtos(v) + " " + unit;
+ } break;
+ case Performance::MONITOR_TYPE_TIME: {
+ tt += " seconds";
+ vs += " s";
+ } break;
+ default: {
+ tt += " " + perf_items[i]->get_text(0);
+ } break;
+ }
+
+ perf_items[i]->set_text(1, vs);
+ perf_items[i]->set_tooltip(1, tt);
if (p[i] > perf_max[i])
perf_max[i] = p[i];
}
@@ -775,7 +806,7 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType
reason->set_tooltip(p_reason);
}
-void ScriptEditorDebugger::_performance_select(Object *, int, bool) {
+void ScriptEditorDebugger::_performance_select() {
perf_draw->update();
}
@@ -785,7 +816,7 @@ void ScriptEditorDebugger::_performance_draw() {
Vector<int> which;
for (int i = 0; i < perf_items.size(); i++) {
- if (perf_items[i]->is_selected(0))
+ if (perf_items[i]->is_checked(0))
which.push_back(i);
}
@@ -816,14 +847,14 @@ void ScriptEditorDebugger::_performance_draw() {
r.position += graph_sb->get_offset();
r.size -= graph_sb->get_minimum_size();
int pi = which[i];
- Color c = get_color("success_color", "Editor");
- c.set_hsv(Math::fmod(c.get_h() + pi * 0.7654, 1), c.get_s(), c.get_v());
- //c = c.linear_interpolate(get_color("base_color", "Editor"), 0.9);
+ Color c = get_color("accent_color", "Editor");
+ float h = (float)which[i] / (float)(perf_items.size());
+ c.set_hsv(Math::fmod(h + 0.4, 0.9), c.get_s() * 0.9, c.get_v() * 1.4);
- c.a = 0.8;
- perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
c.a = 0.6;
- perf_draw->draw_string(graph_font, r.position + Point2(graph_font->get_char_size('X').width, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y);
+ perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
+ c.a = 0.9;
+ perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y);
float spacing = point_sep / float(cols);
float from = r.size.width;
@@ -1785,13 +1816,12 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
perf_monitors->set_column_title(1, TTR("Value"));
perf_monitors->set_column_titles_visible(true);
hsp->add_child(perf_monitors);
- perf_monitors->set_select_mode(Tree::SELECT_MULTI);
- perf_monitors->connect("multi_selected", this, "_performance_select");
+ perf_monitors->connect("item_edited", this, "_performance_select");
perf_draw = memnew(Control);
perf_draw->connect("draw", this, "_performance_draw");
hsp->add_child(perf_draw);
hsp->set_name(TTR("Monitors"));
- hsp->set_split_offset(300);
+ hsp->set_split_offset(340 * EDSCALE);
tabs->add_child(hsp);
perf_max.resize(Performance::MONITOR_MAX);
@@ -1801,6 +1831,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
+ Performance::MonitorType mtype = Performance::get_singleton()->get_monitor_type(Performance::Monitor(i));
String base = n.get_slice("/", 0);
String name = n.get_slice("/", 1);
if (!bases.has(base)) {
@@ -1808,12 +1839,16 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
b->set_text(0, base.capitalize());
b->set_editable(0, false);
b->set_selectable(0, false);
+ b->set_expand_right(0, true);
bases[base] = b;
}
TreeItem *it = perf_monitors->create_item(bases[base]);
- it->set_editable(0, false);
- it->set_selectable(0, true);
+ it->set_metadata(1, mtype);
+ it->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ it->set_editable(0, true);
+ it->set_selectable(0, false);
+ it->set_selectable(1, false);
it->set_text(0, name.capitalize());
perf_items.push_back(it);
perf_max[i] = 0;
diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h
index d0faab5892..d18a625eef 100644
--- a/editor/script_editor_debugger.h
+++ b/editor/script_editor_debugger.h
@@ -142,7 +142,7 @@ class ScriptEditorDebugger : public Control {
bool live_debug;
void _performance_draw();
- void _performance_select(Object *, int, bool);
+ void _performance_select();
void _stack_dump_frame_selected();
void _output_clear();