summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/object.cpp16
-rw-r--r--core/object.h1
-rw-r--r--editor/editor_node.cpp245
-rw-r--r--editor/editor_node.h6
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--scene/2d/camera_2d.cpp132
-rw-r--r--scene/2d/camera_2d.h13
-rw-r--r--scene/resources/primitive_meshes.cpp20
8 files changed, 335 insertions, 101 deletions
diff --git a/core/object.cpp b/core/object.cpp
index d83b2d0c6e..3416cd8c5a 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1357,6 +1357,21 @@ Array Object::_get_signal_connection_list(const String &p_signal) const {
return ret;
}
+Array Object::_get_incoming_connections() const {
+
+ Array ret;
+ int connections_amount = connections.size();
+ for (int idx_conn = 0; idx_conn < connections_amount; idx_conn++) {
+ Dictionary conn_data;
+ conn_data["source"] = connections[idx_conn].source;
+ conn_data["signal_name"] = connections[idx_conn].signal;
+ conn_data["method_name"] = connections[idx_conn].method;
+ ret.push_back(conn_data);
+ }
+
+ return ret;
+}
+
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
if (!script.is_null()) {
@@ -1683,6 +1698,7 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_signal_list"), &Object::_get_signal_list);
ClassDB::bind_method(D_METHOD("get_signal_connection_list", "signal"), &Object::_get_signal_connection_list);
+ ClassDB::bind_method(D_METHOD("get_incoming_connections"), &Object::_get_incoming_connections);
ClassDB::bind_method(D_METHOD("connect", "signal", "target:Object", "method", "binds", "flags"), &Object::connect, DEFVAL(Array()), DEFVAL(0));
ClassDB::bind_method(D_METHOD("disconnect", "signal", "target:Object", "method"), &Object::disconnect);
diff --git a/core/object.h b/core/object.h
index fabd10fa1f..dec4949c8d 100644
--- a/core/object.h
+++ b/core/object.h
@@ -443,6 +443,7 @@ private:
Variant _emit_signal(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
Array _get_signal_list() const;
Array _get_signal_connection_list(const String &p_signal) const;
+ Array _get_incoming_connections() const;
void _set_bind(const String &p_set, const Variant &p_value);
Variant _get_bind(const String &p_name) const;
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index bb6fcd5250..2c0deb0376 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -961,6 +961,23 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
}
+void EditorNode::_save_all_scenes() {
+
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ Node *scene = editor_data.get_edited_scene_root(i);
+ if (scene && scene->get_filename() != "") {
+ // save in background if in the script editor
+ if (i != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) {
+ _save_scene(scene->get_filename(), i);
+ } else {
+ _save_scene_with_preview(scene->get_filename());
+ }
+ } // else: ignore new scenes
+ }
+
+ _save_default_environment();
+}
+
void EditorNode::_import_action(const String &p_action) {
#if 0
import_confirmation->hide();
@@ -1117,14 +1134,26 @@ void EditorNode::_dialog_action(String p_file) {
get_undo_redo()->clear_history();
} break;
+ case FILE_CLOSE:
+ case FILE_CLOSE_ALL_AND_QUIT:
+ case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
+ case SCENE_TAB_CLOSE:
case FILE_SAVE_SCENE:
case FILE_SAVE_AS_SCENE: {
+ int scene_idx = (current_option == FILE_SAVE_SCENE || current_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing;
+
if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
//_save_scene(p_file);
_save_default_environment();
- _save_scene_with_preview(p_file);
+ if (scene_idx != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT)
+ _save_scene(p_file, scene_idx);
+ else
+ _save_scene_with_preview(p_file);
+
+ if (scene_idx != -1)
+ _discard_changes();
}
} break;
@@ -1886,42 +1915,45 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
open_request(previous_scenes.back()->get());
} break;
+ case FILE_CLOSE_ALL_AND_QUIT:
+ case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
case FILE_CLOSE: {
- if (!p_confirmed && unsaved_cache) {
- confirmation->get_ok()->set_text(TTR("Yes"));
- //confirmation->get_cancel()->show();
- confirmation->set_text(TTR("Close scene? (Unsaved changes will be lost)"));
- confirmation->popup_centered_minsize();
+ if (!p_confirmed && (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER)) {
+ tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene();
+ String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename();
+ save_confirmation->get_ok()->set_text(TTR("Save & Close"));
+ save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene"));
+ save_confirmation->popup_centered_minsize();
break;
}
-
- _remove_edited_scene();
-
- } break;
- case SCENE_TAB_CLOSE: {
- _remove_scene(tab_closing);
- _update_scene_tabs();
- current_option = -1;
- } break;
+ } // fallthrough
+ case SCENE_TAB_CLOSE:
case FILE_SAVE_SCENE: {
- Node *scene = editor_data.get_edited_scene_root();
+ int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing;
+
+ Node *scene = editor_data.get_edited_scene_root(scene_idx);
if (scene && scene->get_filename() != "") {
// save in background if in the script editor
- if (_get_current_main_editor() == EDITOR_SCRIPT) {
- _save_scene(scene->get_filename());
+ if (scene_idx != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) {
+ _save_scene(scene->get_filename(), scene_idx);
} else {
_save_scene_with_preview(scene->get_filename());
}
- return;
- };
+
+ if (scene_idx != -1)
+ _discard_changes();
+
+ break;
+ }
// fallthrough to save_as
};
case FILE_SAVE_AS_SCENE: {
+ int scene_idx = (p_option == FILE_SAVE_SCENE || p_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing;
- Node *scene = editor_data.get_edited_scene_root();
+ Node *scene = editor_data.get_edited_scene_root(scene_idx);
if (!scene) {
@@ -1957,7 +1989,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
String existing;
if (extensions.size()) {
- String root_name(get_edited_scene()->get_name());
+ String root_name(scene->get_name());
existing = root_name + "." + extensions.front()->get().to_lower();
}
file->set_current_path(existing);
@@ -1968,19 +2000,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_SAVE_ALL_SCENES: {
- for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- Node *scene = editor_data.get_edited_scene_root(i);
- if (scene && scene->get_filename() != "") {
- // save in background if in the script editor
- if (i != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) {
- _save_scene(scene->get_filename(), i);
- } else {
- _save_scene_with_preview(scene->get_filename());
- }
- } // else: ignore new scenes
- }
- _save_default_environment();
+ _save_all_scenes();
} break;
case FILE_SAVE_BEFORE_RUN: {
if (!p_confirmed) {
@@ -2099,22 +2120,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
- case FILE_QUIT: {
-
- if (!p_confirmed) {
-
- confirmation->get_ok()->set_text(TTR("Quit"));
- //confirmation->get_cancel()->show();
- confirmation->set_text(TTR("Exit the editor?"));
- confirmation->popup_centered(Size2(180, 70) * EDSCALE);
- break;
- }
-
- _menu_option_confirm(RUN_STOP, true);
- exiting = true;
- get_tree()->quit();
-
- } break;
case FILE_EXTERNAL_OPEN_SCENE: {
if (unsaved_cache && !p_confirmed) {
@@ -2443,28 +2448,53 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
project_settings->popup_project_settings();
} break;
+ case FILE_QUIT:
case RUN_PROJECT_MANAGER: {
if (!p_confirmed) {
- confirmation->get_ok()->set_text(TTR("Yes"));
- confirmation->set_text(TTR("Open Project Manager? \n(Unsaved changes will be lost)"));
- confirmation->popup_centered_minsize();
- break;
- }
+ if (_next_unsaved_scene() == -1) {
- _menu_option_confirm(RUN_STOP, true);
- exiting = true;
- get_tree()->quit();
- String exec = OS::get_singleton()->get_executable_path();
+ bool confirm = EDITOR_DEF("interface/quit_confirmation", true);
+ if (confirm) {
- List<String> args;
- args.push_back("-path");
- args.push_back(exec.get_base_dir());
- args.push_back("-pm");
+ confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes"));
+ confirmation->set_text(p_option == FILE_QUIT ? TTR("Exit the editor?") : TTR("Open Project Manager?"));
+ confirmation->popup_centered_minsize();
+ } else {
+ _discard_changes();
+ }
+ } else {
- OS::ProcessID pid = 0;
- Error err = OS::get_singleton()->execute(exec, args, false, &pid);
- ERR_FAIL_COND(err);
+ bool save_each = EDITOR_DEF("interface/save_each_scene_on_quit", true);
+ if (save_each) {
+
+ _menu_option_confirm(p_option == FILE_QUIT ? FILE_CLOSE_ALL_AND_QUIT : FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER, false);
+ } else {
+
+ String unsaved_scenes;
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ int current = editor_data.get_edited_scene();
+ bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
+ if (unsaved) {
+
+ String scene_filename = editor_data.get_edited_scene_root(i)->get_filename();
+ unsaved_scenes += "\n " + scene_filename;
+ }
+ }
+
+ save_confirmation->get_ok()->set_text(TTR("Save & Quit"));
+ save_confirmation->set_text((p_option == FILE_QUIT ? TTR("Save changes to the following scene(s) before quitting?") : TTR("Save changes the following scene(s) before opening Project Manager?")) + unsaved_scenes);
+ save_confirmation->popup_centered_minsize();
+ }
+ }
+
+ break;
+ }
+
+ if (_next_unsaved_scene() != -1) {
+ _save_all_scenes();
+ }
+ _discard_changes();
} break;
case RUN_FILE_SERVER: {
@@ -2690,6 +2720,70 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
+int EditorNode::_next_unsaved_scene() {
+
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+
+ int current = editor_data.get_edited_scene();
+ bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
+ if (unsaved) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+void EditorNode::_discard_changes(const String &p_str) {
+
+ switch (current_option) {
+
+ case FILE_CLOSE_ALL_AND_QUIT:
+ case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
+ case FILE_CLOSE:
+ case SCENE_TAB_CLOSE: {
+
+ _remove_scene(tab_closing);
+ _update_scene_tabs();
+
+ if (current_option == FILE_CLOSE_ALL_AND_QUIT || current_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) {
+ int next_scene = _next_unsaved_scene();
+ if (next_scene == -1) {
+ current_option = current_option == FILE_CLOSE_ALL_AND_QUIT ? FILE_QUIT : RUN_PROJECT_MANAGER;
+ _discard_changes();
+ } else {
+ tab_closing = next_scene;
+ _menu_option_confirm(current_option, false);
+ }
+ } else {
+ current_option = -1;
+ save_confirmation->hide();
+ }
+ } break;
+ case FILE_QUIT: {
+
+ _menu_option_confirm(RUN_STOP, true);
+ exiting = true;
+ get_tree()->quit();
+ } break;
+ case RUN_PROJECT_MANAGER: {
+
+ _menu_option_confirm(RUN_STOP, true);
+ exiting = true;
+ get_tree()->quit();
+ String exec = OS::get_singleton()->get_executable_path();
+
+ List<String> args;
+ args.push_back("-path");
+ args.push_back(exec.get_base_dir());
+ args.push_back("-pm");
+
+ OS::ProcessID pid = 0;
+ Error err = OS::get_singleton()->execute(exec, args, false, &pid);
+ ERR_FAIL_COND(err);
+ } break;
+ }
+}
+
void EditorNode::_update_debug_options() {
bool check_deploy_remote = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_deploy_remote_debug", false);
@@ -4261,19 +4355,17 @@ void EditorNode::_scene_tab_script_edited(int p_tab) {
void EditorNode::_scene_tab_closed(int p_tab) {
current_option = SCENE_TAB_CLOSE;
tab_closing = p_tab;
+ Node *scene = editor_data.get_edited_scene_root(p_tab);
bool unsaved = (p_tab == editor_data.get_edited_scene()) ?
saved_version != editor_data.get_undo_redo().get_version() :
editor_data.get_scene_version(p_tab) != 0;
if (unsaved) {
- confirmation->get_ok()->set_text(TTR("Yes"));
-
- //confirmation->get_cancel()->show();
- confirmation->set_text(TTR("Close scene? (Unsaved changes will be lost)"));
- confirmation->popup_centered_minsize();
+ save_confirmation->get_ok()->set_text(TTR("Save & Close"));
+ save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_filename() != "" ? scene->get_filename() : "unsaved scene"));
+ save_confirmation->popup_centered_minsize();
} else {
- _remove_scene(p_tab);
- _update_scene_tabs();
+ _discard_changes();
}
}
@@ -4891,6 +4983,7 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_scene_tab_script_edited", &EditorNode::_scene_tab_script_edited);
ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
ClassDB::bind_method("_update_scene_tabs", &EditorNode::_update_scene_tabs);
+ ClassDB::bind_method("_discard_changes", &EditorNode::_discard_changes);
ClassDB::bind_method("_prepare_history", &EditorNode::_prepare_history);
ClassDB::bind_method("_select_history", &EditorNode::_select_history);
@@ -5890,6 +5983,12 @@ EditorNode::EditorNode() {
gui_base->add_child(confirmation);
confirmation->connect("confirmed", this, "_menu_confirm_current");
+ save_confirmation = memnew(ConfirmationDialog);
+ save_confirmation->add_button(TTR("Don't Save"), OS::get_singleton()->get_swap_ok_cancel(), "discard");
+ gui_base->add_child(save_confirmation);
+ save_confirmation->connect("confirmed", this, "_menu_confirm_current");
+ save_confirmation->connect("custom_action", this, "_discard_changes");
+
accept = memnew(AcceptDialog);
gui_base->add_child(accept);
accept->connect("confirmed", this, "_menu_confirm_current");
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 3870edb7c6..5e83cec4a3 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -140,6 +140,8 @@ private:
FILE_RUN_SCRIPT,
FILE_OPEN_PREV,
FILE_CLOSE,
+ FILE_CLOSE_ALL_AND_QUIT,
+ FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER,
FILE_QUIT,
FILE_EXTERNAL_OPEN_SCENE,
EDIT_UNDO,
@@ -296,6 +298,7 @@ private:
//CallDialog *call_dialog;
ConfirmationDialog *confirmation;
+ ConfirmationDialog *save_confirmation;
ConfirmationDialog *import_confirmation;
ConfirmationDialog *open_recent_confirmation;
ConfirmationDialog *pick_main_scene;
@@ -465,6 +468,9 @@ private:
void _vp_resized();
void _save_scene(String p_file, int idx = -1);
+ void _save_all_scenes();
+ int _next_unsaved_scene();
+ void _discard_changes(const String &p_str = String());
void _instance_request(const Vector<String> &p_files);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 77f8c59b95..f018603bfc 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -517,6 +517,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("interface/separate_distraction_mode", false);
+ set("interface/save_each_scene_on_quit", true); // Regression
+ set("interface/quit_confirmation", true);
+
set("interface/theme/preset", 0);
hints["interface/theme/preset"] = PropertyInfo(Variant::INT, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Grey,Godot 2,Arc,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
set("interface/theme/base_color", Color::html("#273241"));
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 9d8b5da366..908c95b50c 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -199,10 +199,8 @@ Transform2D Camera2D::get_camera_transform() {
/*
if (0) {
-
xform = get_global_transform() * xform;
} else {
-
xform.elements[2]+=get_global_transform().get_origin();
}
*/
@@ -267,25 +265,76 @@ void Camera2D::_notification(int p_what) {
if (!is_inside_tree() || !get_tree()->is_editor_hint())
break;
- Color area_axis_color(0.5, 0.42, 0.87, 0.63);
- float area_axis_width = 1;
- if (current)
- area_axis_width = 3;
+ if (screen_drawing_enabled) {
+ Color area_axis_color(0.5, 0.42, 0.87, 0.63);
+ float area_axis_width = 1;
+ if (is_current()) {
+ area_axis_width = 3;
+ area_axis_color.a = 0.83;
+ }
- Transform2D inv_camera_transform = get_camera_transform().affine_inverse();
- Size2 screen_size = get_viewport_rect().size;
+ Transform2D inv_camera_transform = get_camera_transform().affine_inverse();
+ Size2 screen_size = get_viewport_rect().size;
- Vector2 screen_endpoints[4] = {
- inv_camera_transform.xform(Vector2(0, 0)),
- inv_camera_transform.xform(Vector2(screen_size.width, 0)),
- inv_camera_transform.xform(Vector2(screen_size.width, screen_size.height)),
- inv_camera_transform.xform(Vector2(0, screen_size.height))
- };
+ Vector2 screen_endpoints[4] = {
+ inv_camera_transform.xform(Vector2(0, 0)),
+ inv_camera_transform.xform(Vector2(screen_size.width, 0)),
+ inv_camera_transform.xform(Vector2(screen_size.width, screen_size.height)),
+ inv_camera_transform.xform(Vector2(0, screen_size.height))
+ };
- Transform2D inv_transform = get_global_transform().affine_inverse(); // undo global space
+ Transform2D inv_transform = get_global_transform().affine_inverse(); // undo global space
- for (int i = 0; i < 4; i++) {
- draw_line(inv_transform.xform(screen_endpoints[i]), inv_transform.xform(screen_endpoints[(i + 1) % 4]), area_axis_color, area_axis_width);
+ for (int i = 0; i < 4; i++) {
+ draw_line(inv_transform.xform(screen_endpoints[i]), inv_transform.xform(screen_endpoints[(i + 1) % 4]), area_axis_color, area_axis_width);
+ }
+ }
+
+ if (limit_drawing_enabled) {
+ Color limit_drawing_color(1, 1, 0, 0.63);
+ float limit_drawing_width = 1;
+ if (is_current()) {
+ limit_drawing_color.a = 0.83;
+ limit_drawing_width = 3;
+ }
+
+ Vector2 camera_origin = get_global_transform().get_origin();
+ Vector2 camera_scale = get_global_transform().get_scale().abs();
+ Vector2 limit_points[4] = {
+ (Vector2(limit[MARGIN_LEFT], limit[MARGIN_TOP]) - camera_origin) / camera_scale,
+ (Vector2(limit[MARGIN_RIGHT], limit[MARGIN_TOP]) - camera_origin) / camera_scale,
+ (Vector2(limit[MARGIN_RIGHT], limit[MARGIN_BOTTOM]) - camera_origin) / camera_scale,
+ (Vector2(limit[MARGIN_LEFT], limit[MARGIN_BOTTOM]) - camera_origin) / camera_scale
+ };
+
+ for (int i = 0; i < 4; i++) {
+ draw_line(limit_points[i], limit_points[(i + 1) % 4], limit_drawing_color, limit_drawing_width);
+ }
+ }
+
+ if (margin_drawing_enabled) {
+ Color margin_drawing_color(0, 1, 1, 0.63);
+ float margin_drawing_width = 1;
+ if (is_current()) {
+ margin_drawing_width = 3;
+ margin_drawing_color.a = 0.83;
+ }
+
+ Transform2D inv_camera_transform = get_camera_transform().affine_inverse();
+ Size2 screen_size = get_viewport_rect().size;
+
+ Vector2 margin_endpoints[4] = {
+ inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[MARGIN_LEFT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[MARGIN_TOP]))),
+ inv_camera_transform.xform(Vector2((screen_size.width / 2) + ((screen_size.width / 2) * drag_margin[MARGIN_RIGHT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[MARGIN_TOP]))),
+ inv_camera_transform.xform(Vector2((screen_size.width / 2) + ((screen_size.width / 2) * drag_margin[MARGIN_RIGHT]), (screen_size.height / 2) + ((screen_size.height / 2) * drag_margin[MARGIN_BOTTOM]))),
+ inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[MARGIN_LEFT]), (screen_size.height / 2) + ((screen_size.height / 2) * drag_margin[MARGIN_BOTTOM])))
+ };
+
+ Transform2D inv_transform = get_global_transform().affine_inverse(); // undo global space
+
+ for (int i = 0; i < 4; i++) {
+ draw_line(inv_transform.xform(margin_endpoints[i]), inv_transform.xform(margin_endpoints[(i + 1) % 4]), margin_drawing_color, margin_drawing_width);
+ }
}
} break;
@@ -330,7 +379,6 @@ void Camera2D::_make_current(Object *p_which) {
if (p_which == this) {
current = true;
- _update_scroll();
} else {
current = false;
}
@@ -342,6 +390,7 @@ void Camera2D::_set_current(bool p_current) {
make_current();
current = p_current;
+ update();
}
bool Camera2D::is_current() const {
@@ -370,6 +419,7 @@ void Camera2D::set_limit(Margin p_margin, int p_limit) {
ERR_FAIL_INDEX(p_margin, 4);
limit[p_margin] = p_limit;
+ update();
}
int Camera2D::get_limit(Margin p_margin) const {
@@ -393,6 +443,7 @@ void Camera2D::set_drag_margin(Margin p_margin, float p_drag_margin) {
ERR_FAIL_INDEX(p_margin, 4);
drag_margin[p_margin] = p_drag_margin;
+ update();
}
float Camera2D::get_drag_margin(Margin p_margin) const {
@@ -554,6 +605,33 @@ Node *Camera2D::get_custom_viewport() const {
return custom_viewport;
}
+void Camera2D::set_screen_drawing_enabled(bool enable) {
+ screen_drawing_enabled = enable;
+ update();
+}
+
+bool Camera2D::is_screen_drawing_enabled() const {
+ return screen_drawing_enabled;
+}
+
+void Camera2D::set_limit_drawing_enabled(bool enable) {
+ limit_drawing_enabled = enable;
+ update();
+}
+
+bool Camera2D::is_limit_drawing_enabled() const {
+ return limit_drawing_enabled;
+}
+
+void Camera2D::set_margin_drawing_enabled(bool enable) {
+ margin_drawing_enabled = enable;
+ update();
+}
+
+bool Camera2D::is_margin_drawing_enabled() const {
+ return margin_drawing_enabled;
+}
+
void Camera2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Camera2D::set_offset);
@@ -616,6 +694,15 @@ void Camera2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_old_smoothing", "follow_smoothing"), &Camera2D::_set_old_smoothing);
+ ClassDB::bind_method(D_METHOD("set_screen_drawing_enabled", "screen_drawing_enabled"), &Camera2D::set_screen_drawing_enabled);
+ ClassDB::bind_method(D_METHOD("is_screen_drawing_enabled"), &Camera2D::is_screen_drawing_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_limit_drawing_enabled", "limit_drawing_enabled"), &Camera2D::set_limit_drawing_enabled);
+ ClassDB::bind_method(D_METHOD("is_limit_drawing_enabled"), &Camera2D::is_limit_drawing_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_margin_drawing_enabled", "margin_drawing_enabled"), &Camera2D::set_margin_drawing_enabled);
+ ClassDB::bind_method(D_METHOD("is_margin_drawing_enabled"), &Camera2D::is_margin_drawing_enabled);
+
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_mode", PROPERTY_HINT_ENUM, "Fixed TopLeft,Drag Center"), "set_anchor_mode", "get_anchor_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotating"), "set_rotating", "is_rotating");
@@ -643,6 +730,11 @@ void Camera2D::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "drag_margin_right", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", MARGIN_RIGHT);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "drag_margin_bottom", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", MARGIN_BOTTOM);
+ ADD_GROUP("Editor", "editor_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_screen"), "set_screen_drawing_enabled", "is_screen_drawing_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_limits"), "set_limit_drawing_enabled", "is_limit_drawing_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_drag_margin"), "set_margin_drawing_enabled", "is_margin_drawing_enabled");
+
BIND_CONSTANT(ANCHOR_MODE_DRAG_CENTER);
BIND_CONSTANT(ANCHOR_MODE_FIXED_TOP_LEFT);
}
@@ -671,6 +763,10 @@ Camera2D::Camera2D() {
smoothing = 5.0;
zoom = Vector2(1, 1);
+ screen_drawing_enabled = true;
+ limit_drawing_enabled = false;
+ margin_drawing_enabled = false;
+
h_drag_enabled = true;
v_drag_enabled = true;
h_ofs = 0;
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 686f40bedf..8d9e76be85 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -79,6 +79,10 @@ protected:
void _set_old_smoothing(float p_enable);
+ bool screen_drawing_enabled;
+ bool limit_drawing_enabled;
+ bool margin_drawing_enabled;
+
protected:
virtual Transform2D get_camera_transform();
void _notification(int p_what);
@@ -138,6 +142,15 @@ public:
void reset_smoothing();
void align();
+ void set_screen_drawing_enabled(bool enable);
+ bool is_screen_drawing_enabled() const;
+
+ void set_limit_drawing_enabled(bool enable);
+ bool is_limit_drawing_enabled() const;
+
+ void set_margin_drawing_enabled(bool enable);
+ bool is_margin_drawing_enabled() const;
+
Camera2D();
};
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index d4221dcb3f..8d058377db 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -359,8 +359,8 @@ int CapsuleMesh::get_rings() const {
CapsuleMesh::CapsuleMesh() {
// defaults
- radius = 0.5;
- mid_height = 0.5;
+ radius = 1.0;
+ mid_height = 1.0;
radial_segments = 64;
rings = 8;
}
@@ -617,7 +617,7 @@ int CubeMesh::get_subdivide_depth() const {
CubeMesh::CubeMesh() {
// defaults
- size = Vector3(1.0, 1.0, 1.0);
+ size = Vector3(2.0, 2.0, 2.0);
subdivide_w = 0;
subdivide_h = 0;
subdivide_d = 0;
@@ -834,9 +834,9 @@ int CylinderMesh::get_rings() const {
CylinderMesh::CylinderMesh() {
// defaults
- top_radius = 0.5;
- bottom_radius = 0.5;
- height = 1.0;
+ top_radius = 1.0;
+ bottom_radius = 1.0;
+ height = 2.0;
radial_segments = 64;
rings = 4;
}
@@ -951,7 +951,7 @@ int PlaneMesh::get_subdivide_depth() const {
PlaneMesh::PlaneMesh() {
// defaults
- size = Size2(1.0, 1.0);
+ size = Size2(2.0, 2.0);
subdivide_w = 0;
subdivide_d = 0;
}
@@ -1242,7 +1242,7 @@ int PrismMesh::get_subdivide_depth() const {
PrismMesh::PrismMesh() {
// defaults
left_to_right = 0.5;
- size = Vector3(1.0, 1.0, 1.0);
+ size = Vector3(2.0, 2.0, 2.0);
subdivide_w = 0;
subdivide_h = 0;
subdivide_d = 0;
@@ -1446,8 +1446,8 @@ bool SphereMesh::get_is_hemisphere() const {
SphereMesh::SphereMesh() {
// defaults
- radius = 0.5;
- height = 1.0;
+ radius = 1.0;
+ height = 2.0;
radial_segments = 64;
rings = 32;
is_hemisphere = false;