diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 229640ba115..aff047177c2 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -55,11 +55,17 @@ bool _ResourceLoader::has(const String &p_path) { return ResourceCache::has(local_path); }; +Ref _ResourceLoader::load_import_metadata(const String& p_path) { + + return ResourceLoader::load_import_metadata(p_path); +} + void _ResourceLoader::_bind_methods() { ObjectTypeDB::bind_method(_MD("load_interactive:ResourceInteractiveLoader","path","type_hint"),&_ResourceLoader::load_interactive,DEFVAL("")); ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("load_import_metadata:ResourceImportMetadata","path"),&_ResourceLoader::load_import_metadata); ObjectTypeDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type); ObjectTypeDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources); ObjectTypeDB::bind_method(_MD("get_dependencies","path"),&_ResourceLoader::get_dependencies); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 4a9bb2a961d..2c43390d3c4 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -26,6 +26,7 @@ public: void set_abort_on_missing_resources(bool p_abort); StringArray get_dependencies(const String& p_path); bool has(const String& p_path); + Ref load_import_metadata(const String& p_path); _ResourceLoader(); }; diff --git a/core/error_macros.h b/core/error_macros.h index cafbf0c16eb..47b1de5df31 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -223,5 +223,10 @@ extern bool _err_error_exists; } \ +#define WARN_PRINTS(m_string) \ + { \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,String(m_string).utf8().get_data(),ERR_HANDLER_WARNING); \ + _err_error_exists=false;\ + } \ #endif diff --git a/core/global_constants.cpp b/core/global_constants.cpp index a183255b068..130fca1b2a2 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -432,6 +432,7 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( ERR_FILE_EOF ), BIND_GLOBAL_CONSTANT( ERR_CANT_OPEN ), ///< Can't open a resource/socket/file BIND_GLOBAL_CONSTANT( ERR_CANT_CREATE ), + BIND_GLOBAL_CONSTANT( ERR_PARSE_ERROR ), BIND_GLOBAL_CONSTANT( ERROR_QUERY_FAILED ), BIND_GLOBAL_CONSTANT( ERR_ALREADY_IN_USE ), BIND_GLOBAL_CONSTANT( ERR_LOCKED ), ///< resource is locked diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index d977ea3e185..54431cf381a 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -51,6 +51,7 @@ #include "packed_data_container.h" #include "func_ref.h" #include "input_map.h" +#include "undo_redo.h" #ifdef XML_ENABLED static ResourceFormatSaverXML *resource_saver_xml=NULL; @@ -128,7 +129,7 @@ void register_core_types() { // ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); - + ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_virtual_type(); diff --git a/demos/plugins/custom_dock/custom_dock.scn b/demos/plugins/custom_dock/custom_dock.scn new file mode 100644 index 00000000000..0e32ece2649 Binary files /dev/null and b/demos/plugins/custom_dock/custom_dock.scn differ diff --git a/demos/plugins/custom_dock/dock_plugin.gd b/demos/plugins/custom_dock/dock_plugin.gd new file mode 100644 index 00000000000..ce8a3bcd09f --- /dev/null +++ b/demos/plugins/custom_dock/dock_plugin.gd @@ -0,0 +1,23 @@ +tool +extends EditorPlugin + +var dock = null + +func _enter_tree(): + # When this plugin node enters tree, add the custom type + + dock = preload("res://addons/custom_dock/custom_dock.scn").instance() + + add_control_to_dock( DOCK_SLOT_LEFT_UL, dock ) + +func _exit_tree(): + + # Remove from docks (must be called so layout is updated and saved) + remove_control_from_docks(dock) + # Remove the node + dock.free() + + + + + \ No newline at end of file diff --git a/demos/plugins/custom_dock/plugin.cfg b/demos/plugins/custom_dock/plugin.cfg new file mode 100644 index 00000000000..e295384c251 --- /dev/null +++ b/demos/plugins/custom_dock/plugin.cfg @@ -0,0 +1,14 @@ +[plugin] + +name="Custom Dock" +description="Adds a new Customizable Dock" +author="Juan Linietsky" +version="1.0" +script="dock_plugin.gd" + + + + + + + diff --git a/demos/plugins/custom_import_plugin/import_plugin.gd b/demos/plugins/custom_import_plugin/import_plugin.gd new file mode 100644 index 00000000000..2cf8a0302f0 --- /dev/null +++ b/demos/plugins/custom_import_plugin/import_plugin.gd @@ -0,0 +1,81 @@ +tool + +extends EditorImportPlugin + + +# Simple plugin that imports a text file with extension .mtxt +# which contains 3 integers in format R,G,B (0-255) +# (see example .mtxt in this folder) +# Imported file is converted to a material + +var dialog = null + +func get_name(): + return "silly_material" + +func get_visible_name(): + return "Silly Material" + +func import_dialog(path): + var md = null + if (path!=""): + md = ResourceLoader.load_import_metadata(path) + dialog.configure(self,path,md) + dialog.popup_centered() + +func import(path,metadata): + + assert(metadata.get_source_count() == 1) + + var source = metadata.get_source_path(0) + var use_red_anyway = metadata.get_option("use_red_anyway") + + var f = File.new() + var err = f.open(source,File.READ) + if (err!=OK): + return ERR_CANT_OPEN + + var l = f.get_line() + + f.close() + + var channels = l.split(",") + if (channels.size()!=3): + return ERR_PARSE_ERROR + + var color = Color8(int(channels[0]),int(channels[1]),int(channels[2])) + + var material + + if (ResourceLoader.has(path)): + # Material is in use, update it + material = ResourceLoader.load(path) + else: + # Material not in use, create + material = FixedMaterial.new() + + if (use_red_anyway): + color=Color8(255,0,0) + + material.set_parameter(FixedMaterial.PARAM_DIFFUSE,color) + + # Make sure import metadata links to this plugin + + metadata.set_editor("silly_material") + + # Update the import metadata + + material.set_import_metadata(metadata) + + + # Save + err = ResourceSaver.save(path,material) + + return err + + +func config(base_control): + + dialog = preload("res://addons/custom_import_plugin/material_dialog.tscn").instance() + base_control.add_child(dialog) + diff --git a/demos/plugins/custom_import_plugin/material_dialog.gd b/demos/plugins/custom_import_plugin/material_dialog.gd new file mode 100644 index 00000000000..1022743254d --- /dev/null +++ b/demos/plugins/custom_import_plugin/material_dialog.gd @@ -0,0 +1,67 @@ +tool +extends ConfirmationDialog + +var src_fs +var dst_fs +var import_plugin + +func configure(p_import_plugin,path,metadata): + import_plugin=p_import_plugin + if (metadata): + # metadata from previous import exists, fill in fields + assert( metadata.get_source_count() > 0 ) + # Always expand the source paths + var src_path = import_plugin.expand_source_path( metadata.get_source_path(0) ) + get_node("src_file").set_text(src_path) + get_node("dst_file").set_text(path) + # Fill in from metadata options + get_node("use_red_anyway").set_pressed( metadata.get_option("use_red_anyway") ) + + +func _ready(): + + src_fs = FileDialog.new() + src_fs.set_mode(FileDialog.MODE_OPEN_FILE) + src_fs.set_access(FileDialog.ACCESS_FILESYSTEM) #access all filesystem, not only res:// + src_fs.add_filter("*.mtxt") + src_fs.connect("file_selected",self,"_on_src_selected") + + add_child(src_fs) + + dst_fs = EditorFileDialog.new() + dst_fs.set_mode(EditorFileDialog.MODE_SAVE_FILE) + dst_fs.add_filter("*.mtl") # Use binary extension always, text can't save metadata + dst_fs.connect("file_selected",self,"_on_dst_selected") + + add_child(dst_fs) + + set_hide_on_ok(true) + get_ok().set_text("Import!") + + +func _on_src_browse_pressed(): + src_fs.popup_centered_ratio() + +func _on_dst_browse_pressed(): + dst_fs.popup_centered_ratio() + +func _on_src_selected(path): + get_node("src_file").set_text(path) + +func _on_dst_selected(path): + get_node("dst_file").set_text(path) + +func _on_MaterialImport_confirmed(): + # Create an import metadata + var imd = ResourceImportMetadata.new() + # Add the source files, always validate the source path + imd.add_source( import_plugin.validate_source_path( get_node("src_file").get_text() )) + # Add the options + imd.set_option( "use_red_anyway", get_node("use_red_anyway").is_pressed() ) + # Perform regular import + var err = import_plugin.import( get_node("dst_file").get_text(), imd ) + # Warn if error + if (err!=OK): + get_node("error").set_text("Error Importing!") + get_node("error").popup_centered_minsize() + diff --git a/demos/plugins/custom_import_plugin/material_dialog.tscn b/demos/plugins/custom_import_plugin/material_dialog.tscn new file mode 100644 index 00000000000..9ad6f492fd4 --- /dev/null +++ b/demos/plugins/custom_import_plugin/material_dialog.tscn @@ -0,0 +1,111 @@ +[gd_scene load_steps=2 format=1] + +[ext_resource path="res://addons/custom_import_plugin/material_dialog.gd" type="Script" id=1] + +[node name="MaterialImport" type="ConfirmationDialog"] + +margin/right = 276.0 +margin/bottom = 154.0 +focus/ignore_mouse = false +focus/stop_mouse = true +size_flags/horizontal = 2 +size_flags/vertical = 2 +popup/exclusive = false +window/title = "Silly Material Import" +dialog/hide_on_ok = true +script/script = ExtResource( 1 ) +__meta__ = { "__editor_plugin_screen__":"Script" } + +[node name="src_file" type="LineEdit" parent="."] + +margin/left = 19.0 +margin/top = 6.0 +margin/right = 190.0 +margin/bottom = 29.0 +focus/ignore_mouse = false +focus/stop_mouse = true +size_flags/horizontal = 2 +size_flags/vertical = 2 +text = "" +max_length = 0 +editable = true +secret = false + +[node name="src_browse" type="Button" parent="."] + +margin/left = 195.0 +margin/top = 7.0 +margin/right = 249.0 +margin/bottom = 29.0 +focus/ignore_mouse = false +focus/stop_mouse = true +size_flags/horizontal = 2 +size_flags/vertical = 2 +toggle_mode = false +text = "browse" +flat = false + +[node name="dst_browse" type="Button" parent="."] + +margin/left = 195.0 +margin/top = 47.0 +margin/right = 249.0 +margin/bottom = 69.0 +focus/ignore_mouse = false +focus/stop_mouse = true +size_flags/horizontal = 2 +size_flags/vertical = 2 +toggle_mode = false +text = "browse" +flat = false + +[node name="dst_file" type="LineEdit" parent="."] + +margin/left = 19.0 +margin/top = 46.0 +margin/right = 190.0 +margin/bottom = 69.0 +focus/ignore_mouse = false +focus/stop_mouse = true +size_flags/horizontal = 2 +size_flags/vertical = 2 +text = "" +max_length = 0 +editable = true +secret = false + +[node name="use_red_anyway" type="CheckBox" parent="."] + +margin/left = 20.0 +margin/top = 84.0 +margin/right = 144.0 +margin/bottom = 106.0 +focus/ignore_mouse = false +focus/stop_mouse = true +size_flags/horizontal = 2 +size_flags/vertical = 2 +toggle_mode = true +text = "Use Red Anyway" +flat = false +align = 0 + +[node name="error" type="AcceptDialog" parent="."] + +visibility/visible = false +margin/right = 40.0 +margin/bottom = 40.0 +focus/ignore_mouse = false +focus/stop_mouse = true +size_flags/horizontal = 2 +size_flags/vertical = 2 +popup/exclusive = false +window/title = "Alert!" +dialog/hide_on_ok = true + +[connection signal="confirmed" from="." to="." method="_on_MaterialImport_confirmed"] + +[connection signal="pressed" from="src_browse" to="." method="_on_src_browse_pressed"] + +[connection signal="pressed" from="dst_browse" to="." method="_on_dst_browse_pressed"] + + diff --git a/demos/plugins/custom_import_plugin/material_import.gd b/demos/plugins/custom_import_plugin/material_import.gd new file mode 100644 index 00000000000..f9859251af6 --- /dev/null +++ b/demos/plugins/custom_import_plugin/material_import.gd @@ -0,0 +1,22 @@ +tool +extends EditorPlugin + +var import_plugin + +func _enter_tree(): + + import_plugin = preload("res://addons/custom_import_plugin/import_plugin.gd").new() + + # pass the GUI base control, so the dialog has a parent node + import_plugin.config( get_base_control() ) + + add_import_plugin( import_plugin) + +func _exit_tree(): + + remove_import_plugin( import_plugin ) + + + + + \ No newline at end of file diff --git a/demos/plugins/custom_import_plugin/plugin.cfg b/demos/plugins/custom_import_plugin/plugin.cfg new file mode 100644 index 00000000000..a002ad680d2 --- /dev/null +++ b/demos/plugins/custom_import_plugin/plugin.cfg @@ -0,0 +1,14 @@ +[plugin] + +name="Silly Material Importer" +description="Imports a 3D Material from an external text file" +author="Juan Linietsky" +version="1.0" +script="material_import.gd" + + + + + + + diff --git a/demos/plugins/custom_import_plugin/test.mtxt b/demos/plugins/custom_import_plugin/test.mtxt new file mode 100644 index 00000000000..546ea2af20e --- /dev/null +++ b/demos/plugins/custom_import_plugin/test.mtxt @@ -0,0 +1 @@ +0,0,255 diff --git a/demos/plugins/custom_node/heart.gd b/demos/plugins/custom_node/heart.gd new file mode 100644 index 00000000000..d53c92d8004 --- /dev/null +++ b/demos/plugins/custom_node/heart.gd @@ -0,0 +1,12 @@ +tool +extends Node2D + + +var heart = preload("res://addons/custom_node/heart.png") + +func _draw(): + draw_texture(heart,-heart.get_size()/2) + +func _get_item_rect(): + #override + return Rect2(-heart.get_size()/2,heart.get_size()) diff --git a/demos/plugins/custom_node/heart.png b/demos/plugins/custom_node/heart.png new file mode 100644 index 00000000000..1dfd14a456e Binary files /dev/null and b/demos/plugins/custom_node/heart.png differ diff --git a/demos/plugins/custom_node/heart_icon.png b/demos/plugins/custom_node/heart_icon.png new file mode 100644 index 00000000000..2eb819aa24d Binary files /dev/null and b/demos/plugins/custom_node/heart_icon.png differ diff --git a/demos/plugins/custom_node/heart_plugin.gd b/demos/plugins/custom_node/heart_plugin.gd new file mode 100644 index 00000000000..01a6177c9bb --- /dev/null +++ b/demos/plugins/custom_node/heart_plugin.gd @@ -0,0 +1,18 @@ +tool +extends EditorPlugin + + +func _enter_tree(): + # When this plugin node enters tree, add the custom type + + add_custom_type("Heart","Node2D",preload("res://addons/custom_node/heart.gd"),preload("res://addons/custom_node/heart_icon.png")) + +func _exit_tree(): + # When the plugin node exits the tree, remove the custom type + + remove_custom_type("Heart") + + + + + \ No newline at end of file diff --git a/demos/plugins/custom_node/plugin.cfg b/demos/plugins/custom_node/plugin.cfg new file mode 100644 index 00000000000..ebb4b56499e --- /dev/null +++ b/demos/plugins/custom_node/plugin.cfg @@ -0,0 +1,14 @@ +[plugin] + +name="Heart" +description="Adds a new Heart node in 2D" +author="Juan Linietsky" +version="1.0" +script="heart_plugin.gd" + + + + + + + diff --git a/demos/plugins/readme.txt b/demos/plugins/readme.txt new file mode 100644 index 00000000000..963850dcbbc --- /dev/null +++ b/demos/plugins/readme.txt @@ -0,0 +1,13 @@ + +To install these, copy each of these folders to a folder: + +addons/ + +inside your projects, example: + +addons/custom_node + +To distribute and install from UI, make a zip that contains the folder, +example: + +zip -r custom_node.zip custom_node/* \ No newline at end of file diff --git a/doc/base/classes.xml b/doc/base/classes.xml index bfe6bfc3aed..5915805b724 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -1,5 +1,5 @@ - + Built-in GDScript functions. @@ -1476,6 +1476,8 @@ + + @@ -2227,7 +2229,7 @@ - + @@ -2258,7 +2260,7 @@ - + Set the value of an existing key. @@ -6118,7 +6120,7 @@ - + Used for editing, returns an opaque value representing the transform state. @@ -6608,7 +6610,7 @@ - + @@ -8059,7 +8061,7 @@ - + @@ -8069,7 +8071,7 @@ - + @@ -8208,7 +8210,7 @@ - + @@ -8216,7 +8218,7 @@ - + @@ -8707,7 +8709,7 @@ - + @@ -9765,6 +9767,47 @@ Returns an empty String "" at the end of the list. + + + Editor plugin to control the export process. + + + This plugin is added into EditorImportExport and allows to modify + the behavior of the export process for individual files. + + + + + + + + + + + This function is called for each file exported and + depending from the return value one of many things + might happen. + + 1) If returned value is null, the file is exported + as is. + + 2) If the returned value is a RawAray (array of + bytes), the content of that array becomes the new + file being exported. + + 3) If the file must also change it's name when + exported, then a [Dictionary] must be returned with + two fields: 'name' with the new filename and 'data' + with a [RawArray] containing the raw contents of the + file. Even if the name is changed, the run-time will + redirect the old file to the new file automatically + when accessed. + + + + + + @@ -9915,8 +9958,14 @@ Returns an empty String "" at the end of the list. + Import plugin for editor + Import plugins make it easy to handle importing of external assets + into a project. + + They way they work is not that obvious though, so please make sure + to read the documentation, tutorials and examples. @@ -9924,19 +9973,35 @@ Returns an empty String "" at the end of the list. + + + Generally, files that are imported stay the same + when exported. The only exception is in some cases + when the file must be re-imported for different + platforms (ie. texture compression). + + If you want to customize the export process, it's + recommended to use [EditorExportPlugin.custom_export] + instead. + Get the name of the import plugin, which will be + used to identify content imported by this plugin. + + Try to use lowecase and underscores if possible. + Visible name for this plugin, which will be shown on + the import menu. @@ -9944,15 +10009,70 @@ Returns an empty String "" at the end of the list. - + + Perform an import of an external resources into the + project. This function is both called on import + (from the dialog) or re-import + (manual or automatic when external source files + changed). + + An import process generally works like this: + + 1) Check the metadata for source files and options. + Metadata is either generated in the import dialog or + taken from an existing resource upon reimport. + + 2) Perform the import process into a new resource. + Some times the resource being re-imported may be already loaded + and in use, so checking for this by using + [ResourceLoader.has] is recommended. Otherwise + create a new resource. + + 3) Set the metadata from the argument into the existing or new + resource being created using + [Resource.set_import_metadata]. + + 4) Save the resource into 'path' (function argument) + This function is called when either the user chooses + to import a resource of this type (Import menu), or + when the user chooses to re-import the resource + (from filesystem). In the later case, the path for + the existing file is supplied in the argument. + + If the path is supplied, it is recommended to read + the import metadata with + [ResourceLoader.load_import_metadata] and fill in + the fields with the values contained there. + + The dialog can be shown in any way (just use a + ConfirmationDialog and pop it up). Upon + confirmation, fill up a ResourceImportMetadata and + call the [EditorImportPlugin.import] function with + this information. + + + + + + + + + + + + + + + + @@ -9961,22 +10081,52 @@ Returns an empty String "" at the end of the list. + Used by the editor to extend it's functionality. + Plugins are used by the editor to extend functionality. The most + common types of plugins are those which edit a given node or + resource type, import plugins and export plugins. + This method is called when the editor is about to + save the project, switch to another tab, etc. It + asks the plugin to apply any pending state changes + to ensure consistency. + + This is used, for example, in shader editors to let + the plugin know that it must apply the shader code + being written by the user to the object. + Clear all the state and reset the object being + edited to zero. This ensures your plugin does not + keep editing a currently existing node, or a node + fromt the wrong scene. + + + + + + + + + This is used for plugins that create gizmos used by + the spatial editor. Just check that the node passed + in the "for_spatial" argument matches your plugin. + This function is used for plugins that edit specific + object types (nodes or resources). It requests the + editor to edit the given object. @@ -9985,6 +10135,13 @@ Returns an empty String "" at the end of the list. + This is a low level function for plugins that edit a given + object type derived from CanvasItem to capture the input in the 2D editor + viewport. The function is only being called if your + object is being edited. + + Return true if you want to capture the input, + otherwise false. @@ -9995,24 +10152,45 @@ Returns an empty String "" at the end of the list. + This is a low level function for plugins that edit a + given objet type derived from Spatial to capture the + input of the viewport. The function is only being + called if your object is being edited. + + By using the [InputEvent] and the [Camera] arguments + it's pretty easy to do raycasts into space using + Camera functions. + + Return true if you want to capture the input, + otherwise false. + This is for editors that edit script based objects. + You can return a list of breakpoints in the format + (script:line), for example: res://path_to_script.gd:25 + Get the name of the editor plugin. For main scren + plugins this is what will appear in the selector + (which by default is 2D, 3D, Script). + Get the state of your plugin editor. This is used + when saving the scene (so state is kept when opening + it again) and for switching tabs (so state can be + restored when the tab returns). @@ -10021,38 +10199,102 @@ Returns an empty String "" at the end of the list. + Implement this function if your plugin edits a + specific type of object (Resource or Node). If you + return true, then you will get the functions + [EditorPlugin.edit] and [EditorPlugin.make_visible] + called when the editor requests them. + Return true if this is a main screen editor plugin + (it goes in the main screen selector together with + 2D, 3D, Script). + This function will be called when the editor is + requested to become visible. It is used for plugins + that edit a specific object type. + + Remember that you have to manage the visibility of + all your editor controls manually. + Restore the state saved by [EditorPlugin.get_state]. - - - - - - - + - + + Add a custom control to a container (see + CONTAINER_* enum). There are many locations where + custom controls can be added in the editor UI. + + Please remember that you have to manage the + visibility of your custom controls yourself (and likely + hide it after adding it). + + If your plugin is being removed, also make sure to + remove your custom controls too. + + + + + + + + + Add a control to the bottom dock (together with + Output, Debug, Animation, etc). + + Please remember that you have to manage the + visibility of your custom controls yourself (and likely + hide it after adding it). + + If your plugin is being removed, also make sure to + remove your custom controls too. + + + + + + + + + Add the control to a specific dock slot (see DOCK_* + enum for options). + + If the dock is repositioned and as long as the + plugin is active, the editor will save the dock + position on further sessions. + + If your plugin is being removed, also make sure to + remove your control by calling [method + remove_control_from_docks]. + + + + + + + + Remove the control from the dock. Don't forget to + call this if you added one, so the editor can save + the layout and remove it cleanly. @@ -10065,12 +10307,102 @@ Returns an empty String "" at the end of the list. + Add a custom type, which will appear in the list of + nodes or resources. An icon can be optionally + passed. + + When given node or resource is selected, the base + type will be instanced (ie, "Spatial", "Control", + "Resource"), then the script will be loaded and set + to this object. + + You can use the [EditorPlugin.handles] to check if + your custom object is being edited by checking the + script or using 'extends' keyword. + + During run-time, this will be a simple object with a + script so this function does not need to be called + then. + Remove a custom type added by + [EditorPlugin.add_custom_type] + + + + + + + Add an import plugin. These plugins manage importing + external content (from outside the project) into + formats the engine can understand. + + On exit, don't forget to remove the plugin by + calling [method remove_import_plugin] + + + + + + + Remove the import plugin, don't forget to call this + on exit. + + + + + + + Add an export plugin. Plugins of this kind can + change files being exported. On exit don't forget to + call [method remove_export_plugin]. + + + + + + + Remove the export plugin, don't forget to call this + on exit. + + + + + + + Get a base control where it's safe to place dialogs. + Many plugins open dialogs and they need a control as + a base to make sure they use the editor icons and + theme. + + + + + + + Get the undo/redo object. Most actions in the editor + can be undoable, so use this object to make sure + this happens when it's worth it. + + + + + + + Get the object that handles the selection of nodes + in the Scene Tree editor. + + + + + + + Get the general settings for the editor (the same + window that appears in the Settings menu). @@ -10087,18 +10419,45 @@ Returns an empty String "" at the end of the list. + + + + + + + + + + + + + + + + + + + Base script for post-processing scenes being imported. + These scripts can modify scenes after being imported by the 3D Scene + import option of the Import menu. + This function is called upon import with the + imported scene. + + Just do any changes desired to the scene and return + it. If null is returned, import will fail and throw + an error to the user. @@ -10107,8 +10466,10 @@ Returns an empty String "" at the end of the list. + Simple script to perform changes in the currently edited scene. + This script can be run from the Scene -> Run Script menu option. @@ -10131,6 +10492,300 @@ Returns an empty String "" at the end of the list. + + + Manages the SceneTree selection in the editor. + + + This object manages the SceneTree selection in the editor. + + + + + Clear the selection. + + + + + + + Add a node to the selection. + + + + + + + Remove a node from the selection. + + + + + + + Get the list of selectes nodes. + + + + + + + Emitted when the selection changes. + + + + + + + + + Object that holds the project-independent editor settings. + + + Object that holds the project-independent editor settings. These + settings are generally visible in the Editor Settings menu. + + Accessing the settings is done by using the regular [Object] API, + such as. + + settings.set(prop,value) + + settings.get(prop) + + list_of_settings = settings.get_property_list() + + + + + + + Erase a given setting (pass full property path). + + + + + + + Get the global settings path for the engine. Inside + this path you can find some standard paths such as: + + settings/tmp - used for temporary storage of files + + settings/templates - where export templates are + located + + + + + + + Get the specific project settings path. Projects all + have an unique sub-directory inside the settings + path where project specific settings are saved. + + + + + + + Set the list of favorite directories for this + project. + + + + + + + Get the list of favorite directories for this + project. + + + + + + + Set the list of recently visited folders in the file + dialog for this project. + + + + + + + Get the list of recently visited folders in the file + dialog for this project. + + + + + + + + + + + + + + + Custom gizmo for editing Spatial objects. + + + Custom gizmo that is used for providing custom visualization and + editing (handles) for 3D Spatial objects. These are created by + [method EditorPlugin.create_spatial_gizmo]. + + + + + + + + + + + Commit a handle being edited (handles must have been + prevously added by [method add_handles]). + + If the cancel parameter is true, an option to + restore the edited value to the original is + provided. + + + + + + + + + Get the name of an edited handle (handles must have + been previously added by [method add_handles]). + + Handles can be named for reference to the user when editing. + + + + + + + + + Get actual value of a handle. This value can be + anything and used for eventually undoing the motion + when calling [method commit_handle] + + + + + This function is called when the Spatial this gizmo + refers to changes (the [method Spatial.update_gizmo] + is called). + + + + + + + + + + + This function is used when the user drags a gizmo + handle (previously added with [method add_handles]) + in screen coordinates. + + The [Camera] is also provided + so screen coordinates can be converted to raycasts. + + + + + + + + + + + Add lines to the gizmo (as sets of 2 points), with a + given material. The lines are used for visualizing + the gizmo. + + Call this function during [method redraw]. + + + + + + + + + + + Add a mesh to the gizmo, this is used for + visualization. + + Call this function during [method redraw]. + + + + + + + + + + + + + Add collision triangles to the gizmo for picking. A + [TriangleMesh] can be generated from a regular + [Mesh] too. + + Call this function during [method redraw]. + + + + + + + + + Add an unscaled billboard for visualization. + + Call this function during [method redraw]. + + + + + + + + + + + Add a list of handles (points) which can be used to + deform the object being edited. + + There are virtual functions which will be called + upon editing of these handles. + + Call this function during [method redraw]. + + + + + + + Call this function once and upon creation of the + gizmo, otherwise no other function will work. + + The argument is the node being edited by the gizmo. + + + + + + @@ -10152,7 +10807,7 @@ Returns an empty String "" at the end of the list. - + @@ -10182,7 +10837,7 @@ Returns an empty String "" at the end of the list. - + @@ -10782,7 +11437,7 @@ Returns an empty String "" at the end of the list. - + @@ -10988,7 +11643,7 @@ Returns an empty String "" at the end of the list. - + Set a parameter, parameters are defined in the PARAM_* enum. The type of each parameter may change, so it's best to check the enum. @@ -11349,25 +12004,25 @@ Returns an empty String "" at the end of the list. - + - + - + - + - + - + - + - + - + - + @@ -11397,7 +12052,7 @@ Returns an empty String "" at the end of the list. - + @@ -15139,7 +15794,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + @@ -16744,7 +17399,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + @@ -17722,7 +18377,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + @@ -17770,7 +18425,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + @@ -17804,7 +18459,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + @@ -20219,7 +20874,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + Set a property. Return true if the property was found. @@ -20248,7 +20903,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + Set property into the object. @@ -20307,7 +20962,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + Set a metadata into the object. Metadata is serialized. Metadata can be [i]anything[/i]. @@ -20356,15 +21011,15 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + - + - + - + - + Emit a signal. Arguments are passed in an array. @@ -20373,25 +21028,25 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + - + - + - + - + - + - + - + - + - + Call a function in the object, result is returned. @@ -20400,15 +21055,15 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + - + - + - + - + Create and store a function in the object. The call will take place on idle time. @@ -20699,7 +21354,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + @@ -20898,7 +21553,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) - + @@ -22795,7 +23450,7 @@ This method controls whether the position between two cached points is interpola - + @@ -22995,7 +23650,7 @@ This method controls whether the position between two cached points is interpola - + @@ -23127,7 +23782,7 @@ This method controls whether the position between two cached points is interpola - + @@ -23291,7 +23946,7 @@ This method controls whether the position between two cached points is interpola - + @@ -23409,7 +24064,7 @@ This method controls whether the position between two cached points is interpola - + @@ -24328,7 +24983,7 @@ This method controls whether the position between two cached points is interpola - + @@ -24512,7 +25167,7 @@ This method controls whether the position between two cached points is interpola - + @@ -24754,7 +25409,7 @@ This method controls whether the position between two cached points is interpola - + @@ -24856,7 +25511,7 @@ This method controls whether the position between two cached points is interpola - + @@ -26149,7 +26804,7 @@ This method controls whether the position between two cached points is interpola - + @@ -26536,7 +27191,7 @@ This method controls whether the position between two cached points is interpola - + @@ -27766,7 +28421,7 @@ This method controls whether the position between two cached points is interpola - + @@ -27864,6 +28519,14 @@ This method controls whether the position between two cached points is interpola + + + + + + + + @@ -28063,7 +28726,7 @@ This method controls whether the position between two cached points is interpola - + @@ -29909,6 +30572,22 @@ This method controls whether the position between two cached points is interpola + + + + + + + + + + + + + + + + @@ -30032,7 +30711,7 @@ This method controls whether the position between two cached points is interpola - + @@ -30168,15 +30847,15 @@ This method controls whether the position between two cached points is interpola - + - + - + - + - + @@ -30628,7 +31307,7 @@ This method controls whether the position between two cached points is interpola - + @@ -31180,7 +31859,7 @@ This method controls whether the position between two cached points is interpola - + @@ -32212,6 +32891,16 @@ This method controls whether the position between two cached points is interpola + + + + + + + + + + @@ -36082,7 +36771,7 @@ This method controls whether the position between two cached points is interpola - + @@ -37704,7 +38393,7 @@ This method controls whether the position between two cached points is interpola - + @@ -38106,9 +38795,9 @@ This method controls whether the position between two cached points is interpola - + - + @@ -38128,9 +38817,9 @@ This method controls whether the position between two cached points is interpola - + - + @@ -38152,15 +38841,15 @@ This method controls whether the position between two cached points is interpola - + - + - + - + - + @@ -38174,15 +38863,15 @@ This method controls whether the position between two cached points is interpola - + - + - + - + - + @@ -38194,7 +38883,7 @@ This method controls whether the position between two cached points is interpola - + @@ -38218,7 +38907,7 @@ This method controls whether the position between two cached points is interpola - + @@ -38246,7 +38935,7 @@ This method controls whether the position between two cached points is interpola - + @@ -38270,7 +38959,7 @@ This method controls whether the position between two cached points is interpola - + @@ -38353,8 +39042,14 @@ This method controls whether the position between two cached points is interpola + Helper to manage UndoRedo in the editor or custom tools. + Helper to maange UndoRedo in the editor or custom tools. It works by + storing calls to functions in both 'do' an 'undo' lists. + + Common behavior is to create an action, then add do/undo calls to + functions or property changes, then commiting the action. @@ -38363,10 +39058,16 @@ This method controls whether the position between two cached points is interpola + Create a new action. After this is called, do all + your calls to [method add_do_method], + [method add_undo_method], [method add_do_property] + and [method add_undo_property]. + Commit the action. All 'do' methods/properties are + called/set when this function is called. @@ -38374,17 +39075,19 @@ This method controls whether the position between two cached points is interpola - + - + - + - + - + + Add a call to a method in a given object with custom + arguments. @@ -38392,17 +39095,20 @@ This method controls whether the position between two cached points is interpola - + - + - + - + - + + Add a call to an undo method in a given object with + custom arguments. Undo calls are used to revert 'do' + calls. @@ -38413,6 +39119,7 @@ This method controls whether the position between two cached points is interpola + Set a property with a custom value. @@ -38423,34 +39130,51 @@ This method controls whether the position between two cached points is interpola + Undo setting of a property with a custom value. + Add a 'do' reference that will be erased if the 'do' + history is lost. This is useful mostly for new nodes + created for the 'do' call. Do not use for resources. + Add an 'undo' reference that will be erased if the + 'undo' history is lost. This is useful mostly for + nodes rmoved with the 'do' call (not the 'undo' + call!). + Clear the undo/redo history and associated + references. + Get the name of the current action. + Get the version, each time a new action is commited, + the version number of the UndoRedo is increased + automatically. + + This is useful mostly to check if something changed + from a saved version. @@ -40175,7 +40899,7 @@ This method controls whether the position between two cached points is interpola - + diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 1b2ed670ad9..c1ee148ef30 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1481,6 +1481,11 @@ Variant GDScript::_new(const Variant** p_args,int p_argcount,Variant::CallError& /* STEP 1, CREATE */ + if (!valid) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; + return Variant(); + } + r_error.error=Variant::CallError::CALL_OK; REF ref; Object *owner=NULL; diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp index 3836fa710b6..2d0d7617c2f 100644 --- a/tools/doc/doc_data.cpp +++ b/tools/doc/doc_data.cpp @@ -190,7 +190,11 @@ void DocData::generate(bool p_basic_types) { #ifdef DEBUG_METHODS_ENABLED if (m && m->get_return_type()!=StringName()) method.return_type=m->get_return_type(); - else if (arginfo.type!=Variant::NIL) // { + else if (method.name.find(":")!=-1) { + method.return_type=method.name.get_slice(":",1); + method.name=method.name.get_slice(":",0); + + } else if (arginfo.type!=Variant::NIL) // { #endif method.return_type=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type); // } @@ -210,7 +214,7 @@ void DocData::generate(bool p_basic_types) { } else if (arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE) { type_name=arginfo.hint_string; } else if (arginfo.type==Variant::NIL) - type_name="var"; + type_name="Variant"; else type_name=Variant::get_type_name(arginfo.type); diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index 0f39d723080..23b8cad9ced 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -171,6 +171,7 @@ void CreateDialog::_update_search() { if (EditorNode::get_editor_data().get_custom_types().has(type)) { //there are custom types based on this... cool. + //print_line("there are custom types"); const Vector &ct = EditorNode::get_editor_data().get_custom_types()[type]; @@ -259,7 +260,33 @@ Object *CreateDialog::instance_selected() { TreeItem *selected = search_options->get_selected(); if (selected) { - return ObjectTypeDB::instance(selected->get_text(0)); + String custom = selected->get_metadata(0); + if (custom!=String()) { + if (EditorNode::get_editor_data().get_custom_types().has(custom)) { + + for(int i=0;iget_text(0)) { + Ref icon = EditorNode::get_editor_data().get_custom_types()[custom][i].icon; + Ref