diff options
-rw-r--r-- | doc/classes/GraphEdit.xml | 2 | ||||
-rw-r--r-- | doc/classes/GraphNode.xml | 2 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/animation_blend_space_1d_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/animation_state_machine_editor.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/animation_tree_editor_plugin.cpp | 34 | ||||
-rw-r--r-- | editor/scene_tree_editor.cpp | 2 | ||||
-rw-r--r-- | modules/gdnative/doc_classes/PluginScript.xml | 7 | ||||
-rw-r--r-- | modules/gdnative/pluginscript/pluginscript_script.cpp | 86 | ||||
-rw-r--r-- | modules/gdnative/pluginscript/pluginscript_script.h | 5 | ||||
-rw-r--r-- | scene/gui/label.cpp | 4 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 1 |
13 files changed, 111 insertions, 44 deletions
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index ce0b619d67..5ac3db1e8e 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -82,7 +82,7 @@ <return type="Array"> </return> <description> - Return an Array containing the list of connections. A connection consists in a structure of the form {from_slot: 0, from: "GraphNode name 0", to_slot: 1, to: "GraphNode name 1" } + Return an Array containing the list of connections. A connection consists in a structure of the form {from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" } </description> </method> <method name="get_zoom_hbox"> diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index 4c39720d69..6e09926c11 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -236,6 +236,8 @@ </theme_item> <theme_item name="close" type="Texture"> </theme_item> + <theme_item name="close_color" type="Color"> + </theme_item> <theme_item name="close_offset" type="int"> </theme_item> <theme_item name="comment" type="StyleBox"> diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index b2368fff6b..4cc0b67b8d 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1180,7 +1180,7 @@ void FileSystemDock::_make_dir_confirm() { String dir_name = make_dir_dialog_text->get_text().strip_edges(); if (dir_name.length() == 0) { - EditorNode::get_singleton()->show_warning(TTR("No name provided")); + EditorNode::get_singleton()->show_warning(TTR("No name provided.")); return; } else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.find("*") != -1 || dir_name.find("|") != -1 || dir_name.find(">") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) { diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 586b7668ad..cb18832641 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -72,7 +72,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven ap->get_animation_list(&names); for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_icon("Animation", "Editoricons"), E->get()); + animations_menu->add_icon_item(get_icon("Animation", "EditorIcons"), E->get()); animations_to_add.push_back(E->get()); } } diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 81d048b2b4..06c2db74af 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -395,7 +395,7 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { undo_redo->create_action("Delete Node"); undo_redo->add_do_method(blend_tree.ptr(), "remove_node", p_which); - undo_redo->add_undo_method(blend_tree.ptr(), "add_node", p_which, blend_tree->get_node(p_which)); + undo_redo->add_undo_method(blend_tree.ptr(), "add_node", p_which, blend_tree->get_node(p_which), blend_tree.ptr()->get_node_position(p_which)); List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); @@ -813,6 +813,8 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima break; } } + + _update_graph(); // Needed to update the signal connections with the new name. } void AnimationNodeBlendTreeEditor::_node_renamed_focus_out(Node *le, Ref<AnimationNode> p_node) { diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index df7ac0b587..8efd12ecf9 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -1073,7 +1073,9 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1) - ERR_FAIL_COND(new_name == prev_name); + if (new_name == prev_name) { + return; // Nothing to do. + } String base_name = new_name; int base = 1; diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 24787a78e9..387a254c4f 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -64,34 +64,15 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) { void AnimationTreeEditor::_path_button_pressed(int p_path) { - Ref<AnimationNode> node = tree->get_tree_root(); - if (node.is_null()) - return; - edited_path.clear(); - if (p_path >= 0) { - for (int i = 0; i <= p_path; i++) { - Ref<AnimationNode> child = node->get_child_by_name(button_path[i]); - ERR_BREAK(child.is_null()); - node = child; - edited_path.push_back(button_path[i]); - } - } - - for (int i = 0; i < editors.size(); i++) { - if (editors[i]->can_edit(node)) { - editors[i]->edit(node); - editors[i]->show(); - } else { - editors[i]->edit(Ref<AnimationNode>()); - editors[i]->hide(); - } + for (int i = 0; i <= p_path; i++) { + edited_path.push_back(button_path[i]); } } void AnimationTreeEditor::_update_path() { - while (path_hb->get_child_count()) { - memdelete(path_hb->get_child(0)); + while (path_hb->get_child_count() > 1) { + memdelete(path_hb->get_child(1)); } Ref<ButtonGroup> group; @@ -176,6 +157,10 @@ void AnimationTreeEditor::_notification(int p_what) { if (root != current_root) { edit_path(Vector<String>()); } + + if (button_path.size() != edited_path.size()) { + edit_path(edited_path); + } } } @@ -251,6 +236,9 @@ AnimationTreeEditor::AnimationTreeEditor() { path_edit->set_enable_v_scroll(false); path_hb = memnew(HBoxContainer); path_edit->add_child(path_hb); + path_hb->add_child(memnew(Label(TTR("Path:")))); + + add_child(memnew(HSeparator)); current_root = 0; singleton = this; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 7205f34343..657293ea7f 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -668,7 +668,7 @@ void SceneTreeEditor::_renamed() { // Empty node names are not allowed, so resets it to previous text and show warning if (which->get_text(0).strip_edges().empty()) { which->set_text(0, n->get_name()); - EditorNode::get_singleton()->show_warning(TTR("No name provided")); + EditorNode::get_singleton()->show_warning(TTR("No name provided.")); return; } diff --git a/modules/gdnative/doc_classes/PluginScript.xml b/modules/gdnative/doc_classes/PluginScript.xml index 27c6adae3f..1876d06c20 100644 --- a/modules/gdnative/doc_classes/PluginScript.xml +++ b/modules/gdnative/doc_classes/PluginScript.xml @@ -9,6 +9,13 @@ <demos> </demos> <methods> + <method name="new" qualifiers="vararg"> + <return type="Object"> + </return> + <description> + Returns a new instance of the script. + </description> + </method> </methods> <constants> </constants> diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index c3a623e9a1..9821cf39e4 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -52,6 +52,79 @@ #endif void PluginScript::_bind_methods() { + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &PluginScript::_new, MethodInfo(Variant::OBJECT, "new")); +} + +PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Variant::CallError &r_error) { + + r_error.error = Variant::CallError::CALL_OK; + + // Create instance + PluginScriptInstance *instance = memnew(PluginScriptInstance()); + + if (instance->init(this, p_owner)) { + _language->lock(); + _instances.insert(instance->get_owner()); + _language->unlock(); + } else { + r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL; + memdelete(instance); + ERR_FAIL_V(NULL); + } + + // Construct + // TODO: Support arguments in the constructor? + // There is currently no way to get the constructor function name of the script. + // instance->call("__init__", p_args, p_argcount, r_error); + if (p_argcount > 0) { + WARN_PRINT("PluginScript doesn't support arguments in the constructor") + } + + return instance; +} + +Variant PluginScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { + + r_error.error = Variant::CallError::CALL_OK; + + if (!_valid) { + r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; + return Variant(); + } + + REF ref; + Object *owner = NULL; + + if (get_instance_base_type() == "") { + owner = memnew(Reference); + } else { + owner = ClassDB::instance(get_instance_base_type()); + } + + if (!owner) { + r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL; + return Variant(); + } + + Reference *r = Object::cast_to<Reference>(owner); + if (r) { + ref = REF(r); + } + + PluginScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r_error); + + if (!instance) { + if (ref.is_null()) { + memdelete(owner); //no owner, sorry + } + return Variant(); + } + + if (ref.is_valid()) { + return ref; + } else { + return owner; + } } #ifdef TOOLS_ENABLED @@ -129,17 +202,8 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) { } } - PluginScriptInstance *instance = memnew(PluginScriptInstance()); - const bool success = instance->init(this, p_this); - if (success) { - _language->lock(); - _instances.insert(instance->get_owner()); - _language->unlock(); - return instance; - } else { - memdelete(instance); - ERR_FAIL_V(NULL); - } + Variant::CallError unchecked_error; + return _create_instance(NULL, 0, p_this, unchecked_error); } bool PluginScript::instance_has(const Object *p_this) const { diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h index 3ade8ac004..68f26b514c 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ b/modules/gdnative/pluginscript/pluginscript_script.h @@ -37,8 +37,6 @@ #include "pluginscript_language.h" #include <pluginscript/godot_pluginscript.h> -class PyInstance; - class PluginScript : public Script { GDCLASS(PluginScript, Script); @@ -74,6 +72,9 @@ private: protected: static void _bind_methods(); + PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Variant::CallError &r_error); + Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error); + #ifdef TOOLS_ENABLED Set<PlaceHolderScriptInstance *> placeholders; //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 1b7196c402..14e8c34d5f 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -244,7 +244,7 @@ void Label::_notification(int p_what) { CharType n = xl_text[i + pos + 1]; if (uppercase) { c = String::char_uppercase(c); - n = String::char_uppercase(c); + n = String::char_uppercase(n); } float move = font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + shadow_ofs, c, n, font_color_shadow, false); @@ -265,7 +265,7 @@ void Label::_notification(int p_what) { CharType n = xl_text[i + pos + 1]; if (uppercase) { c = String::char_uppercase(c); - n = String::char_uppercase(c); + n = String::char_uppercase(n); } x_ofs += drawer.draw_char(ci, Point2(x_ofs, y_ofs), c, n, font_color); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index b0c1dcde9a..7d7bf8a750 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -600,6 +600,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_icon("resizer", "GraphNode", make_icon(window_resizer_png)); theme->set_font("title_font", "GraphNode", default_font); theme->set_color("title_color", "GraphNode", Color(0, 0, 0, 1)); + theme->set_color("close_color", "GraphNode", Color(0, 0, 0, 1)); theme->set_constant("title_offset", "GraphNode", 20 * scale); theme->set_constant("close_offset", "GraphNode", 18 * scale); theme->set_constant("port_offset", "GraphNode", 3 * scale); |