summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/SCsub1
-rw-r--r--editor/action_map_editor.h2
-rw-r--r--editor/animation_track_editor.cpp4
-rw-r--r--editor/audio_stream_preview.cpp4
-rw-r--r--editor/audio_stream_preview.h2
-rw-r--r--editor/code_editor.cpp7
-rw-r--r--editor/code_editor.h3
-rw-r--r--editor/create_dialog.h2
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_parser.cpp1
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_parser.h2
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.h2
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_server.h2
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_types.h2
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp44
-rw-r--r--editor/debugger/editor_debugger_inspector.h1
-rw-r--r--editor/debugger/editor_debugger_node.h1
-rw-r--r--editor/debugger/editor_debugger_server.h6
-rw-r--r--editor/debugger/editor_debugger_tree.h1
-rw-r--r--editor/debugger/editor_network_profiler.h6
-rw-r--r--editor/debugger/editor_profiler.h6
-rw-r--r--editor/debugger/editor_visual_profiler.h6
-rw-r--r--editor/dependency_editor.cpp3
-rw-r--r--editor/doc_tools.cpp48
-rw-r--r--editor/doc_tools.h2
-rw-r--r--editor/editor_about.h2
-rw-r--r--editor/editor_asset_installer.cpp1
-rw-r--r--editor/editor_asset_installer.h6
-rw-r--r--editor/editor_autoload_settings.h2
-rw-r--r--editor/editor_build_profile.cpp797
-rw-r--r--editor/editor_build_profile.h173
-rw-r--r--editor/editor_command_palette.h2
-rw-r--r--editor/editor_export.h532
-rw-r--r--editor/editor_file_system.cpp9
-rw-r--r--editor/editor_file_system.h3
-rw-r--r--editor/editor_fonts.h2
-rw-r--r--editor/editor_inspector.cpp2
-rw-r--r--editor/editor_inspector.h2
-rw-r--r--editor/editor_node.cpp62
-rw-r--r--editor/editor_node.h9
-rw-r--r--editor/editor_plugin.cpp2
-rw-r--r--editor/editor_plugin.h2
-rw-r--r--editor/editor_plugin_settings.h6
-rw-r--r--editor/editor_properties.cpp324
-rw-r--r--editor/editor_properties.h52
-rw-r--r--editor/editor_properties_array_dict.cpp18
-rw-r--r--editor/editor_quick_open.cpp (renamed from editor/quick_open.cpp)4
-rw-r--r--editor/editor_quick_open.h (renamed from editor/quick_open.h)2
-rw-r--r--editor/editor_resource_picker.cpp279
-rw-r--r--editor/editor_resource_picker.h35
-rw-r--r--editor/editor_resource_preview.h6
-rw-r--r--editor/editor_run.cpp2
-rw-r--r--editor/editor_run_native.cpp2
-rw-r--r--editor/editor_scale.h1
-rw-r--r--editor/editor_sectioned_inspector.h1
-rw-r--r--editor/editor_settings.cpp5
-rw-r--r--editor/editor_settings.h2
-rw-r--r--editor/editor_themes.h2
-rw-r--r--editor/editor_vcs_interface.h2
-rw-r--r--editor/export/SCsub5
-rw-r--r--editor/export/editor_export.cpp355
-rw-r--r--editor/export/editor_export.h84
-rw-r--r--editor/export/editor_export_platform.cpp (renamed from editor/editor_export.cpp)909
-rw-r--r--editor/export/editor_export_platform.h221
-rw-r--r--editor/export/editor_export_platform_pc.cpp247
-rw-r--r--editor/export/editor_export_platform_pc.h82
-rw-r--r--editor/export/editor_export_plugin.cpp201
-rw-r--r--editor/export/editor_export_plugin.h132
-rw-r--r--editor/export/editor_export_preset.cpp221
-rw-r--r--editor/export/editor_export_preset.h145
-rw-r--r--editor/export/editor_export_shared_object.h51
-rw-r--r--editor/export/export_template_manager.cpp (renamed from editor/export_template_manager.cpp)21
-rw-r--r--editor/export/export_template_manager.h (renamed from editor/export_template_manager.h)12
-rw-r--r--editor/export/project_export.cpp (renamed from editor/project_export.cpp)20
-rw-r--r--editor/export/project_export.h (renamed from editor/project_export.h)40
-rw-r--r--editor/filesystem_dock.cpp29
-rw-r--r--editor/filesystem_dock.h2
-rw-r--r--editor/groups_editor.h2
-rw-r--r--editor/import/audio_stream_import_settings.cpp650
-rw-r--r--editor/import/audio_stream_import_settings.h (renamed from editor/plugins/audio_stream_editor_plugin.h)69
-rw-r--r--editor/import/dynamic_font_import_settings.cpp1
-rw-r--r--editor/import/editor_import_collada.h2
-rw-r--r--editor/import/editor_import_plugin.h2
-rw-r--r--editor/import/resource_importer_bitmask.h1
-rw-r--r--editor/import/resource_importer_csv_translation.h6
-rw-r--r--editor/import/resource_importer_imagefont.h6
-rw-r--r--editor/import/resource_importer_obj.h6
-rw-r--r--editor/import/resource_importer_scene.h6
-rw-r--r--editor/import/resource_importer_texture.h6
-rw-r--r--editor/import_dock.h6
-rw-r--r--editor/inspector_dock.h2
-rw-r--r--editor/plugins/animation_library_editor.h2
-rw-r--r--editor/plugins/asset_library_editor_plugin.h2
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp285
-rw-r--r--editor/plugins/bit_map_editor_plugin.h6
-rw-r--r--editor/plugins/bone_map_editor_plugin.h6
-rw-r--r--editor/plugins/camera_3d_editor_plugin.h6
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h2
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h2
-rw-r--r--editor/plugins/control_editor_plugin.h2
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.h6
-rw-r--r--editor/plugins/editor_preview_plugins.cpp2
-rw-r--r--editor/plugins/editor_preview_plugins.h7
-rw-r--r--editor/plugins/font_config_plugin.h6
-rw-r--r--editor/plugins/gdextension_export_plugin.h2
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.h6
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.h6
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp1
-rw-r--r--editor/plugins/gradient_texture_2d_editor_plugin.h6
-rw-r--r--editor/plugins/lightmap_gi_editor_plugin.h6
-rw-r--r--editor/plugins/material_editor_plugin.cpp8
-rw-r--r--editor/plugins/mesh_editor_plugin.h2
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.h6
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h6
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp9
-rw-r--r--editor/plugins/node_3d_editor_plugin.h2
-rw-r--r--editor/plugins/occluder_instance_3d_editor_plugin.h2
-rw-r--r--editor/plugins/path_3d_editor_plugin.h6
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.h6
-rw-r--r--editor/plugins/script_text_editor.cpp8
-rw-r--r--editor/plugins/shader_editor_plugin.cpp556
-rw-r--r--editor/plugins/shader_editor_plugin.h44
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.h6
-rw-r--r--editor/plugins/texture_3d_editor_plugin.h2
-rw-r--r--editor/plugins/texture_layered_editor_plugin.h2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp1
-rw-r--r--editor/plugins/tiles/tile_atlas_view.h2
-rw-r--r--editor/plugins/tiles/tile_map_editor.h2
-rw-r--r--editor/plugins/tiles/tile_set_editor.h2
-rw-r--r--editor/plugins/tiles/tile_set_scenes_collection_source_editor.h2
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.cpp10
-rw-r--r--editor/plugins/version_control_editor_plugin.h2
-rw-r--r--editor/plugins/voxel_gi_editor_plugin.h6
-rw-r--r--editor/project_settings_editor.cpp1
-rw-r--r--editor/property_editor.cpp9
-rw-r--r--editor/property_editor.h2
-rw-r--r--editor/property_selector.h6
-rw-r--r--editor/register_exporters.h2
-rw-r--r--editor/scene_tree_dock.cpp8
-rw-r--r--editor/scene_tree_dock.h2
-rw-r--r--editor/scene_tree_editor.h2
-rw-r--r--editor/shader_create_dialog.cpp227
-rw-r--r--editor/shader_create_dialog.h13
-rw-r--r--editor/shader_globals_editor.cpp8
143 files changed, 5062 insertions, 2322 deletions
diff --git a/editor/SCsub b/editor/SCsub
index a596c7d364..59508f3025 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -113,6 +113,7 @@ if env["tools"]:
env.add_source_files(env.editor_sources, "register_exporters.gen.cpp")
SConscript("debugger/SCsub")
+ SConscript("export/SCsub")
SConscript("fileserver/SCsub")
SConscript("icons/SCsub")
SConscript("import/SCsub")
diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h
index d8c40a97a7..1ca3c5bac0 100644
--- a/editor/action_map_editor.h
+++ b/editor/action_map_editor.h
@@ -209,4 +209,4 @@ public:
ActionMapEditor();
};
-#endif
+#endif // ACTION_MAP_EDITOR_H
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 703cfaee3d..234bfb944c 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -6113,7 +6113,8 @@ float AnimationTrackEditor::snap_time(float p_value, bool p_relative) {
void AnimationTrackEditor::_show_imported_anim_warning() {
// It looks terrible on a single line but the TTR extractor doesn't support line breaks yet.
- EditorNode::get_singleton()->show_warning(TTR("This animation belongs to an imported scene, so changes to imported tracks will not be saved.\n\nTo enable the ability to add custom tracks, navigate to the scene's import settings and set\n\"Animation > Storage\" to \"Files\", enable \"Animation > Keep Custom Tracks\", then re-import.\nAlternatively, use an import preset that imports animations to separate files."),
+ EditorNode::get_singleton()->show_warning(
+ TTR("This animation belongs to an imported scene, so changes to imported tracks will not be saved.\n\nTo modify this animation, navigate to the scene's Advanced Import settings and select the animation.\nSome options, including looping, are available here. To add custom tracks, enable \"Save To File\" and\n\"Keep Custom Tracks\"."),
TTR("Warning: Editing imported animation"));
}
@@ -6299,6 +6300,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
imported_anim_warning = memnew(Button);
imported_anim_warning->hide();
+ imported_anim_warning->set_text(TTR("Imported Scene"));
imported_anim_warning->set_tooltip(TTR("Warning: Editing imported animation"));
imported_anim_warning->connect("pressed", callable_mp(this, &AnimationTrackEditor::_show_imported_anim_warning));
bottom_hb->add_child(imported_anim_warning);
diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp
index bea95d873e..fc47e1ef5c 100644
--- a/editor/audio_stream_preview.cpp
+++ b/editor/audio_stream_preview.cpp
@@ -153,6 +153,8 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) {
singleton->call_deferred(SNAME("_update_emit"), preview->id);
}
+ preview->preview->version++;
+
preview->playback->stop();
preview->generating.clear();
@@ -171,7 +173,7 @@ Ref<AudioStreamPreview> AudioStreamPreviewGenerator::generate_preview(const Ref<
Preview *preview = &previews[p_stream->get_instance_id()];
preview->base_stream = p_stream;
- preview->playback = preview->base_stream->instance_playback();
+ preview->playback = preview->base_stream->instantiate_playback();
preview->generating.set();
preview->id = p_stream->get_instance_id();
diff --git a/editor/audio_stream_preview.h b/editor/audio_stream_preview.h
index 307dd93b34..0e3c8f70d2 100644
--- a/editor/audio_stream_preview.h
+++ b/editor/audio_stream_preview.h
@@ -43,8 +43,10 @@ class AudioStreamPreview : public RefCounted {
float length;
friend class AudioStreamPreviewGenerator;
+ uint64_t version = 1;
public:
+ uint64_t get_version() const { return version; }
float get_length() const;
float get_max(float p_time, float p_time_next) const;
float get_min(float p_time, float p_time_next) const;
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 3a0edf301d..99ca82b311 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -824,12 +824,15 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
if (k->is_pressed()) {
if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) {
_zoom_in();
+ accept_event();
}
if (ED_IS_SHORTCUT("script_editor/zoom_out", p_event)) {
_zoom_out();
+ accept_event();
}
if (ED_IS_SHORTCUT("script_editor/reset_zoom", p_event)) {
_reset_zoom();
+ accept_event();
}
}
}
@@ -1594,6 +1597,10 @@ void CodeTextEditor::set_error_pos(int p_line, int p_column) {
error_column = p_column;
}
+Point2i CodeTextEditor::get_error_pos() const {
+ return Point2i(error_line, error_column);
+}
+
void CodeTextEditor::goto_error() {
if (!error->get_text().is_empty()) {
if (text_editor->get_line_count() != error_line) {
diff --git a/editor/code_editor.h b/editor/code_editor.h
index e2441cec2b..49679cc700 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -253,13 +253,14 @@ public:
void update_editor_settings();
void set_error(const String &p_error);
void set_error_pos(int p_line, int p_column);
+ Point2i get_error_pos() const;
void update_line_and_column() { _line_col_changed(); }
CodeEdit *get_text_editor() { return text_editor; }
FindReplaceBar *get_find_replace_bar() { return find_replace_bar; }
void set_find_replace_bar(FindReplaceBar *p_bar);
void remove_find_replace_bar();
virtual void apply_code() {}
- void goto_error();
+ virtual void goto_error();
void toggle_bookmark();
void goto_next_bookmark();
diff --git a/editor/create_dialog.h b/editor/create_dialog.h
index dc8618a1c0..04094108ad 100644
--- a/editor/create_dialog.h
+++ b/editor/create_dialog.h
@@ -125,4 +125,4 @@ public:
CreateDialog();
};
-#endif
+#endif // CREATE_DIALOG_H
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
index 0caeb90108..3c3e4faa6f 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
@@ -34,6 +34,7 @@
#include "editor/debugger/script_editor_debugger.h"
#include "editor/editor_node.h"
#include "editor/editor_run_native.h"
+#include "editor/export/editor_export_platform.h"
#include "editor/plugins/script_editor_plugin.h"
void DebugAdapterParser::_bind_methods() {
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.h b/editor/debugger/debug_adapter/debug_adapter_parser.h
index f458151e17..ee32306146 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.h
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.h
@@ -93,4 +93,4 @@ public:
Dictionary ev_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled) const;
};
-#endif
+#endif // DEBUG_ADAPTER_PARSER_H
diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h
index a17e550dfc..29f577ef97 100644
--- a/editor/debugger/debug_adapter/debug_adapter_protocol.h
+++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h
@@ -152,4 +152,4 @@ public:
~DebugAdapterProtocol();
};
-#endif
+#endif // DEBUG_ADAPTER_PROTOCOL_H
diff --git a/editor/debugger/debug_adapter/debug_adapter_server.h b/editor/debugger/debug_adapter/debug_adapter_server.h
index a2b01f92c6..633739eaae 100644
--- a/editor/debugger/debug_adapter/debug_adapter_server.h
+++ b/editor/debugger/debug_adapter/debug_adapter_server.h
@@ -54,4 +54,4 @@ public:
void stop();
};
-#endif
+#endif // DEBUG_ADAPTER_SERVER_H
diff --git a/editor/debugger/debug_adapter/debug_adapter_types.h b/editor/debugger/debug_adapter/debug_adapter_types.h
index fd66905f9b..eb10184ab3 100644
--- a/editor/debugger/debug_adapter/debug_adapter_types.h
+++ b/editor/debugger/debug_adapter/debug_adapter_types.h
@@ -278,4 +278,4 @@ struct Variable {
} // namespace DAP
-#endif
+#endif // DEBUG_ADAPTER_TYPES_H
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index 0e3d424a4b..58206efc20 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -126,25 +126,25 @@ void EditorDebuggerInspector::_object_selected(ObjectID p_object) {
}
ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
- EditorDebuggerRemoteObject *debugObj = nullptr;
+ EditorDebuggerRemoteObject *debug_obj = nullptr;
SceneDebuggerObject obj;
obj.deserialize(p_arr);
ERR_FAIL_COND_V(obj.id.is_null(), ObjectID());
if (remote_objects.has(obj.id)) {
- debugObj = remote_objects[obj.id];
+ debug_obj = remote_objects[obj.id];
} else {
- debugObj = memnew(EditorDebuggerRemoteObject);
- debugObj->remote_object_id = obj.id;
- debugObj->type_name = obj.class_name;
- remote_objects[obj.id] = debugObj;
- debugObj->connect("value_edited", callable_mp(this, &EditorDebuggerInspector::_object_edited));
+ debug_obj = memnew(EditorDebuggerRemoteObject);
+ debug_obj->remote_object_id = obj.id;
+ debug_obj->type_name = obj.class_name;
+ remote_objects[obj.id] = debug_obj;
+ debug_obj->connect("value_edited", callable_mp(this, &EditorDebuggerInspector::_object_edited));
}
- int old_prop_size = debugObj->prop_list.size();
+ int old_prop_size = debug_obj->prop_list.size();
- debugObj->prop_list.clear();
+ debug_obj->prop_list.clear();
int new_props_added = 0;
HashSet<String> changed;
for (int i = 0; i < obj.properties.size(); i++) {
@@ -165,12 +165,14 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
var = ResourceLoader::load(path);
if (pinfo.hint_string == "Script") {
- if (debugObj->get_script() != var) {
- debugObj->set_script(Ref<RefCounted>());
+ if (debug_obj->get_script() != var) {
+ debug_obj->set_script(Ref<RefCounted>());
Ref<Script> script(var);
if (!script.is_null()) {
- ScriptInstance *script_instance = script->placeholder_instance_create(debugObj);
- debugObj->set_script_and_instance(var, script_instance);
+ ScriptInstance *script_instance = script->placeholder_instance_create(debug_obj);
+ if (script_instance) {
+ debug_obj->set_script_and_instance(var, script_instance);
+ }
}
}
}
@@ -178,27 +180,27 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
}
//always add the property, since props may have been added or removed
- debugObj->prop_list.push_back(pinfo);
+ debug_obj->prop_list.push_back(pinfo);
- if (!debugObj->prop_values.has(pinfo.name)) {
+ if (!debug_obj->prop_values.has(pinfo.name)) {
new_props_added++;
- debugObj->prop_values[pinfo.name] = var;
+ debug_obj->prop_values[pinfo.name] = var;
} else {
- if (bool(Variant::evaluate(Variant::OP_NOT_EQUAL, debugObj->prop_values[pinfo.name], var))) {
- debugObj->prop_values[pinfo.name] = var;
+ if (bool(Variant::evaluate(Variant::OP_NOT_EQUAL, debug_obj->prop_values[pinfo.name], var))) {
+ debug_obj->prop_values[pinfo.name] = var;
changed.insert(pinfo.name);
}
}
}
- if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) {
+ if (old_prop_size == debug_obj->prop_list.size() && new_props_added == 0) {
//only some may have changed, if so, then update those, if exist
for (const String &E : changed) {
- emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E);
+ emit_signal(SNAME("object_property_updated"), debug_obj->remote_object_id, E);
}
} else {
//full update, because props were added or removed
- debugObj->update();
+ debug_obj->update();
}
return obj.id;
}
diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h
index 0e73928558..5aac4dbf11 100644
--- a/editor/debugger/editor_debugger_inspector.h
+++ b/editor/debugger/editor_debugger_inspector.h
@@ -30,6 +30,7 @@
#ifndef EDITOR_DEBUGGER_INSPECTOR_H
#define EDITOR_DEBUGGER_INSPECTOR_H
+
#include "editor/editor_inspector.h"
class EditorDebuggerRemoteObject : public Object {
diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h
index d50cbec291..4c9ad49ac4 100644
--- a/editor/debugger/editor_debugger_node.h
+++ b/editor/debugger/editor_debugger_node.h
@@ -205,4 +205,5 @@ public:
void add_debugger_plugin(const Ref<Script> &p_script);
void remove_debugger_plugin(const Ref<Script> &p_script);
};
+
#endif // EDITOR_DEBUGGER_NODE_H
diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h
index adf9a27c71..f3805f54d8 100644
--- a/editor/debugger/editor_debugger_server.h
+++ b/editor/debugger/editor_debugger_server.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITOR_DEBUGGER_CONNECTION_H
-#define EDITOR_DEBUGGER_CONNECTION_H
+#ifndef EDITOR_DEBUGGER_SERVER_H
+#define EDITOR_DEBUGGER_SERVER_H
#include "core/debugger/remote_debugger_peer.h"
#include "core/object/ref_counted.h"
@@ -57,4 +57,4 @@ public:
virtual Ref<RemoteDebuggerPeer> take_connection() = 0;
};
-#endif // EDITOR_DEBUGGER_CONNECTION_H
+#endif // EDITOR_DEBUGGER_SERVER_H
diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h
index bba524039e..9d163fd548 100644
--- a/editor/debugger/editor_debugger_tree.h
+++ b/editor/debugger/editor_debugger_tree.h
@@ -71,4 +71,5 @@ public:
void update_scene_tree(const SceneDebuggerTree *p_tree, int p_debugger);
EditorDebuggerTree();
};
+
#endif // EDITOR_DEBUGGER_TREE_H
diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h
index d2e70a083d..aea7ce3eec 100644
--- a/editor/debugger/editor_network_profiler.h
+++ b/editor/debugger/editor_network_profiler.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITORNETWORKPROFILER_H
-#define EDITORNETWORKPROFILER_H
+#ifndef EDITOR_NETWORK_PROFILER_H
+#define EDITOR_NETWORK_PROFILER_H
#include "scene/debugger/scene_debugger.h"
#include "scene/gui/box_container.h"
@@ -69,4 +69,4 @@ public:
EditorNetworkProfiler();
};
-#endif //EDITORNETWORKPROFILER_H
+#endif // EDITOR_NETWORK_PROFILER_H
diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h
index cb01a1819f..df92125258 100644
--- a/editor/debugger/editor_profiler.h
+++ b/editor/debugger/editor_profiler.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITORPROFILER_H
-#define EDITORPROFILER_H
+#ifndef EDITOR_PROFILER_H
+#define EDITOR_PROFILER_H
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
@@ -165,4 +165,4 @@ public:
EditorProfiler();
};
-#endif // EDITORPROFILER_H
+#endif // EDITOR_PROFILER_H
diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h
index 4e5169da9e..8aa9e7b308 100644
--- a/editor/debugger/editor_visual_profiler.h
+++ b/editor/debugger/editor_visual_profiler.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITOR_FRAME_PROFILER_H
-#define EDITOR_FRAME_PROFILER_H
+#ifndef EDITOR_VISUAL_PROFILER_H
+#define EDITOR_VISUAL_PROFILER_H
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
@@ -144,4 +144,4 @@ public:
EditorVisualProfiler();
};
-#endif // EDITOR_FRAME_PROFILER_H
+#endif // EDITOR_VISUAL_PROFILER_H
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index aa03b7e252..4f89e1b2d1 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -58,6 +58,9 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button, M
search->set_title(TTR("Search Replacement For:") + " " + replacing.get_file());
+ // Set directory to closest existing directory.
+ search->set_current_dir(replacing.get_base_dir());
+
search->clear_filters();
List<String> ext;
ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0), &ext);
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index a6c7970264..773fcc5017 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -498,53 +498,7 @@ void DocTools::generate(bool p_basic_types) {
}
DocData::MethodDoc method;
-
- method.name = E.name;
-
- if (E.flags & METHOD_FLAG_VIRTUAL) {
- method.qualifiers = "virtual";
- }
-
- if (E.flags & METHOD_FLAG_CONST) {
- if (!method.qualifiers.is_empty()) {
- method.qualifiers += " ";
- }
- method.qualifiers += "const";
- }
-
- if (E.flags & METHOD_FLAG_VARARG) {
- if (!method.qualifiers.is_empty()) {
- method.qualifiers += " ";
- }
- method.qualifiers += "vararg";
- }
-
- if (E.flags & METHOD_FLAG_STATIC) {
- if (!method.qualifiers.is_empty()) {
- method.qualifiers += " ";
- }
- method.qualifiers += "static";
- }
-
- for (int i = -1; i < E.arguments.size(); i++) {
- if (i == -1) {
-#ifdef DEBUG_METHODS_ENABLED
- DocData::return_doc_from_retinfo(method, E.return_val);
-#endif
- } else {
- const PropertyInfo &arginfo = E.arguments[i];
- DocData::ArgumentDoc argument;
- DocData::argument_doc_from_arginfo(argument, arginfo);
-
- int darg_idx = i - (E.arguments.size() - E.default_arguments.size());
- if (darg_idx >= 0) {
- Variant default_arg = E.default_arguments[darg_idx];
- argument.default_value = default_arg.get_construct_string().replace("\n", " ");
- }
-
- method.arguments.push_back(argument);
- }
- }
+ DocData::method_doc_from_methodinfo(method, E, "");
Vector<Error> errs = ClassDB::get_method_error_return_values(name, E.name);
if (errs.size()) {
diff --git a/editor/doc_tools.h b/editor/doc_tools.h
index 843cdf87a6..b3e45c6472 100644
--- a/editor/doc_tools.h
+++ b/editor/doc_tools.h
@@ -53,4 +53,4 @@ public:
Error load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size);
};
-#endif // DOC_DATA_H
+#endif // DOC_TOOLS_H
diff --git a/editor/editor_about.h b/editor/editor_about.h
index 6f05700582..971843f6d2 100644
--- a/editor/editor_about.h
+++ b/editor/editor_about.h
@@ -75,4 +75,4 @@ public:
~EditorAbout();
};
-#endif
+#endif // EDITOR_ABOUT_H
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index 3d4bee4b4e..8fa486408e 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -112,6 +112,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
extension_guess["glb"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
extension_guess["gdshader"] = tree->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"));
+ extension_guess["gdshaderinc"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
extension_guess["gd"] = tree->get_theme_icon(SNAME("GDScript"), SNAME("EditorIcons"));
if (Engine::get_singleton()->has_singleton("GodotSharp")) {
extension_guess["cs"] = tree->get_theme_icon(SNAME("CSharpScript"), SNAME("EditorIcons"));
diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h
index c44f4c5d22..9c88116336 100644
--- a/editor/editor_asset_installer.h
+++ b/editor/editor_asset_installer.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITORASSETINSTALLER_H
-#define EDITORASSETINSTALLER_H
+#ifndef EDITOR_ASSET_INSTALLER_H
+#define EDITOR_ASSET_INSTALLER_H
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
@@ -59,4 +59,4 @@ public:
EditorAssetInstaller();
};
-#endif // EDITORASSETINSTALLER_H
+#endif // EDITOR_ASSET_INSTALLER_H
diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h
index e1e0bb0a64..0eda7016d3 100644
--- a/editor/editor_autoload_settings.h
+++ b/editor/editor_autoload_settings.h
@@ -112,4 +112,4 @@ public:
~EditorAutoloadSettings();
};
-#endif
+#endif // EDITOR_AUTOLOAD_SETTINGS_H
diff --git a/editor/editor_build_profile.cpp b/editor/editor_build_profile.cpp
new file mode 100644
index 0000000000..6a5604290f
--- /dev/null
+++ b/editor/editor_build_profile.cpp
@@ -0,0 +1,797 @@
+/*************************************************************************/
+/* editor_build_profile.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_build_profile.h"
+
+#include "core/io/dir_access.h"
+#include "core/io/json.h"
+#include "editor/editor_file_dialog.h"
+#include "editor/editor_file_system.h"
+#include "editor/editor_node.h"
+#include "editor/editor_property_name_processor.h"
+#include "editor/editor_scale.h"
+#include "editor/editor_settings.h"
+
+const char *EditorBuildProfile::build_option_identifiers[BUILD_OPTION_MAX] = {
+ // This maps to SCons build options.
+ "disable_3d",
+ "disable_2d_physics",
+ "disable_3d_physics",
+ "disable_navigation",
+ "openxr",
+ "opengl3",
+ "vulkan",
+};
+
+const bool EditorBuildProfile::build_option_disable_values[BUILD_OPTION_MAX] = {
+ // This maps to SCons build options.
+ true,
+ true,
+ true,
+ true,
+ false,
+ false,
+ false
+};
+
+void EditorBuildProfile::set_disable_class(const StringName &p_class, bool p_disabled) {
+ if (p_disabled) {
+ disabled_classes.insert(p_class);
+ } else {
+ disabled_classes.erase(p_class);
+ }
+}
+
+bool EditorBuildProfile::is_class_disabled(const StringName &p_class) const {
+ if (p_class == StringName()) {
+ return false;
+ }
+ return disabled_classes.has(p_class) || is_class_disabled(ClassDB::get_parent_class_nocheck(p_class));
+}
+
+void EditorBuildProfile::set_item_collapsed(const StringName &p_class, bool p_collapsed) {
+ if (p_collapsed) {
+ collapsed_classes.insert(p_class);
+ } else {
+ collapsed_classes.erase(p_class);
+ }
+}
+
+bool EditorBuildProfile::is_item_collapsed(const StringName &p_class) const {
+ return collapsed_classes.has(p_class);
+}
+
+void EditorBuildProfile::set_disable_build_option(BuildOption p_build_option, bool p_disable) {
+ ERR_FAIL_INDEX(p_build_option, BUILD_OPTION_MAX);
+ build_options_disabled[p_build_option] = p_disable;
+}
+
+void EditorBuildProfile::clear_disabled_classes() {
+ disabled_classes.clear();
+ collapsed_classes.clear();
+}
+
+bool EditorBuildProfile::is_build_option_disabled(BuildOption p_build_option) const {
+ ERR_FAIL_INDEX_V(p_build_option, BUILD_OPTION_MAX, false);
+ return build_options_disabled[p_build_option];
+}
+
+bool EditorBuildProfile::get_build_option_disable_value(BuildOption p_build_option) {
+ ERR_FAIL_INDEX_V(p_build_option, BUILD_OPTION_MAX, false);
+ return build_option_disable_values[p_build_option];
+}
+
+void EditorBuildProfile::set_force_detect_classes(const String &p_classes) {
+ force_detect_classes = p_classes;
+}
+
+String EditorBuildProfile::get_force_detect_classes() const {
+ return force_detect_classes;
+}
+
+String EditorBuildProfile::get_build_option_name(BuildOption p_build_option) {
+ ERR_FAIL_INDEX_V(p_build_option, BUILD_OPTION_MAX, String());
+ const char *build_option_names[BUILD_OPTION_MAX] = {
+ TTRC("3D Engine"),
+ TTRC("2D Physics"),
+ TTRC("3D Physics"),
+ TTRC("Navigation"),
+ TTRC("XR"),
+ TTRC("RenderingDevice"),
+ TTRC("OpenGL"),
+ TTRC("Vulkan"),
+ };
+ return TTRGET(build_option_names[p_build_option]);
+}
+
+String EditorBuildProfile::get_build_option_description(BuildOption p_build_option) {
+ ERR_FAIL_INDEX_V(p_build_option, BUILD_OPTION_MAX, String());
+
+ const char *build_option_descriptions[BUILD_OPTION_MAX] = {
+ TTRC("3D Nodes as well as RenderingServer access to 3D features."),
+ TTRC("2D Physics nodes and PhysicsServer2D."),
+ TTRC("3D Physics nodes and PhysicsServer3D."),
+ TTRC("Navigation, both 2D and 3D."),
+ TTRC("XR (AR and VR)."),
+ TTRC("RenderingDevice based rendering (if disabled, the OpenGL back-end is required)."),
+ TTRC("OpenGL back-end (if disabled, the RenderingDevice back-end is required)."),
+ TTRC("Vulkan back-end of RenderingDevice."),
+ };
+
+ return TTRGET(build_option_descriptions[p_build_option]);
+}
+
+Error EditorBuildProfile::save_to_file(const String &p_path) {
+ Dictionary data;
+ data["type"] = "build_profile";
+ Array dis_classes;
+ for (const StringName &E : disabled_classes) {
+ dis_classes.push_back(String(E));
+ }
+ dis_classes.sort();
+ data["disabled_classes"] = dis_classes;
+
+ Dictionary dis_build_options;
+ for (int i = 0; i < BUILD_OPTION_MAX; i++) {
+ if (build_options_disabled[i]) {
+ dis_build_options[build_option_identifiers[i]] = build_option_disable_values[i];
+ }
+ }
+
+ data["disabled_build_options"] = dis_build_options;
+
+ if (!force_detect_classes.is_empty()) {
+ data["force_detect_classes"] = force_detect_classes;
+ }
+
+ Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_CREATE, "Cannot create file '" + p_path + "'.");
+
+ JSON json;
+ String text = json.stringify(data, "\t");
+ f->store_string(text);
+ return OK;
+}
+
+Error EditorBuildProfile::load_from_file(const String &p_path) {
+ Error err;
+ String text = FileAccess::get_file_as_string(p_path, &err);
+ if (err != OK) {
+ return err;
+ }
+
+ JSON json;
+ err = json.parse(text);
+ if (err != OK) {
+ ERR_PRINT("Error parsing '" + p_path + "' on line " + itos(json.get_error_line()) + ": " + json.get_error_message());
+ return ERR_PARSE_ERROR;
+ }
+
+ Dictionary data = json.get_data();
+
+ if (!data.has("type") || String(data["type"]) != "build_profile") {
+ ERR_PRINT("Error parsing '" + p_path + "', it's not a build profile.");
+ return ERR_PARSE_ERROR;
+ }
+
+ disabled_classes.clear();
+
+ if (data.has("disabled_classes")) {
+ Array disabled_classes_arr = data["disabled_classes"];
+ for (int i = 0; i < disabled_classes_arr.size(); i++) {
+ disabled_classes.insert(disabled_classes_arr[i]);
+ }
+ }
+
+ for (int i = 0; i < BUILD_OPTION_MAX; i++) {
+ build_options_disabled[i] = false;
+ }
+
+ if (data.has("disabled_build_options")) {
+ Dictionary disabled_build_options_arr = data["disabled_build_options"];
+ List<Variant> keys;
+ disabled_build_options_arr.get_key_list(&keys);
+
+ for (const Variant &K : keys) {
+ String key = K;
+
+ for (int i = 0; i < BUILD_OPTION_MAX; i++) {
+ String f = build_option_identifiers[i];
+ if (f == key) {
+ build_options_disabled[i] = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (data.has("force_detect_classes")) {
+ force_detect_classes = data["force_detect_classes"];
+ }
+
+ return OK;
+}
+
+void EditorBuildProfile::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_disable_class", "class_name", "disable"), &EditorBuildProfile::set_disable_class);
+ ClassDB::bind_method(D_METHOD("is_class_disabled", "class_name"), &EditorBuildProfile::is_class_disabled);
+
+ ClassDB::bind_method(D_METHOD("set_disable_build_option", "build_option", "disable"), &EditorBuildProfile::set_disable_build_option);
+ ClassDB::bind_method(D_METHOD("is_build_option_disabled", "build_option"), &EditorBuildProfile::is_build_option_disabled);
+
+ ClassDB::bind_method(D_METHOD("get_build_option_name", "build_option"), &EditorBuildProfile::_get_build_option_name);
+
+ ClassDB::bind_method(D_METHOD("save_to_file", "path"), &EditorBuildProfile::save_to_file);
+ ClassDB::bind_method(D_METHOD("load_from_file", "path"), &EditorBuildProfile::load_from_file);
+
+ BIND_ENUM_CONSTANT(BUILD_OPTION_3D);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_PHYSICS_2D);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_PHYSICS_3D);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_NAVIGATION);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_XR);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_RENDERING_DEVICE);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_OPENGL);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_VULKAN);
+ BIND_ENUM_CONSTANT(BUILD_OPTION_MAX);
+}
+
+EditorBuildProfile::EditorBuildProfile() {}
+
+//////////////////////////
+
+void EditorBuildProfileManager::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ String last_file = EditorSettings::get_singleton()->get_project_metadata("build_profile", "last_file_path", "");
+ if (!last_file.is_empty()) {
+ _import_profile(last_file);
+ }
+ if (edited.is_null()) {
+ edited.instantiate();
+ _update_edited_profile();
+ }
+
+ } break;
+ }
+}
+
+void EditorBuildProfileManager::_profile_action(int p_action) {
+ last_action = Action(p_action);
+
+ switch (p_action) {
+ case ACTION_RESET: {
+ confirm_dialog->set_text("Reset the edited profile?");
+ confirm_dialog->popup_centered();
+ } break;
+ case ACTION_LOAD: {
+ import_profile->popup_file_dialog();
+ } break;
+ case ACTION_SAVE: {
+ if (!profile_path->get_text().is_empty()) {
+ Error err = edited->save_to_file(profile_path->get_text());
+ if (err != OK) {
+ EditorNode::get_singleton()->show_warning(TTR("File saving failed."));
+ }
+ break;
+ }
+ [[fallthrough]];
+ }
+ case ACTION_SAVE_AS: {
+ export_profile->popup_file_dialog();
+ export_profile->set_current_file(profile_path->get_text());
+ } break;
+ case ACTION_NEW: {
+ confirm_dialog->set_text("Create a new profile?");
+ confirm_dialog->popup_centered();
+ } break;
+ case ACTION_DETECT: {
+ confirm_dialog->set_text("This will scan all files in the current project to detect used classes.");
+ confirm_dialog->popup_centered();
+ } break;
+ case ACTION_MAX: {
+ } break;
+ }
+}
+
+void EditorBuildProfileManager::_find_files(EditorFileSystemDirectory *p_dir, const HashMap<String, DetectedFile> &p_cache, HashMap<String, DetectedFile> &r_detected) {
+ if (p_dir == nullptr) {
+ return;
+ }
+
+ for (int i = 0; i < p_dir->get_file_count(); i++) {
+ String p = p_dir->get_file_path(i);
+
+ uint64_t timestamp = 0;
+ String md5;
+
+ if (p_cache.has(p)) {
+ const DetectedFile &cache = p_cache[p];
+ // Check if timestamp and MD5 match.
+ timestamp = FileAccess::get_modified_time(p);
+ bool cache_valid = true;
+ if (cache.timestamp != timestamp) {
+ md5 = FileAccess::get_md5(p);
+ if (md5 != cache.md5) {
+ cache_valid = false;
+ }
+ }
+
+ if (cache_valid) {
+ r_detected.insert(p, cache);
+ continue;
+ }
+ }
+
+ // Not cached, or cache invalid.
+
+ DetectedFile cache;
+
+ HashSet<StringName> classes;
+ ResourceLoader::get_classes_used(p, &classes);
+
+ for (const StringName &E : classes) {
+ cache.classes.push_back(E);
+ }
+
+ if (md5.is_empty()) {
+ cache.timestamp = FileAccess::get_modified_time(p);
+ cache.md5 = FileAccess::get_md5(p);
+ } else {
+ cache.timestamp = timestamp;
+ cache.md5 = md5;
+ }
+
+ r_detected.insert(p, cache);
+ }
+
+ for (int i = 0; i < p_dir->get_subdir_count(); i++) {
+ _find_files(p_dir->get_subdir(i), p_cache, r_detected);
+ }
+}
+
+void EditorBuildProfileManager::_detect_classes() {
+ HashMap<String, DetectedFile> previous_file_cache;
+
+ Ref<FileAccess> f = FileAccess::open("res://.godot/editor/used_class_cache", FileAccess::READ);
+ if (f.is_valid()) {
+ while (!f->eof_reached()) {
+ String l = f->get_line();
+ Vector<String> fields = l.split("::");
+ if (fields.size() == 4) {
+ String path = fields[0];
+ DetectedFile df;
+ df.timestamp = fields[1].to_int();
+ df.md5 = fields[2];
+ df.classes = fields[3].split(",");
+ previous_file_cache.insert(path, df);
+ }
+ }
+ f.unref();
+ }
+
+ HashMap<String, DetectedFile> updated_file_cache;
+
+ _find_files(EditorFileSystem::get_singleton()->get_filesystem(), previous_file_cache, updated_file_cache);
+
+ HashSet<StringName> used_classes;
+
+ // Find classes and update the disk cache in the process.
+ f = FileAccess::open("res://.godot/editor/used_class_cache", FileAccess::WRITE);
+
+ for (const KeyValue<String, DetectedFile> &E : updated_file_cache) {
+ String l = E.key + "::" + itos(E.value.timestamp) + "::" + E.value.md5 + "::";
+ for (int i = 0; i < E.value.classes.size(); i++) {
+ String c = E.value.classes[i];
+ if (i > 0) {
+ l += ",";
+ }
+ l += c;
+ used_classes.insert(c);
+ }
+ f->store_line(l);
+ }
+
+ f.unref();
+
+ // Add forced ones.
+
+ Vector<String> force_detect = edited->get_force_detect_classes().split(",");
+ for (int i = 0; i < force_detect.size(); i++) {
+ String c = force_detect[i].strip_edges();
+ if (c.is_empty()) {
+ continue;
+ }
+ used_classes.insert(c);
+ }
+
+ // Filter all classes to discard inherited ones.
+
+ HashSet<StringName> all_used_classes;
+
+ for (const StringName &E : used_classes) {
+ StringName c = E;
+ if (!ClassDB::class_exists(c)) {
+ // Maybe this is an old class that got replaced? try getting compat class.
+ c = ClassDB::get_compatibility_class(c);
+ if (!c) {
+ // No luck, skip.
+ continue;
+ }
+ }
+ while (c) {
+ all_used_classes.insert(c);
+ c = ClassDB::get_parent_class(c);
+ }
+ }
+
+ edited->clear_disabled_classes();
+
+ List<StringName> all_classes;
+ ClassDB::get_class_list(&all_classes);
+
+ for (const StringName &E : all_classes) {
+ if (all_used_classes.has(E)) {
+ // This class is valid, do nothing.
+ continue;
+ }
+
+ StringName p = ClassDB::get_parent_class(E);
+ if (!p || all_used_classes.has(p)) {
+ // If no parent, or if the parent is enabled, then add to disabled classes.
+ // This way we avoid disabling redundant classes.
+ edited->set_disable_class(E, true);
+ }
+ }
+}
+
+void EditorBuildProfileManager::_action_confirm() {
+ switch (last_action) {
+ case ACTION_RESET: {
+ edited.instantiate();
+ _update_edited_profile();
+ } break;
+ case ACTION_LOAD: {
+ } break;
+ case ACTION_SAVE: {
+ } break;
+ case ACTION_SAVE_AS: {
+ } break;
+ case ACTION_NEW: {
+ profile_path->set_text("");
+ edited.instantiate();
+ _update_edited_profile();
+ } break;
+ case ACTION_DETECT: {
+ _detect_classes();
+ _update_edited_profile();
+ } break;
+ case ACTION_MAX: {
+ } break;
+ }
+}
+
+void EditorBuildProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected) {
+ TreeItem *class_item = class_list->create_item(p_parent);
+ class_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ class_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_class, "Node"));
+ String text = p_class;
+
+ bool disabled = edited->is_class_disabled(p_class);
+ if (disabled) {
+ class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
+ }
+
+ class_item->set_text(0, text);
+ class_item->set_editable(0, true);
+ class_item->set_selectable(0, true);
+ class_item->set_metadata(0, p_class);
+
+ bool collapsed = edited->is_item_collapsed(p_class);
+ class_item->set_collapsed(collapsed);
+
+ if (p_class == p_selected) {
+ class_item->select(0);
+ }
+ if (disabled) {
+ // Class disabled, do nothing else (do not show further).
+ return;
+ }
+
+ class_item->set_checked(0, true); // If it's not disabled, its checked.
+
+ List<StringName> child_classes;
+ ClassDB::get_direct_inheriters_from_class(p_class, &child_classes);
+ child_classes.sort_custom<StringName::AlphCompare>();
+
+ for (const StringName &name : child_classes) {
+ if (String(name).begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) {
+ continue;
+ }
+ _fill_classes_from(class_item, name, p_selected);
+ }
+}
+
+void EditorBuildProfileManager::_class_list_item_selected() {
+ if (updating_build_options) {
+ return;
+ }
+
+ TreeItem *item = class_list->get_selected();
+ if (!item) {
+ return;
+ }
+
+ Variant md = item->get_metadata(0);
+ if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) {
+ String class_name = md;
+ String class_description;
+
+ DocTools *dd = EditorHelp::get_doc_data();
+ HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(class_name);
+ if (E) {
+ class_description = DTR(E->value.brief_description);
+ }
+
+ description_bit->set_text(class_description);
+ } else if (md.get_type() == Variant::INT) {
+ int build_option_id = md;
+ String build_option_description = EditorBuildProfile::get_build_option_description(EditorBuildProfile::BuildOption(build_option_id));
+
+ description_bit->set_text(TTRGET(build_option_description));
+ return;
+ } else {
+ return;
+ }
+}
+
+void EditorBuildProfileManager::_class_list_item_edited() {
+ if (updating_build_options) {
+ return;
+ }
+
+ TreeItem *item = class_list->get_edited();
+ if (!item) {
+ return;
+ }
+
+ bool checked = item->is_checked(0);
+
+ Variant md = item->get_metadata(0);
+ if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) {
+ String class_selected = md;
+ edited->set_disable_class(class_selected, !checked);
+ _update_edited_profile();
+ } else if (md.get_type() == Variant::INT) {
+ int build_option_selected = md;
+ edited->set_disable_build_option(EditorBuildProfile::BuildOption(build_option_selected), !checked);
+ }
+}
+
+void EditorBuildProfileManager::_class_list_item_collapsed(Object *p_item) {
+ if (updating_build_options) {
+ return;
+ }
+
+ TreeItem *item = Object::cast_to<TreeItem>(p_item);
+ if (!item) {
+ return;
+ }
+
+ Variant md = item->get_metadata(0);
+ if (md.get_type() != Variant::STRING && md.get_type() != Variant::STRING_NAME) {
+ return;
+ }
+
+ String class_name = md;
+ bool collapsed = item->is_collapsed();
+ edited->set_item_collapsed(class_name, collapsed);
+}
+
+void EditorBuildProfileManager::_update_edited_profile() {
+ String class_selected;
+ int build_option_selected = -1;
+
+ if (class_list->get_selected()) {
+ Variant md = class_list->get_selected()->get_metadata(0);
+ if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) {
+ class_selected = md;
+ } else if (md.get_type() == Variant::INT) {
+ build_option_selected = md;
+ }
+ }
+
+ class_list->clear();
+
+ updating_build_options = true;
+
+ TreeItem *root = class_list->create_item();
+
+ TreeItem *build_options = class_list->create_item(root);
+ build_options->set_text(0, TTR("General Features:"));
+ for (int i = 0; i < EditorBuildProfile::BUILD_OPTION_MAX; i++) {
+ TreeItem *build_option;
+ build_option = class_list->create_item(build_options);
+
+ build_option->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ build_option->set_text(0, EditorBuildProfile::get_build_option_name(EditorBuildProfile::BuildOption(i)));
+ build_option->set_selectable(0, true);
+ build_option->set_editable(0, true);
+ build_option->set_metadata(0, i);
+ if (!edited->is_build_option_disabled(EditorBuildProfile::BuildOption(i))) {
+ build_option->set_checked(0, true);
+ }
+
+ if (i == build_option_selected) {
+ build_option->select(0);
+ }
+ }
+
+ TreeItem *classes = class_list->create_item(root);
+ classes->set_text(0, TTR("Nodes and Classes:"));
+
+ _fill_classes_from(classes, "Node", class_selected);
+ _fill_classes_from(classes, "Resource", class_selected);
+
+ force_detect_classes->set_text(edited->get_force_detect_classes());
+
+ updating_build_options = false;
+
+ _class_list_item_selected();
+}
+
+void EditorBuildProfileManager::_force_detect_classes_changed(const String &p_text) {
+ if (updating_build_options) {
+ return;
+ }
+ edited->set_force_detect_classes(force_detect_classes->get_text());
+}
+
+void EditorBuildProfileManager::_import_profile(const String &p_path) {
+ Ref<EditorBuildProfile> profile;
+ profile.instantiate();
+ Error err = profile->load_from_file(p_path);
+ String basefile = p_path.get_file();
+ if (err != OK) {
+ EditorNode::get_singleton()->show_warning(vformat(TTR("File '%s' format is invalid, import aborted."), basefile));
+ return;
+ }
+
+ profile_path->set_text(p_path);
+ EditorSettings::get_singleton()->set_project_metadata("build_profile", "last_file_path", p_path);
+
+ edited = profile;
+ _update_edited_profile();
+}
+
+void EditorBuildProfileManager::_export_profile(const String &p_path) {
+ ERR_FAIL_COND(edited.is_null());
+ Error err = edited->save_to_file(p_path);
+ if (err != OK) {
+ EditorNode::get_singleton()->show_warning(vformat(TTR("Error saving profile to path: '%s'."), p_path));
+ } else {
+ profile_path->set_text(p_path);
+ EditorSettings::get_singleton()->set_project_metadata("build_profile", "last_file_path", p_path);
+ }
+}
+
+Ref<EditorBuildProfile> EditorBuildProfileManager::get_current_profile() {
+ return edited;
+}
+
+EditorBuildProfileManager *EditorBuildProfileManager::singleton = nullptr;
+
+void EditorBuildProfileManager::_bind_methods() {
+ ClassDB::bind_method("_update_selected_profile", &EditorBuildProfileManager::_update_edited_profile);
+}
+
+EditorBuildProfileManager::EditorBuildProfileManager() {
+ VBoxContainer *main_vbc = memnew(VBoxContainer);
+ add_child(main_vbc);
+
+ HBoxContainer *path_hbc = memnew(HBoxContainer);
+ profile_path = memnew(LineEdit);
+ path_hbc->add_child(profile_path);
+ profile_path->set_editable(true);
+ profile_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+
+ profile_actions[ACTION_NEW] = memnew(Button(TTR("New")));
+ path_hbc->add_child(profile_actions[ACTION_NEW]);
+ profile_actions[ACTION_NEW]->connect("pressed", callable_mp(this, &EditorBuildProfileManager::_profile_action), varray(ACTION_NEW));
+
+ profile_actions[ACTION_LOAD] = memnew(Button(TTR("Load")));
+ path_hbc->add_child(profile_actions[ACTION_LOAD]);
+ profile_actions[ACTION_LOAD]->connect("pressed", callable_mp(this, &EditorBuildProfileManager::_profile_action), varray(ACTION_LOAD));
+
+ profile_actions[ACTION_SAVE] = memnew(Button(TTR("Save")));
+ path_hbc->add_child(profile_actions[ACTION_SAVE]);
+ profile_actions[ACTION_SAVE]->connect("pressed", callable_mp(this, &EditorBuildProfileManager::_profile_action), varray(ACTION_SAVE));
+
+ profile_actions[ACTION_SAVE_AS] = memnew(Button(TTR("Save As")));
+ path_hbc->add_child(profile_actions[ACTION_SAVE_AS]);
+ profile_actions[ACTION_SAVE_AS]->connect("pressed", callable_mp(this, &EditorBuildProfileManager::_profile_action), varray(ACTION_SAVE_AS));
+
+ main_vbc->add_margin_child(TTR("Profile:"), path_hbc);
+
+ main_vbc->add_child(memnew(HSeparator));
+
+ HBoxContainer *profiles_hbc = memnew(HBoxContainer);
+
+ profile_actions[ACTION_RESET] = memnew(Button(TTR("Reset to Defaults")));
+ profiles_hbc->add_child(profile_actions[ACTION_RESET]);
+ profile_actions[ACTION_RESET]->connect("pressed", callable_mp(this, &EditorBuildProfileManager::_profile_action), varray(ACTION_RESET));
+
+ profile_actions[ACTION_DETECT] = memnew(Button(TTR("Detect from Project")));
+ profiles_hbc->add_child(profile_actions[ACTION_DETECT]);
+ profile_actions[ACTION_DETECT]->connect("pressed", callable_mp(this, &EditorBuildProfileManager::_profile_action), varray(ACTION_DETECT));
+
+ main_vbc->add_margin_child(TTR("Actions:"), profiles_hbc);
+
+ class_list = memnew(Tree);
+ class_list->set_hide_root(true);
+ class_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
+ class_list->connect("cell_selected", callable_mp(this, &EditorBuildProfileManager::_class_list_item_selected));
+ class_list->connect("item_edited", callable_mp(this, &EditorBuildProfileManager::_class_list_item_edited), varray(), CONNECT_DEFERRED);
+ class_list->connect("item_collapsed", callable_mp(this, &EditorBuildProfileManager::_class_list_item_collapsed));
+ // It will be displayed once the user creates or chooses a profile.
+ main_vbc->add_margin_child(TTR("Configure Engine Build Profile:"), class_list, true);
+
+ description_bit = memnew(EditorHelpBit);
+ description_bit->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
+ main_vbc->add_margin_child(TTR("Description:"), description_bit, false);
+
+ confirm_dialog = memnew(ConfirmationDialog);
+ add_child(confirm_dialog);
+ confirm_dialog->set_title(TTR("Please Confirm:"));
+ confirm_dialog->connect("confirmed", callable_mp(this, &EditorBuildProfileManager::_action_confirm));
+
+ import_profile = memnew(EditorFileDialog);
+ add_child(import_profile);
+ import_profile->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
+ import_profile->add_filter("*.build", TTR("Egine Build Profile"));
+ import_profile->connect("files_selected", callable_mp(this, &EditorBuildProfileManager::_import_profile));
+ import_profile->set_title(TTR("Load Profile"));
+ import_profile->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+
+ export_profile = memnew(EditorFileDialog);
+ add_child(export_profile);
+ export_profile->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
+ export_profile->add_filter("*.build", TTR("Egine Build Profile"));
+ export_profile->connect("file_selected", callable_mp(this, &EditorBuildProfileManager::_export_profile));
+ export_profile->set_title(TTR("Export Profile"));
+ export_profile->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+
+ force_detect_classes = memnew(LineEdit);
+ main_vbc->add_margin_child(TTR("Forced classes on detect:"), force_detect_classes);
+ force_detect_classes->connect("text_changed", callable_mp(this, &EditorBuildProfileManager::_force_detect_classes_changed));
+
+ set_title(TTR("Edit Build Configuration Profile"));
+
+ singleton = this;
+}
diff --git a/editor/editor_build_profile.h b/editor/editor_build_profile.h
new file mode 100644
index 0000000000..bb6494b8c9
--- /dev/null
+++ b/editor/editor_build_profile.h
@@ -0,0 +1,173 @@
+/*************************************************************************/
+/* editor_build_profile.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_BUILD_PROFILE_H
+#define EDITOR_BUILD_PROFILE_H
+
+#include "core/io/file_access.h"
+#include "core/object/ref_counted.h"
+#include "editor/editor_help.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/separator.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/tree.h"
+
+class EditorBuildProfile : public RefCounted {
+ GDCLASS(EditorBuildProfile, RefCounted);
+
+public:
+ enum BuildOption {
+ BUILD_OPTION_3D,
+ BUILD_OPTION_PHYSICS_2D,
+ BUILD_OPTION_PHYSICS_3D,
+ BUILD_OPTION_NAVIGATION,
+ BUILD_OPTION_XR,
+ BUILD_OPTION_RENDERING_DEVICE,
+ BUILD_OPTION_OPENGL,
+ BUILD_OPTION_VULKAN,
+ BUILD_OPTION_MAX
+ };
+
+private:
+ HashSet<StringName> disabled_classes;
+
+ HashSet<StringName> collapsed_classes;
+
+ String force_detect_classes;
+
+ bool build_options_disabled[BUILD_OPTION_MAX] = {};
+ static const char *build_option_identifiers[BUILD_OPTION_MAX];
+ static const bool build_option_disable_values[BUILD_OPTION_MAX];
+
+ String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); }
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_disable_class(const StringName &p_class, bool p_disabled);
+ bool is_class_disabled(const StringName &p_class) const;
+
+ void set_item_collapsed(const StringName &p_class, bool p_collapsed);
+ bool is_item_collapsed(const StringName &p_class) const;
+
+ void set_disable_build_option(BuildOption p_build_option, bool p_disable);
+ bool is_build_option_disabled(BuildOption p_build_option) const;
+
+ void set_force_detect_classes(const String &p_classes);
+ String get_force_detect_classes() const;
+
+ void clear_disabled_classes();
+
+ Error save_to_file(const String &p_path);
+ Error load_from_file(const String &p_path);
+
+ static String get_build_option_name(BuildOption p_build_option);
+ static String get_build_option_description(BuildOption p_build_option);
+ static bool get_build_option_disable_value(BuildOption p_build_option);
+
+ EditorBuildProfile();
+};
+
+VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption)
+
+class EditorFileSystemDirectory;
+
+class EditorBuildProfileManager : public AcceptDialog {
+ GDCLASS(EditorBuildProfileManager, AcceptDialog);
+
+ enum Action {
+ ACTION_NEW,
+ ACTION_RESET,
+ ACTION_LOAD,
+ ACTION_SAVE,
+ ACTION_SAVE_AS,
+ ACTION_DETECT,
+ ACTION_MAX
+ };
+
+ Action last_action = ACTION_NEW;
+
+ ConfirmationDialog *confirm_dialog = nullptr;
+ Button *profile_actions[ACTION_MAX];
+
+ Tree *class_list = nullptr;
+ EditorHelpBit *description_bit = nullptr;
+
+ EditorFileDialog *import_profile = nullptr;
+ EditorFileDialog *export_profile = nullptr;
+
+ LineEdit *profile_path = nullptr;
+
+ LineEdit *force_detect_classes = nullptr;
+
+ void _profile_action(int p_action);
+ void _action_confirm();
+
+ void _update_edited_profile();
+ void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);
+
+ Ref<EditorBuildProfile> edited;
+
+ void _import_profile(const String &p_path);
+ void _export_profile(const String &p_path);
+
+ bool updating_build_options = false;
+
+ void _class_list_item_selected();
+ void _class_list_item_edited();
+ void _class_list_item_collapsed(Object *p_item);
+ void _detect_classes();
+
+ void _force_detect_classes_changed(const String &p_text);
+
+ struct DetectedFile {
+ uint32_t timestamp = 0;
+ String md5;
+ Vector<String> classes;
+ };
+
+ void _find_files(EditorFileSystemDirectory *p_dir, const HashMap<String, DetectedFile> &p_cache, HashMap<String, DetectedFile> &r_detected);
+
+ static EditorBuildProfileManager *singleton;
+
+protected:
+ static void _bind_methods();
+ void _notification(int p_what);
+
+public:
+ Ref<EditorBuildProfile> get_current_profile();
+
+ static EditorBuildProfileManager *get_singleton() { return singleton; }
+ EditorBuildProfileManager();
+};
+
+#endif // EDITOR_BUILD_PROFILE_H
diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h
index 124703cca4..b3e84771d0 100644
--- a/editor/editor_command_palette.h
+++ b/editor/editor_command_palette.h
@@ -101,4 +101,4 @@ public:
Ref<Shortcut> ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name, Key p_keycode = Key::NONE, String p_command = "");
-#endif //EDITOR_COMMAND_PALETTE_H
+#endif // EDITOR_COMMAND_PALETTE_H
diff --git a/editor/editor_export.h b/editor/editor_export.h
deleted file mode 100644
index 9179a3e2b0..0000000000
--- a/editor/editor_export.h
+++ /dev/null
@@ -1,532 +0,0 @@
-/*************************************************************************/
-/* editor_export.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef EDITOR_EXPORT_H
-#define EDITOR_EXPORT_H
-
-#include "core/io/dir_access.h"
-#include "core/io/resource.h"
-#include "scene/gui/rich_text_label.h"
-#include "scene/main/node.h"
-#include "scene/main/timer.h"
-#include "scene/resources/texture.h"
-
-class FileAccess;
-class EditorExportPlatform;
-class EditorFileSystemDirectory;
-struct EditorProgress;
-
-class EditorExportPreset : public RefCounted {
- GDCLASS(EditorExportPreset, RefCounted);
-
-public:
- enum ExportFilter {
- EXPORT_ALL_RESOURCES,
- EXPORT_SELECTED_SCENES,
- EXPORT_SELECTED_RESOURCES,
- EXCLUDE_SELECTED_RESOURCES,
- };
-
- enum ScriptExportMode {
- MODE_SCRIPT_TEXT,
- MODE_SCRIPT_COMPILED,
- };
-
-private:
- Ref<EditorExportPlatform> platform;
- ExportFilter export_filter = EXPORT_ALL_RESOURCES;
- String include_filter;
- String exclude_filter;
- String export_path;
-
- String exporter;
- HashSet<String> selected_files;
- bool runnable = false;
-
- friend class EditorExport;
- friend class EditorExportPlatform;
-
- List<PropertyInfo> properties;
- HashMap<StringName, Variant> values;
-
- String name;
-
- String custom_features;
-
- String enc_in_filters;
- String enc_ex_filters;
- bool enc_pck = false;
- bool enc_directory = false;
-
- int script_mode = MODE_SCRIPT_COMPILED;
- String script_key;
-
-protected:
- bool _set(const StringName &p_name, const Variant &p_value);
- bool _get(const StringName &p_name, Variant &r_ret) const;
- void _get_property_list(List<PropertyInfo> *p_list) const;
-
-public:
- Ref<EditorExportPlatform> get_platform() const;
-
- bool has(const StringName &p_property) const { return values.has(p_property); }
-
- void update_files_to_export();
-
- Vector<String> get_files_to_export() const;
-
- void add_export_file(const String &p_path);
- void remove_export_file(const String &p_path);
- bool has_export_file(const String &p_path);
-
- void set_name(const String &p_name);
- String get_name() const;
-
- void set_runnable(bool p_enable);
- bool is_runnable() const;
-
- void set_export_filter(ExportFilter p_filter);
- ExportFilter get_export_filter() const;
-
- void set_include_filter(const String &p_include);
- String get_include_filter() const;
-
- void set_exclude_filter(const String &p_exclude);
- String get_exclude_filter() const;
-
- void set_custom_features(const String &p_custom_features);
- String get_custom_features() const;
-
- void set_export_path(const String &p_path);
- String get_export_path() const;
-
- void set_enc_in_filter(const String &p_filter);
- String get_enc_in_filter() const;
-
- void set_enc_ex_filter(const String &p_filter);
- String get_enc_ex_filter() const;
-
- void set_enc_pck(bool p_enabled);
- bool get_enc_pck() const;
-
- void set_enc_directory(bool p_enabled);
- bool get_enc_directory() const;
-
- void set_script_export_mode(int p_mode);
- int get_script_export_mode() const;
-
- void set_script_encryption_key(const String &p_key);
- String get_script_encryption_key() const;
-
- const List<PropertyInfo> &get_properties() const { return properties; }
-
- EditorExportPreset() {}
-};
-
-struct SharedObject {
- String path;
- Vector<String> tags;
- String target;
-
- SharedObject(const String &p_path, const Vector<String> &p_tags, const String &p_target) :
- path(p_path),
- tags(p_tags),
- target(p_target) {
- }
-
- SharedObject() {}
-};
-
-class EditorExportPlatform : public RefCounted {
- GDCLASS(EditorExportPlatform, RefCounted);
-
-public:
- typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
- typedef Error (*EditorExportSaveSharedObject)(void *p_userdata, const SharedObject &p_so);
-
- enum ExportMessageType {
- EXPORT_MESSAGE_NONE,
- EXPORT_MESSAGE_INFO,
- EXPORT_MESSAGE_WARNING,
- EXPORT_MESSAGE_ERROR,
- };
-
- struct ExportMessage {
- ExportMessageType msg_type;
- String category;
- String text;
- };
-
-private:
- struct SavedData {
- uint64_t ofs = 0;
- uint64_t size = 0;
- bool encrypted = false;
- Vector<uint8_t> md5;
- CharString path_utf8;
-
- bool operator<(const SavedData &p_data) const {
- return path_utf8 < p_data.path_utf8;
- }
- };
-
- struct PackData {
- Ref<FileAccess> f;
- Vector<SavedData> file_ofs;
- EditorProgress *ep = nullptr;
- Vector<SharedObject> *so_files = nullptr;
- };
-
- struct ZipData {
- void *zip = nullptr;
- EditorProgress *ep = nullptr;
- };
-
- struct FeatureContainers {
- HashSet<String> features;
- Vector<String> features_pv;
- };
-
- Vector<ExportMessage> messages;
-
- void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths);
- void _export_find_dependencies(const String &p_path, HashSet<String> &p_paths);
-
- void gen_debug_flags(Vector<String> &r_flags, int p_flags);
- static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
- static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
-
- void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude);
- void _edit_filter_list(HashSet<String> &r_list, const String &p_filter, bool exclude);
-
- static Error _add_shared_object(void *p_userdata, const SharedObject &p_so);
-
-protected:
- struct ExportNotifier {
- ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags);
- ~ExportNotifier();
- };
-
- FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug);
-
- bool exists_export_template(String template_file_name, String *err) const;
- String find_export_template(String template_file_name, String *err = nullptr) const;
- void gen_export_flags(Vector<String> &r_flags, int p_flags);
-
-public:
- virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
-
- struct ExportOption {
- PropertyInfo option;
- Variant default_value;
-
- ExportOption(const PropertyInfo &p_info, const Variant &p_default) :
- option(p_info),
- default_value(p_default) {
- }
- ExportOption() {}
- };
-
- virtual Ref<EditorExportPreset> create_preset();
-
- virtual void clear_messages() { messages.clear(); }
- virtual void add_message(ExportMessageType p_type, const String &p_category, const String &p_message) {
- ExportMessage msg;
- msg.category = p_category;
- msg.text = p_message;
- msg.msg_type = p_type;
- messages.push_back(msg);
- switch (p_type) {
- case EXPORT_MESSAGE_INFO: {
- print_line(vformat("%s: %s\n", msg.category, msg.text));
- } break;
- case EXPORT_MESSAGE_WARNING: {
- WARN_PRINT(vformat("%s: %s\n", msg.category, msg.text));
- } break;
- case EXPORT_MESSAGE_ERROR: {
- ERR_PRINT(vformat("%s: %s\n", msg.category, msg.text));
- } break;
- default:
- break;
- }
- }
-
- virtual int get_message_count() const {
- return messages.size();
- }
-
- virtual ExportMessage get_message(int p_index) const {
- ERR_FAIL_INDEX_V(p_index, messages.size(), ExportMessage());
- return messages[p_index];
- }
-
- virtual ExportMessageType get_worst_message_type() const {
- ExportMessageType worst_type = EXPORT_MESSAGE_NONE;
- for (int i = 0; i < messages.size(); i++) {
- worst_type = MAX(worst_type, messages[i].msg_type);
- }
- return worst_type;
- }
-
- virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err);
-
- virtual void get_export_options(List<ExportOption> *r_options) = 0;
- virtual bool should_update_export_options() { return false; }
- virtual bool get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; }
-
- virtual String get_os_name() const = 0;
- virtual String get_name() const = 0;
- virtual Ref<Texture2D> get_logo() const = 0;
-
- Error export_project_files(const Ref<EditorExportPreset> &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr);
-
- Error save_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr);
- Error save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path);
-
- virtual bool poll_export() { return false; }
- virtual int get_options_count() const { return 0; }
- virtual String get_options_tooltip() const { return ""; }
- virtual Ref<ImageTexture> get_option_icon(int p_index) const;
- virtual String get_option_label(int p_device) const { return ""; }
- virtual String get_option_tooltip(int p_device) const { return ""; }
-
- enum DebugFlags {
- DEBUG_FLAG_DUMB_CLIENT = 1,
- DEBUG_FLAG_REMOTE_DEBUG = 2,
- DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST = 4,
- DEBUG_FLAG_VIEW_COLLISONS = 8,
- DEBUG_FLAG_VIEW_NAVIGATION = 16,
- };
-
- virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; }
- virtual Ref<Texture2D> get_run_icon() const { return get_logo(); }
-
- String test_etc2() const;
- virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
-
- virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const = 0;
- virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0;
- virtual Error export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
- virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
- virtual void get_platform_features(List<String> *r_features) = 0;
- virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) = 0;
- virtual String get_debug_protocol() const { return "tcp://"; }
-
- EditorExportPlatform();
-};
-
-class EditorExportPlugin : public RefCounted {
- GDCLASS(EditorExportPlugin, RefCounted);
-
- friend class EditorExportPlatform;
-
- Ref<EditorExportPreset> export_preset;
-
- Vector<SharedObject> shared_objects;
- struct ExtraFile {
- String path;
- Vector<uint8_t> data;
- bool remap = false;
- };
- Vector<ExtraFile> extra_files;
- bool skipped = false;
-
- Vector<String> ios_frameworks;
- Vector<String> ios_embedded_frameworks;
- Vector<String> ios_project_static_libs;
- String ios_plist_content;
- String ios_linker_flags;
- Vector<String> ios_bundle_files;
- String ios_cpp_code;
-
- Vector<String> macos_plugin_files;
-
- _FORCE_INLINE_ void _clear() {
- shared_objects.clear();
- extra_files.clear();
- skipped = false;
- }
-
- _FORCE_INLINE_ void _export_end() {
- ios_frameworks.clear();
- ios_embedded_frameworks.clear();
- ios_bundle_files.clear();
- ios_plist_content = "";
- ios_linker_flags = "";
- ios_cpp_code = "";
- macos_plugin_files.clear();
- }
-
- void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features);
- void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
- void _export_end_script();
-
-protected:
- void set_export_preset(const Ref<EditorExportPreset> &p_preset);
- Ref<EditorExportPreset> get_export_preset() const;
-
- void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap);
- void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String());
-
- void add_ios_framework(const String &p_path);
- void add_ios_embedded_framework(const String &p_path);
- void add_ios_project_static_lib(const String &p_path);
- void add_ios_plist_content(const String &p_plist_content);
- void add_ios_linker_flags(const String &p_flags);
- void add_ios_bundle_file(const String &p_path);
- void add_ios_cpp_code(const String &p_code);
- void add_macos_plugin_file(const String &p_path);
-
- void skip();
-
- virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features);
- virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags);
-
- static void _bind_methods();
-
- GDVIRTUAL3(_export_file, String, String, Vector<String>)
- GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t)
- GDVIRTUAL0(_export_end)
-
-public:
- Vector<String> get_ios_frameworks() const;
- Vector<String> get_ios_embedded_frameworks() const;
- Vector<String> get_ios_project_static_libs() const;
- String get_ios_plist_content() const;
- String get_ios_linker_flags() const;
- Vector<String> get_ios_bundle_files() const;
- String get_ios_cpp_code() const;
- const Vector<String> &get_macos_plugin_files() const;
-
- EditorExportPlugin();
-};
-
-class EditorExport : public Node {
- GDCLASS(EditorExport, Node);
-
- Vector<Ref<EditorExportPlatform>> export_platforms;
- Vector<Ref<EditorExportPreset>> export_presets;
- Vector<Ref<EditorExportPlugin>> export_plugins;
-
- StringName _export_presets_updated;
-
- Timer *save_timer = nullptr;
- bool block_save = false;
-
- static EditorExport *singleton;
-
- void _save();
-
-protected:
- friend class EditorExportPreset;
- void save_presets();
-
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- static EditorExport *get_singleton() { return singleton; }
-
- void add_export_platform(const Ref<EditorExportPlatform> &p_platform);
- int get_export_platform_count();
- Ref<EditorExportPlatform> get_export_platform(int p_idx);
-
- void add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos = -1);
- int get_export_preset_count() const;
- Ref<EditorExportPreset> get_export_preset(int p_idx);
- void remove_export_preset(int p_idx);
-
- void add_export_plugin(const Ref<EditorExportPlugin> &p_plugin);
- void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin);
- Vector<Ref<EditorExportPlugin>> get_export_plugins();
-
- void load_config();
- void update_export_presets();
- bool poll_export_platforms();
-
- EditorExport();
- ~EditorExport();
-};
-
-class EditorExportPlatformPC : public EditorExportPlatform {
- GDCLASS(EditorExportPlatformPC, EditorExportPlatform);
-
-private:
- Ref<ImageTexture> logo;
- String name;
- String os_name;
-
- int chmod_flags = -1;
-
-public:
- virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override;
-
- virtual void get_export_options(List<ExportOption> *r_options) override;
-
- virtual String get_name() const override;
- virtual String get_os_name() const override;
- virtual Ref<Texture2D> get_logo() const override;
-
- virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
- virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;
- virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path);
- virtual String get_template_file_name(const String &p_target, const String &p_arch) const = 0;
-
- virtual Error prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags);
- virtual Error modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { return OK; };
- virtual Error export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags);
-
- void set_extension(const String &p_extension, const String &p_feature_key = "default");
- void set_name(const String &p_name);
- void set_os_name(const String &p_name);
-
- void set_logo(const Ref<Texture2D> &p_logo);
-
- void add_platform_feature(const String &p_feature);
- virtual void get_platform_features(List<String> *r_features) override;
- virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override;
-
- int get_chmod_flags() const;
- void set_chmod_flags(int p_flags);
-
- virtual Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {
- return Error::OK;
- }
-};
-
-class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin {
- GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin);
-
-public:
- virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override;
- EditorExportTextSceneToBinaryPlugin();
-};
-
-#endif // EDITOR_IMPORT_EXPORT_H
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 2f106739a4..56046a07d7 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -36,6 +36,7 @@
#include "core/io/resource_importer.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
+#include "core/object/worker_thread_pool.h"
#include "core/os/os.h"
#include "core/variant/variant_parser.h"
#include "editor/editor_node.h"
@@ -2137,7 +2138,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
data.reimport_from = from;
data.reimport_files = reimport_files.ptr();
- import_threads.begin_work(i - from + 1, this, &EditorFileSystem::_reimport_thread, &data);
+ WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &data, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer));
int current_index = from - 1;
do {
if (current_index < data.max_index) {
@@ -2145,9 +2146,9 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
pr.step(reimport_files[current_index].path.get_file(), current_index);
}
OS::get_singleton()->delay_usec(1);
- } while (!import_threads.is_done_dispatching());
+ } while (!WorkerThreadPool::get_singleton()->is_group_task_completed(group_task));
- import_threads.end_work();
+ WorkerThreadPool::get_singleton()->wait_for_group_task_completion(group_task);
importer->import_threaded_end();
}
@@ -2430,12 +2431,10 @@ EditorFileSystem::EditorFileSystem() {
scan_total = 0;
update_script_classes_queued.clear();
- import_threads.init();
ResourceUID::get_singleton()->clear(); //will be updated on scan
ResourceSaver::set_get_resource_id_for_path(_resource_saver_get_resource_id_for_path);
}
EditorFileSystem::~EditorFileSystem() {
- import_threads.finish();
ResourceSaver::set_get_resource_id_for_path(nullptr);
}
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 07b1132046..f4e69b95e7 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -36,7 +36,6 @@
#include "core/os/thread_safe.h"
#include "core/templates/hash_set.h"
#include "core/templates/safe_refcount.h"
-#include "core/templates/thread_work_pool.h"
#include "scene/main/node.h"
class FileAccess;
@@ -275,8 +274,6 @@ class EditorFileSystem : public Node {
HashSet<String> group_file_cache;
- ThreadWorkPool import_threads;
-
struct ImportThreadData {
const ImportFile *reimport_files;
int reimport_from;
diff --git a/editor/editor_fonts.h b/editor/editor_fonts.h
index e450af00da..c8b60b0198 100644
--- a/editor/editor_fonts.h
+++ b/editor/editor_fonts.h
@@ -35,4 +35,4 @@
void editor_register_fonts(Ref<Theme> p_theme);
-#endif
+#endif // EDITOR_FONTS_H
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 1711b23547..b610e09545 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -3558,7 +3558,7 @@ void EditorInspector::_notification(int p_what) {
if (refresh_countdown <= 0) {
for (const KeyValue<StringName, List<EditorProperty *>> &F : editor_property_map) {
for (EditorProperty *E : F.value) {
- if (!E->is_cache_valid()) {
+ if (E && !E->is_cache_valid()) {
E->update_property();
E->update_revert_and_pin_status();
E->update_cache();
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index 9542f102cb..4ec3513da5 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -602,4 +602,4 @@ public:
EditorInspector();
};
-#endif // INSPECTOR_H
+#endif // EDITOR_INSPECTOR_H
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 166dcf19c8..37329c92f3 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -75,9 +75,9 @@
#include "editor/dependency_editor.h"
#include "editor/editor_about.h"
#include "editor/editor_audio_buses.h"
+#include "editor/editor_build_profile.h"
#include "editor/editor_command_palette.h"
#include "editor/editor_data.h"
-#include "editor/editor_export.h"
#include "editor/editor_feature_profile.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_file_system.h"
@@ -90,6 +90,7 @@
#include "editor/editor_plugin.h"
#include "editor/editor_properties.h"
#include "editor/editor_property_name_processor.h"
+#include "editor/editor_quick_open.h"
#include "editor/editor_resource_picker.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_run.h"
@@ -102,8 +103,11 @@
#include "editor/editor_themes.h"
#include "editor/editor_toaster.h"
#include "editor/editor_translation_parser.h"
-#include "editor/export_template_manager.h"
+#include "editor/export/editor_export.h"
+#include "editor/export/export_template_manager.h"
+#include "editor/export/project_export.h"
#include "editor/filesystem_dock.h"
+#include "editor/import/audio_stream_import_settings.h"
#include "editor/import/dynamic_font_import_settings.h"
#include "editor/import/editor_import_collada.h"
#include "editor/import/resource_importer_bitmask.h"
@@ -131,7 +135,6 @@
#include "editor/plugins/animation_state_machine_editor.h"
#include "editor/plugins/animation_tree_editor_plugin.h"
#include "editor/plugins/asset_library_editor_plugin.h"
-#include "editor/plugins/audio_stream_editor_plugin.h"
#include "editor/plugins/audio_stream_randomizer_editor_plugin.h"
#include "editor/plugins/bit_map_editor_plugin.h"
#include "editor/plugins/bone_map_editor_plugin.h"
@@ -197,9 +200,7 @@
#include "editor/plugins/visual_shader_editor_plugin.h"
#include "editor/plugins/voxel_gi_editor_plugin.h"
#include "editor/progress_dialog.h"
-#include "editor/project_export.h"
#include "editor/project_settings_editor.h"
-#include "editor/quick_open.h"
#include "editor/register_exporters.h"
#include "editor/scene_tree_dock.h"
@@ -923,6 +924,7 @@ void EditorNode::_fs_changed() {
// FIXME: Move this to a cleaner location, it's hacky to do this in _fs_changed.
String export_error;
+ Error err = OK;
if (!export_defer.preset.is_empty() && !EditorFileSystem::get_singleton()->is_scanning()) {
String preset_name = export_defer.preset;
// Ensures export_project does not loop infinitely, because notifications may
@@ -940,6 +942,7 @@ void EditorNode::_fs_changed() {
if (export_preset.is_null()) {
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->file_exists("res://export_presets.cfg")) {
+ err = FAILED;
export_error = vformat(
"Invalid export preset name: %s.\nThe following presets were detected in this project's `export_presets.cfg`:\n\n",
preset_name);
@@ -948,17 +951,19 @@ void EditorNode::_fs_changed() {
export_error += vformat(" \"%s\"\n", EditorExport::get_singleton()->get_export_preset(i)->get_name());
}
} else {
+ err = FAILED;
export_error = "This project doesn't have an `export_presets.cfg` file at its root.\nCreate an export preset from the \"Project > Export\" dialog and try again.";
}
} else {
Ref<EditorExportPlatform> platform = export_preset->get_platform();
const String export_path = export_defer.path.is_empty() ? export_preset->get_export_path() : export_defer.path;
if (export_path.is_empty()) {
+ err = FAILED;
export_error = vformat("Export preset \"%s\" doesn't have a default export path, and none was specified.", preset_name);
} else if (platform.is_null()) {
+ err = FAILED;
export_error = vformat("Export preset \"%s\" doesn't have a matching platform.", preset_name);
} else {
- Error err = OK;
if (export_defer.pack_only) { // Only export .pck or .zip data pack.
if (export_path.ends_with(".zip")) {
err = platform->export_zip(export_preset, export_defer.debug, export_path);
@@ -979,17 +984,18 @@ void EditorNode::_fs_changed() {
if (err != OK) {
export_error = vformat("Project export for preset \"%s\" failed.", preset_name);
} else if (platform->get_worst_message_type() >= EditorExportPlatform::EXPORT_MESSAGE_WARNING) {
- export_error = vformat("Project export for preset \"%s\" completed with errors.", preset_name);
+ export_error = vformat("Project export for preset \"%s\" completed with warnings.", preset_name);
}
}
}
- if (!export_error.is_empty()) {
+ if (err != OK) {
ERR_PRINT(export_error);
_exit_editor(EXIT_FAILURE);
- } else {
- _exit_editor(EXIT_SUCCESS);
+ } else if (!export_error.is_empty()) {
+ WARN_PRINT(export_error);
}
+ _exit_editor(EXIT_SUCCESS);
}
}
@@ -1794,9 +1800,16 @@ void EditorNode::restart_editor() {
_exit_editor(EXIT_SUCCESS);
List<String> args;
+
args.push_back("--path");
args.push_back(ProjectSettings::get_singleton()->get_resource_path());
+
args.push_back("-e");
+
+ if (OS::get_singleton()->is_disable_crash_handler()) {
+ args.push_back("--disable-crash-handler");
+ }
+
if (!to_reopen.is_empty()) {
args.push_back(to_reopen);
}
@@ -2175,6 +2188,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
Object *prev_inspected_object = InspectorDock::get_inspector_singleton()->get_edited_object();
bool disable_folding = bool(EDITOR_GET("interface/inspector/disable_folding"));
+ bool stay_in_script_editor_on_node_selected = bool(EDITOR_GET("text_editor/behavior/navigation/stay_in_script_editor_on_node_selected"));
bool is_resource = current_obj->is_class("Resource");
bool is_node = current_obj->is_class("Node");
@@ -2213,6 +2227,9 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
NodeDock::get_singleton()->set_node(current_node);
SceneTreeDock::get_singleton()->set_selected(current_node);
InspectorDock::get_singleton()->update(current_node);
+ if (!inspector_only) {
+ inspector_only = stay_in_script_editor_on_node_selected && ScriptEditor::get_singleton()->is_visible_in_tree();
+ }
} else {
NodeDock::get_singleton()->set_node(nullptr);
SceneTreeDock::get_singleton()->set_selected(nullptr);
@@ -2805,6 +2822,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
} break;
+ case TOOLS_BUILD_PROFILE_MANAGER: {
+ build_profile_manager->popup_centered_clamped(Size2(700, 800) * EDSCALE, 0.8);
+ } break;
case RUN_USER_DATA_FOLDER: {
// Ensure_user_data_dir() to prevent the edge case: "Open User Data Folder" won't work after the project was renamed in ProjectSettingsEditor unless the project is saved.
OS::get_singleton()->ensure_user_data_dir();
@@ -3588,6 +3608,13 @@ void EditorNode::set_current_scene(int p_idx) {
call_deferred(SNAME("_set_main_scene_state"), state, get_edited_scene()); // Do after everything else is done setting up.
}
+void EditorNode::setup_color_picker(ColorPicker *picker) {
+ int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
+ int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
+ picker->set_color_mode((ColorPicker::ColorModeType)default_color_mode);
+ picker->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
+}
+
bool EditorNode::is_scene_open(const String &p_path) {
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
if (editor_data.get_scene_path(i) == p_path) {
@@ -5899,6 +5926,8 @@ EditorNode::EditorNode() {
RenderingServer::get_singleton()->set_debug_generate_wireframes(true);
+ AudioServer::get_singleton()->set_enable_tagging_used_audio_streams(true);
+
// No navigation server by default if in editor.
NavigationServer3D::get_singleton()->set_active(false);
@@ -6443,6 +6472,9 @@ EditorNode::EditorNode() {
scene_import_settings = memnew(SceneImportSettings);
gui_base->add_child(scene_import_settings);
+ audio_stream_import_settings = memnew(AudioStreamImportSettings);
+ gui_base->add_child(audio_stream_import_settings);
+
fontdata_import_settings = memnew(DynamicFontImportSettings);
gui_base->add_child(fontdata_import_settings);
@@ -6451,6 +6483,10 @@ EditorNode::EditorNode() {
feature_profile_manager = memnew(EditorFeatureProfileManager);
gui_base->add_child(feature_profile_manager);
+
+ build_profile_manager = memnew(EditorBuildProfileManager);
+ gui_base->add_child(build_profile_manager);
+
about = memnew(EditorAbout);
gui_base->add_child(about);
feature_profile_manager->connect("current_feature_profile_changed", callable_mp(this, &EditorNode::_feature_profile_changed));
@@ -6543,6 +6579,10 @@ EditorNode::EditorNode() {
p->add_item(TTR("Install Android Build Template..."), FILE_INSTALL_ANDROID_SOURCE);
p->add_item(TTR("Open User Data Folder"), RUN_USER_DATA_FOLDER);
+ p->add_separator();
+ p->add_item(TTR("Customize Engine Build Configuration..."), TOOLS_BUILD_PROFILE_MANAGER);
+ p->add_separator();
+
plugin_config_dialog = memnew(PluginConfigDialog);
plugin_config_dialog->connect("plugin_ready", callable_mp(this, &EditorNode::_on_plugin_ready));
gui_base->add_child(plugin_config_dialog);
@@ -7079,7 +7119,6 @@ EditorNode::EditorNode() {
// This list is alphabetized, and plugins that depend on Node2D are in their own section below.
add_editor_plugin(memnew(AnimationTreeEditorPlugin));
add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
- add_editor_plugin(memnew(AudioStreamEditorPlugin));
add_editor_plugin(memnew(AudioStreamRandomizerEditorPlugin));
add_editor_plugin(memnew(BitMapEditorPlugin));
add_editor_plugin(memnew(BoneMapEditorPlugin));
@@ -7190,6 +7229,7 @@ EditorNode::EditorNode() {
vshader_convert.instantiate();
resource_conversion_plugins.push_back(vshader_convert);
}
+
update_spinner_step_msec = OS::get_singleton()->get_ticks_msec();
update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn();
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 07d565314d..c521c0fb04 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -32,10 +32,10 @@
#define EDITOR_NODE_H
#include "core/templates/safe_refcount.h"
-#include "editor/editor_export.h"
#include "editor/editor_folding.h"
#include "editor/editor_native_shader_source_visualizer.h"
#include "editor/editor_run.h"
+#include "editor/export/editor_export.h"
#include "editor/inspector_dock.h"
#include "editor/property_editor.h"
@@ -88,6 +88,7 @@ class ProjectExportDialog;
class ProjectSettingsEditor;
class RunSettingsDialog;
class SceneImportSettings;
+class AudioStreamImportSettings;
class ScriptCreateDialog;
class SubViewport;
class TabBar;
@@ -95,6 +96,7 @@ class TabContainer;
class TextureProgressBar;
class VSplitContainer;
class Window;
+class EditorBuildProfileManager;
class EditorNode : public Node {
GDCLASS(EditorNode, Node);
@@ -163,6 +165,7 @@ private:
EDIT_REDO,
EDIT_RELOAD_SAVED_SCENE,
TOOLS_ORPHAN_RESOURCES,
+ TOOLS_BUILD_PROFILE_MANAGER,
TOOLS_CUSTOM,
RESOURCE_SAVE,
RESOURCE_SAVE_AS,
@@ -377,6 +380,7 @@ private:
EditorFileDialog *file = nullptr;
ExportTemplateManager *export_template_manager = nullptr;
EditorFeatureProfileManager *feature_profile_manager = nullptr;
+ EditorBuildProfileManager *build_profile_manager = nullptr;
EditorFileDialog *file_templates = nullptr;
EditorFileDialog *file_export_lib = nullptr;
EditorFileDialog *file_script = nullptr;
@@ -468,6 +472,7 @@ private:
DynamicFontImportSettings *fontdata_import_settings = nullptr;
SceneImportSettings *scene_import_settings = nullptr;
+ AudioStreamImportSettings *audio_stream_import_settings = nullptr;
String import_reload_fn;
@@ -783,6 +788,8 @@ public:
void set_current_version(uint64_t p_version);
void set_current_scene(int p_idx);
+ void setup_color_picker(ColorPicker *picker);
+
void request_instance_scene(const String &p_path);
void request_instantiate_scenes(const Vector<String> &p_files);
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index d9c2a42114..566c22f5a9 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -31,11 +31,11 @@
#include "editor_plugin.h"
#include "editor/editor_command_palette.h"
-#include "editor/editor_export.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_settings.h"
+#include "editor/export/editor_export.h"
#include "editor/filesystem_dock.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/node_3d_editor_plugin.h"
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index c666b4639d..84c63d1021 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -346,4 +346,4 @@ public:
}
};
-#endif
+#endif // EDITOR_PLUGIN_H
diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h
index 4903a02c4d..7c6d93e6f4 100644
--- a/editor/editor_plugin_settings.h
+++ b/editor/editor_plugin_settings.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITORPLUGINSETTINGS_H
-#define EDITORPLUGINSETTINGS_H
+#ifndef EDITOR_PLUGIN_SETTINGS_H
+#define EDITOR_PLUGIN_SETTINGS_H
#include "core/object/undo_redo.h"
#include "editor/editor_data.h"
@@ -65,4 +65,4 @@ public:
EditorPluginSettings();
};
-#endif // EDITORPLUGINSETTINGS_H
+#endif // EDITOR_PLUGIN_SETTINGS_H
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index aaa518362c..d145a1e820 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2623,6 +2623,186 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() {
set_label_reference(spin[0]); //show text and buttons around this
}
}
+///////////////////// VECTOR4 /////////////////////////
+
+void EditorPropertyVector4::_set_read_only(bool p_read_only) {
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_read_only(p_read_only);
+ }
+};
+
+void EditorPropertyVector4::_value_changed(double val, const String &p_name) {
+ if (setting) {
+ return;
+ }
+
+ Vector4 p;
+ p.x = spin[0]->get_value();
+ p.y = spin[1]->get_value();
+ p.z = spin[2]->get_value();
+ p.w = spin[3]->get_value();
+ emit_changed(get_edited_property(), p, p_name);
+}
+
+void EditorPropertyVector4::update_property() {
+ Vector4 val = get_edited_object()->get(get_edited_property());
+ setting = true;
+ spin[0]->set_value(val.x);
+ spin[1]->set_value(val.y);
+ spin[2]->set_value(val.z);
+ spin[3]->set_value(val.w);
+ setting = false;
+}
+
+void EditorPropertyVector4::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 4; i++) {
+ spin[i]->add_theme_color_override("label_color", colors[i]);
+ }
+ } break;
+ }
+}
+
+void EditorPropertyVector4::_bind_methods() {
+}
+
+void EditorPropertyVector4::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_min(p_min);
+ spin[i]->set_max(p_max);
+ spin[i]->set_step(p_step);
+ spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_allow_greater(true);
+ spin[i]->set_allow_lesser(true);
+ // Vector4 is inherently unitless, however someone may want to use it as
+ // a generic way to store 4 values, so we'll still respect the suffix.
+ spin[i]->set_suffix(p_suffix);
+ }
+}
+
+EditorPropertyVector4::EditorPropertyVector4() {
+ bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
+
+ BoxContainer *bc;
+
+ if (horizontal) {
+ bc = memnew(HBoxContainer);
+ add_child(bc);
+ set_bottom_editor(bc);
+ } else {
+ bc = memnew(VBoxContainer);
+ add_child(bc);
+ }
+
+ static const char *desc[4] = { "x", "y", "z", "w" };
+ for (int i = 0; i < 4; i++) {
+ spin[i] = memnew(EditorSpinSlider);
+ spin[i]->set_flat(true);
+ spin[i]->set_label(desc[i]);
+ bc->add_child(spin[i]);
+ add_focusable(spin[i]);
+ spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector4::_value_changed), varray(desc[i]));
+ if (horizontal) {
+ spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ }
+ }
+
+ if (!horizontal) {
+ set_label_reference(spin[0]); //show text and buttons around this
+ }
+}
+
+///////////////////// VECTOR4I /////////////////////////
+
+void EditorPropertyVector4i::_set_read_only(bool p_read_only) {
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_read_only(p_read_only);
+ }
+};
+
+void EditorPropertyVector4i::_value_changed(double val, const String &p_name) {
+ if (setting) {
+ return;
+ }
+
+ Vector4i p;
+ p.x = spin[0]->get_value();
+ p.y = spin[1]->get_value();
+ p.z = spin[2]->get_value();
+ p.w = spin[3]->get_value();
+ emit_changed(get_edited_property(), p, p_name);
+}
+
+void EditorPropertyVector4i::update_property() {
+ Vector4i val = get_edited_object()->get(get_edited_property());
+ setting = true;
+ spin[0]->set_value(val.x);
+ spin[1]->set_value(val.y);
+ spin[2]->set_value(val.z);
+ spin[3]->set_value(val.w);
+ setting = false;
+}
+
+void EditorPropertyVector4i::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 4; i++) {
+ spin[i]->add_theme_color_override("label_color", colors[i]);
+ }
+ } break;
+ }
+}
+
+void EditorPropertyVector4i::_bind_methods() {
+}
+
+void EditorPropertyVector4i::setup(double p_min, double p_max, bool p_no_slider, const String &p_suffix) {
+ for (int i = 0; i < 4; i++) {
+ spin[i]->set_min(p_min);
+ spin[i]->set_max(p_max);
+ spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_allow_greater(true);
+ spin[i]->set_allow_lesser(true);
+ spin[i]->set_suffix(p_suffix);
+ }
+}
+
+EditorPropertyVector4i::EditorPropertyVector4i() {
+ bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
+
+ BoxContainer *bc;
+
+ if (horizontal) {
+ bc = memnew(HBoxContainer);
+ add_child(bc);
+ set_bottom_editor(bc);
+ } else {
+ bc = memnew(VBoxContainer);
+ add_child(bc);
+ }
+
+ static const char *desc[4] = { "x", "y", "z", "w" };
+ for (int i = 0; i < 4; i++) {
+ spin[i] = memnew(EditorSpinSlider);
+ spin[i]->set_flat(true);
+ spin[i]->set_label(desc[i]);
+ bc->add_child(spin[i]);
+ add_focusable(spin[i]);
+ spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector4i::_value_changed), varray(desc[i]));
+ if (horizontal) {
+ spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ }
+ }
+
+ if (!horizontal) {
+ set_label_reference(spin[0]); //show text and buttons around this
+ }
+}
///////////////////// AABB /////////////////////////
@@ -2986,6 +3166,111 @@ EditorPropertyTransform3D::EditorPropertyTransform3D() {
set_bottom_editor(g);
}
+///////////////////// PROJECTION /////////////////////////
+
+void EditorPropertyProjection::_set_read_only(bool p_read_only) {
+ for (int i = 0; i < 12; i++) {
+ spin[i]->set_read_only(p_read_only);
+ }
+};
+
+void EditorPropertyProjection::_value_changed(double val, const String &p_name) {
+ if (setting) {
+ return;
+ }
+
+ Projection p;
+ p.matrix[0][0] = spin[0]->get_value();
+ p.matrix[0][1] = spin[1]->get_value();
+ p.matrix[0][2] = spin[2]->get_value();
+ p.matrix[0][3] = spin[3]->get_value();
+ p.matrix[1][0] = spin[4]->get_value();
+ p.matrix[1][1] = spin[5]->get_value();
+ p.matrix[1][2] = spin[6]->get_value();
+ p.matrix[1][3] = spin[7]->get_value();
+ p.matrix[2][0] = spin[8]->get_value();
+ p.matrix[2][1] = spin[9]->get_value();
+ p.matrix[2][2] = spin[10]->get_value();
+ p.matrix[2][3] = spin[11]->get_value();
+ p.matrix[3][0] = spin[12]->get_value();
+ p.matrix[3][1] = spin[13]->get_value();
+ p.matrix[3][2] = spin[14]->get_value();
+ p.matrix[3][3] = spin[15]->get_value();
+
+ emit_changed(get_edited_property(), p, p_name);
+}
+
+void EditorPropertyProjection::update_property() {
+ update_using_transform(get_edited_object()->get(get_edited_property()));
+}
+
+void EditorPropertyProjection::update_using_transform(Projection p_transform) {
+ setting = true;
+ spin[0]->set_value(p_transform.matrix[0][0]);
+ spin[1]->set_value(p_transform.matrix[0][1]);
+ spin[2]->set_value(p_transform.matrix[0][2]);
+ spin[3]->set_value(p_transform.matrix[0][3]);
+ spin[4]->set_value(p_transform.matrix[1][0]);
+ spin[5]->set_value(p_transform.matrix[1][1]);
+ spin[6]->set_value(p_transform.matrix[1][2]);
+ spin[7]->set_value(p_transform.matrix[1][3]);
+ spin[8]->set_value(p_transform.matrix[2][0]);
+ spin[9]->set_value(p_transform.matrix[2][1]);
+ spin[10]->set_value(p_transform.matrix[2][2]);
+ spin[11]->set_value(p_transform.matrix[2][3]);
+ spin[12]->set_value(p_transform.matrix[3][0]);
+ spin[13]->set_value(p_transform.matrix[3][1]);
+ spin[14]->set_value(p_transform.matrix[3][2]);
+ spin[15]->set_value(p_transform.matrix[3][3]);
+ setting = false;
+}
+
+void EditorPropertyProjection::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ const Color *colors = _get_property_colors();
+ for (int i = 0; i < 16; i++) {
+ spin[i]->add_theme_color_override("label_color", colors[i % 4]);
+ }
+ } break;
+ }
+}
+
+void EditorPropertyProjection::_bind_methods() {
+}
+
+void EditorPropertyProjection::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) {
+ for (int i = 0; i < 16; i++) {
+ spin[i]->set_min(p_min);
+ spin[i]->set_max(p_max);
+ spin[i]->set_step(p_step);
+ spin[i]->set_hide_slider(p_no_slider);
+ spin[i]->set_allow_greater(true);
+ spin[i]->set_allow_lesser(true);
+ if (i % 4 == 3) {
+ spin[i]->set_suffix(p_suffix);
+ }
+ }
+}
+
+EditorPropertyProjection::EditorPropertyProjection() {
+ GridContainer *g = memnew(GridContainer);
+ g->set_columns(4);
+ add_child(g);
+
+ static const char *desc[16] = { "xx", "xy", "xz", "xw", "yx", "yy", "yz", "yw", "zx", "zy", "zz", "zw", "wx", "wy", "wz", "ww" };
+ for (int i = 0; i < 16; i++) {
+ spin[i] = memnew(EditorSpinSlider);
+ spin[i]->set_label(desc[i]);
+ spin[i]->set_flat(true);
+ g->add_child(spin[i]);
+ spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ add_focusable(spin[i]);
+ spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyProjection::_value_changed), varray(desc[i]));
+ }
+ set_bottom_editor(g);
+}
////////////// COLOR PICKER //////////////////////
void EditorPropertyColor::_set_read_only(bool p_read_only) {
@@ -3007,14 +3292,6 @@ void EditorPropertyColor::_popup_closed() {
}
}
-void EditorPropertyColor::_picker_created() {
- // get default color picker mode from editor settings
- int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
- picker->get_picker()->set_color_mode((ColorPicker::ColorModeType)default_color_mode);
- int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
- picker->get_picker()->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
-}
-
void EditorPropertyColor::_picker_opening() {
last_color = picker->get_pick_color();
}
@@ -3059,7 +3336,7 @@ EditorPropertyColor::EditorPropertyColor() {
picker->set_flat(true);
picker->connect("color_changed", callable_mp(this, &EditorPropertyColor::_color_changed));
picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed));
- picker->connect("picker_created", callable_mp(this, &EditorPropertyColor::_picker_created));
+ picker->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(picker->get_picker()));
picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_picker_opening));
}
@@ -3177,6 +3454,11 @@ bool EditorPropertyNodePath::is_drop_valid(const Dictionary &p_drag_data) const
Node *dropped_node = get_tree()->get_edited_scene_root()->get_node(nodes[0]);
ERR_FAIL_NULL_V(dropped_node, false);
+ if (valid_types.is_empty()) {
+ // No type requirements specified so any type is valid.
+ return true;
+ }
+
for (const StringName &E : valid_types) {
if (dropped_node->is_class(E)) {
return true;
@@ -3517,6 +3799,9 @@ void EditorPropertyResource::setup(Object *p_object, const String &p_path, const
shader_picker->set_edited_material(Object::cast_to<ShaderMaterial>(p_object));
resource_picker = shader_picker;
connect(SNAME("ready"), callable_mp(this, &EditorPropertyResource::_update_preferred_shader));
+ } else if (p_base_type == "AudioStream") {
+ EditorAudioStreamPicker *astream_picker = memnew(EditorAudioStreamPicker);
+ resource_picker = astream_picker;
} else {
resource_picker = memnew(EditorResourcePicker);
}
@@ -3954,6 +4239,20 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
return editor;
} break;
+ case Variant::VECTOR4: {
+ EditorPropertyVector4 *editor = memnew(EditorPropertyVector4);
+ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step);
+ editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix);
+ return editor;
+
+ } break;
+ case Variant::VECTOR4I: {
+ EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
+ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1);
+ editor->setup(hint.min, hint.max, hint.hide_slider, hint.suffix);
+ return editor;
+
+ } break;
case Variant::TRANSFORM2D: {
EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D);
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step);
@@ -3991,6 +4290,13 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
return editor;
} break;
+ case Variant::PROJECTION: {
+ EditorPropertyProjection *editor = memnew(EditorPropertyProjection);
+ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step);
+ editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix);
+ return editor;
+
+ } break;
// misc types
case Variant::COLOR: {
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 7bec2d0013..b3aac6e8ca 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -636,6 +636,40 @@ public:
EditorPropertyQuaternion();
};
+class EditorPropertyVector4 : public EditorProperty {
+ GDCLASS(EditorPropertyVector4, EditorProperty);
+ EditorSpinSlider *spin[4];
+ bool setting = false;
+ void _value_changed(double p_val, const String &p_name);
+
+protected:
+ virtual void _set_read_only(bool p_read_only) override;
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ virtual void update_property() override;
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ EditorPropertyVector4();
+};
+
+class EditorPropertyVector4i : public EditorProperty {
+ GDCLASS(EditorPropertyVector4i, EditorProperty);
+ EditorSpinSlider *spin[4];
+ bool setting = false;
+ void _value_changed(double p_val, const String &p_name);
+
+protected:
+ virtual void _set_read_only(bool p_read_only) override;
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ virtual void update_property() override;
+ void setup(double p_min, double p_max, bool p_no_slider, const String &p_suffix = String());
+ EditorPropertyVector4i();
+};
+
class EditorPropertyAABB : public EditorProperty {
GDCLASS(EditorPropertyAABB, EditorProperty);
EditorSpinSlider *spin[6];
@@ -705,6 +739,24 @@ public:
EditorPropertyTransform3D();
};
+class EditorPropertyProjection : public EditorProperty {
+ GDCLASS(EditorPropertyProjection, EditorProperty);
+ EditorSpinSlider *spin[16];
+ bool setting = false;
+ void _value_changed(double p_val, const String &p_name);
+
+protected:
+ virtual void _set_read_only(bool p_read_only) override;
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ virtual void update_property() override;
+ virtual void update_using_transform(Projection p_transform);
+ void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String());
+ EditorPropertyProjection();
+};
+
class EditorPropertyColor : public EditorProperty {
GDCLASS(EditorPropertyColor, EditorProperty);
ColorPickerButton *picker = nullptr;
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 0b9004bbc4..e83b070f6b 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -949,6 +949,18 @@ void EditorPropertyDictionary::update_property() {
prop = editor;
} break;
+ case Variant::VECTOR4: {
+ EditorPropertyVector4 *editor = memnew(EditorPropertyVector4);
+ editor->setup(-100000, 100000, default_float_step, true);
+ prop = editor;
+
+ } break;
+ case Variant::VECTOR4I: {
+ EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
+ editor->setup(-100000, 100000, true);
+ prop = editor;
+
+ } break;
case Variant::TRANSFORM2D: {
EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D);
editor->setup(-100000, 100000, default_float_step, true);
@@ -985,6 +997,12 @@ void EditorPropertyDictionary::update_property() {
prop = editor;
} break;
+ case Variant::PROJECTION: {
+ EditorPropertyProjection *editor = memnew(EditorPropertyProjection);
+ editor->setup(-100000, 100000, default_float_step, true);
+ prop = editor;
+
+ } break;
// Miscellaneous types.
case Variant::COLOR: {
diff --git a/editor/quick_open.cpp b/editor/editor_quick_open.cpp
index 4f7f9fc78c..539cb7cd8a 100644
--- a/editor/quick_open.cpp
+++ b/editor/editor_quick_open.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* quick_open.cpp */
+/* editor_quick_open.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "quick_open.h"
+#include "editor_quick_open.h"
#include "core/os/keyboard.h"
diff --git a/editor/quick_open.h b/editor/editor_quick_open.h
index 843ef47711..e41a8c7e75 100644
--- a/editor/quick_open.h
+++ b/editor/editor_quick_open.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* quick_open.h */
+/* editor_quick_open.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 40e16bf717..e0903ea5ce 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -30,14 +30,15 @@
#include "editor_resource_picker.h"
+#include "editor/audio_stream_preview.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
+#include "editor/editor_quick_open.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/filesystem_dock.h"
#include "editor/plugins/script_editor_plugin.h"
-#include "editor/quick_open.h"
#include "editor/scene_tree_dock.h"
HashMap<StringName, List<StringName>> EditorResourcePicker::allowed_types_cache;
@@ -47,32 +48,37 @@ void EditorResourcePicker::clear_caches() {
}
void EditorResourcePicker::_update_resource() {
- preview_rect->set_texture(Ref<Texture2D>());
- assign_button->set_custom_minimum_size(Size2(1, 1));
+ String resource_path;
+ if (edited_resource.is_valid() && edited_resource->get_path().is_resource_file()) {
+ resource_path = edited_resource->get_path() + "\n";
+ }
- if (edited_resource == Ref<Resource>()) {
- assign_button->set_icon(Ref<Texture2D>());
- assign_button->set_text(TTR("[empty]"));
- assign_button->set_tooltip("");
- } else {
- assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), "Object"));
+ if (preview_rect) {
+ preview_rect->set_texture(Ref<Texture2D>());
+
+ assign_button->set_custom_minimum_size(assign_button_min_size);
- if (!edited_resource->get_name().is_empty()) {
- assign_button->set_text(edited_resource->get_name());
- } else if (edited_resource->get_path().is_resource_file()) {
- assign_button->set_text(edited_resource->get_path().get_file());
+ if (edited_resource == Ref<Resource>()) {
+ assign_button->set_icon(Ref<Texture2D>());
+ assign_button->set_text(TTR("[empty]"));
+ assign_button->set_tooltip("");
} else {
- assign_button->set_text(edited_resource->get_class());
- }
+ assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), "Object"));
- String resource_path;
- if (edited_resource->get_path().is_resource_file()) {
- resource_path = edited_resource->get_path() + "\n";
+ if (!edited_resource->get_name().is_empty()) {
+ assign_button->set_text(edited_resource->get_name());
+ } else if (edited_resource->get_path().is_resource_file()) {
+ assign_button->set_text(edited_resource->get_path().get_file());
+ } else {
+ assign_button->set_text(edited_resource->get_class());
+ }
+ assign_button->set_tooltip(resource_path + TTR("Type:") + " " + edited_resource->get_class());
+
+ // Preview will override the above, so called at the end.
+ EditorResourcePreview::get_singleton()->queue_edited_resource_preview(edited_resource, this, "_update_resource_preview", edited_resource->get_instance_id());
}
+ } else if (edited_resource.is_valid()) {
assign_button->set_tooltip(resource_path + TTR("Type:") + " " + edited_resource->get_class());
-
- // Preview will override the above, so called at the end.
- EditorResourcePreview::get_singleton()->queue_edited_resource_preview(edited_resource, this, "_update_resource_preview", edited_resource->get_instance_id());
}
}
@@ -81,28 +87,30 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
return;
}
- Ref<Script> script = edited_resource;
- if (script.is_valid()) {
- assign_button->set_text(script->get_path().get_file());
- return;
- }
+ if (preview_rect) {
+ Ref<Script> script = edited_resource;
+ if (script.is_valid()) {
+ assign_button->set_text(script->get_path().get_file());
+ return;
+ }
- if (p_preview.is_valid()) {
- preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("h_separation"), SNAME("Button")));
+ if (p_preview.is_valid()) {
+ preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("h_separation"), SNAME("Button")));
- // Resource-specific stretching.
- if (Ref<GradientTexture1D>(edited_resource).is_valid() || Ref<Gradient>(edited_resource).is_valid()) {
- preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE);
- assign_button->set_custom_minimum_size(Size2(1, 1));
- } else {
- preview_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
- int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
- thumbnail_size *= EDSCALE;
- assign_button->set_custom_minimum_size(Size2(1, thumbnail_size));
- }
+ // Resource-specific stretching.
+ if (Ref<GradientTexture1D>(edited_resource).is_valid() || Ref<Gradient>(edited_resource).is_valid()) {
+ preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE);
+ assign_button->set_custom_minimum_size(assign_button_min_size);
+ } else {
+ preview_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
+ int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
+ thumbnail_size *= EDSCALE;
+ assign_button->set_custom_minimum_size(Size2(MIN(1, assign_button_min_size.x), MIN(thumbnail_size, assign_button_min_size.y)));
+ }
- preview_rect->set_texture(p_preview);
- assign_button->set_text("");
+ preview_rect->set_texture(p_preview);
+ assign_button->set_text("");
+ }
}
}
@@ -866,7 +874,7 @@ void EditorResourcePicker::_ensure_resource_menu() {
edit_menu->connect("popup_hide", callable_mp((BaseButton *)edit_button, &BaseButton::set_pressed), varray(false));
}
-EditorResourcePicker::EditorResourcePicker() {
+EditorResourcePicker::EditorResourcePicker(bool p_hide_assign_button_controls) {
assign_button = memnew(Button);
assign_button->set_flat(true);
assign_button->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -877,13 +885,15 @@ EditorResourcePicker::EditorResourcePicker() {
assign_button->connect("draw", callable_mp(this, &EditorResourcePicker::_button_draw));
assign_button->connect("gui_input", callable_mp(this, &EditorResourcePicker::_button_input));
- preview_rect = memnew(TextureRect);
- preview_rect->set_ignore_texture_size(true);
- preview_rect->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
- preview_rect->set_offset(SIDE_TOP, 1);
- preview_rect->set_offset(SIDE_BOTTOM, -1);
- preview_rect->set_offset(SIDE_RIGHT, -1);
- assign_button->add_child(preview_rect);
+ if (!p_hide_assign_button_controls) {
+ preview_rect = memnew(TextureRect);
+ preview_rect->set_ignore_texture_size(true);
+ preview_rect->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
+ preview_rect->set_offset(SIDE_TOP, 1);
+ preview_rect->set_offset(SIDE_BOTTOM, -1);
+ preview_rect->set_offset(SIDE_RIGHT, -1);
+ assign_button->add_child(preview_rect);
+ }
edit_button = memnew(Button);
edit_button->set_flat(true);
@@ -993,3 +1003,176 @@ void EditorShaderPicker::set_preferred_mode(int p_mode) {
EditorShaderPicker::EditorShaderPicker() {
}
+
+//////////////
+
+void EditorAudioStreamPicker::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY:
+ case NOTIFICATION_THEME_CHANGED: {
+ _update_resource();
+ } break;
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ Ref<AudioStream> audio_stream = get_edited_resource();
+ if (audio_stream.is_valid()) {
+ if (audio_stream->get_length() > 0) {
+ Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(audio_stream);
+ if (preview.is_valid()) {
+ if (preview->get_version() != last_preview_version) {
+ stream_preview_rect->update();
+ last_preview_version = preview->get_version();
+ }
+ }
+ }
+
+ uint64_t tagged_frame = audio_stream->get_tagged_frame();
+ uint64_t diff_frames = AudioServer::get_singleton()->get_mixed_frames() - tagged_frame;
+ uint64_t diff_msec = diff_frames * 1000 / AudioServer::get_singleton()->get_mix_rate();
+
+ if (diff_msec < 300) {
+ uint32_t count = audio_stream->get_tagged_frame_count();
+
+ bool differ = false;
+
+ if (count != tagged_frame_offset_count) {
+ differ = true;
+ }
+ float offsets[MAX_TAGGED_FRAMES];
+
+ for (uint32_t i = 0; i < MIN(count, uint32_t(MAX_TAGGED_FRAMES)); i++) {
+ offsets[i] = audio_stream->get_tagged_frame_offset(i);
+ if (offsets[i] != tagged_frame_offsets[i]) {
+ differ = true;
+ }
+ }
+
+ if (differ) {
+ tagged_frame_offset_count = count;
+ for (uint32_t i = 0; i < count; i++) {
+ tagged_frame_offsets[i] = offsets[i];
+ }
+ }
+
+ stream_preview_rect->update();
+ } else {
+ if (tagged_frame_offset_count != 0) {
+ stream_preview_rect->update();
+ }
+ tagged_frame_offset_count = 0;
+ }
+ }
+ } break;
+ }
+}
+
+void EditorAudioStreamPicker::_update_resource() {
+ EditorResourcePicker::_update_resource();
+
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+ Ref<AudioStream> audio_stream = get_edited_resource();
+ if (audio_stream.is_valid() && audio_stream->get_length() > 0.0) {
+ set_assign_button_min_size(Size2(1, font->get_height(font_size) * 3));
+ } else {
+ set_assign_button_min_size(Size2(1, font->get_height(font_size) * 1.5));
+ }
+
+ stream_preview_rect->update();
+}
+
+void EditorAudioStreamPicker::_preview_draw() {
+ Ref<AudioStream> audio_stream = get_edited_resource();
+ if (!audio_stream.is_valid()) {
+ get_assign_button()->set_text(TTR("[empty]"));
+ return;
+ }
+
+ int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+
+ get_assign_button()->set_text("");
+
+ Size2i size = stream_preview_rect->get_size();
+ Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
+
+ Rect2 rect(Point2(), size);
+
+ if (audio_stream->get_length() > 0) {
+ rect.size.height *= 0.5;
+
+ stream_preview_rect->draw_rect(rect, Color(0, 0, 0, 1));
+
+ Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(audio_stream);
+ float preview_len = preview->get_length();
+
+ Vector<Vector2> lines;
+ lines.resize(size.width * 2);
+
+ for (int i = 0; i < size.width; i++) {
+ float ofs = i * preview_len / size.width;
+ float ofs_n = (i + 1) * preview_len / size.width;
+ float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;
+ float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5;
+
+ int idx = i;
+ lines.write[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y);
+ lines.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y);
+ }
+
+ Vector<Color> color;
+ color.push_back(get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")));
+
+ RS::get_singleton()->canvas_item_add_multiline(stream_preview_rect->get_canvas_item(), lines, color);
+
+ if (tagged_frame_offset_count) {
+ Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+
+ for (uint32_t i = 0; i < tagged_frame_offset_count; i++) {
+ int x = CLAMP(tagged_frame_offsets[i] * size.width / preview_len, 0, size.width);
+ if (x == 0) {
+ continue; // Because some may always return 0, ignore offset 0.
+ }
+ stream_preview_rect->draw_rect(Rect2i(x, 0, 2, rect.size.height), accent);
+ }
+ }
+ rect.position.y += rect.size.height;
+ }
+
+ Ref<Texture2D> icon;
+ Color icon_modulate(1, 1, 1, 1);
+
+ if (tagged_frame_offset_count > 0) {
+ icon = get_theme_icon(SNAME("Play"), SNAME("EditorIcons"));
+ if ((OS::get_singleton()->get_ticks_msec() % 500) > 250) {
+ icon_modulate = Color(1, 0.5, 0.5, 1); // get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ }
+ } else {
+ icon = EditorNode::get_singleton()->get_object_icon(audio_stream.operator->(), "Object");
+ }
+ String text;
+ if (!audio_stream->get_name().is_empty()) {
+ text = audio_stream->get_name();
+ } else if (audio_stream->get_path().is_resource_file()) {
+ text = audio_stream->get_path().get_file();
+ } else {
+ text = audio_stream->get_class().replace_first("AudioStream", "");
+ }
+
+ stream_preview_rect->draw_texture(icon, Point2i(EDSCALE * 2, rect.position.y + (rect.size.height - icon->get_height()) / 2), icon_modulate);
+ stream_preview_rect->draw_string(font, Point2i(EDSCALE * 2 + icon->get_width(), rect.position.y + font->get_ascent(font_size) + (rect.size.height - font->get_height(font_size)) / 2), text, HORIZONTAL_ALIGNMENT_CENTER, size.width - 4 * EDSCALE - icon->get_width());
+}
+
+EditorAudioStreamPicker::EditorAudioStreamPicker() :
+ EditorResourcePicker(true) {
+ stream_preview_rect = memnew(Control);
+
+ stream_preview_rect->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
+ stream_preview_rect->set_offset(SIDE_TOP, 1);
+ stream_preview_rect->set_offset(SIDE_BOTTOM, -1);
+ stream_preview_rect->set_offset(SIDE_RIGHT, -1);
+ stream_preview_rect->set_mouse_filter(MOUSE_FILTER_IGNORE);
+ stream_preview_rect->connect("draw", callable_mp(this, &EditorAudioStreamPicker::_preview_draw));
+
+ get_assign_button()->add_child(stream_preview_rect);
+ get_assign_button()->move_child(stream_preview_rect, 0);
+ set_process_internal(true);
+}
diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h
index 8e26e1f4c0..d36e742bcd 100644
--- a/editor/editor_resource_picker.h
+++ b/editor/editor_resource_picker.h
@@ -58,6 +58,8 @@ class EditorResourcePicker : public HBoxContainer {
EditorFileDialog *file_dialog = nullptr;
EditorQuickOpen *quick_open = nullptr;
+ Size2i assign_button_min_size = Size2i(1, 1);
+
enum MenuOption {
OBJ_MENU_LOAD,
OBJ_MENU_QUICKLOAD,
@@ -75,7 +77,6 @@ class EditorResourcePicker : public HBoxContainer {
PopupMenu *edit_menu = nullptr;
- void _update_resource();
void _update_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj);
void _resource_selected();
@@ -100,9 +101,17 @@ class EditorResourcePicker : public HBoxContainer {
void _ensure_resource_menu();
protected:
+ virtual void _update_resource();
+
+ Button *get_assign_button() { return assign_button; }
static void _bind_methods();
void _notification(int p_what);
+ void set_assign_button_min_size(const Size2i &p_size) {
+ assign_button_min_size = p_size;
+ assign_button->set_custom_minimum_size(assign_button_min_size);
+ }
+
GDVIRTUAL1(_set_create_options, Object *)
GDVIRTUAL1R(bool, _handle_menu_selected, int)
@@ -126,7 +135,7 @@ public:
virtual void set_create_options(Object *p_menu_node);
virtual bool handle_menu_selected(int p_which);
- EditorResourcePicker();
+ EditorResourcePicker(bool p_hide_assign_button_controls = false);
};
class EditorScriptPicker : public EditorResourcePicker {
@@ -173,4 +182,26 @@ public:
EditorShaderPicker();
};
+class EditorAudioStreamPicker : public EditorResourcePicker {
+ GDCLASS(EditorAudioStreamPicker, EditorResourcePicker);
+
+ uint64_t last_preview_version = 0;
+ Control *stream_preview_rect = nullptr;
+
+ enum {
+ MAX_TAGGED_FRAMES = 8
+ };
+ float tagged_frame_offsets[MAX_TAGGED_FRAMES];
+ uint32_t tagged_frame_offset_count = 0;
+
+ void _preview_draw();
+ virtual void _update_resource() override;
+
+protected:
+ void _notification(int p_what);
+
+public:
+ EditorAudioStreamPicker();
+};
+
#endif // EDITOR_RESOURCE_PICKER_H
diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h
index 820e22bdc8..0413477d88 100644
--- a/editor/editor_resource_preview.h
+++ b/editor/editor_resource_preview.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITORRESOURCEPREVIEW_H
-#define EDITORRESOURCEPREVIEW_H
+#ifndef EDITOR_RESOURCE_PREVIEW_H
+#define EDITOR_RESOURCE_PREVIEW_H
#include "core/os/semaphore.h"
#include "core/os/thread.h"
@@ -124,4 +124,4 @@ public:
~EditorResourcePreview();
};
-#endif // EDITORRESOURCEPREVIEW_H
+#endif // EDITOR_RESOURCE_PREVIEW_H
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index ba49c6dc5f..6ce8625daa 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -55,7 +55,7 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie) {
args.push_back("--remote-debug");
args.push_back(EditorDebuggerNode::get_singleton()->get_server_uri());
- args.push_back("--allow_focus_steal_pid");
+ args.push_back("--editor-pid");
args.push_back(itos(OS::get_singleton()->get_process_id()));
bool debug_collisions = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false);
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 854885c707..efd6c67d7a 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -30,9 +30,9 @@
#include "editor_run_native.h"
-#include "editor/editor_export.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
+#include "editor/export/editor_export_platform.h"
void EditorRunNative::_notification(int p_what) {
switch (p_what) {
diff --git a/editor/editor_scale.h b/editor/editor_scale.h
index 918fde15fb..02e9b997f6 100644
--- a/editor/editor_scale.h
+++ b/editor/editor_scale.h
@@ -35,4 +35,5 @@ void editor_set_scale(float p_scale);
float editor_get_scale();
#define EDSCALE (editor_get_scale())
+
#endif // EDITOR_SCALE_H
diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h
index babd11eb69..758efae31e 100644
--- a/editor/editor_sectioned_inspector.h
+++ b/editor/editor_sectioned_inspector.h
@@ -76,4 +76,5 @@ public:
SectionedInspector();
~SectionedInspector();
};
+
#endif // EDITOR_SECTIONED_INSPECTOR_H
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index abb1b73a18..c73caa78f3 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -544,6 +544,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/behavior/navigation/smooth_scrolling", true);
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/behavior/navigation/v_scroll_speed", 80, "1,10000,1")
_initial_set("text_editor/behavior/navigation/drag_and_drop_selection", true);
+ _initial_set("text_editor/behavior/navigation/stay_in_script_editor_on_node_selected", true);
// Behavior: Indent
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/behavior/indent/type", 0, "Tabs,Spaces")
@@ -1105,8 +1106,8 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) {
// Editor data and config directories
// EditorPaths::create() is responsible for the creation of these directories.
-String EditorSettings::get_templates_dir() const {
- return EditorPaths::get_singleton()->get_data_dir().plus_file("templates");
+String EditorSettings::get_export_templates_dir() const {
+ return EditorPaths::get_singleton()->get_data_dir().plus_file("export_templates");
}
String EditorSettings::get_project_settings_dir() const {
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index 43f90f9258..56c73685bb 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -151,7 +151,7 @@ public:
Ref<Resource> get_resource_clipboard() const { return clipboard; }
String get_data_dir() const;
- String get_templates_dir() const;
+ String get_export_templates_dir() const;
String get_project_settings_dir() const;
String get_text_editor_themes_dir() const;
String get_script_templates_dir() const;
diff --git a/editor/editor_themes.h b/editor/editor_themes.h
index 642558d774..95184b9d4a 100644
--- a/editor/editor_themes.h
+++ b/editor/editor_themes.h
@@ -40,4 +40,4 @@ Ref<Theme> create_custom_theme(Ref<Theme> p_theme = nullptr);
Ref<ImageTexture> create_unscaled_default_project_icon();
-#endif
+#endif // EDITOR_THEMES_H
diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h
index 487625e84c..6a6fca7eba 100644
--- a/editor/editor_vcs_interface.h
+++ b/editor/editor_vcs_interface.h
@@ -85,4 +85,4 @@ public:
virtual ~EditorVCSInterface();
};
-#endif // !EDITOR_VCS_INTERFACE_H
+#endif // EDITOR_VCS_INTERFACE_H
diff --git a/editor/export/SCsub b/editor/export/SCsub
new file mode 100644
index 0000000000..359d04e5df
--- /dev/null
+++ b/editor/export/SCsub
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+Import("env")
+
+env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp
new file mode 100644
index 0000000000..31f408eedb
--- /dev/null
+++ b/editor/export/editor_export.cpp
@@ -0,0 +1,355 @@
+/*************************************************************************/
+/* editor_export.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_export.h"
+
+#include "core/config/project_settings.h"
+#include "core/io/config_file.h"
+
+EditorExport *EditorExport::singleton = nullptr;
+
+void EditorExport::_save() {
+ Ref<ConfigFile> config;
+ config.instantiate();
+ for (int i = 0; i < export_presets.size(); i++) {
+ Ref<EditorExportPreset> preset = export_presets[i];
+ String section = "preset." + itos(i);
+
+ config->set_value(section, "name", preset->get_name());
+ config->set_value(section, "platform", preset->get_platform()->get_name());
+ config->set_value(section, "runnable", preset->is_runnable());
+ config->set_value(section, "custom_features", preset->get_custom_features());
+
+ bool save_files = false;
+ switch (preset->get_export_filter()) {
+ case EditorExportPreset::EXPORT_ALL_RESOURCES: {
+ config->set_value(section, "export_filter", "all_resources");
+ } break;
+ case EditorExportPreset::EXPORT_SELECTED_SCENES: {
+ config->set_value(section, "export_filter", "scenes");
+ save_files = true;
+ } break;
+ case EditorExportPreset::EXPORT_SELECTED_RESOURCES: {
+ config->set_value(section, "export_filter", "resources");
+ save_files = true;
+ } break;
+ case EditorExportPreset::EXCLUDE_SELECTED_RESOURCES: {
+ config->set_value(section, "export_filter", "exclude");
+ save_files = true;
+ } break;
+ }
+
+ if (save_files) {
+ Vector<String> export_files = preset->get_files_to_export();
+ config->set_value(section, "export_files", export_files);
+ }
+ config->set_value(section, "include_filter", preset->get_include_filter());
+ config->set_value(section, "exclude_filter", preset->get_exclude_filter());
+ config->set_value(section, "export_path", preset->get_export_path());
+ config->set_value(section, "encryption_include_filters", preset->get_enc_in_filter());
+ config->set_value(section, "encryption_exclude_filters", preset->get_enc_ex_filter());
+ config->set_value(section, "encrypt_pck", preset->get_enc_pck());
+ config->set_value(section, "encrypt_directory", preset->get_enc_directory());
+ config->set_value(section, "script_export_mode", preset->get_script_export_mode());
+ config->set_value(section, "script_encryption_key", preset->get_script_encryption_key());
+
+ String option_section = "preset." + itos(i) + ".options";
+
+ for (const PropertyInfo &E : preset->get_properties()) {
+ config->set_value(option_section, E.name, preset->get(E.name));
+ }
+ }
+
+ config->save("res://export_presets.cfg");
+}
+
+void EditorExport::save_presets() {
+ if (block_save) {
+ return;
+ }
+ save_timer->start();
+}
+
+void EditorExport::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("export_presets_updated"));
+}
+
+void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) {
+ export_platforms.push_back(p_platform);
+}
+
+int EditorExport::get_export_platform_count() {
+ return export_platforms.size();
+}
+
+Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) {
+ ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>());
+
+ return export_platforms[p_idx];
+}
+
+void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) {
+ if (p_at_pos < 0) {
+ export_presets.push_back(p_preset);
+ } else {
+ export_presets.insert(p_at_pos, p_preset);
+ }
+}
+
+String EditorExportPlatform::test_etc2() const {
+ const bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
+
+ if (!etc2_supported) {
+ return TTR("Target platform requires 'ETC2' texture compression. Enable 'Import Etc 2' in Project Settings.");
+ }
+
+ return String();
+}
+
+int EditorExport::get_export_preset_count() const {
+ return export_presets.size();
+}
+
+Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) {
+ ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>());
+ return export_presets[p_idx];
+}
+
+void EditorExport::remove_export_preset(int p_idx) {
+ export_presets.remove_at(p_idx);
+ save_presets();
+}
+
+void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
+ if (!export_plugins.has(p_plugin)) {
+ export_plugins.push_back(p_plugin);
+ }
+}
+
+void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
+ export_plugins.erase(p_plugin);
+}
+
+Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() {
+ return export_plugins;
+}
+
+void EditorExport::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ load_config();
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ update_export_presets();
+ } break;
+ }
+}
+
+void EditorExport::load_config() {
+ Ref<ConfigFile> config;
+ config.instantiate();
+ Error err = config->load("res://export_presets.cfg");
+ if (err != OK) {
+ return;
+ }
+
+ block_save = true;
+
+ int index = 0;
+ while (true) {
+ String section = "preset." + itos(index);
+ if (!config->has_section(section)) {
+ break;
+ }
+
+ String platform = config->get_value(section, "platform");
+
+ Ref<EditorExportPreset> preset;
+
+ for (int i = 0; i < export_platforms.size(); i++) {
+ if (export_platforms[i]->get_name() == platform) {
+ preset = export_platforms.write[i]->create_preset();
+ break;
+ }
+ }
+
+ if (!preset.is_valid()) {
+ index++;
+ ERR_CONTINUE(!preset.is_valid());
+ }
+
+ preset->set_name(config->get_value(section, "name"));
+ preset->set_runnable(config->get_value(section, "runnable"));
+
+ if (config->has_section_key(section, "custom_features")) {
+ preset->set_custom_features(config->get_value(section, "custom_features"));
+ }
+
+ String export_filter = config->get_value(section, "export_filter");
+
+ bool get_files = false;
+
+ if (export_filter == "all_resources") {
+ preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES);
+ } else if (export_filter == "scenes") {
+ preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES);
+ get_files = true;
+ } else if (export_filter == "resources") {
+ preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES);
+ get_files = true;
+ } else if (export_filter == "exclude") {
+ preset->set_export_filter(EditorExportPreset::EXCLUDE_SELECTED_RESOURCES);
+ get_files = true;
+ }
+
+ if (get_files) {
+ Vector<String> files = config->get_value(section, "export_files");
+
+ for (int i = 0; i < files.size(); i++) {
+ if (!FileAccess::exists(files[i])) {
+ preset->remove_export_file(files[i]);
+ } else {
+ preset->add_export_file(files[i]);
+ }
+ }
+ }
+
+ preset->set_include_filter(config->get_value(section, "include_filter"));
+ preset->set_exclude_filter(config->get_value(section, "exclude_filter"));
+ preset->set_export_path(config->get_value(section, "export_path", ""));
+
+ if (config->has_section_key(section, "encrypt_pck")) {
+ preset->set_enc_pck(config->get_value(section, "encrypt_pck"));
+ }
+ if (config->has_section_key(section, "encrypt_directory")) {
+ preset->set_enc_directory(config->get_value(section, "encrypt_directory"));
+ }
+ if (config->has_section_key(section, "encryption_include_filters")) {
+ preset->set_enc_in_filter(config->get_value(section, "encryption_include_filters"));
+ }
+ if (config->has_section_key(section, "encryption_exclude_filters")) {
+ preset->set_enc_ex_filter(config->get_value(section, "encryption_exclude_filters"));
+ }
+ if (config->has_section_key(section, "script_export_mode")) {
+ preset->set_script_export_mode(config->get_value(section, "script_export_mode"));
+ }
+ if (config->has_section_key(section, "script_encryption_key")) {
+ preset->set_script_encryption_key(config->get_value(section, "script_encryption_key"));
+ }
+
+ String option_section = "preset." + itos(index) + ".options";
+
+ List<String> options;
+
+ config->get_section_keys(option_section, &options);
+
+ for (const String &E : options) {
+ Variant value = config->get_value(option_section, E);
+
+ preset->set(E, value);
+ }
+
+ add_export_preset(preset);
+ index++;
+ }
+
+ block_save = false;
+}
+
+void EditorExport::update_export_presets() {
+ HashMap<StringName, List<EditorExportPlatform::ExportOption>> platform_options;
+
+ for (int i = 0; i < export_platforms.size(); i++) {
+ Ref<EditorExportPlatform> platform = export_platforms[i];
+
+ if (platform->should_update_export_options()) {
+ List<EditorExportPlatform::ExportOption> options;
+ platform->get_export_options(&options);
+
+ platform_options[platform->get_name()] = options;
+ }
+ }
+
+ bool export_presets_updated = false;
+ for (int i = 0; i < export_presets.size(); i++) {
+ Ref<EditorExportPreset> preset = export_presets[i];
+ if (platform_options.has(preset->get_platform()->get_name())) {
+ export_presets_updated = true;
+
+ List<EditorExportPlatform::ExportOption> options = platform_options[preset->get_platform()->get_name()];
+
+ // Copy the previous preset values
+ HashMap<StringName, Variant> previous_values = preset->values;
+
+ // Clear the preset properties and values prior to reloading
+ preset->properties.clear();
+ preset->values.clear();
+
+ for (const EditorExportPlatform::ExportOption &E : options) {
+ preset->properties.push_back(E.option);
+
+ StringName option_name = E.option.name;
+ preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value;
+ }
+ }
+ }
+
+ if (export_presets_updated) {
+ emit_signal(_export_presets_updated);
+ }
+}
+
+bool EditorExport::poll_export_platforms() {
+ bool changed = false;
+ for (int i = 0; i < export_platforms.size(); i++) {
+ if (export_platforms.write[i]->poll_export()) {
+ changed = true;
+ }
+ }
+
+ return changed;
+}
+
+EditorExport::EditorExport() {
+ save_timer = memnew(Timer);
+ add_child(save_timer);
+ save_timer->set_wait_time(0.8);
+ save_timer->set_one_shot(true);
+ save_timer->connect("timeout", callable_mp(this, &EditorExport::_save));
+
+ _export_presets_updated = "export_presets_updated";
+
+ singleton = this;
+ set_process(true);
+}
+
+EditorExport::~EditorExport() {
+}
diff --git a/editor/export/editor_export.h b/editor/export/editor_export.h
new file mode 100644
index 0000000000..13c3c34cea
--- /dev/null
+++ b/editor/export/editor_export.h
@@ -0,0 +1,84 @@
+/*************************************************************************/
+/* editor_export.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_EXPORT_H
+#define EDITOR_EXPORT_H
+
+#include "editor_export_platform.h"
+#include "editor_export_plugin.h"
+
+class EditorExport : public Node {
+ GDCLASS(EditorExport, Node);
+
+ Vector<Ref<EditorExportPlatform>> export_platforms;
+ Vector<Ref<EditorExportPreset>> export_presets;
+ Vector<Ref<EditorExportPlugin>> export_plugins;
+
+ StringName _export_presets_updated;
+
+ Timer *save_timer = nullptr;
+ bool block_save = false;
+
+ static EditorExport *singleton;
+
+ void _save();
+
+protected:
+ friend class EditorExportPreset;
+ void save_presets();
+
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ static EditorExport *get_singleton() { return singleton; }
+
+ void add_export_platform(const Ref<EditorExportPlatform> &p_platform);
+ int get_export_platform_count();
+ Ref<EditorExportPlatform> get_export_platform(int p_idx);
+
+ void add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos = -1);
+ int get_export_preset_count() const;
+ Ref<EditorExportPreset> get_export_preset(int p_idx);
+ void remove_export_preset(int p_idx);
+
+ void add_export_plugin(const Ref<EditorExportPlugin> &p_plugin);
+ void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin);
+ Vector<Ref<EditorExportPlugin>> get_export_plugins();
+
+ void load_config();
+ void update_export_presets();
+ bool poll_export_platforms();
+
+ EditorExport();
+ ~EditorExport();
+};
+
+#endif // EDITOR_EXPORT_H
diff --git a/editor/editor_export.cpp b/editor/export/editor_export_platform.cpp
index e32d4f7e9c..9f64b241c6 100644
--- a/editor/editor_export.cpp
+++ b/editor/export/editor_export_platform.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* editor_export.cpp */
+/* editor_export_platform.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,28 +28,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "editor_export.h"
+#include "editor_export_platform.h"
#include "core/config/project_settings.h"
#include "core/crypto/crypto_core.h"
#include "core/extension/native_extension.h"
-#include "core/io/config_file.h"
-#include "core/io/dir_access.h"
-#include "core/io/file_access.h"
#include "core/io/file_access_encrypted.h"
#include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION
-#include "core/io/resource_loader.h"
-#include "core/io/resource_saver.h"
#include "core/io/zip_io.h"
-#include "core/object/script_language.h"
#include "core/version.h"
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
-#include "editor/editor_settings.h"
#include "editor/plugins/script_editor_plugin.h"
-#include "scene/resources/resource_format_text.h"
+#include "editor_export_plugin.h"
static int _get_pad(int p_alignment, int p_n) {
int rest = p_n % p_alignment;
@@ -63,196 +56,6 @@ static int _get_pad(int p_alignment, int p_n) {
#define PCK_PADDING 16
-bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) {
- if (values.has(p_name)) {
- values[p_name] = p_value;
- EditorExport::singleton->save_presets();
- return true;
- }
-
- return false;
-}
-
-bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
- if (values.has(p_name)) {
- r_ret = values[p_name];
- return true;
- }
-
- return false;
-}
-
-void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
- for (const PropertyInfo &E : properties) {
- if (platform->get_export_option_visibility(E.name, values)) {
- p_list->push_back(E);
- }
- }
-}
-
-Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
- return platform;
-}
-
-void EditorExportPreset::update_files_to_export() {
- Vector<String> to_remove;
- for (const String &E : selected_files) {
- if (!FileAccess::exists(E)) {
- to_remove.push_back(E);
- }
- }
- for (int i = 0; i < to_remove.size(); ++i) {
- selected_files.erase(to_remove[i]);
- }
-}
-
-Vector<String> EditorExportPreset::get_files_to_export() const {
- Vector<String> files;
- for (const String &E : selected_files) {
- files.push_back(E);
- }
- return files;
-}
-
-void EditorExportPreset::set_name(const String &p_name) {
- name = p_name;
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_name() const {
- return name;
-}
-
-void EditorExportPreset::set_runnable(bool p_enable) {
- runnable = p_enable;
- EditorExport::singleton->save_presets();
-}
-
-bool EditorExportPreset::is_runnable() const {
- return runnable;
-}
-
-void EditorExportPreset::set_export_filter(ExportFilter p_filter) {
- export_filter = p_filter;
- EditorExport::singleton->save_presets();
-}
-
-EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const {
- return export_filter;
-}
-
-void EditorExportPreset::set_include_filter(const String &p_include) {
- include_filter = p_include;
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_include_filter() const {
- return include_filter;
-}
-
-void EditorExportPreset::set_export_path(const String &p_path) {
- export_path = p_path;
- /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path,
- * this should be removed. */
- if (export_path.is_absolute_path()) {
- String res_path = OS::get_singleton()->get_resource_dir();
- export_path = res_path.path_to_file(export_path);
- }
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_export_path() const {
- return export_path;
-}
-
-void EditorExportPreset::set_exclude_filter(const String &p_exclude) {
- exclude_filter = p_exclude;
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_exclude_filter() const {
- return exclude_filter;
-}
-
-void EditorExportPreset::add_export_file(const String &p_path) {
- selected_files.insert(p_path);
- EditorExport::singleton->save_presets();
-}
-
-void EditorExportPreset::remove_export_file(const String &p_path) {
- selected_files.erase(p_path);
- EditorExport::singleton->save_presets();
-}
-
-bool EditorExportPreset::has_export_file(const String &p_path) {
- return selected_files.has(p_path);
-}
-
-void EditorExportPreset::set_custom_features(const String &p_custom_features) {
- custom_features = p_custom_features;
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_custom_features() const {
- return custom_features;
-}
-
-void EditorExportPreset::set_enc_in_filter(const String &p_filter) {
- enc_in_filters = p_filter;
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_enc_in_filter() const {
- return enc_in_filters;
-}
-
-void EditorExportPreset::set_enc_ex_filter(const String &p_filter) {
- enc_ex_filters = p_filter;
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_enc_ex_filter() const {
- return enc_ex_filters;
-}
-
-void EditorExportPreset::set_enc_pck(bool p_enabled) {
- enc_pck = p_enabled;
- EditorExport::singleton->save_presets();
-}
-
-bool EditorExportPreset::get_enc_pck() const {
- return enc_pck;
-}
-
-void EditorExportPreset::set_enc_directory(bool p_enabled) {
- enc_directory = p_enabled;
- EditorExport::singleton->save_presets();
-}
-
-bool EditorExportPreset::get_enc_directory() const {
- return enc_directory;
-}
-
-void EditorExportPreset::set_script_export_mode(int p_mode) {
- script_mode = p_mode;
- EditorExport::singleton->save_presets();
-}
-
-int EditorExportPreset::get_script_export_mode() const {
- return script_mode;
-}
-
-void EditorExportPreset::set_script_encryption_key(const String &p_key) {
- script_key = p_key;
- EditorExport::singleton->save_presets();
-}
-
-String EditorExportPreset::get_script_encryption_key() const {
- return script_key;
-}
-
-///////////////////////////////////
-
bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err) {
bool has_messages = false;
@@ -272,7 +75,7 @@ bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err)
} else {
p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER);
p_log->add_text(" ");
- p_log->add_text(TTR("Completed successfully."));
+ p_log->add_text(TTR("Completed sucessfully."));
if (msg_count > 0) {
has_messages = true;
}
@@ -491,7 +294,7 @@ Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const {
String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
String current_version = VERSION_FULL_CONFIG;
- String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(current_version).plus_file(template_file_name);
+ String template_path = EditorSettings::get_singleton()->get_export_templates_dir().plus_file(current_version).plus_file(template_file_name);
if (FileAccess::exists(template_path)) {
return template_path;
@@ -625,138 +428,6 @@ void EditorExportPlatform::_edit_filter_list(HashSet<String> &r_list, const Stri
_edit_files_with_filter(da, filters, r_list, exclude);
}
-void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) {
- if (p_preset.is_valid()) {
- export_preset = p_preset;
- }
-}
-
-Ref<EditorExportPreset> EditorExportPlugin::get_export_preset() const {
- return export_preset;
-}
-
-void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) {
- ExtraFile ef;
- ef.data = p_file;
- ef.path = p_path;
- ef.remap = p_remap;
- extra_files.push_back(ef);
-}
-
-void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &p_tags, const String &p_target) {
- shared_objects.push_back(SharedObject(p_path, p_tags, p_target));
-}
-
-void EditorExportPlugin::add_ios_framework(const String &p_path) {
- ios_frameworks.push_back(p_path);
-}
-
-void EditorExportPlugin::add_ios_embedded_framework(const String &p_path) {
- ios_embedded_frameworks.push_back(p_path);
-}
-
-Vector<String> EditorExportPlugin::get_ios_frameworks() const {
- return ios_frameworks;
-}
-
-Vector<String> EditorExportPlugin::get_ios_embedded_frameworks() const {
- return ios_embedded_frameworks;
-}
-
-void EditorExportPlugin::add_ios_plist_content(const String &p_plist_content) {
- ios_plist_content += p_plist_content + "\n";
-}
-
-String EditorExportPlugin::get_ios_plist_content() const {
- return ios_plist_content;
-}
-
-void EditorExportPlugin::add_ios_linker_flags(const String &p_flags) {
- if (ios_linker_flags.length() > 0) {
- ios_linker_flags += ' ';
- }
- ios_linker_flags += p_flags;
-}
-
-String EditorExportPlugin::get_ios_linker_flags() const {
- return ios_linker_flags;
-}
-
-void EditorExportPlugin::add_ios_bundle_file(const String &p_path) {
- ios_bundle_files.push_back(p_path);
-}
-
-Vector<String> EditorExportPlugin::get_ios_bundle_files() const {
- return ios_bundle_files;
-}
-
-void EditorExportPlugin::add_ios_cpp_code(const String &p_code) {
- ios_cpp_code += p_code;
-}
-
-String EditorExportPlugin::get_ios_cpp_code() const {
- return ios_cpp_code;
-}
-
-void EditorExportPlugin::add_macos_plugin_file(const String &p_path) {
- macos_plugin_files.push_back(p_path);
-}
-
-const Vector<String> &EditorExportPlugin::get_macos_plugin_files() const {
- return macos_plugin_files;
-}
-
-void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) {
- ios_project_static_libs.push_back(p_path);
-}
-
-Vector<String> EditorExportPlugin::get_ios_project_static_libs() const {
- return ios_project_static_libs;
-}
-
-void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) {
- GDVIRTUAL_CALL(_export_file, p_path, p_type, p_features);
-}
-
-void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
- GDVIRTUAL_CALL(_export_begin, p_features, p_debug, p_path, p_flags);
-}
-
-void EditorExportPlugin::_export_end_script() {
- GDVIRTUAL_CALL(_export_end);
-}
-
-void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) {
-}
-
-void EditorExportPlugin::_export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
-}
-
-void EditorExportPlugin::skip() {
- skipped = true;
-}
-
-void EditorExportPlugin::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags", "target"), &EditorExportPlugin::add_shared_object);
- ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib);
- ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file);
- ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework);
- ClassDB::bind_method(D_METHOD("add_ios_embedded_framework", "path"), &EditorExportPlugin::add_ios_embedded_framework);
- ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content);
- ClassDB::bind_method(D_METHOD("add_ios_linker_flags", "flags"), &EditorExportPlugin::add_ios_linker_flags);
- ClassDB::bind_method(D_METHOD("add_ios_bundle_file", "path"), &EditorExportPlugin::add_ios_bundle_file);
- ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code);
- ClassDB::bind_method(D_METHOD("add_macos_plugin_file", "path"), &EditorExportPlugin::add_macos_plugin_file);
- ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip);
-
- GDVIRTUAL_BIND(_export_file, "path", "type", "features");
- GDVIRTUAL_BIND(_export_begin, "features", "is_debug", "path", "flags");
- GDVIRTUAL_BIND(_export_end);
-}
-
-EditorExportPlugin::EditorExportPlugin() {
-}
-
EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) {
Ref<EditorExportPlatform> platform = p_preset->get_platform();
List<String> feature_list;
@@ -1504,573 +1175,3 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
EditorExportPlatform::EditorExportPlatform() {
}
-
-////
-
-EditorExport *EditorExport::singleton = nullptr;
-
-void EditorExport::_save() {
- Ref<ConfigFile> config;
- config.instantiate();
- for (int i = 0; i < export_presets.size(); i++) {
- Ref<EditorExportPreset> preset = export_presets[i];
- String section = "preset." + itos(i);
-
- config->set_value(section, "name", preset->get_name());
- config->set_value(section, "platform", preset->get_platform()->get_name());
- config->set_value(section, "runnable", preset->is_runnable());
- config->set_value(section, "custom_features", preset->get_custom_features());
-
- bool save_files = false;
- switch (preset->get_export_filter()) {
- case EditorExportPreset::EXPORT_ALL_RESOURCES: {
- config->set_value(section, "export_filter", "all_resources");
- } break;
- case EditorExportPreset::EXPORT_SELECTED_SCENES: {
- config->set_value(section, "export_filter", "scenes");
- save_files = true;
- } break;
- case EditorExportPreset::EXPORT_SELECTED_RESOURCES: {
- config->set_value(section, "export_filter", "resources");
- save_files = true;
- } break;
- case EditorExportPreset::EXCLUDE_SELECTED_RESOURCES: {
- config->set_value(section, "export_filter", "exclude");
- save_files = true;
- } break;
- }
-
- if (save_files) {
- Vector<String> export_files = preset->get_files_to_export();
- config->set_value(section, "export_files", export_files);
- }
- config->set_value(section, "include_filter", preset->get_include_filter());
- config->set_value(section, "exclude_filter", preset->get_exclude_filter());
- config->set_value(section, "export_path", preset->get_export_path());
- config->set_value(section, "encryption_include_filters", preset->get_enc_in_filter());
- config->set_value(section, "encryption_exclude_filters", preset->get_enc_ex_filter());
- config->set_value(section, "encrypt_pck", preset->get_enc_pck());
- config->set_value(section, "encrypt_directory", preset->get_enc_directory());
- config->set_value(section, "script_export_mode", preset->get_script_export_mode());
- config->set_value(section, "script_encryption_key", preset->get_script_encryption_key());
-
- String option_section = "preset." + itos(i) + ".options";
-
- for (const PropertyInfo &E : preset->get_properties()) {
- config->set_value(option_section, E.name, preset->get(E.name));
- }
- }
-
- config->save("res://export_presets.cfg");
-}
-
-void EditorExport::save_presets() {
- if (block_save) {
- return;
- }
- save_timer->start();
-}
-
-void EditorExport::_bind_methods() {
- ADD_SIGNAL(MethodInfo("export_presets_updated"));
-}
-
-void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) {
- export_platforms.push_back(p_platform);
-}
-
-int EditorExport::get_export_platform_count() {
- return export_platforms.size();
-}
-
-Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>());
-
- return export_platforms[p_idx];
-}
-
-void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) {
- if (p_at_pos < 0) {
- export_presets.push_back(p_preset);
- } else {
- export_presets.insert(p_at_pos, p_preset);
- }
-}
-
-String EditorExportPlatform::test_etc2() const {
- const bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
-
- if (!etc2_supported) {
- return TTR("Target platform requires 'ETC2' texture compression. Enable 'Import Etc 2' in Project Settings.");
- }
-
- return String();
-}
-
-int EditorExport::get_export_preset_count() const {
- return export_presets.size();
-}
-
-Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>());
- return export_presets[p_idx];
-}
-
-void EditorExport::remove_export_preset(int p_idx) {
- export_presets.remove_at(p_idx);
- save_presets();
-}
-
-void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
- if (!export_plugins.has(p_plugin)) {
- export_plugins.push_back(p_plugin);
- }
-}
-
-void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
- export_plugins.erase(p_plugin);
-}
-
-Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() {
- return export_plugins;
-}
-
-void EditorExport::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
- load_config();
- } break;
-
- case NOTIFICATION_PROCESS: {
- update_export_presets();
- } break;
- }
-}
-
-void EditorExport::load_config() {
- Ref<ConfigFile> config;
- config.instantiate();
- Error err = config->load("res://export_presets.cfg");
- if (err != OK) {
- return;
- }
-
- block_save = true;
-
- int index = 0;
- while (true) {
- String section = "preset." + itos(index);
- if (!config->has_section(section)) {
- break;
- }
-
- String platform = config->get_value(section, "platform");
-
- Ref<EditorExportPreset> preset;
-
- for (int i = 0; i < export_platforms.size(); i++) {
- if (export_platforms[i]->get_name() == platform) {
- preset = export_platforms.write[i]->create_preset();
- break;
- }
- }
-
- if (!preset.is_valid()) {
- index++;
- ERR_CONTINUE(!preset.is_valid());
- }
-
- preset->set_name(config->get_value(section, "name"));
- preset->set_runnable(config->get_value(section, "runnable"));
-
- if (config->has_section_key(section, "custom_features")) {
- preset->set_custom_features(config->get_value(section, "custom_features"));
- }
-
- String export_filter = config->get_value(section, "export_filter");
-
- bool get_files = false;
-
- if (export_filter == "all_resources") {
- preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES);
- } else if (export_filter == "scenes") {
- preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES);
- get_files = true;
- } else if (export_filter == "resources") {
- preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES);
- get_files = true;
- } else if (export_filter == "exclude") {
- preset->set_export_filter(EditorExportPreset::EXCLUDE_SELECTED_RESOURCES);
- get_files = true;
- }
-
- if (get_files) {
- Vector<String> files = config->get_value(section, "export_files");
-
- for (int i = 0; i < files.size(); i++) {
- if (!FileAccess::exists(files[i])) {
- preset->remove_export_file(files[i]);
- } else {
- preset->add_export_file(files[i]);
- }
- }
- }
-
- preset->set_include_filter(config->get_value(section, "include_filter"));
- preset->set_exclude_filter(config->get_value(section, "exclude_filter"));
- preset->set_export_path(config->get_value(section, "export_path", ""));
-
- if (config->has_section_key(section, "encrypt_pck")) {
- preset->set_enc_pck(config->get_value(section, "encrypt_pck"));
- }
- if (config->has_section_key(section, "encrypt_directory")) {
- preset->set_enc_directory(config->get_value(section, "encrypt_directory"));
- }
- if (config->has_section_key(section, "encryption_include_filters")) {
- preset->set_enc_in_filter(config->get_value(section, "encryption_include_filters"));
- }
- if (config->has_section_key(section, "encryption_exclude_filters")) {
- preset->set_enc_ex_filter(config->get_value(section, "encryption_exclude_filters"));
- }
- if (config->has_section_key(section, "script_export_mode")) {
- preset->set_script_export_mode(config->get_value(section, "script_export_mode"));
- }
- if (config->has_section_key(section, "script_encryption_key")) {
- preset->set_script_encryption_key(config->get_value(section, "script_encryption_key"));
- }
-
- String option_section = "preset." + itos(index) + ".options";
-
- List<String> options;
-
- config->get_section_keys(option_section, &options);
-
- for (const String &E : options) {
- Variant value = config->get_value(option_section, E);
-
- preset->set(E, value);
- }
-
- add_export_preset(preset);
- index++;
- }
-
- block_save = false;
-}
-
-void EditorExport::update_export_presets() {
- HashMap<StringName, List<EditorExportPlatform::ExportOption>> platform_options;
-
- for (int i = 0; i < export_platforms.size(); i++) {
- Ref<EditorExportPlatform> platform = export_platforms[i];
-
- if (platform->should_update_export_options()) {
- List<EditorExportPlatform::ExportOption> options;
- platform->get_export_options(&options);
-
- platform_options[platform->get_name()] = options;
- }
- }
-
- bool export_presets_updated = false;
- for (int i = 0; i < export_presets.size(); i++) {
- Ref<EditorExportPreset> preset = export_presets[i];
- if (platform_options.has(preset->get_platform()->get_name())) {
- export_presets_updated = true;
-
- List<EditorExportPlatform::ExportOption> options = platform_options[preset->get_platform()->get_name()];
-
- // Copy the previous preset values
- HashMap<StringName, Variant> previous_values = preset->values;
-
- // Clear the preset properties and values prior to reloading
- preset->properties.clear();
- preset->values.clear();
-
- for (const EditorExportPlatform::ExportOption &E : options) {
- preset->properties.push_back(E.option);
-
- StringName option_name = E.option.name;
- preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value;
- }
- }
- }
-
- if (export_presets_updated) {
- emit_signal(_export_presets_updated);
- }
-}
-
-bool EditorExport::poll_export_platforms() {
- bool changed = false;
- for (int i = 0; i < export_platforms.size(); i++) {
- if (export_platforms.write[i]->poll_export()) {
- changed = true;
- }
- }
-
- return changed;
-}
-
-EditorExport::EditorExport() {
- save_timer = memnew(Timer);
- add_child(save_timer);
- save_timer->set_wait_time(0.8);
- save_timer->set_one_shot(true);
- save_timer->connect("timeout", callable_mp(this, &EditorExport::_save));
-
- _export_presets_updated = "export_presets_updated";
-
- singleton = this;
- set_process(true);
-}
-
-EditorExport::~EditorExport() {
-}
-
-//////////
-
-void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
- if (p_preset->get("texture_format/s3tc")) {
- r_features->push_back("s3tc");
- }
- if (p_preset->get("texture_format/etc")) {
- r_features->push_back("etc");
- }
- if (p_preset->get("texture_format/etc2")) {
- r_features->push_back("etc2");
- }
-
- if (p_preset->get("binary_format/64_bits")) {
- r_features->push_back("64");
- } else {
- r_features->push_back("32");
- }
-}
-
-void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
- String ext_filter = (get_os_name() == "Windows") ? "*.exe" : "";
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, ext_filter), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, ext_filter), ""));
-
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1));
-
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/embed_pck"), false));
-
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/no_bptc_fallbacks"), true));
-}
-
-String EditorExportPlatformPC::get_name() const {
- return name;
-}
-
-String EditorExportPlatformPC::get_os_name() const {
- return os_name;
-}
-
-Ref<Texture2D> EditorExportPlatformPC::get_logo() const {
- return logo;
-}
-
-bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
- String err;
- bool valid = false;
-
- // Look for export templates (first official, and if defined custom templates).
-
- bool use64 = p_preset->get("binary_format/64_bits");
- bool dvalid = exists_export_template(get_template_file_name("debug", use64 ? "64" : "32"), &err);
- bool rvalid = exists_export_template(get_template_file_name("release", use64 ? "64" : "32"), &err);
-
- if (p_preset->get("custom_template/debug") != "") {
- dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
- if (!dvalid) {
- err += TTR("Custom debug template not found.") + "\n";
- }
- }
- if (p_preset->get("custom_template/release") != "") {
- rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
- if (!rvalid) {
- err += TTR("Custom release template not found.") + "\n";
- }
- }
-
- valid = dvalid || rvalid;
- r_missing_templates = !valid;
-
- if (!err.is_empty()) {
- r_error = err;
- }
- return valid;
-}
-
-Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
- ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
-
- Error err = prepare_template(p_preset, p_debug, p_path, p_flags);
- if (err == OK) {
- err = modify_template(p_preset, p_debug, p_path, p_flags);
- }
- if (err == OK) {
- err = export_project_data(p_preset, p_debug, p_path, p_flags);
- }
-
- return err;
-}
-
-Error EditorExportPlatformPC::prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
- if (!DirAccess::exists(p_path.get_base_dir())) {
- add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("The given export path doesn't exist."));
- return ERR_FILE_BAD_PATH;
- }
-
- String custom_debug = p_preset->get("custom_template/debug");
- String custom_release = p_preset->get("custom_template/release");
-
- String template_path = p_debug ? custom_debug : custom_release;
-
- template_path = template_path.strip_edges();
-
- if (template_path.is_empty()) {
- template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", p_preset->get("binary_format/64_bits") ? "64" : "32"));
- }
-
- if (!template_path.is_empty() && !FileAccess::exists(template_path)) {
- add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), vformat(TTR("Template file not found: \"%s\"."), template_path));
- return ERR_FILE_NOT_FOUND;
- }
-
- Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- da->make_dir_recursive(p_path.get_base_dir());
- Error err = da->copy(template_path, p_path, get_chmod_flags());
- if (err != OK) {
- add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("Failed to copy export template."));
- }
-
- return err;
-}
-
-Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
- String pck_path;
- if (p_preset->get("binary_format/embed_pck")) {
- pck_path = p_path;
- } else {
- pck_path = p_path.get_basename() + ".pck";
- }
-
- Vector<SharedObject> so_files;
-
- int64_t embedded_pos;
- int64_t embedded_size;
- Error err = save_pack(p_preset, p_debug, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size);
- if (err == OK && p_preset->get("binary_format/embed_pck")) {
- if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) {
- add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."));
- return ERR_INVALID_PARAMETER;
- }
-
- err = fixup_embedded_pck(p_path, embedded_pos, embedded_size);
- }
-
- if (err == OK && !so_files.is_empty()) {
- // If shared object files, copy them.
- Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- for (int i = 0; i < so_files.size() && err == OK; i++) {
- String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path);
- String target_path;
- if (so_files[i].target.is_empty()) {
- target_path = p_path.get_base_dir().plus_file(src_path.get_file());
- } else {
- target_path = p_path.get_base_dir().plus_file(so_files[i].target).plus_file(src_path.get_file());
- }
-
- if (da->dir_exists(src_path)) {
- err = da->make_dir_recursive(target_path);
- if (err == OK) {
- err = da->copy_dir(src_path, target_path, -1, true);
- }
- } else {
- err = da->copy(src_path, target_path);
- if (err == OK) {
- err = sign_shared_object(p_preset, p_debug, target_path);
- }
- }
- }
- }
-
- return err;
-}
-
-Error EditorExportPlatformPC::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {
- return OK;
-}
-
-void EditorExportPlatformPC::set_name(const String &p_name) {
- name = p_name;
-}
-
-void EditorExportPlatformPC::set_os_name(const String &p_name) {
- os_name = p_name;
-}
-
-void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) {
- logo = p_logo;
-}
-
-void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
- r_features->push_back("pc"); //all pcs support "pc"
- r_features->push_back("s3tc"); //all pcs support "s3tc" compression
- r_features->push_back(get_os_name().to_lower()); //OS name is a feature
-}
-
-void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) {
- if (p_features.has("bptc")) {
- if (p_preset->has("texture_format/no_bptc_fallbacks")) {
- p_features.erase("s3tc");
- }
- }
-}
-
-int EditorExportPlatformPC::get_chmod_flags() const {
- return chmod_flags;
-}
-
-void EditorExportPlatformPC::set_chmod_flags(int p_flags) {
- chmod_flags = p_flags;
-}
-
-///////////////////////
-
-void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) {
- String extension = p_path.get_extension().to_lower();
- if (extension != "tres" && extension != "tscn") {
- return;
- }
-
- bool convert = GLOBAL_GET("editor/export/convert_text_resources_to_binary");
- if (!convert) {
- return;
- }
- String tmp_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpfile.res");
- Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path);
- if (err != OK) {
- DirAccess::remove_file_or_error(tmp_path);
- ERR_FAIL();
- }
- Vector<uint8_t> data = FileAccess::get_file_as_array(tmp_path);
- if (data.size() == 0) {
- DirAccess::remove_file_or_error(tmp_path);
- ERR_FAIL();
- }
- DirAccess::remove_file_or_error(tmp_path);
- add_file(p_path + ".converted.res", data, true);
-}
-
-EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() {
- GLOBAL_DEF("editor/export/convert_text_resources_to_binary", false);
-}
diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h
new file mode 100644
index 0000000000..2778a217b0
--- /dev/null
+++ b/editor/export/editor_export_platform.h
@@ -0,0 +1,221 @@
+/*************************************************************************/
+/* editor_export_platform.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_EXPORT_PLATFORM_H
+#define EDITOR_EXPORT_PLATFORM_H
+
+class EditorFileSystemDirectory;
+struct EditorProgress;
+
+#include "core/io/dir_access.h"
+#include "editor_export_preset.h"
+#include "editor_export_shared_object.h"
+#include "scene/gui/rich_text_label.h"
+#include "scene/main/node.h"
+
+class EditorExportPlatform : public RefCounted {
+ GDCLASS(EditorExportPlatform, RefCounted);
+
+public:
+ typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
+ typedef Error (*EditorExportSaveSharedObject)(void *p_userdata, const SharedObject &p_so);
+
+ enum ExportMessageType {
+ EXPORT_MESSAGE_NONE,
+ EXPORT_MESSAGE_INFO,
+ EXPORT_MESSAGE_WARNING,
+ EXPORT_MESSAGE_ERROR,
+ };
+
+ struct ExportMessage {
+ ExportMessageType msg_type;
+ String category;
+ String text;
+ };
+
+private:
+ struct SavedData {
+ uint64_t ofs = 0;
+ uint64_t size = 0;
+ bool encrypted = false;
+ Vector<uint8_t> md5;
+ CharString path_utf8;
+
+ bool operator<(const SavedData &p_data) const {
+ return path_utf8 < p_data.path_utf8;
+ }
+ };
+
+ struct PackData {
+ Ref<FileAccess> f;
+ Vector<SavedData> file_ofs;
+ EditorProgress *ep = nullptr;
+ Vector<SharedObject> *so_files = nullptr;
+ };
+
+ struct ZipData {
+ void *zip = nullptr;
+ EditorProgress *ep = nullptr;
+ };
+
+ struct FeatureContainers {
+ HashSet<String> features;
+ Vector<String> features_pv;
+ };
+
+ Vector<ExportMessage> messages;
+
+ void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths);
+ void _export_find_dependencies(const String &p_path, HashSet<String> &p_paths);
+
+ void gen_debug_flags(Vector<String> &r_flags, int p_flags);
+ static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
+ static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
+
+ void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude);
+ void _edit_filter_list(HashSet<String> &r_list, const String &p_filter, bool exclude);
+
+ static Error _add_shared_object(void *p_userdata, const SharedObject &p_so);
+
+protected:
+ struct ExportNotifier {
+ ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags);
+ ~ExportNotifier();
+ };
+
+ FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug);
+
+ bool exists_export_template(String template_file_name, String *err) const;
+ String find_export_template(String template_file_name, String *err = nullptr) const;
+ void gen_export_flags(Vector<String> &r_flags, int p_flags);
+
+public:
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
+
+ struct ExportOption {
+ PropertyInfo option;
+ Variant default_value;
+
+ ExportOption(const PropertyInfo &p_info, const Variant &p_default) :
+ option(p_info),
+ default_value(p_default) {
+ }
+ ExportOption() {}
+ };
+
+ virtual Ref<EditorExportPreset> create_preset();
+
+ virtual void clear_messages() { messages.clear(); }
+ virtual void add_message(ExportMessageType p_type, const String &p_category, const String &p_message) {
+ ExportMessage msg;
+ msg.category = p_category;
+ msg.text = p_message;
+ msg.msg_type = p_type;
+ messages.push_back(msg);
+ switch (p_type) {
+ case EXPORT_MESSAGE_INFO: {
+ print_line(vformat("%s: %s\n", msg.category, msg.text));
+ } break;
+ case EXPORT_MESSAGE_WARNING: {
+ WARN_PRINT(vformat("%s: %s\n", msg.category, msg.text));
+ } break;
+ case EXPORT_MESSAGE_ERROR: {
+ ERR_PRINT(vformat("%s: %s\n", msg.category, msg.text));
+ } break;
+ default:
+ break;
+ }
+ }
+
+ virtual int get_message_count() const {
+ return messages.size();
+ }
+
+ virtual ExportMessage get_message(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, messages.size(), ExportMessage());
+ return messages[p_index];
+ }
+
+ virtual ExportMessageType get_worst_message_type() const {
+ ExportMessageType worst_type = EXPORT_MESSAGE_NONE;
+ for (int i = 0; i < messages.size(); i++) {
+ worst_type = MAX(worst_type, messages[i].msg_type);
+ }
+ return worst_type;
+ }
+
+ virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err);
+
+ virtual void get_export_options(List<ExportOption> *r_options) = 0;
+ virtual bool should_update_export_options() { return false; }
+ virtual bool get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; }
+
+ virtual String get_os_name() const = 0;
+ virtual String get_name() const = 0;
+ virtual Ref<Texture2D> get_logo() const = 0;
+
+ Error export_project_files(const Ref<EditorExportPreset> &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr);
+
+ Error save_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr);
+ Error save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path);
+
+ virtual bool poll_export() { return false; }
+ virtual int get_options_count() const { return 0; }
+ virtual String get_options_tooltip() const { return ""; }
+ virtual Ref<ImageTexture> get_option_icon(int p_index) const;
+ virtual String get_option_label(int p_device) const { return ""; }
+ virtual String get_option_tooltip(int p_device) const { return ""; }
+
+ enum DebugFlags {
+ DEBUG_FLAG_DUMB_CLIENT = 1,
+ DEBUG_FLAG_REMOTE_DEBUG = 2,
+ DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST = 4,
+ DEBUG_FLAG_VIEW_COLLISONS = 8,
+ DEBUG_FLAG_VIEW_NAVIGATION = 16,
+ };
+
+ virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; }
+ virtual Ref<Texture2D> get_run_icon() const { return get_logo(); }
+
+ String test_etc2() const;
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
+
+ virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const = 0;
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0;
+ virtual Error export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
+ virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
+ virtual void get_platform_features(List<String> *r_features) = 0;
+ virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) = 0;
+ virtual String get_debug_protocol() const { return "tcp://"; }
+
+ EditorExportPlatform();
+};
+
+#endif // EDITOR_EXPORT_PLATFORM_H
diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp
new file mode 100644
index 0000000000..b60fba13ed
--- /dev/null
+++ b/editor/export/editor_export_platform_pc.cpp
@@ -0,0 +1,247 @@
+/*************************************************************************/
+/* editor_export_platform_pc.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_export_platform_pc.h"
+
+#include "core/config/project_settings.h"
+
+void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
+ if (p_preset->get("texture_format/s3tc")) {
+ r_features->push_back("s3tc");
+ }
+ if (p_preset->get("texture_format/etc")) {
+ r_features->push_back("etc");
+ }
+ if (p_preset->get("texture_format/etc2")) {
+ r_features->push_back("etc2");
+ }
+
+ if (p_preset->get("binary_format/64_bits")) {
+ r_features->push_back("64");
+ } else {
+ r_features->push_back("32");
+ }
+}
+
+void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
+ String ext_filter = (get_os_name() == "Windows") ? "*.exe" : "";
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, ext_filter), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, ext_filter), ""));
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1));
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/embed_pck"), false));
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/no_bptc_fallbacks"), true));
+}
+
+String EditorExportPlatformPC::get_name() const {
+ return name;
+}
+
+String EditorExportPlatformPC::get_os_name() const {
+ return os_name;
+}
+
+Ref<Texture2D> EditorExportPlatformPC::get_logo() const {
+ return logo;
+}
+
+bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
+ String err;
+ bool valid = false;
+
+ // Look for export templates (first official, and if defined custom templates).
+
+ bool use64 = p_preset->get("binary_format/64_bits");
+ bool dvalid = exists_export_template(get_template_file_name("debug", use64 ? "x86_64" : "x86_32"), &err);
+ bool rvalid = exists_export_template(get_template_file_name("release", use64 ? "x86_64" : "x86_32"), &err);
+
+ if (p_preset->get("custom_template/debug") != "") {
+ dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
+ if (!dvalid) {
+ err += TTR("Custom debug template not found.") + "\n";
+ }
+ }
+ if (p_preset->get("custom_template/release") != "") {
+ rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
+ if (!rvalid) {
+ err += TTR("Custom release template not found.") + "\n";
+ }
+ }
+
+ valid = dvalid || rvalid;
+ r_missing_templates = !valid;
+
+ if (!err.is_empty()) {
+ r_error = err;
+ }
+ return valid;
+}
+
+Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
+ ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
+
+ Error err = prepare_template(p_preset, p_debug, p_path, p_flags);
+ if (err == OK) {
+ err = modify_template(p_preset, p_debug, p_path, p_flags);
+ }
+ if (err == OK) {
+ err = export_project_data(p_preset, p_debug, p_path, p_flags);
+ }
+
+ return err;
+}
+
+Error EditorExportPlatformPC::prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
+ if (!DirAccess::exists(p_path.get_base_dir())) {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("The given export path doesn't exist."));
+ return ERR_FILE_BAD_PATH;
+ }
+
+ String custom_debug = p_preset->get("custom_template/debug");
+ String custom_release = p_preset->get("custom_template/release");
+
+ String template_path = p_debug ? custom_debug : custom_release;
+
+ template_path = template_path.strip_edges();
+
+ if (template_path.is_empty()) {
+ template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", p_preset->get("binary_format/64_bits") ? "64" : "32"));
+ }
+
+ if (!template_path.is_empty() && !FileAccess::exists(template_path)) {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), vformat(TTR("Template file not found: \"%s\"."), template_path));
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ da->make_dir_recursive(p_path.get_base_dir());
+ Error err = da->copy(template_path, p_path, get_chmod_flags());
+ if (err != OK) {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("Failed to copy export template."));
+ }
+
+ return err;
+}
+
+Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
+ String pck_path;
+ if (p_preset->get("binary_format/embed_pck")) {
+ pck_path = p_path;
+ } else {
+ pck_path = p_path.get_basename() + ".pck";
+ }
+
+ Vector<SharedObject> so_files;
+
+ int64_t embedded_pos;
+ int64_t embedded_size;
+ Error err = save_pack(p_preset, p_debug, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size);
+ if (err == OK && p_preset->get("binary_format/embed_pck")) {
+ if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."));
+ return ERR_INVALID_PARAMETER;
+ }
+
+ err = fixup_embedded_pck(p_path, embedded_pos, embedded_size);
+ }
+
+ if (err == OK && !so_files.is_empty()) {
+ // If shared object files, copy them.
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ for (int i = 0; i < so_files.size() && err == OK; i++) {
+ String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path);
+ String target_path;
+ if (so_files[i].target.is_empty()) {
+ target_path = p_path.get_base_dir().plus_file(src_path.get_file());
+ } else {
+ target_path = p_path.get_base_dir().plus_file(so_files[i].target).plus_file(src_path.get_file());
+ }
+
+ if (da->dir_exists(src_path)) {
+ err = da->make_dir_recursive(target_path);
+ if (err == OK) {
+ err = da->copy_dir(src_path, target_path, -1, true);
+ }
+ } else {
+ err = da->copy(src_path, target_path);
+ if (err == OK) {
+ err = sign_shared_object(p_preset, p_debug, target_path);
+ }
+ }
+ }
+ }
+
+ return err;
+}
+
+Error EditorExportPlatformPC::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {
+ return OK;
+}
+
+void EditorExportPlatformPC::set_name(const String &p_name) {
+ name = p_name;
+}
+
+void EditorExportPlatformPC::set_os_name(const String &p_name) {
+ os_name = p_name;
+}
+
+void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) {
+ logo = p_logo;
+}
+
+void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
+ r_features->push_back("pc"); //all pcs support "pc"
+ r_features->push_back("s3tc"); //all pcs support "s3tc" compression
+ r_features->push_back(get_os_name().to_lower()); //OS name is a feature
+}
+
+void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) {
+ if (p_features.has("bptc")) {
+ if (p_preset->has("texture_format/no_bptc_fallbacks")) {
+ p_features.erase("s3tc");
+ }
+ }
+}
+
+int EditorExportPlatformPC::get_chmod_flags() const {
+ return chmod_flags;
+}
+
+void EditorExportPlatformPC::set_chmod_flags(int p_flags) {
+ chmod_flags = p_flags;
+}
diff --git a/editor/export/editor_export_platform_pc.h b/editor/export/editor_export_platform_pc.h
new file mode 100644
index 0000000000..ae7d6f1082
--- /dev/null
+++ b/editor/export/editor_export_platform_pc.h
@@ -0,0 +1,82 @@
+/*************************************************************************/
+/* editor_export_platform_pc.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_EXPORT_PLATFORM_PC_H
+#define EDITOR_EXPORT_PLATFORM_PC_H
+
+#include "editor_export_platform.h"
+
+class EditorExportPlatformPC : public EditorExportPlatform {
+ GDCLASS(EditorExportPlatformPC, EditorExportPlatform);
+
+private:
+ Ref<ImageTexture> logo;
+ String name;
+ String os_name;
+
+ int chmod_flags = -1;
+
+public:
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override;
+
+ virtual void get_export_options(List<ExportOption> *r_options) override;
+
+ virtual String get_name() const override;
+ virtual String get_os_name() const override;
+ virtual Ref<Texture2D> get_logo() const override;
+
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;
+ virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path);
+ virtual String get_template_file_name(const String &p_target, const String &p_arch) const = 0;
+
+ virtual Error prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags);
+ virtual Error modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { return OK; };
+ virtual Error export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags);
+
+ void set_extension(const String &p_extension, const String &p_feature_key = "default");
+ void set_name(const String &p_name);
+ void set_os_name(const String &p_name);
+
+ void set_logo(const Ref<Texture2D> &p_logo);
+
+ void add_platform_feature(const String &p_feature);
+ virtual void get_platform_features(List<String> *r_features) override;
+ virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override;
+
+ int get_chmod_flags() const;
+ void set_chmod_flags(int p_flags);
+
+ virtual Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {
+ return Error::OK;
+ }
+};
+
+#endif // EDITOR_EXPORT_PLATFORM_PC_H
diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp
new file mode 100644
index 0000000000..cf3a9b0810
--- /dev/null
+++ b/editor/export/editor_export_plugin.cpp
@@ -0,0 +1,201 @@
+/*************************************************************************/
+/* editor_export_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_export_plugin.h"
+
+#include "core/config/project_settings.h"
+#include "core/io/dir_access.h"
+#include "core/io/file_access.h"
+#include "editor/editor_paths.h"
+#include "editor/export/editor_export_platform.h"
+#include "scene/resources/resource_format_text.h"
+
+void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) {
+ if (p_preset.is_valid()) {
+ export_preset = p_preset;
+ }
+}
+
+Ref<EditorExportPreset> EditorExportPlugin::get_export_preset() const {
+ return export_preset;
+}
+
+void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) {
+ ExtraFile ef;
+ ef.data = p_file;
+ ef.path = p_path;
+ ef.remap = p_remap;
+ extra_files.push_back(ef);
+}
+
+void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &p_tags, const String &p_target) {
+ shared_objects.push_back(SharedObject(p_path, p_tags, p_target));
+}
+
+void EditorExportPlugin::add_ios_framework(const String &p_path) {
+ ios_frameworks.push_back(p_path);
+}
+
+void EditorExportPlugin::add_ios_embedded_framework(const String &p_path) {
+ ios_embedded_frameworks.push_back(p_path);
+}
+
+Vector<String> EditorExportPlugin::get_ios_frameworks() const {
+ return ios_frameworks;
+}
+
+Vector<String> EditorExportPlugin::get_ios_embedded_frameworks() const {
+ return ios_embedded_frameworks;
+}
+
+void EditorExportPlugin::add_ios_plist_content(const String &p_plist_content) {
+ ios_plist_content += p_plist_content + "\n";
+}
+
+String EditorExportPlugin::get_ios_plist_content() const {
+ return ios_plist_content;
+}
+
+void EditorExportPlugin::add_ios_linker_flags(const String &p_flags) {
+ if (ios_linker_flags.length() > 0) {
+ ios_linker_flags += ' ';
+ }
+ ios_linker_flags += p_flags;
+}
+
+String EditorExportPlugin::get_ios_linker_flags() const {
+ return ios_linker_flags;
+}
+
+void EditorExportPlugin::add_ios_bundle_file(const String &p_path) {
+ ios_bundle_files.push_back(p_path);
+}
+
+Vector<String> EditorExportPlugin::get_ios_bundle_files() const {
+ return ios_bundle_files;
+}
+
+void EditorExportPlugin::add_ios_cpp_code(const String &p_code) {
+ ios_cpp_code += p_code;
+}
+
+String EditorExportPlugin::get_ios_cpp_code() const {
+ return ios_cpp_code;
+}
+
+void EditorExportPlugin::add_macos_plugin_file(const String &p_path) {
+ macos_plugin_files.push_back(p_path);
+}
+
+const Vector<String> &EditorExportPlugin::get_macos_plugin_files() const {
+ return macos_plugin_files;
+}
+
+void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) {
+ ios_project_static_libs.push_back(p_path);
+}
+
+Vector<String> EditorExportPlugin::get_ios_project_static_libs() const {
+ return ios_project_static_libs;
+}
+
+void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) {
+ GDVIRTUAL_CALL(_export_file, p_path, p_type, p_features);
+}
+
+void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
+ GDVIRTUAL_CALL(_export_begin, p_features, p_debug, p_path, p_flags);
+}
+
+void EditorExportPlugin::_export_end_script() {
+ GDVIRTUAL_CALL(_export_end);
+}
+
+void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) {
+}
+
+void EditorExportPlugin::_export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
+}
+
+void EditorExportPlugin::skip() {
+ skipped = true;
+}
+
+void EditorExportPlugin::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags", "target"), &EditorExportPlugin::add_shared_object);
+ ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib);
+ ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file);
+ ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework);
+ ClassDB::bind_method(D_METHOD("add_ios_embedded_framework", "path"), &EditorExportPlugin::add_ios_embedded_framework);
+ ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content);
+ ClassDB::bind_method(D_METHOD("add_ios_linker_flags", "flags"), &EditorExportPlugin::add_ios_linker_flags);
+ ClassDB::bind_method(D_METHOD("add_ios_bundle_file", "path"), &EditorExportPlugin::add_ios_bundle_file);
+ ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code);
+ ClassDB::bind_method(D_METHOD("add_macos_plugin_file", "path"), &EditorExportPlugin::add_macos_plugin_file);
+ ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip);
+
+ GDVIRTUAL_BIND(_export_file, "path", "type", "features");
+ GDVIRTUAL_BIND(_export_begin, "features", "is_debug", "path", "flags");
+ GDVIRTUAL_BIND(_export_end);
+}
+
+EditorExportPlugin::EditorExportPlugin() {
+}
+
+///////////////////////
+
+void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) {
+ String extension = p_path.get_extension().to_lower();
+ if (extension != "tres" && extension != "tscn") {
+ return;
+ }
+
+ bool convert = GLOBAL_GET("editor/export/convert_text_resources_to_binary");
+ if (!convert) {
+ return;
+ }
+ String tmp_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpfile.res");
+ Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path);
+ if (err != OK) {
+ DirAccess::remove_file_or_error(tmp_path);
+ ERR_FAIL();
+ }
+ Vector<uint8_t> data = FileAccess::get_file_as_array(tmp_path);
+ if (data.size() == 0) {
+ DirAccess::remove_file_or_error(tmp_path);
+ ERR_FAIL();
+ }
+ DirAccess::remove_file_or_error(tmp_path);
+ add_file(p_path + ".converted.res", data, true);
+}
+
+EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() {
+ GLOBAL_DEF("editor/export/convert_text_resources_to_binary", false);
+}
diff --git a/editor/export/editor_export_plugin.h b/editor/export/editor_export_plugin.h
new file mode 100644
index 0000000000..04ebc1dfed
--- /dev/null
+++ b/editor/export/editor_export_plugin.h
@@ -0,0 +1,132 @@
+/*************************************************************************/
+/* editor_export_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_EXPORT_PLUGIN_H
+#define EDITOR_EXPORT_PLUGIN_H
+
+#include "core/extension/native_extension.h"
+#include "editor_export_preset.h"
+#include "editor_export_shared_object.h"
+
+class EditorExportPlugin : public RefCounted {
+ GDCLASS(EditorExportPlugin, RefCounted);
+
+ friend class EditorExportPlatform;
+
+ Ref<EditorExportPreset> export_preset;
+
+ Vector<SharedObject> shared_objects;
+ struct ExtraFile {
+ String path;
+ Vector<uint8_t> data;
+ bool remap = false;
+ };
+ Vector<ExtraFile> extra_files;
+ bool skipped = false;
+
+ Vector<String> ios_frameworks;
+ Vector<String> ios_embedded_frameworks;
+ Vector<String> ios_project_static_libs;
+ String ios_plist_content;
+ String ios_linker_flags;
+ Vector<String> ios_bundle_files;
+ String ios_cpp_code;
+
+ Vector<String> macos_plugin_files;
+
+ _FORCE_INLINE_ void _clear() {
+ shared_objects.clear();
+ extra_files.clear();
+ skipped = false;
+ }
+
+ _FORCE_INLINE_ void _export_end() {
+ ios_frameworks.clear();
+ ios_embedded_frameworks.clear();
+ ios_bundle_files.clear();
+ ios_plist_content = "";
+ ios_linker_flags = "";
+ ios_cpp_code = "";
+ macos_plugin_files.clear();
+ }
+
+ void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features);
+ void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
+ void _export_end_script();
+
+protected:
+ void set_export_preset(const Ref<EditorExportPreset> &p_preset);
+ Ref<EditorExportPreset> get_export_preset() const;
+
+ void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap);
+ void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String());
+
+ void add_ios_framework(const String &p_path);
+ void add_ios_embedded_framework(const String &p_path);
+ void add_ios_project_static_lib(const String &p_path);
+ void add_ios_plist_content(const String &p_plist_content);
+ void add_ios_linker_flags(const String &p_flags);
+ void add_ios_bundle_file(const String &p_path);
+ void add_ios_cpp_code(const String &p_code);
+ void add_macos_plugin_file(const String &p_path);
+
+ void skip();
+
+ virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features);
+ virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags);
+
+ static void _bind_methods();
+
+ GDVIRTUAL3(_export_file, String, String, Vector<String>)
+ GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t)
+ GDVIRTUAL0(_export_end)
+
+public:
+ Vector<String> get_ios_frameworks() const;
+ Vector<String> get_ios_embedded_frameworks() const;
+ Vector<String> get_ios_project_static_libs() const;
+ String get_ios_plist_content() const;
+ String get_ios_linker_flags() const;
+ Vector<String> get_ios_bundle_files() const;
+ String get_ios_cpp_code() const;
+ const Vector<String> &get_macos_plugin_files() const;
+
+ EditorExportPlugin();
+};
+
+class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin {
+ GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin);
+
+public:
+ virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override;
+ EditorExportTextSceneToBinaryPlugin();
+};
+
+#endif // EDITOR_EXPORT_PLUGIN_H
diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp
new file mode 100644
index 0000000000..cdf69e727d
--- /dev/null
+++ b/editor/export/editor_export_preset.cpp
@@ -0,0 +1,221 @@
+/*************************************************************************/
+/* editor_export_preset.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_export.h"
+
+bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) {
+ if (values.has(p_name)) {
+ values[p_name] = p_value;
+ EditorExport::singleton->save_presets();
+ return true;
+ }
+
+ return false;
+}
+
+bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
+ if (values.has(p_name)) {
+ r_ret = values[p_name];
+ return true;
+ }
+
+ return false;
+}
+
+void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
+ for (const PropertyInfo &E : properties) {
+ if (platform->get_export_option_visibility(E.name, values)) {
+ p_list->push_back(E);
+ }
+ }
+}
+
+Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
+ return platform;
+}
+
+void EditorExportPreset::update_files_to_export() {
+ Vector<String> to_remove;
+ for (const String &E : selected_files) {
+ if (!FileAccess::exists(E)) {
+ to_remove.push_back(E);
+ }
+ }
+ for (int i = 0; i < to_remove.size(); ++i) {
+ selected_files.erase(to_remove[i]);
+ }
+}
+
+Vector<String> EditorExportPreset::get_files_to_export() const {
+ Vector<String> files;
+ for (const String &E : selected_files) {
+ files.push_back(E);
+ }
+ return files;
+}
+
+void EditorExportPreset::set_name(const String &p_name) {
+ name = p_name;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_name() const {
+ return name;
+}
+
+void EditorExportPreset::set_runnable(bool p_enable) {
+ runnable = p_enable;
+ EditorExport::singleton->save_presets();
+}
+
+bool EditorExportPreset::is_runnable() const {
+ return runnable;
+}
+
+void EditorExportPreset::set_export_filter(ExportFilter p_filter) {
+ export_filter = p_filter;
+ EditorExport::singleton->save_presets();
+}
+
+EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const {
+ return export_filter;
+}
+
+void EditorExportPreset::set_include_filter(const String &p_include) {
+ include_filter = p_include;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_include_filter() const {
+ return include_filter;
+}
+
+void EditorExportPreset::set_export_path(const String &p_path) {
+ export_path = p_path;
+ /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path,
+ * this should be removed. */
+ if (export_path.is_absolute_path()) {
+ String res_path = OS::get_singleton()->get_resource_dir();
+ export_path = res_path.path_to_file(export_path);
+ }
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_export_path() const {
+ return export_path;
+}
+
+void EditorExportPreset::set_exclude_filter(const String &p_exclude) {
+ exclude_filter = p_exclude;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_exclude_filter() const {
+ return exclude_filter;
+}
+
+void EditorExportPreset::add_export_file(const String &p_path) {
+ selected_files.insert(p_path);
+ EditorExport::singleton->save_presets();
+}
+
+void EditorExportPreset::remove_export_file(const String &p_path) {
+ selected_files.erase(p_path);
+ EditorExport::singleton->save_presets();
+}
+
+bool EditorExportPreset::has_export_file(const String &p_path) {
+ return selected_files.has(p_path);
+}
+
+void EditorExportPreset::set_custom_features(const String &p_custom_features) {
+ custom_features = p_custom_features;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_custom_features() const {
+ return custom_features;
+}
+
+void EditorExportPreset::set_enc_in_filter(const String &p_filter) {
+ enc_in_filters = p_filter;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_enc_in_filter() const {
+ return enc_in_filters;
+}
+
+void EditorExportPreset::set_enc_ex_filter(const String &p_filter) {
+ enc_ex_filters = p_filter;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_enc_ex_filter() const {
+ return enc_ex_filters;
+}
+
+void EditorExportPreset::set_enc_pck(bool p_enabled) {
+ enc_pck = p_enabled;
+ EditorExport::singleton->save_presets();
+}
+
+bool EditorExportPreset::get_enc_pck() const {
+ return enc_pck;
+}
+
+void EditorExportPreset::set_enc_directory(bool p_enabled) {
+ enc_directory = p_enabled;
+ EditorExport::singleton->save_presets();
+}
+
+bool EditorExportPreset::get_enc_directory() const {
+ return enc_directory;
+}
+
+void EditorExportPreset::set_script_export_mode(int p_mode) {
+ script_mode = p_mode;
+ EditorExport::singleton->save_presets();
+}
+
+int EditorExportPreset::get_script_export_mode() const {
+ return script_mode;
+}
+
+void EditorExportPreset::set_script_encryption_key(const String &p_key) {
+ script_key = p_key;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_script_encryption_key() const {
+ return script_key;
+}
+
+EditorExportPreset::EditorExportPreset() {}
diff --git a/editor/export/editor_export_preset.h b/editor/export/editor_export_preset.h
new file mode 100644
index 0000000000..00109396b0
--- /dev/null
+++ b/editor/export/editor_export_preset.h
@@ -0,0 +1,145 @@
+/*************************************************************************/
+/* editor_export_preset.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_EXPORT_PRESET_H
+#define EDITOR_EXPORT_PRESET_H
+
+class EditorExportPlatform;
+
+#include "core/object/ref_counted.h"
+
+class EditorExportPreset : public RefCounted {
+ GDCLASS(EditorExportPreset, RefCounted);
+
+public:
+ enum ExportFilter {
+ EXPORT_ALL_RESOURCES,
+ EXPORT_SELECTED_SCENES,
+ EXPORT_SELECTED_RESOURCES,
+ EXCLUDE_SELECTED_RESOURCES,
+ };
+
+ enum ScriptExportMode {
+ MODE_SCRIPT_TEXT,
+ MODE_SCRIPT_COMPILED,
+ };
+
+private:
+ Ref<EditorExportPlatform> platform;
+ ExportFilter export_filter = EXPORT_ALL_RESOURCES;
+ String include_filter;
+ String exclude_filter;
+ String export_path;
+
+ String exporter;
+ HashSet<String> selected_files;
+ bool runnable = false;
+
+ friend class EditorExport;
+ friend class EditorExportPlatform;
+
+ List<PropertyInfo> properties;
+ HashMap<StringName, Variant> values;
+
+ String name;
+
+ String custom_features;
+
+ String enc_in_filters;
+ String enc_ex_filters;
+ bool enc_pck = false;
+ bool enc_directory = false;
+
+ int script_mode = MODE_SCRIPT_COMPILED;
+ String script_key;
+
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
+
+public:
+ Ref<EditorExportPlatform> get_platform() const;
+
+ bool has(const StringName &p_property) const { return values.has(p_property); }
+
+ void update_files_to_export();
+
+ Vector<String> get_files_to_export() const;
+
+ void add_export_file(const String &p_path);
+ void remove_export_file(const String &p_path);
+ bool has_export_file(const String &p_path);
+
+ void set_name(const String &p_name);
+ String get_name() const;
+
+ void set_runnable(bool p_enable);
+ bool is_runnable() const;
+
+ void set_export_filter(ExportFilter p_filter);
+ ExportFilter get_export_filter() const;
+
+ void set_include_filter(const String &p_include);
+ String get_include_filter() const;
+
+ void set_exclude_filter(const String &p_exclude);
+ String get_exclude_filter() const;
+
+ void set_custom_features(const String &p_custom_features);
+ String get_custom_features() const;
+
+ void set_export_path(const String &p_path);
+ String get_export_path() const;
+
+ void set_enc_in_filter(const String &p_filter);
+ String get_enc_in_filter() const;
+
+ void set_enc_ex_filter(const String &p_filter);
+ String get_enc_ex_filter() const;
+
+ void set_enc_pck(bool p_enabled);
+ bool get_enc_pck() const;
+
+ void set_enc_directory(bool p_enabled);
+ bool get_enc_directory() const;
+
+ void set_script_export_mode(int p_mode);
+ int get_script_export_mode() const;
+
+ void set_script_encryption_key(const String &p_key);
+ String get_script_encryption_key() const;
+
+ const List<PropertyInfo> &get_properties() const { return properties; }
+
+ EditorExportPreset();
+};
+
+#endif // EDITOR_EXPORT_PRESET_H
diff --git a/editor/export/editor_export_shared_object.h b/editor/export/editor_export_shared_object.h
new file mode 100644
index 0000000000..558f403ca1
--- /dev/null
+++ b/editor/export/editor_export_shared_object.h
@@ -0,0 +1,51 @@
+/*************************************************************************/
+/* editor_export_shared_object.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_EXPORT_SHARED_OBJECT_H
+#define EDITOR_EXPORT_SHARED_OBJECT_H
+
+#include "core/string/ustring.h"
+#include "core/templates/vector.h"
+
+struct SharedObject {
+ String path;
+ Vector<String> tags;
+ String target;
+
+ SharedObject(const String &p_path, const Vector<String> &p_tags, const String &p_target) :
+ path(p_path),
+ tags(p_tags),
+ target(p_target) {
+ }
+
+ SharedObject() {}
+};
+
+#endif // EDITOR_EXPORT_SHARED_OBJECT_H
diff --git a/editor/export_template_manager.cpp b/editor/export/export_template_manager.cpp
index af9c918360..e02066e956 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export/export_template_manager.cpp
@@ -30,23 +30,22 @@
#include "export_template_manager.h"
-#include "core/input/input.h"
#include "core/io/dir_access.h"
#include "core/io/json.h"
#include "core/io/zip_io.h"
-#include "core/os/keyboard.h"
-#include "core/templates/rb_set.h"
#include "core/version.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
-#include "progress_dialog.h"
-#include "scene/gui/link_button.h"
+#include "editor/progress_dialog.h"
+#include "scene/gui/file_dialog.h"
+#include "scene/gui/tree.h"
+#include "scene/main/http_request.h"
void ExportTemplateManager::_update_template_status() {
// Fetch installed templates from the file system.
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
+ const String &templates_dir = EditorSettings::get_singleton()->get_export_templates_dir();
Error err = da->change_dir(templates_dir);
ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'.");
@@ -439,7 +438,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
}
Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(version);
+ String template_path = EditorSettings::get_singleton()->get_export_templates_dir().plus_file(version);
Error err = d->make_dir_recursive(template_path);
if (err != OK) {
EditorNode::get_singleton()->show_warning(TTR("Error creating path for extracting templates:") + "\n" + template_path);
@@ -538,7 +537,7 @@ void ExportTemplateManager::_uninstall_template(const String &p_version) {
void ExportTemplateManager::_uninstall_template_confirmed() {
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
+ const String &templates_dir = EditorSettings::get_singleton()->get_export_templates_dir();
Error err = da->change_dir(templates_dir);
ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'.");
@@ -616,7 +615,7 @@ void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_co
}
void ExportTemplateManager::_open_template_folder(const String &p_version) {
- const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
+ const String &templates_dir = EditorSettings::get_singleton()->get_export_templates_dir();
OS::get_singleton()->shell_open("file://" + templates_dir.plus_file(p_version));
}
@@ -640,12 +639,12 @@ void ExportTemplateManager::_hide_dialog() {
}
bool ExportTemplateManager::can_install_android_template() {
- const String templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
+ const String templates_dir = EditorSettings::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG);
return FileAccess::exists(templates_dir.plus_file("android_source.zip"));
}
Error ExportTemplateManager::install_android_template() {
- const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
+ const String &templates_path = EditorSettings::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG);
const String &source_zip = templates_path.plus_file("android_source.zip");
ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN);
return install_android_template_from_file(source_zip);
diff --git a/editor/export_template_manager.h b/editor/export/export_template_manager.h
index 3494e11d5e..f01da15832 100644
--- a/editor/export_template_manager.h
+++ b/editor/export/export_template_manager.h
@@ -31,15 +31,15 @@
#ifndef EXPORT_TEMPLATE_MANAGER_H
#define EXPORT_TEMPLATE_MANAGER_H
-#include "editor/editor_settings.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/progress_bar.h"
-#include "scene/gui/scroll_container.h"
-#include "scene/main/http_request.h"
class ExportTemplateVersion;
+class FileDialog;
+class HTTPRequest;
+class MenuButton;
+class OptionButton;
+class ProgressBar;
+class Tree;
class ExportTemplateManager : public AcceptDialog {
GDCLASS(ExportTemplateManager, AcceptDialog);
diff --git a/editor/project_export.cpp b/editor/export/project_export.cpp
index 209c997d58..a20f19efc8 100644
--- a/editor/project_export.cpp
+++ b/editor/export/project_export.cpp
@@ -31,23 +31,15 @@
#include "project_export.h"
#include "core/config/project_settings.h"
-#include "core/io/dir_access.h"
-#include "core/io/file_access.h"
-#include "core/io/image_loader.h"
-#include "core/io/resource_loader.h"
-#include "core/io/resource_saver.h"
-#include "core/os/os.h"
-#include "core/string/optimized_translation.h"
-#include "core/version_generated.gen.h"
+#include "core/version.h"
#include "editor/editor_file_dialog.h"
+#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
+#include "editor/editor_properties.h"
#include "editor/editor_scale.h"
-#include "editor/editor_settings.h"
-#include "scene/gui/box_container.h"
-#include "scene/gui/margin_container.h"
-#include "scene/gui/scroll_container.h"
-#include "scene/gui/tab_container.h"
-#include "servers/display_server.h"
+#include "editor/export/editor_export.h"
+#include "scene/gui/link_button.h"
+#include "scene/gui/tree.h"
void ProjectExportDialog::_theme_changed() {
duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")));
diff --git a/editor/project_export.h b/editor/export/project_export.h
index 6b10642495..96dd765a2c 100644
--- a/editor/project_export.h
+++ b/editor/export/project_export.h
@@ -28,31 +28,25 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PROJECT_EXPORT_SETTINGS_H
-#define PROJECT_EXPORT_SETTINGS_H
-
-#include "core/io/dir_access.h"
-#include "core/os/thread.h"
-#include "editor/editor_export.h"
-#include "editor/editor_file_system.h"
-#include "editor/editor_inspector.h"
-#include "editor/editor_properties.h"
-#include "scene/gui/button.h"
-#include "scene/gui/check_button.h"
-#include "scene/gui/control.h"
+#ifndef PROJECT_EXPORT_H
+#define PROJECT_EXPORT_H
+
#include "scene/gui/dialogs.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/label.h"
-#include "scene/gui/link_button.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/option_button.h"
-#include "scene/gui/rich_text_label.h"
-#include "scene/gui/slider.h"
-#include "scene/gui/tab_container.h"
-#include "scene/gui/tree.h"
-#include "scene/main/timer.h"
+class CheckBox;
+class CheckButton;
+class EditorExportPreset;
class EditorFileDialog;
+class EditorFileSystemDirectory;
+class EditorInspector;
+class EditorPropertyPath;
+class ItemList;
+class MenuButton;
+class OptionButton;
+class RichTextLabel;
+class TabContainer;
+class Tree;
+class TreeItem;
class ProjectExportDialog : public ConfirmationDialog {
GDCLASS(ProjectExportDialog, ConfirmationDialog);
@@ -183,4 +177,4 @@ public:
~ProjectExportDialog();
};
-#endif // PROJECT_EXPORT_SETTINGS_H
+#endif // PROJECT_EXPORT_H
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index fe6e6044a4..e025cedf02 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -985,7 +985,9 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit
}
}
- if (ResourceLoader::get_resource_type(fpath) == "PackedScene") {
+ String resource_type = ResourceLoader::get_resource_type(fpath);
+
+ if (resource_type == "PackedScene") {
bool is_imported = false;
{
@@ -1005,7 +1007,7 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit
} else {
EditorNode::get_singleton()->open_request(fpath);
}
- } else if (ResourceLoader::get_resource_type(fpath) == "AnimationLibrary") {
+ } else if (resource_type == "AnimationLibrary") {
bool is_imported = false;
{
@@ -1025,6 +1027,25 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit
} else {
EditorNode::get_singleton()->open_request(fpath);
}
+ } else if (ResourceLoader::is_imported(fpath)) {
+ // If the importer has advanced settings, show them.
+ int order;
+ bool can_threads;
+ String name;
+ Error err = ResourceFormatImporter::get_singleton()->get_import_order_threads_and_importer(fpath, order, can_threads, name);
+ bool used_advanced_settings = false;
+ if (err == OK) {
+ Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(name);
+ if (importer.is_valid() && importer->has_advanced_options()) {
+ importer->show_advanced_options(fpath);
+ used_advanced_settings = true;
+ }
+ }
+
+ if (!used_advanced_settings) {
+ EditorNode::get_singleton()->load_resource(fpath);
+ }
+
} else {
EditorNode::get_singleton()->load_resource(fpath);
}
@@ -2034,6 +2055,10 @@ void FileSystemDock::_resource_created() {
make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 1);
make_shader_dialog->popup_centered();
return;
+ } else if (type_name == "ShaderInclude") {
+ make_shader_dialog->config(fpath.plus_file("new_shader_include"), false, false, 2);
+ make_shader_dialog->popup_centered();
+ return;
}
Variant c = new_resource_dialog->instance_selected();
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index f73e076ac0..c38b3f8a47 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -342,4 +342,4 @@ public:
~FileSystemDock();
};
-#endif // SCENES_DOCK_H
+#endif // FILESYSTEM_DOCK_H
diff --git a/editor/groups_editor.h b/editor/groups_editor.h
index 75cbfd01a4..fec8913e31 100644
--- a/editor/groups_editor.h
+++ b/editor/groups_editor.h
@@ -144,4 +144,4 @@ public:
~GroupsEditor();
};
-#endif
+#endif // GROUPS_EDITOR_H
diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp
new file mode 100644
index 0000000000..f3709efab6
--- /dev/null
+++ b/editor/import/audio_stream_import_settings.cpp
@@ -0,0 +1,650 @@
+/*************************************************************************/
+/* audio_stream_import_settings.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "audio_stream_import_settings.h"
+#include "editor/audio_stream_preview.h"
+#include "editor/editor_file_system.h"
+#include "editor/editor_scale.h"
+
+AudioStreamImportSettings *AudioStreamImportSettings::singleton = nullptr;
+
+void AudioStreamImportSettings::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamImportSettings::_preview_changed));
+ connect("confirmed", callable_mp(this, &AudioStreamImportSettings::_reimport));
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_ENTER_TREE: {
+ _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
+ _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
+ _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor")));
+ color_rect->set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor")));
+ _current_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ _current_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+ _duration_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ _duration_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+
+ zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons")));
+ zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
+ zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons")));
+
+ _indicator->update();
+ _preview->update();
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ _current = _player->get_playback_position();
+ _indicator->update();
+ } break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible()) {
+ _stop();
+ }
+ } break;
+ }
+}
+
+void AudioStreamImportSettings::_draw_preview() {
+ Rect2 rect = _preview->get_rect();
+ Size2 size = rect.size;
+
+ Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream);
+ float preview_offset = zoom_bar->get_value();
+ float preview_len = zoom_bar->get_page();
+
+ Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts"));
+ int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"));
+ Vector<Vector2> lines;
+ lines.resize(size.width * 2);
+ Color color_active = get_theme_color(SNAME("contrast_color_2"), SNAME("Editor"));
+ Color color_inactive = color_active;
+ color_inactive.a *= 0.5;
+ Vector<Color> color;
+ color.resize(lines.size());
+
+ float inactive_from = 1e20;
+ float beat_size = 0;
+ int last_beat = 0;
+ if (stream->get_bpm() > 0) {
+ beat_size = 60 / float(stream->get_bpm());
+ int y_ofs = beat_font->get_height(main_size) + 4 * EDSCALE;
+ rect.position.y += y_ofs;
+ rect.size.y -= y_ofs;
+
+ if (stream->get_beat_count() > 0) {
+ last_beat = stream->get_beat_count();
+ inactive_from = last_beat * beat_size;
+ }
+ }
+
+ for (int i = 0; i < size.width; i++) {
+ float ofs = preview_offset + i * preview_len / size.width;
+ float ofs_n = preview_offset + (i + 1) * preview_len / size.width;
+ float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;
+ float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5;
+
+ int idx = i;
+ lines.write[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y);
+ lines.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y);
+
+ Color c = ofs > inactive_from ? color_inactive : color_active;
+
+ color.write[idx * 2 + 0] = c;
+ color.write[idx * 2 + 1] = c;
+ }
+
+ RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color);
+
+ if (beat_size) {
+ Color beat_color = Color(1, 1, 1, 1);
+ Color final_beat_color = beat_color;
+ Color bar_color = beat_color;
+ beat_color.a *= 0.4;
+ bar_color.a *= 0.6;
+
+ int prev_beat = 0; // Do not draw beat zero
+ Color color_bg = color_active;
+ color_bg.a *= 0.2;
+ _preview->draw_rect(Rect2(0, 0, rect.size.width, rect.position.y), color_bg);
+ int bar_beats = stream->get_bar_beats();
+
+ int last_text_end_x = 0;
+ for (int i = 0; i < size.width; i++) {
+ float ofs = preview_offset + i * preview_len / size.width;
+ int beat = int(ofs / beat_size);
+ if (beat != prev_beat) {
+ String text = itos(beat);
+ int text_w = beat_font->get_string_size(text).width;
+ if (i - text_w / 2 > last_text_end_x + 2 * EDSCALE) {
+ int x_ofs = i - text_w / 2;
+ _preview->draw_string(beat_font, Point2(x_ofs, 2 * EDSCALE + beat_font->get_ascent(main_size)), text, HORIZONTAL_ALIGNMENT_LEFT, rect.size.width - x_ofs, Font::DEFAULT_FONT_SIZE, color_active);
+ last_text_end_x = i + text_w / 2;
+ }
+
+ if (beat == last_beat) {
+ _preview->draw_rect(Rect2i(i, rect.position.y, 2, rect.size.height), final_beat_color);
+ // Darken subsequent beats
+ beat_color.a *= 0.3;
+ color_active.a *= 0.3;
+ } else {
+ _preview->draw_rect(Rect2i(i, rect.position.y, 1, rect.size.height), (beat % bar_beats) == 0 ? bar_color : beat_color);
+ }
+ prev_beat = beat;
+ }
+ }
+ }
+}
+
+void AudioStreamImportSettings::_preview_changed(ObjectID p_which) {
+ if (stream.is_valid() && stream->get_instance_id() == p_which) {
+ _preview->update();
+ }
+}
+
+void AudioStreamImportSettings::_preview_zoom_in() {
+ if (!stream.is_valid()) {
+ return;
+ }
+ float page_size = zoom_bar->get_page();
+ zoom_bar->set_page(page_size * 0.5);
+ zoom_bar->set_value(zoom_bar->get_value() + page_size * 0.25);
+
+ _preview->update();
+ _indicator->update();
+}
+
+void AudioStreamImportSettings::_preview_zoom_out() {
+ if (!stream.is_valid()) {
+ return;
+ }
+ float page_size = zoom_bar->get_page();
+ zoom_bar->set_page(MIN(zoom_bar->get_max(), page_size * 2.0));
+ zoom_bar->set_value(zoom_bar->get_value() - page_size * 0.5);
+
+ _preview->update();
+ _indicator->update();
+}
+
+void AudioStreamImportSettings::_preview_zoom_reset() {
+ if (!stream.is_valid()) {
+ return;
+ }
+ zoom_bar->set_max(stream->get_length());
+ zoom_bar->set_page(zoom_bar->get_max());
+ zoom_bar->set_value(0);
+ _preview->update();
+ _indicator->update();
+}
+
+void AudioStreamImportSettings::_preview_zoom_offset_changed(double) {
+ _preview->update();
+ _indicator->update();
+}
+
+void AudioStreamImportSettings::_audio_changed() {
+ if (!is_visible()) {
+ return;
+ }
+ _preview->update();
+ _indicator->update();
+ color_rect->update();
+}
+
+void AudioStreamImportSettings::_play() {
+ if (_player->is_playing()) {
+ // '_pausing' variable indicates that we want to pause the audio player, not stop it. See '_on_finished()'.
+ _pausing = true;
+ _player->stop();
+ _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
+ set_process(false);
+ } else {
+ _player->play(_current);
+ _play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")));
+ set_process(true);
+ }
+}
+
+void AudioStreamImportSettings::_stop() {
+ _player->stop();
+ _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
+ _current = 0;
+ _indicator->update();
+ set_process(false);
+}
+
+void AudioStreamImportSettings::_on_finished() {
+ _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
+ if (!_pausing) {
+ _current = 0;
+ _indicator->update();
+ } else {
+ _pausing = false;
+ }
+ set_process(false);
+}
+
+void AudioStreamImportSettings::_draw_indicator() {
+ if (!stream.is_valid()) {
+ return;
+ }
+
+ Rect2 rect = _preview->get_rect();
+
+ Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts"));
+ int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"));
+
+ if (stream->get_bpm() > 0) {
+ int y_ofs = beat_font->get_height(main_size) + 4 * EDSCALE;
+ rect.position.y += y_ofs;
+ rect.size.height -= y_ofs;
+ }
+
+ float ofs_x = (_current - zoom_bar->get_value()) * rect.size.width / zoom_bar->get_page();
+ if (ofs_x < 0 || ofs_x >= rect.size.width) {
+ return;
+ }
+
+ const Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ _indicator->draw_line(Point2(ofs_x, rect.position.y), Point2(ofs_x, rect.position.y + rect.size.height), color, Math::round(2 * EDSCALE));
+ _indicator->draw_texture(
+ get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")),
+ Point2(ofs_x - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, rect.position.y),
+ color);
+
+ if (stream->get_bpm() > 0 && _hovering_beat != -1) {
+ // Draw hovered beat.
+ float preview_offset = zoom_bar->get_value();
+ float preview_len = zoom_bar->get_page();
+ float beat_size = 60 / float(stream->get_bpm());
+ int prev_beat = 0;
+ int last_text_end_x = 0;
+ for (int i = 0; i < rect.size.width; i++) {
+ float ofs = preview_offset + i * preview_len / rect.size.width;
+ int beat = int(ofs / beat_size);
+ if (beat != prev_beat) {
+ String text = itos(beat);
+ int text_w = beat_font->get_string_size(text).width;
+ if (i - text_w / 2 > last_text_end_x + 2 * EDSCALE && beat == _hovering_beat) {
+ int x_ofs = i - text_w / 2;
+ _indicator->draw_string(beat_font, Point2(x_ofs, 2 * EDSCALE + beat_font->get_ascent(main_size)), text, HORIZONTAL_ALIGNMENT_LEFT, rect.size.width - x_ofs, Font::DEFAULT_FONT_SIZE, color);
+ last_text_end_x = i + text_w / 2;
+ break;
+ }
+ prev_beat = beat;
+ }
+ }
+ }
+
+ _current_label->set_text(String::num(_current, 2).pad_decimals(2) + " /");
+}
+
+void AudioStreamImportSettings::_on_indicator_mouse_exited() {
+ _hovering_beat = -1;
+ _indicator->update();
+}
+
+void AudioStreamImportSettings::_on_input_indicator(Ref<InputEvent> p_event) {
+ const Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
+ if (stream->get_bpm() > 0) {
+ int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"));
+ Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts"));
+ int y_ofs = beat_font->get_height(main_size) + 4 * EDSCALE;
+ if ((!_dragging && mb->get_position().y < y_ofs) || _beat_len_dragging) {
+ if (mb->is_pressed()) {
+ _set_beat_len_to(mb->get_position().x);
+ _beat_len_dragging = true;
+ } else {
+ _beat_len_dragging = false;
+ }
+ return;
+ }
+ }
+
+ if (mb->is_pressed()) {
+ _seek_to(mb->get_position().x);
+ }
+ _dragging = mb->is_pressed();
+ }
+
+ const Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (_dragging) {
+ _seek_to(mm->get_position().x);
+ }
+ if (_beat_len_dragging) {
+ _set_beat_len_to(mm->get_position().x);
+ }
+ if (stream->get_bpm() > 0) {
+ int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"));
+ Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts"));
+ int y_ofs = beat_font->get_height(main_size) + 4 * EDSCALE;
+ if (mm->get_position().y < y_ofs) {
+ int new_hovering_beat = _get_beat_at_pos(mm->get_position().x);
+ if (new_hovering_beat != _hovering_beat) {
+ _hovering_beat = new_hovering_beat;
+ _indicator->update();
+ }
+ } else if (_hovering_beat != -1) {
+ _hovering_beat = -1;
+ _indicator->update();
+ }
+ }
+ }
+}
+
+int AudioStreamImportSettings::_get_beat_at_pos(real_t p_x) {
+ float ofs_sec = zoom_bar->get_value() + p_x * zoom_bar->get_page() / _preview->get_size().width;
+ ofs_sec = CLAMP(ofs_sec, 0, stream->get_length());
+ float beat_size = 60 / float(stream->get_bpm());
+ int beat = int(ofs_sec / beat_size + 0.5);
+
+ if (beat * beat_size > stream->get_length() + 0.001) { // Stream may end few audio frames before but may still want to use full loop.
+ beat--;
+ }
+ return beat;
+}
+
+void AudioStreamImportSettings::_set_beat_len_to(real_t p_x) {
+ int beat = _get_beat_at_pos(p_x);
+ if (beat < 1) {
+ beat = 1; // Because 0 is disable.
+ }
+ updating_settings = true;
+ beats_enabled->set_pressed(true);
+ beats_edit->set_value(beat);
+ updating_settings = false;
+ _settings_changed();
+}
+
+void AudioStreamImportSettings::_seek_to(real_t p_x) {
+ _current = zoom_bar->get_value() + p_x / _preview->get_rect().size.x * zoom_bar->get_page();
+ _current = CLAMP(_current, 0, stream->get_length());
+ _player->seek(_current);
+ _indicator->update();
+}
+
+void AudioStreamImportSettings::edit(const String &p_path, const String &p_importer, const Ref<AudioStream> &p_stream) {
+ if (!stream.is_null()) {
+ stream->disconnect("changed", callable_mp(this, &AudioStreamImportSettings::_audio_changed));
+ }
+
+ importer = p_importer;
+ path = p_path;
+
+ stream = p_stream;
+ _player->set_stream(stream);
+ _current = 0;
+ String text = String::num(stream->get_length(), 2).pad_decimals(2) + "s";
+ _duration_label->set_text(text);
+
+ if (!stream.is_null()) {
+ stream->connect("changed", callable_mp(this, &AudioStreamImportSettings::_audio_changed));
+ _preview->update();
+ _indicator->update();
+ color_rect->update();
+ } else {
+ hide();
+ }
+ params.clear();
+
+ if (stream.is_valid()) {
+ Ref<ConfigFile> config_file;
+ config_file.instantiate();
+ Error err = config_file->load(p_path + ".import");
+ updating_settings = true;
+ if (err == OK) {
+ double bpm = config_file->get_value("params", "bpm", 0);
+ int beats = config_file->get_value("params", "beat_count", 0);
+ bpm_edit->set_value(bpm > 0 ? bpm : 120);
+ bpm_enabled->set_pressed(bpm > 0);
+ beats_edit->set_value(beats);
+ beats_enabled->set_pressed(beats > 0);
+ loop->set_pressed(config_file->get_value("params", "loop", false));
+ loop_offset->set_value(config_file->get_value("params", "loop_offset", 0));
+ bar_beats_edit->set_value(config_file->get_value("params", "bar_beats", 4));
+
+ List<String> keys;
+ config_file->get_section_keys("params", &keys);
+ for (const String &K : keys) {
+ params[K] = config_file->get_value("params", K);
+ }
+ } else {
+ bpm_edit->set_value(false);
+ bpm_enabled->set_pressed(false);
+ beats_edit->set_value(0);
+ beats_enabled->set_pressed(false);
+ bar_beats_edit->set_value(4);
+ loop->set_pressed(false);
+ loop_offset->set_value(0);
+ }
+
+ _preview_zoom_reset();
+ updating_settings = false;
+ _settings_changed();
+
+ set_title(vformat(TTR("Audio Stream Importer: %s"), p_path.get_file()));
+ popup_centered();
+ }
+}
+
+void AudioStreamImportSettings::_settings_changed() {
+ if (updating_settings) {
+ return;
+ }
+
+ updating_settings = true;
+ stream->call("set_loop", loop->is_pressed());
+ stream->call("set_loop_offset", loop_offset->get_value());
+ if (bpm_enabled->is_pressed()) {
+ stream->call("set_bpm", bpm_edit->get_value());
+ beats_enabled->show();
+ beats_edit->show();
+ bar_beats_label->show();
+ bar_beats_edit->show();
+ double bpm = bpm_edit->get_value();
+ if (bpm > 0) {
+ float beat_size = 60 / float(bpm);
+ int beat_max = int((stream->get_length() + 0.001) / beat_size);
+ int current_beat = beats_edit->get_value();
+ beats_edit->set_max(beat_max);
+ if (current_beat > beat_max) {
+ beats_edit->set_value(beat_max);
+ stream->call("set_beat_count", beat_max);
+ }
+ }
+ stream->call("set_bar_beats", bar_beats_edit->get_value());
+ } else {
+ stream->call("set_bpm", 0);
+ stream->call("set_bar_beats", 4);
+ beats_enabled->hide();
+ beats_edit->hide();
+ bar_beats_label->hide();
+ bar_beats_edit->hide();
+ }
+ if (bpm_enabled->is_pressed() && beats_enabled->is_pressed()) {
+ stream->call("set_beat_count", beats_edit->get_value());
+ } else {
+ stream->call("set_beat_count", 0);
+ }
+
+ updating_settings = false;
+
+ _preview->update();
+ _indicator->update();
+ color_rect->update();
+}
+
+void AudioStreamImportSettings::_reimport() {
+ params["loop"] = loop->is_pressed();
+ params["loop_offset"] = loop_offset->get_value();
+ params["bpm"] = bpm_enabled->is_pressed() ? double(bpm_edit->get_value()) : double(0);
+ params["beat_count"] = (bpm_enabled->is_pressed() && beats_enabled->is_pressed()) ? int(beats_edit->get_value()) : int(0);
+ params["bar_beats"] = (bpm_enabled->is_pressed()) ? int(bar_beats_edit->get_value()) : int(4);
+
+ EditorFileSystem::get_singleton()->reimport_file_with_custom_parameters(path, importer, params);
+}
+
+AudioStreamImportSettings::AudioStreamImportSettings() {
+ get_ok_button()->set_text(TTR("Reimport"));
+ get_cancel_button()->set_text(TTR("Close"));
+
+ VBoxContainer *main_vbox = memnew(VBoxContainer);
+ add_child(main_vbox);
+
+ HBoxContainer *loop_hb = memnew(HBoxContainer);
+ loop_hb->add_theme_constant_override("separation", 4 * EDSCALE);
+ loop = memnew(CheckBox);
+ loop->set_text(TTR("Enable"));
+ loop->set_tooltip(TTR("Enable looping."));
+ loop->connect("toggled", callable_mp(this, &AudioStreamImportSettings::_settings_changed).unbind(1));
+ loop_hb->add_child(loop);
+ loop_hb->add_spacer();
+ loop_hb->add_child(memnew(Label(TTR("Offset:"))));
+ loop_offset = memnew(SpinBox);
+ loop_offset->set_max(10000);
+ loop_offset->set_step(0.001);
+ loop_offset->set_suffix("sec");
+ loop_offset->set_tooltip(TTR("Loop offset (from beginning). Note that if BPM is set, this setting will be ignored."));
+ loop_offset->connect("value_changed", callable_mp(this, &AudioStreamImportSettings::_settings_changed).unbind(1));
+ loop_hb->add_child(loop_offset);
+ main_vbox->add_margin_child(TTR("Loop:"), loop_hb);
+
+ HBoxContainer *interactive_hb = memnew(HBoxContainer);
+ interactive_hb->add_theme_constant_override("separation", 4 * EDSCALE);
+ bpm_enabled = memnew(CheckBox);
+ bpm_enabled->set_text((TTR("BPM:")));
+ bpm_enabled->connect("toggled", callable_mp(this, &AudioStreamImportSettings::_settings_changed).unbind(1));
+ interactive_hb->add_child(bpm_enabled);
+ bpm_edit = memnew(SpinBox);
+ bpm_edit->set_max(400);
+ bpm_edit->set_step(0.01);
+ bpm_edit->set_tooltip(TTR("Configure the Beats Per Measure (tempo) used for the interactive streams.\nThis is required in order to configure beat information."));
+ bpm_edit->connect("value_changed", callable_mp(this, &AudioStreamImportSettings::_settings_changed).unbind(1));
+ interactive_hb->add_child(bpm_edit);
+ interactive_hb->add_spacer();
+ bar_beats_label = memnew(Label(TTR("Beats/Bar:")));
+ interactive_hb->add_child(bar_beats_label);
+ bar_beats_edit = memnew(SpinBox);
+ bar_beats_edit->set_tooltip(TTR("Configure the Beats Per Bar. This used for music-aware transitions between AudioStreams."));
+ bar_beats_edit->set_min(2);
+ bar_beats_edit->set_max(32);
+ bar_beats_edit->connect("value_changed", callable_mp(this, &AudioStreamImportSettings::_settings_changed).unbind(1));
+ interactive_hb->add_child(bar_beats_edit);
+ interactive_hb->add_spacer();
+ beats_enabled = memnew(CheckBox);
+ beats_enabled->set_text(TTR("Length (in beats):"));
+ beats_enabled->connect("toggled", callable_mp(this, &AudioStreamImportSettings::_settings_changed).unbind(1));
+ interactive_hb->add_child(beats_enabled);
+ beats_edit = memnew(SpinBox);
+ beats_edit->set_tooltip(TTR("Configure the amount of Beats used for music-aware looping. If zero, it will be autodetected from the length.\nIt is recommended to set this value (either manually or by clicking on a beat number in the preview) to ensure looping works properly."));
+ beats_edit->set_max(99999);
+ beats_edit->connect("value_changed", callable_mp(this, &AudioStreamImportSettings::_settings_changed).unbind(1));
+ interactive_hb->add_child(beats_edit);
+ main_vbox->add_margin_child(TTR("Music Playback:"), interactive_hb);
+
+ color_rect = memnew(ColorRect);
+ main_vbox->add_margin_child(TTR("Preview:"), color_rect);
+
+ color_rect->set_custom_minimum_size(Size2(600, 200) * EDSCALE);
+ color_rect->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+
+ _player = memnew(AudioStreamPlayer);
+ _player->connect("finished", callable_mp(this, &AudioStreamImportSettings::_on_finished));
+ color_rect->add_child(_player);
+
+ VBoxContainer *vbox = memnew(VBoxContainer);
+ vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, 0);
+ color_rect->add_child(vbox);
+ vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+
+ _preview = memnew(ColorRect);
+ _preview->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ _preview->connect("draw", callable_mp(this, &AudioStreamImportSettings::_draw_preview));
+ _preview->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ vbox->add_child(_preview);
+
+ HBoxContainer *zoom_hbox = memnew(HBoxContainer);
+ zoom_bar = memnew(HScrollBar);
+ zoom_in = memnew(Button);
+ zoom_in->set_flat(true);
+ zoom_reset = memnew(Button);
+ zoom_reset->set_flat(true);
+ zoom_out = memnew(Button);
+ zoom_out->set_flat(true);
+ zoom_hbox->add_child(zoom_bar);
+ zoom_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ zoom_bar->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ zoom_hbox->add_child(zoom_out);
+ zoom_hbox->add_child(zoom_reset);
+ zoom_hbox->add_child(zoom_in);
+ zoom_in->connect("pressed", callable_mp(this, &AudioStreamImportSettings::_preview_zoom_in));
+ zoom_reset->connect("pressed", callable_mp(this, &AudioStreamImportSettings::_preview_zoom_reset));
+ zoom_out->connect("pressed", callable_mp(this, &AudioStreamImportSettings::_preview_zoom_out));
+ zoom_bar->connect("value_changed", callable_mp(this, &AudioStreamImportSettings::_preview_zoom_offset_changed));
+ vbox->add_child(zoom_hbox);
+
+ _indicator = memnew(Control);
+ _indicator->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
+ _indicator->connect("draw", callable_mp(this, &AudioStreamImportSettings::_draw_indicator));
+ _indicator->connect("gui_input", callable_mp(this, &AudioStreamImportSettings::_on_input_indicator));
+ _indicator->connect("mouse_exited", callable_mp(this, &AudioStreamImportSettings::_on_indicator_mouse_exited));
+ _preview->add_child(_indicator);
+
+ HBoxContainer *hbox = memnew(HBoxContainer);
+ hbox->add_theme_constant_override("separation", 0);
+ vbox->add_child(hbox);
+
+ _play_button = memnew(Button);
+ _play_button->set_flat(true);
+ hbox->add_child(_play_button);
+ _play_button->set_focus_mode(Control::FOCUS_NONE);
+ _play_button->connect("pressed", callable_mp(this, &AudioStreamImportSettings::_play));
+
+ _stop_button = memnew(Button);
+ _stop_button->set_flat(true);
+ hbox->add_child(_stop_button);
+ _stop_button->set_focus_mode(Control::FOCUS_NONE);
+ _stop_button->connect("pressed", callable_mp(this, &AudioStreamImportSettings::_stop));
+
+ _current_label = memnew(Label);
+ _current_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
+ _current_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ _current_label->set_modulate(Color(1, 1, 1, 0.5));
+ hbox->add_child(_current_label);
+
+ _duration_label = memnew(Label);
+ hbox->add_child(_duration_label);
+
+ singleton = this;
+}
diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/import/audio_stream_import_settings.h
index 0d927bddd5..5e399237ca 100644
--- a/editor/plugins/audio_stream_editor_plugin.h
+++ b/editor/import/audio_stream_import_settings.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* audio_stream_editor_plugin.h */
+/* audio_stream_import_settings.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,17 +28,27 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef AUDIO_STREAM_EDITOR_PLUGIN_H
-#define AUDIO_STREAM_EDITOR_PLUGIN_H
+#ifndef AUDIO_STREAM_IMPORT_SETTINGS_H
+#define AUDIO_STREAM_IMPORT_SETTINGS_H
#include "editor/editor_plugin.h"
#include "scene/audio/audio_stream_player.h"
#include "scene/gui/color_rect.h"
+#include "scene/gui/spin_box.h"
#include "scene/resources/texture.h"
-class AudioStreamEditor : public ColorRect {
- GDCLASS(AudioStreamEditor, ColorRect);
+class AudioStreamImportSettings : public ConfirmationDialog {
+ GDCLASS(AudioStreamImportSettings, ConfirmationDialog);
+ CheckBox *bpm_enabled = nullptr;
+ SpinBox *bpm_edit = nullptr;
+ CheckBox *beats_enabled = nullptr;
+ SpinBox *beats_edit = nullptr;
+ Label *bar_beats_label = nullptr;
+ SpinBox *bar_beats_edit = nullptr;
+ CheckBox *loop = nullptr;
+ SpinBox *loop_offset = nullptr;
+ ColorRect *color_rect = nullptr;
Ref<AudioStream> stream;
AudioStreamPlayer *_player = nullptr;
ColorRect *_preview = nullptr;
@@ -46,18 +56,42 @@ class AudioStreamEditor : public ColorRect {
Label *_current_label = nullptr;
Label *_duration_label = nullptr;
+ HScrollBar *zoom_bar = nullptr;
+ Button *zoom_in = nullptr;
+ Button *zoom_reset = nullptr;
+ Button *zoom_out = nullptr;
+
Button *_play_button = nullptr;
Button *_stop_button = nullptr;
+ bool updating_settings = false;
+
float _current = 0;
bool _dragging = false;
+ bool _beat_len_dragging = false;
bool _pausing = false;
+ int _hovering_beat = -1;
+
+ HashMap<StringName, Variant> params;
+ String importer;
+ String path;
void _audio_changed();
+ static AudioStreamImportSettings *singleton;
+
+ void _settings_changed();
+
+ void _reimport();
+
protected:
void _notification(int p_what);
void _preview_changed(ObjectID p_which);
+ void _preview_zoom_in();
+ void _preview_zoom_out();
+ void _preview_zoom_reset();
+ void _preview_zoom_offset_changed(double);
+
void _play();
void _stop();
void _on_finished();
@@ -65,27 +99,16 @@ protected:
void _draw_indicator();
void _on_input_indicator(Ref<InputEvent> p_event);
void _seek_to(real_t p_x);
- static void _bind_methods();
+ void _set_beat_len_to(real_t p_x);
+ void _on_indicator_mouse_exited();
+ int _get_beat_at_pos(real_t p_x);
public:
- void edit(Ref<AudioStream> p_stream);
- AudioStreamEditor();
-};
+ void edit(const String &p_path, const String &p_importer, const Ref<AudioStream> &p_stream);
-class AudioStreamEditorPlugin : public EditorPlugin {
- GDCLASS(AudioStreamEditorPlugin, EditorPlugin);
+ static AudioStreamImportSettings *get_singleton() { return singleton; }
- AudioStreamEditor *audio_editor = nullptr;
-
-public:
- virtual String get_name() const override { return "Audio"; }
- bool has_main_screen() const override { return false; }
- virtual void edit(Object *p_object) override;
- virtual bool handles(Object *p_object) const override;
- virtual void make_visible(bool p_visible) override;
-
- AudioStreamEditorPlugin();
- ~AudioStreamEditorPlugin();
+ AudioStreamImportSettings();
};
-#endif // AUDIO_STREAM_EDITOR_PLUGIN_H
+#endif // AUDIO_STREAM_IMPORT_SETTINGS_H
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp
index ee13a1a9c1..043681aa87 100644
--- a/editor/import/dynamic_font_import_settings.cpp
+++ b/editor/import/dynamic_font_import_settings.cpp
@@ -971,6 +971,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
base_path = p_path;
inspector_vars->edit(nullptr);
+ inspector_text->edit(nullptr);
inspector_general->edit(nullptr);
text_settings_data.instantiate();
diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h
index e45db47440..a75b0a903f 100644
--- a/editor/import/editor_import_collada.h
+++ b/editor/import/editor_import_collada.h
@@ -44,4 +44,4 @@ public:
EditorSceneFormatImporterCollada();
};
-#endif
+#endif // EDITOR_IMPORT_COLLADA_H
diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h
index 44fbd41962..4548513b6f 100644
--- a/editor/import/editor_import_plugin.h
+++ b/editor/import/editor_import_plugin.h
@@ -68,4 +68,4 @@ public:
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override;
};
-#endif //EDITOR_IMPORT_PLUGIN_H
+#endif // EDITOR_IMPORT_PLUGIN_H
diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h
index 8682ab80a3..e791788d50 100644
--- a/editor/import/resource_importer_bitmask.h
+++ b/editor/import/resource_importer_bitmask.h
@@ -53,4 +53,5 @@ public:
ResourceImporterBitMap();
~ResourceImporterBitMap();
};
+
#endif // RESOURCE_IMPORTER_BITMASK_H
diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h
index 306aafa843..2ed121c5e8 100644
--- a/editor/import/resource_importer_csv_translation.h
+++ b/editor/import/resource_importer_csv_translation.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RESOURCEIMPORTERCSVTRANSLATION_H
-#define RESOURCEIMPORTERCSVTRANSLATION_H
+#ifndef RESOURCE_IMPORTER_CSV_TRANSLATION_H
+#define RESOURCE_IMPORTER_CSV_TRANSLATION_H
#include "core/io/resource_importer.h"
@@ -54,4 +54,4 @@ public:
ResourceImporterCSVTranslation();
};
-#endif // RESOURCEIMPORTERCSVTRANSLATION_H
+#endif // RESOURCE_IMPORTER_CSV_TRANSLATION_H
diff --git a/editor/import/resource_importer_imagefont.h b/editor/import/resource_importer_imagefont.h
index f46bc8c19b..e163f873da 100644
--- a/editor/import/resource_importer_imagefont.h
+++ b/editor/import/resource_importer_imagefont.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RESOURCE_IMPORTER_IMAGE_FONT_H
-#define RESOURCE_IMPORTER_IMAGE_FONT_H
+#ifndef RESOURCE_IMPORTER_IMAGEFONT_H
+#define RESOURCE_IMPORTER_IMAGEFONT_H
#include "core/io/resource_importer.h"
#include "scene/resources/font.h"
@@ -55,4 +55,4 @@ public:
ResourceImporterImageFont();
};
-#endif // RESOURCE_IMPORTER_IMAGE_FONT_H
+#endif // RESOURCE_IMPORTER_IMAGEFONT_H
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 3da9f02adb..4dfac90fa1 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RESOURCEIMPORTEROBJ_H
-#define RESOURCEIMPORTEROBJ_H
+#ifndef RESOURCE_IMPORTER_OBJ_H
+#define RESOURCE_IMPORTER_OBJ_H
#include "resource_importer_scene.h"
@@ -69,4 +69,4 @@ public:
ResourceImporterOBJ();
};
-#endif // RESOURCEIMPORTEROBJ_H
+#endif // RESOURCE_IMPORTER_OBJ_H
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index b77c1dccb4..db6ca0cdcf 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RESOURCEIMPORTERSCENE_H
-#define RESOURCEIMPORTERSCENE_H
+#ifndef RESOURCE_IMPORTER_SCENE_H
+#define RESOURCE_IMPORTER_SCENE_H
#include "core/error/error_macros.h"
#include "core/io/resource_importer.h"
@@ -479,4 +479,4 @@ Transform3D ResourceImporterScene::get_collision_shapes_transform(const M &p_opt
return transform;
}
-#endif // RESOURCEIMPORTERSCENE_H
+#endif // RESOURCE_IMPORTER_SCENE_H
diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h
index 7def2d4f77..496ad3bf70 100644
--- a/editor/import/resource_importer_texture.h
+++ b/editor/import/resource_importer_texture.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RESOURCEIMPORTTEXTURE_H
-#define RESOURCEIMPORTTEXTURE_H
+#ifndef RESOURCE_IMPORTER_TEXTURE_H
+#define RESOURCE_IMPORTER_TEXTURE_H
#include "core/io/file_access.h"
#include "core/io/image.h"
@@ -109,4 +109,4 @@ public:
~ResourceImporterTexture();
};
-#endif // RESOURCEIMPORTTEXTURE_H
+#endif // RESOURCE_IMPORTER_TEXTURE_H
diff --git a/editor/import_dock.h b/editor/import_dock.h
index 7f4aa1ddb3..3098c6e815 100644
--- a/editor/import_dock.h
+++ b/editor/import_dock.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef IMPORTDOCK_H
-#define IMPORTDOCK_H
+#ifndef IMPORT_DOCK_H
+#define IMPORT_DOCK_H
#include "core/io/config_file.h"
#include "core/io/resource_importer.h"
@@ -105,4 +105,4 @@ public:
~ImportDock();
};
-#endif // IMPORTDOCK_H
+#endif // IMPORT_DOCK_H
diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h
index 1f2d8afb7d..536852c0f2 100644
--- a/editor/inspector_dock.h
+++ b/editor/inspector_dock.h
@@ -153,4 +153,4 @@ public:
~InspectorDock();
};
-#endif
+#endif // INSPECTOR_DOCK_H
diff --git a/editor/plugins/animation_library_editor.h b/editor/plugins/animation_library_editor.h
index bf89508321..6e214860b8 100644
--- a/editor/plugins/animation_library_editor.h
+++ b/editor/plugins/animation_library_editor.h
@@ -116,4 +116,4 @@ public:
AnimationLibraryEditor();
};
-#endif // ANIMATIONPLAYERLIBRARYEDITOR_H
+#endif // ANIMATION_LIBRARY_EDITOR_H
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index e02662b8db..070d25e29f 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -338,4 +338,4 @@ public:
~AssetLibraryEditorPlugin();
};
-#endif // EDITORASSETLIBRARY_H
+#endif // ASSET_LIBRARY_EDITOR_PLUGIN_H
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
deleted file mode 100644
index 9b874ada45..0000000000
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/*************************************************************************/
-/* audio_stream_editor_plugin.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "audio_stream_editor_plugin.h"
-
-#include "core/config/project_settings.h"
-#include "core/io/resource_loader.h"
-#include "core/os/keyboard.h"
-#include "editor/audio_stream_preview.h"
-#include "editor/editor_node.h"
-#include "editor/editor_scale.h"
-#include "editor/editor_settings.h"
-
-void AudioStreamEditor::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_READY: {
- AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed));
- } break;
-
- case NOTIFICATION_THEME_CHANGED:
- case NOTIFICATION_ENTER_TREE: {
- _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
- _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor")));
- set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor")));
-
- _indicator->update();
- _preview->update();
- } break;
-
- case NOTIFICATION_PROCESS: {
- _current = _player->get_playback_position();
- _indicator->update();
- } break;
-
- case NOTIFICATION_VISIBILITY_CHANGED: {
- if (!is_visible_in_tree()) {
- _stop();
- }
- } break;
- }
-}
-
-void AudioStreamEditor::_draw_preview() {
- Rect2 rect = _preview->get_rect();
- Size2 size = get_size();
-
- Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream);
- float preview_len = preview->get_length();
-
- Vector<Vector2> lines;
- lines.resize(size.width * 2);
-
- for (int i = 0; i < size.width; i++) {
- float ofs = i * preview_len / size.width;
- float ofs_n = (i + 1) * preview_len / size.width;
- float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;
- float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5;
-
- int idx = i;
- lines.write[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y);
- lines.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y);
- }
-
- Vector<Color> color;
- color.push_back(get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")));
-
- RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color);
-}
-
-void AudioStreamEditor::_preview_changed(ObjectID p_which) {
- if (stream.is_valid() && stream->get_instance_id() == p_which) {
- _preview->update();
- }
-}
-
-void AudioStreamEditor::_audio_changed() {
- if (!is_visible()) {
- return;
- }
- update();
-}
-
-void AudioStreamEditor::_play() {
- if (_player->is_playing()) {
- // '_pausing' variable indicates that we want to pause the audio player, not stop it. See '_on_finished()'.
- _pausing = true;
- _player->stop();
- _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- set_process(false);
- } else {
- _player->play(_current);
- _play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")));
- set_process(true);
- }
-}
-
-void AudioStreamEditor::_stop() {
- _player->stop();
- _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- _current = 0;
- _indicator->update();
- set_process(false);
-}
-
-void AudioStreamEditor::_on_finished() {
- _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- if (!_pausing) {
- _current = 0;
- _indicator->update();
- } else {
- _pausing = false;
- }
- set_process(false);
-}
-
-void AudioStreamEditor::_draw_indicator() {
- if (!stream.is_valid()) {
- return;
- }
-
- Rect2 rect = _preview->get_rect();
- float len = stream->get_length();
- float ofs_x = _current / len * rect.size.width;
- const Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
- _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), color, Math::round(2 * EDSCALE));
- _indicator->draw_texture(
- get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")),
- Point2(ofs_x - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, 0),
- color);
-
- _current_label->set_text(String::num(_current, 2).pad_decimals(2) + " /");
-}
-
-void AudioStreamEditor::_on_input_indicator(Ref<InputEvent> p_event) {
- const Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
- if (mb->is_pressed()) {
- _seek_to(mb->get_position().x);
- }
- _dragging = mb->is_pressed();
- }
-
- const Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid()) {
- if (_dragging) {
- _seek_to(mm->get_position().x);
- }
- }
-}
-
-void AudioStreamEditor::_seek_to(real_t p_x) {
- _current = p_x / _preview->get_rect().size.x * stream->get_length();
- _current = CLAMP(_current, 0, stream->get_length());
- _player->seek(_current);
- _indicator->update();
-}
-
-void AudioStreamEditor::edit(Ref<AudioStream> p_stream) {
- if (!stream.is_null()) {
- stream->disconnect("changed", callable_mp(this, &AudioStreamEditor::_audio_changed));
- }
-
- stream = p_stream;
- _player->set_stream(stream);
- _current = 0;
- String text = String::num(stream->get_length(), 2).pad_decimals(2) + "s";
- _duration_label->set_text(text);
-
- if (!stream.is_null()) {
- stream->connect("changed", callable_mp(this, &AudioStreamEditor::_audio_changed));
- update();
- } else {
- hide();
- }
-}
-
-void AudioStreamEditor::_bind_methods() {
-}
-
-AudioStreamEditor::AudioStreamEditor() {
- set_custom_minimum_size(Size2(1, 100) * EDSCALE);
-
- _player = memnew(AudioStreamPlayer);
- _player->connect("finished", callable_mp(this, &AudioStreamEditor::_on_finished));
- add_child(_player);
-
- VBoxContainer *vbox = memnew(VBoxContainer);
- vbox->set_anchors_and_offsets_preset(PRESET_FULL_RECT, PRESET_MODE_MINSIZE, 0);
- add_child(vbox);
-
- _preview = memnew(ColorRect);
- _preview->set_v_size_flags(SIZE_EXPAND_FILL);
- _preview->connect("draw", callable_mp(this, &AudioStreamEditor::_draw_preview));
- vbox->add_child(_preview);
-
- _indicator = memnew(Control);
- _indicator->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
- _indicator->connect("draw", callable_mp(this, &AudioStreamEditor::_draw_indicator));
- _indicator->connect("gui_input", callable_mp(this, &AudioStreamEditor::_on_input_indicator));
- _preview->add_child(_indicator);
-
- HBoxContainer *hbox = memnew(HBoxContainer);
- hbox->add_theme_constant_override("separation", 0);
- vbox->add_child(hbox);
-
- _play_button = memnew(Button);
- _play_button->set_flat(true);
- hbox->add_child(_play_button);
- _play_button->set_focus_mode(Control::FOCUS_NONE);
- _play_button->connect("pressed", callable_mp(this, &AudioStreamEditor::_play));
- _play_button->set_shortcut(ED_SHORTCUT("inspector/audio_preview_play_pause", TTR("Audio Preview Play/Pause"), Key::SPACE));
-
- _stop_button = memnew(Button);
- _stop_button->set_flat(true);
- hbox->add_child(_stop_button);
- _stop_button->set_focus_mode(Control::FOCUS_NONE);
- _stop_button->connect("pressed", callable_mp(this, &AudioStreamEditor::_stop));
-
- _current_label = memnew(Label);
- _current_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
- _current_label->set_h_size_flags(SIZE_EXPAND_FILL);
- _current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- _current_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
- _current_label->set_modulate(Color(1, 1, 1, 0.5));
- hbox->add_child(_current_label);
-
- _duration_label = memnew(Label);
- _duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- _duration_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
- hbox->add_child(_duration_label);
-}
-
-void AudioStreamEditorPlugin::edit(Object *p_object) {
- AudioStream *s = Object::cast_to<AudioStream>(p_object);
- if (!s) {
- return;
- }
-
- audio_editor->edit(Ref<AudioStream>(s));
-}
-
-bool AudioStreamEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("AudioStream");
-}
-
-void AudioStreamEditorPlugin::make_visible(bool p_visible) {
- audio_editor->set_visible(p_visible);
-}
-
-AudioStreamEditorPlugin::AudioStreamEditorPlugin() {
- audio_editor = memnew(AudioStreamEditor);
- add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, audio_editor);
- audio_editor->hide();
-}
-
-AudioStreamEditorPlugin::~AudioStreamEditorPlugin() {
-}
diff --git a/editor/plugins/bit_map_editor_plugin.h b/editor/plugins/bit_map_editor_plugin.h
index c883e5542f..b045f8c751 100644
--- a/editor/plugins/bit_map_editor_plugin.h
+++ b/editor/plugins/bit_map_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef BIT_MAP_PREVIEW_EDITOR_PLUGIN_H
-#define BIT_MAP_PREVIEW_EDITOR_PLUGIN_H
+#ifndef BIT_MAP_EDITOR_PLUGIN_H
+#define BIT_MAP_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/resources/bit_map.h"
@@ -61,4 +61,4 @@ public:
BitMapEditorPlugin();
};
-#endif // BIT_MAP_PREVIEW_EDITOR_PLUGIN_H
+#endif // BIT_MAP_EDITOR_PLUGIN_H
diff --git a/editor/plugins/bone_map_editor_plugin.h b/editor/plugins/bone_map_editor_plugin.h
index e1ea6b4060..79fb47505b 100644
--- a/editor/plugins/bone_map_editor_plugin.h
+++ b/editor/plugins/bone_map_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef BONE_MAP_EDITOR_H
-#define BONE_MAP_EDITOR_H
+#ifndef BONE_MAP_EDITOR_PLUGIN_H
+#define BONE_MAP_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
@@ -176,4 +176,4 @@ public:
BoneMapEditorPlugin();
};
-#endif // BONE_MAP_EDITOR_H
+#endif // BONE_MAP_EDITOR_PLUGIN_H
diff --git a/editor/plugins/camera_3d_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h
index a8164f9b85..a969b31976 100644
--- a/editor/plugins/camera_3d_editor_plugin.h
+++ b/editor/plugins/camera_3d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CAMERA_EDITOR_PLUGIN_H
-#define CAMERA_EDITOR_PLUGIN_H
+#ifndef CAMERA_3D_EDITOR_PLUGIN_H
+#define CAMERA_3D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/3d/camera_3d.h"
@@ -68,4 +68,4 @@ public:
~Camera3DEditorPlugin();
};
-#endif // CAMERA_EDITOR_PLUGIN_H
+#endif // CAMERA_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 18c898521d..5b368de3cc 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -630,4 +630,4 @@ public:
~CanvasItemEditorViewport();
};
-#endif //CANVAS_ITEM_EDITOR_PLUGIN_H
+#endif // CANVAS_ITEM_EDITOR_PLUGIN_H
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index da9e9f339f..f7de05ddd1 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -112,4 +112,4 @@ public:
~CollisionShape2DEditorPlugin();
};
-#endif //COLLISION_SHAPE_2D_EDITOR_PLUGIN_H
+#endif // COLLISION_SHAPE_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/control_editor_plugin.h b/editor/plugins/control_editor_plugin.h
index d3f1d3acbb..11389bc095 100644
--- a/editor/plugins/control_editor_plugin.h
+++ b/editor/plugins/control_editor_plugin.h
@@ -247,4 +247,4 @@ public:
ControlEditorPlugin();
};
-#endif //CONTROL_EDITOR_PLUGIN_H
+#endif // CONTROL_EDITOR_PLUGIN_H
diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h
index 70f2da4b2d..f38349985c 100644
--- a/editor/plugins/cpu_particles_3d_editor_plugin.h
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CPU_PARTICLES_EDITOR_PLUGIN_H
-#define CPU_PARTICLES_EDITOR_PLUGIN_H
+#ifndef CPU_PARTICLES_3D_EDITOR_PLUGIN_H
+#define CPU_PARTICLES_3D_EDITOR_PLUGIN_H
#include "editor/plugins/gpu_particles_3d_editor_plugin.h"
#include "scene/3d/cpu_particles_3d.h"
@@ -78,4 +78,4 @@ public:
~CPUParticles3DEditorPlugin();
};
-#endif // CPU_PARTICLES_EDITOR_PLUGIN_H
+#endif // CPU_PARTICLES_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 478f4264e5..6b632101d3 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -599,7 +599,7 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const Ref<Resource> &p_f
uint8_t *imgdata = img.ptrw();
uint8_t *imgw = imgdata;
- Ref<AudioStreamPlayback> playback = stream->instance_playback();
+ Ref<AudioStreamPlayback> playback = stream->instantiate_playback();
ERR_FAIL_COND_V(playback.is_null(), Ref<Texture2D>());
real_t len_s = stream->get_length();
diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h
index f548683b70..163cfe79f9 100644
--- a/editor/plugins/editor_preview_plugins.h
+++ b/editor/plugins/editor_preview_plugins.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef EDITORPREVIEWPLUGINS_H
-#define EDITORPREVIEWPLUGINS_H
+#ifndef EDITOR_PREVIEW_PLUGINS_H
+#define EDITOR_PREVIEW_PLUGINS_H
#include "core/templates/safe_refcount.h"
#include "editor/editor_resource_preview.h"
@@ -193,4 +193,5 @@ public:
EditorGradientPreviewPlugin();
};
-#endif // EDITORPREVIEWPLUGINS_H
+
+#endif // EDITOR_PREVIEW_PLUGINS_H
diff --git a/editor/plugins/font_config_plugin.h b/editor/plugins/font_config_plugin.h
index 9b7ee55870..67c16bfe60 100644
--- a/editor/plugins/font_config_plugin.h
+++ b/editor/plugins/font_config_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef OT_FEATURES_PLUGIN_H
-#define OT_FEATURES_PLUGIN_H
+#ifndef FONT_CONFIG_PLUGIN_H
+#define FONT_CONFIG_PLUGIN_H
#include "core/io/marshalls.h"
#include "editor/editor_plugin.h"
@@ -258,4 +258,4 @@ public:
virtual String get_name() const override { return "Font"; }
};
-#endif // OT_FEATURES_PLUGIN_H
+#endif // FONT_CONFIG_PLUGIN_H
diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h
index b91a17d9e5..b5eca46ad3 100644
--- a/editor/plugins/gdextension_export_plugin.h
+++ b/editor/plugins/gdextension_export_plugin.h
@@ -31,7 +31,7 @@
#ifndef GDEXTENSION_EXPORT_PLUGIN_H
#define GDEXTENSION_EXPORT_PLUGIN_H
-#include "editor/editor_export.h"
+#include "editor/export/editor_export.h"
class GDExtensionExportPlugin : public EditorExportPlugin {
protected:
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h
index 75f68617d1..bf49a82166 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.h
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PARTICLES_2D_EDITOR_PLUGIN_H
-#define PARTICLES_2D_EDITOR_PLUGIN_H
+#ifndef GPU_PARTICLES_2D_EDITOR_PLUGIN_H
+#define GPU_PARTICLES_2D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/2d/collision_polygon_2d.h"
@@ -97,4 +97,4 @@ public:
~GPUParticles2DEditorPlugin();
};
-#endif // PARTICLES_2D_EDITOR_PLUGIN_H
+#endif // GPU_PARTICLES_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h
index 6ba6d102ef..17bdfa6e3f 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.h
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PARTICLES_EDITOR_PLUGIN_H
-#define PARTICLES_EDITOR_PLUGIN_H
+#ifndef GPU_PARTICLES_3D_EDITOR_PLUGIN_H
+#define GPU_PARTICLES_3D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/3d/gpu_particles_3d.h"
@@ -114,4 +114,4 @@ public:
~GPUParticles3DEditorPlugin();
};
-#endif // PARTICLES_EDITOR_PLUGIN_H
+#endif // GPU_PARTICLES_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index 1386f03662..5c7047a81f 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -85,6 +85,7 @@ void GradientEditor::reverse_gradient() {
}
GradientEditor::GradientEditor() {
+ GradientEdit::get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(GradientEdit::get_picker()));
editing = false;
}
diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.h b/editor/plugins/gradient_texture_2d_editor_plugin.h
index 4ce64ce1dc..93c49b1e6f 100644
--- a/editor/plugins/gradient_texture_2d_editor_plugin.h
+++ b/editor/plugins/gradient_texture_2d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GRADIENT_TEXTURE_2D_EDITOR
-#define GRADIENT_TEXTURE_2D_EDITOR
+#ifndef GRADIENT_TEXTURE_2D_EDITOR_PLUGIN_H
+#define GRADIENT_TEXTURE_2D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "editor/editor_spin_slider.h"
@@ -109,4 +109,4 @@ public:
GradientTexture2DEditorPlugin();
};
-#endif
+#endif // GRADIENT_TEXTURE_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/lightmap_gi_editor_plugin.h b/editor/plugins/lightmap_gi_editor_plugin.h
index 1202efe8fc..a06f97fc94 100644
--- a/editor/plugins/lightmap_gi_editor_plugin.h
+++ b/editor/plugins/lightmap_gi_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef BAKED_LIGHTMAP_EDITOR_PLUGIN_H
-#define BAKED_LIGHTMAP_EDITOR_PLUGIN_H
+#ifndef LIGHTMAP_GI_EDITOR_PLUGIN_H
+#define LIGHTMAP_GI_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/3d/lightmap_gi.h"
@@ -67,4 +67,4 @@ public:
~LightmapGIEditorPlugin();
};
-#endif
+#endif // LIGHTMAP_GI_EDITOR_PLUGIN_H
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 34db75f118..e21cb7e76a 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -155,7 +155,9 @@ MaterialEditor::MaterialEditor() {
camera = memnew(Camera3D);
camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 3)));
- camera->set_perspective(45, 0.1, 10);
+ // Use low field of view so the sphere/box is fully encompassed within the preview,
+ // without much distortion.
+ camera->set_perspective(20, 0.1, 10);
camera->make_current();
viewport->add_child(camera);
@@ -177,8 +179,8 @@ MaterialEditor::MaterialEditor() {
Transform3D box_xform;
box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0));
box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0));
- box_xform.basis.scale(Vector3(0.8, 0.8, 0.8));
- box_xform.origin.y = 0.2;
+ box_xform.basis.scale(Vector3(0.7, 0.7, 0.7));
+ box_xform.origin.y = 0.05;
box_instance->set_transform(box_xform);
sphere_mesh.instantiate();
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 3554b3c1e9..fb61f03485 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -87,4 +87,4 @@ public:
MeshEditorPlugin();
};
-#endif
+#endif // MESH_EDITOR_PLUGIN_H
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h
index 36d8eacd98..7968176744 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.h
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef MESH_INSTANCE_EDITOR_PLUGIN_H
-#define MESH_INSTANCE_EDITOR_PLUGIN_H
+#ifndef MESH_INSTANCE_3D_EDITOR_PLUGIN_H
+#define MESH_INSTANCE_3D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/3d/mesh_instance_3d.h"
@@ -97,4 +97,4 @@ public:
~MeshInstance3DEditorPlugin();
};
-#endif // MESH_EDITOR_PLUGIN_H
+#endif // MESH_INSTANCE_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 7550b75fa3..239da88ba2 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef NAVIGATIONPOLYGONEDITORPLUGIN_H
-#define NAVIGATIONPOLYGONEDITORPLUGIN_H
+#ifndef NAVIGATION_POLYGON_EDITOR_PLUGIN_H
+#define NAVIGATION_POLYGON_EDITOR_PLUGIN_H
#include "editor/plugins/abstract_polygon_2d_editor.h"
#include "scene/2d/navigation_region_2d.h"
@@ -67,4 +67,4 @@ public:
NavigationPolygonEditorPlugin();
};
-#endif // NAVIGATIONPOLYGONEDITORPLUGIN_H
+#endif // NAVIGATION_POLYGON_EDITOR_PLUGIN_H
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 6543da8776..44ab4e0a41 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -33,8 +33,8 @@
#include "core/config/project_settings.h"
#include "core/input/input.h"
#include "core/input/input_map.h"
-#include "core/math/camera_matrix.h"
#include "core/math/math_funcs.h"
+#include "core/math/projection.h"
#include "core/os/keyboard.h"
#include "core/templates/sort_array.h"
#include "editor/debugger/editor_debugger_node.h"
@@ -642,7 +642,7 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, Vector<_RayRe
}
Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
- CameraMatrix cm;
+ Projection cm;
if (orthogonal) {
cm.set_orthogonal(camera->get_size(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar());
} else {
@@ -6639,7 +6639,7 @@ void Node3DEditor::_finish_grid() {
}
void Node3DEditor::update_grid() {
- const Camera3D::Projection current_projection = viewports[0]->camera->get_projection();
+ const Camera3D::ProjectionType current_projection = viewports[0]->camera->get_projection();
if (current_projection != grid_camera_last_update_perspective) {
grid_init_draw = false; // redraw
@@ -8028,6 +8028,7 @@ void fragment() {
sun_color->set_edit_alpha(false);
sun_vb->add_margin_child(TTR("Sun Color"), sun_color);
sun_color->connect("color_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
+ sun_color->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(sun_color->get_picker()));
sun_energy = memnew(EditorSpinSlider);
sun_vb->add_margin_child(TTR("Sun Energy"), sun_energy);
@@ -8073,10 +8074,12 @@ void fragment() {
environ_sky_color = memnew(ColorPickerButton);
environ_sky_color->set_edit_alpha(false);
environ_sky_color->connect("color_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
+ environ_sky_color->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(environ_sky_color->get_picker()));
environ_vb->add_margin_child(TTR("Sky Color"), environ_sky_color);
environ_ground_color = memnew(ColorPickerButton);
environ_ground_color->connect("color_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
environ_ground_color->set_edit_alpha(false);
+ environ_ground_color->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(environ_ground_color->get_picker()));
environ_vb->add_margin_child(TTR("Ground Color"), environ_ground_color);
environ_energy = memnew(EditorSpinSlider);
environ_energy->connect("value_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index c98022bcf7..244b461e16 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -560,7 +560,7 @@ private:
bool grid_enable[3]; //should be always visible if true
bool grid_enabled = false;
bool grid_init_draw = false;
- Camera3D::Projection grid_camera_last_update_perspective = Camera3D::PROJECTION_PERSPECTIVE;
+ Camera3D::ProjectionType grid_camera_last_update_perspective = Camera3D::PROJECTION_PERSPECTIVE;
Vector3 grid_camera_last_update_position = Vector3();
Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[4], scale_gizmo[3], scale_plane_gizmo[3], axis_gizmo[3];
diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.h b/editor/plugins/occluder_instance_3d_editor_plugin.h
index 360b7297cf..e8d98927f4 100644
--- a/editor/plugins/occluder_instance_3d_editor_plugin.h
+++ b/editor/plugins/occluder_instance_3d_editor_plugin.h
@@ -63,4 +63,4 @@ public:
~OccluderInstance3DEditorPlugin();
};
-#endif
+#endif // OCCLUDER_INSTANCE_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h
index ee31fcf43d..53e4e2efa8 100644
--- a/editor/plugins/path_3d_editor_plugin.h
+++ b/editor/plugins/path_3d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PATH_EDITOR_PLUGIN_H
-#define PATH_EDITOR_PLUGIN_H
+#ifndef PATH_3D_EDITOR_PLUGIN_H
+#define PATH_3D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "editor/plugins/node_3d_editor_gizmos.h"
@@ -118,4 +118,4 @@ public:
~Path3DEditorPlugin();
};
-#endif // PATH_EDITOR_PLUGIN_H
+#endif // PATH_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/physical_bone_3d_editor_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h
index 93e722a432..f15eab7991 100644
--- a/editor/plugins/physical_bone_3d_editor_plugin.h
+++ b/editor/plugins/physical_bone_3d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PHYSICAL_BONE_PLUGIN_H
-#define PHYSICAL_BONE_PLUGIN_H
+#ifndef PHYSICAL_BONE_3D_EDITOR_PLUGIN_H
+#define PHYSICAL_BONE_3D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/3d/physics_body_3d.h"
@@ -76,4 +76,4 @@ public:
PhysicalBone3DEditorPlugin();
};
-#endif
+#endif // PHYSICAL_BONE_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index fc545b44e8..14e3eb5402 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1862,16 +1862,10 @@ void ScriptTextEditor::_enable_code_editor() {
color_picker = memnew(ColorPicker);
color_picker->set_deferred_mode(true);
color_picker->connect("color_changed", callable_mp(this, &ScriptTextEditor::_color_changed));
+ color_panel->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(color_picker));
color_panel->add_child(color_picker);
- // get default color picker mode from editor settings
- int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
- color_picker->set_color_mode((ColorPicker::ColorModeType)default_color_mode);
-
- int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
- color_picker->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
-
quick_open = memnew(ScriptEditorQuickOpen);
quick_open->connect("goto_line", callable_mp(this, &ScriptTextEditor::_goto_line));
add_child(quick_open);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 70b8c3aaa7..bdf566e991 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -45,6 +45,7 @@
#include "editor/shader_create_dialog.h"
#include "scene/gui/split_container.h"
#include "servers/display_server.h"
+#include "servers/rendering/shader_preprocessor.h"
#include "servers/rendering/shader_types.h"
/*** SHADER SCRIPT EDITOR ****/
@@ -72,15 +73,65 @@ Ref<Shader> ShaderTextEditor::get_edited_shader() const {
return shader;
}
+Ref<ShaderInclude> ShaderTextEditor::get_edited_shader_include() const {
+ return shader_inc;
+}
+
void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
+ set_edited_shader(p_shader, p_shader->get_code());
+}
+
+void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader, const String &p_code) {
if (shader == p_shader) {
return;
}
+ if (shader.is_valid()) {
+ shader->disconnect(SNAME("changed"), callable_mp(this, &ShaderTextEditor::_shader_changed));
+ }
shader = p_shader;
+ shader_inc = Ref<ShaderInclude>();
+
+ set_edited_code(p_code);
+
+ if (shader.is_valid()) {
+ shader->connect(SNAME("changed"), callable_mp(this, &ShaderTextEditor::_shader_changed));
+ }
+}
+
+void ShaderTextEditor::set_edited_shader_include(const Ref<ShaderInclude> &p_shader_inc) {
+ set_edited_shader_include(p_shader_inc, p_shader_inc->get_code());
+}
+void ShaderTextEditor::_shader_changed() {
+ // This function is used for dependencies (include changing changes main shader and forces it to revalidate)
+ if (block_shader_changed) {
+ return;
+ }
+ dependencies_version++;
+ _validate_script();
+}
+
+void ShaderTextEditor::set_edited_shader_include(const Ref<ShaderInclude> &p_shader_inc, const String &p_code) {
+ if (shader_inc == p_shader_inc) {
+ return;
+ }
+ if (shader_inc.is_valid()) {
+ shader_inc->disconnect(SNAME("changed"), callable_mp(this, &ShaderTextEditor::_shader_changed));
+ }
+ shader_inc = p_shader_inc;
+ shader = Ref<Shader>();
+
+ set_edited_code(p_code);
+
+ if (shader_inc.is_valid()) {
+ shader_inc->connect(SNAME("changed"), callable_mp(this, &ShaderTextEditor::_shader_changed));
+ }
+}
+
+void ShaderTextEditor::set_edited_code(const String &p_code) {
_load_theme_settings();
- get_text_editor()->set_text(p_shader->get_code());
+ get_text_editor()->set_text(p_code);
get_text_editor()->clear_undo_history();
get_text_editor()->call_deferred(SNAME("set_h_scroll"), 0);
get_text_editor()->call_deferred(SNAME("set_v_scroll"), 0);
@@ -132,11 +183,12 @@ void ShaderTextEditor::_load_theme_settings() {
syntax_highlighter->clear_keyword_colors();
- List<String> keywords;
- ShaderLanguage::get_keyword_list(&keywords);
const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ List<String> keywords;
+ ShaderLanguage::get_keyword_list(&keywords);
+
for (const String &E : keywords) {
if (ShaderLanguage::is_control_flow_keyword(E)) {
syntax_highlighter->add_keyword_color(E, control_flow_keyword_color);
@@ -145,11 +197,41 @@ void ShaderTextEditor::_load_theme_settings() {
}
}
+ List<String> pp_keywords;
+ ShaderPreprocessor::get_keyword_list(&pp_keywords, false);
+
+ for (const String &E : pp_keywords) {
+ syntax_highlighter->add_keyword_color(E, keyword_color);
+ }
+
// Colorize built-ins like `COLOR` differently to make them easier
// to distinguish from keywords at a quick glance.
List<String> built_ins;
- if (shader.is_valid()) {
+
+ if (shader_inc.is_valid()) {
+ for (int i = 0; i < RenderingServer::SHADER_MAX; i++) {
+ for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(i))) {
+ for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) {
+ built_ins.push_back(F.key);
+ }
+ }
+
+ const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i));
+
+ for (int j = 0; j < modes.size(); j++) {
+ const ShaderLanguage::ModeInfo &info = modes[j];
+
+ if (!info.options.is_empty()) {
+ for (int k = 0; k < info.options.size(); k++) {
+ built_ins.push_back(String(info.name) + "_" + String(info.options[k]));
+ }
+ } else {
+ built_ins.push_back(String(info.name));
+ }
+ }
+ }
+ } else if (shader.is_valid()) {
for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()))) {
for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) {
built_ins.push_back(F.key);
@@ -191,8 +273,12 @@ void ShaderTextEditor::_load_theme_settings() {
text_editor->add_auto_brace_completion_pair("/*", "*/");
}
+ // Colorize preprocessor include strings.
+ const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ syntax_highlighter->add_color_region("\"", "\"", string_color, false);
+
if (warnings_panel) {
- // Warnings panel
+ // Warnings panel.
warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts")));
warnings_panel->add_theme_font_size_override("normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")));
}
@@ -216,7 +302,9 @@ void ShaderTextEditor::_check_shader_mode() {
}
if (shader->get_mode() != mode) {
+ set_block_shader_changed(true);
shader->set_code(get_text_editor()->get_text());
+ set_block_shader_changed(false);
_load_theme_settings();
}
}
@@ -226,72 +314,192 @@ static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_va
return (ShaderLanguage::DataType)RS::global_variable_type_get_shader_datatype(gvt);
}
+static String complete_from_path;
+
+static void _complete_include_paths_search(EditorFileSystemDirectory *p_efsd, List<ScriptLanguage::CodeCompletionOption> *r_options) {
+ if (!p_efsd) {
+ return;
+ }
+ for (int i = 0; i < p_efsd->get_file_count(); i++) {
+ if (p_efsd->get_file_type(i) == SNAME("ShaderInclude")) {
+ String path = p_efsd->get_file_path(i);
+ if (path.begins_with(complete_from_path)) {
+ path = path.replace_first(complete_from_path, "");
+ }
+ r_options->push_back(ScriptLanguage::CodeCompletionOption(path, ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH));
+ }
+ }
+ for (int j = 0; j < p_efsd->get_subdir_count(); j++) {
+ _complete_include_paths_search(p_efsd->get_subdir(j), r_options);
+ }
+}
+
+static void _complete_include_paths(List<ScriptLanguage::CodeCompletionOption> *r_options) {
+ _complete_include_paths_search(EditorFileSystem::get_singleton()->get_filesystem(), r_options);
+}
+
void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options) {
- _check_shader_mode();
+ List<ScriptLanguage::CodeCompletionOption> pp_options;
+ ShaderPreprocessor preprocessor;
+ String code;
+ complete_from_path = (shader.is_valid() ? shader->get_path() : shader_inc->get_path()).get_base_dir();
+ if (!complete_from_path.ends_with("/")) {
+ complete_from_path += "/";
+ }
+ preprocessor.preprocess(p_code, code, nullptr, nullptr, nullptr, &pp_options, _complete_include_paths);
+ complete_from_path = String();
+ if (pp_options.size()) {
+ for (const ScriptLanguage::CodeCompletionOption &E : pp_options) {
+ r_options->push_back(E);
+ }
+ return;
+ }
ShaderLanguage sl;
String calltip;
-
ShaderLanguage::ShaderCompileInfo info;
+ info.global_variable_type_func = _get_global_variable_type;
+
+ if (shader.is_null()) {
+ info.is_include = true;
+
+ sl.complete(code, info, r_options, calltip);
+ get_text_editor()->set_code_hint(calltip);
+ return;
+ }
+ _check_shader_mode();
info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()));
info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
info.shader_types = ShaderTypes::get_singleton()->get_types();
- info.global_variable_type_func = _get_global_variable_type;
-
- sl.complete(p_code, info, r_options, calltip);
+ sl.complete(code, info, r_options, calltip);
get_text_editor()->set_code_hint(calltip);
}
void ShaderTextEditor::_validate_script() {
- _check_shader_mode();
+ emit_signal(SNAME("script_changed")); // Ensure to notify that it changed, so it is applied
- String code = get_text_editor()->get_text();
- //List<StringName> params;
- //shader->get_param_list(&params);
+ String code;
- ShaderLanguage::ShaderCompileInfo info;
- info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()));
- info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
- info.shader_types = ShaderTypes::get_singleton()->get_types();
- info.global_variable_type_func = _get_global_variable_type;
-
- ShaderLanguage sl;
+ if (shader.is_valid()) {
+ _check_shader_mode();
+ code = shader->get_code();
+ } else {
+ code = shader_inc->get_code();
+ }
- sl.enable_warning_checking(saved_warnings_enabled);
- sl.set_warning_flags(saved_warning_flags);
+ ShaderPreprocessor preprocessor;
+ String code_pp;
+ String error_pp;
+ List<ShaderPreprocessor::FilePosition> err_positions;
+ last_compile_result = preprocessor.preprocess(code, code_pp, &error_pp, &err_positions);
- last_compile_result = sl.compile(code, info);
+ for (int i = 0; i < get_text_editor()->get_line_count(); i++) {
+ get_text_editor()->set_line_background_color(i, Color(0, 0, 0, 0));
+ }
+ set_error("");
+ set_error_count(0);
if (last_compile_result != OK) {
- String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
+ //preprocessor error
+ ERR_FAIL_COND(err_positions.size() == 0);
+
+ String error_text = error_pp;
+ int error_line = err_positions.front()->get().line;
+ if (err_positions.size() == 1) {
+ // Error in main file
+ error_text = "error(" + itos(error_line) + "): " + error_text;
+ } else {
+ error_text = "error(" + itos(error_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + error_text;
+ set_error_count(err_positions.size() - 1);
+ }
+
set_error(error_text);
- set_error_pos(sl.get_error_line() - 1, 0);
+ set_error_pos(error_line - 1, 0);
for (int i = 0; i < get_text_editor()->get_line_count(); i++) {
get_text_editor()->set_line_background_color(i, Color(0, 0, 0, 0));
}
- get_text_editor()->set_line_background_color(sl.get_error_line() - 1, marked_line_color);
+ get_text_editor()->set_line_background_color(error_line - 1, marked_line_color);
+
+ set_warning_count(0);
+
} else {
- for (int i = 0; i < get_text_editor()->get_line_count(); i++) {
- get_text_editor()->set_line_background_color(i, Color(0, 0, 0, 0));
+ ShaderLanguage sl;
+
+ sl.enable_warning_checking(saved_warnings_enabled);
+ uint32_t flags = saved_warning_flags;
+ if (shader.is_null()) {
+ if (flags & ShaderWarning::UNUSED_CONSTANT) {
+ flags &= ~(ShaderWarning::UNUSED_CONSTANT);
+ }
+ if (flags & ShaderWarning::UNUSED_FUNCTION) {
+ flags &= ~(ShaderWarning::UNUSED_FUNCTION);
+ }
+ if (flags & ShaderWarning::UNUSED_STRUCT) {
+ flags &= ~(ShaderWarning::UNUSED_STRUCT);
+ }
+ if (flags & ShaderWarning::UNUSED_UNIFORM) {
+ flags &= ~(ShaderWarning::UNUSED_UNIFORM);
+ }
+ if (flags & ShaderWarning::UNUSED_VARYING) {
+ flags &= ~(ShaderWarning::UNUSED_VARYING);
+ }
}
- set_error("");
- }
+ sl.set_warning_flags(flags);
- if (warnings.size() > 0 || last_compile_result != OK) {
- warnings_panel->clear();
- }
- warnings.clear();
- for (List<ShaderWarning>::Element *E = sl.get_warnings_ptr(); E; E = E->next()) {
- warnings.push_back(E->get());
- }
- if (warnings.size() > 0 && last_compile_result == OK) {
- warnings.sort_custom<WarningsComparator>();
- _update_warning_panel();
- } else {
- set_warning_count(0);
+ ShaderLanguage::ShaderCompileInfo info;
+ info.global_variable_type_func = _get_global_variable_type;
+
+ if (shader.is_null()) {
+ info.is_include = true;
+ } else {
+ Shader::Mode mode = shader->get_mode();
+ info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode));
+ info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode));
+ info.shader_types = ShaderTypes::get_singleton()->get_types();
+ }
+
+ code = code_pp;
+ //compiler error
+ last_compile_result = sl.compile(code, info);
+
+ if (last_compile_result != OK) {
+ String error_text;
+ int error_line;
+ Vector<ShaderLanguage::FilePosition> include_positions = sl.get_include_positions();
+ if (include_positions.size() > 1) {
+ //error is in an include
+ error_line = include_positions[0].line;
+ error_text = "error(" + itos(error_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text();
+ set_error_count(include_positions.size() - 1);
+ } else {
+ error_line = sl.get_error_line();
+ error_text = "error(" + itos(error_line) + "): " + sl.get_error_text();
+ set_error_count(0);
+ }
+ set_error(error_text);
+ set_error_pos(error_line - 1, 0);
+ get_text_editor()->set_line_background_color(error_line - 1, marked_line_color);
+ } else {
+ set_error("");
+ }
+
+ if (warnings.size() > 0 || last_compile_result != OK) {
+ warnings_panel->clear();
+ }
+ warnings.clear();
+ for (List<ShaderWarning>::Element *E = sl.get_warnings_ptr(); E; E = E->next()) {
+ warnings.push_back(E->get());
+ }
+ if (warnings.size() > 0 && last_compile_result == OK) {
+ warnings.sort_custom<WarningsComparator>();
+ _update_warning_panel();
+ } else {
+ set_warning_count(0);
+ }
}
- emit_signal(SNAME("script_changed"));
+
+ emit_signal(SNAME("script_validated"), last_compile_result == OK); // Notify that validation finished, to update the list of scripts
}
void ShaderTextEditor::_update_warning_panel() {
@@ -338,6 +546,7 @@ void ShaderTextEditor::_update_warning_panel() {
}
void ShaderTextEditor::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("script_validated", PropertyInfo(Variant::BOOL, "valid")));
}
ShaderTextEditor::ShaderTextEditor() {
@@ -473,6 +682,8 @@ void ShaderEditor::_warning_clicked(Variant p_line) {
void ShaderEditor::_bind_methods() {
ClassDB::bind_method("_show_warnings_panel", &ShaderEditor::_show_warnings_panel);
ClassDB::bind_method("_warning_clicked", &ShaderEditor::_warning_clicked);
+
+ ADD_SIGNAL(MethodInfo("validation_changed"));
}
void ShaderEditor::ensure_select_current() {
@@ -524,15 +735,23 @@ void ShaderEditor::_update_warnings(bool p_validate) {
}
void ShaderEditor::_check_for_external_edit() {
- if (shader.is_null() || !shader.is_valid()) {
+ bool use_autoreload = bool(EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change"));
+
+ if (shader_inc.is_valid()) {
+ if (shader_inc->get_last_modified_time() != FileAccess::get_modified_time(shader_inc->get_path())) {
+ if (use_autoreload) {
+ _reload_shader_include_from_disk();
+ } else {
+ disk_changed->call_deferred(SNAME("popup_centered"));
+ }
+ }
return;
}
- if (shader->is_built_in()) {
+ if (shader.is_null() || shader->is_built_in()) {
return;
}
- bool use_autoreload = bool(EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change"));
if (shader->get_last_modified_time() != FileAccess::get_modified_time(shader->get_path())) {
if (use_autoreload) {
_reload_shader_from_disk();
@@ -546,11 +765,32 @@ void ShaderEditor::_reload_shader_from_disk() {
Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
ERR_FAIL_COND(!rel_shader.is_valid());
+ shader_editor->set_block_shader_changed(true);
shader->set_code(rel_shader->get_code());
+ shader_editor->set_block_shader_changed(false);
shader->set_last_modified_time(rel_shader->get_last_modified_time());
shader_editor->reload_text();
}
+void ShaderEditor::_reload_shader_include_from_disk() {
+ Ref<ShaderInclude> rel_shader_include = ResourceLoader::load(shader_inc->get_path(), shader_inc->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
+ ERR_FAIL_COND(!rel_shader_include.is_valid());
+
+ shader_editor->set_block_shader_changed(true);
+ shader_inc->set_code(rel_shader_include->get_code());
+ shader_editor->set_block_shader_changed(false);
+ shader_inc->set_last_modified_time(rel_shader_include->get_last_modified_time());
+ shader_editor->reload_text();
+}
+
+void ShaderEditor::_reload() {
+ if (shader.is_valid()) {
+ _reload_shader_from_disk();
+ } else if (shader_inc.is_valid()) {
+ _reload_shader_include_from_disk();
+ }
+}
+
void ShaderEditor::edit(const Ref<Shader> &p_shader) {
if (p_shader.is_null() || !p_shader->is_text_shader()) {
return;
@@ -561,37 +801,79 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) {
}
shader = p_shader;
+ shader_inc = Ref<ShaderInclude>();
+
+ shader_editor->set_edited_shader(shader);
+}
+
+void ShaderEditor::edit(const Ref<ShaderInclude> &p_shader_inc) {
+ if (p_shader_inc.is_null()) {
+ return;
+ }
+
+ if (shader_inc == p_shader_inc) {
+ return;
+ }
- shader_editor->set_edited_shader(p_shader);
+ shader_inc = p_shader_inc;
+ shader = Ref<Shader>();
- //vertex_editor->set_edited_shader(shader,ShaderLanguage::SHADER_MATERIAL_VERTEX);
- // see if already has it
+ shader_editor->set_edited_shader_include(p_shader_inc);
}
void ShaderEditor::save_external_data(const String &p_str) {
- if (shader.is_null()) {
+ if (shader.is_null() && shader_inc.is_null()) {
disk_changed->hide();
return;
}
apply_shaders();
- if (!shader->is_built_in()) {
- //external shader, save it
+
+ Ref<Shader> edited_shader = shader_editor->get_edited_shader();
+ if (edited_shader.is_valid()) {
+ ResourceSaver::save(edited_shader->get_path(), edited_shader);
+ }
+ if (shader.is_valid() && shader != edited_shader) {
ResourceSaver::save(shader->get_path(), shader);
}
+ Ref<ShaderInclude> edited_shader_inc = shader_editor->get_edited_shader_include();
+ if (edited_shader_inc.is_valid()) {
+ ResourceSaver::save(edited_shader_inc->get_path(), edited_shader_inc);
+ }
+ if (shader_inc.is_valid() && shader_inc != edited_shader_inc) {
+ ResourceSaver::save(shader_inc->get_path(), shader_inc);
+ }
+
disk_changed->hide();
}
+void ShaderEditor::validate_script() {
+ shader_editor->_validate_script();
+}
+
void ShaderEditor::apply_shaders() {
+ String editor_code = shader_editor->get_text_editor()->get_text();
if (shader.is_valid()) {
String shader_code = shader->get_code();
- String editor_code = shader_editor->get_text_editor()->get_text();
- if (shader_code != editor_code) {
+ if (shader_code != editor_code || dependencies_version != shader_editor->get_dependencies_version()) {
+ shader_editor->set_block_shader_changed(true);
shader->set_code(editor_code);
+ shader_editor->set_block_shader_changed(false);
shader->set_edited(true);
}
}
+ if (shader_inc.is_valid()) {
+ String shader_inc_code = shader_inc->get_code();
+ if (shader_inc_code != editor_code || dependencies_version != shader_editor->get_dependencies_version()) {
+ shader_editor->set_block_shader_changed(true);
+ shader_inc->set_code(editor_code);
+ shader_editor->set_block_shader_changed(false);
+ shader_inc->set_edited(true);
+ }
+ }
+
+ dependencies_version = shader_editor->get_dependencies_version();
}
void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
@@ -704,6 +986,9 @@ ShaderEditor::ShaderEditor() {
_update_warnings(false);
shader_editor = memnew(ShaderTextEditor);
+
+ shader_editor->connect("script_validated", callable_mp(this, &ShaderEditor::_script_validated));
+
shader_editor->set_v_size_flags(SIZE_EXPAND_FILL);
shader_editor->add_theme_constant_override("separation", 0);
shader_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
@@ -829,7 +1114,7 @@ ShaderEditor::ShaderEditor() {
dl->set_text(TTR("This shader has been modified on disk.\nWhat action should be taken?"));
vbc->add_child(dl);
- disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk));
+ disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload));
disk_changed->set_ok_button_text(TTR("Reload"));
disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
@@ -844,19 +1129,37 @@ void ShaderEditorPlugin::_update_shader_list() {
shader_list->clear();
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
String text;
- String path = edited_shaders[i].shader->get_path();
- String _class = edited_shaders[i].shader->get_class();
+ String path;
+ String _class;
+ String shader_name;
+ if (edited_shaders[i].shader.is_valid()) {
+ Ref<Shader> shader = edited_shaders[i].shader;
+
+ path = shader->get_path();
+ _class = shader->get_class();
+ shader_name = shader->get_name();
+ } else {
+ Ref<ShaderInclude> shader_inc = edited_shaders[i].shader_inc;
+
+ path = shader_inc->get_path();
+ _class = shader_inc->get_class();
+ shader_name = shader_inc->get_name();
+ }
if (path.is_resource_file()) {
text = path.get_file();
- } else if (edited_shaders[i].shader->get_name() != "") {
- text = edited_shaders[i].shader->get_name();
+ } else if (shader_name != "") {
+ text = shader_name;
} else {
- text = _class + ":" + itos(edited_shaders[i].shader->get_instance_id());
+ if (edited_shaders[i].shader.is_valid()) {
+ text = _class + ":" + itos(edited_shaders[i].shader->get_instance_id());
+ } else {
+ text = _class + ":" + itos(edited_shaders[i].shader_inc->get_instance_id());
+ }
}
if (!shader_list->has_theme_icon(_class, SNAME("EditorIcons"))) {
- _class = "Resource";
+ _class = "TextFile";
}
Ref<Texture2D> icon = shader_list->get_theme_icon(_class, SNAME("EditorIcons"));
@@ -871,38 +1174,70 @@ void ShaderEditorPlugin::_update_shader_list() {
for (int i = 1; i < FILE_MAX; i++) {
file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(i), edited_shaders.size() == 0);
}
+
+ _update_shader_list_status();
}
-void ShaderEditorPlugin::edit(Object *p_object) {
- Shader *s = Object::cast_to<Shader>(p_object);
- for (uint32_t i = 0; i < edited_shaders.size(); i++) {
- if (edited_shaders[i].shader.ptr() == s) {
- // Exists, select.
- shader_tabs->set_current_tab(i);
- shader_list->select(i);
- return;
+void ShaderEditorPlugin::_update_shader_list_status() {
+ for (int i = 0; i < shader_list->get_item_count(); i++) {
+ ShaderEditor *se = Object::cast_to<ShaderEditor>(shader_tabs->get_tab_control(i));
+ if (se) {
+ if (se->was_compilation_successful()) {
+ shader_list->set_item_tag_icon(i, Ref<Texture2D>());
+ } else {
+ shader_list->set_item_tag_icon(i, shader_list->get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
+ }
}
}
- // Add.
+}
+
+void ShaderEditorPlugin::edit(Object *p_object) {
EditedShader es;
- es.shader = Ref<Shader>(s);
- Ref<VisualShader> vs = es.shader;
- if (vs.is_valid()) {
- es.visual_shader_editor = memnew(VisualShaderEditor);
- shader_tabs->add_child(es.visual_shader_editor);
- es.visual_shader_editor->edit(vs.ptr());
- } else {
+
+ ShaderInclude *si = Object::cast_to<ShaderInclude>(p_object);
+ if (si != nullptr) {
+ for (uint32_t i = 0; i < edited_shaders.size(); i++) {
+ if (edited_shaders[i].shader_inc.ptr() == si) {
+ shader_tabs->set_current_tab(i);
+ shader_list->select(i);
+ return;
+ }
+ }
+ es.shader_inc = Ref<ShaderInclude>(si);
es.shader_editor = memnew(ShaderEditor);
+ es.shader_editor->edit(si);
shader_tabs->add_child(es.shader_editor);
- es.shader_editor->edit(s);
+ es.shader_editor->connect("validation_changed", callable_mp(this, &ShaderEditorPlugin::_update_shader_list_status));
+ } else {
+ Shader *s = Object::cast_to<Shader>(p_object);
+ for (uint32_t i = 0; i < edited_shaders.size(); i++) {
+ if (edited_shaders[i].shader.ptr() == s) {
+ shader_tabs->set_current_tab(i);
+ shader_list->select(i);
+ return;
+ }
+ }
+ es.shader = Ref<Shader>(s);
+ Ref<VisualShader> vs = es.shader;
+ if (vs.is_valid()) {
+ es.visual_shader_editor = memnew(VisualShaderEditor);
+ shader_tabs->add_child(es.visual_shader_editor);
+ es.visual_shader_editor->edit(vs.ptr());
+ } else {
+ es.shader_editor = memnew(ShaderEditor);
+ shader_tabs->add_child(es.shader_editor);
+ es.shader_editor->edit(s);
+ es.shader_editor->connect("validation_changed", callable_mp(this, &ShaderEditorPlugin::_update_shader_list_status));
+ }
}
+
shader_tabs->set_current_tab(shader_tabs->get_tab_count() - 1);
edited_shaders.push_back(es);
_update_shader_list();
}
bool ShaderEditorPlugin::handles(Object *p_object) const {
- return Object::cast_to<Shader>(p_object) != nullptr;
+ return Object::cast_to<Shader>(p_object) != nullptr || Object::cast_to<ShaderInclude>(p_object) != nullptr;
}
void ShaderEditorPlugin::make_visible(bool p_visible) {
@@ -949,6 +1284,9 @@ void ShaderEditorPlugin::apply_changes() {
}
void ShaderEditorPlugin::_shader_selected(int p_index) {
+ if (edited_shaders[p_index].shader_editor) {
+ edited_shaders[p_index].shader_editor->validate_script();
+ }
shader_tabs->set_current_tab(p_index);
}
@@ -975,31 +1313,56 @@ void ShaderEditorPlugin::_resource_saved(Object *obj) {
void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
switch (p_index) {
case FILE_NEW: {
- String base_path = FileSystemDock::get_singleton()->get_current_path();
+ String base_path = FileSystemDock::get_singleton()->get_current_path().get_base_dir();
shader_create_dialog->config(base_path.plus_file("new_shader"), false, false, 0);
shader_create_dialog->popup_centered();
} break;
+ case FILE_NEW_INCLUDE: {
+ String base_path = FileSystemDock::get_singleton()->get_current_path().get_base_dir();
+ shader_create_dialog->config(base_path.plus_file("new_shader"), false, false, 2);
+ shader_create_dialog->popup_centered();
+ } break;
case FILE_OPEN: {
InspectorDock::get_singleton()->open_resource("Shader");
} break;
+ case FILE_OPEN_INCLUDE: {
+ InspectorDock::get_singleton()->open_resource("ShaderInclude");
+ } break;
case FILE_SAVE: {
int index = shader_tabs->get_current_tab();
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
- EditorNode::get_singleton()->save_resource(edited_shaders[index].shader);
+ if (edited_shaders[index].shader.is_valid()) {
+ EditorNode::get_singleton()->save_resource(edited_shaders[index].shader);
+ } else {
+ EditorNode::get_singleton()->save_resource(edited_shaders[index].shader_inc);
+ }
} break;
case FILE_SAVE_AS: {
int index = shader_tabs->get_current_tab();
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
- String path = edited_shaders[index].shader->get_path();
- if (!path.is_resource_file()) {
- path = "";
+ String path;
+ if (edited_shaders[index].shader.is_valid()) {
+ path = edited_shaders[index].shader->get_path();
+ if (!path.is_resource_file()) {
+ path = "";
+ }
+ EditorNode::get_singleton()->save_resource_as(edited_shaders[index].shader, path);
+ } else {
+ path = edited_shaders[index].shader_inc->get_path();
+ if (!path.is_resource_file()) {
+ path = "";
+ }
+ EditorNode::get_singleton()->save_resource_as(edited_shaders[index].shader_inc, path);
}
- EditorNode::get_singleton()->save_resource_as(edited_shaders[index].shader, path);
} break;
case FILE_INSPECT: {
int index = shader_tabs->get_current_tab();
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
- EditorNode::get_singleton()->push_item(edited_shaders[index].shader.ptr());
+ if (edited_shaders[index].shader.is_valid()) {
+ EditorNode::get_singleton()->push_item(edited_shaders[index].shader.ptr());
+ } else {
+ EditorNode::get_singleton()->push_item(edited_shaders[index].shader_inc.ptr());
+ }
} break;
case FILE_CLOSE: {
_close_shader(shader_tabs->get_current_tab());
@@ -1011,6 +1374,10 @@ void ShaderEditorPlugin::_shader_created(Ref<Shader> p_shader) {
EditorNode::get_singleton()->push_item(p_shader.ptr());
}
+void ShaderEditorPlugin::_shader_include_created(Ref<ShaderInclude> p_shader_inc) {
+ EditorNode::get_singleton()->push_item(p_shader_inc.ptr());
+}
+
ShaderEditorPlugin::ShaderEditorPlugin() {
main_split = memnew(HSplitContainer);
@@ -1021,18 +1388,20 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
file_menu = memnew(MenuButton);
file_menu->set_text(TTR("File"));
file_menu->get_popup()->add_item(TTR("New Shader"), FILE_NEW);
+ file_menu->get_popup()->add_item(TTR("New Shader Include"), FILE_NEW_INCLUDE);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_item(TTR("Load Shader"), FILE_OPEN);
- file_menu->get_popup()->add_item(TTR("Save Shader"), FILE_SAVE);
- file_menu->get_popup()->add_item(TTR("Save Shader As"), FILE_SAVE_AS);
+ file_menu->get_popup()->add_item(TTR("Load Shader File"), FILE_OPEN);
+ file_menu->get_popup()->add_item(TTR("Load Shader Include File"), FILE_OPEN_INCLUDE);
+ file_menu->get_popup()->add_item(TTR("Save File"), FILE_SAVE);
+ file_menu->get_popup()->add_item(TTR("Save File As"), FILE_SAVE_AS);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_item(TTR("Open Shader in Inspector"), FILE_INSPECT);
+ file_menu->get_popup()->add_item(TTR("Open File in Inspector"), FILE_INSPECT);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_item(TTR("Close Shader"), FILE_CLOSE);
+ file_menu->get_popup()->add_item(TTR("Close File"), FILE_CLOSE);
file_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditorPlugin::_menu_item_pressed));
file_hb->add_child(file_menu);
- for (int i = 1; i < FILE_MAX; i++) {
+ for (int i = 2; i < FILE_MAX; i++) {
file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(i), true);
}
@@ -1060,6 +1429,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
shader_create_dialog = memnew(ShaderCreateDialog);
vb->add_child(shader_create_dialog);
shader_create_dialog->connect("shader_created", callable_mp(this, &ShaderEditorPlugin::_shader_created));
+ shader_create_dialog->connect("shader_include_created", callable_mp(this, &ShaderEditorPlugin::_shader_include_created));
}
ShaderEditorPlugin::~ShaderEditorPlugin() {
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index 2e0dbe0d60..907de6ea87 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -40,6 +40,7 @@
#include "scene/gui/text_edit.h"
#include "scene/main/timer.h"
#include "scene/resources/shader.h"
+#include "scene/resources/shader_include.h"
#include "servers/rendering/shader_warnings.h"
class ItemList;
@@ -59,12 +60,18 @@ class ShaderTextEditor : public CodeTextEditor {
Ref<CodeHighlighter> syntax_highlighter;
RichTextLabel *warnings_panel = nullptr;
Ref<Shader> shader;
+ Ref<ShaderInclude> shader_inc;
List<ShaderWarning> warnings;
Error last_compile_result = Error::OK;
void _check_shader_mode();
void _update_warning_panel();
+ bool block_shader_changed = false;
+ void _shader_changed();
+
+ uint32_t dependencies_version = 0; // Incremented if deps changed
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -73,13 +80,23 @@ protected:
virtual void _code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options) override;
public:
+ void set_block_shader_changed(bool p_block) { block_shader_changed = p_block; }
+ uint32_t get_dependencies_version() const { return dependencies_version; }
+
virtual void _validate_script() override;
void reload_text();
void set_warnings_panel(RichTextLabel *p_warnings_panel);
Ref<Shader> get_edited_shader() const;
+ Ref<ShaderInclude> get_edited_shader_include() const;
+
void set_edited_shader(const Ref<Shader> &p_shader);
+ void set_edited_shader(const Ref<Shader> &p_shader, const String &p_code);
+ void set_edited_shader_include(const Ref<ShaderInclude> &p_include);
+ void set_edited_shader_include(const Ref<ShaderInclude> &p_include, const String &p_code);
+ void set_edited_code(const String &p_code);
+
ShaderTextEditor();
};
@@ -126,38 +143,50 @@ class ShaderEditor : public PanelContainer {
ConfirmationDialog *disk_changed = nullptr;
ShaderTextEditor *shader_editor = nullptr;
+ bool compilation_success = true;
void _menu_option(int p_option);
mutable Ref<Shader> shader;
+ mutable Ref<ShaderInclude> shader_inc;
void _editor_settings_changed();
void _project_settings_changed();
void _check_for_external_edit();
void _reload_shader_from_disk();
+ void _reload_shader_include_from_disk();
+ void _reload();
void _show_warnings_panel(bool p_show);
void _warning_clicked(Variant p_line);
void _update_warnings(bool p_validate);
+ void _script_validated(bool p_valid) {
+ compilation_success = p_valid;
+ emit_signal(SNAME("validation_changed"));
+ }
+
+ uint32_t dependencies_version = 0xFFFFFFFF;
+
protected:
void _notification(int p_what);
static void _bind_methods();
void _make_context_menu(bool p_selection, Vector2 p_position);
- void _text_edit_gui_input(const Ref<InputEvent> &ev);
+ void _text_edit_gui_input(const Ref<InputEvent> &p_ev);
void _update_bookmark_list();
void _bookmark_item_pressed(int p_idx);
public:
+ bool was_compilation_successful() const { return compilation_success; }
void apply_shaders();
-
void ensure_select_current();
void edit(const Ref<Shader> &p_shader);
-
+ void edit(const Ref<ShaderInclude> &p_shader_inc);
void goto_line_selection(int p_line, int p_begin, int p_end);
+ void save_external_data(const String &p_str = "");
+ void validate_script();
virtual Size2 get_minimum_size() const override { return Size2(0, 200); }
- void save_external_data(const String &p_str = "");
ShaderEditor();
};
@@ -167,6 +196,7 @@ class ShaderEditorPlugin : public EditorPlugin {
struct EditedShader {
Ref<Shader> shader;
+ Ref<ShaderInclude> shader_inc;
ShaderEditor *shader_editor = nullptr;
VisualShaderEditor *visual_shader_editor = nullptr;
};
@@ -175,7 +205,9 @@ class ShaderEditorPlugin : public EditorPlugin {
enum {
FILE_NEW,
+ FILE_NEW_INCLUDE,
FILE_OPEN,
+ FILE_OPEN_INCLUDE,
FILE_SAVE,
FILE_SAVE_AS,
FILE_INSPECT,
@@ -199,6 +231,8 @@ class ShaderEditorPlugin : public EditorPlugin {
void _close_shader(int p_index);
void _shader_created(Ref<Shader> p_shader);
+ void _shader_include_created(Ref<ShaderInclude> p_shader_inc);
+ void _update_shader_list_status();
public:
virtual String get_name() const override { return "Shader"; }
@@ -218,4 +252,4 @@ public:
~ShaderEditorPlugin();
};
-#endif
+#endif // SHADER_EDITOR_PLUGIN_H
diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h
index 8e3dc19c7e..b87f108bd2 100644
--- a/editor/plugins/sprite_2d_editor_plugin.h
+++ b/editor/plugins/sprite_2d_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SPRITE_EDITOR_PLUGIN_H
-#define SPRITE_EDITOR_PLUGIN_H
+#ifndef SPRITE_2D_EDITOR_PLUGIN_H
+#define SPRITE_2D_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/2d/sprite_2d.h"
@@ -111,4 +111,4 @@ public:
~Sprite2DEditorPlugin();
};
-#endif // SPRITE_EDITOR_PLUGIN_H
+#endif // SPRITE_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/texture_3d_editor_plugin.h b/editor/plugins/texture_3d_editor_plugin.h
index 2f7f6f83bb..357bdb0845 100644
--- a/editor/plugins/texture_3d_editor_plugin.h
+++ b/editor/plugins/texture_3d_editor_plugin.h
@@ -91,4 +91,4 @@ public:
Texture3DEditorPlugin();
};
-#endif // TEXTURE_EDITOR_PLUGIN_H
+#endif // TEXTURE_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/texture_layered_editor_plugin.h b/editor/plugins/texture_layered_editor_plugin.h
index 830916e954..f49aa83eb2 100644
--- a/editor/plugins/texture_layered_editor_plugin.h
+++ b/editor/plugins/texture_layered_editor_plugin.h
@@ -93,4 +93,4 @@ public:
TextureLayeredEditorPlugin();
};
-#endif // TEXTURE_EDITOR_PLUGIN_H
+#endif // TEXTURE_LAYERED_EDITOR_PLUGIN_H
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index afd29ae8e5..744ed1f1a2 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -2492,6 +2492,7 @@ void ThemeTypeEditor::_update_type_items() {
if (E.value) {
item_editor->set_pick_color(edited_theme->get_color(E.key, edited_type));
item_editor->connect("color_changed", callable_mp(this, &ThemeTypeEditor::_color_item_changed), varray(E.key));
+ item_editor->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(item_editor->get_picker()));
} else {
item_editor->set_pick_color(Theme::get_default()->get_color(E.key, edited_type));
item_editor->set_disabled(true);
diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h
index ff46b7871f..196a642283 100644
--- a/editor/plugins/tiles/tile_atlas_view.h
+++ b/editor/plugins/tiles/tile_atlas_view.h
@@ -158,4 +158,4 @@ public:
TileAtlasView();
};
-#endif // TILE_ATLAS_VIEW
+#endif // TILE_ATLAS_VIEW_H
diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h
index ff586ebbfe..605fbe4823 100644
--- a/editor/plugins/tiles/tile_map_editor.h
+++ b/editor/plugins/tiles/tile_map_editor.h
@@ -377,4 +377,4 @@ public:
static Vector<Vector2i> get_line(TileMap *p_tile_map, Vector2i p_from_cell, Vector2i p_to_cell);
};
-#endif // TILE_MAP_EDITOR_PLUGIN_H
+#endif // TILE_MAP_EDITOR_H
diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h
index e633de37b0..c45240043e 100644
--- a/editor/plugins/tiles/tile_set_editor.h
+++ b/editor/plugins/tiles/tile_set_editor.h
@@ -108,4 +108,4 @@ public:
~TileSetEditor();
};
-#endif // TILE_SET_EDITOR_PLUGIN_H
+#endif // TILE_SET_EDITOR_H
diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h
index 657bfca032..77a583e522 100644
--- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h
+++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h
@@ -142,4 +142,4 @@ public:
~TileSetScenesCollectionSourceEditor();
};
-#endif
+#endif // TILE_SET_SCENES_COLLECTION_SOURCE_EDITOR_H
diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp
index 419d0ffcfc..97553578ba 100644
--- a/editor/plugins/tiles/tiles_editor_plugin.cpp
+++ b/editor/plugins/tiles/tiles_editor_plugin.cpp
@@ -226,14 +226,14 @@ void TilesEditorPlugin::synchronize_sources_list(Object *p_current_list, Object
}
if (item_list->is_visible_in_tree()) {
+ // Make sure the selection is not overwritten after sorting.
+ int atlas_sources_lists_current_mem = atlas_sources_lists_current;
+ item_list->emit_signal(SNAME("sort_request"));
+ atlas_sources_lists_current = atlas_sources_lists_current_mem;
+
if (atlas_sources_lists_current < 0 || atlas_sources_lists_current >= item_list->get_item_count()) {
item_list->deselect_all();
} else {
- // Make sure the selection is not overwritten after sorting.
- int atlas_sources_lists_current_mem = atlas_sources_lists_current;
- item_list->emit_signal(SNAME("sort_request"));
- atlas_sources_lists_current = atlas_sources_lists_current_mem;
-
item_list->set_current(atlas_sources_lists_current);
item_list->ensure_current_is_visible();
item_list->emit_signal(SNAME("item_selected"), atlas_sources_lists_current);
diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h
index 39a56de772..fa721268ba 100644
--- a/editor/plugins/version_control_editor_plugin.h
+++ b/editor/plugins/version_control_editor_plugin.h
@@ -148,4 +148,4 @@ public:
VARIANT_ENUM_CAST(VersionControlEditorPlugin::ChangeType);
-#endif // !VERSION_CONTROL_EDITOR_PLUGIN_H
+#endif // VERSION_CONTROL_EDITOR_PLUGIN_H
diff --git a/editor/plugins/voxel_gi_editor_plugin.h b/editor/plugins/voxel_gi_editor_plugin.h
index 621e98beef..43d6f71e26 100644
--- a/editor/plugins/voxel_gi_editor_plugin.h
+++ b/editor/plugins/voxel_gi_editor_plugin.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VOXEL_GIEDITORPLUGIN_H
-#define VOXEL_GIEDITORPLUGIN_H
+#ifndef VOXEL_GI_EDITOR_PLUGIN_H
+#define VOXEL_GI_EDITOR_PLUGIN_H
#include "editor/editor_plugin.h"
#include "scene/3d/voxel_gi.h"
@@ -71,4 +71,4 @@ public:
~VoxelGIEditorPlugin();
};
-#endif // VOXEL_GIEDITORPLUGIN_H
+#endif // VOXEL_GI_EDITOR_PLUGIN_H
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 49707355a0..077dfc60c0 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -31,7 +31,6 @@
#include "project_settings_editor.h"
#include "core/config/project_settings.h"
-#include "editor/editor_export.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 0693294316..86b6e4c6a5 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -43,7 +43,6 @@
#include "editor/array_property_edit.h"
#include "editor/create_dialog.h"
#include "editor/dictionary_property_edit.h"
-#include "editor/editor_export.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_file_system.h"
#include "editor/editor_help.h"
@@ -828,13 +827,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
value_vbox->add_child(color_picker);
color_picker->hide();
color_picker->connect("color_changed", callable_mp(this, &CustomPropertyEditor::_color_changed));
-
- // get default color picker mode from editor settings
- int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
- color_picker->set_color_mode((ColorPicker::ColorModeType)default_color_mode);
-
- int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
- color_picker->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
+ color_picker->connect("show", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker), varray(color_picker));
}
color_picker->show();
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 3230834d00..27d1cabc3d 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -181,4 +181,4 @@ public:
CustomPropertyEditor();
};
-#endif
+#endif // PROPERTY_EDITOR_H
diff --git a/editor/property_selector.h b/editor/property_selector.h
index f42f5daa3f..e2bf5c02b7 100644
--- a/editor/property_selector.h
+++ b/editor/property_selector.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PROPERTYSELECTOR_H
-#define PROPERTYSELECTOR_H
+#ifndef PROPERTY_SELECTOR_H
+#define PROPERTY_SELECTOR_H
#include "editor/editor_help.h"
#include "editor/property_editor.h"
@@ -80,4 +80,4 @@ public:
PropertySelector();
};
-#endif // PROPERTYSELECTOR_H
+#endif // PROPERTY_SELECTOR_H
diff --git a/editor/register_exporters.h b/editor/register_exporters.h
index 09076af978..9aa98f509f 100644
--- a/editor/register_exporters.h
+++ b/editor/register_exporters.h
@@ -33,4 +33,4 @@
void register_exporters();
-#endif
+#endif // REGISTER_EXPORTERS_H
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index be37d50a2e..ca1771bedf 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -72,7 +72,7 @@ void SceneTreeDock::input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && (mb->get_button_index() == MouseButton::LEFT || mb->get_button_index() == MouseButton::RIGHT)) {
- if (mb->is_pressed() && scene_tree->get_rect().has_point(mb->get_position())) {
+ if (mb->is_pressed() && scene_tree->get_rect().has_point(scene_tree->get_local_mouse_position())) {
tree_clicked = true;
} else if (!mb->is_pressed()) {
tree_clicked = false;
@@ -1337,14 +1337,14 @@ void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root
UndoRedo *undo_redo = &editor_data->get_undo_redo();
switch (p_mode) {
case MODE_BIDI: {
- bool is_unique = p_node->is_unique_name_in_owner() && p_base->get_node_or_null(UNIQUE_NODE_PREFIX + String(p_node->get_name())) != nullptr;
- if (is_unique) {
+ bool disable_unique = p_node->is_unique_name_in_owner() && p_root->get_node_or_null(UNIQUE_NODE_PREFIX + String(p_node->get_name())) != nullptr;
+ if (disable_unique) {
// Will create a unique name conflict. Disable before setting owner.
undo_redo->add_do_method(p_node, "set_unique_name_in_owner", false);
}
undo_redo->add_do_method(p_node, "set_owner", p_root);
undo_redo->add_undo_method(p_node, "set_owner", p_base);
- if (is_unique) {
+ if (disable_unique) {
// Will create a unique name conflict. Enable after setting owner.
undo_redo->add_undo_method(p_node, "set_unique_name_in_owner", true);
}
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index dc7f3476ee..e15865036b 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -33,8 +33,8 @@
#include "editor/create_dialog.h"
#include "editor/editor_data.h"
+#include "editor/editor_quick_open.h"
#include "editor/groups_editor.h"
-#include "editor/quick_open.h"
#include "editor/reparent_dialog.h"
#include "editor/script_create_dialog.h"
#include "scene/animation/animation_player.h"
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index 31a14e4667..31772e55b5 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -192,4 +192,4 @@ public:
~SceneTreeDialog();
};
-#endif
+#endif // SCENE_TREE_EDITOR_H
diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp
index 28e1e9bf22..7ae03ee96f 100644
--- a/editor/shader_create_dialog.cpp
+++ b/editor/shader_create_dialog.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_scale.h"
+#include "scene/resources/shader_include.h"
#include "scene/resources/visual_shader.h"
#include "servers/rendering/shader_types.h"
@@ -43,15 +44,15 @@ void ShaderCreateDialog::_notification(int p_what) {
String last_lang = EditorSettings::get_singleton()->get_project_metadata("shader_setup", "last_selected_language", "");
if (!last_lang.is_empty()) {
- for (int i = 0; i < language_menu->get_item_count(); i++) {
- if (language_menu->get_item_text(i) == last_lang) {
- language_menu->select(i);
- current_language = i;
+ for (int i = 0; i < type_menu->get_item_count(); i++) {
+ if (type_menu->get_item_text(i) == last_lang) {
+ type_menu->select(i);
+ current_type = i;
break;
}
}
} else {
- language_menu->select(default_language);
+ type_menu->select(default_type);
}
current_mode = EditorSettings::get_singleton()->get_project_metadata("shader_setup", "last_selected_mode", 0);
@@ -67,12 +68,17 @@ void ShaderCreateDialog::_notification(int p_what) {
void ShaderCreateDialog::_update_theme() {
Ref<Texture2D> shader_icon = gc->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"));
if (shader_icon.is_valid()) {
- language_menu->set_item_icon(0, shader_icon);
+ type_menu->set_item_icon(0, shader_icon);
}
Ref<Texture2D> visual_shader_icon = gc->get_theme_icon(SNAME("VisualShader"), SNAME("EditorIcons"));
if (visual_shader_icon.is_valid()) {
- language_menu->set_item_icon(1, visual_shader_icon);
+ type_menu->set_item_icon(1, visual_shader_icon);
+ }
+
+ Ref<Texture2D> include_icon = gc->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
+ if (include_icon.is_valid()) {
+ type_menu->set_item_icon(2, include_icon);
}
path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
@@ -80,7 +86,7 @@ void ShaderCreateDialog::_update_theme() {
}
void ShaderCreateDialog::_update_language_info() {
- language_data.clear();
+ type_data.clear();
for (int i = 0; i < SHADER_TYPE_MAX; i++) {
ShaderTypeData data;
@@ -88,12 +94,15 @@ void ShaderCreateDialog::_update_language_info() {
data.use_templates = true;
data.extensions.push_back("gdshader");
data.default_extension = "gdshader";
+ } else if (i == int(SHADER_TYPE_INC)) {
+ data.extensions.push_back("gdshaderinc");
+ data.default_extension = "gdshaderinc";
} else {
data.default_extension = "tres";
}
data.extensions.push_back("res");
data.extensions.push_back("tres");
- language_data.push_back(data);
+ type_data.push_back(data);
}
}
@@ -136,69 +145,97 @@ void ShaderCreateDialog::ok_pressed() {
void ShaderCreateDialog::_create_new() {
Ref<Resource> shader;
-
- if (language_menu->get_selected() == int(SHADER_TYPE_TEXT)) {
- Ref<Shader> text_shader;
- text_shader.instantiate();
- shader = text_shader;
-
- StringBuilder code;
- code += vformat("shader_type %s;\n", mode_menu->get_text().replace(" ", "").camelcase_to_underscore());
-
- if (current_template == 0) { // Default template.
- code += "\n";
- switch (current_mode) {
- case Shader::MODE_SPATIAL:
- code += "void fragment() {\n";
- code += "\t// Place fragment code here.\n";
- code += "}\n";
- break;
- case Shader::MODE_CANVAS_ITEM:
- code += "void fragment() {\n";
- code += "\t// Place fragment code here.\n";
- code += "}\n";
- break;
- case Shader::MODE_PARTICLES:
- code += "void start() {\n";
- code += "\t// Place start code here.\n";
- code += "}\n";
- code += "\n";
- code += "void process() {\n";
- code += "\t// Place process code here.\n";
- code += "}\n";
- break;
- case Shader::MODE_SKY:
- code += "void sky() {\n";
- code += "\t// Place sky code here.\n";
- code += "}\n";
- break;
- case Shader::MODE_FOG:
- code += "void fog() {\n";
- code += "\t// Place fog code here.\n";
- code += "}\n";
- break;
+ Ref<Resource> shader_inc;
+
+ switch (type_menu->get_selected()) {
+ case SHADER_TYPE_TEXT: {
+ Ref<Shader> text_shader;
+ text_shader.instantiate();
+ shader = text_shader;
+
+ StringBuilder code;
+ code += vformat("shader_type %s;\n", mode_menu->get_text().replace(" ", "").camelcase_to_underscore());
+
+ if (current_template == 0) { // Default template.
+ code += "\n";
+ switch (current_mode) {
+ case Shader::MODE_SPATIAL:
+ code += "void fragment() {\n";
+ code += "\t// Place fragment code here.\n";
+ code += "}\n";
+ break;
+ case Shader::MODE_CANVAS_ITEM:
+ code += "void fragment() {\n";
+ code += "\t// Place fragment code here.\n";
+ code += "}\n";
+ break;
+ case Shader::MODE_PARTICLES:
+ code += "void start() {\n";
+ code += "\t// Place start code here.\n";
+ code += "}\n";
+ code += "\n";
+ code += "void process() {\n";
+ code += "\t// Place process code here.\n";
+ code += "}\n";
+ break;
+ case Shader::MODE_SKY:
+ code += "void sky() {\n";
+ code += "\t// Place sky code here.\n";
+ code += "}\n";
+ break;
+ case Shader::MODE_FOG:
+ code += "void fog() {\n";
+ code += "\t// Place fog code here.\n";
+ code += "}\n";
+ break;
+ }
}
- }
- text_shader->set_code(code.as_string());
- } else {
- Ref<VisualShader> visual_shader;
- visual_shader.instantiate();
- shader = visual_shader;
- visual_shader->set_mode(Shader::Mode(current_mode));
+ text_shader->set_code(code.as_string());
+ } break;
+ case SHADER_TYPE_VISUAL: {
+ Ref<VisualShader> visual_shader;
+ visual_shader.instantiate();
+ shader = visual_shader;
+ visual_shader->set_mode(Shader::Mode(current_mode));
+ } break;
+ case SHADER_TYPE_INC: {
+ Ref<ShaderInclude> include;
+ include.instantiate();
+ shader_inc = include;
+ } break;
+ default: {
+ } break;
}
- if (!is_built_in) {
+ if (shader.is_null()) {
String lpath = ProjectSettings::get_singleton()->localize_path(file_path->get_text());
- shader->set_path(lpath);
- Error err = ResourceSaver::save(lpath, shader, ResourceSaver::FLAG_CHANGE_PATH);
- if (err != OK) {
- alert->set_text(TTR("Error - Could not create shader in filesystem."));
+ shader_inc->set_path(lpath);
+
+ Error error = ResourceSaver::save(lpath, shader_inc, ResourceSaver::FLAG_CHANGE_PATH);
+ if (error != OK) {
+ alert->set_text(TTR("Error - Could not create shader include in filesystem."));
alert->popup_centered();
return;
}
+
+ emit_signal(SNAME("shader_include_created"), shader_inc);
+ } else {
+ if (!is_built_in) {
+ String lpath = ProjectSettings::get_singleton()->localize_path(file_path->get_text());
+ shader->set_path(lpath);
+
+ Error error = ResourceSaver::save(lpath, shader, ResourceSaver::FLAG_CHANGE_PATH);
+ if (error != OK) {
+ alert->set_text(TTR("Error - Could not create shader in filesystem."));
+ alert->popup_centered();
+ return;
+ }
+ }
+
+ emit_signal(SNAME("shader_created"), shader);
}
- emit_signal(SNAME("shader_created"), shader);
+ file_path->set_text(file_path->get_text().get_base_dir());
hide();
}
@@ -215,9 +252,9 @@ void ShaderCreateDialog::_load_exist() {
hide();
}
-void ShaderCreateDialog::_language_changed(int p_language) {
- current_language = p_language;
- ShaderTypeData data = language_data[p_language];
+void ShaderCreateDialog::_type_changed(int p_language) {
+ current_type = p_language;
+ ShaderTypeData data = type_data[p_language];
String selected_ext = "." + data.default_extension;
String path = file_path->get_text();
@@ -238,6 +275,8 @@ void ShaderCreateDialog::_language_changed(int p_language) {
_path_changed(path);
file_path->set_text(path);
+ type_menu->set_item_disabled(int(SHADER_TYPE_INC), load_enabled);
+ mode_menu->set_disabled(p_language == SHADER_TYPE_INC);
template_menu->set_disabled(!data.use_templates);
template_menu->clear();
@@ -253,7 +292,7 @@ void ShaderCreateDialog::_language_changed(int p_language) {
template_menu->add_item(TTR("N/A"));
}
- EditorSettings::get_singleton()->set_project_metadata("shader_setup", "last_selected_language", language_menu->get_item_text(language_menu->get_selected()));
+ EditorSettings::get_singleton()->set_project_metadata("shader_setup", "last_selected_language", type_menu->get_item_text(type_menu->get_selected()));
_update_dialog();
}
@@ -275,7 +314,7 @@ void ShaderCreateDialog::_browse_path() {
file_browse->set_disable_overwrite_warning(true);
file_browse->clear_filters();
- List<String> extensions = language_data[language_menu->get_selected()].extensions;
+ List<String> extensions = type_data[type_menu->get_selected()].extensions;
for (const String &E : extensions) {
file_browse->add_filter("*." + E);
@@ -330,8 +369,8 @@ void ShaderCreateDialog::_path_submitted(const String &p_path) {
void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled, int p_preferred_type, int p_preferred_mode) {
if (!p_base_path.is_empty()) {
initial_base_path = p_base_path.get_basename();
- file_path->set_text(initial_base_path + "." + language_data[language_menu->get_selected()].default_extension);
- current_language = language_menu->get_selected();
+ file_path->set_text(initial_base_path + "." + type_data[type_menu->get_selected()].default_extension);
+ current_type = type_menu->get_selected();
} else {
initial_base_path = "";
file_path->set_text("");
@@ -342,8 +381,8 @@ void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabl
load_enabled = p_load_enabled;
if (p_preferred_type > -1) {
- language_menu->select(p_preferred_type);
- _language_changed(p_preferred_type);
+ type_menu->select(p_preferred_type);
+ _type_changed(p_preferred_type);
}
if (p_preferred_mode > -1) {
@@ -351,7 +390,7 @@ void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabl
_mode_changed(p_preferred_mode);
}
- _language_changed(current_language);
+ _type_changed(current_type);
_path_changed(file_path->get_text());
}
@@ -384,14 +423,14 @@ String ShaderCreateDialog::_validate_path(const String &p_path) {
HashSet<String> extensions;
for (int i = 0; i < SHADER_TYPE_MAX; i++) {
- for (const String &ext : language_data[i].extensions) {
+ for (const String &ext : type_data[i].extensions) {
if (!extensions.has(ext)) {
extensions.insert(ext);
}
}
}
- ShaderTypeData data = language_data[language_menu->get_selected()];
+ ShaderTypeData data = type_data[type_menu->get_selected()];
bool found = false;
bool match = false;
@@ -399,8 +438,8 @@ String ShaderCreateDialog::_validate_path(const String &p_path) {
for (const String &ext : extensions) {
if (ext.nocasecmp_to(extension) == 0) {
found = true;
- for (const String &lang_ext : language_data[current_language].extensions) {
- if (lang_ext.nocasecmp_to(extension) == 0) {
+ for (const String &type_ext : type_data[current_type].extensions) {
+ if (type_ext.nocasecmp_to(extension) == 0) {
match = true;
break;
}
@@ -504,6 +543,7 @@ void ShaderCreateDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("config", "path", "built_in_enabled", "load_enabled"), &ShaderCreateDialog::config, DEFVAL(true), DEFVAL(true));
ADD_SIGNAL(MethodInfo("shader_created", PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader")));
+ ADD_SIGNAL(MethodInfo("shader_include_created", PropertyInfo(Variant::OBJECT, "shader_include", PROPERTY_HINT_RESOURCE_TYPE, "ShaderInclude")));
}
ShaderCreateDialog::ShaderCreateDialog() {
@@ -547,24 +587,27 @@ ShaderCreateDialog::ShaderCreateDialog() {
vb->add_child(status_panel);
add_child(vb);
- // Language.
+ // Type.
- language_menu = memnew(OptionButton);
- language_menu->set_custom_minimum_size(Size2(250, 0) * EDSCALE);
- language_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- gc->add_child(memnew(Label(TTR("Language:"))));
- gc->add_child(language_menu);
+ type_menu = memnew(OptionButton);
+ type_menu->set_custom_minimum_size(Size2(250, 0) * EDSCALE);
+ type_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ gc->add_child(memnew(Label(TTR("Type:"))));
+ gc->add_child(type_menu);
for (int i = 0; i < SHADER_TYPE_MAX; i++) {
- String language;
+ String type;
bool invalid = false;
switch (i) {
case SHADER_TYPE_TEXT:
- language = "Shader";
- default_language = i;
+ type = "Shader";
+ default_type = i;
break;
case SHADER_TYPE_VISUAL:
- language = "VisualShader";
+ type = "VisualShader";
+ break;
+ case SHADER_TYPE_INC:
+ type = "ShaderInclude";
break;
case SHADER_TYPE_MAX:
invalid = true;
@@ -576,13 +619,13 @@ ShaderCreateDialog::ShaderCreateDialog() {
if (invalid) {
continue;
}
- language_menu->add_item(language);
+ type_menu->add_item(type);
}
- if (default_language >= 0) {
- language_menu->select(default_language);
+ if (default_type >= 0) {
+ type_menu->select(default_type);
}
- current_language = default_language;
- language_menu->connect("item_selected", callable_mp(this, &ShaderCreateDialog::_language_changed));
+ current_type = default_type;
+ type_menu->connect("item_selected", callable_mp(this, &ShaderCreateDialog::_type_changed));
// Modes.
diff --git a/editor/shader_create_dialog.h b/editor/shader_create_dialog.h
index 6737ce4f10..bf031c3601 100644
--- a/editor/shader_create_dialog.h
+++ b/editor/shader_create_dialog.h
@@ -47,6 +47,7 @@ class ShaderCreateDialog : public ConfirmationDialog {
enum ShaderType {
SHADER_TYPE_TEXT,
SHADER_TYPE_VISUAL,
+ SHADER_TYPE_INC,
SHADER_TYPE_MAX,
};
@@ -56,14 +57,14 @@ class ShaderCreateDialog : public ConfirmationDialog {
bool use_templates = false;
};
- List<ShaderTypeData> language_data;
+ List<ShaderTypeData> type_data;
GridContainer *gc = nullptr;
Label *error_label = nullptr;
Label *path_error_label = nullptr;
Label *builtin_warning_label = nullptr;
PanelContainer *status_panel = nullptr;
- OptionButton *language_menu = nullptr;
+ OptionButton *type_menu = nullptr;
OptionButton *mode_menu = nullptr;
OptionButton *template_menu = nullptr;
CheckBox *internal = nullptr;
@@ -79,8 +80,8 @@ class ShaderCreateDialog : public ConfirmationDialog {
bool built_in_enabled = true;
bool load_enabled = false;
bool re_check_path = false;
- int current_language = -1;
- int default_language = -1;
+ int current_type = -1;
+ int default_type = -1;
int current_mode = 0;
int current_template = 0;
@@ -89,7 +90,7 @@ class ShaderCreateDialog : public ConfirmationDialog {
void _path_hbox_sorted();
void _path_changed(const String &p_path = String());
void _path_submitted(const String &p_path = String());
- void _language_changed(int p_language = 0);
+ void _type_changed(int p_type = 0);
void _built_in_toggled(bool p_enabled);
void _template_changed(int p_template = 0);
void _mode_changed(int p_mode = 0);
@@ -113,4 +114,4 @@ public:
ShaderCreateDialog();
};
-#endif
+#endif // SHADER_CREATE_DIALOG_H
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp
index bfabf269bf..26bd3a5979 100644
--- a/editor/shader_globals_editor.cpp
+++ b/editor/shader_globals_editor.cpp
@@ -156,7 +156,7 @@ protected:
pinfo.type = Variant::VECTOR3I;
} break;
case RS::GLOBAL_VAR_TYPE_IVEC4: {
- pinfo.type = Variant::PACKED_INT32_ARRAY;
+ pinfo.type = Variant::VECTOR4I;
} break;
case RS::GLOBAL_VAR_TYPE_RECT2I: {
pinfo.type = Variant::RECT2I;
@@ -171,7 +171,7 @@ protected:
pinfo.type = Variant::VECTOR3I;
} break;
case RS::GLOBAL_VAR_TYPE_UVEC4: {
- pinfo.type = Variant::PACKED_INT32_ARRAY;
+ pinfo.type = Variant::VECTOR4I;
} break;
case RS::GLOBAL_VAR_TYPE_FLOAT: {
pinfo.type = Variant::FLOAT;
@@ -183,7 +183,7 @@ protected:
pinfo.type = Variant::VECTOR3;
} break;
case RS::GLOBAL_VAR_TYPE_VEC4: {
- pinfo.type = Variant::QUATERNION;
+ pinfo.type = Variant::VECTOR4;
} break;
case RS::GLOBAL_VAR_TYPE_RECT2: {
pinfo.type = Variant::RECT2;
@@ -204,7 +204,7 @@ protected:
pinfo.type = Variant::TRANSFORM3D;
} break;
case RS::GLOBAL_VAR_TYPE_MAT4: {
- pinfo.type = Variant::PACKED_INT32_ARRAY;
+ pinfo.type = Variant::PROJECTION;
} break;
case RS::GLOBAL_VAR_TYPE_SAMPLER2D: {
pinfo.type = Variant::OBJECT;