Skip to content

Commit 19d76ff

Browse files
committed
Add EditorInterface methods for Project Settings, Export Dialog, and Asset Lib
1 parent ccf414e commit 19d76ff

File tree

7 files changed

+102
-1
lines changed

7 files changed

+102
-1
lines changed

doc/classes/EditorInterface.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,20 @@
293293
Marks the current scene tab as unsaved.
294294
</description>
295295
</method>
296+
<method name="open_export_dialog">
297+
<return type="void" />
298+
<description>
299+
Opens the project export dialog window.
300+
</description>
301+
</method>
302+
<method name="open_project_settings">
303+
<return type="void" />
304+
<param index="0" name="general_page" type="String" default="&quot;&quot;" />
305+
<param index="1" name="filter" type="String" default="&quot;&quot;" />
306+
<description>
307+
Opens the project settings window at the optionally specified [param general_page], with an optional [param filter] applied.
308+
</description>
309+
</method>
296310
<method name="open_scene_from_path">
297311
<return type="void" />
298312
<param index="0" name="scene_filepath" type="String" />
@@ -467,6 +481,13 @@
467481
Saves the currently active scene as a file at [param path].
468482
</description>
469483
</method>
484+
<method name="search_asset_library">
485+
<return type="void" />
486+
<param index="0" name="filter" type="String" />
487+
<description>
488+
Opens the Editor Asset Library and applies the specified [param filter] to the search bar.
489+
</description>
490+
</method>
470491
<method name="select_file">
471492
<return type="void" />
472493
<param index="0" name="file" type="String" />

editor/asset_library/asset_library_editor_plugin.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,25 @@ void EditorAssetLibrary::disable_community_support() {
16141614
support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false);
16151615
}
16161616

1617+
void EditorAssetLibrary::search(const String &p_filter_str) {
1618+
ERR_FAIL_COND(!is_visible());
1619+
1620+
// If Asset Library hasn't been opened yet, we must wait for the initial request to complete.
1621+
if (!filter->is_editable()) {
1622+
request->connect("request_completed", callable_mp(this, &EditorAssetLibrary::_on_request_completed).bind(p_filter_str), CONNECT_ONE_SHOT);
1623+
} else {
1624+
filter->set_text(p_filter_str);
1625+
filter->emit_signal("text_changed", filter->get_text());
1626+
}
1627+
}
1628+
1629+
void EditorAssetLibrary::_on_request_completed(int p_result, int p_response_code, const PackedStringArray &p_headers, const PackedByteArray &p_body, String p_filter_str) {
1630+
ERR_FAIL_COND_MSG(p_response_code != 200, vformat("Asset Library HTTPRequest returned with response code %s", p_response_code));
1631+
1632+
filter->set_text(p_filter_str);
1633+
filter->emit_signal("text_changed", filter->get_text());
1634+
}
1635+
16171636
void EditorAssetLibrary::_bind_methods() {
16181637
ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
16191638
}
@@ -1832,6 +1851,11 @@ void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
18321851
}
18331852
}
18341853

1854+
void AssetLibraryEditorPlugin::search_assset_library(const String &p_filter) {
1855+
ERR_FAIL_COND_MSG(!is_available(), "Asset Library not availabe on current platform");
1856+
addon_library->search(p_filter);
1857+
}
1858+
18351859
AssetLibraryEditorPlugin::AssetLibraryEditorPlugin() {
18361860
addon_library = memnew(EditorAssetLibrary);
18371861
addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL);

editor/asset_library/asset_library_editor_plugin.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ class EditorAssetLibrary : public PanelContainer {
323323

324324
void _update_asset_items_columns();
325325

326+
void _on_request_completed(int p_result, int p_response_code, const PackedStringArray &p_headers, const PackedByteArray &p_body, String p_search_string);
327+
326328
friend class EditorAssetLibraryItemDescription;
327329
friend class EditorAssetLibraryItem;
328330

@@ -334,6 +336,8 @@ class EditorAssetLibrary : public PanelContainer {
334336
public:
335337
void disable_community_support();
336338

339+
void search(const String &p_filter);
340+
337341
EditorAssetLibrary(bool p_templates_only = false);
338342
};
339343

@@ -354,5 +358,7 @@ class AssetLibraryEditorPlugin : public EditorPlugin {
354358
//virtual Dictionary get_state() const;
355359
//virtual void set_state(const Dictionary& p_state);
356360

361+
void search_assset_library(const String &p_filter);
362+
357363
AssetLibraryEditorPlugin();
358364
};

editor/editor_interface.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
/**************************************************************************/
3030

3131
#include "editor_interface.h"
32+
#include "core/string/print_string.h"
3233
#include "editor_interface.compat.inc"
3334

3435
#include "core/config/project_settings.h"
3536
#include "core/io/resource_loader.h"
37+
#include "editor/asset_library/asset_library_editor_plugin.h"
3638
#include "editor/docks/filesystem_dock.h"
3739
#include "editor/docks/inspector_dock.h"
3840
#include "editor/editor_main_screen.h"
@@ -52,12 +54,15 @@
5254
#include "editor/settings/editor_command_palette.h"
5355
#include "editor/settings/editor_feature_profile.h"
5456
#include "editor/settings/editor_settings.h"
57+
#include "editor/settings/project_settings_editor.h"
5558
#include "editor/themes/editor_scale.h"
5659
#include "main/main.h"
5760
#include "scene/3d/light_3d.h"
5861
#include "scene/3d/mesh_instance_3d.h"
5962
#include "scene/gui/box_container.h"
6063
#include "scene/gui/control.h"
64+
#include "scene/gui/line_edit.h"
65+
#include "scene/main/http_request.h"
6166
#include "scene/main/window.h"
6267
#include "scene/resources/packed_scene.h"
6368
#include "scene/resources/theme.h"
@@ -105,6 +110,31 @@ EditorUndoRedoManager *EditorInterface::get_editor_undo_redo() const {
105110
return EditorUndoRedoManager::get_singleton();
106111
}
107112

113+
void EditorInterface::open_project_settings(const String &p_general_page, const String &p_filter) {
114+
ProjectSettingsEditor *project_settings = EditorNode::get_singleton()->get_project_settings();
115+
116+
if (!p_general_page.is_empty()) {
117+
project_settings->set_general_page(p_general_page);
118+
}
119+
if (!p_filter.is_empty()) {
120+
project_settings->set_filter(p_filter);
121+
}
122+
123+
project_settings->popup_project_settings(false);
124+
}
125+
126+
void EditorInterface::open_export_dialog() {
127+
EditorNode::get_singleton()->open_export_dialog();
128+
}
129+
130+
void EditorInterface::search_asset_library(const String &p_filter) {
131+
AssetLibraryEditorPlugin *asset_lib = EditorNode::get_singleton()->get_asset_library();
132+
ERR_FAIL_NULL_MSG(asset_lib, "Asset Library not available.");
133+
134+
set_main_screen_editor("AssetLib");
135+
asset_lib->search_assset_library(p_filter);
136+
}
137+
108138
AABB EditorInterface::_calculate_aabb_for_scene(Node *p_node, AABB &p_scene_aabb) {
109139
MeshInstance3D *mesh_node = Object::cast_to<MeshInstance3D>(p_node);
110140
if (mesh_node && mesh_node->get_mesh().is_valid()) {
@@ -830,6 +860,10 @@ void EditorInterface::_bind_methods() {
830860
ClassDB::bind_method(D_METHOD("get_editor_toaster"), &EditorInterface::get_editor_toaster);
831861
ClassDB::bind_method(D_METHOD("get_editor_undo_redo"), &EditorInterface::get_editor_undo_redo);
832862

863+
ClassDB::bind_method(D_METHOD("open_project_settings", "general_page", "filter"), &EditorInterface::open_project_settings, DEFVAL(""), DEFVAL(""));
864+
ClassDB::bind_method(D_METHOD("open_export_dialog"), &EditorInterface::open_export_dialog);
865+
ClassDB::bind_method(D_METHOD("search_asset_library", "filter"), &EditorInterface::search_asset_library);
866+
833867
ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
834868

835869
ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled);

editor/editor_interface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class EditorSettings;
4848
class EditorToaster;
4949
class EditorUndoRedoManager;
5050
class FileSystemDock;
51+
class LineEdit;
5152
class Mesh;
5253
class Node;
5354
class PropertySelector;
@@ -146,6 +147,10 @@ class EditorInterface : public Object {
146147
String get_current_feature_profile() const;
147148
void set_current_feature_profile(const String &p_profile_name);
148149

150+
void open_project_settings(const String &p_general_page = "", const String &p_filter = "");
151+
void open_export_dialog();
152+
void search_asset_library(const String &p_filter);
153+
149154
// Editor dialogs.
150155

151156
void popup_node_selector(const Callable &p_callback, const TypedArray<StringName> &p_valid_types = TypedArray<StringName>(), Node *p_current_value = nullptr);

editor/editor_node.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7432,6 +7432,10 @@ bool EditorNode::is_editor_dimmed() const {
74327432
return dimmed;
74337433
}
74347434

7435+
void EditorNode::open_export_dialog() {
7436+
project_export->popup_export();
7437+
}
7438+
74357439
void EditorNode::open_export_template_manager() {
74367440
export_template_manager->popup_manager();
74377441
}
@@ -8953,7 +8957,8 @@ EditorNode::EditorNode() {
89538957
TextEditor::register_editor();
89548958

89558959
if (AssetLibraryEditorPlugin::is_available()) {
8956-
add_editor_plugin(memnew(AssetLibraryEditorPlugin));
8960+
asset_library_plugin = memnew(AssetLibraryEditorPlugin);
8961+
add_editor_plugin(asset_library_plugin);
89578962
} else {
89588963
print_verbose("Asset Library not available (due to using Web editor, or SSL support disabled).");
89598964
}

editor/editor_node.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Window;
6464

6565
class AudioStreamImportSettingsDialog;
6666
class AudioStreamPreviewGenerator;
67+
class AssetLibraryEditorPlugin;
6768
class BackgroundProgress;
6869
class DependencyErrorDialog;
6970
class DockSplitContainer;
@@ -275,6 +276,8 @@ class EditorNode : public Node {
275276
ProjectExportDialog *project_export = nullptr;
276277
ProjectSettingsEditor *project_settings_editor = nullptr;
277278

279+
AssetLibraryEditorPlugin *asset_library_plugin = nullptr;
280+
278281
FBXImporterManager *fbx_importer_manager = nullptr;
279282

280283
Vector<EditorPlugin *> editor_plugins;
@@ -795,6 +798,8 @@ class EditorNode : public Node {
795798

796799
ProjectSettingsEditor *get_project_settings() { return project_settings_editor; }
797800

801+
AssetLibraryEditorPlugin *get_asset_library() { return asset_library_plugin; }
802+
798803
void trigger_menu_option(int p_option, bool p_confirmed);
799804
bool has_previous_closed_scenes() const;
800805

@@ -982,6 +987,7 @@ class EditorNode : public Node {
982987
void save_editor_layout_delayed();
983988
void save_default_environment();
984989

990+
void open_export_dialog();
985991
void open_export_template_manager();
986992

987993
void reload_scene(const String &p_path);

0 commit comments

Comments
 (0)